ymake.core.conf 350 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246
  1. # !!! DISCLAIMER! PLEASE DON'T IGNORE !!!
  2. # The FAKEID value is huge hammer. It affects UIDs of all nodes in build graph including, but not limnited to
  3. # any resource fetch (think java contrib), build on any language (C++, Python, Java, Go), any code generation.
  4. # Any build after this change will pay the price:
  5. # - Local builds and Sandbox builds will reload all resources from Sandbox and cached data from YT (if ready).
  6. # - Distributed (YT) cache warmup will take signigicant time to catch up and will need to recache everithing.
  7. # - Autocheck will rebuild and recache everything.
  8. # Use this with extreme care and only change if it is utlimately needed. Consider more specific XXX_FAKEIDs below instead.
  9. FAKEID=3141592653
  10. SANDBOX_FAKEID=${FAKEID}.7600000
  11. CPP_FAKEID=9265081
  12. GO_FAKEID=9056219
  13. ANDROID_FAKEID=8821472
  14. CLANG_TIDY_FAKEID=8625699
  15. CURDIR=.
  16. MODDIR=.
  17. BINDIR=bin:/
  18. SRCDIR=
  19. YMAKE=ymake
  20. ECHO=echo
  21. INCLUDE_EXTS=.h .hh .hpp .rli .cuh .inc .i
  22. CPP_EXT=.cpp
  23. OBJ_SUF=
  24. CFLAGS=
  25. EXTRA_C_FLAGS=
  26. SFLAGS=
  27. AUTOCHECK_BALANCING_OPTIONS=
  28. SO_OTPUTS=no
  29. @import "${CONF_ROOT}/conf/settings.conf"
  30. @import "${CONF_ROOT}/conf/opensource.conf"
  31. @import "${CONF_ROOT}/conf/rules.conf"
  32. @import "${CONF_ROOT}/conf/sysincl.conf"
  33. @import "${CONF_ROOT}/conf/license.conf"
  34. @import "${CONF_ROOT}/conf/ts.conf"
  35. @import "${CONF_ROOT}/conf/docs.conf"
  36. @import "${CONF_ROOT}/conf/project_specific/other.conf"
  37. USE_GLOBAL_CMD=no
  38. when ($OS_WINDOWS != "yes") {
  39. USE_GLOBAL_CMD=yes
  40. }
  41. YMAKE_RESOURCE_BIN=${YMAKE_RESOURCE_GLOBAL}/ymake
  42. YMAKE_RESOURCE_DIR=build/external_resources/ymake
  43. when ($USE_YMAKE_RESOURCE == "yes") {
  44. PEERDIR+=${YMAKE_RESOURCE_DIR}
  45. }
  46. __COMMA__=${comma:""}
  47. ARCADIA_TEST_ROOT=../arcadia_tests_data/
  48. DEFAULT_REQUIREMENTS=network:restricted cpu:1 ram:32
  49. BISON_DATA_DIR=contrib/tools/bison/bison/data
  50. CPP_BISON_SKELS=${BISON_DATA_DIR}/glr.cc ${BISON_DATA_DIR}/lalr1.cc ${BISON_DATA_DIR}/yacc.c ${BISON_DATA_DIR}/stack.hh ${BISON_DATA_DIR}/variant.hh ${BISON_DATA_DIR}/c++.m4 ${BISON_DATA_DIR}/c++-skel.m4
  51. USE_PREBUILT_TOOLS=yes
  52. when ($OPENSOURCE == "yes") {
  53. USE_PREBUILT_TOOLS=no
  54. }
  55. FAIL_PY2=no
  56. _PREBUILT_TOOLS_ROOT=build/prebuilt
  57. _TOOL_PROTOC_GEN_GO=vendor/github.com/golang/protobuf/protoc-gen-go
  58. _TOOL_RESCOMPILER=tools/rescompiler
  59. _TOOL_RESCOMPRESSOR=tools/rescompressor
  60. _TOOL_RORESCOMPILER=tools/rorescompiler
  61. when ($HOST_ARCH_X86_64 == "yes") {
  62. when ($HOST_OS_DARWIN == "yes" || $HOST_OS_LINUX == "yes" || $HOST_OS_WINDOWS == "yes") {
  63. VALID_HOST_PLATFORM_FOR_COMMON_PREBUILT_TOOLS=yes
  64. when ($USE_PREBUILT_TOOLS == "yes" && $ARCH_X86_64 == "yes") {
  65. _TOOL_PROTOC_GEN_GO=${_PREBUILT_TOOLS_ROOT}/vendor/github.com/golang/protobuf/protoc-gen-go
  66. }
  67. }
  68. }
  69. FAIL_MODULE_CMD=$YMAKE_PYTHON ${input:"build/scripts/fail_module_cmd.py"} $TARGET ${kv;hide:"p ER"} ${kv;hide:"pc red"}
  70. when ($TIDY == "yes") {
  71. when ($TIDY_EXPORT_FIXES=="") {
  72. TIDY_EXPORT_FIXES="no"
  73. }
  74. CLANG_TIDY_ARGS=${hide:CLANG_TIDY_FAKEID} $YMAKE_PYTHON ${input:"build/scripts/clang_tidy.py"} "--ymake-python" $YMAKE_PYTHON "--clang-tidy-bin" "$(CLANG_TIDY_BIN)/bin/clang-tidy" "--config-validation-script" ${input:"build/tests/config/clang_tidy/tidy_config_validation.py"} "--testing-src" ${input:SRC} "--source-root" $(SOURCE_ROOT) "--build-root" $(BUILD_ROOT) "--tidy-json" ${output;noauto;suf=${OBJ_CROSS_SUF}${COMPILE_OUT_SUFFIX}.tidyjson:SRC} "--export-fixes" $TIDY_EXPORT_FIXES
  75. CLANG_TIDY_ARGS+="--default-config-file" ${input:DEFAULT_TIDY_CONFIG}
  76. CLANG_TIDY_ARGS+="--project-config-file" ${input:PROJECT_TIDY_CONFIG}
  77. when ($TIDY_CHECKS) {
  78. CLANG_TIDY_ARGS+="--checks=$TIDY_CHECKS"
  79. }
  80. when ($TIDY_HEADER_FILTER) {
  81. CLANG_TIDY_ARGS+="--header-filter=$TIDY_HEADER_FILTER"
  82. }
  83. TIDY_VALUE=USE_CONDITIONAL_SRCS
  84. }
  85. otherwise {
  86. CLANG_TIDY_ARGS=
  87. TIDY_VALUE=
  88. }
  89. # tag:codenav
  90. when ($CODENAVIGATION && $NOCODENAVIGATION != "yes") {
  91. PY_PROGRAM_LINK_EXE=$LINK_EXE ${kv;hide:"pyndex $TARGET"}
  92. YNDEXER_ARGS=$YMAKE_PYTHON ${input:"build/scripts/yndexer.py"} $CPPYNDEXER_RESOURCE_GLOBAL/yndexer 1500 $(SOURCE_ROOT) $ARCADIA_BUILD_ROOT ${input:SRC}
  93. YNDEXER_OUTPUT=${output;noauto;suf=${OBJ_CROSS_SUF}.ydx.pb2:SRC}
  94. }
  95. otherwise {
  96. PY_PROGRAM_LINK_EXE=$LINK_EXE
  97. YNDEXER_ARGS=
  98. YNDEXER_OUTPUT=
  99. }
  100. COVERAGE_FLAGS=
  101. EXTRA_OUTPUT=
  102. when ($CLANG == "yes" || $GCC == "yes") {
  103. when ($BUILD_TYPE == "COVERAGE" || $GCOV_COVERAGE) {
  104. COVERAGE_FLAGS=-fprofile-arcs -ftest-coverage
  105. EXTRA_OUTPUT=${output;noauto;hide;suf=${OBJ_CROSS_SUF}${COMPILE_OUT_SUFFIX}.gcno:SRC}
  106. }
  107. }
  108. when ($OS_CYGWIN == "yes") {
  109. CFLAGS+=-D_LDBL_EQ_DBL=1 -U__STRICT_ANSI__
  110. USE_ASMLIB=no
  111. FSTACK=
  112. }
  113. CFLAGS+=$COVERAGE_FLAGS
  114. LDFLAGS+=$COVERAGE_FLAGS
  115. CHECKFLAG=
  116. LEX_FLAGS=
  117. NO_MAPREDUCE=
  118. when ($NO_MAPREDUCE == "yes") {
  119. C_DEFINES+=-DNO_MAPREDUCE
  120. }
  121. when ($OS_ANDROID == "yes") {
  122. PIE=yes
  123. }
  124. # TODO: extract to conf/maps/maps.conf
  125. when ($MAPSMOBI_BUILD_TARGET == "yes" && $OS_LINUX != "yes") {
  126. USE_STL_SYSTEM=yes
  127. }
  128. when ($MAPSMOBI_BUILD_TARGET == "yes" && $OS_IOS == "yes") {
  129. BUILD_IOS_APP=yes
  130. when ($ARCH_ARM7 || $ARCH_ARM64) {
  131. BOOSTTEST_IS_FAT_OBJECT=yes
  132. }
  133. }
  134. # USE_INTERNAL_STL is an internal flag (set on by default) but may be used externally to
  135. # select system standard C++ library when USE_INTERNAL_STL=no is set.
  136. #
  137. # USE_STL_SYSTEM=yes is a regular way to select system standard C++ library.
  138. #
  139. when ($USE_STL_SYSTEM == "yes") {
  140. USE_INTERNAL_STL=no
  141. }
  142. when ($USE_INTERNAL_STL == "no") {
  143. USE_STL_SYSTEM=yes
  144. }
  145. otherwise {
  146. USE_INTERNAL_STL=yes
  147. # TODO: Extract to conf/sysincl.conf
  148. # This trigger doesn't work for module level since SYSINCL is processed at
  149. # configuration stage (This means that NO_RUNTIME() macro called in ya.make
  150. # won't affect SYSINCL and the only way to make this trigger work correctly
  151. # is to define configuration varaible NORUNTIME (-DNORUNTIME) on the command
  152. # line when `ya make ...` is invoked.
  153. when ($NORUNTIME != "yes") {
  154. SYSINCL+=build/sysincl/stl-to-libcxx.yml
  155. when ($MUSL == "yes") {
  156. SYSINCL+=build/sysincl/libc-musl-libcxx.yml
  157. }
  158. }
  159. }
  160. # tag:linux-specific
  161. when ($OS_LINUX && $OS_SDK == "ubuntu-14" && $MUSL != "yes") {
  162. USE_UBUNTU_COMPATIBILITY=yes
  163. }
  164. USE_ARCADIA_PYTHON=yes
  165. USE_ARCADIA_LIBM=no
  166. USE_EAT_MY_DATA=no
  167. HAVE_MKL=
  168. when ($HAVE_MKL == "") {
  169. when ($OS_LINUX && $ARCH_X86_64 && !$SANITIZER_TYPE) {
  170. HAVE_MKL=yes
  171. }
  172. otherwise {
  173. HAVE_MKL=no
  174. }
  175. }
  176. SFDL_TMP_OUT= ${output;tmp:SRC.tmp}
  177. # tag:perl-specific
  178. when ($USE_LOCAL_TOOLS == "yes") {
  179. PERL=$LOCAL_PERL
  180. PERL_VERSION=$LOCAL_PERL_VERSION
  181. PERL_PRIVLIB=$LOCAL_PERL_PRIVLIB
  182. PERL_ARCHLIB=$LOCAL_PERL_ARCHLIB
  183. when ($LOCAL_PERL_LIBS) {
  184. PERL_LIBS=$LOCAL_PERL_LIBS
  185. }
  186. }
  187. otherwise {
  188. PERL=NO-PERL-SELECTED
  189. PERL_VERSION=NO-PERL-SELECTED-VERSION
  190. PERL_PRIVLIB=NO-PERL-SELECTED-PRIVLIB
  191. PERL_ARCHLIB=NO-PERL-SELECTED-ARCHLIB
  192. }
  193. # tag:perl-specific
  194. PERL_LD_LIBRARY_PATH=
  195. PERL_INCLUDE=
  196. USE_PERL_SYSTEM=yes
  197. when ($USE_PERL_SYSTEM == "yes") {
  198. select ($PERL_SDK) {
  199. "ubuntu-12" ? {
  200. PERL_VERSION=5.14
  201. PERL_ROOT=${SYSTEM_PERL_514_RESOURCE_GLOBAL}/perl${PERL_VERSION}
  202. PERL_LIB_ARCH=
  203. }
  204. "ubuntu-14" ? {
  205. PERL_VERSION=5.18
  206. PERL_ROOT=${SYSTEM_PERL_518_RESOURCE_GLOBAL}/perl${PERL_VERSION}
  207. PERL_LIB_ARCH=
  208. }
  209. "ubuntu-16" ? {
  210. PERL_VERSION=5.22
  211. PERL_ROOT=${SYSTEM_PERL_522_RESOURCE_GLOBAL}/perl${PERL_VERSION}
  212. PERL_LIB_ARCH=/x86_64-linux-gnu
  213. }
  214. "ubuntu-18" ? {
  215. PERL_VERSION=5.26
  216. PERL_ROOT=${SYSTEM_PERL_526_RESOURCE_GLOBAL}/perl${PERL_VERSION}
  217. PERL_LIB_ARCH=/x86_64-linux-gnu
  218. }
  219. "ubuntu-20" ? {
  220. PERL_VERSION=5.30
  221. PERL_ROOT=${SYSTEM_PERL_530_RESOURCE_GLOBAL}/usr
  222. PERL_LIB_ARCH=/x86_64-linux-gnu
  223. }
  224. }
  225. PERL=${PERL_ROOT}/bin/perl
  226. PERL_ARCHLIB=${PERL_ROOT}/lib$PERL_LIB_ARCH/perl/${PERL_VERSION}
  227. PERL_PRIVLIB=${PERL_ROOT}/share/perl/${PERL_VERSION}
  228. PERL_LIBS=${PERL_ROOT}/lib${PERL_LIB_ARCH}
  229. PERL_LD_LIBRARY_PATH=${env:"LD_LIBRARY_PATH=${PERL_ROOT}/lib"}
  230. # Perl searches it's modules in INC@ paths. They can not be sysrooted or disabled (at least I haven't found a way),
  231. # so default Perl module directories should be prepended to perl command lines when using non-local perl.
  232. PERL_INCLUDE=-I${PERL_ARCHLIB} -I${PERL_PRIVLIB}
  233. }
  234. PERL_DEFAULT_PEERDIR=yes
  235. # tag:perl-specific
  236. PERLSUFFIX=-csuffix .cpp
  237. PERLOUTPUT=${stdout;output:SRC.cpp}
  238. when ($PERLC == "yes") {
  239. PERLSUFFIX=-csuffix .c
  240. PERLOUTPUT=${stdout;output:SRC.c}
  241. }
  242. XSUBPPFLAGS=
  243. # tag:tool-specific
  244. ARCH_TOOL=${tool:"tools/archiver"}
  245. # tag:tool-specific tag:proto
  246. PROTOC=${tool:"contrib/tools/protoc"}
  247. PROTOC_STYLEGUIDE_OUT=--cpp_styleguide_out=$ARCADIA_BUILD_ROOT/$PROTO_NAMESPACE
  248. PROTOC_PLUGIN_STYLEGUIDE=--plugin=protoc-gen-cpp_styleguide=${tool:"contrib/tools/protoc/plugins/cpp_styleguide"}
  249. PROTOBUF_PATH=${ARCADIA_ROOT}/contrib/libs/protobuf/src
  250. USE_VANILLA_PROTOC=no
  251. PROTOC_TRANSITIVE_HEADERS=yes
  252. # tag:tool-specific
  253. FML_TOOL=${tool:"tools/relev_fml_codegen"}
  254. FML_UNUSED_TOOL=${tool:"tools/relev_fml_unused"}
  255. LUA_TOOL=${tool:"tools/lua"}
  256. ENUM_PARSER_TOOL=${tool:"tools/enum_parser/enum_parser"}
  257. # tag:python-specific tag:cython-specific
  258. CYTHON_SCRIPT=${input:"${ARCADIA_ROOT}/contrib/tools/cython/cython.py"}
  259. RUN_CYTHON_SCRIPT=$YMAKE_PYTHON $CYTHON_SCRIPT
  260. CYTHON_OUTPUT_INCLUDES=\
  261. ${output_include;hide:"contrib/libs/python/Include/compile.h"} \
  262. ${output_include;hide:"contrib/libs/python/Include/frameobject.h"} \
  263. ${output_include;hide:"contrib/libs/python/Include/longintrepr.h"} \
  264. ${output_include;hide:"contrib/libs/python/Include/pyconfig.h"} \
  265. ${output_include;hide:"contrib/libs/python/Include/Python.h"} \
  266. ${output_include;hide:"contrib/libs/python/Include/pythread.h"} \
  267. ${output_include;hide:"contrib/libs/python/Include/structmember.h"} \
  268. ${output_include;hide:"contrib/libs/python/Include/traceback.h"} \
  269. ${output_include;hide:"contrib/tools/cython/generated_c_headers.h"} \
  270. ${output_include;hide:"omp.h"}
  271. # tag:cython-specific
  272. CYTHON_CPP_OUTPUT_INCLUDES=${output_include;hide:"contrib/tools/cython/generated_cpp_headers.h"}
  273. # tag:cython-specific
  274. CYTHON_OPTIONS=
  275. when ($OS_LINUX) {
  276. CYTHON_OPTIONS += -E UNAME_SYSNAME=Linux
  277. }
  278. elsewhen ($OS_DARWIN) {
  279. CYTHON_OPTIONS += -E UNAME_SYSNAME=Darwin
  280. }
  281. elsewhen ($OS_WINDOWS) {
  282. CYTHON_OPTIONS += -E UNAME_SYSNAME=Windows
  283. }
  284. when ($USE_LOCAL_SWIG != "yes") {
  285. _SWIG_TOOL=${tool:"contrib/tools/swig"}
  286. _SWIG_LIBRARY=contrib/tools/swig/Lib
  287. _SWIG_LIBRARY_ABS=$ARCADIA_ROOT/$_SWIG_LIBRARY
  288. }
  289. otherwise {
  290. _SWIG_TOOL=$SWIG_TOOL
  291. _SWIG_LIBRARY=$SWIG_LIBRARY
  292. _SWIG_LIBRARY_ABS=$SWIG_LIBRARY
  293. }
  294. SWIG_IMPLICIT_INCLUDES = swig.swg go.swg java.swg perl5.swg python.swg
  295. FATAL_ERROR_MODULE=no
  296. FATAL_ERROR_MESSAGE=
  297. # tag:python-specific
  298. # PYTHON_DISTR={ "default" | "macos-brew" } determine python system supply
  299. # see build/platform/python/ya.make
  300. PYTHON_DISTR="default"
  301. when ($USE_SYSTEM_PYTHON) {
  302. USE_ARCADIA_PYTHON=no
  303. select ($USE_SYSTEM_PYTHON) {
  304. "2.7" ? {
  305. _SYSTEM_PYTHON27=yes
  306. PY_VERSION=2.7
  307. PY_FRAMEWORK_VERSION=2.7
  308. }
  309. "3.4" ? {
  310. _SYSTEM_PYTHON34=yes
  311. PY_VERSION=3.4m
  312. PY_FRAMEWORK_VERSION=3.4
  313. }
  314. "3.5" ? {
  315. _SYSTEM_PYTHON35=yes
  316. PY_VERSION=3.5m
  317. PY_FRAMEWORK_VERSION=3.5
  318. }
  319. "3.6" ? {
  320. _SYSTEM_PYTHON36=yes
  321. PY_VERSION=3.6m
  322. PY_FRAMEWORK_VERSION=3.6
  323. }
  324. "3.7" ? {
  325. _SYSTEM_PYTHON37=yes
  326. PY_VERSION=3.7m
  327. PY_FRAMEWORK_VERSION=3.7
  328. }
  329. "3.8" ? {
  330. _SYSTEM_PYTHON38=yes
  331. PY_VERSION=3.8
  332. PY_FRAMEWORK_VERSION=3.8
  333. }
  334. "3.9" ? {
  335. _SYSTEM_PYTHON39=yes
  336. PY_VERSION=3.9
  337. PY_FRAMEWORK_VERSION=3.9
  338. }
  339. "3.10" ? {
  340. _SYSTEM_PYTHON310=yes
  341. PY_VERSION=3.10
  342. PY_FRAMEWORK_VERSION=3.10
  343. }
  344. default ? {
  345. FATAL_ERROR_MESSAGE+=invalid USE_SYSTEM_PYTHON value
  346. }
  347. }
  348. }
  349. ### @usage: NO_LTO()
  350. ###
  351. ### Diasble any lto (link-time optimizations) for the module.
  352. ### This will compile module source files as usual (without LTO) but will not prevent lto-enabled
  353. ### linking of entire program if global settings say so.
  354. macro NO_LTO() {
  355. DISABLE(USE_LTO)
  356. DISABLE(USE_THINLTO)
  357. }
  358. when ($USE_LTO == "yes" && $OS_LINUX != "yes" && $OS_ANDROID != "yes") {
  359. FATAL_ERROR_MESSAGE+=lto is only supported for linux
  360. }
  361. # tag:python-specific
  362. YMAKE_PYTHON3_PEER=build/platform/python/ymake_python3
  363. YMAKE_PYTHON3=$YMAKE_PYTHON3_RESOURCE_GLOBAL/python3
  364. when ($HOST_OS_WINDOWS == "yes") {
  365. YMAKE_PYTHON3=$YMAKE_PYTHON3_RESOURCE_GLOBAL/python3.exe
  366. }
  367. # tag:python-specific
  368. when ($USE_ARCADIA_PYTHON == "no") {
  369. SYSINCL+=build/sysincl/python.yml
  370. }
  371. # tag:allocator
  372. DEFAULT_ALLOCATOR=LF
  373. # tag:allocator
  374. when ($OS_ANDROID == "yes" || $MSVC == "yes") {
  375. DEFAULT_ALLOCATOR=J
  376. }
  377. # tag:allocator
  378. when ($OS_CYGWIN == "yes" || $ARCH_PPC64LE == "yes") {
  379. DEFAULT_ALLOCATOR=SYSTEM
  380. }
  381. # tag:allocator
  382. when ($OS_DARWIN == "yes") {
  383. DEFAULT_ALLOCATOR=SYSTEM
  384. }
  385. # tag:allocator
  386. when ($SANITIZER_TYPE) {
  387. when ($SANITIZER_TYPE != "no") {
  388. DEFAULT_ALLOCATOR=SYSTEM
  389. }
  390. }
  391. # tag:internal
  392. ### @usage: CHECK_CONFIG_H(<conf_header>) # internal
  393. ###
  394. ### This internal macro adds checking code for configuration header in external (contrib) library.
  395. ### The check is needed to avoid conflicts on certain types and functions available in arcadia.
  396. ###
  397. ### @see https://a.yandex-team.ru/arc/trunk/arcadia/build/scripts/check_config_h.py for exact details
  398. macro CHECK_CONFIG_H(Conf) {
  399. .CMD=$YMAKE_PYTHON ${input:"build/scripts/check_config_h.py"} ${input;rootrel:Conf} ${output;nopath;noext:Conf.config.cpp} ${kv;hide:"p CH"} ${kv;hide:"pc yellow"}
  400. OUTPUT_INCLUDES=$Conf
  401. }
  402. REQUIRED_TRANSITIVE_PEERS=
  403. ### @usage REQUIRES(dirs...)
  404. ###
  405. ### Specify list of dirs which this module must depend on indirectly.
  406. ###
  407. ### This macro can be used if module depends on the directories specified but they can't be listed
  408. ### as direct PEERDIR dependencies (due to public include order or link order issues).
  409. macro REQUIRES(DIRS[]) {
  410. SET_APPEND(REQUIRED_TRANSITIVE_PEERS $DIRS)
  411. }
  412. CHECK_DEPENDENT_DIRS_TYPES=
  413. CHECK_DEPENDENT_DIRS_RESTRICTIONS=
  414. ### @usage CHECK_DEPENDENT_DIRS(DENY|ALLOW_ONLY ([ALL|PEERDIRS|GLOB] dir)...)
  415. ###
  416. ### Specify project transitive dependencies constraints.
  417. ###
  418. ### @params:
  419. ### 1. DENY: current module can not depend on module from any specified directory neither directly nor transitively.
  420. ### 2. ALLOW_ONLY: current module can not depend on module from a dir not specified in the directory list neither directly nor transitively.
  421. ### 3. ALL: directory constraints following after this modifier are applied to both transitive PEERDIR dependencies and tool dependencies.
  422. ### 4. PEERDIRS: directory constraints following after this modifier are applied to transitive PEERDIR dependencies only.
  423. ### 5. GLOB: next directory constraint is an ANT glob pattern.
  424. ### 6. EXCEPT: next constraint is an excption for the rest of other rules.
  425. ###
  426. ### Direcory constraints added before either ALL or PEERDIRS modifier is used are treated as ALL directory constraints.
  427. ###
  428. ### Note: Can be used multiple times on the same module all specified constraints will be checked.
  429. ### All macro invocation for the same module must use same constraints type (DENY or ALLOW_ONLY)
  430. macro CHECK_DEPENDENT_DIRS(TYPE, ALL?"UNUSED":"", PEERDIRS?"PEERDIRS":"ALL", RESTRICTIONS...) {
  431. SET_APPEND(CHECK_DEPENDENT_DIRS_RESTRICTIONS $PEERDIRS $RESTRICTIONS)
  432. SET_APPEND(CHECK_DEPENDENT_DIRS_TYPES $TYPE)
  433. }
  434. # tag:proto
  435. PY_PROTOS_FOR=no
  436. BUILD_PROTO_AS_EVLOG=no
  437. # tag:proto
  438. PROTO_NAMESPACE=
  439. # tag:proto tag:python-specific
  440. GEN_PY_PROTOS=$YMAKE_PYTHON ${input:"build/scripts/gen_py_protos.py"}
  441. # tag:proto tag:cpp-specific
  442. PROTO_HEADER_EXTS=.pb.h
  443. CPP_PROTO_CMDLINE=
  444. CPP_PROTO_OPTS=
  445. CPP_PROTO_OUTS=
  446. CPP_PROTO_OUTS_SEM=
  447. CPP_PROTO_SUFFIXES=.pb.h .pb.cc
  448. CPP_PROTO_PLUGINS=
  449. # tag:proto tag:cpp-specific
  450. CPP_EV_OPTS=--plugin=protoc-gen-event2cpp=${tool:"tools/event2cpp"} --event2cpp_out=$ARCADIA_BUILD_ROOT -I=$ARCADIA_ROOT/library/cpp/eventlog
  451. CPP_EV_OUTS=
  452. # tag:proto tag:python-specific
  453. PY_PROTO_OPTS=
  454. PY_PROTO_OUTS=
  455. PY_PROTO_OUTS_INTERNAL=
  456. PY_PROTO_DEPS=
  457. PY_PROTO_SUFFIXES=_pb2.py
  458. PY_EVLOG_SUFFIXES=_ev_pb2.py
  459. # tag:proto tag:java-specific
  460. JAVA_PROTO_ARGS=
  461. # tag:proto tag:python-specific
  462. OPTIMIZE_PY_PROTOS_FLAG=no
  463. macro _RESOURCE_SEM(INPUTS[], KEYS[]) {
  464. SET(RESOURCE_OUTPUT ${hash:INPUTS}.cpp)
  465. .SEM=resources ${output;global:RESOURCE_OUTPUT} INPUTS ${input:INPUTS} KEYS $KEYS ${tool;hide:"tools/rescompiler/bin"}
  466. }
  467. # tag:built-in
  468. ### @usage: RESOURCE([FORCE_TEXT ][Src Key]* [- Key=Value]*) # built-in
  469. ### Add data (resources, random files, strings) to the program)
  470. ### The common usage is to place Src file into binary. The Key is used to access it using library/cpp/resource or library/python/resource.
  471. ### Alternative syntax with '- Key=Value' allows placing Value string as resource data into binary and make it accessible by Key.
  472. ###
  473. ### This is a simpler but less flexible option than ARCHIVE(), because in the case of ARCHIVE(), you have to use the data explicitly,
  474. ### and in the case of RESOURCE(), the data will fall through SRCS() or SRCS(GLOBAL) to binary linking.
  475. ###
  476. ### Use the FORCE_TEXT parameter to explicitly mark all Src files as text files: they will not be parsed unless used elsewhere.
  477. ###
  478. ### @example: https://wiki.yandex-team.ru/yatool/howtowriteyamakefiles/#a2ispolzujjtekomanduresource
  479. ###
  480. ### @example:
  481. ###
  482. ### LIBRARY()
  483. ### OWNER(user1)
  484. ###
  485. ### RESOURCE(
  486. ### path/to/file1 /key/in/program/1
  487. ### path/to/file2 /key2
  488. ### )
  489. ### END()
  490. ###
  491. macro RESOURCE(Args...) {
  492. PEERDIR(library/cpp/resource)
  493. }
  494. # tag:internal
  495. ### @usage: _ORDER_ADDINCL([BUILD ...] [SOURCE ...] Args...) # internal
  496. ###
  497. ### Order and filter ADDINCLs (Args - is intentionally omitted in ADDINCL macro)
  498. macro _ORDER_ADDINCL(BUILD[], SOURCE[], ARGS...) {
  499. ADDINCL($BUILD $SOURCE)
  500. }
  501. # tag:proto
  502. ### @usage: PROTO_ADDINCL([GLOBAL] [WITH_GEN] Path)
  503. ###
  504. ### This macro introduces proper ADDINCLs for .proto-files found in sources and
  505. ### .cpp/.h generated files, supplying them to appropriate commands and allowing
  506. ### proper dependency resolution at configure-time.
  507. ###
  508. ### Note: you normally shouldn't use this macro. ADDINCLs should be sent to user
  509. ### from dependency via PROTO_NAMESPACE macro
  510. macro PROTO_ADDINCL(GLOBAL?"GLOBAL":"", Path, WITH_GEN?"BUILD":"") {
  511. _ORDER_ADDINCL($WITH_GEN $GLOBAL FOR proto ${ARCADIA_BUILD_ROOT}/$Path SOURCE $GLOBAL FOR proto ${ARCADIA_ROOT}/$Path)
  512. ADDINCL($GLOBAL ${ARCADIA_BUILD_ROOT}/$Path)
  513. }
  514. # tag:proto
  515. ### @usage: PROTO_NAMESPACE([GLOBAL] [WITH_GEN] Namespace)
  516. ###
  517. ### Defines protobuf namespace (import/export path prefix) which should be used for imports and
  518. ### which defines output path for .proto generation.
  519. ###
  520. ### For proper importing and configure-time depenedency management it sets ADDINCLs
  521. ### for both .cpp headers includes and .proto imports. If .proto expected to be used outsed of the
  522. ### processing module use GLOBAL to send proper ADDINCLs to all (transitive) users. PEERDIR to
  523. ### PROTO_LIBRARY with PROTO_NAMESPACE(GLOBAL ) is enough at user side to correctly use the library.
  524. ### If generated .proto files are going to be used for building a module than use of WITH_GEN
  525. ### parameter will add appropriate dir from the build root for .proto files search.
  526. macro PROTO_NAMESPACE(GLOBAL?"GLOBAL":"", WITH_GEN?"WITH_GEN":"", Namespace) {
  527. SET(PROTO_NAMESPACE $Namespace)
  528. PROTO_ADDINCL($GLOBAL $WITH_GEN $Namespace)
  529. }
  530. # tag:proto tag:internal tag:python-specific
  531. ### @usage: OPTIMIZE_PY_PROTOS() # internal
  532. ###
  533. ### Enable Python proto optimization by embedding corresponding C++ code into binary.
  534. ### Python protobuf runtime will use C++ implementation instead of Python one if former is available.
  535. ### This is default mode for most PROTO_LIBRARY's and PY2_LIBRARY's, some system ones being exceptions.
  536. macro OPTIMIZE_PY_PROTOS() {
  537. SET(OPTIMIZE_PY_PROTOS_FLAG yes)
  538. }
  539. # tag:proto tag:python-specific
  540. ### @usage: NO_OPTIMIZE_PY_PROTOS()
  541. ###
  542. ### Disable Python proto optimization using embedding corresponding C++ code into binary.
  543. ### Python protobuf runtime will use C++ implementation instead of Python one if former is available.
  544. ### This is default mode only for some system libraries.
  545. macro NO_OPTIMIZE_PY_PROTOS() {
  546. SET(OPTIMIZE_PY_PROTOS_FLAG no)
  547. }
  548. # tag:proto tag:python-specific
  549. macro _PROTO_PLUGIN_ARGS_BASE(Name, Tool, OutParm...) {
  550. .CMD=--plugin=protoc-gen-${Name}=\${tool:"$Tool"} --${Name}_out=$OutParm$ARCADIA_BUILD_ROOT/\$PROTO_NAMESPACE
  551. .SEM=ignored
  552. }
  553. # tag:proto tag:python-specific
  554. macro _ADD_PY_PROTO_OUT(Suf) {
  555. SET_APPEND(PY_PROTO_OUTS \${output;hide;noauto;norel;nopath;noext;suf=$Suf:File})
  556. SET_APPEND(PY_PROTO_OUTS_INTERNAL \${output;hide;noauto;norel;nopath;noext;suf=__int__$Suf:File} \${hide;kv:"ext_out_name_for_\${nopath;noext;suf=__int__$Suf:File} \${nopath;noext;suf=$Suf:File}"})
  557. # XXX fix variable expansion in plugins
  558. SET(PY_PROTO_SUFFIXES $PY_PROTO_SUFFIXES $Suf)
  559. }
  560. # tag:proto tag:python-specific
  561. ### @usage: PY_PROTO_PLUGIN(Name Ext Tool DEPS <Dependencies>)
  562. ###
  563. ### Define protoc plugin for python with given Name that emits extra output with provided Extension
  564. ### using Tool. Extra dependencies are passed via DEPS
  565. macro PY_PROTO_PLUGIN(NAME, EXT, TOOL, DEPS[]) {
  566. SET_APPEND(PY_PROTO_OPTS $_PROTO_PLUGIN_ARGS_BASE($NAME $TOOL))
  567. _ADD_PY_PROTO_OUT($EXT)
  568. # XXX fix variable expansion in plugins
  569. SET(PY_PROTO_DEPS $PY_PROTO_DEPS $DEPS)
  570. }
  571. # tag:proto tag:python-specific
  572. ### @usage: PY_PROTO_PLUGIN2(Name Ext1 Ext2 Tool DEPS <Dependencies>)
  573. ###
  574. ### Define protoc plugin for python with given Name that emits 2 extra outputs with provided Extensions
  575. ### using Tool. Extra dependencies are passed via DEPS
  576. macro PY_PROTO_PLUGIN2(NAME, EXT1, EXT2, TOOL, DEPS[]) {
  577. PY_PROTO_PLUGIN($NAME $EXT1 $TOOL DEPS $DEPS)
  578. _ADD_PY_PROTO_OUT($EXT2)
  579. }
  580. # tag:proto tag:java-specific
  581. macro _JAVA_PROTO_PLUGIN_ARGS_BASE(Name, Tool, OutParm...) {
  582. .CMD=--plugin=protoc-gen-${Name}=\${tool:"$Tool"} --${Name}_out=$ARCADIA_BUILD_ROOT/java_out
  583. }
  584. # tag:proto tag:java-specific
  585. ### @usage: JAVA_PROTO_PLUGIN(Name Tool DEPS <Dependencies>)
  586. ###
  587. ### Define protoc plugin for Java with given Name that emits extra outputs
  588. ### using Tool. Extra dependencies are passed via DEPS
  589. macro JAVA_PROTO_PLUGIN(NAME, TOOL, DEPS[]) {
  590. SET_APPEND(JAVA_PROTO_ARGS $_JAVA_PROTO_PLUGIN_ARGS_BASE($NAME $TOOL))
  591. # XXX fix variable expansion in plugins
  592. SET(JAVA_PROTOBUF_PEERS $JAVA_PROTOBUF_PEERS $DEPS)
  593. }
  594. # tag:proto tag:cpp-specific
  595. macro _ADD_CPP_PROTO_OUT(Suf) {
  596. .SEM=append_target_property PROTOC_EXTRA_OUTS $Suf ${output;hide;suf=.o:Suf}
  597. SET_APPEND(CPP_PROTO_OUTS \${output;hide;norel;nopath;noext;suf=$Suf:File})
  598. # XXX fix variable expansion in plugins
  599. SET(CPP_PROTO_SUFFIXES $CPP_PROTO_SUFFIXES $Suf)
  600. }
  601. # tag:proto tag:cpp-specific
  602. HAS_CPP_PROTOBUF_PEERS=no
  603. CPP_PROTOBUF_PEERS=
  604. # tag:proto tag:cpp-specific
  605. ### @usage: CPP_PROTO_PLUGIN0(Name Tool DEPS <Dependencies>)
  606. ###
  607. ### Define protoc plugin for C++ with given Name that emits code into regular outputs
  608. ### using Tool. Extra dependencies are passed via DEPS.
  609. macro CPP_PROTO_PLUGIN0(NAME, TOOL, DEPS[]) {
  610. .SEM=target_proto_plugin $NAME ${tool;rootrel:TOOL} ${output;hide;suf=.fake.o:NAME}
  611. SET_APPEND(CPP_PROTO_OPTS $_PROTO_PLUGIN_ARGS_BASE($NAME $TOOL))
  612. # XXX fix variable expansion in plugins
  613. ENABLE(HAS_CPP_PROTOBUF_PEERS)
  614. SET(CPP_PROTOBUF_PEERS $CPP_PROTOBUF_PEERS $DEPS)
  615. }
  616. # tag:proto tag:cpp-specific
  617. ### @usage: CPP_PROTO_PLUGIN(Name Tool Suf DEPS <Dependencies>)
  618. ###
  619. ### Define protoc plugin for C++ with given Name that emits code into 1 extra output
  620. ### using Tool. Extra dependencies are passed via DEPS.
  621. macro CPP_PROTO_PLUGIN(NAME, TOOL, SUF, DEPS[]) {
  622. CPP_PROTO_PLUGIN0($NAME $TOOL DEPS $DEPS)
  623. _ADD_CPP_PROTO_OUT($SUF)
  624. }
  625. # tag:proto tag:cpp-specific
  626. ### @usage: CPP_PROTO_PLUGIN2(Name Tool Suf1 Suf2 DEPS <Dependencies>)
  627. ###
  628. ### Define protoc plugin for C++ with given Name that emits code into 2 extra outputs
  629. ### using Tool. Extra dependencies are passed via DEPS.
  630. macro CPP_PROTO_PLUGIN2(NAME, TOOL, SUF1, SUF2, DEPS[]) {
  631. CPP_PROTO_PLUGIN($NAME $TOOL $SUF1 DEPS $DEPS)
  632. _ADD_CPP_PROTO_OUT($SUF2)
  633. SET_APPEND(CPP_PROTO_OUTS_SEM \${output;hide;norel;nopath;noext;suf=$SUF2:File})
  634. }
  635. # tag:proto
  636. ### @usage: USE_SKIFF() #wip, do not use
  637. ###
  638. ### Use mapreduce/yt/skiff_proto/plugin for C++
  639. macro USE_SKIFF() {
  640. # Move extra includes to INDUCED_DEPS macro in mapreduce/yt/skiff_proto/plugin/ya.make
  641. CPP_PROTO_PLUGIN0(skiff mapreduce/yt/skiff_proto/plugin DEPS mapreduce/yt/skiff_proto/lib)
  642. }
  643. # tag:go-specific
  644. _GO_COMMON_GOOGLE_APIS = \
  645. vendor/google.golang.org/genproto/googleapis/api/annotations \
  646. vendor/google.golang.org/genproto/googleapis/api/configchange \
  647. vendor/google.golang.org/genproto/googleapis/api/distribution \
  648. vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1 \
  649. vendor/google.golang.org/genproto/googleapis/api/expr/v1beta1 \
  650. vendor/google.golang.org/genproto/googleapis/api/httpbody \
  651. vendor/google.golang.org/genproto/googleapis/api/label \
  652. vendor/google.golang.org/genproto/googleapis/api/metric \
  653. vendor/google.golang.org/genproto/googleapis/api/monitoredres \
  654. vendor/google.golang.org/genproto/googleapis/api/serviceconfig \
  655. vendor/google.golang.org/genproto/googleapis/api/servicecontrol/v1 \
  656. vendor/google.golang.org/genproto/googleapis/api/servicemanagement/v1 \
  657. vendor/google.golang.org/genproto/googleapis/iam/admin/v1 \
  658. vendor/google.golang.org/genproto/googleapis/iam/credentials/v1 \
  659. vendor/google.golang.org/genproto/googleapis/iam/v1 \
  660. vendor/google.golang.org/genproto/googleapis/iam/v1/logging \
  661. vendor/google.golang.org/genproto/googleapis/logging/type \
  662. vendor/google.golang.org/genproto/googleapis/logging/v2 \
  663. vendor/google.golang.org/genproto/googleapis/rpc/code \
  664. vendor/google.golang.org/genproto/googleapis/rpc/errdetails \
  665. vendor/google.golang.org/genproto/googleapis/rpc/status \
  666. vendor/google.golang.org/genproto/googleapis/type/calendarperiod \
  667. vendor/google.golang.org/genproto/googleapis/type/color \
  668. vendor/google.golang.org/genproto/googleapis/type/date \
  669. vendor/google.golang.org/genproto/googleapis/type/dayofweek \
  670. vendor/google.golang.org/genproto/googleapis/type/expr \
  671. vendor/google.golang.org/genproto/googleapis/type/fraction \
  672. vendor/google.golang.org/genproto/googleapis/type/latlng \
  673. vendor/google.golang.org/genproto/googleapis/type/money \
  674. vendor/google.golang.org/genproto/googleapis/type/postaladdress \
  675. vendor/google.golang.org/genproto/googleapis/type/quaternion \
  676. vendor/google.golang.org/genproto/googleapis/type/timeofday
  677. # tag:go-specific
  678. _COMMON_GOOGLE_APIS=None
  679. # tag:go-specific
  680. ### @usage: USE_COMMON_GOOGLE_APIS([apis...])
  681. ###
  682. ### Use common-google-apis library set. Pass optional apis list to be used or use them all.
  683. ### This macro is properly handled for all languages including Go, where apis come in
  684. ## pregenerated form. In other languages apis are generated from sources in Arcadia.
  685. macro USE_COMMON_GOOGLE_APIS(APIS...) {
  686. SET(_COMMON_GOOGLE_APIS ${pre=vendor/google.golang.org/genproto/googleapis/:APIS})
  687. }
  688. # tag:go-specific tag:proto
  689. GO_PROTO_GEN_TOOL=$_TOOL_PROTOC_GEN_GO
  690. GO_PROTO_GEN_PLUGINS=
  691. GO_PROTO_PACKAGE_MAP=
  692. GO_PROTO_OPTS=$_GO_PROTOC_PLUGIN_ARGS_BASE(go $GO_PROTO_GEN_TOOL MAP $GO_PROTO_PACKAGE_MAP PLUGINS $GO_PROTO_GEN_PLUGINS)
  693. GO_PROTO_OUTS=
  694. # tag:go-specific tag:proto
  695. GO_PROTOBUF_IMPORTS=\
  696. ${GOSTD}/sync \
  697. ${GOSTD}/reflect \
  698. ${GOSTD}/fmt \
  699. ${GOSTD}/math \
  700. vendor/github.com/golang/protobuf/proto \
  701. vendor/google.golang.org/protobuf/types/descriptorpb \
  702. vendor/google.golang.org/protobuf/runtime/protoimpl \
  703. vendor/google.golang.org/protobuf/runtime/protoiface \
  704. vendor/google.golang.org/protobuf/reflect/protoreflect
  705. # tag:go-specific tag:proto
  706. GO_PROTOBUF_WELLKNOWN_TYPES=\
  707. vendor/google.golang.org/protobuf/types/known/anypb \
  708. vendor/google.golang.org/protobuf/types/known/apipb \
  709. vendor/google.golang.org/protobuf/types/known/durationpb \
  710. vendor/google.golang.org/protobuf/types/known/emptypb \
  711. vendor/google.golang.org/protobuf/types/known/fieldmaskpb \
  712. vendor/google.golang.org/protobuf/types/known/sourcecontextpb \
  713. vendor/google.golang.org/protobuf/types/known/structpb \
  714. vendor/google.golang.org/protobuf/types/known/timestamppb \
  715. vendor/google.golang.org/protobuf/types/known/typepb \
  716. vendor/google.golang.org/protobuf/types/known/wrapperspb
  717. # tag:go-specific tag:proto
  718. ### @usage: GO_PROTO_PLUGIN(Name Ext Tool [DEPS dependencies...])
  719. ###
  720. ### Define protoc plugin for GO with given Name that emits extra output with provided extension
  721. ### Ext using Tool. Extra dependencies are passed via DEPS.
  722. macro GO_PROTO_PLUGIN(NAME, EXT, TOOL, DEPS[]) {
  723. SET_APPEND(GO_PROTO_OPTS $_PROTO_PLUGIN_ARGS_BASE($NAME $TOOL))
  724. SET_APPEND(GO_PROTO_OUTS \${output;hide;noauto;norel;nopath;noext;suf=$EXT:File})
  725. PEERDIR(${DEPS})
  726. }
  727. # tag:go-specific tag:proto
  728. macro _GO_PROTOC_PLUGIN_ARGS_BASE_IMPL(Name, Tool, PLUGINS...) {
  729. .CMD=--plugin=protoc-gen-${Name}=${tool:Tool} --${Name}_out=${join=|:PLUGINS}:${ARCADIA_BUILD_ROOT}/$PROTO_NAMESPACE
  730. }
  731. # tag:go-specific tag:proto
  732. macro _GO_PROTOC_PLUGIN_ARGS_BASE_PROXY(Name, Tool, MAP[], PLUGINS[]) {
  733. .CMD=$_GO_PROTOC_PLUGIN_ARGS_BASE_IMPL($Name $Tool $MAP ${pre=plugins=:PLUGINS})
  734. }
  735. # tag:go-specific tag:proto
  736. macro _GO_PROTOC_PLUGIN_ARGS_BASE(Name, Tool, MAP[], PLUGINS[]) {
  737. .CMD=$_GO_PROTOC_PLUGIN_ARGS_BASE_PROXY($Name $Tool MAP ${pre=M:MAP} PLUGINS ${join=|:PLUGINS})
  738. }
  739. # tag:go-specific tag:proto
  740. GO_PROTO_CMDLINE=${cwd;rootdir;input:File} $YMAKE_PYTHON ${input:"build/scripts/go_proto_wrapper.py"} $GO_ARCADIA_PROJECT_PREFIX $GO_CONTRIB_PROJECT_PREFIX ./$PROTO_NAMESPACE $PROTOC -I=./$PROTO_NAMESPACE -I=$ARCADIA_ROOT/$PROTO_NAMESPACE ${pre=-I=:_PROTO__INCLUDE} -I=$ARCADIA_BUILD_ROOT -I=$PROTOBUF_PATH ${input;rootrel:File}
  741. # tag:go-specific tag:proto
  742. macro _GO_PROTO_CMD_IMPL(File, OPTS[], OUTS[]) {
  743. .CMD=$GO_PROTO_CMDLINE $OPTS $OUTS ${kv;hide:"p PB"} ${kv;hide:"pc yellow"}
  744. .PEERDIR=${GO_PROTOBUF_IMPORTS} ${GO_PROTOBUF_WELLKNOWN_TYPES}
  745. .ADDINCL=FOR proto contrib/libs/protobuf/src
  746. }
  747. # tag:go-specific tag:proto
  748. macro _GO_PROTO_CMD(File) {
  749. .CMD=$_GO_PROTO_CMD_IMPL($File OPTS $GO_PROTO_OPTS OUTS $GO_PROTO_OUTS)
  750. }
  751. # tag:proto
  752. ### @usage: YP_PROTO_YSON(Files... OUT_OPTS Opts...)
  753. ###
  754. ### Genereate .yson.go from .proto using yp/go/yson/internal/proto-yson-gen/cmd/proto-yson-gen
  755. macro YP_PROTO_YSON(OUT_OPTS[], Files...) {
  756. .CMD=${cwd:BINDIR} $PROTOC --plugin=protoc-gen-custom=${tool:"yp/go/yson/internal/proto-yson-gen/cmd/proto-yson-gen"} -I=${ARCADIA_ROOT}/${PROTO_NAMESPACE} ${pre=-I=:_PROTO__INCLUDE} -I=${ARCADIA_ROOT} --custom_out="$OUT_OPTS paths=base_name:." --custom_opt="goroot=${GO_TOOLS_ROOT}" ${input:Files} ${output;hide;noauto;nopath;noext;suf=.yson.go:Files}
  757. .ADDINCL=FOR proto ${ARCADIA_ROOT}/${MODDIR} FOR proto ${ARCADIA_ROOT}/${GO_TEST_IMPORT_PATH} FOR proto yt ${ARCADIA_BUILD_ROOT}/yt FOR proto contrib/libs/protobuf/src
  758. .PEERDIR=$GOSTD/strings $GOSTD/fmt $GOSTD/errors $GOSTD/encoding/json library/go/core/xerrors yt/go/yson yt/go/yterrors yp/go/yson/ytypes contrib/libs/protobuf
  759. }
  760. # tag:proto
  761. macro _CPP_PROTO_CMD(File) {
  762. .CMD=$CPP_PROTO_CMDLINE $CPP_PROTO_OPTS $CPP_PROTO_OUTS ${kv;hide:"p PB"} ${kv;hide:"pc yellow"}
  763. .SEM=target_proto_messages PRIVATE ${input:File} $CPP_PROTO_OUTS_SEM ${output;hide;suf=${OBJ_SUF}.pb.o:File} ${hide;tool:"contrib/tools/protoc/bin"} ${hide;tool:"contrib/tools/protoc/plugins/cpp_styleguide"} && set_global_flags COMMON_PROTOC_FLAGS -I=$ARCADIA_ROOT -I=$ARCADIA_BUILD_ROOT
  764. .PEERDIR=contrib/libs/protobuf
  765. }
  766. # tag:proto
  767. macro _CPP_VANILLA_PROTO_CMD(File) {
  768. .CMD=$CPP_PROTO_CMDLINE $CPP_PROTO_OPTS $CPP_PROTO_OUTS ${kv;hide:"p PB"} ${kv;hide:"pc yellow"}
  769. .PEERDIR=contrib/libs/protobuf_std
  770. }
  771. # tag:proto
  772. macro _CPP_EVLOG_CMD(File) {
  773. .CMD=$CPP_PROTO_CMDLINE $CPP_EV_OPTS $CPP_EV_OUTS ${kv;hide:"p EV"} ${kv;hide:"pc yellow"}
  774. .PEERDIR=library/cpp/eventlog contrib/libs/protobuf
  775. }
  776. # tag:proto
  777. macro _CPP_PROTO_EVLOG_CMD(File) {
  778. # process .proto as .ev
  779. .CMD=$CPP_PROTO_CMDLINE $CPP_EV_OPTS $CPP_PROTO_OUTS ${kv;hide:"p PB"} ${kv;hide:"pc yellow"}
  780. .PEERDIR=library/cpp/eventlog contrib/libs/protobuf
  781. }
  782. # tag:proto
  783. macro _CPP_CFGPROTO_CMD(File) {
  784. # keep extension in output just as in EV: this is hard-codeded behaviour of protoc for non-.proto extensions
  785. .CMD=$CPP_PROTO_CMDLINE --plugin=protoc-gen-config=${tool:"library/cpp/proto_config/plugin"} --config_out=$ARCADIA_BUILD_ROOT/$PROTO_NAMESPACE $CPP_EV_OUTS ${kv;hide:"p PB"} ${kv;hide:"pc yellow"}
  786. .PEERDIR=library/cpp/proto_config/codegen library/cpp/proto_config/protos contrib/libs/protobuf
  787. }
  788. # tag:proto
  789. PY_PROTO_MYPY_ENABLED=yes
  790. PY_PROTO_MYPY_PLUGIN_BASE=--plugin=protoc-gen-mypy=${tool:"contrib/python/mypy-protobuf/bin/protoc-gen-mypy"} --mypy_out=$ARCADIA_BUILD_ROOT/$PROTO_NAMESPACE
  791. # tag:proto tag:python-specific
  792. PY_PROTO_MYPY_SUFFIX=
  793. PY_PROTO_MYPY_PLUGIN=
  794. PY_PROTO_MYPY_PLUGIN_INTERNAL=
  795. # tag:proto tag:python-specific
  796. macro NO_MYPY() {
  797. DISABLE(PY_PROTO_MYPY_ENABLED)
  798. }
  799. # tag:proto tag:python-specific
  800. macro _PY_PROTO_CMD_BASE(File, Suf, Args...) {
  801. .CMD=$PROTOC -I=./$PROTO_NAMESPACE -I=$ARCADIA_ROOT/$PROTO_NAMESPACE ${pre=-I=:_PROTO__INCLUDE} -I=$ARCADIA_BUILD_ROOT -I=$PROTOBUF_PATH --python_out=$ARCADIA_BUILD_ROOT/$PROTO_NAMESPACE ${input;rootrel:File} ${output;hide;noauto;norel;nopath;noext;suf=$Suf:File} ${kv;hide:"p PB"} ${kv;hide:"pc yellow"} $Args
  802. }
  803. # tag:proto tag:python-specific
  804. macro _PY_PROTO_CMD(File) {
  805. .CMD=${cwd;rootdir;input:File} $_PY_PROTO_CMD_BASE($File _pb2.py $PY_PROTO_OPTS $PY_PROTO_OUTS $PY_PROTO_MYPY_PLUGIN)
  806. }
  807. # tag:proto tag:python-specific
  808. macro _PY_PROTO_CMD_INTERNAL(File) {
  809. .CMD=${cwd;rootdir;input:File} $GEN_PY_PROTOS --suffixes $PY_PROTO_SUFFIXES $PY_PROTO_MYPY_SUFFIX -- $_PY_PROTO_CMD_BASE($File __int___pb2.py $PY_PROTO_OPTS $PY_PROTO_OUTS_INTERNAL ${hide;kv:"ext_out_name_for_${nopath;noext;suf=__int___pb2.py:File} ${nopath;noext;suf=_pb2.py:File}"} $PY_PROTO_MYPY_PLUGIN_INTERNAL)
  810. }
  811. # tag:proto tag:java-specific
  812. JAVA_PROTO_RUNTIME=
  813. # tag:proto tag:java-specific
  814. ### @usage: USE_JAVALITE()
  815. ### Use protobuf-javalite for Java
  816. macro USE_JAVALITE() {
  817. SET(JAVA_PROTO_RUNTIME javalite)
  818. }
  819. # tag:proto tag:java-specific
  820. JAVA_PROTO_RUNTIME_VERSION = 3.18.2
  821. JAVA_PROTO_COMMON_VERSION = 1.12.0
  822. when ($JAVA_PROTO_RUNTIME == "javalite") {
  823. _JAVA_PROTO_OUT_ARG=--java_out=lite:
  824. JAVA_PROTOBUF_PEERS=contrib/java/com/google/protobuf/protobuf-javalite/${JAVA_PROTO_RUNTIME_VERSION}
  825. JAVA_GRPC_STUB=contrib/java/io/grpc/grpc-stub/1.19.0
  826. JAVA_GRPC_PROTOBUF=contrib/java/io/grpc/grpc-protobuf/1.19.0
  827. }
  828. otherwise {
  829. _JAVA_PROTO_OUT_ARG=--java_out=
  830. JAVA_PROTOBUF_PEERS=contrib/java/com/google/protobuf/protobuf-java/${JAVA_PROTO_RUNTIME_VERSION}
  831. JAVA_GRPC_STUB=contrib/java/io/grpc/grpc-stub/1.26.0
  832. JAVA_GRPC_PROTOBUF=contrib/java/io/grpc/grpc-protobuf/1.26.0
  833. }
  834. # tag:proto tag:java-specific
  835. macro _JAVA_PROTO_CMD(File) {
  836. .CMD=${cwd;rootdir;input:File} $YMAKE_PYTHON ${input:"build/scripts/tared_protoc.py"} --tar-output ${output;norel;nopath;noext;suf=.jsrc:File} --protoc-out-dir $ARCADIA_BUILD_ROOT/java_out $PROTOC -I=./$PROTO_NAMESPACE ${pre=-I=:_PROTO__INCLUDE} -I=$ARCADIA_ROOT $_JAVA_PROTO_OUT_ARG$ARCADIA_BUILD_ROOT/java_out ${input;rootrel:File} ${kv;hide:"p PB"} ${kv;hide:"pc yellow"} $JAVA_PROTO_ARGS
  837. }
  838. # tag:proto tag:perl-specific tag:deprecated
  839. ### @usage: XS_PROTO(InputProto Dir Outputs...) # deprecated
  840. ###
  841. ### Generate Perl code from protobuf.
  842. ### In order to use this macro one should predict all outputs protoc will emit from input_proto file and enlist those as outputs.
  843. macro XS_PROTO(File, Dir, Outputs...) {
  844. .CMD=$PROTOC -I=${ARCADIA_ROOT}/${Dir} ${pre=-I=:_PROTO__INCLUDE} -I=${ARCADIA_ROOT} -I=${PROTOBUF_PATH} --perlxs_out=${BINDIR} ${input:File} ${hide;output:Outputs} ${output_include;hide;nopath;noext;suf=.pb.h:File}
  845. PEERDIR(${Dir})
  846. ADDINCL(${ARCADIA_BUILD_ROOT}/${Dir})
  847. }
  848. # tag:proto tag:fbs
  849. ### @usage: PROTO2FBS(InputProto)
  850. ###
  851. ### Produce flatbuf schema out of protobuf description.
  852. macro PROTO2FBS(File) {
  853. .CMD=${cwd:BINDIR} ${tool:"contrib/tools/flatc"} -I . -I ${ARCADIA_ROOT} --proto ${input:File} ${output;hide;nopath;noext:File.fbs} ${kv;hide:"p FBS"} ${kv;hide:"pc yellow"}
  854. }
  855. # tag:proto tag:python-specific
  856. when ($PY_PROTOS_FOR == "yes") {
  857. PEERDIR+=contrib/libs/protobuf/python
  858. }
  859. # tag:python-specific
  860. macro _PY_EVLOG_CMD_BASE(File, Suf, Args...) {
  861. .CMD=$_PY_PROTO_CMD_BASE($File $Suf $Args)
  862. .PEERDIR=library/cpp/eventlog/proto
  863. }
  864. # tag:python-specific tag:proto
  865. macro _PY_EVLOG_CMD(File) {
  866. .CMD=${cwd;rootdir;input:File} $_PY_EVLOG_CMD_BASE($File _ev_pb2.py)
  867. }
  868. # tag:python-specific tag:proto
  869. macro _PY_EVLOG_CMD_INTERNAL(File) {
  870. .CMD=${cwd;rootdir;input:File} $GEN_PY_PROTOS --suffixes $PY_EVLOG_SUFFIXES -- $_PY_EVLOG_CMD_BASE($File __int___ev_pb2.py ${hide;kv:"ext_out_name_for_${nopath;noext;suf=__int___ev_pb2.py:File} ${nopath;noext;suf=_ev_pb2.py:File}"})
  871. }
  872. # tag:java-specific tag:proto
  873. macro _JAVA_EVLOG_CMD(File) {
  874. .CMD=$COPY_CMD ${input:File} ${output;nopath;noext;norel;suf=_ev.proto:File} ${kv;hide:"p EV"} ${kv;hide:"pc yellow"}
  875. .PEERDIR=library/cpp/eventlog/proto
  876. }
  877. # tag:sanitize
  878. RUN_NO_SANITIZE=$YMAKE_PYTHON ${input:"build/scripts/run_tool.py"} --
  879. # tag:sanitize
  880. when ($IS_CROSS_SANITIZE) {
  881. RUN_NO_SANITIZE=
  882. }
  883. YIELD=$YMAKE_PYTHON ${input:"build/scripts/yield_line.py"} -- ${BINDIR}/__args
  884. XARGS=$YMAKE_PYTHON ${input:"build/scripts/xargs.py"} -- ${BINDIR}/__args
  885. RESPFILE_CMD=$YMAKE_PYTHON ${input:"build/scripts/writer.py"}
  886. FS_TOOLS=$YMAKE_PYTHON ${input:"build/scripts/fs_tools.py"}
  887. COPY_CMD=$FS_TOOLS copy
  888. LINK_OR_COPY_CMD=$FS_TOOLS link_or_copy
  889. REMOVE_FILE=$FS_TOOLS remove
  890. MOVE_FILE=$FS_TOOLS rename
  891. # tag:allocator tag:windows-specific
  892. MSVC_DYNAMICBASE=/DYNAMICBASE
  893. when ($ALLOCATOR == "LF") {
  894. MSVC_DYNAMICBASE=/DYNAMICBASE:NO
  895. }
  896. # tag:sanitize
  897. SANITIZER_CFLAGS=
  898. # tag:proto tag:grpc
  899. ### @usage: GRPC()
  900. ###
  901. ### Emit GRPC code for all .proto files in a PROTO_LIBRARY.
  902. ### This works for all available PROTO_LIBRARY versions (C++, Python 2.x, Pyton 3.x, Java and Go).
  903. macro GRPC() {
  904. # C++
  905. CPP_PROTO_PLUGIN2(grpc_cpp contrib/tools/protoc/plugins/grpc_cpp .grpc.pb.cc .grpc.pb.h DEPS contrib/libs/grpc)
  906. # Python
  907. PY_PROTO_PLUGIN(grpc_py _pb2_grpc.py contrib/tools/protoc/plugins/grpc_python DEPS contrib/libs/grpc/python contrib/libs/grpc)
  908. # Java
  909. JAVA_PROTO_PLUGIN(grpc_java contrib/tools/protoc/plugins/grpc_java DEPS $JAVA_GRPC_STUB $JAVA_GRPC_PROTOBUF)
  910. }
  911. # tag:fbs
  912. FLATC_FLAGS_VALUE=
  913. ### @usage: FLATC_FLAGS(flags...)
  914. ###
  915. ### Add flags to flatc command line
  916. macro FLATC_FLAGS(FLAGS...) {
  917. SET_APPEND(FLATC_FLAGS_VALUE $FLAGS)
  918. }
  919. # tag:fbs
  920. _PY_FBS_DEPS=contrib/python/flatbuffers
  921. # tag:fbs tag:internal
  922. ### @usage: FBS_TO_PYSRC(output_base_name fbs_files...) # internal
  923. ###
  924. ### Create a tar archive of .py files generated by flatc for Python. Output tar
  925. ### archive will have .fbs.pysrc extension. This .fbs.pysrc extension is specially
  926. ### processed when --add-flatbuf-result flag is specified on the command line
  927. ### for 'ya make ...' (tar archive is extracted to output directory).
  928. macro FBS_TO_PYSRC(OUT_NAME, IN_FBS_FILES...) {
  929. .CMD=${cwd:ARCADIA_BUILD_ROOT} ${tool:"contrib/tools/flatc"} --python --gen-mutable ${FLATC_FLAGS_VALUE} ${pre=-I :_FLATC__INCLUDE} -o ${BINDIR} ${input:IN_FBS_FILES} && $YMAKE_PYTHON ${input:"build/scripts/tar_sources.py"} --exts .py --input $BINDIR --output ${output;noauto;tared:OUT_NAME.fbs.pysrc} ${kv;hide:"p FP"} ${kv;hide:"pc light-green"} ${kv;hide:"tared_kind nodir"}
  930. }
  931. # tag:fbs tag:go-specific
  932. # Implicit dependencies of generated code for Go
  933. _GO_FLATC_IMPORTS=\
  934. ${GOSTD}/strconv \
  935. vendor/github.com/google/flatbuffers/go
  936. # tag:fbs tag:cpp-specific
  937. macro _CPP_FLATC_CMD(SRC, SRCFLAGS...) {
  938. .CMD=${cwd:ARCADIA_BUILD_ROOT} $YMAKE_PYTHON ${input:"build/scripts/cpp_flatc_wrapper.py"} ${tool:"contrib/tools/flatc"} --no-warnings --cpp --keep-prefix --gen-mutable --schema -b --yandex-maps-iter --gen-object-api --filename-suffix .fbs ${FLATC_FLAGS_VALUE} ${pre=-I :_FLATC__INCLUDE} -o ${output;norel:SRC.h} ${output;hide;norel:SRC.cpp} ${input:SRC} ${output;hide;noext;norel:SRC.iter.fbs.h} ${output;noauto;hide;noext;norel:SRC.bfbs} ${kv;hide:"p FL"} ${kv;hide:"pc light-green"}
  939. .SEM=target_fbs_source PRIVATE ${input:SRC} ${pre=-I :_FLATC__INCLUDE} ${output;hide;norel:SRC.h} ${output;hide;norel:SRC.cpp} ${output;hide;noext;norel:SRC.iter.fbs.h} ${output;noauto;hide;noext;norel:SRC.bfbs} ${hide;tool:"contrib/tools/flatc/bin"} && set_global_flags FBS_CPP_FLAGS --no-warnings --cpp --keep-prefix --gen-mutable --schema -b --yandex-maps-iter --gen-object-api --filename-suffix .fbs ${FLATC_FLAGS_VALUE}
  940. .PEERDIR=contrib/libs/flatbuffers
  941. }
  942. # tag:fbs tag:cpp-specific
  943. macro _CPP_FLATC64_CMD(SRC, SRCFLAGS...) {
  944. .CMD=${cwd:ARCADIA_BUILD_ROOT} $YMAKE_PYTHON ${input:"build/scripts/cpp_flatc_wrapper.py"} ${tool:"contrib/tools/flatc64"} --no-warnings --cpp --keep-prefix --gen-mutable --schema -b --filename-suffix .fbs64 ${FLATC_FLAGS_VALUE} -I ${ARCADIA_ROOT} -I ${ARCADIA_BUILD_ROOT} -o ${output;norel:SRC.h} ${output;hide;norel:SRC.cpp} ${input:SRC} ${output;noauto;hide;noext;norel:SRC.bfbs64} ${kv;hide:"p FL64"} ${kv;hide:"pc light-green"}
  945. .PEERDIR=contrib/libs/flatbuffers64
  946. }
  947. # tag:fbs tag:go-specific tag:internal
  948. ### @usage: _GO_FLATC_CMD(fbs_file flags...) # internal
  949. ###
  950. ### Create a tar archive of .go files generated by flatc for Go. Output tar archive
  951. ### wiil have .fbs.gosrc extension. This .fbs.gosrc is specially processed when
  952. ### --add-protobuf-result flag is specified on the command line for 'ya make ...'
  953. ### (tar archive is extracted to output directory).
  954. macro _GO_FLATC_CMD(SRC, PACKAGE_NAME) {
  955. .CMD=${cwd:ARCADIA_BUILD_ROOT} ${tool:"contrib/tools/flatc"} --go --gen-mutable --go-namespace ${PACKAGE_NAME} ${FLATC_FLAGS_VALUE} ${pre=-I :_FLATC__INCLUDE} -o ${BINDIR}/_generated ${input:SRC} && $YMAKE_PYTHON ${input:"build/scripts/postprocess_go_fbs.py"} --input-dir ${BINDIR} --map $_FBS_NAMESPACE_MAP_GLOBAL && $YMAKE_PYTHON ${input:"build/scripts/tar_sources.py"} --flat --input ${BINDIR}/_generated --output ${output;noext;tared:SRC.fbs.gosrc} --exts .go ${kv;hide:"p FG"} ${kv;hide:"pc light-green"} ${kv;hide:"tared_kind nodir"}
  956. .PEERDIR=${_GO_FLATC_IMPORTS}
  957. }
  958. # tag:fbs tag:java-specific tag:internal
  959. ### @usage: _JAVA_FLATC_CMD(fbs_file) # internal
  960. ###
  961. ### Create a tar archive of .java files generated by flatc for Java. Output tar
  962. ### acrchive will have .fbs.jsrc extension. Files with .fbs.jsrc extension will
  963. ### be added to results when --add-flatbuf-result flag is specified on the command
  964. ### line for 'ya make ...'
  965. macro _JAVA_FLATC_CMD(SRC) {
  966. .CMD=${cwd:ARCADIA_BUILD_ROOT} ${tool:"contrib/tools/flatc"} --java --gen-mutable ${FLATC_FLAGS_VALUE} ${pre=-I :_FLATC__INCLUDE} -o ${BINDIR} ${input:SRC} && $YMAKE_PYTHON ${input:"build/scripts/tar_sources.py"} --input $BINDIR --output ${output;nopath;noext:SRC.fbs.jsrc} --exts .java ${kv;hide:"p FJ"} ${kv;hide:"pc light-green"}
  967. .PEERDIR=contrib/java/com/google/flatbuffers/flatbuffers-java/${JAVA_FLATBUFFERS_VERSION}
  968. }
  969. # variables must be defined for all module types to make generate_mf.py work
  970. MODULE_PREFIX=
  971. MODULE_SUFFIX=
  972. NEED_PLATFORM_PEERDIRS=yes
  973. PEERDIR_TEST_TOOL=yes
  974. # tag:python-specific
  975. PYTHON2=no
  976. PYTHON3=no
  977. # tag:python-specific
  978. when (!$ARCADIA_PYTHON_UNICODE_SIZE) {
  979. when ($OS_WINDOWS) {
  980. ARCADIA_PYTHON_UNICODE_SIZE=2
  981. }
  982. otherwise {
  983. ARCADIA_PYTHON_UNICODE_SIZE=4
  984. }
  985. }
  986. ### @usage: _BARE_UNIT # internal
  987. ###
  988. ### The base of all modules describing default bare minimum for all modules.
  989. ### To avoid surprises, all buildable modules are better to be inherited from it or its descendants.
  990. module _BARE_UNIT {
  991. .EXTS=.*
  992. .CMD=TOUCH_UNIT
  993. .IGNORED=GO_PROTO_PLUGIN
  994. .NODE_TYPE=Bundle
  995. .PEERDIR_POLICY=as_include
  996. .RESTRICTED=GRPC USE_SKIFF INDUCED_DEPS FUZZ_DICTS FUZZ_OPTS PACK DOCS_DIR DOCS_CONFIG DOCS_VARS YT_SPEC USE_CXX USE_UTIL WHOLE_ARCHIVE PRIMARY_OUTPUT SECONDARY_OUTPUT DEPENDENCY_MANAGEMENT EXCLUDE NO_DOCTESTS EMBED_JAVA_VCS_INFO RESOURCE_FILES PACK_GLOBALS_IN_LIBRARY EXPOSE GLOBAL_DEPS
  997. .FINAL_TARGET=no
  998. PEERDIR_TAGS=__EMPTY__
  999. when ($FATAL_ERROR_MESSAGE && $FATAL_ERROR_MODULE != "yes") {
  1000. PEERDIR+=build/conf_fatal_error
  1001. }
  1002. DEFAULT(MODULE_VERSION)
  1003. DEFAULT(MODULE_PREFIX)
  1004. DEFAULT(MODULE_SUFFIX)
  1005. }
  1006. ### @usage: _BASE_UNIT # internal
  1007. ###
  1008. ### The base of all LIBRARY/PROGRAM modules describing common logic for all modules.
  1009. ### To avoid surprises, all buildable modules are better to be inherited from it or its descendants.
  1010. module _BASE_UNIT: _BARE_UNIT {
  1011. .GLOBAL=_FBS_NAMESPACE_MAP
  1012. PEERDIR_TAGS=CPP_PROTO CPP_FBS CPP_SSQLS CPP_IDL PY2 PY2_NATIVE YQL_UDF_STATIC __EMPTY__ DLL_LIB
  1013. CPP_PROTO_CMDLINE=${cwd;rootdir;input:File} $PROTOC -I=./$PROTO_NAMESPACE -I=$ARCADIA_ROOT/$PROTO_NAMESPACE ${pre=-I=:_PROTO__INCLUDE} -I=$ARCADIA_BUILD_ROOT -I=$PROTOBUF_PATH --cpp_out=${CPP_PROTO_PLUGINS}$ARCADIA_BUILD_ROOT/$PROTO_NAMESPACE $PROTOC_STYLEGUIDE_OUT $PROTOC_PLUGIN_STYLEGUIDE ${input;rootrel:File}
  1014. CPP_PROTO_OUTS+=${output;hide;norel;nopath;noext:File.pb.cc} ${output;main;hide;norel;nopath;noext:File.pb.h}
  1015. CPP_PROTO_OUTS_SEM+=${output;main;hide;norel;nopath;noext:File.pb.h}
  1016. CPP_EV_OUTS+=${output;hide;norel:File.pb.cc} ${output;hide;norel:File.pb.h}
  1017. when ($PY_PROTOS_FOR == "yes") {
  1018. MACRO_ALIAS(EVLOG_CMD _PY_EVLOG_CMD)
  1019. MACRO_ALIAS(PROTO_CMD _PY_PROTO_CMD)
  1020. }
  1021. otherwise {
  1022. MACRO_ALIAS(EVLOG_CMD _CPP_EVLOG_CMD)
  1023. MACRO_ALIAS(FBS_CMD _CPP_FLATC_CMD)
  1024. when ($BUILD_PROTO_AS_EVLOG == "yes") {
  1025. MACRO_ALIAS(PROTO_CMD _CPP_PROTO_EVLOG_CMD)
  1026. }
  1027. otherwise {
  1028. MACRO_ALIAS(PROTO_CMD _CPP_PROTO_CMD)
  1029. }
  1030. when ($USE_VANILLA_PROTOC == "yes") {
  1031. PROTOC=${tool:"contrib/tools/protoc_std"}
  1032. PROTOC_STYLEGUIDE_OUT=
  1033. PROTOC_PLUGIN_STYLEGUIDE=
  1034. PROTOBUF_PATH=${ARCADIA_ROOT}/contrib/libs/protobuf_std
  1035. MACRO_ALIAS(PROTO_CMD _CPP_VANILLA_PROTO_CMD)
  1036. }
  1037. when ($PROTOC_TRANSITIVE_HEADERS == "no") {
  1038. CPP_PROTO_PLUGINS=transitive_pb_h=false:${CPP_PROTO_PLUGINS}
  1039. }
  1040. }
  1041. SANITIZER_DEFINED=no
  1042. when ($SANITIZER_TYPE && $SANITIZER_TYPE != "no") {
  1043. CFLAGS+=-fsanitize=$SANITIZER_TYPE -D${SANITIZER_TYPE}_sanitizer_enabled $SANITIZER_CFLAGS -fno-omit-frame-pointer
  1044. LDFLAGS+=-fsanitize=$SANITIZER_TYPE
  1045. SANITIZER_DEFINED=yes
  1046. when ($CLANG) {
  1047. CFLAGS+=-fsanitize-blacklist=${input:"build/sanitize-blacklist.txt"}
  1048. LDFLAGS+=-fsanitize-blacklist=${input:"build/sanitize-blacklist.txt"}
  1049. }
  1050. }
  1051. when ($SANITIZE_COVERAGE && $SANITIZE_COVERAGE != "no") {
  1052. CFLAGS+=-fsanitize-coverage=$SANITIZE_COVERAGE
  1053. LDFLAGS+=-fsanitize-coverage=$SANITIZE_COVERAGE
  1054. }
  1055. when ($CLANG_COVERAGE && $CLANG_COVERAGE != "no") {
  1056. CFLAGS+=-fprofile-instr-generate -fcoverage-mapping -DCLANG_COVERAGE
  1057. LDFLAGS+=-fprofile-instr-generate -fcoverage-mapping
  1058. }
  1059. when ($NLG_COVERAGE && $NLG_COVERAGE != "no") {
  1060. CFLAGS+=-DNLG_COVERAGE
  1061. }
  1062. when ($GCC) {
  1063. select ($SANITIZER_TYPE) {
  1064. "address" ? {
  1065. LDFLAGS+=-static-libasan
  1066. }
  1067. "undefined" ? {
  1068. LDFLAGS+=-static-libubsan
  1069. }
  1070. "thread" ? {
  1071. PIE=yes
  1072. LDFLAGS+=-static-libtsan
  1073. }
  1074. }
  1075. }
  1076. when ($HARDENING == "yes") {
  1077. when ($CLANG) {
  1078. CFLAGS+=-fstack-protector-all -D_hardening_enabled_
  1079. LDFLAGS+=-z relro -z now -z noexecstack
  1080. PIE=yes
  1081. }
  1082. }
  1083. when ($USE_LTO == "yes") {
  1084. when ($GCC) {
  1085. CFLAGS+=-flto -fno-fat-lto-objects
  1086. LDFLAGS+=-flto
  1087. NO_LTO_CFLAGS=-fno-lto
  1088. }
  1089. when ($CLANG) {
  1090. CFLAGS+=-flto
  1091. LDFLAGS+=-flto
  1092. NO_LTO_CFLAGS=-fno-lto
  1093. }
  1094. }
  1095. when ($USE_THINLTO == "yes") {
  1096. when ($GCC) {
  1097. CFLAGS+=-flto=thin
  1098. LDFLAGS+=-flto=thin
  1099. NO_LTO_CFLAGS=-fno-lto
  1100. }
  1101. when ($CLANG) {
  1102. CFLAGS+=-flto=thin
  1103. LDFLAGS+=-flto=thin
  1104. NO_LTO_CFLAGS=-fno-lto
  1105. }
  1106. }
  1107. when ($CLANG) {
  1108. when ($PGO_ADD == "yes") {
  1109. CFLAGS+=-fprofile-instr-generate
  1110. LDFLAGS+=-fprofile-instr-generate
  1111. }
  1112. when ($PGO_PATH) {
  1113. CFLAGS+=-fprofile-instr-use=$PGO_PATH -Wno-profile-instr-unprofiled -Wno-profile-instr-out-of-date
  1114. LDFLAGS+=-fprofile-instr-use=$PGO_PATH
  1115. }
  1116. }
  1117. when ($COMPILER_PLATFORM && $NEED_PLATFORM_PEERDIRS == "yes") {
  1118. PEERDIR+=$COMPILER_PLATFORM
  1119. }
  1120. when ($OS_LINUX && $NEED_PLATFORM_PEERDIRS == "yes") {
  1121. PEERDIR+=contrib/libs/linux-headers
  1122. }
  1123. # Adding PEERDIR from trigger doesn't always work. In this case it
  1124. # cause troubles in contrib/libs/libc_compat/ubuntu_14 under musl
  1125. # Workaround this issue by setting variable with PEERDIR in trigger
  1126. # and then adding PEERDIR to it's value unconditionally.
  1127. when ($USE_UBUNTU_COMPATIBILITY == "yes" && $NEED_PLATFORM_PEERDIRS == "yes") {
  1128. _UBUNTU_COMPAT_PEERDIR=contrib/libs/libc_compat/ubuntu_14
  1129. }
  1130. otherwise {
  1131. _UBUNTU_COMPAT_PEERDIR=
  1132. }
  1133. PEERDIR+=$_UBUNTU_COMPAT_PEERDIR
  1134. when ($NORUNTIME != "yes") {
  1135. PEERDIR+=contrib/libs/cxxsupp
  1136. when ($MAPSMOBI_BUILD_TARGET == "yes") {
  1137. PEERDIR+=build/platform/mapkit
  1138. }
  1139. }
  1140. when ($NOUTIL != "yes") {
  1141. PEERDIR+=util
  1142. }
  1143. when ($MUSL == "yes") {
  1144. CFLAGS += -D_musl_
  1145. LINK_DYN_LIB_FLAGS += --musl
  1146. LINK_SCRIPT_EXE_FLAGS += --musl
  1147. PEERDIR+=contrib/libs/musl/include
  1148. }
  1149. # g++ has proxy C-headers which are incompatible with libc++ proxy C-headers.
  1150. # The same problem exists for clang toolchain. On the other hand, the problem
  1151. # doesn't affect cl since it has united C/C++ library and doesn't need
  1152. # proxy C-headers.
  1153. # Disable all C++ headers including proxy C-headers when we use libc++.
  1154. when ($USE_INTERNAL_STL == "yes" && $MSVC != "yes") {
  1155. CXXFLAGS += -nostdinc++
  1156. }
  1157. otherwise {
  1158. CFLAGS += -DUSE_STL_SYSTEM
  1159. }
  1160. when ($CODENAVIGATION && $NOCODENAVIGATION != "yes") {
  1161. PEERDIR += build/external_resources/codenavigation
  1162. }
  1163. when ($CYTHON_COVERAGE && $CYTHON_COVERAGE == "yes") {
  1164. CFLAGS+=-DCYTHON_TRACE=1 -DCYTHON_TRACE_NOGIL=1
  1165. }
  1166. DEFAULT(USE_SSE4 yes)
  1167. when ($NOSSE != "yes") {
  1168. CFLAGS+=$SSE_CFLAGS
  1169. C_DEFINES+=$SSE_DEFINES
  1170. when ($USE_SSE4 == "yes") {
  1171. CFLAGS+=$SSE4_CFLAGS
  1172. C_DEFINES+=$SSE4_DEFINES
  1173. }
  1174. }
  1175. elsewhen ($MSVC != "yes") {
  1176. CFLAGS += -mno-sse
  1177. }
  1178. when ($LIPO == "yes" && $NEED_PLATFORM_PEERDIRS != "no") {
  1179. when ($OS_DARWIN == "yes" || $OS_IOS == "yes") {
  1180. PEERDIR += build/platform/cctools
  1181. }
  1182. }
  1183. _REGISTER_NO_CHECK_IMPORTS()
  1184. DEFAULT(PACKAGE_PREFIX_ARGS)
  1185. DEFAULT(BYACC_FLAGS -v)
  1186. DEFAULT(SWIG_LANG python)
  1187. DEFAULT(BISON_FLAGS -v)
  1188. DEFAULT(GP_FLAGS -CtTLANSI-C -Dk* -c)
  1189. when ($NEED_BINUTILS_PEERDIR && $BINUTILS_USED && $NEED_PLATFORM_PEERDIRS == "yes") {
  1190. PEERDIR+=build/platform/binutils
  1191. }
  1192. }
  1193. _LINKER_ID=
  1194. # GCC does not support -fuse-ld with an executable path, only
  1195. # -fuse-ld=bfd or -fuse-ld=gold (or -fuse-ld=lld in later versions).
  1196. when ($_LINKER_ID != "" && $_DEFAULT_LINKER_ID != "" && $CLANG == "yes" && $NEED_PLATFORM_PEERDIRS == "yes") {
  1197. when ($_LINKER_ID in [ "bfd", "gold", "lld" ]) {
  1198. PEERDIR+=build/platform/${_LINKER_ID}
  1199. }
  1200. }
  1201. macro _USE_LINKER_IMPL(LINKER_ID...) {
  1202. SET(_LINKER_ID $LINKER_ID)
  1203. }
  1204. macro _USE_LINKER() {
  1205. _USE_LINKER_IMPL($_DEFAULT_LINKER_ID)
  1206. }
  1207. ### @usage: USE_LINKER_BFD()
  1208. ### Use bfd linker for a program. This doesn't work in libraries
  1209. macro USE_LINKER_BFD() {
  1210. _USE_LINKER_IMPL(bfd)
  1211. }
  1212. ### @usage: USE_LINKER_GOLD()
  1213. ### Use gold linker for a program. This doesn't work in libraries
  1214. macro USE_LINKER_GOLD() {
  1215. _USE_LINKER_IMPL(gold)
  1216. }
  1217. ### @usage: USE_LINKER_LLD()
  1218. ### Use lld linker for a program. This doesn't work in libraries
  1219. macro USE_LINKER_LLD() {
  1220. _USE_LINKER_IMPL(lld)
  1221. }
  1222. COMMON_LINK_SETTINGS=
  1223. LINK_ADDITIONAL_SECTIONS=
  1224. LINK_ADDITIONAL_SECTIONS_COMMAND=
  1225. when ($COMMON_LINK_SETTINGS == "yes") {
  1226. when ($_LINKER_ID == "lld" || $_LINKER_ID == "gold") {
  1227. LDFLAGS += -Wl,--gdb-index
  1228. }
  1229. when ($EMBED_LINKER_CREF == "yes") {
  1230. LDFLAGS+=-Wl,--cref ${tmp;stdout;pre=$MODULE_PREFIX;suf=.ldcref:REALPRJNAME} -Wl,--no-demangle
  1231. LINK_ADDITIONAL_SECTIONS+=--add-section=.ya.linker_cref=${tmp;pre=$MODULE_PREFIX;suf=.ldcref:REALPRJNAME}
  1232. }
  1233. elsewhen ($DUMP_LINKER_CREF == "yes") {
  1234. LDFLAGS+=-Wl,--cref ${output;stdout;pre=$MODULE_PREFIX;suf=.ldcref:REALPRJNAME} -Wl,--no-demangle
  1235. }
  1236. when ($EMBED_LINKER_MAP == "yes") {
  1237. LDFLAGS+=-Wl,-Map=${tmp;pre=$MODULE_PREFIX;suf=.map.$_LINKER_ID:REALPRJNAME}
  1238. LINK_ADDITIONAL_SECTIONS+=--add-section=.ya.linker_map.${_LINKER_ID}=${tmp;pre=$MODULE_PREFIX;suf=.map.$_LINKER_ID:REALPRJNAME}
  1239. }
  1240. elsewhen ($DUMP_LINKER_MAP == "yes") {
  1241. LDFLAGS+=-Wl,-Map=${output;rootrel;pre=$MODULE_PREFIX;suf=.map.$_LINKER_ID:REALPRJNAME}
  1242. }
  1243. when ($USE_MKL == "yes") {
  1244. NOPLATFORM=yes
  1245. }
  1246. when (($USE_EAT_MY_DATA == "yes") && ($WIN32 != "yes") && ($DARWIN != "yes") && ($OS_ANDROID != "yes") && ($OS_IOS != "yes")) {
  1247. PEERDIR+=contrib/libs/libeatmydata/autocheck_wrapper
  1248. }
  1249. when ($USE_ARCADIA_LIBM == "yes") {
  1250. PEERDIR+=contrib/libs/libm
  1251. }
  1252. when ($USE_ARCADIA_LIBM == "no") {
  1253. C_SYSTEM_LIBRARIES+=-lm
  1254. }
  1255. when (($MUSL != "yes" && $WITH_VALGRIND == "yes") || $SANITIZER_DEFINED == "yes") {
  1256. when ($ALLOCATOR in [ "TCMALLOC", "TCMALLOC_SMALL_BUT_SLOW", "TCMALLOC_NUMA_256K", "TCMALLOC_NUMA_LARGE_PAGES", "TCMALLOC_256K", "GOOGLE", "J", "LF", "LF_YT", "LF_DBG", "B", "BM", "C", "LOCKLESS", "YT", "MIM", "HU" ]) {
  1257. PEERDIR+=library/cpp/malloc/system
  1258. }
  1259. }
  1260. otherwise {
  1261. select ($ALLOCATOR) {
  1262. "MIM" ? {
  1263. PEERDIR+=library/cpp/malloc/mimalloc
  1264. }
  1265. "HU" ? {
  1266. PEERDIR+=library/cpp/malloc/hu
  1267. }
  1268. "TCMALLOC_256K" ? {
  1269. PEERDIR+=library/cpp/malloc/tcmalloc
  1270. PEERDIR+=contrib/libs/tcmalloc
  1271. }
  1272. "TCMALLOC_SMALL_BUT_SLOW" ? {
  1273. PEERDIR+=library/cpp/malloc/tcmalloc
  1274. PEERDIR+=contrib/libs/tcmalloc/small_but_slow
  1275. }
  1276. "TCMALLOC_NUMA_256K" ? {
  1277. PEERDIR+=library/cpp/malloc/tcmalloc
  1278. PEERDIR+=contrib/libs/tcmalloc/numa_256k
  1279. }
  1280. "TCMALLOC_NUMA_LARGE_PAGES" ? {
  1281. PEERDIR+=library/cpp/malloc/tcmalloc
  1282. PEERDIR+=contrib/libs/tcmalloc/numa_large_pages
  1283. }
  1284. "TCMALLOC" ? {
  1285. PEERDIR+=library/cpp/malloc/tcmalloc
  1286. PEERDIR+=contrib/libs/tcmalloc/default
  1287. }
  1288. "GOOGLE" ? {
  1289. PEERDIR+=library/cpp/malloc/galloc
  1290. }
  1291. "J" ? {
  1292. when ($WIN32 == "yes") {
  1293. PEERDIR+=library/cpp/malloc/system
  1294. }
  1295. otherwise {
  1296. PEERDIR+=library/cpp/malloc/jemalloc
  1297. }
  1298. }
  1299. "LF" ? {
  1300. PEERDIR+=library/cpp/lfalloc
  1301. }
  1302. "LF_YT" ? {
  1303. PEERDIR+=library/cpp/lfalloc/yt
  1304. }
  1305. "LF_DBG" ? {
  1306. PEERDIR+=library/cpp/lfalloc/dbg
  1307. }
  1308. "B" ? {
  1309. PEERDIR+=library/cpp/balloc
  1310. }
  1311. "BM" ? {
  1312. PEERDIR+=library/cpp/balloc_market
  1313. }
  1314. "C" ? {
  1315. PEERDIR+=library/cpp/malloc/calloc
  1316. }
  1317. "LOCKLESS" ? {
  1318. PEERDIR+=library/cpp/malloc/lockless
  1319. }
  1320. "YT" ? {
  1321. PEERDIR+=library/cpp/ytalloc/impl
  1322. }
  1323. }
  1324. }
  1325. when ($ALLOCATOR == "SYSTEM") {
  1326. PEERDIR+=library/cpp/malloc/system
  1327. }
  1328. when ($WERROR != "no") {
  1329. when ($WERROR_MODE == "all" || ($WERROR_MODE == "compiler_specific" && $WERROR == "yes")) {
  1330. C_WARNING_OPTS += $WERROR_FLAG
  1331. }
  1332. }
  1333. when ($ICC == "yes") {
  1334. PEERDIR+=contrib/libs/intel/core
  1335. }
  1336. when ($WITH_VALGRIND == "yes") {
  1337. PEERDIR+=contrib/libs/valgrind
  1338. }
  1339. }
  1340. when ($EMBED_LINKER_MAP == "yes" || $EMBED_LINKER_CREF == "yes") {
  1341. LINK_ADDITIONAL_SECTIONS_COMMAND+= \
  1342. $OBJCOPY_TOOL $LINK_ADDITIONAL_SECTIONS $TARGET
  1343. }
  1344. _SO_EXT_FILTER=${ext=.so:PEERS} ${hide;late_out;nopath;ext=.so;pre=$BINDIR/:PEERS}
  1345. when ($OS_WINDOWS == "yes") {
  1346. _SO_EXT_FILTER=${ext=.dll:PEERS} ${hide;late_out;nopath;ext=.dll;pre=$BINDIR/:PEERS}
  1347. }
  1348. elsewhen ($OS_DARWIN == "yes" || $OS_IOS == "yes") {
  1349. _SO_EXT_FILTER=${ext=.dylib:PEERS} ${hide;late_out;nopath;ext=.dylib;pre=$BINDIR/:PEERS}
  1350. }
  1351. LINK_OR_COPY_SO_CMD=
  1352. when ($SO_OUTPUTS == "yes") {
  1353. LINK_OR_COPY_SO_CMD=$FS_TOOLS link_or_copy_to_dir --no-check $_SO_EXT_FILTER ${BINDIR}
  1354. LDFLAGS+=$RPATH_GLOBAL
  1355. }
  1356. # tag:restrinced tag:DLL
  1357. ### $usage: WITH_DYNAMIC_LIBS() # restricted
  1358. ###
  1359. ### Include dynamic libraries as extra PROGRAM/DLL outputs
  1360. macro WITH_DYNAMIC_LIBS() {
  1361. ENABLE(SO_OUTPUTS)
  1362. }
  1363. # tag:internal
  1364. ### $usage: REAL_LINK_EXE_IMPL(peers...) # internal
  1365. macro REAL_LINK_EXE_IMPL(WHOLE_ARCHIVE_PEERS...) {
  1366. .CMD=$REAL_LINK_EXE_CMDLINE && $LINK_OR_COPY_SO_CMD
  1367. }
  1368. # tag:internal
  1369. ### $usage: REAL_LINK_EXEC_DYN_LIB_IMPL(peers...) # internal
  1370. macro REAL_LINK_EXEC_DYN_LIB_IMPL(WHOLE_ARCHIVE_PEERS...) {
  1371. .CMD=$REAL_LINK_EXEC_DYN_LIB_CMDLINE
  1372. }
  1373. # tag:internal
  1374. ### $usage: REAL_LINK_DYN_LIB_IMPL(peers...) # internal
  1375. macro REAL_LINK_DYN_LIB_IMPL(WHOLE_ARCHIVE_PEERS...) {
  1376. .CMD=$REAL_LINK_DYN_LIB_CMDLINE && $LINK_OR_COPY_SO_CMD
  1377. }
  1378. # tag:internal
  1379. ### $usage: LINK_EXE_IMPL(peers...) # internal
  1380. macro LINK_EXE_IMPL(WHOLE_ARCHIVE_PEERS...) {
  1381. .CMD=$LINK_EXE_CMDLINE && $LINK_OR_COPY_SO_CMD
  1382. }
  1383. # tag:internal
  1384. ### $usage: LINK_EXEC_DYN_LIB_IMPL(peers...) # internal
  1385. macro LINK_EXEC_DYN_LIB_IMPL(WHOLE_ARCHIVE_PEERS...) {
  1386. .CMD=$LINK_EXEC_DYN_LIB_CMDLINE
  1387. }
  1388. # tag:internal
  1389. ### @usage: _LINK_UNIT # internal
  1390. ###
  1391. ### The base of all linkable modules: programs, DLLs etc. Describes common linking logic.
  1392. module _LINK_UNIT: _BASE_UNIT {
  1393. .EXTS=.o .obj .supp .tidyjson .ld
  1394. .CMD=LINK_EXE
  1395. .ALLOWED=EXTRALIBS OBJADDE_GLOBAL RESOURCE_FILES
  1396. .NODE_TYPE=Program
  1397. .PEERDIR_POLICY=as_build_from
  1398. .FINAL_TARGET=yes
  1399. DEFAULT(ALLOCATOR $DEFAULT_ALLOCATOR)
  1400. _USE_LINKER()
  1401. #link with libunwind manually
  1402. when ($DARWIN == "yes" && $NOPLATFORM != "yes") {
  1403. PEERDIR += contrib/libs/cxxsupp
  1404. }
  1405. when ($USE_LIBCXXRT == "yes") {
  1406. PEERDIR += contrib/libs/cxxsupp/libcxxrt
  1407. }
  1408. ENABLE(COMMON_LINK_SETTINGS)
  1409. CHECK_PROVIDES()
  1410. }
  1411. MODULE_TYPE=UNKNOWN
  1412. macro ADD_CLANG_TIDY() {
  1413. ADD_YTEST($MODULE_PREFIX$REALPRJNAME clang_tidy)
  1414. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS ${ARCADIA_ROOT}/build/yandex_specific/config/clang_tidy/tidy_project_map.json)
  1415. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS ${ARCADIA_ROOT}/build/yandex_specific/config/clang_tidy/tidy_default_map.json)
  1416. }
  1417. # tag:internal
  1418. ### @usage: _BASE_PROGRAM # internal
  1419. ###
  1420. ### The base of all programs. It adds dependencies to make final artefact complete and runnable.
  1421. module _BASE_PROGRAM: _LINK_UNIT {
  1422. .SYMLINK_POLICY=EXE
  1423. .ALLOWED=INDUCED_DEPS WHOLE_ARCHIVE
  1424. .GLOBAL=LDFLAGS _WHOLE_ARCHIVE_LIBS_VALUE RPATH
  1425. SET(MODULE_TYPE PROGRAM)
  1426. when ($OS_IOS == "yes") {
  1427. EXTS+=.ios.interface
  1428. }
  1429. when ($WIN32 == "yes" || $OS_CYGWIN == "yes") {
  1430. MODULE_SUFFIX=.exe
  1431. }
  1432. when ($TIDY == "yes") {
  1433. MODULE_SUFFIX=.tidyjson
  1434. }
  1435. when ($MSVC != "yes" && $NOPLATFORM != "yes" && $WITH_VALGRIND != "yes" && $USE_ASMLIB != "no" && $MIC_ARCH != "yes" && $PIC != "yes" && $PIE != "yes") {
  1436. PEERDIR+=contrib/libs/asmlib
  1437. }
  1438. when ($MUSL == "yes") {
  1439. when ($MUSL_LITE == "yes") {
  1440. PEERDIR += contrib/libs/musl
  1441. }
  1442. otherwise {
  1443. PEERDIR += contrib/libs/musl/full
  1444. }
  1445. }
  1446. when ($USE_DYNAMIC_CUDA == "yes") {
  1447. LINK_SCRIPT_EXE_FLAGS += --dynamic-cuda
  1448. }
  1449. DEFAULT(CPU_CHECK yes)
  1450. when ($USE_SSE4 != "yes" || $NOUTIL == "yes" || $ALLOCATOR == "FAKE") {
  1451. CPU_CHECK = no
  1452. }
  1453. when ($CPU_CHECK == "yes") {
  1454. PEERDIR += library/cpp/cpuid_check
  1455. }
  1456. when ($USE_ARC_PROFILE == "yes" && $NOUTIL != "yes") {
  1457. PEERDIR += library/cpp/execprofile/autostart
  1458. }
  1459. when ($SANITIZER_DEFINED == "yes") {
  1460. PEERDIR += contrib/libs/cxxsupp/libsan
  1461. }
  1462. when ($CLANG_COVERAGE && $CLANG_COVERAGE != "no") {
  1463. PEERDIR+=library/cpp/testing/dump_clang_coverage
  1464. }
  1465. when ($IDE_MSVS == "yes") {
  1466. PEERDIR+=build/scripts/c_templates
  1467. }
  1468. when ($_CUSTOM_LINK_STEP_SCRIPT) {
  1469. LINK_SCRIPT_EXE_FLAGS+=--python=$YMAKE_PYTHON --custom-step=${input:_CUSTOM_LINK_STEP_SCRIPT}
  1470. }
  1471. }
  1472. CPP_PROGRAM_SEM=add_executable $MODDIR $REALPRJNAME ${hide:TARGET} ${hide:AUTO_INPUT} \
  1473. && vcs_info \
  1474. && target_link_flags PUBLIC $LDFLAGS $LDFLAGS_GLOBAL $OBJADDE_LIB $OBJADDE \
  1475. && target_include_directories PRIVATE $_C__INCLUDE_OWNED \
  1476. && target_compile_options PRIVATE $USER_CFLAGS $USER_CXXFLAGS
  1477. ### @usage: PROGRAM([progname])
  1478. ###
  1479. ### Regular program module.
  1480. ### If name is not specified it will be generated from the name of the containing project directory.
  1481. module PROGRAM: _BASE_PROGRAM {
  1482. .SEM=CPP_PROGRAM_SEM
  1483. ADD_YTEST($MODULE_PREFIX$REALPRJNAME coverage.extractor)
  1484. ADD_CLANG_TIDY()
  1485. SET(MODULE_LANG CPP)
  1486. }
  1487. # tag:python-specific tag:deprecated tag:internal
  1488. module _PY2_PROGRAM: _BASE_PY_PROGRAM {
  1489. SET(MODULE_LANG PY2)
  1490. # Looks like we cannot avoid copy-paste util ymake supports multiple inheritance
  1491. # We need to attach coverage.extractor to every py_program target, except pytest targets
  1492. ADD_YTEST($MODULE_PREFIX$REALPRJNAME coverage.extractor)
  1493. }
  1494. # tag:python-specific tag:deprecated
  1495. ### @usage: PY2_PROGRAM([progname]) # deprecated
  1496. ###
  1497. ### Deprecated. Use PY3_PROGRAM instead.
  1498. ### Python 2.x binary program. Links all Python 2.x libraries and Python 2.x interpreter into itself to form regular executable.
  1499. ### If name is not specified it will be generated from the name of the containing project directory.
  1500. ### This only compatible with PYTHON2-tagged modules and selects those from multimodules.
  1501. ###
  1502. ### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/py_srcs/
  1503. module PY2_PROGRAM: _PY2_PROGRAM {
  1504. when ($FAIL_PY2 == "yes") {
  1505. _OK=no
  1506. }
  1507. otherwise {
  1508. PEERDIR+=build/rules/py2_deprecation
  1509. }
  1510. ASSERT(_OK You are using deprecated Python2-only code (PY2_PROGRAM). Please consider rewriting to Python 3.)
  1511. }
  1512. # tag:python-specific
  1513. ### @usage: NO_EXTENDED_SOURCE_SEARCH()
  1514. ###
  1515. ### Prevent module using in extended python source search.
  1516. ### Use the macro if module contains python2-only files (or other python sources which shouldn't be imported by python3 interpreter)
  1517. ### which resides in the same directories with python 3 usefull code. contrib/python/future is a example.
  1518. ### Anyway, preferred way is to move such files into separate dir and don't use this macro at all.
  1519. ###
  1520. ### Also see: https://docs.yandex-team.ru/ya-make/manual/python/vars#y_python_extended_source_search for details
  1521. macro NO_EXTENDED_SOURCE_SEARCH() {
  1522. SET(NO_EXTENDED_SOURCE_SEARCH yes)
  1523. }
  1524. # tag:python-specific
  1525. ### @usage: PY3_PROGRAM([progname])
  1526. ###
  1527. ### Python 3.x binary program. Links all Python 3.x libraries and Python 3.x interpreter into itself to form regular executable.
  1528. ### If name is not specified it will be generated from the name of the containing project directory.
  1529. ### This only compatible with PYTHON3-tagged modules and selects those from multimodules.
  1530. ###
  1531. ### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/py_srcs/
  1532. multimodule PY3_PROGRAM {
  1533. module PY3_BIN: PY3_PROGRAM_BIN {
  1534. .PEERDIRSELF=PY3_BIN_LIB
  1535. .IGNORED=RESOURCE RESOURCE_FILES PEERDIR TASKLET_REG
  1536. # Notify pybuild to skip almost all PY_SRCS arguments except MAIN
  1537. ENABLE(PROCESS_PY_MAIN_ONLY)
  1538. _PY_PROGRAM()
  1539. }
  1540. module PY3_BIN_LIB: PY3_LIBRARY {
  1541. .IGNORED=RESTRICT_LICENSES
  1542. # Notify pybuild to skip all python main function definitions
  1543. ENABLE(IGNORE_PY_MAIN)
  1544. _REQUIRE_EXPLICIT_LICENSE()
  1545. }
  1546. }
  1547. # tag:ycr-specific
  1548. macro _YCR_GENERATE_CONFIGS_INTL(Package, App, Configs...) {
  1549. .CMD=${tool:"maps/infra/yacare/scripts/make_configs"} $Package $App ${cwd:BINDIR} ${output;hide;pre=debian/$Package/:Configs}
  1550. }
  1551. # tag:ycr-specific
  1552. macro _YCR_GENERATE_CONFIGS(Package, App) {
  1553. .CMD=$_YCR_GENERATE_CONFIGS_INTL($Package $App ${pre=etc/yandex/maps/yacare/:App.conf} ${pre=etc/template_generator/templates/etc/logrotate.d/:App} ${pre=etc/nginx/sites-available/:App.conf} ${pre=etc/syslog-ng/conf-available/:App.conf} ${pre=etc/template_generator/config.d/:App.yaml} ${pre=/juggler/checks-available/yacare_;suf=/MANIFEST.json:App} ${pre=etc/yandex/maps/roquefort/:App.conf} ${pre=usr/lib/yandex/maps/yacare/lua/init_worker.d/rate_limiter_:App.lua} ${pre=usr/lib/yandex/maps/yacare/lua/init_worker.d/tvm_:App.lua} ${pre=usr/lib/yandex/maps/yacare/lua/init.d/tvm_:App.lua} ${pre=etc/template_generator/templates/etc/supervisor/conf-available/:App.conf} ${pre=etc/template_generator/templates/etc/yandex/unified_agent/conf.d/04_yacare_:App.yml})
  1554. }
  1555. # tag:ycr-specific
  1556. when ($TIDY=="yes") {
  1557. YCR_LINK_EXE=$LINK_EXE
  1558. }
  1559. otherwise {
  1560. YCR_LINK_EXE=$LINK_EXE && $_YCR_GENERATE_CONFIGS($MODULE_PREFIX$REALPRJNAME $MODULE_PREFIX$REALPRJNAME)
  1561. }
  1562. # tag:ycr-specific
  1563. ### @usage: YCR_PROGRAM([progname])
  1564. ###
  1565. ### yacare-specific program module. Generates yacare configs in addition to producing the program.
  1566. ### If name is not specified it will be generated from the name of the containing project directory.
  1567. module YCR_PROGRAM: PROGRAM {
  1568. .CMD=YCR_LINK_EXE
  1569. }
  1570. # tag:ycr-specific tag:python-specific
  1571. macro _PYCR_GENERATE_CONFIGS_INTL(Package, App, Configs...) {
  1572. .CMD=${tool:"maps/infra/pycare/scripts/make_configs"} $Package $App ${cwd:BINDIR} ${output;hide;pre=configs/:Configs}
  1573. }
  1574. # tag:ycr-specific tag:python-specific
  1575. macro _PYCR_GENERATE_CONFIGS(Package, App) {
  1576. .CMD=$_PYCR_GENERATE_CONFIGS_INTL($Package $App ${pre=etc/nginx/sites-available/:App.conf} ${pre=etc/template_generator/templates/etc/logrotate.d/:App} ${pre=etc/syslog-ng/conf-available/:App.conf} ${pre=etc/yandex/maps/roquefort/:App.conf} ${pre=etc/template_generator/config.d/:App.yaml} ${pre=etc/supervisor/conf-available/:App.conf} ${pre=etc/template_generator/templates/etc/yandex/unified_agent/conf.d/04_pycare_:App.yml})
  1577. }
  1578. # tag:ycr-specific tag:python-specific
  1579. PYCR_LINK_EXE=$LINK_EXE && $_PYCR_GENERATE_CONFIGS($MODULE_PREFIX$REALPRJNAME $MODULE_PREFIX$REALPRJNAME)
  1580. # tag:ycr-specific tag:python-specific
  1581. ### @usage: PYCR_PROGRAM([progname])
  1582. ###
  1583. ### pycare-specific program module. Generates pycare configs in addition to producing the program.
  1584. ### If name is not specified it will be generated from the name of the containing project directory.
  1585. module PYCR_PROGRAM: PY3_PROGRAM_BIN {
  1586. .CMD=PYCR_LINK_EXE
  1587. }
  1588. ### @usage: EXPORTS_SCRIPT(exports_file)
  1589. ###
  1590. ### Specify exports script within PROGRAM, DLL and DLL-derived modules.
  1591. ### This accepts 2 kind of files: .exports with <lang symbol> pairs and JSON-line .symlist files.
  1592. ### The other option use EXPORTS parameter of the DLL module itself.
  1593. ###
  1594. ### @see: [DLL](#module_DLL)
  1595. macro EXPORTS_SCRIPT(Arg) {
  1596. SET(EXPORTS_FILE $Arg)
  1597. }
  1598. ### @usage: NO_EXPORT_DYNAMIC_SYMBOLS()
  1599. ###
  1600. ### Disable exporting all non-hidden symbols as dynamic when linking a PROGRAM.
  1601. macro NO_EXPORT_DYNAMIC_SYMBOLS() {
  1602. ENABLE(NO_EXPORT_DYNAMIC_SYMBOLS)
  1603. }
  1604. ### @usage: EXPORT_ALL_DYNAMIC_SYMBOLS()
  1605. ###
  1606. ### Export all non-hidden symbols as dynamic when linking a PROGRAM.
  1607. macro EXPORT_ALL_DYNAMIC_SYMBOLS() {
  1608. # Dummy: default behaviour
  1609. ENABLE(EXPORT_ALL_DYNAMIC_SYMBOLS)
  1610. }
  1611. ### @usage: USE_DYNAMIC_CUDA()
  1612. ###
  1613. ### Enable linking of PROGRAM with dynamic CUDA. By default CUDA uses static linking
  1614. macro USE_DYNAMIC_CUDA() {
  1615. ENABLE(USE_DYNAMIC_CUDA)
  1616. }
  1617. ### @usage: CUSTOM_LINK_STEP_SCRIPT(name)
  1618. ###
  1619. ### Specifies name of a script for custom link step. The scripts
  1620. ### should be placed in the build/scripts directory and are subject to
  1621. ### review by devtools@.
  1622. macro CUSTOM_LINK_STEP_SCRIPT(Name) {
  1623. SET(_CUSTOM_LINK_STEP_SCRIPT build/scripts/$Name)
  1624. }
  1625. ### @usage: _BASE_UNITTEST # internal
  1626. ###
  1627. ### Module with base logic for all unit-test modules: it makes code runnable as unit-test by Arcadia testing machinery.
  1628. module _BASE_UNITTEST: _BASE_PROGRAM {
  1629. .FINAL_TARGET=no
  1630. .NODE_TYPE=Program
  1631. .ALLOWED=YT_SPEC
  1632. when ($UT_SKIP_EXCEPTIONS == "yes") {
  1633. C_DEFINES+=-DUT_SKIP_EXCEPTIONS
  1634. }
  1635. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS canondata/result.json)
  1636. }
  1637. UNITTEST_SEM=$CPP_PROGRAM_SEM && add_test NAME $REALPRJNAME COMMAND $REALPRJNAME --print-before-suite --print-before-test --fork-tests --print-times --show-fails
  1638. # tag:test
  1639. ### @usage: UNITTEST([name])
  1640. ###
  1641. ### Unit test module based on library/cpp/testing/unittest.
  1642. ### It is recommended not to specify the name.
  1643. ###
  1644. ### Documentation: https://wiki.yandex-team.ru/yatool/test/#opisanievya.make1
  1645. module UNITTEST: _BASE_UNITTEST {
  1646. .SEM=UNITTEST_SEM
  1647. PEERDIR(library/cpp/testing/unittest_main)
  1648. ADD_YTEST($MODULE_PREFIX$REALPRJNAME unittest.py)
  1649. SET(MODULE_LANG CPP)
  1650. }
  1651. # tag:yt-specific tag:test
  1652. ### @usage: YT_UNITTEST([name])
  1653. ###
  1654. ### YT Unit test module based on mapreduce/yt/library/utlib
  1655. module YT_UNITTEST: _BASE_UNITTEST {
  1656. PEERDIR(mapreduce/yt/library/utlib)
  1657. ADD_YTEST($MODULE_PREFIX$REALPRJNAME unittest.py)
  1658. }
  1659. # tag:test
  1660. ### @usage: UNITTEST_WITH_CUSTOM_ENTRY_POINT([name])
  1661. ###
  1662. ### Generic unit test module.
  1663. module UNITTEST_WITH_CUSTOM_ENTRY_POINT: _BASE_UNITTEST {
  1664. ADD_YTEST($MODULE_PREFIX$REALPRJNAME unittest.py)
  1665. }
  1666. # tag:cpp-specific tag:test
  1667. ### @usage: GTEST([name])
  1668. ###
  1669. ### Unit test module based on library/cpp/testing/gtest.
  1670. ### It is recommended not to specify the name.
  1671. ###
  1672. ### Documentation: https://docs.yandex-team.ru/arcadia-cpp/cpp_test
  1673. module GTEST: _BASE_UNITTEST {
  1674. .SEM=UNITTEST_SEM
  1675. PEERDIR(library/cpp/testing/gtest library/cpp/testing/gtest_main)
  1676. ADD_YTEST($MODULE_PREFIX$REALPRJNAME gunittest)
  1677. SET(MODULE_LANG CPP)
  1678. }
  1679. USE_AFL=no
  1680. # tag:fuzzing
  1681. ### @usage: FUZZ()
  1682. ###
  1683. ### In order to start using Fuzzing in Arcadia, you need to create a FUZZ module with the implementation of the function LLVMFuzzerTestOneInput().
  1684. ### This module should be reachable by RECURSE from /autocheck project in order for the corpus to be regularly updated.
  1685. ### AFL and Libfuzzer are supported in Arcadia via a single interface, but the automatic fuzzing still works only through Libfuzzer.
  1686. ###
  1687. ### Example: https://a.yandex-team.ru/arc/trunk/arcadia/contrib/libs/re2/re2/fuzzing/re2_fuzzer.cc?rev=2919463#L58
  1688. ###
  1689. ### Documentation: https://wiki.yandex-team.ru/yatool/fuzzing/
  1690. module FUZZ: _BASE_PROGRAM {
  1691. .NODE_TYPE=Program
  1692. .FINAL_TARGET=no
  1693. .ALLOWED=FUZZ_DICTS FUZZ_OPTS
  1694. DEFAULT(LIBFUZZER_PATH contrib/libs/libfuzzer12)
  1695. when ($USE_AFL == "no") {
  1696. PEERDIR+=$LIBFUZZER_PATH
  1697. }
  1698. when ($USE_AFL == "yes") {
  1699. PEERDIR+=$LIBFUZZER_PATH/afl
  1700. }
  1701. when (!$SANITIZER_TYPE || $SANITIZER_TYPE == "no") {
  1702. PEERDIR+=devtools/nofuzz
  1703. }
  1704. ADD_YTEST($MODULE_PREFIX$REALPRJNAME fuzz.test)
  1705. }
  1706. # tag:ios-specific
  1707. PACK_IOS_CMD=
  1708. when ($OS_IOS && $BUILD_IOS_APP) {
  1709. PACK_IOS_CMD=$YMAKE_PYTHON ${input:"build/scripts/pack_ios.py"} --binary $TARGET --target $TARGET --temp-dir $BINDIR $PEERS
  1710. }
  1711. LINK_BOOSTTEST_CMD=
  1712. BOOST_TEST_TYPE_STRING=
  1713. when ($BOOSTTEST_IS_FAT_OBJECT) {
  1714. LINK_BOOSTTEST_CMD=$LINK_RECURSIVE_LIBRARY
  1715. BOOST_TEST_TYPE_STRING=no.test
  1716. }
  1717. otherwise {
  1718. LINK_BOOSTTEST_CMD=$LINK_EXE
  1719. BOOST_TEST_TYPE_STRING=boost.test
  1720. }
  1721. # tag:deprecated
  1722. ### @usage: BOOSTTEST([name]) #deprecated
  1723. ###
  1724. ### Test module based on boost/test/unit_test.hpp.
  1725. ### As with entire boost library usage of this technology is deprecated in Arcadia and restricted with configuration error in most of projects.
  1726. ### No new module of this type should be introduced unless it is explicitly approved by C++ committee.
  1727. module BOOSTTEST: _BASE_PROGRAM {
  1728. .NODE_TYPE=Program
  1729. .FINAL_TARGET=no
  1730. .CMD=LINK_BOOSTTEST_CMD
  1731. PEERDIR(library/cpp/testing/boost_test)
  1732. when ($BOOSTTEST_IS_FAT_OBJECT) {
  1733. MODULE_SUFFIX=.a
  1734. }
  1735. elsewhen ($OS_IOS && $BUILD_IOS_APP) {
  1736. PEERDIR+=devtools/boosttest_ios_wrapper/library
  1737. MODULE_SUFFIX=.ios.tar
  1738. }
  1739. ADD_YTEST($MODULE_PREFIX$REALPRJNAME $BOOST_TEST_TYPE_STRING)
  1740. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS canondata/result.json)
  1741. }
  1742. # tag:deprecated
  1743. ### @usage BOOSTTEST_WITH_MAIN([name]) #deprecated
  1744. ###
  1745. ### Same as BOOSTTEST (see above), but comes with builtin int main(argc, argv) implementation
  1746. module BOOSTTEST_WITH_MAIN: BOOSTTEST {
  1747. PEERDIR(library/cpp/testing/boost_test_main)
  1748. }
  1749. FUZZ_DICTS_VALUE=
  1750. ### @usage: FUZZ_DICTS(path1 [path2...])
  1751. ###
  1752. ### Allows you to specify dictionaries, relative to the root of Arcadia, which will be used in Fuzzing.
  1753. ### Libfuzzer and AFL use a single syntax for dictionary descriptions.
  1754. ### Should only be used in FUZZ modules.
  1755. ###
  1756. ### Documentation: https://wiki.yandex-team.ru/yatool/fuzzing/
  1757. macro FUZZ_DICTS(Data...) {
  1758. SET_APPEND(FUZZ_DICTS_VALUE $Data)
  1759. }
  1760. FUZZ_OPTS_VALUE=
  1761. ### @usage: FUZZ_OPTS(opt1 [Opt2...])
  1762. ###
  1763. ### Overrides or adds options to the corpus mining and fuzzer run.
  1764. ### Currently supported only Libfuzzer, so you should use the options for it.
  1765. ### Should only be used in FUZZ modules.
  1766. ###
  1767. ### @example:
  1768. ###
  1769. ### FUZZ_OPTS (
  1770. ### -max_len=1024
  1771. ### -rss_limit_mb=8192
  1772. ### )
  1773. ###
  1774. ### Documentation: https://wiki.yandex-team.ru/yatool/fuzzing/
  1775. macro FUZZ_OPTS(Data...) {
  1776. SET_APPEND(FUZZ_OPTS_VALUE $Data)
  1777. }
  1778. # tag:yt-specific tag:test
  1779. TEST_YT_SPEC_VALUE=
  1780. ### @usage: YT_SPEC(path1 [path2...])
  1781. ###
  1782. ### Allows you to specify json-files with YT task and operation specs,
  1783. ### which will be used to run test node in the YT.
  1784. ### Test must be marked with ya:yt tag.
  1785. ### Files must be relative to the root of Arcadia.
  1786. ###
  1787. ### Documentation: https://wiki.yandex-team.ru/yatool/test/
  1788. macro YT_SPEC(Data...) {
  1789. SET_APPEND(TEST_YT_SPEC_VALUE $Data)
  1790. }
  1791. # tag:test
  1792. TEST_SRCS_VALUE=
  1793. ### @usage: TEST_SRCS(Files...)
  1794. ###
  1795. ### In PY2TEST, PY3TEST and PY*_LIBRARY modules used as PY_SRCS macro and additionally used to mine test cases to be executed by testing framework.
  1796. ###
  1797. ### Documentation: https://wiki.yandex-team.ru/yatool/test/#testynapytest
  1798. macro TEST_SRCS(Tests...) {
  1799. SET_APPEND(TEST_SRCS_VALUE $Tests)
  1800. }
  1801. macro DISABLE_DATA_VALIDATION() {
  1802. DISABLE(VALIDATE_DATA)
  1803. }
  1804. # tag:test
  1805. TEST_DATA_VALUE=
  1806. ### @usage: DATA([path...])
  1807. ###
  1808. ### Specifies the path to the data necessary test.
  1809. ### Valid values are: arcadia/<path> , arcadia_tests_data/<path> and sbr://<resource_id>.
  1810. ### In the latter case resource will be brought to the working directory of the test before it is started
  1811. ###
  1812. ### Used only inside TEST modules.
  1813. ###
  1814. ### Documentation: https://wiki.yandex-team.ru/yatool/test/#dannyeizrepozitorija
  1815. macro DATA(Data...) {
  1816. SET_APPEND(TEST_DATA_VALUE $Data)
  1817. ADD_CHECK(check.data $Data)
  1818. }
  1819. # tag:test
  1820. TEST_TAGS_VALUE=
  1821. ### @usage: TAG ([tag...])
  1822. ###
  1823. ### Each test can have one or more tags used to filter tests list for running.
  1824. ### There are also special tags affecting test behaviour, for example ya:external, sb:ssd.
  1825. ###
  1826. ### Documentation: https://wiki.yandex-team.ru/yatool/test/#obshhieponjatija
  1827. macro TAG(Tags...) {
  1828. SET_APPEND(TEST_TAGS_VALUE $Tags)
  1829. }
  1830. # tag:test
  1831. TEST_REQUIREMENTS_VALUE=
  1832. ### @usage: REQUIREMENTS([cpu:<count>] [disk_usage:<size>] [ram:<size>] [ram_disk:<size>] [container:<id>] [network:<restricted|full>] [dns:dns64])
  1833. ###
  1834. ### Allows you to specify the requirements of the test.
  1835. ###
  1836. ### Documentation about the Arcadia test system: https://wiki.yandex-team.ru/yatool/test/
  1837. macro REQUIREMENTS(Tags...) {
  1838. SET_APPEND(TEST_REQUIREMENTS_VALUE $Tags)
  1839. }
  1840. # tag:test
  1841. TEST_ENV_VALUE=
  1842. ### @usage: ENV(key[=value])
  1843. ###
  1844. ### Sets env variable key to value (gets value from system env by default).
  1845. macro ENV(Data...) {
  1846. SET_APPEND(TEST_ENV_VALUE ${quo:Data})
  1847. }
  1848. ### @usage: CONFTEST_LOAD_POLICY_LOCAL()
  1849. ###
  1850. ### Loads conftest.py files in a way that pytest does it
  1851. macro CONFTEST_LOAD_POLICY_LOCAL() {
  1852. SET_APPEND(TEST_ENV_VALUE "CONFTEST_LOAD_POLICY=LOCAL")
  1853. }
  1854. # tag:test
  1855. TEST_RECIPES_VALUE=
  1856. ### @usage: USE_RECIPE(path [arg1 arg2...])
  1857. ###
  1858. ### Provides prepared environment via recipe for test.
  1859. ###
  1860. ### Documentation: https://wiki.yandex-team.ru/yatool/test/recipes
  1861. macro USE_RECIPE(Data...) {
  1862. SET_APPEND(TEST_RECIPES_VALUE $Data)
  1863. SET_APPEND(TEST_RECIPES_VALUE "USE_RECIPE_DELIM")
  1864. }
  1865. # tag:python-specific tag:test
  1866. TEST_PYTHON_PATH_VALUE=
  1867. # tag:python-specific tag:test
  1868. ### @usage: PYTHON_PATH(Path)
  1869. ###
  1870. ### Set path to Python that will be used to runs scripts in tests
  1871. macro PYTHON_PATH(Path) {
  1872. SET(TEST_PYTHON_PATH_VALUE $Path)
  1873. }
  1874. # tag:test
  1875. SKIP_TEST_VALUE=
  1876. ### @usage: SKIP_TEST(Reason)
  1877. ###
  1878. ### Skip the suite defined by test module. Provide a reason to be output in test execution report.
  1879. macro SKIP_TEST(Reason...) {
  1880. SET(SKIP_TEST_VALUE $Reason)
  1881. }
  1882. # tag:test
  1883. LINT_LEVEL_VALUE=extended
  1884. ### @usage: NO_LINT()
  1885. ###
  1886. ### Do not check for style files included in PY_SRCS, TEST_SRCS, JAVA_SRCS.
  1887. macro NO_LINT() {
  1888. SET(LINT_LEVEL_VALUE none)
  1889. }
  1890. ### @usage: LINT(<none|base|strict>)
  1891. ###
  1892. ### Set linting levem for sources of the module
  1893. macro LINT(level) {
  1894. SET(LINT_LEVEL_VALUE $level)
  1895. }
  1896. # tag:python-specific tag:test
  1897. ### @usage: NO_DOCTESTS()
  1898. ###
  1899. ### Disable doctests in PY[|3|23_]TEST
  1900. macro NO_DOCTESTS() {
  1901. ENV(YA_PYTEST_DISABLE_DOCTEST="yes")
  1902. }
  1903. # tag:python-specific tag:test
  1904. ### @usage: _BASE_PYTEST # internal
  1905. ###
  1906. ### Base logic of Python 2.x py.test modules: common module properties and dependencies.
  1907. module _BASE_PYTEST: _BASE_PY_PROGRAM {
  1908. .NODE_TYPE=Program
  1909. .FINAL_TARGET=no
  1910. .ALLOWED=YT_SPEC NO_DOCTESTS
  1911. when ($USE_ARCADIA_PYTHON == "yes") {
  1912. PEERDIR+=library/python/pytest
  1913. }
  1914. when ($USE_ARCADIA_PYTHON == "no") {
  1915. MODULE_SUFFIX=.pkg.fake
  1916. PEERDIR+=library/python/pytest/empty
  1917. }
  1918. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS canondata/result.json)
  1919. }
  1920. # tag:python-specific tag:deprecated tag:test
  1921. ### @usage: PYTEST_BIN() #deprecated
  1922. ###
  1923. ### Same as PY2TEST. Don't use this, use PY2TEST instead.
  1924. module PYTEST_BIN: _BASE_PYTEST {
  1925. .NODE_TYPE=Program
  1926. SETUP_PYTEST_BIN()
  1927. }
  1928. # tag:python-specific tag:test
  1929. ### @usage: PY2TEST([name])
  1930. ###
  1931. ### The test module for Python 2.x based on py.test
  1932. ###
  1933. ### This module is compatible only with PYTHON2-tagged modules and selects peers from multimodules accordingly.
  1934. ### This module is compatible with non-Arcadia Python builds.
  1935. ###
  1936. ### Documentation: https://wiki.yandex-team.ru/yatool/test/#python
  1937. ### Documentation about the Arcadia test system: https://wiki.yandex-team.ru/yatool/test/
  1938. module PY2TEST: PYTEST_BIN {
  1939. when ($FAIL_PY2 == "yes") {
  1940. _OK=no
  1941. }
  1942. otherwise {
  1943. PEERDIR+=build/rules/py2_deprecation
  1944. }
  1945. SET(MODULE_LANG PY2)
  1946. ASSERT(_OK You are using deprecated Python2-only code (PY2TEST). Please consider rewriting to Python 3.)
  1947. }
  1948. # tag:python-specific tag:deprecated tag:test
  1949. ### @usage: PY3TEST_BIN() #deprecated
  1950. ###
  1951. ### Same as PY3TEST. Don't use this, use PY3TEST instead.
  1952. module PY3TEST_BIN: _BASE_PY3_PROGRAM {
  1953. .NODE_TYPE=Program
  1954. .FINAL_TARGET=no
  1955. .ALLOWED=YT_SPEC NO_DOCTESTS
  1956. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS canondata/result.json)
  1957. SET(MODULE_LANG PY3)
  1958. SETUP_PYTEST_BIN()
  1959. PEERDIR+=library/python/pytest
  1960. }
  1961. # tag:python-specific tag:test
  1962. ### Disable submodules with the specified name(s).
  1963. ### Unlike EXCLUDE_TAGS this variable:
  1964. ### - affects all projects in the build;
  1965. ### - filter by module name and ignore MODULE_TAG.
  1966. EXCLUDE_SUBMODULES=PY3TEST_LIBRARY
  1967. # tag:python-specific tag:test
  1968. ### @usage: PY3TEST([name])
  1969. ###
  1970. ### The test module for Python 3.x based on py.test
  1971. ###
  1972. ### This module is compatible only with PYTHON3-tagged modules and selects peers from multimodules accordingly.
  1973. ### This module is only compatible with Arcadia Python build (to avoid tests duplication from Python2/3-tests). For non-Arcadia python use PYTEST.
  1974. ###
  1975. ### Documentation: https://wiki.yandex-team.ru/yatool/test/#testynapytest
  1976. ### Documentation about the Arcadia test system: https://wiki.yandex-team.ru/yatool/test/
  1977. multimodule PY3TEST {
  1978. module PY3TEST_PROGRAM: PY3TEST_BIN {
  1979. .FINAL_TARGET=yes
  1980. }
  1981. module PY3TEST_LIBRARY: PY3_LIBRARY {
  1982. PEERDIR+=library/python/pytest
  1983. _REQUIRE_EXPLICIT_LICENSE()
  1984. }
  1985. }
  1986. # tag:cpp-specific tag:test
  1987. module CPP_STYLE_TEST: PY3TEST_BIN {
  1988. DEPENDS(contrib/libs/clang12/tools/clang-format)
  1989. PEERDIR+=library/python/cpp_test
  1990. }
  1991. macro STYLE(Globs...) {
  1992. _GLOB(STYLE_SRCS_GLOB ${pre=${ARCADIA_ROOT}:Globs})
  1993. _STYLE(${STYLE_SRCS_GLOB})
  1994. }
  1995. # tag:cpp-specific tag:deprecated tag:test
  1996. ### @usage: GTEST_UGLY([name])
  1997. ###
  1998. ### Deprecated, do not use in new projects. Use GTEST instead.
  1999. ###
  2000. ### The test module based on gtest (contrib/libs/gtest contrib/libs/gmock).
  2001. ### Use public documentation on gtest for details.
  2002. ###
  2003. ### Documentation about the Arcadia test system: https://wiki.yandex-team.ru/yatool/test/
  2004. module GTEST_UGLY: _BASE_PROGRAM {
  2005. .NODE_TYPE=Program
  2006. .FINAL_TARGET=no
  2007. PEERDIR(contrib/restricted/googletest/googlemock contrib/restricted/googletest/googletest)
  2008. ADD_YTEST($MODULE_PREFIX$REALPRJNAME gtest)
  2009. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS canondata/result.json)
  2010. }
  2011. # tag:test
  2012. ### @usage: EXECTEST()
  2013. ###
  2014. ### Module definition of generic test that executes a binary.
  2015. ### Use macro RUN to specify binary to run.
  2016. ###
  2017. ### @example:
  2018. ###
  2019. ### EXECTEST()
  2020. ### OWNER(g:yatool)
  2021. ###
  2022. ### RUN(
  2023. ### cat input.txt
  2024. ### )
  2025. ### DATA(
  2026. ### arcadia/devtools/ya/test/tests/exectest/data
  2027. ### )
  2028. ### DEPENDS(
  2029. ### devtools/dummy_arcadia/cat
  2030. ### )
  2031. ### TEST_CWD(devtools/ya/test/tests/exectest/data)
  2032. ### END()
  2033. ###
  2034. ### More examples: https://wiki.yandex-team.ru/yatool/test/#exec-testy
  2035. ###
  2036. ### @see: [RUN()](#macro_RUN)
  2037. module EXECTEST: _BARE_UNIT {
  2038. .NODE_TYPE=Program
  2039. .FINAL_TARGET=no
  2040. .ALLOWED=YT_SPEC
  2041. .RESTRICTED=FORK_TEST_FILES
  2042. SET(MODULE_SUFFIX .pkg.fake)
  2043. SETUP_EXECTEST()
  2044. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS canondata/result.json)
  2045. }
  2046. # tag:cpp-specific tag:test
  2047. ### @usage: Y_BENCHMARK([benchmarkname])
  2048. ###
  2049. ### Benchmark test based on the library/cpp/testing/benchmark.
  2050. ###
  2051. ### For more details see: https://wiki.yandex-team.ru/yatool/test/#zapuskbenchmark
  2052. module Y_BENCHMARK: PROGRAM {
  2053. .SEM=CPP_PROGRAM_SEM
  2054. PEERDIR(library/cpp/testing/benchmark/main)
  2055. SET(MODULE_LANG CPP)
  2056. }
  2057. # tag:cpp-specific tag:test
  2058. ### @usage: G_BENCHMARK([benchmarkname])
  2059. ###
  2060. ### Benchmark test based on the google benchmark.
  2061. ###
  2062. ### For more details see: https://a.yandex-team.ru/arc/trunk/arcadia/contrib/libs/benchmark/README.md
  2063. module G_BENCHMARK: _BASE_PROGRAM {
  2064. PEERDIR(library/cpp/testing/gbenchmark_main)
  2065. ADD_YTEST($MODULE_PREFIX$REALPRJNAME g_benchmark)
  2066. SET(MODULE_LANG CPP)
  2067. }
  2068. # tag:test
  2069. TEST_ROOT=$(TESTS_DATA_ROOT)
  2070. RESULT_MAX_FILE=0
  2071. STRIP_FILES=--dont-strip-files
  2072. VERIFY_RESULTS=--verify-results
  2073. ADDITIONAL_PATH=
  2074. # set for tests variables to fill it by YA_DEV or YA
  2075. YA_ROOT=ya
  2076. when ($YA_DEV == "yes") {
  2077. YA_ROOT=ya-dev
  2078. }
  2079. # tag:test
  2080. ### @usage: UNITTEST_FOR(path/to/lib)
  2081. ###
  2082. ### Convenience extension of UNITTEST module.
  2083. ### The UNINTTEST module with additional SRCDIR + ADDINCL + PEERDIR on path/to/lib.
  2084. ### path/to/lib is the path to the directory with the LIBRARY project.
  2085. ###
  2086. ### Documentation about the Arcadia test system: https://wiki.yandex-team.ru/yatool/test/
  2087. module UNITTEST_FOR: UNITTEST {
  2088. .SEM=UNITTEST_SEM
  2089. PEERDIR(ADDINCL $UNITTEST_DIR)
  2090. SRCDIR($UNITTEST_DIR)
  2091. }
  2092. ### @usage: _LIBRARY # internal
  2093. ###
  2094. ### Base module definition for all libraries.
  2095. ### Contains basic logic like module properties, default variable values etc.
  2096. ### All libraries similar to C++-libraries should be inherited from it.
  2097. module _LIBRARY: _BASE_UNIT {
  2098. .CMD=LINK_LIB
  2099. .NODE_TYPE=Library
  2100. .PEERDIR_POLICY=as_include
  2101. .EXTS=.o .obj .a .mf .supp .tidyjson .ld
  2102. .ALLOWED=GRPC USE_SKIFF EXTRALIBS OBJADDE_GLOBAL RESOURCE_FILES
  2103. .GLOBAL=USER_CFLAGS USER_CXXFLAGS USER_CONLYFLAGS LDFLAGS SRCS _WHOLE_ARCHIVE_LIBS_VALUE RPATH
  2104. .RESTRICTED=ALLOCATOR SIZE TAG DATA TEST_DATA DEPENDS FORK_TESTS FORK_SUBTESTS SPLIT_FACTOR TEST_CWD RUN TIMEOUT SPLIT_DWARF
  2105. .FINAL_TARGET=no
  2106. .GLOBAL_CMD=GLOBAL_LINK_LIB
  2107. .GLOBAL_EXTS=.o .obj .tidyjson
  2108. GLOBAL_SUFFIX=.global$MODULE_SUFFIX
  2109. #TODO: Remove this hack (really we do not need add fake src at all)
  2110. ENABLE(NEED_ADD_FAKE_SRC)
  2111. _REQUIRE_EXPLICIT_LICENSE(contrib/deprecated contrib/libs contrib/restricted contrib/python)
  2112. CHECK_CONTRIB_CREDITS(contrib/clickhouse contrib/libs contrib/deprecated EXCEPT contrib/deprecated/python)
  2113. when ($USE_MKL == "yes") {
  2114. NOPLATFORM=yes
  2115. }
  2116. when ($MSVC == "yes" || $CYGWIN == "yes") {
  2117. MODULE_PREFIX=
  2118. MODULE_SUFFIX=.lib
  2119. }
  2120. otherwise {
  2121. when ($TIDY == "yes") {
  2122. MODULE_PREFIX=
  2123. MODULE_SUFFIX=.tidyjson
  2124. }
  2125. otherwise {
  2126. MODULE_PREFIX=lib
  2127. MODULE_SUFFIX=.a
  2128. }
  2129. }
  2130. when ($WERROR != "no") {
  2131. when ($WERROR_MODE == "all" || ($WERROR_MODE == "compiler_specific" && $WERROR == "yes")) {
  2132. C_WARNING_OPTS += $WERROR_FLAG
  2133. }
  2134. }
  2135. when ($WITH_VALGRIND == "yes") {
  2136. PEERDIR+=contrib/libs/valgrind
  2137. }
  2138. when ($USE_ARCADIA_LIBM == "yes") {
  2139. PEERDIR+=contrib/libs/libm
  2140. }
  2141. }
  2142. CPP_LIBRARY_SEM=add_library ${MODDIR} $REALPRJNAME ${hide:TARGET} ${hide:AUTO_INPUT} \
  2143. && library_fake_marker FAKE_MODULE ${FAKE_MODULE} \
  2144. && consumer_link_library PUBLIC $CMAKE_LINK_TARGET \
  2145. && target_include_directories PUBLIC $_C__INCLUDE_GLOBAL \
  2146. && target_include_directories PRIVATE $_C__INCLUDE_OWNED \
  2147. && target_compile_options PRIVATE $USER_CFLAGS $USER_CXXFLAGS \
  2148. && target_compile_options PUBLIC $USER_CFLAGS_GLOBAL_RAW $USER_CXXFLAGS_GLOBAL_RAW \
  2149. && add_language C && add_language CXX
  2150. CPP_OBJ_LIBRARY_SEM=add_global_library_for ${MODDIR} ${suf=.global:REALPRJNAME} $REALPRJNAME ${hide:GLOBAL_TARGET} ${hide:AUTO_INPUT} \
  2151. && target_include_directories PUBLIC $_C__INCLUDE_GLOBAL \
  2152. && target_include_directories PRIVATE $_C__INCLUDE_OWNED \
  2153. && target_compile_options PRIVATE $USER_CFLAGS $USER_CXXFLAGS \
  2154. && target_compile_options PUBLIC $USER_CFLAGS_GLOBAL_RAW $USER_CXXFLAGS_GLOBAL_RAW
  2155. CMAKE_FIND_PKG=
  2156. CMAKE_LINK_TARGET=$REALPRJNAME
  2157. CMAKE_FIND_PKG_COMP=
  2158. CONAN_REQUIRE=
  2159. ### @usage: LIBRARY()
  2160. ###
  2161. ### The regular static library module.
  2162. ###
  2163. ### The LIBRARY() is intermediate module, so when built directly it won't build its dependencies.
  2164. ### It transitively provides its PEERDIRs to ultimate final target, where all LIBRARY() modules are built and linked together.
  2165. ###
  2166. ### This is C++ library, and it selects peers from multimodules accordingly.
  2167. ###
  2168. ### It makes little sense to mention LIBRARY in DEPENDS or BUNDLE, package and deploy it since it is not a standalone entity.
  2169. ### In order to use library in tests PEERDIR it to link into tests.
  2170. ### If you think you need to distribute static library please contact devtools@ for assistance.
  2171. module LIBRARY: _LIBRARY {
  2172. .GLOBAL=_AARS _PROGUARD_RULES
  2173. .SEM=CPP_LIBRARY_SEM
  2174. .GLOBAL_SEM=CPP_OBJ_LIBRARY_SEM
  2175. when ($CMAKE_PACKAGE_COMPONENT != "") {
  2176. CMAKE_FIND_PKG_COMP=COMPONENTS $CMAKE_PACKAGE_COMPONENT
  2177. }
  2178. when ($CMAKE_PACKAGE != "") {
  2179. CMAKE_FIND_PKG=find_package $CMAKE_PACKAGE $CMAKE_FIND_PKG_COMP
  2180. CPP_LIBRARY_SEM=$CMAKE_FIND_PKG && consumer_link_library PUBLIC $CMAKE_LINK_TARGET $CONAN_REQUIRE $CONAN_OPTS_SEM && ignored
  2181. }
  2182. when ($CONAN_REFERENCE != "") {
  2183. CONAN_REQUIRE=&& conan_require $CONAN_REFERENCE
  2184. CPP_LIBRARY_SEM=$CMAKE_FIND_PKG && consumer_link_library PUBLIC $CMAKE_LINK_TARGET $CONAN_REQUIRE $CONAN_OPTS_SEM && ignored
  2185. }
  2186. when ($CONAN_PKG_OPTS != "") {
  2187. CONAN_OPTS_SEM=&& conan_options $CONAN_PKG_OPTS
  2188. }
  2189. when ($OPENSOURCE_EXPORT == "no") {
  2190. CPP_LIBRARY_SEM=ignored
  2191. }
  2192. when ($HAS_CPP_PROTOBUF_PEERS == "yes") {
  2193. PEERDIR+=$CPP_PROTOBUF_PEERS
  2194. }
  2195. SET(MODULE_TYPE LIBRARY)
  2196. SET(MODULE_LANG CPP)
  2197. ADD_CLANG_TIDY()
  2198. }
  2199. # tag:internal
  2200. ### @usage: _BARE_MODULE() # internal
  2201. ###
  2202. ### Remove unwanted dependencies for "empty" library module
  2203. macro _BARE_MODULE() {
  2204. SET(NEED_PLATFORM_PEERDIRS no)
  2205. SET(PEERDIR_TEST_TOOL no)
  2206. DISABLE(WITH_VALGRIND)
  2207. NO_CODENAVIGATION()
  2208. NO_PLATFORM()
  2209. NO_RUNTIME()
  2210. NO_UTIL()
  2211. NO_CLANG_TIDY()
  2212. }
  2213. # tag:internal
  2214. ### @usage: _BARE_LINK_MODULE() # internal
  2215. ###
  2216. ### Remove unwanted dependencies for "empty" link module
  2217. macro _BARE_LINK_MODULE() {
  2218. _BARE_MODULE()
  2219. ALLOCATOR(FAKE)
  2220. }
  2221. # tag:internal
  2222. ### @usage: _CONDITIONAL_SRCS([USE_CONDITIONAL_SRCS] Files...) # internal
  2223. ###
  2224. ### Adds Files... to SRCS if first word is `USE_CONDITIONAL_SRCS`
  2225. ### To be used with some variable which is set to `USE_CONDITIONAL_SRCS` under condition
  2226. macro _CONDITIONAL_SRCS(USE_CONDITIONAL_SRCS[], DYMMY...) {
  2227. SRCS($USE_CONDITIONAL_SRCS)
  2228. }
  2229. # XXX: dirty hack for correct LDFLAGS passing
  2230. RESOURCES_LIBRARY_LINK=$TOUCH_UNIT ${hide:LDFLAGS_GLOBAL} ${hide:LDFLAGS}
  2231. RESOURCES_LIBRARY_SEM=ignored
  2232. ### @usage: RESOURCES_LIBRARY()
  2233. ###
  2234. ### Definition of a module that brings its content from external source (Sandbox) via DECLARE_EXTERNAL_RESOURCE macro.
  2235. ### This can participate in PEERDIRs of others as library but it cannot have own sources and PEERDIRs.
  2236. ###
  2237. ### @see: [DECLARE_EXTERNAL_RESOURCE()](#macro_DECLARE_EXTERNAL_RESOURCE)
  2238. module RESOURCES_LIBRARY: _BARE_UNIT {
  2239. .CMD=RESOURCES_LIBRARY_LINK
  2240. .SEM=RESOURCES_LIBRARY_SEM
  2241. .ALLOWED=DECLARE_EXTERNAL_RESOURCE EXTRALIBS OBJADDE_GLOBAL
  2242. .RESTRICTED=ALLOCATOR SIZE TAG DATA TEST_DATA DEPENDS FORK_TESTS FORK_SUBTESTS SPLIT_FACTOR TEST_CWD RUN TIMEOUT SRC SRCS PEERDIR SPLIT_DWARF
  2243. .NODE_TYPE=Library
  2244. .PEERDIR_POLICY=as_include
  2245. .EXTS=.o .obj .a .mf .supp .tidyjson .ld
  2246. .GLOBAL=USER_CFLAGS USER_CXXFLAGS USER_CONLYFLAGS LDFLAGS _WHOLE_ARCHIVE_LIBS_VALUE RPATH
  2247. MODULE_SUFFIX=.pkg.fake
  2248. ENABLE(NEED_ADD_FAKE_SRC)
  2249. WITHOUT_LICENSE_TEXTS()
  2250. }
  2251. FAT_OBJECT_ARGS=
  2252. FAT_OBJECT_OUTS=
  2253. macro _FAT_OBJECT_ARGS_BASE(Flag, Lib) {
  2254. .CMD=$Flag=$Lib
  2255. }
  2256. macro PACK_GLOBALS_IN_LIBRARY() {
  2257. SET_APPEND(FAT_OBJECT_ARGS $_FAT_OBJECT_ARGS_BASE(--globals-lib, ${BINDIR}/${pre=$MODULE_PREFIX:REALPRJNAME.globals.a}))
  2258. SET_APPEND(FAT_OBJECT_OUTS \${output;hide;noauto;norel;nopath;noext;pre=$MODULE_PREFIX;suf=$BINDIR:REALPRJNAME.globals.a})
  2259. }
  2260. when ($OS_ANDROID != "yes") {
  2261. LINK_FAT_OBJECT_CMD=$LINK_FAT_OBJECT
  2262. }
  2263. otherwise {
  2264. LINK_FAT_OBJECT_CMD=$LINK_FAT_OBJECT_LIBRARY
  2265. }
  2266. FAT_OBJECT_SEM=add_fat_object ${MODDIR} ${REALPRJNAME}.objects ${TARGET} ${hide:AUTO_INPUT} \
  2267. && target_include_directories PRIVATE $_C__INCLUDE_OWNED \
  2268. && target_compile_options PRIVATE $USER_CFLAGS $USER_CXXFLAGS \
  2269. ### @usage: FAT_OBJECT()
  2270. ###
  2271. ### The "fat" object module. It will contain all its transitive dependencies reachable by PEERDIRs:
  2272. ### static libraries, local (from own SRCS) and global (from peers') object files.
  2273. ###
  2274. ### Designed for use in XCode projects for iOS.
  2275. module FAT_OBJECT: LIBRARY {
  2276. .ALLOWED=PACK_GLOBALS_IN_LIBRARY
  2277. .CMD=LINK_FAT_OBJECT_CMD
  2278. .SEM=FAT_OBJECT_SEM
  2279. .PEERDIR_POLICY=as_build_from
  2280. when ($MSVC == "yes" || $CYGWIN == "yes") {
  2281. MODULE_SUFFIX=.global.lib
  2282. }
  2283. elsewhen ($OS_ANDROID == "yes") {
  2284. MODULE_SUFFIX=.a
  2285. }
  2286. otherwise {
  2287. MODULE_SUFFIX=.o
  2288. }
  2289. _USE_LINKER()
  2290. # This module requires at least one .o which is not subject to removal so just add _fake_src.cpp as SRCS
  2291. # ymake's handling of NEED_ADD_FAKE_SRC may insert arbitrary command, not necessarily compilation
  2292. DISABLE(NEED_ADD_FAKE_SRC)
  2293. SRCS(build/scripts/_fake_src.cpp)
  2294. }
  2295. ### @usage: RECURSIVE_LIBRARY()
  2296. ###
  2297. ### The recursive ("fat") library module. It will contain all its transitive dependencies reachable by PEERDIRs:
  2298. ### from static libraries, local (from own SRCS) and global (from peers') object files.
  2299. ###
  2300. ### Designed for use in XCode projects for iOS.
  2301. module RECURSIVE_LIBRARY: LIBRARY {
  2302. .CMD=LINK_RECURSIVE_LIBRARY
  2303. .PEERDIR_POLICY=as_build_from
  2304. # This module requires at least one .o which is not subject to removal so just add _fake_src.cpp as SRCS
  2305. # ymake's handling of NEED_ADD_FAKE_SRC may insert arbitrary command, not necessarily compilation
  2306. DISABLE(NEED_ADD_FAKE_SRC)
  2307. SRCS(build/scripts/_fake_src.cpp)
  2308. }
  2309. _SONAME=
  2310. macro _ADD_DYNLYB_SEM(Libname) {
  2311. .SEM=add_library ${MODDIR} ${Libname} SHARED ${hide:TARGET} ${hide:AUTO_INPUT} && target_include_directories PUBLIC $_C__INCLUDE_GLOBAL && target_include_directories PRIVATE $_C__INCLUDE_OWNED && target_compile_options PRIVATE $USER_CFLAGS $USER_CXXFLAGS && target_compile_options PUBLIC $USER_CFLAGS_GLOBAL_RAW $USER_CXXFLAGS_GLOBAL_RAW && vcs_info
  2312. }
  2313. CPP_DYN_LIBRARY_SEM=$_ADD_DYNLYB_SEM($REALPRJNAME)
  2314. ### @usage: DLL_UNIT # internal
  2315. ###
  2316. ### Base module for all dynamically linked libraries as final artifacts.
  2317. ### Contains all general logic for such kind of modules. Supports versioning and export files.
  2318. ### Cannot participate in linking to programs, intended to be used as final artifact (packaged and deployed).
  2319. module DLL_UNIT: _LINK_UNIT {
  2320. .CMD=LINK_DYN_LIB
  2321. .SEM=CPP_DYN_LIBRARY_SEM
  2322. .NODE_TYPE=Library
  2323. .SYMLINK_POLICY=SO
  2324. .GLOBAL=USER_CFLAGS USER_CXXFLAGS USER_CONLYFLAGS LDFLAGS _WHOLE_ARCHIVE_LIBS_VALUE RPATH
  2325. .ALLOWED=WHOLE_ARCHIVE
  2326. DYNAMIC_LINK=yes
  2327. ALLOCATOR(FAKE)
  2328. SET(MODULE_TYPE DLL)
  2329. SET(MODULE_TAG DLL)
  2330. SET(MODULE_LANG CPP)
  2331. ADD_CLANG_TIDY()
  2332. when ($MSVC == "yes" || $CYGWIN == "yes") {
  2333. MODULE_SUFFIX=.dll
  2334. }
  2335. elsewhen ($DARWIN == "yes" || $OS_IOS == "yes") {
  2336. MODULE_PREFIX=lib
  2337. MODULE_SUFFIX=.dylib
  2338. }
  2339. elsewhen ($TIDY == "yes") {
  2340. MODULE_PREFIX=
  2341. MODULE_SUFFIX=.tidyjson
  2342. }
  2343. otherwise {
  2344. MODULE_PREFIX=lib
  2345. MODULE_SUFFIX=.so
  2346. }
  2347. # This by now replicates ymake's bahavior. We'll get rid of SONAME setting in ymake and fix this code alltogether
  2348. SONAME=${pre=$MODULE_PREFIX;suf=$MODULE_SUFFIX:REALPRJNAME}
  2349. when ($MODULE_VERSION) {
  2350. LINK_DYN_LIB_FLAGS=--soname ${output;pre=$MODULE_PREFIX;suf=$MODULE_SUFFIX$MODULE_VERSION:REALPRJNAME}
  2351. }
  2352. _SONAME=$SONAME$MODULE_VERSION
  2353. when ($LINUX == "yes") {
  2354. # '-z notext' is needed for linking mkl into shared libraries
  2355. LDFLAGS += -Wl,-z,notext
  2356. when ($_NO_FIX_ELF != "yes") {
  2357. LINK_DYN_LIB_FLAGS+=--fix-elf ${tool:"tools/fix_elf"}
  2358. }
  2359. }
  2360. when ($DARWIN == "yes") {
  2361. LDFLAGS += -undefined dynamic_lookup
  2362. }
  2363. when ($CLANG_COVERAGE && $CLANG_COVERAGE != "no") {
  2364. PEERDIR+=library/cpp/testing/dump_clang_coverage
  2365. }
  2366. when ($IDE_MSVS == "yes") {
  2367. PEERDIR+=build/scripts/c_templates
  2368. }
  2369. }
  2370. # tag:python-specific
  2371. ### @usage: PY_ANY_MODULE(name major_ver [minor_ver] [EXPORTS symlist_file] [PREFIX prefix])
  2372. ###
  2373. ### The Python external module for any versio of Arcadia or system Python.
  2374. ### 1. major_ver and minor_ver must be integers.
  2375. ### 2. The resulting .so will have the prefix "lib".
  2376. ### 3. Processing EXPORTS and PREFIX is the same as for DLL module
  2377. ### This is native DLL, so it will select C++ version from PROTO_LIBRARY.
  2378. ###
  2379. ### Note: Use PYTHON2_MODULE()/PYTHON3_MODULE() in order to PEERDIR proper version of PY23_NATIVE_LIBRARY.
  2380. ### Do not PEERDIR any PY*_LIBRARY: this will link Python in and render artifact unusable as Python module.
  2381. ###
  2382. ### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/py_srcs/
  2383. module PY_ANY_MODULE: DLL_UNIT {
  2384. .SEM=CPP_DYN_LIBRARY_SEM
  2385. when ($MSVC != "yes" && $DARWIN != "yes") {
  2386. LDFLAGS+= -Wl,-Bsymbolic
  2387. }
  2388. when ($USE_ARCADIA_PYTHON == "no") {
  2389. when ($USE_SYSTEM_PYTHON) {
  2390. PEERDIR+=build/platform/python
  2391. }
  2392. otherwise {
  2393. when ($MSVC == "yes" || $CYGWIN == "yes") {
  2394. LDFLAGS+=$PYTHON_LIBRARIES
  2395. }
  2396. }
  2397. }
  2398. # This by now replicates ymake's bahavior. We'll get rid of SONAME setting in ymake and fix this code alltogether
  2399. SONAME=${pre=$MODULE_PREFIX;suf=$MODULE_SUFFIX:REALPRJNAME}
  2400. when ($MODULE_VERSION) {
  2401. LINK_DYN_LIB_FLAGS=--soname ${output;pre=$MODULE_PREFIX;suf=$MODULE_SUFFIX$MODULE_VERSION:REALPRJNAME}
  2402. }
  2403. _SONAME=$SONAME$MODULE_VERSION
  2404. # -bundle
  2405. when ($DARWIN == "yes") {
  2406. LDFLAGS+=-flat_namespace
  2407. }
  2408. when ($MSVC == "yes" || $CYGWIN == "yes") {
  2409. MODULE_PREFIX=
  2410. MODULE_SUFFIX=.pyd
  2411. }
  2412. otherwise {
  2413. MODULE_PREFIX=
  2414. MODULE_SUFFIX=.so
  2415. }
  2416. .RESTRICTED=USE_PYTHON2 USE_PYTHON3 PY_SRCS PY_MAIN
  2417. }
  2418. # tag:python-specific
  2419. ### @usage: PY2MODULE(name major_ver [minor_ver] [EXPORTS symlist_file] [PREFIX prefix])
  2420. ###
  2421. ### The Python external module for Python2 and any system Python
  2422. ### 1. major_ver and minor_ver must be integers.
  2423. ### 2. The resulting .so will have the prefix "lib".
  2424. ### 3. Processing EXPORTS and PREFIX is the same as for DLL module
  2425. ### This is native DLL, so it will select C++ version from PROTO_LIBRARY.
  2426. ###
  2427. ### Note: this module will always PEERDIR Python2 version of PY23_NATIVE_LIBRARY.
  2428. ### Do not PEERDIR PY2_LIBRARY or PY23_LIBRARY: this will link Python in and render artifact unusable as Python module.
  2429. ###
  2430. ### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/py_srcs/
  2431. module PY2MODULE: PY_ANY_MODULE {
  2432. PYTHON2_MODULE()
  2433. SET(MODULE_LANG PY2)
  2434. .RESTRICTED=PYTHON3_MODULE PYTHON3_ADDINCL
  2435. }
  2436. # tag:python-specific
  2437. ### @usage: PY3MODULE(name major_ver [minor_ver] [EXPORTS symlist_file] [PREFIX prefix])
  2438. ###
  2439. ### The Python external module for Python3 and any system Python
  2440. ### 1. major_ver and minor_ver must be integers.
  2441. ### 2. The resulting .so will have the prefix "lib".
  2442. ### 3. Processing EXPORTS and PREFIX is the same as for DLL module
  2443. ### This is native DLL, so it will select C++ version from PROTO_LIBRARY.
  2444. ###
  2445. ### Note: this module will always PEERDIR Python3 version of PY23_NATIVE_LIBRARY.
  2446. ### Do not PEERDIR PY3_LIBRARY or PY23_LIBRARY: this will link Python in and render artifact unusable as Python module.
  2447. ###
  2448. ### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/py_srcs/
  2449. module PY3MODULE: PY_ANY_MODULE {
  2450. PYTHON3_MODULE()
  2451. SET(MODULE_LANG PY3)
  2452. .RESTRICTED=PYTHON2_MODULE PYTHON2_ADDINCL
  2453. }
  2454. # tag:python-specific
  2455. ### @usage: PYTHON2_MODULE()
  2456. ###
  2457. ### Use in PY_ANY_MODULE to set it up for Python 2.x.
  2458. macro PYTHON2_MODULE() {
  2459. when ($USE_ARCADIA_PYTHON == "yes" && $MSVC == "yes" || $IS_CROSS_TOOLS == "yes") {
  2460. PEERDIR+=contrib/tools/python/lib
  2461. }
  2462. PYTHON2_ADDINCL()
  2463. }
  2464. # tag:python-specific
  2465. ### @usage: PYTHON3_MODULE()
  2466. ###
  2467. ### Use in PY_ANY_MODULE to set it up for Python 3.x.
  2468. macro PYTHON3_MODULE() {
  2469. when ($USE_ARCADIA_PYTHON == "yes" && $MSVC == "yes" || $IS_CROSS_TOOLS == "yes") {
  2470. PEERDIR+=contrib/tools/python3/lib
  2471. }
  2472. PYTHON3_ADDINCL()
  2473. }
  2474. # tag:r-specific
  2475. ### @usage: R_MODULE(name major_ver [minor_ver] [EXPORTS symlist_file] [PREFIX prefix])
  2476. ###
  2477. ### The external module for R language.
  2478. ### 1. major_ver and minor_ver must be integers.
  2479. ### 2. The resulting .so will have the prefix "lib".
  2480. ### 3. Processing EXPORTS and PREFIX is the same as for DLL module
  2481. ### This is native DLL, so it will select C++ version from PROTO_LIBRARY.
  2482. module R_MODULE: DLL_UNIT {
  2483. .SEM=CPP_DYN_LIBRARY_SEM
  2484. when ($DARWIN == "yes") {
  2485. LDFLAGS+=-flat_namespace -dynamiclib
  2486. }
  2487. when ($MSVC == "yes" || $CYGWIN == "yes") {
  2488. MODULE_PREFIX=lib
  2489. MODULE_SUFFIX=.dll
  2490. }
  2491. ADDINCL(contrib/libs/r-lang)
  2492. }
  2493. ### @usage: DYNAMIC_LIBRARY_FROM(Paths)
  2494. ###
  2495. ### Use specified libraries as sources of DLL
  2496. macro DYNAMIC_LIBRARY_FROM(Path...) {
  2497. PEERDIR($Path)
  2498. WHOLE_ARCHIVE($Path)
  2499. }
  2500. ### @usage: DLL(name major_ver [minor_ver] [EXPORTS symlist_file] [PREFIX prefix])
  2501. ###
  2502. ### Dynamic library module defintion.
  2503. ### 1. major_ver and minor_ver must be integers.
  2504. ### 2. EXPORTS allows you to explicitly specify the list of exported functions. This accepts 2 kind of files: .exports with <lang symbol> pairs and JSON-line .symlist files
  2505. ### 3. PREFIX allows you to change the prefix of the output file (default DLL has the prefix "lib").
  2506. ###
  2507. ### DLL cannot participate in linking to programs but can be used from Java or as final artifact (packaged and deployed).
  2508. module DLL: DLL_UNIT {
  2509. .SEM=CPP_DYN_LIBRARY_SEM
  2510. SET(MAKE_ONLY_SHARED_LIB yes)
  2511. SET(MODULE_LANG CPP)
  2512. when ($OS_WINDOWS) {
  2513. MODULE_SUFFIX=.dll
  2514. }
  2515. # TODO: Make it possible to use this syntax
  2516. # DEFAULT(DLL_FOR_DIR no)
  2517. ### FIXME: XXX
  2518. ###when ($DLL_FOR_DIR != "no") {
  2519. ### SRCDIR($DLL_FOR_DIR)
  2520. ### ADDINCL($DLL_FOR_DIR)
  2521. ###}
  2522. }
  2523. ### DLL_TOOL is a DLL that can be used as a LD_PRELOAD tool.
  2524. module DLL_TOOL: DLL {
  2525. .SEM=CPP_DYN_LIBRARY_SEM
  2526. # ymake resolves only program nodes as tools.
  2527. .NODE_TYPE=Program
  2528. }
  2529. ### @usage: SO_PROGRAM(name major_ver [minor_ver] [EXPORTS symlist_file] [PREFIX prefix])
  2530. ###
  2531. ### Executable dynamic library module defintion.
  2532. ### 1. major_ver and minor_ver must be integers.
  2533. ### 2. EXPORTS allows you to explicitly specify the list of exported functions. This accepts 2 kind of files: .exports with <lang symbol> pairs and JSON-line .symlist files
  2534. ### 3. PREFIX allows you to change the prefix of the output file.
  2535. module SO_PROGRAM: DLL {
  2536. .CMD=LINK_EXEC_DYN_LIB
  2537. SET(MODULE_TYPE PROGRAM)
  2538. MODULE_PREFIX=
  2539. when ($MSVC == "yes" || $CYGWIN == "yes") {
  2540. MODULE_SUFFIX=.exe
  2541. }
  2542. otherwise {
  2543. MODULE_SUFFIX=
  2544. }
  2545. }
  2546. DLL_PROXY_CMD_MF=$GENERATE_MF && $COPY_CMD $AUTO_INPUT $TARGET
  2547. # tag:internal
  2548. ### @usage: DEV_DLL_PROXY() # internal
  2549. ###
  2550. ### The use of this module is strictly prohibited!!!
  2551. ### This is a temporary and project-specific solution.
  2552. module DEV_DLL_PROXY: _BARE_UNIT {
  2553. .NODE_TYPE=Library
  2554. .EXTS=.so .dll .dylib .mf
  2555. .CMD=DLL_PROXY_CMD_MF
  2556. DYNAMIC_LINK=yes
  2557. when ($OS_WINDOWS == "yes") {
  2558. MODULE_SUFFIX=.dll
  2559. }
  2560. elsewhen ($DARWIN == "yes" || $OS_IOS == "yes") {
  2561. MODULE_PREFIX=lib
  2562. MODULE_SUFFIX=.dylib$MODULE_VERSION
  2563. }
  2564. otherwise {
  2565. MODULE_PREFIX=lib
  2566. MODULE_SUFFIX=.so$MODULE_VERSION
  2567. }
  2568. }
  2569. # tag:internal
  2570. ### @usage: DLL_PROXY() # internal
  2571. ###
  2572. ### The use of this module is strictly prohibited!!!
  2573. ### This is a temporary and project-specific solution.
  2574. module DLL_PROXY: DEV_DLL_PROXY {
  2575. .EXTS=.so .dylib .lib .mf
  2576. .PROXY=yes
  2577. .PEERDIR_POLICY=as_build_from
  2578. SET(PEERDIR_TAGS DLL __EMPTY__)
  2579. when ($OS_WINDOWS == "yes") {
  2580. MODULE_SUFFIX=.lib
  2581. }
  2582. }
  2583. # tag:internal
  2584. ### @usage: DYNAMIC_DEPS(Path...) # internal, temporary
  2585. ###
  2586. ### Enlist paths to all DYNAMIC_LIBRARY dependencies of the DYNAMIC_LIBRARY
  2587. ### This it needed to transfer their outputs through the library to PROGRAM
  2588. ### or dependent DLL/DYNAMIC_LIBRARY.
  2589. ###
  2590. ### Note: this is temporary solution until support of `super-global` variables come
  2591. ### which will enable transfer of some properies though final targets like DLLs.
  2592. macro DYNAMIC_DEPS(Path...) {
  2593. # PEERDIR as macro completely ignored in place where this macro applies
  2594. SET_APPEND(PEERDIR $Path)
  2595. }
  2596. # tag:internal
  2597. ### @usage: DYNAMIC_LIBRARY() # internal
  2598. ###
  2599. ### The use of this module is strictly prohibited except LGPL-related opensourcing
  2600. ### This provides linkable DLL module which brings its results to programs and tests
  2601. ### for seamless tesing and packaging
  2602. multimodule DYNAMIC_LIBRARY {
  2603. module DLL_BIN: DLL {
  2604. .PROXY=yes
  2605. .IGNORED=PROVIDES
  2606. SET(MODULE_TAG DLL)
  2607. }
  2608. module DLL_LIB: _DLL_COMPATIBLE_LIBRARY {
  2609. .CMD=TOUCH_UNIT_MF
  2610. .PEERDIRSELF=DLL_BIN
  2611. .IGNORED=SRCS PEERDIR RUN_PROGRAM PYTHON DYNAMIC_LIBRARY_FROM GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER USE_PYTHON2 USE_PYTHON3
  2612. .ALLOWED=DYNAMIC_DEPS
  2613. SET(PEERDIR_TAGS DLL_LIB __EMPTY__)
  2614. _BARE_MODULE()
  2615. DYNAMIC_LINK=yes
  2616. MODULE_SUFFIX=.pkg.fake
  2617. PEERDIR+=build/platform/local_so
  2618. RESTRICT_PATH(contrib devtools/dummy_arcadia MSG Use of this module type outside contrib/libs is prohibited)
  2619. # disable credits generation for static library
  2620. SET(CREDITS_FLAGS)
  2621. }
  2622. }
  2623. ### @usage: GLOBAL_SRCS(filenames...)
  2624. ###
  2625. ### Make all source files listed as GLOBAL.
  2626. ### Call to GLOBAL_SRCS macro is equivalent to call to SRCS macro when each source file is marked with GLOBAL keyword.
  2627. ### Arcadia root relative or project dir relative paths are supported for filenames arguments. GLOBAL keyword is not
  2628. ### recognized for GLOBAL_SRCS in contrast to SRCS macro.
  2629. ###
  2630. ### @example:
  2631. ### Consider the file to ya.make:
  2632. ###
  2633. ### LIBRARY()
  2634. ### GLOBAL_SRCS(foo.cpp bar.cpp)
  2635. ### END()
  2636. ###
  2637. ### @see: [SRCS()](#macro_SRCS)
  2638. macro GLOBAL_SRCS(Files...) {
  2639. SRCS(${pre=GLOBAL :Files})
  2640. }
  2641. ### @usage: ALL_SRCS([GLOBAL] filenames...)
  2642. ###
  2643. ### Make all source files listed as GLOBAL or not depending on the keyword GLOBAL
  2644. ### Call to ALL_SRCS macro is equivalent to call to GLOBAL_SRCS macro when GLOBAL keyword is specified
  2645. ### as the first argument and is equivalent to call to SRCS macro otherwise.
  2646. ###
  2647. ### @example:
  2648. ###
  2649. ### LIBRARY()
  2650. ### SET(MAKE_IT_GLOBAL GLOBAL)
  2651. ### ALL_SRCS(${MAKE_IT_GLOBAL} foo.cpp bar.cpp)
  2652. ### END()
  2653. ###
  2654. ### @see: [GLOBAL_SRCS()](#macro_GLOBAL_SRCS), [SRCS()](#macro_SRCS)
  2655. macro ALL_SRCS(GLOBAL?"GLOBAL":"", Files...) {
  2656. SRCS(${pre=$GLOBAL :Files})
  2657. }
  2658. ### @usage: _DLL_COMPATIBLE_LIBRARY # internal
  2659. ###
  2660. ### Base module to place DLLs into multimodules back to back with libraries.
  2661. ### In order to function properly all modules in multimodule shall have the
  2662. ### same set of arguments. So this module is just library that accepts but
  2663. ### ignores all DLL arguments.
  2664. module _DLL_COMPATIBLE_LIBRARY: LIBRARY {
  2665. }
  2666. @import "${CONF_ROOT}/conf/project_specific/yql_udf.conf"
  2667. # as SRCS in packages use macro BUNDLE_SRCS!
  2668. PACKED_PACKAGE_ARGS=
  2669. PACKED_PACKAGE_EXT=
  2670. ### @usage: PACK(archive_type)
  2671. ###
  2672. ### When placed inside the PACKAGE module, packs the build results tree to the archive with specified extension. Currently supported extensions are `tar` and `tar.gz`
  2673. ###
  2674. ### Is not allowed other module types than PACKAGE().
  2675. ###
  2676. ### @see: [PACKAGE()](#module_PACKAGE)
  2677. macro PACK(Ext) {
  2678. SET(PACKED_PACKAGE_EXT $Ext)
  2679. }
  2680. PACKAGE_STRICT_VALUE=
  2681. macro PACKAGE_STRICT() {
  2682. SET(PACKAGE_STRICT_VALUE yes)
  2683. }
  2684. ### @usage: PACKAGE(name)
  2685. ###
  2686. ### Module collects what is described directly inside it, builds and collects all its transitively available PEERDIRs.
  2687. ### As a result, build directory of the project gets the structure of the accessible part of Arcadia, where the build result of each PEERDIR is placed to relevant Arcadia subpath.
  2688. ### The data can be optionally packed if macro PACK() is used.
  2689. ###
  2690. ### Is only used together with the macros FILES(), PEERDIR(), COPY(), FROM_SANDBOX(), RUN_PROGRAM or BUNDLE(). Don't use SRCS inside a PACKAGE.
  2691. ###
  2692. ### Documentation: https://wiki.yandex-team.ru/yatool/large-data/
  2693. ###
  2694. ### @see: [PACK()](#macro_PACK)
  2695. module PACKAGE: _BASE_UNIT {
  2696. .CMD=TOUCH_PACKAGE_MF
  2697. .PEERDIR_POLICY=as_build_from
  2698. .ALL_INS_TO_OUT=yes
  2699. .FINAL_TARGET=yes
  2700. .ALLOWED=PACK
  2701. SET(MODULE_SUFFIX .pkg.fake)
  2702. SET(DONT_RESOLVE_INCLUDES yes)
  2703. NO_PLATFORM()
  2704. when ($PACKED_PACKAGE_EXT) {
  2705. PACKED_PACKAGE_ARGS+=--dest-arch ${output;pre=$MODULE_PREFIX;suf=.$PACKED_PACKAGE_EXT:REALPRJNAME}
  2706. }
  2707. SET(NEED_PLATFORM_PEERDIRS no)
  2708. PEERDIR_TAGS=CPP_PROTO CPP_FBS PY2 PY2_NATIVE YQL_UDF_SHARED __EMPTY__ DOCSBOOK JAR_RUNNABLE PY3_BIN PY3TEST_PROGRAM DLL
  2709. }
  2710. TOUCH_GROUP=$TOUCH_PACKAGE ${kv;hide:"p CI"}
  2711. ### @usage: CI_GROUP()
  2712. ###
  2713. ### Module collects what is described directly inside it transitively by PEERDIRs.
  2714. ### No particular layout of built artifacts is implied. This module is needed primarilly for CI dependency analysis and may not trigger builds at all.
  2715. ###
  2716. ### Is only used together with the macro PEERDIR() and FILES(). Don't use SRCS inside CI_GROUP().
  2717. module CI_GROUP: _BARE_UNIT {
  2718. .CMD=TOUCH_GROUP
  2719. .PEERDIR_POLICY=as_build_from
  2720. .ALL_INS_TO_OUT=yes
  2721. .FINAL_TARGET=yes
  2722. .RESTRICTED=SRCS
  2723. MODULE_SUFFIX=.ci.pkg.fake
  2724. PEERDIR_TAGS=CPP_PROTO PY3 PY3_NATIVE YQL_UDF_SHARED __EMPTY__ DOCSBOOK JAR_RUNNABLE DLL
  2725. }
  2726. # tag:generic tag:internal
  2727. TOUCH_UNIT_MF=$TOUCH_UNIT && $GENERATE_MF
  2728. # tag:proto
  2729. ### @usage: RESOLVE_PROTO()
  2730. ###
  2731. ### Enable include resolving within UNIONs and let system .proto being resolved
  2732. ### among .proto/.gztproto imports
  2733. ###
  2734. ### Note: it is currently impossible to enbale resolving only for .proto, so resolving is enabled for all supported files
  2735. ### also we only add ADDINCL for stock protobuf. So use this macro with care: it may cause resolving problems those are
  2736. ### to be addressed by either ADDINCLs or marking them as TEXT. Please contact devtools for details.
  2737. macro RESOLVE_PROTO() {
  2738. SET(DONT_RESOLVE_INCLUDES no)
  2739. ADDINCL(FOR proto $PROTOBUF_PATH)
  2740. }
  2741. ### @usage: UNION(name)
  2742. ###
  2743. ### Collection of PEERDIR dependencies, files and artifacts.
  2744. ### UNION doesn't build its peers, just provides those to modules depending on it.
  2745. ### When specied in DEPENDS() macro the UNION is transitively closed, building all its peers and providing those by own paths (without adding this module path like PACKAGE does).
  2746. ###
  2747. ### Is only used together with the macros like FILES(), PEERDIR(), COPY(), FROM_SANDBOX(), RUN_PROGRAM or BUNDLE(). Don't use SRCS inside a UNION.
  2748. ###
  2749. ### Documentation: https://wiki.yandex-team.ru/yatool/large-data/
  2750. module UNION: _BASE_UNIT {
  2751. .ALL_INS_TO_OUT=yes
  2752. .FINAL_TARGET=no
  2753. NO_PLATFORM()
  2754. SET(MODULE_SUFFIX .pkg.fake)
  2755. SET(DONT_RESOLVE_INCLUDES yes)
  2756. .CMD=TOUCH_UNIT_MF
  2757. SET(NEED_PLATFORM_PEERDIRS no)
  2758. PEERDIR_TAGS=CPP_PROTO CPP_FBS PY2 PY2_NATIVE YQL_UDF_SHARED __EMPTY__ DOCSBOOK JAR_RUNABLE PY3_BIN DLL
  2759. }
  2760. # tag:python-specific
  2761. module _PY_PACKAGE: UNION {
  2762. .EXTS=.py
  2763. .ALL_INS_TO_OUT=yes
  2764. .ALLOWED=GRPC USE_SKIFF
  2765. ENABLE(PY_PROTOS_FOR)
  2766. SET(PEERDIR_TAGS PY_PROTO)
  2767. SET(DONT_RESOLVE_INCLUDES no)
  2768. }
  2769. # tag:python-specific tag:deprecated tag:internal
  2770. ### @usage: PY_PACKAGE(name) # internal, deprecated
  2771. ###
  2772. ### This is module created via PY_PROTOS_FOR() macro
  2773. module PY_PACKAGE: _PY_PACKAGE {
  2774. .FINAL_TARGET=yes
  2775. }
  2776. # tag:internal
  2777. ### @usage: _SET_FIRST_VALUE(name args...) # interanl
  2778. ###
  2779. ### This macro sets the value of `name` vraiable to the value of next argument
  2780. macro _SET_FIRST_VALUE(NAME, VALUE, OTHER...) {
  2781. SET($NAME $VALUE)
  2782. }
  2783. # tag:python-specific
  2784. PY_NAMESPACE_VALUE=
  2785. # tag:python-specific
  2786. ### @usage: PY_NAMESPACE(prefix)
  2787. ###
  2788. ### Sets default Python namespace for all python sources in the module.
  2789. ### Especially suitable in PROTO_LIBRARY where Python sources are generated and there is no PY_SRCS to place NAMESPACE parameter.
  2790. macro PY_NAMESPACE(Arg) {
  2791. SET(PY_NAMESPACE_VALUE $Arg)
  2792. }
  2793. # tag:internal
  2794. ### @usage: _SRCS_NO_GLOBAL(files...) # internal
  2795. ###
  2796. ### Proxy macro to SRCS macro which filters out GLOBAL keyword from the list of source files.
  2797. ### Useful for modules like EXTERNAL_JAVA_LIBRARY, where GLOBAL keyword cannot be applied properly.
  2798. ### Note: this macro changes order of source files.
  2799. macro _SRCS_NO_GLOBAL(GLOBAL[], FILES...) {
  2800. SRCS($GLOBAL $FILES)
  2801. }
  2802. # tag:java-specific
  2803. JAVA_VCS_MF_ARG=
  2804. COMPILE_JAVA_MF=$COMPILE_JAVA
  2805. # tag:java-specific
  2806. when ($EXT_JAVA_VCS_INFO == "yes") {
  2807. JAVA_VCS_MF_ARG=--vcs-mf $VCS_JAVA
  2808. COMPILE_JAVA_MF=$GENERATE_VCS_JAVA_INFO_NODEP && $COMPILE_JAVA
  2809. }
  2810. # tag:java-specific
  2811. EXT_JAVA_VCS_INFO=no
  2812. ### @usage: EMBED_JAVA_VCS_INFO()
  2813. ###
  2814. ### Embed manifest with vcs info into `EXTERNAL_JAVA_LIBRARY`
  2815. ### By default this is disabled.
  2816. macro EMBED_JAVA_VCS_INFO() {
  2817. ENABLE(EXT_JAVA_VCS_INFO)
  2818. }
  2819. # tag:java-specific tag:internal
  2820. ### @usage: EXTERNAL_JAVA_LIBRARY() #internal
  2821. ###
  2822. ### EXTERNAL_JAVA_LIBRARY() is a module for creating a .jar file using non-Java code (generators etc.)
  2823. ### Unlike regular JAVA_LIBRARY this module doesn't produce .pom file, so it cannot be exported to Maven itself.
  2824. ### PEERDIR it from JAVA_LIBRARY or JAVA_PROGRAM for export to Maven.
  2825. module EXTERNAL_JAVA_LIBRARY: _BASE_UNIT {
  2826. .EXTS=.jsrc .java .jar .mf
  2827. .NODE_TYPE=Bundle
  2828. .CMD=COMPILE_JAVA_MF
  2829. .PEERDIR_POLICY=as_build_from
  2830. .FINAL_TARGET=no
  2831. .ALIASES=SRCS=_SRCS_NO_GLOBAL
  2832. .ALLOWED=EMBED_JAVA_VCS_INFO
  2833. .RESTRICTED=EXTERNAL_JAR
  2834. PEERDIR(build/platform/java/jdk)
  2835. PEERDIR+=$JDK_RESOURCE_PEERDIR $EXTERNAL_JAVA_EXTRA_PEERDIR
  2836. PEERDIR_TAGS=JAVA_PROTO JAVA_FBS JAVA_IDL
  2837. HAS_MANAGEABLE_PEERS=yes
  2838. DYNAMIC_LINK=yes
  2839. MACRO_ALIAS(PROTO_CMD _JAVA_PROTO_CMD)
  2840. MACRO_ALIAS(EVLOG_CMD _JAVA_EVLOG_CMD)
  2841. MACRO_ALIAS(FBS_CMD _JAVA_FLATC_CMD)
  2842. when ($PACKAGE_PREFIX) {
  2843. PACKAGE_PREFIX_ARGS=--package-prefix=$PACKAGE_PREFIX
  2844. }
  2845. DISABLE(NEED_PLATFORM_PEERDIRS)
  2846. NO_PLATFORM()
  2847. SET(MODULE_SUFFIX .jar)
  2848. SET(MODULE_LANG JAVA)
  2849. }
  2850. # tag:java-specific
  2851. ALL_JAR_SOURCES=
  2852. LINT_JAVA_SOURCES=
  2853. ALL_SRCDIRS=
  2854. LINK_JAR_RESOURCES=
  2855. LINK_JAR_JSOURCES=
  2856. JAR_GEN_SRCS=
  2857. JAR_GEN_JSRCS=
  2858. macro _JAR_SRCS(SRCDIR=".", PACKAGE_PREFIX="", EXCLUDE[], FILES[], RESOURCES?"yes":"no", Globs...) {
  2859. _CHECK_JAVA_SRCDIR($SRCDIR)
  2860. SET_APPEND(ALL_SRCDIRS $SRCDIR)
  2861. SET(VAR_SALT $SRCDIR $Globs $EXCLUDE $PACKAGE_PREFIX $RESOURCES $FILES)
  2862. SET(JAR_SRCS_GLOB uniq_${hash:VAR_SALT})
  2863. _LATE_GLOB(${JAR_SRCS_GLOB} ${pre=${SRCDIR}/:Globs} EXCLUDE ${EXCLUDE})
  2864. SET_APPEND(LINT_JAVA_SOURCES \${input;rootrel;ext=.java:${JAR_SRCS_GLOB}})
  2865. SET_APPEND(ALL_JAR_SOURCES --jsources ${BINDIR}/misc/${tolower:JAR_SRCS_GLOB}.src.txt --resources ${BINDIR}/misc/${tolower:JAR_SRCS_GLOB}.res.txt --srcdir ${quo:SRCDIR} \${input:${JAR_SRCS_GLOB}} ${pre=\$\{input\:\";suf=\"\}:FILES})
  2866. _FILL_JAR_COPY_RESOURCES_CMD(LINK_JAR_RESOURCES ${quo:SRCDIR} ${BINDIR}/cls ${PACKAGE_PREFIX} ${BINDIR}/misc/${tolower:JAR_SRCS_GLOB}.res.txt)
  2867. _FILL_JAR_COPY_RESOURCES_CMD(LINK_JAR_JSOURCES ${quo:SRCDIR} ${BINDIR}/src ${PACKAGE_PREFIX} ${BINDIR}/misc/${tolower:JAR_SRCS_GLOB}.src.txt)
  2868. _FILL_JAR_GEN_SRCS(JAR_GEN_SRCS JAR $SRCDIR ${BINDIR}/cls ${BINDIR}/all-java.srclst ${BINDIR}/misc/all-kt-sources.txt ${BINDIR}/misc/all-gr-sources.txt ${BINDIR}/misc/${tolower:JAR_SRCS_GLOB}.res.txt $Globs EXCLUDE $EXCLUDE)
  2869. _FILL_JAR_GEN_SRCS(JAR_GEN_JSRCS SRC_JAR $SRCDIR ${BINDIR}/cls ${BINDIR}/all-java.srclst ${BINDIR}/misc/all-kt-sources.txt ${BINDIR}/misc/all-gr-sources.txt ${BINDIR}/misc/${tolower:JAR_SRCS_GLOB}.src.txt $Globs EXCLUDE $EXCLUDE)
  2870. }
  2871. macro IDEA_JAR_SRCS(Args...) {
  2872. _JAR_SRCS($Args)
  2873. SET_APPEND(JAVA_SRCS_VALUE $ARGS_DELIM $Args)
  2874. }
  2875. macro _HASH_HELPER(Args...) {
  2876. .CMD=${hash:Args}
  2877. }
  2878. macro _GENTAR_HELPER(OUT_DIR[], Args...) {
  2879. .CMD=${cwd:BINDIR} $YMAKE_PYTHON ${input:"build/scripts/autotar_gendirs.py"} --pack ${OUT_DIR} --outs ${output;tared;suf=.$_HASH_HELPER($Args).gentar:OUT_DIR} ${kv;hide:"tared_kind nodir"}
  2880. }
  2881. # tag:java-specific
  2882. RUN_JAR_PROG_CP_PRE=@
  2883. RUN_JAR_PROG_CP_SUF=.cplst
  2884. when($JDK_VERSION == "8") {
  2885. RUN_JAR_PROG_CP_PRE=
  2886. RUN_JAR_PROG_CP_SUF=
  2887. }
  2888. # tag:java-specific
  2889. macro _DO_2_RUN_JAR_PROGRAM(IN_DIRS_VAR="uniq_", IN_DIRS_INPUTS[], IN{input}[], IN_NOPARSE{input}[], IN_DIR[], OUT_NOAUTO{output}[], OUT{output}[], TOOL{tool}[], OUT_DIR[], CLASSPATH[], ADD_SRCS_TO_CLASSPATH?"yes":"no", CWD="${ARCADIA_BUILD_ROOT}", Args...) {
  2890. _LATE_GLOB(${IN_DIRS_VAR} ${suf=/**/*:IN_DIR})
  2891. _CHECK_RUN_JAVA_PROG_CLASSPATH($CLASSPATH)
  2892. .PEERDIR=build/platform/java/jdk $JDK_RESOURCE_PEERDIR
  2893. .CMD=${cwd:BINDIR} $YMAKE_PYTHON ${input:"build/scripts/mkdir.py"} ${OUT_DIR} && ${cwd:CWD} $YMAKE_PYTHON ${input:"build/scripts/setup_java_tmpdir.py"} $YMAKE_PYTHON ${input:"build/scripts/stdout2stderr.py"} $YMAKE_PYTHON ${input:"build/scripts/fix_java_command_file_cp.py"} --build-root ${ARCADIA_BUILD_ROOT} $JDK_RESOURCE/bin/java -Dfile.encoding=utf8 -classpath ${RUN_JAR_PROG_CP_PRE}${tool:CLASSPATH}${RUN_JAR_PROG_CP_SUF} ${Args} && $_GENTAR_HELPER($CLASSPATH $IN_DIR $IN $IN_NOPARSE $TOOL $Args OUT_DIR $OUT_DIR) ${input;hide:IN} ${input;context=TEXT;hide:IN_NOPARSE} ${output;noauto;hide:OUT_NOAUTO} ${output;hide:OUT} ${tool;hide:TOOL} ${IN_DIRS_INPUTS}
  2894. }
  2895. # tag:java-specific
  2896. macro _DO_1_RUN_JAR_PROGRAM(IN_DIRS_VAR="uniq", Args...) {
  2897. _DO_2_RUN_JAR_PROGRAM($Args IN_DIRS_VAR $IN_DIRS_VAR IN_DIRS_INPUTS ${"$"}{input;hide:$IN_DIRS_VAR})
  2898. }
  2899. # tag:java-specific
  2900. macro RUN_JAVA_PROGRAM(Args...) {
  2901. _DO_1_RUN_JAR_PROGRAM($Args IN_DIRS_VAR uniq_${hash:Args})
  2902. }
  2903. # tag:java-specific
  2904. _JAR_ANN_PROCESSORS=
  2905. _JAR_ANN_PROC_OPT_PREFIX=
  2906. macro JAR_ANNOTATION_PROCESSOR(Classes...) {
  2907. SET_APPEND(_JAR_ANN_PROCESSORS $Classes)
  2908. SET(_JAR_ANN_PROC_OPT_PREFIX -processor)
  2909. # for ya ide idea only
  2910. SET_APPEND(ANNOTATION_PROCESSOR_VALUE $ARGS_DELIM $Classes)
  2911. }
  2912. # tag:java-specific
  2913. macro _JAR_ANN_PROC_OPTS(Classes...) {
  2914. .CMD=$_JAR_ANN_PROC_OPT_PREFIX ${join=,:Classes}
  2915. }
  2916. # tag:java-specific
  2917. macro _NOOP_MACRO(Args...) {
  2918. ENABLE(UNUSED_MACRO)
  2919. }
  2920. # tag:java-specific
  2921. module _JAR_BASE: _BARE_UNIT {
  2922. .NODE_TYPE=Bundle
  2923. .CMD=TOUCH_UNIT
  2924. .PEERDIR_POLICY=as_build_from
  2925. .FINAL_TARGET=no
  2926. .ALIASES=SRCS=_SRCS_NO_GLOBAL
  2927. .ALLOWED=EMBED_JAVA_VCS_INFO DEPENDENCY_MANAGEMENT EXCLUDE
  2928. PEERDIR_TAGS=JAVA_PROTO JAVA_FBS JAVA_IDL DLL JAR_COMPILATION __EMPTY__
  2929. HAS_MANAGEABLE_PEERS=yes
  2930. DYNAMIC_LINK=yes
  2931. MACRO_ALIAS(PROTO_CMD _JAVA_PROTO_CMD)
  2932. MACRO_ALIAS(EVLOG_CMD _JAVA_EVLOG_CMD)
  2933. MACRO_ALIAS(FBS_CMD _JAVA_FLATC_CMD)
  2934. DISABLE(NEED_PLATFORM_PEERDIRS)
  2935. NO_PLATFORM()
  2936. VCS_JAVA=${suf=.__vcs_version__.mf:TARGET}
  2937. SET(MODULE_LANG JAVA)
  2938. }
  2939. # tag:java-specific
  2940. module JAVA_CONTRIB_PROXY: _JAR_BASE {
  2941. }
  2942. # tag:java-specific
  2943. macro _FETCH_CONTRIB(Id, Out, SBR="sbr:") {
  2944. .CMD=${hide:SANDBOX_FAKEID} ${cwd:BINDIR} ${resource;pre=$SBR:Id} $YMAKE_PYTHON ${input:"build/scripts/fetch_from_sandbox.py"} --resource-file $(RESOURCE_ROOT)/sbr/$Id/resource --resource-id $Id --copy-to ${output:Out} ${input;hide:"build/scripts/fetch_from.py"} ${requirements;hide:"network:full"} ${kv;hide:"p SB"} ${kv;hide:"pc yellow"} ${kv;hide:"show_out"}
  2945. ADD_CHECK(check.resource $Id)
  2946. }
  2947. # tag:java-specific
  2948. LOCAL_JAR_PATH=
  2949. LOCAL_SOURCES_JAR_PATH=
  2950. JAR_RESOURCE_ID=
  2951. SRC_RESOURCE_ID=
  2952. FETCH_SRCS_JAR=
  2953. FETCH_TARGET_JAR=
  2954. FETCH_CONTRIB_JAR=$FETCH_TARGET_JAR $FETCH_SRCS_JAR
  2955. # tag:java-specific
  2956. macro JAR_RESOURCE(Id) {
  2957. SET(JAR_RESOURCE_ID $Id)
  2958. }
  2959. # tag:java-specific
  2960. macro SRC_RESOURCE(Id) {
  2961. SET(SRC_RESOURCE_ID $Id)
  2962. }
  2963. # tag:java-specific
  2964. macro LOCAL_JAR(File) {
  2965. SET(LOCAL_JAR_PATH $File)
  2966. }
  2967. # tag:java-specific
  2968. macro LOCAL_SOURCES_JAR(File) {
  2969. SET(LOCAL_SOURCES_JAR_PATH $File)
  2970. }
  2971. # tag:java-specific
  2972. module JAVA_CONTRIB: _JAR_BASE {
  2973. .CMD=FETCH_CONTRIB_JAR
  2974. .FINAL_TARGET=yes
  2975. when ($JAR_RESOURCE_ID) {
  2976. FETCH_TARGET_JAR= && $_FETCH_CONTRIB($JAR_RESOURCE_ID ${BINDIR}/${MODULE_PREFIX}${REALPRJNAME}${MODULE_SUFFIX})
  2977. }
  2978. otherwise {
  2979. when ($LOCAL_JAR_PATH) {
  2980. FETCH_TARGET_JAR= && $FS_TOOLS copy ${input:LOCAL_JAR_PATH} $TARGET
  2981. }
  2982. otherwise {
  2983. FETCH_TARGET_JAR= && $GENERATE_VCS_JAVA_INFO_NODEP && ${cwd:BINDIR} $JDK_RESOURCE/bin/jar cfvm $TARGET $VCS_JAVA .
  2984. PEERDIR+=build/platform/java/jdk
  2985. PEERDIR+=$JDK_RESOURCE_PEERDIR
  2986. }
  2987. }
  2988. when ($SRC_RESOURCE_ID) {
  2989. FETCH_SRCS_JAR= && $_FETCH_CONTRIB($SRC_RESOURCE_ID ${BINDIR}/${REALPRJNAME}-sources.jar)
  2990. }
  2991. otherwise {
  2992. when ($LOCAL_SOURCES_JAR_PATH) {
  2993. FETCH_SRCS_JAR= && $FS_TOOLS copy ${input:LOCAL_SOURCES_JAR_PATH} {output;pre=${BINDIR}/;suf=-sources.jar:REALPRJNAME}
  2994. }
  2995. otherwise {
  2996. FETCH_SRCS_JAR= && $GENERATE_VCS_JAVA_INFO_NODEP && $FS_TOOLS md ${BINDIR}/fake-src && ${cwd;suf=/fake-src:BINDIR} $JDK_RESOURCE/bin/jar cfvm ${output;pre=${BINDIR}/;suf=-sources.jar:REALPRJNAME} $VCS_JAVA .
  2997. PEERDIR+=build/platform/java/jdk
  2998. PEERDIR+=$JDK_RESOURCE_PEERDIR
  2999. }
  3000. }
  3001. SET(MODULE_SUFFIX .jar)
  3002. }
  3003. # tag:kotlin-specific
  3004. KOTLINC_OPTS_VALUE=
  3005. # tag:kotlin-specific
  3006. KT_SRSCLIST_FLAG=--kotlin ${BINDIR}/misc/all-kt-sources.txt
  3007. KT_CLASSES_DIR=${BINDIR}/kt_cls
  3008. COLLECT_KT_CLASSPATH=${YMAKE_PYTHON} ${input:"build/scripts/writer.py"} --file ${BINDIR}/kt_bfg.txt -m --ya-start-command-file ${ext=.jar:MANAGED_PEERS_CLOSURE} --ya-end-command-file
  3009. LINK_KT_CLASSPATH=$YMAKE_PYTHON ${input:"build/scripts/make_java_classpath_file.py"} ${BINDIR}/kt_bfg.txt ${BINDIR}/kt_cp.txt && $FS_TOOLS md $KT_CLASSES_DIR
  3010. COMPILE_KT=${cwd:ARCADIA_BUILD_ROOT} $YMAKE_PYTHON ${input:"build/scripts/with_pathsep_resolve.py"} $YMAKE_PYTHON ${input:"build/scripts/run_javac.py"} --kotlin --sources-list ${BINDIR}/misc/all-kt-sources.txt $JDK_RESOURCE/bin/java -jar $KOTLIN_COMPILER_RESOURCE_GLOBAL/kotlin-compiler.jar -no-stdlib -module-name $REALPRJNAME -jvm-target ${KOTLIN_JVM_TARGET} @${BINDIR}/misc/all-kt-sources.txt -classpath @${BINDIR}/kt_cp.txt $KOTLINC_FLAGS_VALUE -d $KT_CLASSES_DIR $KOTLINC_OPTS_VALUE
  3011. ALL_KT_COMMANDS=
  3012. KT_CLASSPATH_ITEM=
  3013. # tag:java-specific
  3014. JAVAC_CMD=$JDK_RESOURCE/bin/javac
  3015. ERROR_PRONE_JAVAC_CMD=${YMAKE_PYTHON} ${input:"build/scripts/build_java_with_error_prone2.py"} $JDK_RESOURCE/bin/java $JDK_RESOURCE/bin/javac $ERROR_PRONE_RESOURCE/error_prone.jar
  3016. # tag:java-specific tag:codenav
  3017. JAVA_YNDEXING=no
  3018. # tag:java-specific
  3019. when ($USE_SYSTEM_KYTHE) {
  3020. KYTHE_RESOURCE=$USE_SYSTEM_KYTHE
  3021. }
  3022. otherwise {
  3023. KYTHE_RESOURCE=$KYTHE_RESOURCE_GLOBAL
  3024. }
  3025. # tag:java-specific tag:codenav
  3026. _JAVA_YNDEXING_CMD=$YMAKE_PYTHON ${input:"build/scripts/build_java_codenav_index.py"} $TARGET $ARCADIA_BUILD_ROOT $ARCADIA_ROOT ${BINDIR}/all-java.srclst $JDK_RESOURCE/bin/java -jar $KYTHE_RESOURCE/kythe/extractors/javac_extractor.jar
  3027. _DO_JAVA_YNDEXING=
  3028. # tag:java-specific
  3029. SOURCES_JAR=no
  3030. _PACK_SRC_JAR_IMPL=&& $FS_TOOLS md ${BINDIR}/src $JAR_GEN_JSRCS $LINK_JAR_JSOURCES && ${cwd;suf=/src:BINDIR} $JDK_RESOURCE/bin/jar cfvm ${output;pre=${BINDIR}/${MODULE_PREFIX};suf=-sources.jar:REALPRJNAME} $VCS_JAVA .
  3031. _PACK_SRC_JAR=
  3032. # tag:java-specific
  3033. _PACK_JNI=
  3034. _PACK_JNI_CMD= && $FS_TOOLS link_or_copy_to_dir --ya-start-command-file ${ext=.so:MANAGED_PEERS_CLOSURE} ${ext=.dll:MANAGED_PEERS_CLOSURE} ${ext=.dylib:MANAGED_PEERS_CLOSURE} --ya-end-command-file ${BINDIR}/cls
  3035. # tag:java-specific
  3036. _MAKE_JSTYLE_FILE_LIST=
  3037. # tag:java-specific
  3038. _LINK_UBERJAR=
  3039. _UBERJAR_SELF=
  3040. _DO_LINK_UBERJAR= && $JDK_RESOURCE/bin/java -cp $UBERJAR_RESOURCE/devtools-java_shader.jar ru.yandex.devtools.emigrante.Main --out-jar $TARGET $_UBERJAR_SELF ${ext=.jar;pre=--jar :MANAGED_PEERS_CLOSURE} ${UBERJAR_PREFIX_FLAG} ${UBERJAR_HIDE_EXCLUDE_FLAGS} $UBERJAR_PATH_EXCLUDES ${UBERJAR_MANIFEST_TRANSFORMER_MAIN_FLAG} ${UBERJAR_MANIFEST_TRANSFORMER_ATTRIBUTE_FLAGS} ${UBERJAR_APPENDING_TRANSFORMER_FLAGS} ${UBERJAR_SERVICES_RESOURCE_TRANSFORMER_FLAG} \
  3041. && $YMAKE_PYTHON ${input:"build/scripts/mkdir.py"} $BINDIR/_empty/META-INF \
  3042. && $YMAKE_PYTHON ${input:"build/scripts/touch.py"} $BINDIR/_empty/META-INF/MANIFEST.MF \
  3043. && $UPDATE_VCS_JAVA_INFO_NODEP($TARGET) \
  3044. && ${cwd;suf=/_empty:BINDIR} ${JDK_RESOURCE}/bin/jar ufv ${TARGET} META-INF/MANIFEST.MF \
  3045. && $JDK_RESOURCE/bin/jar ufvm $TARGET $VCS_JAVA
  3046. # tag:java-specific
  3047. macro _PACK_JAR_HELPER(Out) {
  3048. .CMD=${cwd;suf=/cls:BINDIR} $JDK_RESOURCE/bin/jar cfvm $Out $VCS_JAVA .
  3049. }
  3050. # tag:java-specific
  3051. macro _JAVAC_RUN_HELPER(JAVAC_CMD_WITH_ARGS...) {
  3052. .CMD=${cwd:ARCADIA_BUILD_ROOT} $YMAKE_PYTHON ${input:"build/scripts/with_pathsep_resolve.py"} $YMAKE_PYTHON ${input:"build/scripts/setup_java_tmpdir.py"} $YMAKE_PYTHON ${input:"build/scripts/run_javac.py"} --sources-list ${BINDIR}/all-java.srclst ${JAVAC_CMD_WITH_ARGS} @${BINDIR}/all-java.srclst -classpath ${ARCADIA_BUILD_ROOT}/bfg.jar -Xpkginfo:always ${JAVAC_OPTS} $_JAR_ANN_PROC_OPTS($_JAR_ANN_PROCESSORS) -d ${BINDIR}/cls -g -encoding UTF-8
  3053. }
  3054. macro _ADD_HIDDEN_INPUTS(Inputs...) {
  3055. .CMD=${input;hide:Inputs}
  3056. }
  3057. # tag:java-specific
  3058. ERROR_PRONE_JDK16_ADD_OPENS=-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED -J--add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
  3059. ERROR_PRONE_2_7_1_FORCED_OPTS=-Xep:InlineMeInliner:OFF -Xep:SameNameButDifferent:OFF
  3060. # tag:java-specific
  3061. JAVA_COVERAGE_SRCLIST_FLAG=--coverage ${output;pre=${MODULE_PREFIX};suf=.cpsf:REALPRJNAME} --source-root ${ARCADIA_ROOT}
  3062. JAVA_COVERAGE_SRCLIST=
  3063. PREPARE_JAVA_BUILD_DIRS=$FS_TOOLS md ${BINDIR}/cls && $FS_TOOLS md ${BINDIR}/misc
  3064. EXTRACT_GENDIRS=${cwd:BINDIR} $YMAKE_PYTHON ${input:"build/scripts/autotar_gendirs.py"} --unpack --ext .gentar ${ext=.gentar:AUTO_INPUT}
  3065. COLLECT_JAVA_SRCLIST=${YMAKE_PYTHON} ${input:"build/scripts/make_java_srclists.py"} --moddir ${CURDIR} --java ${BINDIR}/all-java.srclst ${KT_SRSCLIST} ${JAVA_COVERAGE_SRCLIST} --ya-start-command-file ${ALL_JAR_SOURCES} ${ext=.java:AUTO_INPUT} ${ext=.kt:AUTO_INPUT} --ya-end-command-file
  3066. COLLECT_CLASSPATH=${YMAKE_PYTHON} ${input:"build/scripts/writer.py"} --file ${BINDIR}/bfg.txt -m --ya-start-command-file ${rootrel:MANAGED_PEERS_CLOSURE} $KT_CLASSPATH_ITEM --ya-end-command-file
  3067. LINK_CLASSPATH=${YMAKE_PYTHON} ${input:"build/scripts/make_manifest_from_bf.py"} ${BINDIR}/bfg.txt ${ARCADIA_BUILD_ROOT}/bfg.jar
  3068. COMPILE_JAVA_SRCLIST=$_JAVAC_RUN_HELPER($JAVAC_CMD)
  3069. PACK_JAR=$_PACK_JAR_HELPER($TARGET)
  3070. # NOTE: No && before LINK_JAR_RESOURCES, ALL_KT_COMMANDS and JAR_GEN_SRCS needed since those vars either empty or starts with &&
  3071. LINK_JAR=$PREPARE_JAVA_BUILD_DIRS \
  3072. && $EXTRACT_GENDIRS \
  3073. && $COLLECT_JAVA_SRCLIST \
  3074. $JAR_GEN_SRCS \
  3075. $ALL_KT_COMMANDS \
  3076. && $COLLECT_CLASSPATH \
  3077. && $LINK_CLASSPATH \
  3078. && $COMPILE_JAVA_SRCLIST \
  3079. $LINK_JAR_RESOURCES \
  3080. && ${cwd;suf=/cls:BINDIR} $GENERATE_VCS_JAVA_INFO_NODEP . \
  3081. $_PACK_SRC_JAR \
  3082. $_PACK_JNI \
  3083. && $PACK_JAR \
  3084. $_DO_JAVA_YNDEXING \
  3085. ${kv;hide:"p JV"} ${kv;hide:"pc light-blue"} ${kv;hide:"show_out"} \
  3086. $_MAKE_JSTYLE_FILE_LIST \
  3087. $_LINK_UBERJAR \
  3088. $_ADD_HIDDEN_INPUTS($JAVA_EXTERNAL_DEPENDENCIES_VALUE)
  3089. # tag:java-specific
  3090. _EXT_SRC_JAR=
  3091. _EXT_JAR=
  3092. _COPY_EXT_SRC_JAR=
  3093. _DO_USE_EXT_JAR=$FS_TOOLS copy ${input:_EXT_JAR} $TARGET $_COPY_EXT_SRC_JAR
  3094. _DO_COPY_EXT_SRC_JAR= && $FS_TOOLS copy $_EXT_SRC_JAR ${output;pre=${BINDIR}/${MODULE_PREFIX};suf=-sources.jar:REALPRJNAME}
  3095. macro JAVA_RESOURCE(JAR, SOURCES="") {
  3096. SET(_EXT_SRC_JAR $SOURCES)
  3097. SET(_EXT_JAR $JAR)
  3098. }
  3099. # tag:java-specific tag:fbs
  3100. JAVA_FLATBUFFERS_VERSION = 2.0.0
  3101. # tag:java-specific
  3102. module _COMPILABLE_JAR_BASE : _JAR_BASE {
  3103. # flatbuffers-java
  3104. DEPENDENCY_MANAGEMENT(contrib/java/com/google/flatbuffers/flatbuffers-java/${JAVA_FLATBUFFERS_VERSION})
  3105. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/com/google/flatbuffers/flatbuffers-java EXCEPT contrib/java/com/google/flatbuffers/flatbuffers-java/${JAVA_FLATBUFFERS_VERSION})
  3106. # protobuf-java
  3107. DEPENDENCY_MANAGEMENT(contrib/java/com/google/protobuf/protobuf-java/${JAVA_PROTO_RUNTIME_VERSION})
  3108. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/com/google/protobuf/protobuf-java EXCEPT contrib/java/com/google/protobuf/protobuf-java/${JAVA_PROTO_RUNTIME_VERSION})
  3109. # protobuf-javalite
  3110. DEPENDENCY_MANAGEMENT(contrib/java/com/google/protobuf/protobuf-javalite/${JAVA_PROTO_RUNTIME_VERSION})
  3111. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/com/google/protobuf/protobuf-javalite EXCEPT contrib/java/com/google/protobuf/protobuf-javalite/${JAVA_PROTO_RUNTIME_VERSION})
  3112. # protobuf-java-util
  3113. DEPENDENCY_MANAGEMENT(contrib/java/com/google/protobuf/protobuf-java-util/${JAVA_PROTO_RUNTIME_VERSION})
  3114. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/com/google/protobuf/protobuf-java-util EXCEPT contrib/java/com/google/protobuf/protobuf-java-util/${JAVA_PROTO_RUNTIME_VERSION})
  3115. }
  3116. # tag:java-specific tag:internal
  3117. ### @usage: JAR_LIBRARY() #internal
  3118. ###
  3119. ### Reimplementation of the JAVA_LIBRARY with ymake.core.conf and ymake based dependency management
  3120. module JAR_LIBRARY: _COMPILABLE_JAR_BASE {
  3121. .EXTS=.jsrc .java .jar .mf .gentar .kt
  3122. .CMD=LINK_JAR
  3123. .FINAL_TARGET=yes
  3124. .ALIASES=JAVA_SRCS=IDEA_JAR_SRCS ANNOTATION_PROCESSOR=JAR_ANNOTATION_PROCESSOR
  3125. .RESTRICTED=EXTERNAL_JAR
  3126. MODULE_SUFFIX=.jar
  3127. PEERDIR(build/platform/java/jdk)
  3128. PEERDIR+=$JDK_RESOURCE_PEERDIR
  3129. when ($_EXT_SRC_JAR) {
  3130. _COPY_EXT_SRC_JAR=_DO_COPY_EXT_SRC_JAR
  3131. }
  3132. when ($_EXT_JAR) {
  3133. LINK_JAR=$_DO_USE_EXT_JAR
  3134. }
  3135. # in the ideal world this statement must be under condition bellow
  3136. DEPENDENCY_MANAGEMENT(contrib/java/org/jetbrains/kotlin/kotlin-stdlib-jdk8/${KOTLIN_VERSION})
  3137. when ($WITH_KOTLIN_VALUE) {
  3138. KT_SRSCLIST=$KT_SRSCLIST_FLAG
  3139. ALL_KT_COMMANDS=&& $COLLECT_KT_CLASSPATH && $LINK_KT_CLASSPATH && $COMPILE_KT
  3140. LINK_JAR_RESOURCES+=&& $FS_TOOLS copy_all_files ${KT_CLASSES_DIR} ${BINDIR}/cls
  3141. PEERDIR+=build/platform/java/kotlin contrib/java/org/jetbrains/kotlin/kotlin-stdlib-jdk8
  3142. when($WITH_KOTLINC_PLUGIN_ALLOPEN) {
  3143. KOTLINC_OPTS_VALUE+=-Xplugin=${KOTLIN_COMPILER_RESOURCE_GLOBAL}/plugins/kotlin-allopen-plugin.jar
  3144. }
  3145. when($WITH_KOTLINC_PLUGIN_NOARG) {
  3146. KOTLINC_OPTS_VALUE+=-Xplugin=${KOTLIN_COMPILER_RESOURCE_GLOBAL}/plugins/kotlin-noarg-plugin.jar
  3147. }
  3148. # Must be in sync with KT_CLASSES_DIR!
  3149. # There are problems in JDK13 with abs paths in classapth baked into jar file manifest. Using relative path
  3150. # here assumes that jar file with classpath for javac located in the $ARCADIA_BUILD_ROOT
  3151. KT_CLASSPATH_ITEM=$MODDIR/kt_cls
  3152. }
  3153. otherwise {
  3154. KT_SRSCLIST=
  3155. ALL_KT_COMMANDS=
  3156. KT_CLASSES=
  3157. }
  3158. when ($SOURCES_JAR == "yes") {
  3159. _PACK_SRC_JAR=$_PACK_SRC_JAR_IMPL
  3160. }
  3161. when ($JAVA_COVERAGE == "yes") {
  3162. JAVA_COVERAGE_SRCLIST=$JAVA_COVERAGE_SRCLIST_FLAG
  3163. }
  3164. when ($MAKE_UBERJAR_VALUE == "yes") {
  3165. _LINK_UBERJAR=$_DO_LINK_UBERJAR
  3166. PACK_JAR=$_PACK_JAR_HELPER(${BINDIR}/${REALPRJNAME}.lib.jar)
  3167. # TODO: This condition is incorrect in case of autoinputs _UBERJAR_SELF should be empty only for
  3168. # modules without AUTO_INPUT and withuout JAVA_SRCS added inputs.
  3169. when($ALL_JAR_SOURCES) {
  3170. _UBERJAR_SELF=--jar ${BINDIR}/${REALPRJNAME}.lib.jar
  3171. }
  3172. PEERDIR+=build/platform/java/uberjar
  3173. PEERDIR+=$UBERJAR_RESOURCE_PEERDIR
  3174. }
  3175. when($JAVA_YNDEXING == "yes") {
  3176. PEERDIR+=build/platform/java/kythe
  3177. _DO_JAVA_YNDEXING=&& $_JAVAC_RUN_HELPER($_JAVA_YNDEXING_CMD) && ${cwd:BINDIR} $YMAKE_PYTHON ${input:"build/scripts/find_and_tar.py"} kindex.tar .kzip ${output;hide;tared:"kindex.tar"}
  3178. }
  3179. when($ERROR_PRONE_VALUE) {
  3180. PEERDIR+=$ERROR_PRONE_PEERDIR
  3181. JAVAC_CMD=$ERROR_PRONE_JAVAC_CMD
  3182. }
  3183. when($ERROR_PRONE_VALUE && $JDK_REAL_VERSION == "16") {
  3184. JAVAC_FLAGS_VALUE+=$ERROR_PRONE_JDK16_ADD_OPENS
  3185. JAVAC_OPTS+=$ERROR_PRONE_JDK16_ADD_OPENS
  3186. }
  3187. when($ERROR_PRONE_VALUE && $JDK_REAL_VERSION == "17") {
  3188. JAVAC_FLAGS_VALUE+=$ERROR_PRONE_JDK16_ADD_OPENS
  3189. JAVAC_OPTS+=$ERROR_PRONE_JDK16_ADD_OPENS
  3190. }
  3191. when($ERROR_PRONE_VALUE && $ERROR_PRONE_VERSION == "2.7.1") {
  3192. JAVAC_FLAGS_VALUE+=$ERROR_PRONE_2_7_1_FORCED_OPTS
  3193. JAVAC_OPTS+=$ERROR_PRONE_2_7_1_FORCED_OPTS
  3194. }
  3195. when ($JAVA_ADD_DLLS_VALUE == "yes") {
  3196. CONSUME_NON_MANAGEABLE_PEERS=yes
  3197. _PACK_JNI=$_PACK_JNI_CMD
  3198. }
  3199. when ($LINT_LEVEL_VALUE != "none") {
  3200. _MAKE_JSTYLE_FILE_LIST= && $YMAKE_PYTHON ${input:"build/scripts/writer.py"} --file ${output;noauto:"lint-java.srclst"} -m --ya-start-command-file $LINT_JAVA_SOURCES --ya-end-command-file
  3201. }
  3202. SET(MODULE_TYPE JAVA_LIBRARY)
  3203. ENABLE(YMAKE_JAVA_TEST)
  3204. _ADD_JAVA_STYLE_CHECKS($(BUILD_ROOT)/$MODDIR/lint-java.srclst::$(SOURCE_ROOT))
  3205. _ADD_CLASSPATH_CLASH_CHECK()
  3206. JAVA_MODULE(IDEA_ONLY)
  3207. }
  3208. # tag:java-specific
  3209. _SCRIPTGEN_FLAGS=
  3210. macro _GEN_JAVA_SCRIPT_IMPL(Out, Template, Props...) {
  3211. .CMD=$SCRIPTGEN_RESOURCE_GLOBAL/scriptgen --java $JDK_RESOURCE/bin/java --output ${output:Out} --template ${input:Template} ${_SCRIPTGEN_FLAGS} -D JAR_NAME=${REALPRJNAME}.jar -D CLASSPATH=${nopath;join;ext=.jar;pre="::":MANAGED_PEERS_CLOSURE} -D PROJECT_DIR=${MODDIR} -D JAR_BASENAME=${REALPRJNAME} $Props
  3212. }
  3213. # tag:java-specific
  3214. _GEN_USERSCRIPTS=
  3215. macro _ADD_GEN_JAVA_SCRIPT(Out, Template, Props...) {
  3216. SET_APPEND(_GEN_USERSCRIPTS && \$_GEN_JAVA_SCRIPT_IMPL($Out $Template $Props))
  3217. }
  3218. # tag:java-specific
  3219. _PACK_JDK=
  3220. # tag:java-specific
  3221. DO_GEN_JAVA_RUN_SH=
  3222. _SOURCE_JARS=
  3223. _SOURCE_JARS_CPLIST=
  3224. GEN_JAVA_RUN_SH=$SCRIPTGEN_RESOURCE_GLOBAL/scriptgen --java $JDK_RESOURCE/bin/java --output ${output:"run.sh"} -D GENERATE_DEFAULT_RUNNER=yes -D JAR_NAME=${REALPRJNAME}.jar -D CLASSPATH=${nopath;join;pre="::":MANAGED_PEERS_CLOSURE} -D PROJECT_DIR=${REALPRJNAME}
  3225. GEN_RUN_CP=${YMAKE_PYTHON} ${input:"build/scripts/writer.py"} --file ${BINDIR}/run-bf.txt -Q -m --ya-start-command-file ${nopath;qe;pre=$REALPRJNAME/:MANAGED_PEERS_CLOSURE} --ya-end-command-file && ${YMAKE_PYTHON} ${input:"build/scripts/make_manifest_from_bf.py"} ${BINDIR}/run-bf.txt ${TARGET}
  3226. COLLECT_JAR_PROGRAM_CP=$FS_TOOLS link_or_copy_to_dir --ya-start-command-file ${ext=.jar:MANAGED_PEERS_CLOSURE} ${ext=.so:MANAGED_PEERS_CLOSURE} ${ext=.dll:MANAGED_PEERS_CLOSURE} ${ext=.dylib:MANAGED_PEERS_CLOSURE} ${_SOURCE_JARS} --ya-end-command-file ${BINDIR}/${REALPRJNAME} ${hide;late_out;nopath;ext=.jar;pre=$BINDIR/$REALPRJNAME/:MANAGED_PEERS_CLOSURE} ${hide;late_out;nopath;ext=.so;pre=$BINDIR/$REALPRJNAME/:MANAGED_PEERS_CLOSURE} ${hide;late_out;nopath;ext=.dll;pre=$BINDIR/$REALPRJNAME/:MANAGED_PEERS_CLOSURE} ${hide;late_out;nopath;ext=.dylib;pre=$BINDIR/$REALPRJNAME/:MANAGED_PEERS_CLOSURE}
  3227. MAKE_JAR_PROGRAM_CPLST=$YMAKE_PYTHON ${input:"build/scripts/make_java_classpath_file.py"} --from-args ${output;pre=$MODULE_PREFIX;suf=${MODULE_SUFFIX}.cplst:REALPRJNAME} --ya-start-command-file ${nopath;rootrel;ext=.jar;pre=$BINDIR/$REALPRJNAME/:MANAGED_PEERS_CLOSURE} ${_SOURCE_JARS_CPLIST} --ya-end-command-file
  3228. TAR_CLASSPATH= && $YMAKE_PYTHON ${input:"build/scripts/find_and_tar.py"} ${output;pre=$MODULE_PREFIX;suf=.tar:REALPRJNAME} ${cwd;pre=$BINDIR/:REALPRJNAME}
  3229. DO_TAR_CLASSPATH=
  3230. LINK_JAR_PROGRAM=$FS_TOOLS md ${BINDIR}/${REALPRJNAME} && $COLLECT_JAR_PROGRAM_CP && $DO_GEN_JAVA_RUN_SH && $GEN_RUN_CP && $MAKE_JAR_PROGRAM_CPLST $DO_TAR_CLASSPATH $_GEN_USERSCRIPTS $_PACK_JDK ${kv;hide:"p JP"} ${kv;hide:"pc light-blue"} ${kv;hide:"show_out"}
  3231. # tag:java-specific
  3232. # UBERJAR program link command
  3233. LINK_UBERJAR_PROGRAM=$YMAKE_PYTHON ${input:"build/scripts/make_java_classpath_file.py"} --from-args ${output;pre=$MODULE_PREFIX;suf=${MODULE_SUFFIX}.cplst:REALPRJNAME} $TARGET \
  3234. && $FS_TOOLS md ${BINDIR}/${REALPRJNAME} \
  3235. && $FS_TOOLS link_or_copy ${BINDIR}/${REALPRJNAME}.jar $TARGET \
  3236. && $FS_TOOLS link_or_copy_to_dir --ya-start-command-file ${BINDIR}/${REALPRJNAME}.jar ${ext=.so:MANAGED_PEERS_CLOSURE} ${ext=.dll:MANAGED_PEERS_CLOSURE} ${ext=.dylib:MANAGED_PEERS_CLOSURE} ${_SOURCE_JARS} --ya-end-command-file ${BINDIR}/${REALPRJNAME} ${hide;late_out;ext=.jar;pre=$BINDIR/$REALPRJNAME/:REALPRJNAME} ${hide;late_out;nopath;ext=.so;pre=$BINDIR/$REALPRJNAME/:MANAGED_PEERS_CLOSURE} ${hide;late_out;nopath;ext=.dll;pre=$BINDIR/$REALPRJNAME/:MANAGED_PEERS_CLOSURE} ${hide;late_out;nopath;ext=.dylib;pre=$BINDIR/$REALPRJNAME/:MANAGED_PEERS_CLOSURE} \
  3237. $DO_TAR_CLASSPATH \
  3238. $_GEN_USERSCRIPTS \
  3239. $_PACK_JDK
  3240. # tag:java-specific
  3241. RUN_WITH_SOURCES=no
  3242. TARED_CLASSPATH=yes # TODO jbuild creates tar with all classpath deps by default and some projects rely on this. In ymake build this tar file creation is not needed and should be disabled by dafault in future
  3243. _JAR_SRCS_CALLED=no
  3244. # tag:java-specific
  3245. macro _MARK_JAVA_PROG_WITH_SOURCES(Args...) {
  3246. ENABLE(_JAR_SRCS_CALLED)
  3247. }
  3248. # tag:java-specific
  3249. module _JAR_RUNABLE: _COMPILABLE_JAR_BASE {
  3250. .FINAL_TARGET=yes
  3251. .CMD=LINK_JAR_PROGRAM
  3252. .ALIASES=JAVA_SRCS=_MARK_JAVA_PROG_WITH_SOURCES GENERATE_SCRIPT=_YMAKE_GENERATE_SCRIPT
  3253. MODULE_SUFFIX=.run.cp.jar
  3254. CONSUME_NON_MANAGEABLE_PEERS=yes
  3255. when ($RUN_WITH_SOURCES == "yes") {
  3256. _SOURCE_JARS=${ext=.jar;noext;suf=-sources.jar:MANAGED_PEERS_CLOSURE} ${hide;late_out;ext=.jar;nopath;pre=$BINDIR/$REALPRJNAME/;noext;suf=-sources.jar:MANAGED_PEERS_CLOSURE}
  3257. _SOURCE_JARS_CPLIST=${nopath;rootrel;ext=.jar;pre=$BINDIR/$REALPRJNAME/;noext;suf=-sources.jar:MANAGED_PEERS_CLOSURE}
  3258. }
  3259. when ($_JAR_SRCS_CALLED && $TARED_CLASSPATH) {
  3260. DO_TAR_CLASSPATH=$TAR_CLASSPATH
  3261. }
  3262. when ($DISABLE_SCRIPTGEN) {
  3263. DO_GEN_JAVA_RUN_SH=
  3264. }
  3265. otherwise {
  3266. DO_GEN_JAVA_RUN_SH=$GEN_JAVA_RUN_SH
  3267. PEERDIR+=build/platform/java/scriptgen
  3268. }
  3269. when ($WITH_JDK_VALUE) {
  3270. _PACK_JDK= && ${YMAKE_PYTHON} ${input:"build/scripts/tar_directory.py"} ${output;tared:"jdk.tar"} $WITH_JDK_RESOURCE $WITH_JDK_RESOURCE
  3271. }
  3272. when ($MAKE_UBERJAR_VALUE == "yes") {
  3273. LINK_JAR_PROGRAM=$LINK_UBERJAR_PROGRAM
  3274. DYNAMIC_LINK=no
  3275. _SCRIPTGEN_FLAGS=-D IS_UBERJAR=yes
  3276. }
  3277. otherwise {
  3278. _SCRIPTGEN_FLAGS=-D IS_UBERJAR=no
  3279. }
  3280. CHECK_PROVIDES()
  3281. }
  3282. # tag:java-specific
  3283. multimodule JAR_PROGRAM {
  3284. module JAR_RUNABLE: _JAR_RUNABLE {
  3285. .ALLOWED=JAVA_RUNTIME_PEERDIR JAVA_RUNTIME_EXCLUDE
  3286. .IGNORED=JAVA_SRCS RUN_JAVA_PROGRAM
  3287. .ALIASES=EXCLUDE=_NOOP_MACRO PEERDIR=_NOOP_MACRO DEPENDENCY_MANAGEMENT=_NOOP_MACRO JAVA_RUNTIME_PEERDIR=PEERDIR JAVA_RUNTIME_EXCLUDE=EXCLUDE
  3288. .PEERDIRSELF=JAR_COMPILATION
  3289. SET(MODULE_TYPE JAVA_PROGRAM)
  3290. }
  3291. module JAR_COMPILATION: JAR_LIBRARY {
  3292. .ALIASES=JAVA_RUNTIME_PEERDIR=_NOOP_MACRO JAVA_RUNTIME_EXCLUDE=_NOOP_MACRO
  3293. .FINAL_TARGET=no
  3294. SET(MODULE_TYPE JAVA_PROGRAM)
  3295. }
  3296. }
  3297. # tag:java-specific
  3298. LINK_JAR_TEST=${YMAKE_PYTHON} ${input:"build/scripts/writer.py"} --file ${BINDIR}/run-bf.txt -Q -m --ya-start-command-file ${ext=.jar:MANAGED_PEERS_CLOSURE} --ya-end-command-file && ${YMAKE_PYTHON} ${input:"build/scripts/make_manifest_from_bf.py"} ${BINDIR}/run-bf.txt ${TARGET}
  3299. YMAKE_JAVA_TEST=
  3300. module _JAR_TEST: _COMPILABLE_JAR_BASE {
  3301. .FINAL_TARGET=yes
  3302. .CMD=LINK_JAR_TEST
  3303. CONSUME_NON_MANAGEABLE_PEERS=yes
  3304. SET(MODULE_SUFFIX .test.cp.jar)
  3305. ENABLE(YMAKE_JAVA_TEST)
  3306. JAVA_TEST()
  3307. CHECK_PROVIDES()
  3308. }
  3309. # tag:java-specific
  3310. multimodule JUNIT5_YMAKE {
  3311. module JAR_TESTABLE: _JAR_TEST {
  3312. .ALLOWED=JAVA_TEST_PEERDIR
  3313. .IGNORED=JAVA_SRCS RUN_JAVA_PROGRAM
  3314. .ALIASES=EXCLUDE=_NOOP_MACRO PEERDIR=_NOOP_MACRO DEPENDENCY_MANAGEMENT=_NOOP_MACRO JAVA_TEST_PEERDIR=PEERDIR
  3315. .PEERDIRSELF=JAR_COMPILATION
  3316. SET(MODULE_TYPE JUNIT5)
  3317. }
  3318. module JAR_COMPILATION: JAR_LIBRARY {
  3319. .IGNORED=JAVA_TEST_PEERDIR
  3320. .ALIASES=JAVA_TEST_PEERDIR=_NOOP_MACRO
  3321. .FINAL_TARGET=no
  3322. PEERDIR(devtools/junit5-runner build/platform/java/jacoco-agent)
  3323. }
  3324. }
  3325. # tag:java-specific
  3326. multimodule JTEST_YMAKE {
  3327. module JAR_TESTABLE: _JAR_TEST {
  3328. .ALLOWED=YT_SPEC
  3329. .IGNORED=JAVA_SRCS RUN_JAVA_PROGRAM
  3330. .ALIASES=EXCLUDE=_NOOP_MACRO PEERDIR=_NOOP_MACRO DEPENDENCY_MANAGEMENT=_NOOP_MACRO JAVA_TEST_PEERDIR=PEERDIR
  3331. .PEERDIRSELF=JAR_COMPILATION
  3332. SET(MODULE_TYPE JTEST)
  3333. PEERDIR(devtools/junit-runner)
  3334. DEPENDENCY_MANAGEMENT(contrib/java/org/hamcrest/hamcrest-core/1.3 contrib/java/com/google/code/gson/gson/2.8.6 contrib/java/com/beust/jcommander/1.72 contrib/java/junit/junit/4.12)
  3335. }
  3336. module JAR_COMPILATION: JAR_LIBRARY {
  3337. .ALIASES=JAVA_TEST_PEERDIR=_NOOP_MACRO
  3338. .ALLOWED=YT_SPEC
  3339. .FINAL_TARGET=no
  3340. DEPENDS(contrib/java/org/sonarsource/scanner/cli/sonar-scanner-cli/2.8)
  3341. PEERDIR(build/platform/java/jacoco-agent)
  3342. }
  3343. }
  3344. # tag:python-specific tag:deprecated
  3345. ### @usage: PY2_LIBRARY() # deprecated
  3346. ###
  3347. ### Deprecated. Use PY23_LIBRARY or PY3_LIBRARY instead.
  3348. ### Python 2.x binary built library. Builds sources from PY_SRCS to data suitable for PY2_PROGRAM.
  3349. ### Adds dependencies to Python 2.x runtime library from Arcadia.
  3350. ### This module is only compatible with PYTHON2-tagged modules and selects those from multimodules.
  3351. ### This module is only compatible with Arcadia Python build.
  3352. ###
  3353. ### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/py_srcs/
  3354. module PY2_LIBRARY: _LIBRARY {
  3355. _ARCADIA_PYTHON_ADDINCL()
  3356. when ($NO_PYTHON_INCLS != "yes") {
  3357. PEERDIR+=contrib/libs/python
  3358. }
  3359. when ($MSVC == "yes" || $CYGWIN == "yes") {
  3360. MODULE_PREFIX=py
  3361. }
  3362. otherwise {
  3363. MODULE_PREFIX=libpy
  3364. }
  3365. .ALLOWED=FORK_TESTS
  3366. .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER USE_PYTHON2
  3367. .RESTRICTED=PYTHON3_ADDINCL USE_PYTHON3 PYTHON2_ADDINCL OPTIMIZE_PY_PROTOS NO_OPTIMIZE_PY_PROTOS
  3368. USE_GLOBAL_CMD=yes
  3369. when ($PY_PROTO_MYPY_ENABLED == "yes") {
  3370. PY_PROTO_MYPY_SUFFIX=_pb2.pyi
  3371. PY_PROTO_MYPY_PLUGIN=$PY_PROTO_MYPY_PLUGIN_BASE ${output;hide;noauto;norel;nopath;noext;suf=_pb2.pyi:File}
  3372. PY_PROTO_MYPY_PLUGIN_INTERNAL=$PY_PROTO_MYPY_PLUGIN_BASE ${output;hide;noauto;norel;nopath;noext;suf=__int___pb2.pyi:File} ${hide;kv:"ext_out_name_for_${nopath;noext;suf=__int___pb2.pyi:File} ${nopath;noext;suf=_pb2.pyi:File}"})
  3373. }
  3374. SET(MODULE_LANG PY2)
  3375. }
  3376. # tag:python-specific
  3377. ### @usage: PY3_LIBRARY()
  3378. ###
  3379. ### Python 3.x binary library. Builds sources from PY_SRCS to data suitable for PY2_PROGRAM
  3380. ### Adds dependencies to Python 2.x runtime library from Arcadia.
  3381. ### This module is only compatible with PYTHON3-tagged modules and selects those from multimodules.
  3382. ### This module is only compatible with Arcadia Python build.
  3383. ###
  3384. ### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/py_srcs/
  3385. module PY3_LIBRARY: _LIBRARY {
  3386. _ARCADIA_PYTHON3_ADDINCL()
  3387. when ($NO_PYTHON_INCLS != "yes") {
  3388. PEERDIR+=contrib/libs/python
  3389. }
  3390. when ($MSVC == "yes" || $CYGWIN == "yes") {
  3391. MODULE_PREFIX=py
  3392. }
  3393. otherwise {
  3394. MODULE_PREFIX=libpy
  3395. }
  3396. .ALLOWED=FORK_TESTS
  3397. .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER
  3398. .RESTRICTED=PYTHON3_ADDINCL USE_PYTHON3 PYTHON2_ADDINCL USE_PYTHON2 OPTIMIZE_PY_PROTOS NO_OPTIMIZE_PY_PROTOS
  3399. USE_GLOBAL_CMD=yes
  3400. PEERDIR($YMAKE_PYTHON3_PEER)
  3401. RUN_CYTHON_SCRIPT=$YMAKE_PYTHON3 $CYTHON_SCRIPT
  3402. when ($PY_PROTO_MYPY_ENABLED == "yes") {
  3403. PY_PROTO_MYPY_SUFFIX=_pb2.pyi
  3404. PY_PROTO_MYPY_PLUGIN=$PY_PROTO_MYPY_PLUGIN_BASE ${output;hide;noauto;norel;nopath;noext;suf=_pb2.pyi:File}
  3405. PY_PROTO_MYPY_PLUGIN_INTERNAL=$PY_PROTO_MYPY_PLUGIN_BASE ${output;hide;noauto;norel;nopath;noext;suf=__int___pb2.pyi:File} ${hide;kv:"ext_out_name_for_${nopath;noext;suf=__int___pb2.pyi:File} ${nopath;noext;suf=_pb2.pyi:File}"})
  3406. }
  3407. SET(MODULE_LANG PY3)
  3408. }
  3409. # tag:python-specific
  3410. ### @usage: _BASE_PY_PROGRAM #internal
  3411. ###
  3412. ### The base module for all Python 2.x binary programs. Adds linking logic, relevant module properties and
  3413. ### dependency on Python 2.x interpreter. Also adds import tests on all sources including PEERDIR'ed libraries.
  3414. ### Links all Python 2.x libraries and Python 2.x interpreter into itself to form regular executable.
  3415. ### This only compatible with PYTHON2-tagged modules and selects those from multimodules.
  3416. ###
  3417. ### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/py_srcs/
  3418. module _BASE_PY_PROGRAM: _BASE_PROGRAM {
  3419. .CMD=PY_PROGRAM_LINK_EXE
  3420. _ARCADIA_PYTHON_ADDINCL()
  3421. when ($SANITIZER_TYPE && $SANITIZER_TYPE != "no") {
  3422. NO_CHECK_IMPORTS_FOR_VALUE=
  3423. }
  3424. ADD_CHECK_PY_IMPORTS()
  3425. when ($NO_PYTHON_INCLS != "yes") {
  3426. PEERDIR += contrib/libs/python
  3427. }
  3428. when ($USE_ARCADIA_PYTHON == "yes") {
  3429. PEERDIR += library/python/runtime/main
  3430. PEERDIR += contrib/python/subprocess32
  3431. when ($PYTHON_SQLITE3 != "no") {
  3432. PEERDIR += contrib/tools/python/src/Modules/_sqlite
  3433. }
  3434. }
  3435. when ($PYTHON_COVERAGE == "yes") {
  3436. PEERDIR+=library/python/coverage
  3437. }
  3438. when ($ARCH_PPC64LE == "yes") {
  3439. _MY_ALLOCATOR=SYSTEM
  3440. }
  3441. otherwise {
  3442. _MY_ALLOCATOR=J
  3443. }
  3444. ALLOCATOR($_MY_ALLOCATOR)
  3445. STRIP()
  3446. when ($BUILD_TYPE == "DEBUG") {
  3447. NO_STRIP=yes
  3448. }
  3449. when ($SANITIZER_TYPE && $SANITIZER_TYPE != "no") {
  3450. NO_STRIP=yes
  3451. }
  3452. .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER USE_PYTHON2
  3453. .RESTRICTED=PYTHON3_ADDINCL USE_PYTHON3 PYTHON2_ADDINCL OPTIMIZE_PY_PROTOS NO_OPTIMIZE_PY_PROTOS
  3454. SET(MODULE_LANG PY2)
  3455. }
  3456. # tag:python-specific tag:codenav
  3457. when ($CODENAVIGATION && $NOCODENAVIGATION != "yes") {
  3458. PY3_PROGRAM_LINK_EXE=$LINK_EXE ${kv;hide:"py3yndex $TARGET"}
  3459. }
  3460. otherwise {
  3461. PY3_PROGRAM_LINK_EXE=$LINK_EXE
  3462. }
  3463. # tag:python-specific
  3464. ### @usage: _BASE_PY_PROGRAM #internal
  3465. ###
  3466. ### The base module for all Python 3.x binary programs. Adds linking logic, relevant module properties and
  3467. ### dependency on Python 3.x interpreter. Also adds import tests on all sources including libraries.
  3468. ### Links all Python 3.x libraries and Python 3.x interpreter into itself to form regular executable.
  3469. ### This only compatible with PYTHON3-tagged modules and selects those from multimodules
  3470. ###
  3471. ### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/py_srcs/
  3472. module _BASE_PY3_PROGRAM: _BASE_PROGRAM {
  3473. .CMD=PY3_PROGRAM_LINK_EXE
  3474. _ARCADIA_PYTHON3_ADDINCL()
  3475. PEERDIR(library/python/runtime_py3/main)
  3476. when ($PYTHON_SQLITE3 != "no") {
  3477. PEERDIR += contrib/tools/python3/src/Modules/_sqlite
  3478. }
  3479. when ($SANITIZER_TYPE && $SANITIZER_TYPE != "no") {
  3480. NO_CHECK_IMPORTS_FOR_VALUE=
  3481. }
  3482. ADD_CHECK_PY_IMPORTS()
  3483. when ($ARCH_PPC64LE == "yes") {
  3484. _MY_ALLOCATOR=SYSTEM
  3485. }
  3486. otherwise {
  3487. _MY_ALLOCATOR=J
  3488. }
  3489. ALLOCATOR($_MY_ALLOCATOR)
  3490. STRIP()
  3491. when ($NO_PYTHON_INCLS != "yes") {
  3492. PEERDIR+=contrib/libs/python
  3493. }
  3494. when ($BUILD_TYPE == "DEBUG") {
  3495. NO_STRIP=yes
  3496. }
  3497. when ($SANITIZER_TYPE && $SANITIZER_TYPE != "no") {
  3498. NO_STRIP=yes
  3499. }
  3500. when ($PYTHON_COVERAGE == "yes") {
  3501. PEERDIR+=library/python/coverage
  3502. }
  3503. when ($CODENAVIGATION && $NOCODENAVIGATION != "yes") {
  3504. PEERDIR += contrib/python/six
  3505. }
  3506. .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER
  3507. .RESTRICTED=PYTHON3_ADDINCL USE_PYTHON3 PYTHON2_ADDINCL USE_PYTHON2
  3508. SET(MODULE_LANG PY3)
  3509. }
  3510. # tag:python-specific
  3511. ### @usage: PY3_PROGRAM_BIN([progname])
  3512. ### Use instead of PY3_PROGRAM only if ya.make with PY3_PROGRAM() included in another ya.make
  3513. ### In all other cases use PY3_PROGRAM
  3514. module PY3_PROGRAM_BIN: _BASE_PY3_PROGRAM {
  3515. # Look's like we cannot avoid copy-paste util ymake supports multiple inheritance
  3516. # We need to attach coverage.extractor to every py_program target, except pytest targets
  3517. ADD_YTEST($MODULE_PREFIX$REALPRJNAME coverage.extractor)
  3518. }
  3519. # tag:java-specific
  3520. JAVA_SWIG_DELIM=JAVA_SWIG_DELIM
  3521. # tag:java-specific
  3522. JDK_REAL_VERSION=
  3523. JDK_VERSION=
  3524. when ($JDK_VERSION == "17") {
  3525. JDK_REAL_VERSION=17
  3526. }
  3527. elsewhen ($JDK_VERSION == "16") {
  3528. JDK_REAL_VERSION=16
  3529. }
  3530. elsewhen ($JDK_VERSION == "15") {
  3531. JDK_REAL_VERSION=15
  3532. }
  3533. elsewhen ($JDK_VERSION == "14") {
  3534. JDK_REAL_VERSION=14
  3535. }
  3536. elsewhen ($JDK_VERSION == "13") {
  3537. JDK_REAL_VERSION=13
  3538. }
  3539. elsewhen ($JDK_VERSION == "12") {
  3540. JDK_REAL_VERSION=12
  3541. }
  3542. elsewhen ($JDK_VERSION == "11") {
  3543. JDK_REAL_VERSION=11
  3544. }
  3545. elsewhen ($JDK_VERSION == "10") {
  3546. JDK_REAL_VERSION=10
  3547. }
  3548. elsewhen ($JDK_VERSION == "8") {
  3549. JDK_REAL_VERSION=8
  3550. }
  3551. elsewhen ($MAPSMOBI_BUILD_TARGET && $OS_ANDROID) {
  3552. JDK_REAL_VERSION=8
  3553. }
  3554. otherwise {
  3555. JDK_REAL_VERSION=17
  3556. }
  3557. # tag:java-specific
  3558. # remove extra peerdir to jdk11 after https://st.yandex-team.ru/DEVTOOLS-8851 is done
  3559. when ($USE_SYSTEM_JDK) {
  3560. JDK_RESOURCE_PEERDIR=
  3561. }
  3562. otherwise {
  3563. when ($JDK_REAL_VERSION == "17") {
  3564. # need jdk11 for spare parts in "host" platform
  3565. JDK_RESOURCE_PEERDIR=build/platform/java/jdk/jdk17 build/platform/java/jdk/jdk11
  3566. }
  3567. when ($JDK_REAL_VERSION == "16") {
  3568. JDK_RESOURCE_PEERDIR=build/platform/java/jdk/jdk16 build/platform/java/jdk/jdk17
  3569. }
  3570. when ($JDK_REAL_VERSION == "15") {
  3571. JDK_RESOURCE_PEERDIR=build/platform/java/jdk/jdk15 build/platform/java/jdk/jdk17
  3572. }
  3573. when ($JDK_REAL_VERSION == "14") {
  3574. JDK_RESOURCE_PEERDIR=build/platform/java/jdk/jdk14 build/platform/java/jdk/jdk17
  3575. }
  3576. when ($JDK_REAL_VERSION == "13") {
  3577. JDK_RESOURCE_PEERDIR=build/platform/java/jdk/jdk13 build/platform/java/jdk/jdk17
  3578. }
  3579. when ($JDK_REAL_VERSION == "12") {
  3580. JDK_RESOURCE_PEERDIR=build/platform/java/jdk/jdk12 build/platform/java/jdk/jdk17
  3581. }
  3582. when ($JDK_REAL_VERSION == "11") {
  3583. JDK_RESOURCE_PEERDIR=build/platform/java/jdk/jdk11 build/platform/java/jdk/jdk17
  3584. }
  3585. when ($JDK_REAL_VERSION == "10") {
  3586. JDK_RESOURCE_PEERDIR=build/platform/java/jdk/jdk10 build/platform/java/jdk/jdk17
  3587. }
  3588. when ($JDK_REAL_VERSION == "8") {
  3589. JDK_RESOURCE_PEERDIR=build/platform/java/jdk/jdk8 build/platform/java/jdk/jdk17
  3590. }
  3591. }
  3592. # tag:java-specific
  3593. when ($JDK_REAL_VERSION == "17") {
  3594. UBERJAR_RESOURCE_PEERDIR=build/platform/java/uberjar/uberjar17
  3595. }
  3596. when ($JDK_REAL_VERSION == "16") {
  3597. UBERJAR_RESOURCE_PEERDIR=build/platform/java/uberjar/uberjar16
  3598. }
  3599. when ($JDK_REAL_VERSION == "15") {
  3600. UBERJAR_RESOURCE_PEERDIR=build/platform/java/uberjar/uberjar15
  3601. }
  3602. when ($JDK_REAL_VERSION == "14") {
  3603. UBERJAR_RESOURCE_PEERDIR=build/platform/java/uberjar/uberjar14
  3604. }
  3605. when ($JDK_REAL_VERSION == "13") {
  3606. UBERJAR_RESOURCE_PEERDIR=build/platform/java/uberjar/uberjar13
  3607. }
  3608. when ($JDK_REAL_VERSION == "12") {
  3609. UBERJAR_RESOURCE_PEERDIR=build/platform/java/uberjar/uberjar12
  3610. }
  3611. when ($JDK_REAL_VERSION == "11") {
  3612. UBERJAR_RESOURCE_PEERDIR=build/platform/java/uberjar/uberjar11
  3613. }
  3614. when ($JDK_REAL_VERSION == "10") {
  3615. UBERJAR_RESOURCE_PEERDIR=build/platform/java/uberjar/uberjar10
  3616. }
  3617. when ($JDK_REAL_VERSION == "8") {
  3618. UBERJAR_RESOURCE_PEERDIR=build/platform/java/uberjar/uberjar8
  3619. }
  3620. # tag:java-specific
  3621. JAVAC_OPTS=
  3622. when ($USE_SYSTEM_JDK) {
  3623. JDK_RESOURCE=$USE_SYSTEM_JDK
  3624. }
  3625. otherwise {
  3626. when ($JDK_REAL_VERSION == "17") {
  3627. JDK_RESOURCE=$JDK17_RESOURCE_GLOBAL
  3628. }
  3629. when ($JDK_REAL_VERSION == "16") {
  3630. JDK_RESOURCE=$JDK16_RESOURCE_GLOBAL
  3631. }
  3632. when ($JDK_REAL_VERSION == "15") {
  3633. JDK_RESOURCE=$JDK15_RESOURCE_GLOBAL
  3634. }
  3635. when ($JDK_REAL_VERSION == "14") {
  3636. JDK_RESOURCE=$JDK14_RESOURCE_GLOBAL
  3637. }
  3638. when ($JDK_REAL_VERSION == "13") {
  3639. JDK_RESOURCE=$JDK13_RESOURCE_GLOBAL
  3640. }
  3641. when ($JDK_REAL_VERSION == "12") {
  3642. JDK_RESOURCE=$JDK12_RESOURCE_GLOBAL
  3643. }
  3644. when ($JDK_REAL_VERSION == "11") {
  3645. JDK_RESOURCE=$JDK11_RESOURCE_GLOBAL
  3646. }
  3647. when ($JDK_REAL_VERSION == "10") {
  3648. JDK_RESOURCE=$JDK10_RESOURCE_GLOBAL
  3649. }
  3650. when ($JDK_REAL_VERSION == "8") {
  3651. JDK_RESOURCE=$JDK8_RESOURCE_GLOBAL
  3652. }
  3653. }
  3654. # tag:java-specific
  3655. when (!$USE_SYSTEM_ERROR_PRONE) {
  3656. when ($JDK_REAL_VERSION == "8" || $JDK_REAL_VERSION == "10") {
  3657. ERROR_PRONE_VERSION=2.3.1
  3658. ERROR_PRONE_PEERDIR=build/platform/java/error_prone/2.3.1
  3659. ERROR_PRONE_RESOURCE=$ERROR_PRONE_2_3_1_RESOURCE_GLOBAL
  3660. }
  3661. elsewhen ($JDK_REAL_VERSION == "11" || $JDK_REAL_VERSION == "12" || $JDK_REAL_VERSION == "13" || $JDK_REAL_VERSION == "14" || $JDK_REAL_VERSION == "15" || $JDK_REAL_VERSION == "16") {
  3662. ERROR_PRONE_VERSION=2.7.1
  3663. ERROR_PRONE_PEERDIR=build/platform/java/error_prone/2.7.1
  3664. ERROR_PRONE_RESOURCE=$ERROR_PRONE_2_7_1_RESOURCE_GLOBAL
  3665. }
  3666. elsewhen ($JDK_REAL_VERSION == "17") {
  3667. ERROR_PRONE_VERSION=2.10.0
  3668. ERROR_PRONE_PEERDIR=build/platform/java/error_prone/2.10.0
  3669. ERROR_PRONE_RESOURCE=$ERROR_PRONE_2_10_0_RESOURCE_GLOBAL
  3670. }
  3671. otherwise {
  3672. ERROR_PRONE_VERSION=2.7.1
  3673. ERROR_PRONE_PEERDIR=build/platform/java/error_prone
  3674. ERROR_PRONE_RESOURCE=$ERROR_PRONE_RESOURCE_GLOBAL
  3675. }
  3676. }
  3677. otherwise {
  3678. ERROR_PRONE_VERSION=2.7.1
  3679. ERROR_PRONE_PEERDIR=build/platform/java/error_prone
  3680. ERROR_PRONE_RESOURCE=$ERROR_PRONE_RESOURCE_GLOBAL
  3681. }
  3682. # tag:java-specific
  3683. when ($USE_SYSTEM_UBERJAR) {
  3684. UBERJAR_RESOURCE=$USE_SYSTEM_UBERJAR
  3685. }
  3686. otherwise {
  3687. when ($JDK_REAL_VERSION == "17") {
  3688. UBERJAR_RESOURCE=$UBERJAR17_RESOURCE_GLOBAL
  3689. }
  3690. when ($JDK_REAL_VERSION == "16") {
  3691. UBERJAR_RESOURCE=$UBERJAR16_RESOURCE_GLOBAL
  3692. }
  3693. when ($JDK_REAL_VERSION == "15") {
  3694. UBERJAR_RESOURCE=$UBERJAR15_RESOURCE_GLOBAL
  3695. }
  3696. when ($JDK_REAL_VERSION == "14") {
  3697. UBERJAR_RESOURCE=$UBERJAR14_RESOURCE_GLOBAL
  3698. }
  3699. when ($JDK_REAL_VERSION == "13") {
  3700. UBERJAR_RESOURCE=$UBERJAR13_RESOURCE_GLOBAL
  3701. }
  3702. when ($JDK_REAL_VERSION == "12") {
  3703. UBERJAR_RESOURCE=$UBERJAR12_RESOURCE_GLOBAL
  3704. }
  3705. when ($JDK_REAL_VERSION == "11") {
  3706. UBERJAR_RESOURCE=$UBERJAR11_RESOURCE_GLOBAL
  3707. }
  3708. when ($JDK_REAL_VERSION == "10") {
  3709. UBERJAR_RESOURCE=$UBERJAR10_RESOURCE_GLOBAL
  3710. }
  3711. when ($JDK_REAL_VERSION == "8") {
  3712. UBERJAR_RESOURCE=$UBERJAR8_RESOURCE_GLOBAL
  3713. }
  3714. }
  3715. # tag:java-specific
  3716. when ($JDK_REAL_VERSION == "17") {
  3717. WITH_JDK_RESOURCE=$WITH_JDK17_RESOURCE_GLOBAL
  3718. }
  3719. when ($JDK_REAL_VERSION == "16") {
  3720. WITH_JDK_RESOURCE=$WITH_JDK16_RESOURCE_GLOBAL
  3721. }
  3722. when ($JDK_REAL_VERSION == "15") {
  3723. WITH_JDK_RESOURCE=$WITH_JDK15_RESOURCE_GLOBAL
  3724. }
  3725. when ($JDK_REAL_VERSION == "14") {
  3726. WITH_JDK_RESOURCE=$WITH_JDK14_RESOURCE_GLOBAL
  3727. }
  3728. when ($JDK_REAL_VERSION == "13") {
  3729. WITH_JDK_RESOURCE=$WITH_JDK13_RESOURCE_GLOBAL
  3730. }
  3731. when ($JDK_REAL_VERSION == "12") {
  3732. WITH_JDK_RESOURCE=$WITH_JDK12_RESOURCE_GLOBAL
  3733. }
  3734. when ($JDK_REAL_VERSION == "11") {
  3735. WITH_JDK_RESOURCE=$WITH_JDK11_RESOURCE_GLOBAL
  3736. }
  3737. when ($JDK_REAL_VERSION == "10") {
  3738. WITH_JDK_RESOURCE=$WITH_JDK10_RESOURCE_GLOBAL
  3739. }
  3740. when ($JDK_REAL_VERSION == "8") {
  3741. WITH_JDK_RESOURCE=$WITH_JDK8_RESOURCE_GLOBAL
  3742. }
  3743. # tag:java-specific
  3744. EXTERNAL_JAVA_JDK_RESOURCE=
  3745. EXTERNAL_JAVA_EXTRA_PEERDIR=
  3746. when ($USE_SYSTEM_JDK) {
  3747. EXTERNAL_JAVA_EXTRA_PEERDIR=
  3748. EXTERNAL_JAVA_JDK_RESOURCE=$USE_SYSTEM_JDK
  3749. }
  3750. elsewhen ($JDK_VERSION == "") {
  3751. EXTERNAL_JAVA_JDK_RESOURCE=$JDK11_RESOURCE_GLOBAL
  3752. EXTERNAL_JAVA_EXTRA_PEERDIR=build/platform/java/jdk/jdk11
  3753. }
  3754. otherwise {
  3755. EXTERNAL_JAVA_JDK_RESOURCE=$JDK_RESOURCE
  3756. }
  3757. COMPILE_JAVA=${cwd:ARCADIA_BUILD_ROOT} $YMAKE_PYTHON ${input:"build/scripts/compile_java.py"} --javac-bin $EXTERNAL_JAVA_JDK_RESOURCE/bin/javac --jar-bin $JDK_RESOURCE/bin/jar $JAVA_VCS_MF_ARG $PACKAGE_PREFIX_ARGS --jar-output $TARGET --srcs-jar-output ${output;suf=-sources.jar:REALPRJNAME} $AUTO_INPUT DELIM $JAVAC_OPTS DELIM $MANAGED_PEERS_CLOSURE ${kv;hide:"p JV"} ${kv;hide:"pc light-blue"} ${kv;hide:"show_out"}
  3758. REAL_SWIG_DLL_JAR_CMD=$GENERATE_VCS_JAVA_INFO_NODEP && ${cwd:ARCADIA_BUILD_ROOT} $YMAKE_PYTHON ${input:"build/scripts/build_dll_and_java.py"} $JAVA_SWIG_DELIM $REAL_LINK_DYN_LIB $JAVA_SWIG_DELIM $COMPILE_JAVA $JAVA_SWIG_DELIM $AUTO_INPUT $JAVA_SWIG_DELIM $TARGET $JAVA_SWIG_DELIM ${output;suf=.jar:REALPRJNAME} $JAVA_SWIG_DELIM ${output;suf=-sources.jar:REALPRJNAME} $JAVA_SWIG_DELIM $ARCADIA_BUILD_ROOT $ARCADIA_ROOT
  3759. # tag:deprecated
  3760. ### @usage: METAQUERY() #deprecated
  3761. ###
  3762. ### Project Definition - KIWI Meta query. (Objected)
  3763. ###
  3764. ### https://wiki.yandex-team.ru/robot/manual/kiwi/techdoc/design/metaquery/
  3765. module METAQUERY: _BASE_UNIT {
  3766. .ALL_INS_TO_OUT=yes
  3767. .FINAL_TARGET=yes
  3768. PRINT_MODULE_TYPE(METAQUERY $MODULE_PREFIX$REALPRJNAME)
  3769. }
  3770. ARGS_DELIM="MACRO_CALLS_DELIM"
  3771. SYSTEM_PROPERTIES_VALUE=
  3772. ### @usage: SYSTEM_PROPERTIES([<Key Value>...] [<File Path>...])
  3773. ###
  3774. ### List of Key,Value pairs that will be available to test via System.getProperty().
  3775. ### FILE means that parst should be read from file specifies as Path.
  3776. ###
  3777. ### Documentation: https://wiki.yandex-team.ru/yatool/test/
  3778. macro SYSTEM_PROPERTIES(Args...) {
  3779. SET_APPEND(SYSTEM_PROPERTIES_VALUE $Args)
  3780. }
  3781. # tag:java-specific
  3782. JVM_ARGS_VALUE=
  3783. ### @usage: JVM_ARGS(Args...)
  3784. ###
  3785. ### Arguments to run Java programs in tests.
  3786. ###
  3787. ### Documentation: https://wiki.yandex-team.ru/yatool/test/
  3788. macro JVM_ARGS(Args...) {
  3789. SET_APPEND(JVM_ARGS_VALUE $Args)
  3790. }
  3791. # tag:java-specific
  3792. CHECK_JAVA_DEPS_VALUE=
  3793. ### @usage: CHECK_JAVA_DEPS(<yes|no>)
  3794. ###
  3795. ### Check for different classes with duplicate name in classpath.
  3796. ###
  3797. ### Documentation: https://wiki.yandex-team.ru/yatool/test/
  3798. macro CHECK_JAVA_DEPS(Arg) {
  3799. SET(CHECK_JAVA_DEPS_VALUE $Arg)
  3800. }
  3801. ERROR_PRONE_VALUE=
  3802. ### @usage: USE_ERROR_PRONE()
  3803. ###
  3804. ### Use errorprone instead of javac for .java compilation.
  3805. macro USE_ERROR_PRONE() {
  3806. SET(ERROR_PRONE_VALUE yes)
  3807. }
  3808. TEST_CWD_VALUE=
  3809. ### @usage: TEST_CWD(path)
  3810. ###
  3811. ### Defines working directory for test runs. Othen used in conjunction with DATA() macro.
  3812. ### Is only used inside of the TEST modules.
  3813. ###
  3814. ### Documentation: https://wiki.yandex-team.ru/yatool/test/
  3815. macro TEST_CWD(Arg) {
  3816. SET(TEST_CWD_VALUE $Arg)
  3817. }
  3818. # tag:java-specific
  3819. MAKE_UBERJAR_VALUE=
  3820. ### @usage: UBERJAR()
  3821. ###
  3822. ### UBERJAR is a single all-in-one jar-archive that includes all its Java dependencies (reachable PEERDIR).
  3823. ### It also supports shading classes inside the archive by moving them to a different package (similar to the maven-shade-plugin).
  3824. ### Use UBERJAR inside JAVA_PROGRAM module.
  3825. ###
  3826. ### You can use the following macros to configure the archive:
  3827. ### 1. UBERJAR_HIDING_PREFIX prefix for classes to shade (classes remain in their packages by default)
  3828. ### 2. UBERJAR_HIDE_EXCLUDE_PATTERN exclude classes matching this patterns from shading (if enabled).
  3829. ### 3. UBERJAR_PATH_EXCLUDE_PREFIX the prefix for classes that should not get into the jar archive (all classes are placed into the archive by default)
  3830. ### 4. UBERJAR_MANIFEST_TRANSFORMER_MAIN add ManifestResourceTransformer class to uberjar processing and specify main-class
  3831. ### 5. UBERJAR_MANIFEST_TRANSFORMER_ATTRIBUTE add ManifestResourceTransformer class to uberjar processing and specify some attribute
  3832. ### 6. UBERJAR_APPENDING_TRANSFORMER add AppendingTransformer class to uberjar processing
  3833. ### 7. UBERJAR_SERVICES_RESOURCE_TRANSFORMER add ServicesResourceTransformer class to uberjar processing
  3834. ###
  3835. ### Documentation: https://wiki.yandex-team.ru/yatool/java/
  3836. ###
  3837. ### @see: [JAVA_PROGRAM](#module_JAVA_PROGRAM), [UBERJAR_HIDING_PREFIX](#macro_UBERJAR_HIDING_PREFIX), [UBERJAR_HIDE_EXCLUDE_PATTERN](#macro_UBERJAR_HIDE_EXCLUDE_PATTERN), [UBERJAR_PATH_EXCLUDE_PREFIX](#macro_UBERJAR_PATH_EXCLUDE_PREFIX)
  3838. macro UBERJAR() {
  3839. SET(MAKE_UBERJAR_VALUE yes)
  3840. }
  3841. # tag:java-specific
  3842. UBERJAR_PREFIX_VALUE=
  3843. UBERJAR_PREFIX_FLAG=
  3844. ### @usage: UBERJAR_HIDING_PREFIX(Arg)
  3845. ###
  3846. ### Set prefix for classes to shade. All classes in UBERJAR will be moved into package prefixed with Arg.
  3847. ### Classes remain in their packages by default.
  3848. ###
  3849. ### @see: [UBERJAR](#macro_UBERJAR)
  3850. macro UBERJAR_HIDING_PREFIX(Arg) {
  3851. SET(UBERJAR_PREFIX_VALUE $Arg)
  3852. SET(UBERJAR_PREFIX_FLAG ${pre=--shade-prefix :Arg})
  3853. }
  3854. # tag:java-specific
  3855. UBERJAR_HIDE_EXCLUDE_VALUE=
  3856. UBERJAR_HIDE_EXCLUDE_FLAGS=
  3857. ### @usage: UBERJAR_HIDE_EXCLUDE_PATTERN(Args...)
  3858. ###
  3859. ### Exculude classes matching this patterns from shading (if enabled).
  3860. ### Pattern may contain '*' and '**' globs.
  3861. ### Shading is enabled for UBERJAR program using UBERJAR_HIDING_PREFIX macro. If this macro is not specified all classes are shaded.
  3862. ###
  3863. ### @see: [UBERJAR](#macro_UBERJAR), [UBERJAR_HIDING_PREFIX](#macro_UBERJAR_HIDING_PREFIX)
  3864. macro UBERJAR_HIDE_EXCLUDE_PATTERN(Args...) {
  3865. SET_APPEND(UBERJAR_HIDE_EXCLUDE_VALUE $ARGS_DELIM $Args)
  3866. SET_APPEND(UBERJAR_HIDE_EXCLUDE_FLAGS ${pre=--shade-exclude :Args})
  3867. }
  3868. # tag:java-specific
  3869. UBERJAR_PATH_EXCLUDES=
  3870. UBERJAR_PATH_EXCLUDE_VALUE=
  3871. ### @usage: UBERJAR_PATH_EXCLUDE_PREFIX(Args...)
  3872. ###
  3873. ### Exculude classes matching this patterns from UBERJAR.
  3874. ### By default all dependencies of UBERJAR program will lend in a .jar archive.
  3875. ###
  3876. ### @see: [UBERJAR](#macro_UBERJAR)
  3877. macro UBERJAR_PATH_EXCLUDE_PREFIX(Args...) {
  3878. SET_APPEND(UBERJAR_PATH_EXCLUDE_VALUE $ARGS_DELIM $Args)
  3879. SET_APPEND(UBERJAR_PATH_EXCLUDES ${pre=--uber-exclude :Args})
  3880. }
  3881. # tag:java-specific
  3882. UBERJAR_MANIFEST_TRANSFORMER_MAIN_VALUE=
  3883. UBERJAR_MANIFEST_TRANSFORMER_MAIN_FLAG=
  3884. ### @usage: UBERJAR_MANIFEST_TRANSFORMER_MAIN(Main)
  3885. ###
  3886. ### Transform manifest.mf for UBERJAR() java programs, set main-class attribute
  3887. ###
  3888. ### @see: [UBERJAR](#macro_UBERJAR)
  3889. macro UBERJAR_MANIFEST_TRANSFORMER_MAIN(Main) {
  3890. SET(UBERJAR_MANIFEST_TRANSFORMER_MAIN_VALUE $Main)
  3891. SET(UBERJAR_MANIFEST_TRANSFORMER_MAIN_FLAG --manifest-main $Main)
  3892. }
  3893. # tag:java-specific
  3894. UBERJAR_MANIFEST_TRANSFORMER_ATTRIBUTE_VALUE=
  3895. UBERJAR_MANIFEST_TRANSFORMER_ATTRIBUTE_FLAGS=
  3896. ### @usage: UBERJAR_MANIFEST_TRANSFORMER_ATTRIBUTE(Key, Value)
  3897. ###
  3898. ### Transform manifest.mf for UBERJAR() java programs, set attribute
  3899. ###
  3900. ### @see: [UBERJAR](#macro_UBERJAR)
  3901. macro UBERJAR_MANIFEST_TRANSFORMER_ATTRIBUTE(Key, Value) {
  3902. SET_APPEND(UBERJAR_MANIFEST_TRANSFORMER_ATTRIBUTE_VALUE $ARGS_DELIM $Key : $Value)
  3903. SET_APPEND(UBERJAR_MANIFEST_TRANSFORMER_ATTRIBUTE_FLAGS --manifest-attribute ${Key}:${Value})
  3904. }
  3905. # tag:java-specific
  3906. UBERJAR_APPENDING_TRANSFORMER_VALUE=
  3907. UBERJAR_APPENDING_TRANSFORMER_FLAGS=
  3908. ### @usage: UBERJAR_APPENDING_TRANSFORMER(Resource)
  3909. ###
  3910. ### Add AppendingTransformer for UBERJAR() java programs
  3911. ###
  3912. ### Parameters:
  3913. ### - Resource - Resource name
  3914. ###
  3915. ### @see: [UBERJAR](#macro_UBERJAR)
  3916. macro UBERJAR_APPENDING_TRANSFORMER(Resources...) {
  3917. SET_APPEND(UBERJAR_APPENDING_TRANSFORMER_VALUE $ARGS_DELIM $Resources)
  3918. SET_APPEND(UBERJAR_APPENDING_TRANSFORMER_FLAGS ${pre=--append-transformer :Resources})
  3919. }
  3920. # tag:java-specific
  3921. UBERJAR_SERVICES_RESOURCE_TRANSFORMER_VALUE=
  3922. UBERJAR_SERVICES_RESOURCE_TRANSFORMER_FLAG=
  3923. ### @usage: UBERJAR_SERVICES_RESOURCE_TRANSFORMER()
  3924. ###
  3925. ### Add ServicesResourceTransformer for UBERJAR() java programs
  3926. ###
  3927. ### @see: [UBERJAR](#macro_UBERJAR)
  3928. macro UBERJAR_SERVICES_RESOURCE_TRANSFORMER() {
  3929. SET(UBERJAR_SERVICES_RESOURCE_TRANSFORMER_VALUE yes)
  3930. SET(UBERJAR_SERVICES_RESOURCE_TRANSFORMER_FLAG --service-transformer)
  3931. }
  3932. # tag:idea-specific
  3933. IDEA_EXCLUDE_DIRS_VALUE=
  3934. ### @usage: IDEA_EXCLUDE_DIRS(<excluded dirs>)
  3935. ###
  3936. ### Exclude specified directories from an idea project generated by ya ide idea
  3937. ### Have no effect on regular build.
  3938. macro IDEA_EXCLUDE_DIRS(Args...) {
  3939. SET_APPEND(IDEA_EXCLUDE_DIRS_VALUE $Args)
  3940. }
  3941. # tag:idea-specific
  3942. IDEA_RESOURCE_DIRS_VALUE=
  3943. ### @usage: IDEA_RESOURCE_DIRS(<additional dirs>)
  3944. ###
  3945. ### Set specified resource directories in an idea project generated by ya ide idea
  3946. ### Have no effect on regular build.
  3947. macro IDEA_RESOURCE_DIRS(Args...) {
  3948. SET_APPEND(IDEA_RESOURCE_DIRS_VALUE $Args)
  3949. }
  3950. # tag:idea-specific
  3951. IDEA_MODULE_NAME_VALUE=
  3952. ### @usage: IDEA_MODULE_NAME(module_name)
  3953. ###
  3954. ### Set module name in an idea project generated by ya ide idea
  3955. ### Have no effect on regular build.
  3956. macro IDEA_MODULE_NAME(Name) {
  3957. SET(IDEA_MODULE_NAME_VALUE $Name)
  3958. }
  3959. # tag:java-specific
  3960. JAVAC_FLAGS_VALUE=
  3961. ### @usage: JAVAC_FLAGS(Args...)
  3962. ###
  3963. ### Set additional Java compilation flags.
  3964. macro JAVAC_FLAGS(Args...) {
  3965. SET_APPEND(JAVAC_OPTS $Args)
  3966. SET_APPEND(JAVAC_FLAGS_VALUE $ARGS_DELIM $Args)
  3967. }
  3968. # tag:java-specific
  3969. ENABLE_PREVIEW_VALUE=
  3970. ### @usage: ENABLE_PREVIEW()
  3971. ###
  3972. ### Enable java preview features.
  3973. macro ENABLE_PREVIEW() {
  3974. SET_APPEND(JVM_ARGS_VALUE --enable-preview)
  3975. SET_APPEND(JAVAC_OPTS --enable-preview --release $JDK_REAL_VERSION)
  3976. SET_APPEND(JAVAC_FLAGS_VALUE --enable-preview --release $JDK_REAL_VERSION)
  3977. SET(ENABLE_PREVIEW_VALUE yes)
  3978. }
  3979. # tag:java-specific
  3980. SAVE_JAVAC_GENERATED_SRCS=
  3981. SAVE_JAVAC_GENERATED_SRCS_DIR=
  3982. SAVE_JAVAC_GENERATED_SRCS_TAR=
  3983. when ($SAVE_JAVAC_GENERATED_SRCS) {
  3984. SAVE_JAVAC_GENERATED_SRCS_DIR=${BINDIR}/__javac_generated_srcs__
  3985. SAVE_JAVAC_GENERATED_SRCS_TAR=${BINDIR}/javac_generated.tar
  3986. JAVAC_FLAGS_VALUE+=-s $SAVE_JAVAC_GENERATED_SRCS_DIR
  3987. }
  3988. # tag:java-specific
  3989. MAVEN_GROUP_ID_VALUE=
  3990. ### @usage: MAVEN_GROUP_ID(group_id_for_maven_export)
  3991. ###
  3992. ### Set maven export group id for JAVA_PROGRAM() and JAVA_LIBRARY().
  3993. ### Have no effect on regular build.
  3994. macro MAVEN_GROUP_ID(Arg) {
  3995. SET(MAVEN_GROUP_ID_VALUE $Arg)
  3996. }
  3997. # tag:java-specific
  3998. ANNOTATION_PROCESSOR_VALUE=
  3999. ### @usage: ANNOTATION_PROCESSOR(processors...)
  4000. ###
  4001. ### The macro is in development.
  4002. ### Used to specify annotation processors to build JAVA_PROGRAM() and JAVA_LIBRARY().
  4003. macro ANNOTATION_PROCESSOR(Args...) {
  4004. SET_APPEND(ANNOTATION_PROCESSOR_VALUE $ARGS_DELIM $Args)
  4005. }
  4006. EXCLUDE_VALUE=
  4007. ### EXCLUDE(prefixes)
  4008. ###
  4009. ### The macro is in development.
  4010. ### Specifies which libraries should be excluded from the classpath.
  4011. macro EXCLUDE(Args...) {
  4012. SET_APPEND(EXCLUDE_VALUE $ARGS_DELIM $Args)
  4013. }
  4014. # tag:java-specific
  4015. JAVA_SRCS_VALUE=
  4016. ### @usage: JAVA_SRCS(srcs)
  4017. ###
  4018. ### Specify java source files and resources. A macro can be contained in any of four java modules.
  4019. ### Keywords:
  4020. ### 1. X SRCDIR - specify the directory x is performed relatively to search the source code for these patterns. If there is no SRCDIR, the source will be searched relative to the module directory.
  4021. ### 2. PACKAGE_PREFIX x - use if source paths relative to the SRCDIR does not coincide with the full class names. For example, if all sources of module are in the same package, you can create a directory package/name , and just put the source code in the SRCDIR and specify PACKAGE_PREFIX package.name.
  4022. ###
  4023. ### @example:
  4024. ### - example/ya.make
  4025. ###
  4026. ### JAVA_PROGRAM()
  4027. ### JAVA_SRCS(SRCDIR src/main/java **/*)
  4028. ### END()
  4029. ###
  4030. ### - example/src/main/java/ru/yandex/example/HelloWorld.java
  4031. ###
  4032. ### package ru.yandex.example;
  4033. ### public class HelloWorld {
  4034. ### public static void main(String[] args) {
  4035. ### System.out.println("Hello, World!");
  4036. ### }
  4037. ### }
  4038. ###
  4039. ### Documentation: https://wiki.yandex-team.ru/yatool/java/#javasrcs
  4040. macro JAVA_SRCS(Args...) {
  4041. SET_APPEND(JAVA_SRCS_VALUE $ARGS_DELIM $Args)
  4042. }
  4043. # tag:java-specific
  4044. JAVA_ADD_DLLS_VALUE=no
  4045. macro ADD_DLLS_TO_JAR() {
  4046. SET(JAVA_ADD_DLLS_VALUE yes)
  4047. }
  4048. # tag:java-specific
  4049. MANAGED_PEERS=
  4050. MANAGED_PEERS_CLOSURE=
  4051. RUN_JAVA_PROGRAM_MANAGED=
  4052. MANAGEABLE_PEERS_ROOTS=contrib/java
  4053. HAS_MANAGEABLE_PEERS=no
  4054. PROPAGATES_MANAGEABLE_PEERS=no
  4055. YMAKE_CLASSPATH_CHECKS=yes
  4056. # All items of this list must be PEERS, GHOST PEERS or TOOLS of the test module or module itself.
  4057. # All items of this list must has at least one of HAS_MANAGEABLE_PEERS or PROPAGATES_MANAGEABLE_PEERS flags set yes.
  4058. # This variable is used by JUnit tests but not TestNG.
  4059. TEST_CLASSPATH_VALUE=
  4060. # Calculated and replaced by ymake can be used in DART DATA
  4061. TEST_CLASSPATH_MANAGED=
  4062. # tag:java-specific
  4063. DEPENDENCY_MANAGEMENT_VALUE=
  4064. ### @usage: DEPENDENCY_MANAGEMENT(path/to/lib1 path/to/lib2 ...)
  4065. ###
  4066. ### Lock version of the library from the contrib/java at some point, so that all unversioned PEERDIRs to this library refer to the specified version.
  4067. ###
  4068. ### For example, if the moduse has PEERDIR (contrib/java/junit/junit), and
  4069. ### 1. specifies DEPENDENCY_MANAGEMENT(contrib/java/junit/junit/4.12),
  4070. ### the PEERDIR is automatically replaced by contrib/java/junit/junit/4.12;
  4071. ### 2. doesn't specify DEPENDENCY_MANAGEMENT, PEERDIR automatically replaced
  4072. ### with the default from contrib/java/junit/junit/ya.make.
  4073. ### These defaults are always there and are supported by maven-import, which puts
  4074. ### there the maximum version available in contrib/java.
  4075. ###
  4076. ### The property is transitive. That is, if module A PEERDIRs module B, and B has PEERDIR(contrib/java/junit/junit), and this junit was replaced by junit-4.12, then junit-4.12 will come to A through B.
  4077. ###
  4078. ### If some module has both DEPENDENCY_MANAGEMENT(contrib/java/junit/junit/4.12) and PERDIR(contrib/java/junit/junit/4.11), the PEERDIR wins.
  4079. ###
  4080. ### Documentation: https://wiki.yandex-team.ru/yatool/java/
  4081. macro DEPENDENCY_MANAGEMENT(Args...) {
  4082. SET_APPEND(DEPENDENCY_MANAGEMENT_VALUE $ARGS_DELIM $Args)
  4083. _GHOST_PEERDIR($Args)
  4084. }
  4085. # tag:java-specific
  4086. WITH_JDK_VALUE=
  4087. ### @usage: WITH_JDK()
  4088. ###
  4089. ### Add directory with JDK to JAVA_PROGRAM output
  4090. macro WITH_JDK() {
  4091. SET(WITH_JDK_VALUE yes)
  4092. }
  4093. # tag:kotlin-specific
  4094. WITH_KOTLIN_VALUE=
  4095. ### @usage: WITH_KOTLIN()
  4096. ###
  4097. ### Compile kotlin source code in this java module
  4098. macro WITH_KOTLIN() {
  4099. SET(WITH_KOTLIN_VALUE yes)
  4100. }
  4101. # tag:java-specific
  4102. WITH_GROOVY_VALUE=
  4103. ### @usage: WITH_GROOVY()
  4104. ###
  4105. ### Compile groovy source code in this java module
  4106. macro WITH_GROOVY() {
  4107. SET(WITH_GROOVY_VALUE yes)
  4108. }
  4109. # tag:kotlin-specific
  4110. KOTLINC_FLAGS_VALUE=-Xjvm-default=all
  4111. ### @usage: KOTLINC_FLAGS(-flags)
  4112. ###
  4113. ### Set additional Kotlin compilation flags.
  4114. macro KOTLINC_FLAGS(Args...) {
  4115. SET_APPEND(KOTLINC_OPTS_VALUE $Args)
  4116. }
  4117. # tag:kotlin-specific
  4118. WITH_KOTLINC_PLUGIN_ALLOPEN=
  4119. ### @usage: WITH_KOTLINC_ALLOPEN(-flags)
  4120. ###
  4121. ### Enable allopen kotlin compiler plugin https://kotlinlang.org/docs/all-open-plugin.html
  4122. macro WITH_KOTLINC_ALLOPEN(Options...) {
  4123. SET_APPEND(KOTLINC_OPTS_VALUE ${pre=-P plugin\:org.jetbrains.kotlin.allopen\::Options})
  4124. SET(WITH_KOTLINC_PLUGIN_ALLOPEN yes)
  4125. }
  4126. # tag:kotlin-specific
  4127. WITH_KOTLINC_PLUGIN_NOARG=
  4128. ### @usage: WITH_KOTLINC_NOARG(-flags)
  4129. ###
  4130. ### Enable noarg kotlin compiler plugin https://kotlinlang.org/docs/no-arg-plugin.html
  4131. macro WITH_KOTLINC_NOARG(Options...) {
  4132. SET_APPEND(KOTLINC_OPTS_VALUE ${pre=-P plugin\:org.jetbrains.kotlin.noarg\::Options})
  4133. SET(WITH_KOTLINC_PLUGIN_NOARG yes)
  4134. }
  4135. # tag:kotlin-specific
  4136. KOTLIN_VERSION=1.6.10
  4137. KOTLIN_BOM_FILE=${ARCADIA_ROOT}/contrib/java/org/jetbrains/kotlin/kotlin-bom/1.6.10/ya.dependency_management.inc
  4138. GROOVY_VERSION=3.0.5
  4139. # tag:java-specific
  4140. DIRECT_DEPS_ONLY_VALUE=
  4141. ### @usage: DIRECT_DEPS_ONLY
  4142. ###
  4143. ### Add direct PEERDIR's only in java compile classpath
  4144. macro DIRECT_DEPS_ONLY() {
  4145. SET(DIRECT_DEPS_ONLY_VALUE yes)
  4146. }
  4147. # tag:java-specific
  4148. JAVA_EXTERNAL_DEPENDENCIES_VALUE=
  4149. ### @usage: JAVA_EXTERNAL_DEPENDENCIES(file1 file2 ...)
  4150. ###
  4151. ### Add non-source java external build dependency (like lombok config file)
  4152. macro JAVA_EXTERNAL_DEPENDENCIES(Args...) {
  4153. SET_APPEND(JAVA_EXTERNAL_DEPENDENCIES_VALUE $Args)
  4154. }
  4155. # tag:java-specific
  4156. ### @usage _JAVA_PLACEHOLDER #internal
  4157. ### The base module for all Java modules. Defines common properties and dependencies.
  4158. module _JAVA_PLACEHOLDER: _BASE_UNIT {
  4159. .CMD=TOUCH_JAVA_UNIT
  4160. .FINAL_TARGET=yes
  4161. .ALLOWED=DEPENDENCY_MANAGEMENT EXCLUDE
  4162. .ALIASES=RUN_JAVA_PROGRAM=_RUN_JBUILD_PROGRAM
  4163. HAS_MANAGEABLE_PEERS=yes
  4164. DYNAMIC_LINK=yes
  4165. PEERDIR_TAGS=JAVA_PROTO JAVA_FBS JAVA_IDL JAR_COMPILATION
  4166. PEERDIR(build/platform/java/jdk)
  4167. PEERDIR+=$JDK_RESOURCE_PEERDIR
  4168. when($MAKE_UBERJAR_VALUE) {
  4169. PEERDIR+=build/platform/java/uberjar
  4170. PEERDIR+=$UBERJAR_RESOURCE_PEERDIR
  4171. }
  4172. when($ERROR_PRONE_VALUE) {
  4173. # Jbuild assumes hardcoded resource name https://a.yandex-team.ru/arc_vcs/devtools/ya/jbuild/gen/consts/__init__.py?rev=1739368ed5aaa585b8300b84e5dea708a2bedd3a#L130
  4174. # adding default peerdir as a hack to make `ya ide idea` and `ya maven-export` work for now
  4175. PEERDIR+=build/platform/java/error_prone
  4176. PEERDIR+=$ERROR_PRONE_PEERDIR
  4177. }
  4178. # in the ideal world this statement must be under condition bellow
  4179. DEPENDENCY_MANAGEMENT(contrib/java/org/jetbrains/kotlin/kotlin-stdlib-jdk8/${KOTLIN_VERSION})
  4180. when($WITH_KOTLIN_VALUE) {
  4181. PEERDIR+=build/platform/java/kotlin contrib/java/org/jetbrains/kotlin/kotlin-stdlib-jdk8
  4182. when($WITH_KOTLINC_PLUGIN_ALLOPEN) {
  4183. KOTLINC_OPTS_VALUE+=-Xplugin=${KOTLIN_COMPILER_RESOURCE_GLOBAL}/plugins/kotlin-allopen-plugin.jar
  4184. }
  4185. when($WITH_KOTLINC_PLUGIN_NOARG) {
  4186. KOTLINC_OPTS_VALUE+=-Xplugin=${KOTLIN_COMPILER_RESOURCE_GLOBAL}/plugins/kotlin-noarg-plugin.jar
  4187. }
  4188. }
  4189. when($WITH_GROOVY_VALUE) {
  4190. PEERDIR+=build/platform/java/groovy contrib/java/org/codehaus/groovy/groovy/${GROOVY_VERSION}
  4191. }
  4192. when($ERROR_PRONE_VALUE && $JDK_REAL_VERSION == "16") {
  4193. JAVAC_FLAGS_VALUE+=$ERROR_PRONE_JDK16_ADD_OPENS
  4194. }
  4195. when($ERROR_PRONE_VALUE && $ERROR_PRONE_VERSION == "2.7.1") {
  4196. JAVAC_FLAGS_VALUE+=$ERROR_PRONE_2_7_1_FORCED_OPTS
  4197. }
  4198. JAVA_DEPENDENCIES_CONFIGURATION(FORBID_DEFAULT_VERSIONS)
  4199. DISABLE(NEED_PLATFORM_PEERDIRS)
  4200. NO_PLATFORM()
  4201. JAVA_MODULE()
  4202. # flatbuffers-java
  4203. DEPENDENCY_MANAGEMENT(contrib/java/com/google/flatbuffers/flatbuffers-java/${JAVA_FLATBUFFERS_VERSION})
  4204. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/com/google/flatbuffers/flatbuffers-java EXCEPT contrib/java/com/google/flatbuffers/flatbuffers-java/${JAVA_FLATBUFFERS_VERSION})
  4205. # protobuf-java
  4206. DEPENDENCY_MANAGEMENT(contrib/java/com/google/protobuf/protobuf-java/${JAVA_PROTO_RUNTIME_VERSION})
  4207. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/com/google/protobuf/protobuf-java EXCEPT contrib/java/com/google/protobuf/protobuf-java/${JAVA_PROTO_RUNTIME_VERSION})
  4208. # protobuf-javalite
  4209. DEPENDENCY_MANAGEMENT(contrib/java/com/google/protobuf/protobuf-javalite/${JAVA_PROTO_RUNTIME_VERSION})
  4210. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/com/google/protobuf/protobuf-javalite EXCEPT contrib/java/com/google/protobuf/protobuf-javalite/${JAVA_PROTO_RUNTIME_VERSION})
  4211. # protobuf-java-util
  4212. DEPENDENCY_MANAGEMENT(contrib/java/com/google/protobuf/protobuf-java-util/${JAVA_PROTO_RUNTIME_VERSION})
  4213. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/com/google/protobuf/protobuf-java-util EXCEPT contrib/java/com/google/protobuf/protobuf-java-util/${JAVA_PROTO_RUNTIME_VERSION})
  4214. SET(MODULE_LANG JAVA)
  4215. }
  4216. # tag:java-specific
  4217. JAVA_CLASSPATH_CMD_TYPE_VALUE=
  4218. # tag:java-specific
  4219. ### @usage:TEST_JAVA_CLASSPATH_CMD_TYPE(Type)
  4220. ### Availible types: MANIFEST(default), COMMAND_FILE, LIST
  4221. ### Method for passing a classpath value to a java command line
  4222. ### MANIFEST via empty jar file with manifest that cantains Class-Path attribute
  4223. ### COMMAND_FILE via @command_file
  4224. ### LIST via flat args
  4225. macro TEST_JAVA_CLASSPATH_CMD_TYPE(Type) {
  4226. SET(JAVA_CLASSPATH_CMD_TYPE_VALUE $Type)
  4227. }
  4228. # tag:java-specific
  4229. IGNORE_JAVA_DEPENDENCIES_CONFIGURATION=no
  4230. JAVA_DEPENDENCIES_CONFIGURATION_VALUE=
  4231. # tag:java-specific
  4232. ### @usage JAVA_DEPENDENCIES_CONFIGURATION(Vetos...)
  4233. ### Validate contrib/java dependencies
  4234. ### Valid arguments
  4235. ### FORBID_DIRECT_PEERDIRS - fail when module have direct PEERDIR (with version) (non-transitive)
  4236. ### FORBID_DEFAULT_VERSIONS - fail when module have PEERDIR to library with default (last) version (transitive)
  4237. ### FORBID_CONFLICT - fail when module have resolved without DEPENDENCY_MANAGEMENT version conflict (transitive)
  4238. ### FORBID_CONFLICT_DM - fail when module have resolved with DEPENDENCY_MANAGEMENT version conflict (transitive)
  4239. ### FORBID_CONFLICT_DM_RECENT - like FORBID_CONFLICT_DM but fail only when dependency have more recent version than specified in DEPENDENCY_MANAGEMENT
  4240. ### REQUIRE_DM - all dependencies must be specified in DEPENDENCY_MANAGEMENT (transitive)
  4241. macro JAVA_DEPENDENCIES_CONFIGURATION(Args...) {
  4242. SET_APPEND(JAVA_DEPENDENCIES_CONFIGURATION_VALUE $Args)
  4243. }
  4244. # tag:java-specific
  4245. # TODO(DEVTOOLS-6901): remove this variable when there are no more references to it in jbuild
  4246. JAVA_FORBIDDEN_LIBRARIES_VALUE=
  4247. # tag:java-specific
  4248. JAR_INCLUDE_FILTER_VALUE=
  4249. JAR_EXCLUDE_FILTER_VALUE=
  4250. # tag:java-specific
  4251. ### @usage:JAR_INCLUDE(Filters...)
  4252. ### Filter .jar file content: keep only matched files
  4253. ### * and ** patterns are supported (like JAVA_SRCS)
  4254. macro JAR_INCLUDE(Filters...) {
  4255. SET_APPEND(JAR_INCLUDE_FILTER_VALUE $Filters)
  4256. }
  4257. # tag:java-specific
  4258. ### @usage:JAR_EXCLUDE(Filters...)
  4259. ### Filter .jar file content: remove matched files
  4260. ### * and ** patterns are supported (like JAVA_SRCS)
  4261. macro JAR_EXCLUDE(Filters...) {
  4262. SET_APPEND(JAR_EXCLUDE_FILTER_VALUE $Filters)
  4263. }
  4264. # tag:sandbox-specific
  4265. ### @usage: SANDBOX_TASK([Name])
  4266. ###
  4267. ### Multimodule describing Sandbox task (Python code that can be executed by Sandbox system).
  4268. ###
  4269. ### When being a final target, this multimodule builds Sandbox binary task. It may PEERDIR other SANDBOX_TASKs as libraries.
  4270. ### The final artifact is provided when SANDBOX_TASK is referred to by DEPENDS and BUNDLE macros.
  4271. ### As PEERDIR target, it works like regular PY2_LIBRARY with predefined dependencies on Sandbox SDK to allow code reuse among SANDBOX_TASKs.
  4272. ###
  4273. ### Currently Sandbox supports only Python 2.x, so both variants will be compatible only with Python 2.x modules
  4274. ### and will select multimodule variants accordingly.
  4275. ###
  4276. ### Documentation: https://wiki.yandex-team.ru/sandbox/tasks/binary
  4277. multimodule SANDBOX_TASK {
  4278. module SB_TASK_BIN: _PY2_PROGRAM {
  4279. PY_MAIN(sandbox.taskbox.binary)
  4280. PEERDIR(sandbox/bin sandbox/sdk2 sandbox/sandboxsdk sandbox/taskbox/worker)
  4281. SET_APPEND(NO_CHECK_IMPORTS_FOR_VALUE api.*)
  4282. SET_APPEND(NO_CHECK_IMPORTS_FOR_VALUE kernel.*)
  4283. SET_APPEND(NO_CHECK_IMPORTS_FOR_VALUE library.*)
  4284. SET_APPEND(NO_CHECK_IMPORTS_FOR_VALUE sky*)
  4285. REGISTER_SANDBOX_IMPORT(${MODDIR})
  4286. when ($FAIL_PY2 == "yes") {
  4287. _OK=no
  4288. }
  4289. otherwise {
  4290. PEERDIR+=build/rules/py2_deprecation
  4291. }
  4292. ASSERT(_OK You are using deprecated Python2-only code (SANDBOX_TASK). Please consider rewriting to 2/3-compatible code.)
  4293. }
  4294. module PY2: PY2_LIBRARY {
  4295. PEERDIR(sandbox/sdk2 sandbox/sandboxsdk)
  4296. REGISTER_SANDBOX_IMPORT(${MODDIR})
  4297. }
  4298. }
  4299. # tag:sandbox-specific
  4300. multimodule SANDBOX_PY23_TASK {
  4301. module SB_TASK_BIN: _PY2_PROGRAM {
  4302. PY_MAIN(sandbox.taskbox.binary)
  4303. PEERDIR(sandbox/bin sandbox/sdk2 sandbox/sandboxsdk sandbox/taskbox/worker)
  4304. SET_APPEND(NO_CHECK_IMPORTS_FOR_VALUE api.*)
  4305. SET_APPEND(NO_CHECK_IMPORTS_FOR_VALUE kernel.*)
  4306. SET_APPEND(NO_CHECK_IMPORTS_FOR_VALUE library.*)
  4307. SET_APPEND(NO_CHECK_IMPORTS_FOR_VALUE sky*)
  4308. REGISTER_SANDBOX_IMPORT(${MODDIR})
  4309. }
  4310. module PY2: PY2_LIBRARY {
  4311. PEERDIR(sandbox/sdk2 sandbox/sandboxsdk)
  4312. REGISTER_SANDBOX_IMPORT(${MODDIR})
  4313. OBJ_SUF=.py2
  4314. RUN_CYTHON_SCRIPT=$YMAKE_PYTHON $CYTHON_SCRIPT
  4315. }
  4316. module PY3: PY3_LIBRARY {
  4317. when ($MSVC == "yes" || $CYGWIN == "yes") {
  4318. MODULE_PREFIX=py3
  4319. }
  4320. otherwise {
  4321. MODULE_PREFIX=libpy3
  4322. }
  4323. OBJ_SUF=.py3
  4324. RUN_CYTHON_SCRIPT=$YMAKE_PYTHON $CYTHON_SCRIPT
  4325. PEERDIR(sandbox/sdk2)
  4326. REGISTER_SANDBOX_IMPORT(${MODDIR})
  4327. }
  4328. }
  4329. # tag:sandbox-specific
  4330. ### @usage: SANDBOX_PY3_TASK([Name])
  4331. ###
  4332. ### Multimodule describing Sandbox task (Python3 code that can be executed by Sandbox system).
  4333. ###
  4334. ### When being a final target, this multimodule builds Sandbox binary task. It may PEERDIR other SANDBOX_PY3_TASKs as libraries.
  4335. ### The final artifact is provided when SANDBOX_PY3_TASK is referred to by DEPENDS and BUNDLE macros.
  4336. ### As PEERDIR target, it works like regular PY3_LIBRARY with predefined dependencies on Sandbox SDK to allow code reuse among SANDBOX_PY3_TASKs.
  4337. ###
  4338. ### Currently Sandbox supports Python 3.x only in binary tasks, both variants will be compatible only with Python 3.x and py23 libraries
  4339. ### and will select multimodule variants accordingly.
  4340. ###
  4341. ### Documentation: https://wiki.yandex-team.ru/sandbox/tasks/binary
  4342. multimodule SANDBOX_PY3_TASK {
  4343. module SB_TASK_BIN: PY3_PROGRAM_BIN {
  4344. PY_MAIN(sandbox.taskbox.binary)
  4345. PEERDIR(sandbox/bin sandbox/sdk2 sandbox/taskbox/worker)
  4346. SET_APPEND(NO_CHECK_IMPORTS_FOR_VALUE api.*)
  4347. SET_APPEND(NO_CHECK_IMPORTS_FOR_VALUE kernel.*)
  4348. SET_APPEND(NO_CHECK_IMPORTS_FOR_VALUE library.*)
  4349. SET_APPEND(NO_CHECK_IMPORTS_FOR_VALUE sky*)
  4350. REGISTER_SANDBOX_IMPORT(${MODDIR})
  4351. }
  4352. module PY3: PY3_LIBRARY {
  4353. PEERDIR(sandbox/sdk2)
  4354. REGISTER_SANDBOX_IMPORT(${MODDIR})
  4355. }
  4356. }
  4357. # tag:python-specific tag:internal
  4358. NO_PYTHON_INCLS=no
  4359. ### @usage: NO_PYTHON_INCLUDES() # internal
  4360. ###
  4361. ### Disable dependencies on libraries providing Python headers.
  4362. ### This is only used in Python libraries themselves to avoid PEERDIR loops.
  4363. macro NO_PYTHON_INCLUDES() {
  4364. ENABLE(NO_PYTHON_INCLS)
  4365. }
  4366. # tag:python-specific
  4367. ### @usage: PYTHON2_ADDINCL()
  4368. ###
  4369. ### This macro adds include path for Python headers (Python 2.x variant) without PEERDIR.
  4370. ### This should be used in 2 cases only:
  4371. ### - In PY2MODULE since it compiles into .so and uses external Python runtime;
  4372. ### - In system Python libraries themselves since proper PEERDIR there may create a loop;
  4373. ### In all other cases use USE_PYTHON2 macro instead.
  4374. ###
  4375. ### Never use this macro in PY2_PROGRAM, PY2_LIBRARY and PY23_LIBRARY: they have everything needed by default.
  4376. ###
  4377. ### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/py_srcs
  4378. macro PYTHON2_ADDINCL() {
  4379. _PYTHON_ADDINCL()
  4380. SET(MODULE_TAG PY2_NATIVE)
  4381. SET(PEERDIR_TAGS CPP_PROTO CPP_FBS PY2_NATIVE YQL_UDF_STATIC __EMPTY__ DLL_LIB)
  4382. }
  4383. # tag:python-specific tag:internal
  4384. ### @usage: _ARCADIA_PYTHON_ADDINCL() # internal
  4385. ### This macro sets up Python headers for modules with Arcadia python (e.g. PY2_LIBRARY) and configures module as Python 2.x.
  4386. macro _ARCADIA_PYTHON_ADDINCL() {
  4387. _PYTHON_ADDINCL()
  4388. SET(MODULE_TAG PY2)
  4389. SET(PEERDIR_TAGS PY2 PY2_NATIVE PY_PROTO PY2_FBS YQL_UDF_STATIC __EMPTY__ DLL_LIB)
  4390. }
  4391. # tag:python-specific tag:internal
  4392. ### @usage: _PYTHON_ADDINCL() # internal
  4393. ### This macro sets up Python 2.x headers for both Arcadia and non-Arcadia python.
  4394. macro _PYTHON_ADDINCL() {
  4395. SET(PYTHON2 yes)
  4396. SET(PYTHON3 no)
  4397. when ($USE_ARCADIA_PYTHON == "yes") {
  4398. ADDINCL+=GLOBAL contrib/libs/python/Include
  4399. CFLAGS+=-DARCADIA_PYTHON_UNICODE_SIZE=$ARCADIA_PYTHON_UNICODE_SIZE
  4400. }
  4401. otherwise {
  4402. when ($USE_SYSTEM_PYTHON) {
  4403. PEERDIR+=build/platform/python
  4404. }
  4405. otherwise {
  4406. CFLAGS+=$PYTHON_INCLUDE
  4407. }
  4408. }
  4409. }
  4410. # tag:python-specific
  4411. ### @usage: PYTHON3_ADDINCL()
  4412. ###
  4413. ### This macro adds include path for Python headers (Python 3.x variant).
  4414. ### This should be used in 2 cases only:
  4415. ### - In PY2MODULE since it compiles into .so and uses external Python runtime;
  4416. ### - In system Python libraries themselves since peerdir there may create a loop;
  4417. ### In all other cases use USE_PYTHON3() macro instead.
  4418. ###
  4419. ### Never use this macro in PY3_PROGRAM and PY3_LIBRARY and PY23_LIBRARY: they have everything by default.
  4420. ###
  4421. ### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/py_srcs
  4422. macro PYTHON3_ADDINCL() {
  4423. _PYTHON3_ADDINCL()
  4424. SET(MODULE_TAG PY3_NATIVE)
  4425. SET(PEERDIR_TAGS CPP_PROTO CPP_FBS PY3_NATIVE YQL_UDF_STATIC __EMPTY__ DLL_LIB)
  4426. }
  4427. # tag:python-specific tag:internal
  4428. ### @usage: _ARCADIA_PYTHON3_ADDINCL() # internal
  4429. ###
  4430. ### This macro sets up Python3 headers for modules with Arcadia python (e.g. PY3_LIBRARY) and configures module as Python 3.x.
  4431. macro _ARCADIA_PYTHON3_ADDINCL() {
  4432. _PYTHON3_ADDINCL()
  4433. SET(MODULE_TAG PY3)
  4434. SET(MODULE_LANG PY3)
  4435. SET(PEERDIR_TAGS PY3 PY3_BIN_LIB PY3TEST_LIBRARY PY3_NATIVE PY3_PROTO PY3_FBS PY3_SSQLS YQL_UDF_STATIC __EMPTY__ DLL_LIB)
  4436. }
  4437. # tag:python-specific tag:internal
  4438. ### @usage: _PYTHON_ADDINCL() # internal
  4439. ###
  4440. ### This macro sets up Python 3.x headers for both Arcadia and non-Arcadia python.
  4441. macro _PYTHON3_ADDINCL() {
  4442. SET(PYTHON3 yes)
  4443. SET(PYTHON2 no)
  4444. when ($USE_ARCADIA_PYTHON == "yes") {
  4445. CFLAGS+=-DUSE_PYTHON3
  4446. ADDINCL+=GLOBAL contrib/libs/python/Include
  4447. }
  4448. otherwise {
  4449. when ($USE_SYSTEM_PYTHON) {
  4450. PEERDIR+=build/platform/python
  4451. }
  4452. otherwise {
  4453. CFLAGS+=$PYTHON_INCLUDE
  4454. }
  4455. }
  4456. }
  4457. # tag:python-specific
  4458. ### @usage: USE_PYTHON2()
  4459. ###
  4460. ### This adds Python 2.x runtime library to your LIBRARY and makes it Python2-compatible.
  4461. ### Compatibility means proper PEERDIRs, ADDINCLs and variant selection on PEERDIRs to multimodules.
  4462. ###
  4463. ### If you'd like to use #include <Python.h> with Python2 specify USE_PYTHON2 or better make it PY2_LIBRARY.
  4464. ### If you'd like to use #include <Python.h> with Python3 specify USE_PYTHON3 or better make it PY3_LIBRARY.
  4465. ### If you'd like to use #include <Python.h> with both Python2 and Python3 convert your LIBRARY to PY23_LIBRARY.
  4466. ###
  4467. ### @see: [PY2_LIBRARY](#module_PY2_LIBRARY), [PY3_LIBRARY](#module_PY3_LIBRARY), [PY23_LIBRARY](#multimodule_PY23_LIBRARY)
  4468. macro USE_PYTHON2() {
  4469. _ARCADIA_PYTHON_ADDINCL()
  4470. SET(PEERDIR_TAGS PY2 PY2_NATIVE CPP_PROTO CPP_FBS YQL_UDF_STATIC __EMPTY__ DLL_LIB)
  4471. PEERDIR(contrib/libs/python)
  4472. }
  4473. # tag:python-specific
  4474. ### @usage: USE_PYTHON3()
  4475. ###
  4476. ### This adds Python3 library to your LIBRARY and makes it Python3-compatible.
  4477. ### Compatibility means proper PEERDIRs, ADDINCLs and variant selection on PEERDIRs to multimodules.
  4478. ###
  4479. ### If you'd like to use #include <Python.h> with Python3 specify USE_PYTHON3 or better make it PY3_LIBRARY.
  4480. ### If you'd like to use #include <Python.h> with Python2 specify USE_PYTHON2 or better make it PY2_LIBRARY.
  4481. ### If you'd like to use #include <Python.h> with both Python2 and Python3 convert your LIBRARY to PY23_LIBRARY.
  4482. ###
  4483. ### @see: [PY2_LIBRARY](#module_PY2_LIBRARY), [PY3_LIBRARY](#module_PY3_LIBRARY), [PY23_LIBRARY](#multimodule_PY23_LIBRARY)
  4484. macro USE_PYTHON3() {
  4485. _ARCADIA_PYTHON3_ADDINCL()
  4486. SET(PEERDIR_TAGS PY3 PY3_BIN_LIB PY3TEST_LIBRARY PY3_NATIVE CPP_PROTO CPP_FBS YQL_UDF_STATIC __EMPTY__ DLL_LIB)
  4487. PEERDIR(contrib/libs/python)
  4488. when ($USE_ARCADIA_PYTHON == "yes") {
  4489. PEERDIR+=library/python/runtime_py3
  4490. }
  4491. }
  4492. # tag:python-specific
  4493. when ($PERL_DEFAULT_PEERDIR == "yes") {
  4494. when (($PERLXS == "yes") || ($PERLXSCPP == "yes") || ($USE_PERL == "yes")) {
  4495. PEERDIR+=build/platform/perl
  4496. }
  4497. }
  4498. # tag:perl-specific
  4499. ### @usage: USE_PERL_LIB()
  4500. ### Add dependency on Perl to your LIBRARY
  4501. macro USE_PERL_LIB() {
  4502. PEERDIR(build/platform/perl)
  4503. }
  4504. # tag:perl-specific
  4505. ### @usage: USE_PERL_514_LIB()
  4506. ### Add dependency on Perl 5.14 to your LIBRARY
  4507. macro USE_PERL_514_LIB() {
  4508. SET(PERL_SDK ubuntu-12)
  4509. SET(PERL_DEFAULT_PEERDIR no)
  4510. PEERDIR(build/platform/perl/5.14)
  4511. }
  4512. # tag:perl-specific
  4513. ### @usage: ADD_PERL_MODULE(Dir ModuleName)
  4514. ### Add dependency on specified Perl module to the library
  4515. macro ADD_PERL_MODULE(Dir, Module) {
  4516. PEERDIR($Dir)
  4517. SET_APPEND(modules $Module)
  4518. }
  4519. # tag:allocator
  4520. ### @usage: ALLOCATOR(Alloc) # Default: LF
  4521. ###
  4522. ### Set memory allocator implementation for the PROGRAM()/DLL() module.
  4523. ### This may only be specified for programs and dlls, use in other modules leads to configuration errors.
  4524. ###
  4525. ### Available allocators are: "LF", "LF_YT", "LF_DBG", "YT", "J", "B", "BM", "C", "TCMALLOC", "GOOGLE", "LOCKLESS", "SYSTEM", "FAKE", "MIM", "HU".
  4526. ### - LF - lfalloc (https://a.yandex-team.ru/arc/trunk/arcadia/library/cpp/lfalloc)
  4527. ### - LF_YT - Allocator selection for YT (https://a.yandex-team.ru/arc/trunk/arcadia/library/cpp/lfalloc/yt/ya.make)
  4528. ### - LF_DBG - Debug allocator selection (https://a.yandex-team.ru/arc/trunk/arcadia/library/cpp/lfalloc/dbg/ya.make)
  4529. ### - YT - The YTAlloc allocator (https://a.yandex-team.ru/arc/trunk/arcadia/library/cpp/ytalloc/impl/ya.make)
  4530. ### - J - The JEMalloc allocator (https://a.yandex-team.ru/arc/trunk/arcadia/library/malloc/jemalloc)
  4531. ### - B - The balloc allocator named Pyotr Popov and Anton Samokhvalov
  4532. ### - Discussion: https://ironpeter.at.yandex-team.ru/replies.xml?item_no=126
  4533. ### - Code: https://a.yandex-team.ru/arc/trunk/arcadia/library/cpp/balloc
  4534. ### - BM - The balloc for market (agri@ commits from july 2018 till November 2018 saved)
  4535. ### - C - Like B, but can be disabled for each thread to LF or SYSTEM one (B can be disabled only to SYSTEM)
  4536. ### - MIM - Microsoft's mimalloc (actual version) (https://a.yandex-team.ru/arc/trunk/arcadia/library/malloc/mimalloc)
  4537. ### - TCMALLOC - Google TCMalloc (actual version) (https://a.yandex-team.ru/arc/trunk/arcadia/library/malloc/tcmalloc)
  4538. ### - GOOGLE - Google TCMalloc (https://a.yandex-team.ru/arc/trunk/arcadia/library/malloc/galloc)
  4539. ### - LOCKLESS - Allocator based upon lockless queues (https://a.yandex-team.ru/arc/trunk/arcadia/library/malloc/lockless)
  4540. ### - SYSTEM - Use target system allocator
  4541. ### - FAKE - Don't link with any allocator
  4542. ###
  4543. ### More about allocators in Arcadia: https://wiki.yandex-team.ru/arcadia/allocators/
  4544. macro ALLOCATOR(Alloc) {
  4545. SET(ALLOCATOR $Alloc)
  4546. when ($ALLOCATOR in [ "LF", "LF_YT", "LF_DBG", "YT", "J", "B", "BM", "C", "TCMALLOC", "TCMALLOC_SMALL_BUT_SLOW", "TCMALLOC_NUMA_256K", "TCMALLOC_NUMA_LARGE_PAGES", "TCMALLOC_256K", "GOOGLE", "LOCKLESS", "SYSTEM", "FAKE", "MIM", "HU" ]) {
  4547. }
  4548. otherwise {
  4549. PEERDIR+=___configure_error___unknown_allocator_type___$ALLOCATOR
  4550. }
  4551. }
  4552. when ($MIC_ARCH == "yes") {
  4553. CFLAGS+=-mmic
  4554. LDFLAGS+=-mmic
  4555. }
  4556. when ($USE_OPENMP == "yes") {
  4557. PEERDIR+=contrib/libs/openmp
  4558. }
  4559. when ($STRIP == "yes" && $NO_STRIP != "yes") {
  4560. STRIP_FLAG=$LD_STRIP_FLAG
  4561. DWARF_COMMAND=
  4562. GO_LINK_FLAGS_VALUE+=-s
  4563. }
  4564. when ($NO_LINKER_DCE != "yes") {
  4565. DCE_FLAG=$LD_DCE_FLAG
  4566. }
  4567. when ($BT_MINSIZEREL == "yes" || $LINKER_ICF == "yes") {
  4568. ICF_FLAG=$LD_ICF_FLAG
  4569. }
  4570. OBJCOPY_TOOL=$OBJCOPY_TOOL_VENDOR
  4571. STRIP_TOOL=$STRIP_TOOL_VENDOR
  4572. NEED_BINUTILS_PEERDIR=
  4573. BINUTILS_USED=
  4574. when (!$OBJCOPY_TOOL_VENDOR) {
  4575. OBJCOPY_TOOL=$BINUTILS_ROOT_RESOURCE_GLOBAL/bin/objcopy
  4576. NEED_BINUTILS_PEERDIR=yes
  4577. }
  4578. when (!$STRIP_TOOL_VENDOR) {
  4579. STRIP_TOOL=$BINUTILS_ROOT_RESOURCE_GLOBAL/bin/strip
  4580. NEED_BINUTILS_PEERDIR=yes
  4581. }
  4582. SPLIT_DWARF_VALUE=no
  4583. NO_SPLIT_DWARF=no
  4584. when ($STRIP_DEBUG_INFO) {
  4585. SPLIT_DWARF_VALUE=yes
  4586. NO_SPLIT_DWARF=no
  4587. }
  4588. ### @usage: SPLIT_DWARF()
  4589. ###
  4590. ### Emit debug info for the PROGRAM/DLL as a separate file <module_name>.debug.
  4591. ### NB: It does not help you to save process RSS but can add problems (see e.g. BEGEMOT-2147).
  4592. macro SPLIT_DWARF() {
  4593. SET(SPLIT_DWARF_VALUE yes)
  4594. }
  4595. SPLIT_DWARF_OUTPUT=${output;tobindir;pre=$MODULE_PREFIX;suf=$MODULE_SUFFIX.debug:REALPRJNAME}
  4596. when ($SPLIT_DWARF_VALUE == "yes" && $NO_SPLIT_DWARF != "yes" && $NO_DEBUGINFO != "yes" && $HOST_OS_LINUX == "yes" && $TARGET_PLATFORM == "LINUX") {
  4597. DWARF_COMMAND+= \
  4598. $OBJCOPY_TOOL --only-keep-debug $TARGET $SPLIT_DWARF_OUTPUT && \
  4599. $STRIP_TOOL --strip-debug $TARGET && \
  4600. $OBJCOPY_TOOL --remove-section=.gnu_debuglink --add-gnu-debuglink $SPLIT_DWARF_OUTPUT $TARGET
  4601. BINUTILS_USED=yes
  4602. }
  4603. ### @usage: EXTRALIBS_STATIC(Libs...)
  4604. ###
  4605. ### Add the specified external static libraries to the program link
  4606. macro EXTRALIBS_STATIC(Args...) {
  4607. LDFLAGS(-Wl,-Bstatic ${Args} -Wl,-Bdynamic)
  4608. }
  4609. ### @usage ADD_COMPILABLE_TRANSLATE(Dict Name Options...)
  4610. ###
  4611. ### Generate translation dictionary code to transdict.LOWER(Name).cpp that will than be compiled into library
  4612. macro ADD_COMPILABLE_TRANSLATE(Dict, Name, MakeTransDictOptions...) {
  4613. __translatename_lower=${tolower:Name}
  4614. __translate_dict=${BINDIR}/transdict.${__translatename_lower}.cpp
  4615. RUN_PROGRAM(dict/tools/maketransdict -i ${Dict} ${MakeTransDictOptions} ${Name} STDOUT_NOAUTO ${__translate_dict} IN ${Dict})
  4616. }
  4617. ### @usage ADD_COMPILABLE_TRANSLIT(TranslitTable NGrams Name Options...)
  4618. ###
  4619. ### Generate transliteration dictionary code
  4620. ### This will emit both translit, untranslit and ngrams table codes those will be than further compiled into library
  4621. macro ADD_COMPILABLE_TRANSLIT(TranslitTable, NGrams, Name, Options...) {
  4622. __translitname_lower=${tolower:Name}
  4623. __translit_table=${BINDIR}/translit_trie_${__translitname_lower}.cpp
  4624. __untranslit_table=${BINDIR}/untranslit_trie_${__translitname_lower}.cpp
  4625. __ngrams_table=${BINDIR}/ngr_arr_${__translitname_lower}.cpp
  4626. __gentrie_dir=dict/tools/make_untranslit_trie
  4627. RUN_PROGRAM(${__gentrie_dir} -i ${TranslitTable} ${Options} ${__translitname_lower} IN ${TranslitTable} STDOUT ${__untranslit_table})
  4628. RUN_PROGRAM(${__gentrie_dir} -i ${TranslitTable} -n ${Options} ${__translitname_lower} IN ${TranslitTable} STDOUT ${__translit_table})
  4629. RUN_PROGRAM(dict/tools/make_ngrams -i ${NGrams} ${Options} ${__translitname_lower} IN ${NGrams} STDOUT ${__ngrams_table})
  4630. }
  4631. # tag:python-specific tag:proto tag:deprecated
  4632. ### @usage GENERATE_PY_PROTOS(ProtoFiles...) # deprecated
  4633. ###
  4634. ### Generate python bindings for protobuf files.
  4635. ### Macro is obsolete and not recommended for use!
  4636. macro GENERATE_PY_PROTOS(FILES...) {
  4637. foreach (FILE : $FILES) {
  4638. _PY_PROTO_CMD($FILE)
  4639. }
  4640. }
  4641. # tag:python-specific tag:proto
  4642. macro _GENERATE_PY_PROTOS_INTERNAL(FILES...) {
  4643. foreach (FILE : $FILES) {
  4644. _PY_PROTO_CMD_INTERNAL($FILE)
  4645. }
  4646. }
  4647. # tag:python-specific
  4648. macro _GENERATE_PY_EVS_INTERNAL(FILES...) {
  4649. foreach (FILE : $FILES) {
  4650. _PY_EVLOG_CMD_INTERNAL($FILE)
  4651. }
  4652. }
  4653. macro _COPY_FILE_IMPL(FILE, AUTO_DST="", NOAUTO_DST="", OUTPUT_INCLUDES[]) {
  4654. .CMD=$COPY_CMD ${input:FILE} ${output:AUTO_DST} ${output;noauto:NOAUTO_DST} ${output_include;hide:OUTPUT_INCLUDES} ${kv;hide:"p CP"} ${kv;hide:"pc light-cyan"}
  4655. .SEM=copy_file ${input:FILE} ${output:AUTO_DST} ${output;noauto:NOAUTO_DST}
  4656. }
  4657. ### @usage: COPY_FILE(File Destination [AUTO] [OUTPUT_INCLUDES Deps...])
  4658. ###
  4659. ### Copy file to build root. It is possible to change both location and the name.
  4660. ###
  4661. ### Parameters:
  4662. ### - File - Source file name.
  4663. ### - Destination - Output file name.
  4664. ### - AUTO - Consider copied file for further processing automtically.
  4665. ### - OUTPUT_INCLUDES output_includes... - Output file dependencies.
  4666. ###
  4667. ### The file will be just copied if AUTO boolean parameter is not specified. You should explicitly
  4668. ### mention it in SRCS under new name (or specify AUTO boolean parameter) for further processing.
  4669. macro COPY_FILE(File, Destination, AUTO?"AUTO_DST":"NOAUTO_DST", OUTPUT_INCLUDES[]) {
  4670. .CMD=$_COPY_FILE_IMPL($File $AUTO $Destination OUTPUT_INCLUDES $OUTPUT_INCLUDES)
  4671. .SEM=$_COPY_FILE_IMPL($File $AUTO $Destination OUTPUT_INCLUDES $OUTPUT_INCLUDES)
  4672. }
  4673. ### @usage: COPY_FILE_WITH_CONTEXT(FILE DEST [AUTO] [OUTPUT_INCLUDES DEPS...])
  4674. ###
  4675. ### Copy file to build root the same way as it is done for COPY_FILE, but also
  4676. ### propagates the context of the source file.
  4677. macro COPY_FILE_WITH_CONTEXT(FILE, DEST, AUTO?"AUTO":"", OUTPUT_INCLUDES[]) {
  4678. .CMD=$COPY_FILE($FILE $DEST $AUTO OUTPUT_INCLUDES $FILE $OUTPUT_INCLUDES)
  4679. }
  4680. macro _BUNDLE_TARGET(Target, Destination) {
  4681. .CMD=$MOVE_FILE ${result:Target} ${output;noauto:Destination} ${kv;hide:"p BN"} ${kv;hide:"pc light-cyan"} $VCS_INFO_DISABLE_CACHE__NO_UID__
  4682. }
  4683. ### @usage: TIMEOUT(TIMEOUT)
  4684. ###
  4685. ### Sets a timeout on test execution
  4686. ###
  4687. ### Documentation about the system test: https://wiki.yandex-team.ru/yatool/test/
  4688. macro TIMEOUT(Time) {
  4689. SET(TEST_TIMEOUT $Time)
  4690. }
  4691. SBR_UID_EXT=""
  4692. # tag:test
  4693. ### @usage: VALIDATE_DATA_RESTART(ext)
  4694. ###
  4695. ### Change uid for resource validation tests. May be useful when sandbox resource ttl is changed, but test status is cached in CI.
  4696. ### You can change ext to change test's uid. For example VALIDATE_DATA_RESTART(X), where is X is current revision.
  4697. macro VALIDATE_DATA_RESTART(Ext) {
  4698. SET(SBR_UID_EXT $Ext)
  4699. }
  4700. # tag:test
  4701. TEST_FORK_MODE=none
  4702. TEST_PARTITION=SEQUENTIAL
  4703. # tag:test
  4704. ### @usage: FORK_TESTS()
  4705. ###
  4706. ### Splits a test run on chunks by test classes.
  4707. ### The number of chunks can be overridden using the macro SPLIT_FACTOR.
  4708. ###
  4709. ### Allows to run tests in parallel. Supported in UNITTEST, JTEST/JUNIT5 and PY2TEST/PY3TEST modules.
  4710. ###
  4711. ### Documentation about the system test: https://wiki.yandex-team.ru/yatool/test/
  4712. macro FORK_TESTS(MODE...) {
  4713. SET(TEST_FORK_MODE tests)
  4714. SET(TEST_PARTITION $MODE)
  4715. }
  4716. # tag:test
  4717. ### @usage: FORK_SUBTESTS()
  4718. ###
  4719. ### Splits the test run in chunks on subtests.
  4720. ### The number of chunks can be overridden using the macro SPLIT_FACTOR.
  4721. ###
  4722. ### Allows to run tests in parallel. Supported in UNITTEST, JTEST/JUNIT5 and PY2TEST/PY3TEST modules.
  4723. ###
  4724. ### Documentation about the system test: https://wiki.yandex-team.ru/yatool/test/
  4725. macro FORK_SUBTESTS(MODE...) {
  4726. SET(TEST_FORK_MODE subtests)
  4727. SET(TEST_PARTITION $MODE)
  4728. }
  4729. # tag:test
  4730. ### @usage: SPLIT_FACTOR(x)
  4731. ###
  4732. ### Sets the number of chunks for parallel run tests when used in test module with FORK_TESTS() or FORK_SUBTESTS().
  4733. ### If none of those is specified this macro implies FORK_TESTS().
  4734. ###
  4735. ### Supports C++ ut and PyTest.
  4736. ###
  4737. ### Documentation about the system test: https://wiki.yandex-team.ru/yatool/test/
  4738. macro SPLIT_FACTOR(Factor) {
  4739. SET(TEST_SPLIT_FACTOR $Factor)
  4740. }
  4741. # tag:test
  4742. FORK_TEST_FILES_MODE=
  4743. ### @usage: FORK_TEST_FILES()
  4744. ###
  4745. ### Only for PY2TEST and PY3TEST: splits a file executable with the tests on chunks in the files listed in TEST_SRCS
  4746. ### Compatible with FORK_(SUB)TESTS.
  4747. ###
  4748. ### Documentation about the system test: https://wiki.yandex-team.ru/yatool/test/
  4749. macro FORK_TEST_FILES() {
  4750. SET(FORK_TEST_FILES_MODE on)
  4751. }
  4752. # tag:test
  4753. TEST_SIZE_NAME=SMALL
  4754. ### @usage: SIZE(SMALL/MEDIUM/LARGE)
  4755. ###
  4756. ### Set the 'size' for the test. Each 'size' has own set of resrtictions, SMALL bein the most restricted and LARGE being the list.
  4757. ### See documentation on test system for more details.
  4758. ###
  4759. ### Documentation about the system test: https://wiki.yandex-team.ru/yatool/test/
  4760. macro SIZE(Type) {
  4761. SET(TEST_SIZE_NAME $Type)
  4762. }
  4763. ### @usage: JOIN_SRCS(Out Src...)
  4764. ###
  4765. ### Join set of sources into single file named Out and send it for further processing.
  4766. ### This macro doesn't place all file into Out, it emits #include<Src>... Use the for C++ source files only.
  4767. ### You should specify file name with the extension as Out. Futher processing will be done according this extension.
  4768. macro JOIN_SRCS(Out, Src...) {
  4769. .CMD=$YMAKE_PYTHON ${input:"build/scripts/gen_join_srcs.py"} ${output:Out} --ya-start-command-file ${input;rootrel:Src} --ya-end-command-file ${output_include;hide:Src} ${kv;hide:"p JS"} ${kv;hide:"pc magenta"}
  4770. .SEM=target_joined_source $Out ${input:Src} ${output;hide;suf=.o:Out}
  4771. _CONDITIONAL_SRCS($TIDY_VALUE $Src)
  4772. }
  4773. ### @usage: JOIN_SRCS_GLOBAL(Out Src...)
  4774. ###
  4775. ### Join set of sources into single file named Out and send it for further processing as if it were listed as SRCS(GLOBAL Out).
  4776. ### This macro doesn't place all file into Out, it emits #include<Src>... Use the for C++ source files only.
  4777. ### You should specify file name with the extension as Out. Further processing will be done according to this extension.
  4778. macro JOIN_SRCS_GLOBAL(Out, Src...) {
  4779. .CMD=$YMAKE_PYTHON ${input:"build/scripts/gen_join_srcs.py"} ${output;noauto:Out} --ya-start-command-file ${input;rootrel:Src} --ya-end-command-file ${output_include;hide:Src} ${kv;hide:"p JS"} ${kv;hide:"pc magenta"}
  4780. SRCS(GLOBAL $Out)
  4781. }
  4782. ### @usage: FLAT_JOIN_SRCS_GLOBAL(Out Src...)
  4783. ###
  4784. ### Join set of sources into single file named Out and send it for further processing as if it were listed as SRCS(GLOBAL Out).
  4785. ### This macro places all files into single file, so will work with any sources.
  4786. ### You should specify file name with the extension as Out. Further processing will be done according to this extension.
  4787. macro FLAT_JOIN_SRCS_GLOBAL(Out, Src...) {
  4788. .CMD=$YMAKE_PYTHON ${input:"build/scripts/fs_tools.py"} cat ${output;noauto:Out} --ya-start-command-file ${input:Src} --ya-end-command-file ${output_include;hide:Src} ${kv;hide:"p JS"} ${kv;hide:"pc magenta"}
  4789. SRCS(GLOBAL $Out)
  4790. }
  4791. # tag:cpu
  4792. PIC_CFLAGS=
  4793. SSE2_CFLAGS=
  4794. SSE3_CFLAGS=
  4795. SSSE3_CFLAGS=
  4796. SSE41_CFLAGS=
  4797. SSE42_CFLAGS=
  4798. POPCNT_CFLAGS=
  4799. PCLMUL_CFLAGS=
  4800. CX16_FLAGS=
  4801. AVX_CFLAGS=
  4802. AVX2_CFLAGS=
  4803. AVX512_CFLAGS=
  4804. # tag:cpu
  4805. SSE_DEFINES=
  4806. SSE_CFLAGS=
  4807. SSE4_DEFINES=
  4808. SSE4_CFLAGS=
  4809. NO_LTO_CFLAGS=
  4810. # tag:cpu
  4811. when (($ARCH_X86_64 || $ARCH_I386) && $DISABLE_INSTRUCTION_SETS != "yes") {
  4812. when ($CLANG || $CLANG_CL || $GCC) {
  4813. PIC_CFLAGS=-fPIC
  4814. SSE2_CFLAGS=-msse2
  4815. SSE3_CFLAGS=-msse3
  4816. SSSE3_CFLAGS=-mssse3
  4817. SSE41_CFLAGS=-msse4.1
  4818. SSE42_CFLAGS=-msse4.2
  4819. POPCNT_CFLAGS=-mpopcnt
  4820. PCLMUL_CFLAGS=-mpclmul
  4821. AVX_CFLAGS=-mavx
  4822. # On Intel FMA3 instruction set comes together with AVX-2 extension starting with Broadwell / Haswell.
  4823. # See:
  4824. # https://en.wikipedia.org/wiki/FMA_instruction_set
  4825. #
  4826. # AMD implemented it in Piledriver architecture over AVX prior to AVX-2 which was introduced in Zen.
  4827. # See:
  4828. # https://en.wikipedia.org/wiki/Template:AMD_x86_CPU_features
  4829. AVX2_CFLAGS=-mavx2 -mfma
  4830. # All Intel CPUS with AVX-512 have these instructions except for the Knights Landing / Knights Mill
  4831. # (these are Xeon Phi)
  4832. # See:
  4833. # https://en.wikichip.org/wiki/x86/avx-512
  4834. AVX512_CFLAGS=-mavx512f -mavx512cd -mavx512bw -mavx512dq -mavx512vl
  4835. when ($ARCH_X86_64 && $OS_ANDROID != "yes") {
  4836. CX16_FLAGS=-mcx16
  4837. }
  4838. SSE_DEFINES=-DSSE_ENABLED=1 -DSSE3_ENABLED=1 -DSSSE3_ENABLED=1
  4839. SSE4_DEFINES=-DSSE41_ENABLED=1 -DSSE42_ENABLED=1 -DPOPCNT_ENABLED=1 -DCX16_ENABLED=1
  4840. }
  4841. elsewhen ($MSVC) {
  4842. SSE2_CFLAGS=/D__SSE2__=1
  4843. SSE3_CFLAGS=/D__SSE3__=1
  4844. SSSE3_CFLAGS=/D__SSSE3__=1
  4845. SSE41_CFLAGS=/D__SSE4_1__=1
  4846. SSE42_CFLAGS=/D__SSE4_2__=1
  4847. POPCNT_CFLAGS=/D__POPCNT__=1
  4848. PCLMUL_CFLAGS=/D__PCLMUL__=1
  4849. AVX_CFLAGS=/arch:AVX /DAVX_ENABLED=1
  4850. AVX2_CFLAGS=/arch:AVX2 /DAVX2_ENABLED=1
  4851. AVX512_CFLAGS=/arch:AVX512 /DAVX512_ENABLED=1
  4852. SSE_DEFINES=/DSSE_ENABLED=1 /DSSE3_ENABLED=1 /DSSSE3_ENABLED=1
  4853. SSE4_DEFINES=/DSSE41_ENABLED=1 /DSSE42_ENABLED=1 /DPOPCNT_ENABLED=1 /DCX16_ENABLED=1
  4854. }
  4855. SSE_CFLAGS=$SSE2_CFLAGS $SSE3_CFLAGS $SSSE3_CFLAGS
  4856. SSE4_CFLAGS=$SSE41_CFLAGS $SSE42_CFLAGS $POPCNT_CFLAGS $CX16_FLAGS
  4857. when ($ARCH_I386 && $OS_ANDROID == "yes") {
  4858. USE_SSE4=no
  4859. }
  4860. }
  4861. otherwise {
  4862. USE_SSE4=no
  4863. CPU_CHECK=no
  4864. }
  4865. # tag:cpu
  4866. when ($NOSSE == "yes") {
  4867. USE_SSE4=no
  4868. }
  4869. # tag:cpu
  4870. ### @usage: NO_SSE4()
  4871. ###
  4872. ### Compile module without SSE4
  4873. macro NO_SSE4() {
  4874. SET(USE_SSE4 no)
  4875. }
  4876. # tag:cpu
  4877. ### @usage: NO_CPU_CHECK()
  4878. ###
  4879. ### Compile module without startup CPU features check
  4880. macro NO_CPU_CHECK() {
  4881. SET(CPU_CHECK no)
  4882. }
  4883. ### @usage: ADDINCLSELF()
  4884. ###
  4885. ### The macro adds the -I<project source path> flag to the source compilation flags of the current project.
  4886. macro ADDINCLSELF(FOR="") {
  4887. when($FOR) {
  4888. ADDINCL+=FOR $FOR ${MODDIR}
  4889. }
  4890. otherwise {
  4891. ADDINCL+=${MODDIR}
  4892. }
  4893. }
  4894. COMPILE_OUT_SUFFIX=
  4895. _COMPILE_OUTPUTS=${output;suf=${COMPILE_OUT_SUFFIX}${OBJECT_SUF}:SRC}
  4896. _COMPILE_TIME_TRACE_OUTPUTS=${output;noauto;suf=${COMPILE_OUT_SUFFIX}${OBJECT_SUF}.time_trace.json:SRC}
  4897. macro SET_COMPILE_OUTPUTS_MODIFIERS(NOREL?";norel":"") {
  4898. SET(_COMPILE_OUTPUTS \${output;suf=\${OBJECT_SUF}$NOREL:SRC})
  4899. SET(_COMPILE_TIME_TRACE_OUTPUTS \${output;noauto;suf=\${OBJECT_SUF}.time_trace.json$NOREL:SRC})
  4900. }
  4901. # tag:internal
  4902. ### @usage: _ADD_EXTRA_FLAGS_IMPL([GENERATE] Args...) # internal
  4903. ### Generate prefix = " && set_property SOURCE ${input:SRC} APPEND PROPERTY COMPILE_OPTIONS " before $Args when GENERATE
  4904. ### is specified in the list of actual arguments
  4905. macro _ADD_EXTRA_FLAGS_IMPL(GENERATE?" && set_property SOURCE ${input:SRC} APPEND PROPERTY COMPILE_OPTIONS ":"", Args...) {
  4906. .SEM=$GENERATE $Args
  4907. }
  4908. # tag:internal
  4909. ### @usage: _ADD_EXTRA_FLAGS([GENERATE] Args...) # internal
  4910. ### Generate prefix = " && set_property SOURCE ${input:SRC} APPEND PROPERTY COMPILE_OPTIONS " if Args is not empty
  4911. macro _ADD_EXTRA_FLAGS(COMPILE_OUT_SUFFIX="", Args...) {
  4912. .SEM=$_ADD_EXTRA_FLAGS_IMPL(${pre=GENERATE :Args})
  4913. }
  4914. _EMPTY_CMD=
  4915. # tag:src-processing tag:internal
  4916. ### @usage: _SRC(Ext Src Flags) # internal
  4917. ###
  4918. ### Basic building block of extension-based command dispatching
  4919. ### To enable specific extension processing define _SRC() macro with fixed first argument (Ext).
  4920. ### Internal logic will apply this macro to all files with this Ext listed in SRC/SRCS macros or outputs
  4921. ### of other commands (except ones marked as noauto)
  4922. macro _SRC(EXT, SRC, SRCFLAGS...) {
  4923. # Generic macro definition for _SRC (just a placeholder, it does nothing)
  4924. }
  4925. RODATA_SYMBOL_PREFIX=
  4926. when ($DARWIN == "yes" || $IOS == "yes" || ($WINDOWS == "yes" && $ARCH_TYPE_32 == "yes")) {
  4927. RODATA_SYMBOL_PREFIX=_
  4928. }
  4929. RODATA_ELF_FLAGS=
  4930. when($LINUX == "yes" || $ANDROID == "yes") {
  4931. RODATA_ELF_FLAGS=--elf
  4932. }
  4933. RODATA_COMPILE=$YMAKE_PYTHON3 ${input:"build/scripts/rodata2asm.py"} $RODATA_ELF_FLAGS ${RODATA_SYMBOL_PREFIX}${noext;nopath:SRC} ${input:SRC} ${tmp;suf=.asm:SRC} ${hide:OBJECT_SUF} && $_SRC_yasm_helper(${tmp;suf=.asm:SRC})
  4934. when (($ARCH_AARCH64 || $ARCH_ARM || $ARCH_PPC64LE) == "yes") {
  4935. RODATA_COMPILE=$YMAKE_PYTHON3 ${input:"build/scripts/rodata2cpp.py"} ${noext;nopath:SRC} ${input:SRC} ${output;suf=.cpp:SRC}
  4936. }
  4937. # tag:src-processing
  4938. macro _SRC("rodata", SRC, SRCFLAGS...) {
  4939. .CMD=$RODATA_COMPILE ${hide;kv:"p RD"} ${hide;kv:"pc light-green"}
  4940. .PEERDIR=$YMAKE_PYTHON3_PEER
  4941. .SEM=target_rodata_sources PRIVATE ${input:SRC} ${output;hide;suf=${OBJ_SUF}.o:SRC}
  4942. }
  4943. # tag:src-processing
  4944. macro _SRC("S", SRC, SRCFLAGS...) {
  4945. .CMD=$C_COMPILER $C_FLAGS_PLATFORM $CFLAGS $SFLAGS $SRCFLAGS -c -o ${output:SRC.o} ${input:SRC} ${pre=-I:_C__INCLUDE}
  4946. .SEM=target_sources PRIVATE ${input:SRC} ${output;hide;suf=${OBJ_SUF}.o:SRC} $_ADD_EXTRA_FLAGS($SRCFLAGS)
  4947. }
  4948. # tag:src-processing
  4949. macro _SRC("s", SRC, SRCFLAGS...) {
  4950. .CMD=$_SRC(S, $SRC $SRCFLAGS)
  4951. }
  4952. # tag:src-processing
  4953. macro _SRC("s79", SRC, SRCFLAGS...) {
  4954. .CMD=$_SRC(S, $SRC $SRCFLAGS -x assembler-with-cpp)
  4955. }
  4956. # tag:src-processing
  4957. macro _SRC("mm", SRC, SRCFLAGS...) {
  4958. .CMD=$C_COMPILER $C_FLAGS_PLATFORM -x objective-c++ -fobjc-arc -fobjc-abi-version=2 -c -o ${output:SRC.o} ${input:SRC} $CXXFLAGS ${pre=-I:_C__INCLUDE} ${SRCFLAGS} ${kv;hide:"p CC"} ${kv;hide:"pc light-green"} $TOOLCHAIN_ENV
  4959. }
  4960. # tag:src-processing
  4961. macro _SRC("fml", SRC, SRCFLAGS...) {
  4962. .CMD=$FML_TOOL $CHECKFLAG -b -o ${output:SRC.inc} -T ${input:SRC} ${SRCFLAGS} ${kv;hide:"p FM"} ${kv;hide:"pc yellow"}
  4963. }
  4964. # tag:src-processing
  4965. macro _SRC("fml2", SRC, SRCFLAGS...) {
  4966. .CMD=$FML_TOOL $CHECKFLAG -b -o ${output;nopath;noext:SRC.fml.inc} -2 -O ${output;nopath;noext:SRC.fml.cpp} -T ${input:SRC} ${SRCFLAGS} ${kv;hide:"p FM"} ${kv;hide:"pc yellow"}
  4967. }
  4968. # tag:src-processing
  4969. macro _SRC("fml3", SRC, SRCFLAGS...) {
  4970. .CMD=$FML_TOOL $CHECKFLAG -b -o ${output;nopath;noext:SRC.fml.inc} -3 -O ${output;nopath;noext:SRC.fml.cpp} -L ${input;nopath;noext:SRC.list} -P ${nopath;noext:SRC} -T ${input:SRC} ${SRCFLAGS} ${kv;hide:"p FM"} ${kv;hide:"pc yellow"}
  4971. }
  4972. # tag:src-processing
  4973. macro _SRC("sfdl", SRC, SRCFLAGS...) {
  4974. .CMD=$CXX_COMPILER $C_FLAGS_PLATFORM $CXXFLAGS $SFDL_FLAG ${SRCFLAGS} ${input:SRC} && ${tool:"tools/calcstaticopt"} -i ${tmp:SRC.tmp} -a $ARCADIA_ROOT ${output;stdout;nopath;noext;defext=.inc:SRC} ${kv;hide:"p SF"} ${kv;hide:"pc yellow"} $TOOLCHAIN_ENV
  4975. }
  4976. # tag:src-processing
  4977. macro _SRC("xs", SRC, SRCFLAGS...) {
  4978. .CMD=$PERL_LD_LIBRARY_PATH $PERL $PERL_INCLUDE ${suf=/ExtUtils/xsubpp:PERL_PRIVLIB} -typemap ${suf=/ExtUtils/typemap:PERL_PRIVLIB} $PERLSUFFIX $XSUBPPFLAGS ${SRCFLAGS} ${input:SRC} $PERLOUTPUT ${kv;hide:"p XS"} ${kv;hide:"pc yellow"}
  4979. }
  4980. # tag:src-processing
  4981. macro _SRC("y", SRC, SRCFLAGS...) {
  4982. # .CMD=${tool:"contrib/tools/byacc"} $BYACC_FLAGS ${nopath;noext;output:SRC.cpp} ${input:SRC} ${nopath;noext;hide;output;addincl:SRC.h} ${kv;hide:"p YC"} ${kv;hide:"pc light-green"}
  4983. .CMD=${tool:"contrib/tools/bison/bison"} $BISON_FLAGS --m4=${tool:"contrib/tools/bison/m4"} --defines=${nopath;noext;output;main;addincl;norel:SRC.h} -o ${nopath;noext;output:SRC.cpp} ${input:SRC} ${SRCFLAGS} && $YMAKE_PYTHON ${input:"build/scripts/preprocess.py"} $_ADD_HIDDEN_INPUTS($CPP_BISON_SKELS) ${nopath;noext;tmp:SRC.h} ${kv;hide:"p YC"} ${kv;hide:"pc light-green"}
  4984. .SEM=target_bison_parser PRIVATE ${input:SRC} ${output;nopath;noext;hide;suf=${OBJ_SUF}.o:SRC} ${nopath;noext;output;hide:SRC.h} ${nopath;noext;output;addincl;hide:SRC.h} && set_global_flags BISON_FLAGS $BISON_FLAGS && conan_require bison/3.5.3 && conan_import '"bin, bison* -> ./bin/bison/bin"' && conan_import '"res, * -> ./bin/bison/res"'
  4985. }
  4986. # tag:src-processing
  4987. macro _SRC("ypp", SRC, SRCFLAGS...) {
  4988. .CMD=$_SRC(y $SRC $SRCFLAGS)
  4989. }
  4990. # tag:src-processing
  4991. macro _SRC("gperf", SRC, SRCFLAGS...) {
  4992. .CMD=$RUN_NO_SANITIZE ${tool:"contrib/tools/gperf"} $GP_FLAGS ${SRCFLAGS} ${pre=-Nin_;suf=_set;nopath;noallext:SRC} ${input:SRC} ${output;stdout;nopath;noext;defext=.gperf.cpp:SRC} ${kv;hide:"p GP"} ${kv;hide:"pc yellow"}
  4993. }
  4994. # tag:src-processing
  4995. macro _SRC("rl", SRC, SRCFLAGS...) {
  4996. .CMD=$RUN_NO_SANITIZE ${tool:"contrib/tools/ragel5/ragel"} $RAGEL_FLAGS ${SRCFLAGS} -o ${tmp:SRC.tmp} ${input:SRC} && $RUN_NO_SANITIZE ${tool:"contrib/tools/ragel5/rlgen-cd"} $RLGEN_FLAGS -o ${output;nopath;noext;defext=.rl5.cpp:SRC} ${tmp:SRC.tmp} ${kv;hide:"p R5"} ${kv;hide:"pc yellow"}
  4997. }
  4998. # tag:src-processing
  4999. macro _SRC("rl5", SRC, SRCFLAGS...) {
  5000. .CMD=$_SRC(rl $SRC $SRCFLAGS)
  5001. }
  5002. # tag:src-processing
  5003. macro _SRC("asp", SRC, SRCFLAGS...) {
  5004. .CMD=$RUN_NO_SANITIZE ${tool:"tools/html2cpp"} ${input:SRC} ${output:SRC.cpp} ${kv;hide:"p HT"} ${kv;hide:"pc yellow"}
  5005. }
  5006. # tag:src-processing
  5007. macro _SRC("rl6", SRC, SRCFLAGS...) {
  5008. .CMD=$RUN_NO_SANITIZE ${tool:"contrib/tools/ragel6"} $RAGEL6_FLAGS ${SRCFLAGS} -L -I${ARCADIA_ROOT} -o ${output;nopath;noext;defext=.rl6.cpp:SRC} ${input:SRC} ${kv;hide:"p R6"} ${kv;hide:"pc yellow"}
  5009. .SEM=target_ragel_lexers PRIVATE ${input:SRC} ${output;hide;suf=${OBJ_SUF}.o:SRC} $RAGEL6_FLAGS ${SRCFLAGS} && set_global_flags RAGEL_FLAGS -L -I $S/ && conan_require ragel/6.10 && conan_import '"bin, ragel* -> ./bin"'
  5010. }
  5011. # tag:src-processing
  5012. macro _SRC("l", SRC, SRCFLAGS...) {
  5013. .CMD=${tool:"contrib/tools/flex-old"} $LEX_FLAGS ${SRCFLAGS} -o${output:SRC.cpp} ${output_include;hide:"util/system/compiler.h"} ${input:SRC} ${kv;hide:"p LX"} ${kv;hide:"pc yellow"}
  5014. .ADDINCL=contrib/tools/flex-old
  5015. .SEM=target_flex_lexers ${tool;hide:"contrib/tools/flex-old"} ${output;hide;suf=${OBJ_SUF}.o:SRC} ${input:SRC} && set_global_flags LEX_FLAGS $LEX_FLAGS
  5016. }
  5017. # tag:src-processing
  5018. macro _SRC("lex", SRC, SRCFLAGS...) {
  5019. .CMD=$_SRC(l $SRC $SRCFLAGS)
  5020. }
  5021. # tag:src-processing
  5022. macro _SRC("lpp", SRC, SRCFLAGS...) {
  5023. .CMD=$_SRC(l $SRC $SRCFLAGS)
  5024. }
  5025. # tag:src-processing
  5026. macro _SRC("pln", SRC, SRCFLAGS...) {
  5027. .CMD=$FML_TOOL -b -o ${output;pre=pln.;nopath;noext:SRC.cpp} -f ${input:SRC} ${SRCFLAGS} ${kv;hide:"p FM"} ${kv;hide:"pc yellow"}
  5028. }
  5029. # tag:src-processing
  5030. macro _SRC("xsyn", SRC, SRCFLAGS...) {
  5031. .CMD=$YMAKE_PYTHON ${input:"library/cpp/xml/parslib/xsyn2ragel.py"} ${input:SRC} ${input:"library/cpp/xml/parslib/xmlpars.xh"} dontuse ${output;stdout:SRC.h.rl5} ${kv;hide:"p XN"} ${kv;hide:"pc yellow"}
  5032. }
  5033. # tag:src-processing
  5034. macro _SRC("ev", SRC, SRCFLAGS...) {
  5035. .CMD=$EVLOG_CMD($SRC)
  5036. }
  5037. # tag:src-processing
  5038. macro _SRC("proto", SRC, SRCFLAGS...) {
  5039. .CMD=$PROTO_CMD($SRC)
  5040. .SEM=$PROTO_CMD($SRC)
  5041. }
  5042. # tag:src-processing
  5043. macro _SRC("gztproto", SRC, SRCFLAGS...) {
  5044. # _PROTO__INCLUDE is before ARCADIA_ROOT in includes because in gazetteer we don't use builtins now and paths'canonization (resolving) depends on order of roots.
  5045. # descriptor.proto must be resolved as google/protobuf/descriptor.proto
  5046. .CMD=${tool:"dict/gazetteer/converter"} -I$PROTOBUF_PATH ${pre="-I":_PROTO__INCLUDE} -I$ARCADIA_ROOT ${SRCFLAGS} ${input:SRC} ${output;nopath;noext;norel:SRC.proto} ${kv;hide:"p GZ"} ${kv;hide:"pc yellow"}
  5047. .PEERDIR=kernel/gazetteer/proto
  5048. }
  5049. # tag:src-processing
  5050. macro _SRC("cfgproto", SRC, SRCFLAGS...) {
  5051. .CMD=$_CPP_CFGPROTO_CMD($SRC)
  5052. }
  5053. # tag:src-processing
  5054. macro _SRC("pyx", SRC, SRCFLAGS...) {
  5055. # Copy-paste from BUILDWITH_CYTHON
  5056. .CMD=$RUN_CYTHON_SCRIPT $CYTHON_OPTIONS --cplus ${CYTHON_CPP_OUTPUT_INCLUDES} ${pre=-I:_CYTHON__INCLUDE} ${input:SRC} -o ${output;tobindir:SRC.cpp} $CYTHON_OUTPUT_INCLUDES ${SRCFLAGS} ${kv;hide:"p CY"} ${kv;hide:"pc yellow"}
  5057. .ADDINCL=FOR cython contrib/tools/cython/Cython/Includes
  5058. }
  5059. # tag:src-processing
  5060. macro _SRC("in", SRC, SRCFLAGS...) {
  5061. .CMD=$CONFIGURE_FILE(${SRC} ${nopath;noext:SRC})
  5062. .SEM=$CONFIGURE_FILE(${SRC} ${nopath;noext:SRC})
  5063. }
  5064. macro MANUAL_GENERATION(Outs...) {
  5065. .SEM=ignored ${output;hide;noauto:Outs}
  5066. }
  5067. # tag:src-processing
  5068. macro _SRC("sc", SRC, SRCFLAGS...) {
  5069. .CMD=${tool:"tools/domschemec"} --in ${input:SRC} --out ${output;norel:SRC.h} ${output_include;hide:"util/generic/strbuf.h"} ${output_include;hide:"util/generic/string.h"} ${output_include;hide:"util/generic/vector.h"} ${output_include;hide:"util/string/cast.h"} ${SRCFLAGS} ${kv;hide:"p SC"} ${kv;hide:"pc yellow"}
  5070. }
  5071. # tag:src-processing
  5072. macro _SRC("ssqls", SRC, SRCFLAGS...) {
  5073. .CMD=${tool:"metrika/core/tools/ssqls"} ${input;notransformbuilddir:SRC} -S $ARCADIA_ROOT -B $ARCADIA_BUILD_ROOT $SRCFLAGS ${output;noext;hide:SRC.cpp} ${output;noext;hide:SRC.h} ${kv;hide:"p SS"} ${kv;hide:"pc yellow"}
  5074. }
  5075. # tag:src-processing
  5076. macro _SRC("f", SRC, SRCFLAGS...) {
  5077. .CMD=$YMAKE_PYTHON ${input:"build/scripts/f2c.py"} -t ${tool:"contrib/tools/f2c"} -c ${input:SRC} -o ${output:SRC.c} ${kv;hide:"p FT"} ${kv;hide:"pc light-green"}
  5078. .PEERDIR=contrib/libs/libf2c
  5079. .ADDINCL=contrib/libs/libf2c
  5080. }
  5081. # tag:src-processing
  5082. macro _SRC("cpp", SRC, SRCFLAGS...) {
  5083. .CMD=$_SRC_cpp($SRC $SRCFLAGS)
  5084. .SEM=target_sources PRIVATE ${input:SRC} ${output;hide;suf=${OBJ_SUF}.o:SRC} $_ADD_EXTRA_FLAGS($SRCFLAGS)
  5085. }
  5086. # tag:src-processing
  5087. macro _SRC("cxx", SRC, SRCFLAGS...) {
  5088. .CMD=$_SRC(cpp $SRC $SRCFLAGS)
  5089. }
  5090. # tag:src-processing
  5091. macro _SRC("cc", SRC, SRCFLAGS...) {
  5092. .CMD=$_SRC(cpp $SRC $SRCFLAGS)
  5093. .SEM=target_sources PRIVATE ${input:SRC} ${output;hide;suf=${OBJ_SUF}.o:SRC} $_ADD_EXTRA_FLAGS($SRCFLAGS)
  5094. }
  5095. # tag:src-processing
  5096. macro _SRC("C", SRC, SRCFLAGS...) {
  5097. .CMD=$_SRC(cpp $SRC $SRCFLAGS)
  5098. }
  5099. # tag:src-processing
  5100. macro _SRC("c", SRC, SRCFLAGS...) {
  5101. .CMD=$_SRC_c($SRC $SRCFLAGS)
  5102. .SEM=target_sources PRIVATE ${input:SRC} ${output;hide;suf=${OBJ_SUF}.o:SRC} $_ADD_EXTRA_FLAGS($SRCFLAGS $USER_CONLYFLAGS $USER_CONLYFLAGS_GLOBAL)
  5103. }
  5104. # tag:src-processing
  5105. macro _SRC("m", SRC, SRCFLAGS...) {
  5106. .CMD=$_SRC(c $SRC $SRCFLAGS)
  5107. }
  5108. # tag:src-processing
  5109. macro _SRC("masm", SRC, SRCFLAGS...) {
  5110. .CMD=$_SRC_masm($SRC $SRCFLAGS)
  5111. }
  5112. YASM_SEM=target_yasm_source PRIVATE ${input:SRC} ${output;hide;suf=${OBJ_SUF}.o:SRC} $YASM_FLAGS ${pre=-I :_ASM__INCLUDE} $SRCFLAGS ${pre=-P :PREINCLUDES} \
  5113. && set_global_flags YASM_FLAGS -f ${_YASM_FMT_VALUE}${HARDWARE_ARCH} $_YASM_PLATFORM_FLAGS_VALUE -D ${pre=_;suf=_:HARDWARE_TYPE} -D_YASM_ $ASM_PREFIX_VALUE $_YASM_PREDEFINED_FLAGS_VALUE \
  5114. && add_language ASM \
  5115. && conan_require yasm/1.3.0 && conan_import '"bin, *yasm* -> ./bin"' && conan_import '"bin, ytasm* -> ./bin"'
  5116. ASM_SEM=target_yasm_source PRIVATE ${input:SRC} ${output;hide;suf=${OBJ_SUF}.o:SRC} $YASM_FLAGS ${pre=-I :_ASM__INCLUDE} $SRCFLAGS \
  5117. && set_global_flags YASM_FLAGS -f ${_YASM_FMT_VALUE}${HARDWARE_ARCH} $_YASM_PLATFORM_FLAGS_VALUE -D ${pre=_;suf=_:HARDWARE_TYPE} -D_YASM_ $ASM_PREFIX_VALUE $_YASM_PREDEFINED_FLAGS_VALUE \
  5118. && add_language ASM \
  5119. && conan_require yasm/1.3.0 && conan_import '"bin, *yasm* -> ./bin"' && conan_import '"bin, ytasm* -> ./bin"'
  5120. # tag:src-processing
  5121. macro _SRC("yasm", SRC, SRCFLAGS...) {
  5122. .CMD=$_SRC_yasm($SRC $SRCFLAGS PREINCLUDES $YASM_PREINCLUDES_VALUE)
  5123. .SEM=$YASM_SEM
  5124. }
  5125. # tag:src-processing
  5126. macro _SRC("asm", SRC, SRCFLAGS...) {
  5127. .CMD=$_SRC(yasm $SRC $SRCFLAGS)
  5128. .SEM=$ASM_SEM
  5129. }
  5130. # tag:src-processing
  5131. macro _SRC("lua", SRC, SRCFLAGS...) {
  5132. .CMD=${cwd:LUAJIT_PATH} ${tool:"contrib/libs/luajit/compiler"} -b -g ${input:SRC} ${SRCFLAGS} ${global;output;suf=.o:SRC} ${kv;hide:"p LJ"} ${kv;hide:"pc light-cyan"}
  5133. .PEERDIR=$LUAJIT_PATH
  5134. }
  5135. # tag:src-processing
  5136. macro _SRC("cu", SRC, SRCFLAGS...) {
  5137. .CMD=$_SRC_CU_CMD
  5138. .SEM=target_sources PRIVATE ${input:SRC} ${output;hide;suf=${OBJ_SUF}.o:SRC} $_ADD_EXTRA_FLAGS($SRCFLAGS) && target_cuda_flags PRIVATE $CUDA_NVCC_FLAGS
  5139. .PEERDIR=$_SRC_CU_PEERDIR
  5140. }
  5141. # tag:src-processing
  5142. macro _SRC("fbs", SRC, SRCFLAGS...) {
  5143. .CMD=$FBS_CMD($SRC, $SRCFLAGS)
  5144. .SEM=$FBS_CMD($SRC, $SRCFLAGS)
  5145. }
  5146. # tag:src-processing
  5147. macro _SRC("fbs64", SRC, SRCFLAGS...) {
  5148. .CMD=$_CPP_FLATC64_CMD($SRC, $SRCFLAGS)
  5149. }
  5150. # tag:src-processing
  5151. macro _SRC("pysrc", SRC, SRCFLAGS...) {
  5152. .CMD=$_SRC_PYSRC($SRC, $SRCFLAGS)
  5153. }
  5154. # tag:src-processing
  5155. macro _SRC_py2src(SRC, SRCFLAGS...) {
  5156. .CMD=${cwd:BINDIR} $YMAKE_PYTHON ${input:"build/scripts/compile_pysrc.py"} --input ${input:SRC} --output ${output;noext;suf=.py2_raw.cpp:SRC} --rescompiler ${tool:"tools/rescompiler"} py2 --python $(PYTHON)/python --py_compile ${input:"build/scripts/py_compile.py"} ${kv;hide:"p P2"} ${kv;hide:"pc light-green"}
  5157. }
  5158. # tag:src-processing
  5159. macro _SRC_py3src(SRC, SRCFLAGS...) {
  5160. .CMD=${cwd:BINDIR} $YMAKE_PYTHON ${input:"build/scripts/compile_pysrc.py"} --input ${input:SRC} --output ${output;noext;suf=.py3_raw.cpp:SRC} --rescompiler ${tool:"tools/rescompiler"} py3 --pycc ${tool:"contrib/tools/python3/pycc"} ${kv;hide:"p P3"} ${kv;hide:"pc light-green"}
  5161. }
  5162. # tag:src-processing python-specific
  5163. when ($PYTHON3 == "yes") {
  5164. MACRO_ALIAS(_SRC_PYSRC _SRC_py3src)
  5165. }
  5166. otherwise {
  5167. MACRO_ALIAS(_SRC_PYSRC _SRC_py2src)
  5168. }
  5169. # tag:src-processing
  5170. macro _SRC_c_nodeps(SRC, OUTFILE, INC...) {
  5171. .CMD=$_SRC_C_NODEPS_CMD
  5172. }
  5173. # Custom flags for generated cpp-files. To support another generator:
  5174. # - insert additional file extension before .cpp into generated cpp-file name
  5175. # - update _LANG_CFLAGS_FILTER variable. Don't forget to add ' SKIP ' after flag list
  5176. #
  5177. # ragel5 and ragel6 generated terrible code which makes use of goto's in switch statements.
  5178. # This triggers -Werror-implicit-fallthrough due to `unannotated fall-through between switch labels`.
  5179. #
  5180. # cython generated code also fails to pass this diagnostics due to `fallthrough annotation in unreachable code`.
  5181. # We use cython==0.29.26 at the time. This issue might be fixed in further versions.
  5182. ## tag:src-processing
  5183. _LANG_CFLAGS_FILTER=\
  5184. ${pre=-Wno-implicit-fallthrough SKIP ;ext=.rl5:SRC} \
  5185. ${pre=-Wno-implicit-fallthrough SKIP ;ext=.rl6:SRC} \
  5186. ${pre=-Wno-implicit-fallthrough SKIP ;ext=.pyx:SRC}
  5187. # tag:src-processing
  5188. # Magic macro for removing file name from result (file name is passed as unused SKIP parameter)
  5189. macro _FILTER_EXTS(SKIP="", FLAGS...) {
  5190. .CMD=$FLAGS
  5191. }
  5192. # tag:src-processing
  5193. macro _LANG_CFLAGS(SRC) {
  5194. .CMD=$_FILTER_EXTS($_LANG_CFLAGS_FILTER)
  5195. }
  5196. # tag:src-processing
  5197. # ymake bug workaround: variables followed a macros call in .CMD are not substituted and are placed in result as is
  5198. # Pack macro call into a variable and use it in _SRC_CPP_CMD instead of macro call
  5199. _LANG_CFLAGS_VALUE=
  5200. when ($CLANG == "yes" || $CLANG_CL == "yes" || $GCC == "yes") {
  5201. _LANG_CFLAGS_VALUE=$_LANG_CFLAGS(${noext:SRC})
  5202. }
  5203. # Allows to add single compilation unit name to the node's 'kv' section.
  5204. # This is used by the coverage machinery to instrument only the necessary sources
  5205. # when --coverage-prefix-filter <rootrelpath> is specified. For more info see DEVTOOLSSUPPORT-16891
  5206. SCU_NAME_KV=
  5207. when ($CLANG_COVERAGE && $CLANG_COVERAGE != "no") {
  5208. SCU_NAME_KV=${hide;kv:"scu_name $KV_VAL"}
  5209. }
  5210. macro _ADD_SCU_NAME(KV_VAL) {
  5211. .CMD=$SCU_NAME_KV
  5212. }
  5213. # tag:src-processing
  5214. macro _SRC_cpp(SRC, COMPILE_OUT_SUFFIX="", SRCFLAGS...) {
  5215. .CMD=$_SRC_CPP_CMD $_ADD_SCU_NAME(${input:SRC})
  5216. }
  5217. # tag:src-processing
  5218. macro _SRC_c(SRC, COMPILE_OUT_SUFFIX="", SRCFLAGS...) {
  5219. .CMD=$_SRC_C_CMD $_ADD_SCU_NAME(${input:SRC})
  5220. }
  5221. # tag:src-processing
  5222. macro _SRC_m(SRC, SRCFLAGS...) {
  5223. .CMD=$_SRC_M_CMD
  5224. }
  5225. # tag:src-processing
  5226. macro _SRC_masm(SRC, SRCFLAGS...) {
  5227. .CMD=$_SRC_MASM_CMD
  5228. }
  5229. # tag:lua-specific
  5230. ### @usage: COMPILE_LUA(Src, [NAME <import_name>])
  5231. ###
  5232. ### Compile LUA source file to object code using LUA 2.0
  5233. ### Optionally override import name which is by default reflects Src name
  5234. macro COMPILE_LUA(Src, NAME="") {
  5235. .CMD=$_SRC(lua, $Src, ${pre=-n :NAME})
  5236. }
  5237. # tag:lua-specific
  5238. ### @usage: _SRC_lua_21(SRC [SRCFLAGS...]) # internal
  5239. ###
  5240. ### Compile LUA source file to object code using LUA 2.1
  5241. macro _SRC_lua_21(SRC, SRCFLAGS...) {
  5242. .CMD=${cwd:LUAJIT_21_PATH} ${tool:"contrib/libs/luajit_21/compiler"} -b -g ${input:SRC} ${SRCFLAGS} ${global;output;suf=.o:SRC} ${kv;hide:"p LJ"} ${kv;hide:"pc light-cyan"}
  5243. .PEERDIR=$LUAJIT_21_PATH
  5244. }
  5245. # tag:lua-specific
  5246. ### @usage: COMPILE_LUA_21(Src, [NAME <import_name>])
  5247. ###
  5248. ### Compile LUA source file to object code using LUA 2.1
  5249. ### Optionally override import name which is by default reflects Src name
  5250. macro COMPILE_LUA_21(Src, NAME="") {
  5251. .CMD=$_SRC_lua_21($Src, ${pre=-n :NAME})
  5252. }
  5253. GETTEXT_KEEP_PATH=no
  5254. _MO_OUTPUT=
  5255. when ($GETTEXT_KEEP_PATH == "yes") {
  5256. _MO_OUTPUT=${output;noauto;norel;noext:SRC.mo}
  5257. }
  5258. otherwise {
  5259. _MO_OUTPUT=${output;noauto;nopath;noext;tobindir:SRC.mo}
  5260. }
  5261. # tag:src-processing
  5262. macro _SRC("po", SRC, SRCFLAGS...) {
  5263. .CMD=$YMAKE_PYTHON ${input:"contrib/tools/python/src/Tools/i18n/msgfmt.py"} -o $_MO_OUTPUT ${input:SRC}
  5264. }
  5265. # tag:ydl-specific
  5266. YDL_FLAGS= --force-color -I ${ARCADIA_ROOT}
  5267. YDL_DESC_FLAGS=
  5268. # tag:src-processing tag:ydl-specific
  5269. macro _SRC("ydl", SRC, SRCFLAGS...) {
  5270. .CMD=${tool:"statbox/ydl/compiler/tooling/ydl/bin"} c $YDL_FLAGS --cpp-output-header ${output;suf=.h:SRC} --cpp-output-source ${output;suf=.cpp:SRC} ${input:SRC} ${output_include;hide:"statbox/ydl/runtime/cpp/gen_support/standard_includes.h"} ${kv;hide:"p YDL"} ${kv;hide:"pc yellow"}
  5271. .PEERDIR+=statbox/ydl/runtime/cpp
  5272. }
  5273. # tag:ydl-specific
  5274. ### @usage BUILD_YDL_DESC(Input Symbol Output)
  5275. ###
  5276. ### Generate a descriptor for a Symbol located in a ydl module Input, and put it to the file Output.
  5277. ###
  5278. ### @example:
  5279. ###
  5280. ### PACKAGE()
  5281. ### BUILD_YDL_DESC(../types.ydl Event Event.ydld)
  5282. ### END()
  5283. ###
  5284. ### This will parse file ../types.ydl, generate a descriptor for a symbol Event defined in the said file, and put the descriptor to the Event.ydld.
  5285. macro BUILD_YDL_DESC(Input, Symbol, Output) {
  5286. .CMD=${tool:"statbox/ydl/compiler/tooling/ydl/bin"} ti $YDL_FLAGS $YDL_DESC_FLAGS -o ${output;noauto:Output} ${input:Input} ${Symbol} ${kv;hide:"p YDL"} ${kv;hide:"pc yellow"}
  5287. }
  5288. # tag:ydl-specific
  5289. ### @usage: YDL_DESC_USE_BINARY()
  5290. ###
  5291. ### Used in conjunction with BUILD_YDL_DESC. When enabled, all generated descriptors are binary.
  5292. ###
  5293. ### @example:
  5294. ###
  5295. ### PACKAGE()
  5296. ### YDL_DESC_USE_BINARY()
  5297. ### BUILD_YDL_DESC(../types.ydl Event Event.ydld)
  5298. ### END()
  5299. ###
  5300. ### This will generate descriptor Event.ydld in a binary format.
  5301. macro YDL_DESC_USE_BINARY() {
  5302. YDL_DESC_FLAGS_BINARY= --binary
  5303. SET_APPEND(YDL_DESC_FLAGS $YDL_DESC_FLAGS_BINARY)
  5304. }
  5305. ### @usage SRC(File Flags...)
  5306. ###
  5307. ### Compile single file with extra Flags.
  5308. ### Compilation is driven by the last extension of the File and Flags are specific to corresponding compilation command
  5309. macro SRC(FILE, FLAGS...) {
  5310. _SRC(${lastext:FILE} $FILE $FLAGS)
  5311. }
  5312. ### @usage: SRCS(<[GLOBAL] File> ...)
  5313. ###
  5314. ### Source files of the project. Files are built according to their extension and put int module output or fed to ultimate PROGRAM/DLL depending on GLOBAL presence.
  5315. ### Arcadia Paths from the root and is relative to the project's LIST are supported
  5316. ###
  5317. ### GLOBAL marks next file as direct input to link phase of the program/shared library project built into. This prevents symbols of the file to be excluded by linker as unused.
  5318. ### The scope of the GLOBAL keyword is the following file (that is, in the case of SRCS(GLOBAL foo.cpp bar.cpp) global will be only foo.cpp)
  5319. ###
  5320. ### @example:
  5321. ###
  5322. ### LIBRARY(test_global)
  5323. ### SRCS(GLOBAL foo.cpp)
  5324. ### END()
  5325. ###
  5326. ### This will produce foo.o and feed it to any PROGRAM/DLL module transitively depending on test_global library. The library itself will be empty and won't produce .a file.
  5327. macro SRCS(FILES...) {
  5328. foreach (FILE : $FILES) {
  5329. _SRC(${lastext:FILE} $FILE)
  5330. }
  5331. }
  5332. # tag:cpu tag:src-processing
  5333. ### @usage SRC_C_SSE2(File Flags...)
  5334. ### Compile single .c-file with SSE2 and extra Flags.
  5335. macro SRC_C_SSE2(FILE, FLAGS...) {
  5336. _SRC(c $FILE $SSE2_CFLAGS $FLAGS COMPILE_OUT_SUFFIX .sse2)
  5337. }
  5338. # tag:cpu tag:src-processing
  5339. ### @usage SRC_C_SSE3(File Flags...)
  5340. ### Compile single .c-file with SSE3 and extra Flags.
  5341. macro SRC_C_SSE3(FILE, FLAGS...) {
  5342. _SRC(c $FILE $SSE3_CFLAGS $FLAGS COMPILE_OUT_SUFFIX .sse3)
  5343. }
  5344. # tag:cpu tag:src-processing
  5345. ### @usage SRC_C_SSSE3(File Flags...)
  5346. ### Compile single .c-file with SSSE3 and extra Flags.
  5347. macro SRC_C_SSSE3(FILE, FLAGS...) {
  5348. _SRC(c $FILE $SSSE3_CFLAGS $FLAGS COMPILE_OUT_SUFFIX .ssse3)
  5349. }
  5350. # tag:cpu tag:src-processing
  5351. ### @usage SRC_C_SSE41(File Flags...)
  5352. ### Compile single .c-file with SSE4.1 and extra Flags.
  5353. macro SRC_C_SSE41(FILE, FLAGS...) {
  5354. _SRC(c $FILE $SSE41_CFLAGS $FLAGS COMPILE_OUT_SUFFIX .sse41)
  5355. }
  5356. # tag:cpu tag:src-processing
  5357. ### @usage SRC_C_SSE4(File Flags...)
  5358. ### Compile single .c-file with SSE4 (SSE4.1, SSE4.2 and POPCNT) and extra Flags.
  5359. macro SRC_C_SSE4(FILE, FLAGS...) {
  5360. _SRC(c $FILE $SSE4_CFLAGS $FLAGS COMPILE_OUT_SUFFIX .sse4)
  5361. }
  5362. # tag:cpu tag:src-processing
  5363. ### @usage SRC_C_AVX(File Flags...)
  5364. ### Compile single .c-file with AVX and extra Flags.
  5365. macro SRC_C_AVX(FILE, FLAGS...) {
  5366. _SRC(c $FILE $AVX_CFLAGS $FLAGS COMPILE_OUT_SUFFIX .avx)
  5367. }
  5368. # tag:cpu tag:src-processing
  5369. ### @usage SRC_C_AVX2(File Flags...)
  5370. ### Compile single .c-file with AVX2 and extra Flags.
  5371. macro SRC_C_AVX2(FILE, FLAGS...) {
  5372. _SRC(c $FILE $AVX2_CFLAGS $FLAGS COMPILE_OUT_SUFFIX .avx2)
  5373. }
  5374. # tag:cpu tag:src-processing
  5375. ### @usage SRC_CPP_PIC(File Flags...)
  5376. ### Compile single .c-file with -fPIC and extra Flags.
  5377. macro SRC_CPP_PIC(FILE, FLAGS...) {
  5378. _SRC(cpp $FILE $PIC_CFLAGS $FLAGS)
  5379. }
  5380. # tag:cpu tag:src-processing
  5381. ### @usage SRC_CPP_NO_LTO(File)
  5382. ### Compile single .cpp file with link-time-optimization disabled
  5383. macro SRC_CPP_NO_LTO(FILE) {
  5384. _SRC(cpp $FILE $NO_LTO_CFLAGS)
  5385. }
  5386. # tag:cpu tag:src-processing
  5387. ### @usage SRC_CPP_SSE2(File Flags...)
  5388. ### Compile single .cpp-file with SSE2 and extra Flags.
  5389. macro SRC_CPP_SSE2(FILE, FLAGS...) {
  5390. _SRC(cpp $FILE $SSE2_CFLAGS $FLAGS COMPILE_OUT_SUFFIX .sse2)
  5391. }
  5392. # tag:cpu tag:src-processing
  5393. ### @usage SRC_CPP_SSE3(File Flags...)
  5394. ### Compile single .cpp-file with SSE3 and extra Flags.
  5395. macro SRC_CPP_SSE3(FILE, FLAGS...) {
  5396. _SRC(cpp $FILE $SSE3_CFLAGS $FLAGS COMPILE_OUT_SUFFIX .sse3)
  5397. }
  5398. # tag:cpu tag:src-processing
  5399. ### @usage SRC_CPP_SSSE3(File Flags...)
  5400. ### Compile single .cpp-file with SSSE3 and extra Flags.
  5401. macro SRC_CPP_SSSE3(FILE, FLAGS...) {
  5402. _SRC(cpp $FILE $SSSE3_CFLAGS $FLAGS COMPILE_OUT_SUFFIX .sss3)
  5403. }
  5404. # tag:cpu tag:src-processing
  5405. ### @usage SRC_CPP_SSE41(File Flags...)
  5406. ### Compile single .cpp-file with SSE4.1 and extra Flags.
  5407. macro SRC_CPP_SSE41(FILE, FLAGS...) {
  5408. _SRC(cpp $FILE $SSE41_CFLAGS $FLAGS COMPILE_OUT_SUFFIX .sse41)
  5409. }
  5410. # tag:cpu tag:src-processing
  5411. ### @usage SRC_CPP_SSE4(File Flags...)
  5412. ### Compile single .cpp-file with SSE4 (SSE4.1, SSE4.2 and POPCNT) and extra Flags.
  5413. macro SRC_CPP_SSE4(FILE, FLAGS...) {
  5414. _SRC(cpp $FILE $SSE4_CFLAGS $FLAGS COMPILE_OUT_SUFFIX .sse4)
  5415. }
  5416. # tag:cpu tag:src-processing
  5417. ### @usage SRC_CPP_AVX(File Flags...)
  5418. ### Compile single .cpp-file with AVX and extra Flags.
  5419. macro SRC_CPP_AVX(FILE, FLAGS...) {
  5420. _SRC(cpp $FILE $AVX_CFLAGS $FLAGS COMPILE_OUT_SUFFIX .avx)
  5421. }
  5422. # tag:cpu tag:src-processing
  5423. ### @usage SRC_CPP_AVX2(File Flags...)
  5424. ### Compile single .cpp-file with AVX2 and extra Flags.
  5425. macro SRC_CPP_AVX2(FILE, FLAGS...) {
  5426. _SRC(cpp $FILE $AVX2_CFLAGS $FLAGS COMPILE_OUT_SUFFIX .avx2)
  5427. }
  5428. # tag:python-processing tag:cython
  5429. # TODO: use it in [.pyx] cmd
  5430. ### @usage: BUILDWITH_CYTHON_CPP(Src Options...)
  5431. ###
  5432. ### Generates .cpp file from .pyx.
  5433. macro BUILDWITH_CYTHON_CPP(Src, Options...) {
  5434. .CMD=$RUN_CYTHON_SCRIPT $CYTHON_OPTIONS ${Options} --cplus ${CYTHON_CPP_OUTPUT_INCLUDES} ${pre=-I:_CYTHON__INCLUDE} ${input:Src} -o ${output;tobindir:Src.cpp} $CYTHON_OUTPUT_INCLUDES ${kv;hide:"p CY"} ${kv;hide:"pc yellow"}
  5435. ADDINCL(FOR cython contrib/tools/cython/Cython/Includes)
  5436. }
  5437. # tag:python-processing tag:cython tag:internal
  5438. ### @usage: _BUILDWITH_CYTHON_CPP_DEP(Src Dep Options...) # internal
  5439. ###
  5440. ### Generates .cpp file from .pyx and attach extra input Dep.
  5441. ### If Dep changes the .cpp file will be re-generated.
  5442. macro _BUILDWITH_CYTHON_CPP_DEP(Src, Dep, Options...) {
  5443. .CMD=$RUN_CYTHON_SCRIPT $CYTHON_OPTIONS ${Options} --cplus ${CYTHON_CPP_OUTPUT_INCLUDES} ${pre=-I:_CYTHON__INCLUDE} ${input:Src} ${input;hide:Dep} -o ${output;tobindir:Src.cpp} $CYTHON_OUTPUT_INCLUDES ${kv;hide:"p CY"} ${kv;hide:"pc yellow"}
  5444. ADDINCL(FOR cython contrib/tools/cython/Cython/Includes)
  5445. }
  5446. # tag:python-processing tag:cython
  5447. ### @usage: BUILDWITH_CYTHON_C(Src Options...)
  5448. ###
  5449. ### Generates .c file from .pyx.
  5450. macro BUILDWITH_CYTHON_C(Src, Options...) {
  5451. .CMD=$RUN_CYTHON_SCRIPT $CYTHON_OPTIONS ${Options} ${pre=-I:_CYTHON__INCLUDE} ${input:Src} -o ${output;tobindir:Src.c} $CYTHON_OUTPUT_INCLUDES ${kv;hide:"p CY"} ${kv;hide:"pc yellow"}
  5452. ADDINCL(FOR cython contrib/tools/cython/Cython/Includes)
  5453. }
  5454. # tag:python-processing tag:cython tag:internal
  5455. ### @usage: _BUILDWITH_CYTHON_C_DEP(Src Dep Options...) # internal
  5456. ###
  5457. ### Generates .c file from .pyx and attach extra input Dep.
  5458. ### If Dep changes the .c file will be re-generated.
  5459. macro _BUILDWITH_CYTHON_C_DEP(Src, Dep, Options...) {
  5460. .CMD=$RUN_CYTHON_SCRIPT $CYTHON_OPTIONS ${Options} ${pre=-I:_CYTHON__INCLUDE} ${input:Src} ${input;hide:Dep} -o ${output;tobindir:Src.c} $CYTHON_OUTPUT_INCLUDES ${kv;hide:"p CY"} ${kv;hide:"pc yellow"}
  5461. ADDINCL(FOR cython contrib/tools/cython/Cython/Includes)
  5462. }
  5463. # tag:python-processing tag:cython tag:internal
  5464. ### @usage: _BUILDWITH_CYTHON_C_H(Src Dep Options...) # internal
  5465. ###
  5466. ### BUILDWITH_CYTHON_C without .pyx infix and with cdef public .h file.
  5467. macro _BUILDWITH_CYTHON_C_H(Src, Dep, Options...) {
  5468. .CMD=$RUN_CYTHON_SCRIPT $CYTHON_OPTIONS ${Options} ${pre=-I:_CYTHON__INCLUDE} ${input:Src} ${input;hide:Dep} -o ${output;noext;tobindir:Src.c} ${output;hide;addincl;noext;tobindir:Src.h} $CYTHON_OUTPUT_INCLUDES ${kv;hide:"p CY"} ${kv;hide:"pc yellow"}
  5469. ADDINCL(FOR cython contrib/tools/cython/Cython/Includes)
  5470. }
  5471. # tag:python-processing tag:cython tag:internal
  5472. ### @usage: _BUILDWITH_CYTHON_C_API_H(Src Dep Options...) # internal
  5473. ###
  5474. ### BUILDWITH_CYTHON_C_H with cdef api _api.h file.
  5475. macro _BUILDWITH_CYTHON_C_API_H(Src, Dep, Options...) {
  5476. .CMD=$RUN_CYTHON_SCRIPT $CYTHON_OPTIONS ${Options} ${pre=-I:_CYTHON__INCLUDE} ${input:Src} ${input;hide:Dep} -o ${output;noext;tobindir:Src.c} ${output;hide;addincl;noext;tobindir:Src.h} ${output;hide;addincl;noext;defext=_api.h;tobindir:Src} $CYTHON_OUTPUT_INCLUDES ${kv;hide:"p CY"} ${kv;hide:"pc yellow"}
  5477. ADDINCL(FOR cython contrib/tools/cython/Cython/Includes)
  5478. }
  5479. # tag:python-processing tag:internal
  5480. ### @usage: _SWIG_PYTHON_CPP(Src, DstSubPrefix) # internal
  5481. ###
  5482. ### Run swig on Src to produce DstSubPrefix.py and DstSubPrefix_swg.cpp that
  5483. ### provides DstSubPrefix_swg python module.
  5484. macro _SWIG_PYTHON_CPP(Src, DstSubPrefix) {
  5485. .CMD=$_SWIG_TOOL -I$ARCADIA_BUILD_ROOT -I$ARCADIA_ROOT -I$_SWIG_LIBRARY_ABS/python -I$_SWIG_LIBRARY_ABS -c++ -python -module ${nopath:DstSubPrefix} -interface ${nopath;suf=_swg:DstSubPrefix} -o ${output;suf=.swg.cpp:DstSubPrefix} ${input:Src} ${output;noauto;hide;suf=.py:DstSubPrefix} ${kv;hide:"p SW"} ${kv;hide:"pc yellow"}
  5486. ADDINCL(FOR swig $_SWIG_LIBRARY/python FOR swig $_SWIG_LIBRARY)
  5487. }
  5488. # tag:python-processing tag:internal
  5489. ### @usage: _SWIG_PYTHON_C(Src, DstSubPrefix) # internal
  5490. ###
  5491. ### Like _SWIG_PYTHON_CPP but generate DstSubPrefix_swg.c.
  5492. macro _SWIG_PYTHON_C(Src, DstSubPrefix) {
  5493. .CMD=$_SWIG_TOOL -I$ARCADIA_BUILD_ROOT -I$ARCADIA_ROOT -I$_SWIG_LIBRARY_ABS/python -I$_SWIG_LIBRARY_ABS -python -module ${nopath:DstSubPrefix} -interface ${nopath;suf=_swg:DstSubPrefix} -o ${output;suf=.swg.c:DstSubPrefix} ${input:Src} ${output;noauto;hide;suf=.py:DstSubPrefix} ${kv;hide:"p SW"} ${kv;hide:"pc yellow"}
  5494. ADDINCL(FOR swig $_SWIG_LIBRARY/python FOR swig $_SWIG_LIBRARY)
  5495. }
  5496. ### @usage: BUILDWITH_RAGEL6(Src Options...)
  5497. ###
  5498. ### Compile .rl file using Ragel6.
  5499. macro BUILDWITH_RAGEL6(Src, Options...) {
  5500. .CMD=$RUN_NO_SANITIZE ${tool:"contrib/tools/ragel6"} $RAGEL6_FLAGS ${Options} -I${ARCADIA_ROOT} -o ${output;nopath;noext;defext=.rl6.cpp:Src} ${input:Src} ${kv;hide:"p R6"} ${kv;hide:"pc yellow"}
  5501. }
  5502. # tag:python-processing tag:internal
  5503. # TODO: use it in [.pyx] cmd
  5504. ### @usage: _PY_REGISTER() # internal
  5505. ###
  5506. ### Register Python 2.x module in internal resource file system. Arcadia Python 2.x importer will be retrieve these on import directive.
  5507. ###
  5508. ### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/pysrcs/#makrospyregister
  5509. macro _PY_REGISTER(Func) {
  5510. .CMD=$YMAKE_PYTHON ${input:"build/scripts/gen_py_reg.py"} $Func ${output;noauto:Func.reg.cpp} ${kv;hide:"p PY"} ${kv;hide:"pc yellow"}
  5511. SRCS(GLOBAL $Func.reg.cpp)
  5512. }
  5513. # tag:python-processing tag:internal
  5514. ### @usage: _PY3_REGISTER() # internal
  5515. ###
  5516. ### Register Python 3.x module in internal resource file system. Arcadia Python 3.x importer will be retrieve these on import directive
  5517. ###
  5518. ### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/pysrcs/#makrospyregister
  5519. macro _PY3_REGISTER(Func) {
  5520. .CMD=$YMAKE_PYTHON ${input:"build/scripts/gen_py3_reg.py"} $Func ${output;noauto:Func.reg3.cpp} ${kv;hide:"p PY"} ${kv;hide:"pc yellow"}
  5521. SRCS(GLOBAL $Func.reg3.cpp)
  5522. }
  5523. # tag:python-processing tag:internal
  5524. ### @usage: _PY_COMPILE_BYTECODE(SrcX Src) # internal
  5525. ###
  5526. ### Compile Python 2.x .py source file into Arcadia binary form suitable for PY2_PROGRAM
  5527. ###
  5528. ### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/pysrcs/#makrospyregister
  5529. macro _PY_COMPILE_BYTECODE(SrcX, Src, Dst) {
  5530. .CMD=$YMAKE_PYTHON ${input:"build/scripts/py_compile.py"} $SrcX ${input:Src} ${output;noauto:Dst.yapyc} ${kv;hide:"p PY"} ${kv;hide:"pc yellow"}
  5531. }
  5532. # tag:python-processing tag:internal
  5533. ### @usage: _PY3_COMPILE_BYTECODE(SrcX Src) # internal
  5534. ###
  5535. ### Compile Python 3.x .py source file into Arcadia binary form suitable for PY3_PROGRAM
  5536. ###
  5537. ### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/pysrcs/#makrospyregister
  5538. macro _PY3_COMPILE_BYTECODE(SrcX, Src, Dst) {
  5539. .CMD=${env:"PYTHONHASHSEED=0"} ${tool:"contrib/tools/python3/pycc"} $SrcX ${input:Src} ${output;noauto:Dst.yapyc3} ${kv;hide:"p PY"} ${kv;hide:"pc yellow"}
  5540. }
  5541. macro _ARCHIVE_SEM_HELPER(OUT, DONTCOMPRESS, Files...) {
  5542. .SEM=add_custom_command OUTPUT ${OUT} DEPENDS ${Files} COMMAND $ARCH_TOOL -q $DONTCOMPRESS ${join=\: :Files}: -o ${OUT}
  5543. }
  5544. ### @usage: ARCHIVE_ASM(NAME archive_name files...)
  5545. ###
  5546. ### Similar to the macro ARCHIVE, but:
  5547. ### 1. works faster and it is better to use for large files.
  5548. ### 2. Different syntax (see examples in codesearch or users/pg/tests/archive_test)
  5549. macro ARCHIVE_ASM(NAME="", DONTCOMPRESS?"-p":"", Files...) {
  5550. .CMD=$ARCH_TOOL -q $DONTCOMPRESS ${input;join=\: :Files}: -o ${output;chksum;suf=$OBJ_SUF.rodata:NAME} ${kv;hide:"p AR"} ${kv;hide:"pc light-cyan"}
  5551. .SEM=$_ARCHIVE_SEM_HELPER(${output;suf=$OBJ_SUF.rodata:NAME}, $DONTCOMPRESS, ${input:Files})
  5552. }
  5553. # tag:yweb-specific
  5554. macro PIRE_INLINE_CMD(SRC) {
  5555. .CMD=${tool:"library/cpp/regex/pire/inline"} -o ${output:SRC} ${input:SRC} ${output_include;hide:SRC} ${kv;hide:"p PI"} ${kv;hide:"pc yellow"}
  5556. }
  5557. # tag:yweb-specific
  5558. macro PIRE_INLINE(FILES...) {
  5559. foreach (FILE : $FILES) {
  5560. PIRE_INLINE_CMD($FILE)
  5561. }
  5562. }
  5563. ### @usage: ARCHIVE(archive_name [DONT_COMPRESS] files...)
  5564. ###
  5565. ### Add arbitrary data to a modules. Unlike RESOURCE macro the result should be futher processed by othet macros in the module.
  5566. ###
  5567. ### Example: https://wiki.yandex-team.ru/yatool/howtowriteyamakefiles/#a1ispolzujjtekomanduarchive
  5568. macro ARCHIVE(NAME="", DONTCOMPRESS?"-p":"", Files...) {
  5569. .CMD=$ARCH_TOOL -q -x $DONTCOMPRESS ${input;join=\: :Files}: -o ${output;chksum;addincl;noauto:NAME} ${kv;hide:"p AR"} ${kv;hide:"pc light-red"}
  5570. .SEM=$_ARCHIVE_SEM_HELPER(${output;addincl;noauto:NAME}, $DONTCOMPRESS, ${input:Files})
  5571. }
  5572. ### @usage: ARCHIVE_BY_KEYS(archive_name key [DONT_COMPRESS] files...)
  5573. ###
  5574. ### Add arbitrary data to a module be accessible by specified key.
  5575. ### Unlike RESOURCE macro the result should be futher processed by othet macros in the module.
  5576. ###
  5577. ### Example: https://wiki.yandex-team.ru/yatool/howtowriteyamakefiles/#a1ispolzujjtekomanduarchive
  5578. macro ARCHIVE_BY_KEYS(NAME="", KEYS="", DONTCOMPRESS?"-p":"", Files...) {
  5579. .CMD=$ARCH_TOOL -q -x $DONTCOMPRESS ${input:Files} -k $KEYS -o ${output;chksum;addincl;noauto:NAME} ${kv;hide:"p AR"} ${kv;hide:"pc light-red"}
  5580. }
  5581. #scripts
  5582. #special commands
  5583. BUILDVERSION_SCRIPT=build/scripts/build_info_gen.py
  5584. SVNVERSION_JAVA_MARKER=output-java-class
  5585. SVNVERSION_GO_MARKER=output-go
  5586. VCS_C_OBJ=$BINDIR/__vcs_version__.c$OBJECT_SUF
  5587. VCS_C_OBJ_RR=$MODDIR/__vcs_version__.c$OBJECT_SUF
  5588. VCS_C=$BINDIR/__vcs_version__.c
  5589. VCS_GO=$BINDIR/__vcs_version__.go
  5590. VCS_JAVA=$BINDIR/__vcs_version__.mf
  5591. VCS_INFO_DISABLE_CACHE__NO_UID__=
  5592. YASM_DEBUG_INFO_DISABLE_CACHE__NO_UID__=
  5593. CL_DEBUG_INFO_DISABLE_CACHE__NO_UID__=
  5594. CL_MACRO_INFO_DISABLE_CACHE__NO_UID__=
  5595. YASM_DEBUG_INFO=
  5596. CL_DEBUG_INFO=
  5597. CL_MACRO_INFO=
  5598. when ($FORCE_VCS_INFO_UPDATE == "yes") {
  5599. VCS_INFO_DISABLE_CACHE__NO_UID__=${hide;kv:"disable_cache"}
  5600. }
  5601. ### Works for pyton too.
  5602. GENERATE_VCS_C_INFO_NODEP=$YMAKE_PYTHON ${input:"build/scripts/vcs_info.py"} $(VCS)/vcs.json $VCS_C ${input:"build/scripts/c_templates/svn_interface.c"} $VCS_INFO_DISABLE_CACHE__NO_UID__ && $_SRC_c_nodeps($VCS_C, $VCS_C_OBJ, $(SOURCE_ROOT))
  5603. GENERATE_VCS_GO_INFO_NODEP=$YMAKE_PYTHON ${input:"build/scripts/vcs_info.py"} output-go $(VCS)/vcs.json $VCS_GO $VCS_INFO_DISABLE_CACHE__NO_UID__
  5604. GENERATE_VCS_JAVA_INFO_NODEP=$YMAKE_PYTHON ${input:"build/scripts/vcs_info.py"} output-java $(VCS)/vcs.json $VCS_JAVA $VCS_INFO_DISABLE_CACHE__NO_UID__
  5605. macro UPDATE_VCS_JAVA_INFO_NODEP(Jar) {
  5606. .CMD=$YMAKE_PYTHON ${input:"build/scripts/vcs_info.py"} output-java $(VCS)/vcs.json $VCS_JAVA $Jar $VCS_INFO_DISABLE_CACHE__NO_UID__
  5607. }
  5608. ### @usage: CREATE_BUILDINFO_FOR(GenHdr)
  5609. ###
  5610. ### Creates header file to access some information about build specified via configuration variables.
  5611. ### Unlike CREATE_SVNVERSION_FOR() it doesn't take revion information from VCS, it uses revision and SandboxTaskId passed via -D options to ya make
  5612. macro CREATE_BUILDINFO_FOR(GenHdr) {
  5613. .CMD=$YIELD $CXX_COMPILER && $YIELD $CXXFLAGS && $XARGS $YMAKE_PYTHON ${input:BUILDVERSION_SCRIPT} ${output:GenHdr} ${kv;hide:"p BI"} ${kv;hide:"pc yellow"} ${hide;kv:"show_out"} $SVN_DEPENDS_CACHE__NO_UID__
  5614. .SEM=$PYTHON($BUILDVERSION_SCRIPT $GenHdr \\\"${CMAKE_CXX_COMPILER}\\\" \\\"${CMAKE_CXX_FLAGS}\\\" OUT $GenHdr)
  5615. }
  5616. DECIMAL_MD5_SCRIPT=build/scripts/decimal_md5.py
  5617. DECIMAL_MD5_FIXED=
  5618. ### @usage: DECIMAL_MD5_LOWER_32_BITS(<fileName> [FUNCNAME funcName] [inputs...])
  5619. ###
  5620. ### Generates .cpp file <fileName> with one defined function 'const char* <funcName>() { return "<calculated_md5_hash>"; }'.
  5621. ### <calculated_md5_hash> will be md5 hash for all inputs passed to this macro.
  5622. macro DECIMAL_MD5_LOWER_32_BITS(File, FUNCNAME="", Opts...) {
  5623. .CMD=$YMAKE_PYTHON ${input:DECIMAL_MD5_SCRIPT} --fixed-output=${DECIMAL_MD5_FIXED} --func-name=${FUNCNAME} --lower-bits 32 --source-root=$ARCADIA_ROOT ${input;context=TEXT:Opts} ${output;stdout;chksum:File} ${kv;hide:"p SV"} ${kv;hide:"pc yellow"} ${hide;kv:"show_out"}
  5624. }
  5625. # tag:internal
  5626. ### @usage $CFG_VARS # internal
  5627. ###
  5628. ### Mark commands that embed Configuration variables into files
  5629. macro CFG_VARS() {
  5630. .GEN_FROM_FILE=yes
  5631. }
  5632. ### @usage: CONFIGURE_FILE(from to)
  5633. ###
  5634. ### Copy file with the replacement of configuration variables in form of @ANY_CONF_VAR@ with their values.
  5635. ### The values are collected during configure stage, while replacement itself happens during build stage.
  5636. ### Used implicitly for .in-files processing.
  5637. macro CONFIGURE_FILE(Src, Dst) {
  5638. .CMD=$YMAKE_PYTHON ${input:"build/scripts/configure_file.py"} ${input:Src} ${output;addincl:Dst} $CFG_VARS ${kv;hide:"p CF"} ${kv;hide:"pc yellow"}
  5639. .SEM=set_vars ${CFG_VARS} && configure_file $S/${input;rootrel:Src} $B/${output;rootrel:Dst}
  5640. }
  5641. ### @usage: BASE_CODEGEN(tool_path prefix)
  5642. ###
  5643. ### Generator ${prefix}.cpp + ${prefix}.h files based on ${prefix}.in.
  5644. macro BASE_CODEGEN(Tool, Prefix, Opts...) {
  5645. .CMD=${tool:Tool} ${input:Prefix.in} ${output;nopath;noauto:Prefix.cpp} ${output;nopath:Prefix.h} $Opts ${kv;hide:"p BC"} ${kv;hide:"pc yellow"}
  5646. }
  5647. # tag:internal
  5648. ### @usage: _SPLIT_CODEGEN_BASE(tool prefix OUTS[] OUTPUT_INCLUDES[]) # internal
  5649. ###
  5650. ### Generator of a certain number .the. cpp file + one header .h file from .in.
  5651. ### This is the call of the generator. Python macro SPLIT_CODEGEN() is defined in order to properly fill command outputs from OUT_NUM argument.
  5652. macro _SPLIT_CODEGEN_BASE(Tool, Prefix, OUT[], OPTS[], OUTPUT_INCLUDES[]) {
  5653. .CMD=${tool:Tool} ${input:Prefix.in} ${output;hide:OUT} ${output;nopath;noauto:Prefix.cpp} ${output;nopath:Prefix.h} $OPTS ${output_include;hide:OUTPUT_INCLUDES} ${kv;hide:"p SC"} ${kv;hide:"pc yellow"}
  5654. }
  5655. STRUCT_CODEGEN_OUTPUT_INCLUDES=${output_include;hide:"util/generic/singleton.h"} \
  5656. ${output_include;hide:"util/generic/strbuf.h"} \
  5657. ${output_include;hide:"util/generic/vector.h"} \
  5658. ${output_include;hide:"util/generic/ptr.h"} \
  5659. ${output_include;hide:"util/generic/yexception.h"} \
  5660. ${output_include;hide:"kernel/struct_codegen/reflection/reflection.h"} \
  5661. ${output_include;hide:"kernel/struct_codegen/reflection/floats.h"}
  5662. ### @usage: STRUCT_CODEGEN(Prefix)
  5663. ### A special case BASE_CODEGEN, in which the kernel/struct_codegen/codegen_tool tool is used.
  5664. macro STRUCT_CODEGEN(Prefix) {
  5665. .CMD=$BASE_CODEGEN(kernel/struct_codegen/codegen_tool, $Prefix, $STRUCT_CODEGEN_OUTPUT_INCLUDES)
  5666. .PEERDIR=kernel/struct_codegen/metadata kernel/struct_codegen/reflection
  5667. }
  5668. ### @usage: DUMPERF_CODEGEN(Prefix)
  5669. ### A special case BASE_CODEGEN, in which the extsearch/images/robot/tools/dumperf/codegen tool is used
  5670. macro DUMPERF_CODEGEN(Prefix) {
  5671. .CMD=$BASE_CODEGEN(extsearch/images/robot/tools/dumperf/codegen, $Prefix, ${output_include;hide:"extsearch/images/kernel/erf/erf_format.h"})
  5672. }
  5673. # tag:flags
  5674. ### @usage: LDFLAGS(LinkerFlags...)
  5675. ###
  5676. ### Add flags to the link command line of executable or shared library/dll.
  5677. ### Note: LDFLAGS are always global. When set in the LIBRARY module they will affect all programs/dlls/tests the library is linked into.
  5678. ### Note: remember about the incompatibility of flags for gcc and cl.
  5679. macro LDFLAGS(Flags...) {
  5680. SET_APPEND(LDFLAGS_GLOBAL $Flags)
  5681. }
  5682. # tag:flags
  5683. ### @usage: CFLAGS([GLOBAL compiler_flag]* compiler_flags)
  5684. ###
  5685. ### Add the specified flags to the compilation command of C and C++ files.
  5686. ### @params: GLOBAL - Propagates these flags to dependent projects
  5687. ### Note: remember about the incompatibility flags for clang and cl (to set flags specifically for cl.exe use MSVC_FLAGS).
  5688. macro CFLAGS(Flags...) {
  5689. SET_APPEND_WITH_GLOBAL(USER_CFLAGS $Flags)
  5690. }
  5691. # tag:flags
  5692. ### @usage: MASMFLAGS(compiler flags)
  5693. ### Add the specified flags to the compilation command of .masm files.
  5694. macro MASMFLAGS(Flags...) {
  5695. SET_APPEND(MASMFLAGS $Flags)
  5696. }
  5697. # tag:flags
  5698. ### @usage: CONLYFLAGS([GLOBAL compiler_flag]* compiler_flags)
  5699. ### Add the specified flags to the compilation command of .c (but not .cpp) files.
  5700. ### @params: GLOBAL - Distributes these flags on dependent projects
  5701. macro CONLYFLAGS(Flags...) {
  5702. SET_APPEND_WITH_GLOBAL(USER_CONLYFLAGS $Flags)
  5703. }
  5704. # tag:flags
  5705. ### @usage: CXXFLAGS(compiler_flags)
  5706. ### Add the specified flags to the compilation command of .cpp (but not .c) files.
  5707. macro CXXFLAGS(Flags...) {
  5708. SET_APPEND_WITH_GLOBAL(USER_CXXFLAGS $Flags)
  5709. }
  5710. # tag:flags
  5711. ### @usage: CUDA_NVCC_FLAGS(compiler flags)
  5712. ### Add the specified flags to the compile line .cu-files.
  5713. macro CUDA_NVCC_FLAGS(Flags...) {
  5714. SET_APPEND(CUDA_NVCC_FLAGS $Flags)
  5715. }
  5716. # tag:flags
  5717. ### @usage: NVCC_DEVICE_LINK(file.cu...)
  5718. ### Run nvcc --device-link on objects compiled from srcs with --device-c.
  5719. ### This generates a stub object devlink.o that supplies missing pieces for the
  5720. ### host linker to link relocatable device objects into the final executable.
  5721. macro NVCC_DEVICE_LINK(Srcs...) {
  5722. .CMD=$NVCC $NVCC_FLAGS -o ${output;suf=${OBJ_SUF}${NVCC_OBJ_EXT}:"devlink"} -dlink ${input;suf=${OBJ_SUF}${NVCC_OBJ_EXT}:Srcs} ${kv;hide:"p DL"} ${kv;hide:"pc light-blue"}
  5723. }
  5724. ### @usage: STRIP()
  5725. ### Strip debug info from a PROGRAM, DLL or TEST.
  5726. ### This macro doesn't work in LIBRARY's, UNION's and PACKAGE's.
  5727. macro STRIP() {
  5728. ENABLE(STRIP)
  5729. }
  5730. ### @usage: NO_OPTIMIZE()
  5731. ### Build code without any optimizations (-O0 mode).
  5732. macro NO_OPTIMIZE() {
  5733. ENABLE(NO_OPTIMIZE)
  5734. }
  5735. ### @usage: NO_COMPILER_WARNINGS()
  5736. ### Disable all compiler warnings in the module.
  5737. ### Priorities: NO_COMPILER_WARNINGS > NO_WERROR > WERROR_MODE > WERROR.
  5738. macro NO_COMPILER_WARNINGS() {
  5739. ENABLE(NO_COMPILER_WARNINGS)
  5740. }
  5741. ### @usage: WERROR()
  5742. ### Consider warnings as errors in the current module.
  5743. ### In the bright future will be removed, since WERROR is the default.
  5744. ### Priorities: NO_COMPILER_WARNINGS > NO_WERROR > WERROR_MODE > WERROR.
  5745. macro WERROR() {
  5746. ENABLE(WERROR)
  5747. }
  5748. ### @usage: NO_WERROR()
  5749. ### Override WERROR() behavior
  5750. ### Priorities: NO_COMPILER_WARNINGS > NO_WERROR > WERROR_MODE > WERROR.
  5751. macro NO_WERROR() {
  5752. DISABLE(WERROR)
  5753. }
  5754. ### @usage: NO_WSHADOW()
  5755. ### Disable C++ shadowing warnings.
  5756. macro NO_WSHADOW() {
  5757. ENABLE(NO_WSHADOW)
  5758. }
  5759. # tag:internal
  5760. ### @usage: NO_PLATFORM_RESOURCES() # internal
  5761. ### Exclude dependency on platform resources libraries.
  5762. ### Most probably you'll never need this. If you think you need, please contact devtools@ for assistance.
  5763. macro NO_PLATFORM_RESOURCES() {
  5764. ENABLE(NOPLATFORM_RESOURCES)
  5765. }
  5766. # tag:internal tag:codenav
  5767. ### @usage: NO_CODENAVIGATION() # internal
  5768. ### Disable codenaviagtion for a module. Needed to avoid PEERDIR loops in codenavigation support.
  5769. ### Most probably you'll never need this. If you think you need, please contact devtools@ for assistance.
  5770. macro NO_CODENAVIGATION() {
  5771. ENABLE(NOCODENAVIGATION)
  5772. }
  5773. ### @usage: NO_UTIL()
  5774. ### Build module without dependency on util.
  5775. ### Note: use this with care. Util most likely will be linked into executable anyway,
  5776. ### so using util headers/functions/classes may not be detected at build time and may lead to unpredictable behavors at configure time.
  5777. macro NO_UTIL() {
  5778. ENABLE(NOUTIL)
  5779. }
  5780. ### @usage: NO_RUNTIME()
  5781. ###
  5782. ### This macro:
  5783. ### 1. Sets the ENABLE(NOUTIL) + DISABLE(USE_INTERNAL_STL);
  5784. ### 2. If the project that contains the macro NO_RUNTIME(), peerdir-it project does not contain NO_RUNTIME() => Warning.
  5785. ### Note: use this with care. Arcadia STL most likely will be linked into executable anyway, so using STL headers/functions/classes
  5786. ### may not be detected at build time and may lead to unpredictable behavors at configure time.
  5787. macro NO_RUNTIME() {
  5788. SET(USE_ARCADIA_LIBM no)
  5789. NO_UTIL()
  5790. ENABLE(NORUNTIME)
  5791. }
  5792. ### @usage: NO_LIBC()
  5793. ###
  5794. ### Exclude dependencies on C++ and C runtimes (including util, musl and libeatmydata).
  5795. ### Note: use this with care. libc most likely will be linked into executable anyway,
  5796. ### so using libc headers/functions may not be detected at build time and may lead to unpredictable behavors at configure time.
  5797. macro NO_LIBC() {
  5798. NO_RUNTIME()
  5799. DISABLE(MUSL)
  5800. }
  5801. ### @usage: NO_PLATFORM()
  5802. ###
  5803. ### Exclude dependencies on C++ and C runtimes (including util, musl and libeatmydata) and set NO_PLATFORM variable for special processing.
  5804. ### Note: use this with care. libc most likely will be linked into executable anyway,
  5805. ### so using libc headers/functions may not be detected at build time and may lead to unpredictable behavors at configure time.
  5806. macro NO_PLATFORM() {
  5807. NO_LIBC()
  5808. ENABLE(NOPLATFORM)
  5809. }
  5810. # tag:cpp-specific
  5811. ### @usage: USE_CXX()
  5812. ###
  5813. ### Add dependency on C++ runtime
  5814. ### Note: This macro is inteneded for use in _GO_BASE_UNIT like module when the module is built without C++ runtime by default
  5815. macro USE_CXX() {
  5816. DISABLE(NORUNTIME)
  5817. }
  5818. ### @usage: USE_UTIL()
  5819. ###
  5820. ### Add dependency on util and C++ runtime
  5821. ### Note: This macro is intended for use in _GO_BASE_UNIT like module when the module is build without util by default
  5822. macro USE_UTIL() {
  5823. USE_CXX()
  5824. DISABLE(NOUTIL)
  5825. }
  5826. # tag:deprecated
  5827. ### @usage: NO_JOIN_SRC() # deprecated, does-nothing
  5828. ### This macro currently does nothing. This is default behavior which cannot be overridden at module level.
  5829. macro NO_JOIN_SRC() {
  5830. ENABLE(UNUSED_MACRO)
  5831. }
  5832. # tag:deprecated
  5833. ### @usage: JOINSRC() # deprecated, does-nothing
  5834. ### This macro currently does nothing. Use JOIN_SRCS and similar macros to make one file of set of sources.
  5835. macro JOINSRC() {
  5836. ENABLE(UNUSED_MACRO)
  5837. }
  5838. # tag:sanitize
  5839. ### @usage: NO_SANITIZE()
  5840. ###
  5841. ### Disable all sanitizers for the module.
  5842. macro NO_SANITIZE() {
  5843. DISABLE(SANITIZER_TYPE)
  5844. }
  5845. # tag:coverage tag:sanitize
  5846. ### @usage: NO_SANITIZE_COVERAGE()
  5847. ###
  5848. ### Disable lightweight coverage (-fsanitize-coverage) for the module.
  5849. macro NO_SANITIZE_COVERAGE() {
  5850. DISABLE(SANITIZE_COVERAGE)
  5851. }
  5852. # tag:coverage
  5853. ### @usage: NO_CLANG_COVERAGE()
  5854. ###
  5855. ### Disable heavyweight clang coverage for the module
  5856. macro NO_CLANG_COVERAGE() {
  5857. DISABLE(CLANG_COVERAGE)
  5858. }
  5859. macro NO_CLANG_TIDY() {
  5860. DISABLE(TIDY)
  5861. }
  5862. # tag:python-specific tag:coverage
  5863. ### @usage: NO_PYTHON_COVERAGE()
  5864. ###
  5865. ### Disable python coverage for module
  5866. macro NO_PYTHON_COVERAGE() {
  5867. DISABLE(PYTHON_COVERAGE)
  5868. }
  5869. # tag:python-specific tag:coverage tag:cython
  5870. ### @usage: NO_CYTHON_COVERAGE()
  5871. ###
  5872. ### Disable cython and cythonized python coverage (CYTHONIZE_PY)
  5873. ### Implies NO_CLANG_COVERAGE() - right now, we can't disable instrumentation for .py.cpp files, but enable for .cpp
  5874. macro NO_CYTHON_COVERAGE() {
  5875. DISABLE(CYTHON_COVERAGE)
  5876. NO_CLANG_COVERAGE()
  5877. }
  5878. # tag:lua-specific
  5879. LUAJIT_PATH=${ARCADIA_ROOT}/contrib/libs/luajit
  5880. macro _LUAJIT_OBJDUMP(Src, OUT="") {
  5881. .CMD=${cwd:LUAJIT_PATH} ${tool:"contrib/libs/luajit/compiler"} -b -g ${input:Src} ${output;noauto:OUT} ${kv;hide:"p LJ"} ${kv;hide:"pc light-cyan"}
  5882. }
  5883. # tag:lua-specific
  5884. LUAJIT_21_PATH=${ARCADIA_ROOT}/contrib/libs/luajit_21
  5885. macro _LUAJIT_21_OBJDUMP(Src, OUT="") {
  5886. .CMD=${cwd:LUAJIT_21_PATH} ${tool:"contrib/libs/luajit_21/compiler"} -b -g ${input:Src} ${output;noauto:OUT} ${kv;hide:"p LJ"} ${kv;hide:"pc light-cyan"}
  5887. }
  5888. macro _MX_BIN_TO_INFO(Src) {
  5889. .CMD=${tool:"tools/mx_bin2info"} ${input:Src} ${output;nopath;noext;noauto:Src.info} ${kv;hide:"p MX"} ${kv;hide:"pc yellow"}
  5890. }
  5891. MX_GEN_TABLE_INCLS=${output_include;hide:"yabs_mx_calc_table.h"} \
  5892. ${output_include;hide:"kernel/matrixnet/mn_sse.h"} \
  5893. ${output_include;hide:"library/cpp/archive/yarchive.h"} \
  5894. ${output_include;hide:"util/memory/blob.h"} \
  5895. ${output_include;hide:"util/generic/hash.h"} \
  5896. ${output_include;hide:"util/generic/ptr.h"} \
  5897. ${output_include;hide:"util/generic/singleton.h"}
  5898. macro _MX_GEN_TABLE(Srcs...) {
  5899. .CMD=$YMAKE_PYTHON ${input:"build/scripts/gen_mx_table.py"} $Srcs ${output;stdout:"mx_tables.cpp"} $MX_GEN_TABLE_INCLS ${kv;hide:"p MX"} ${kv;hide:"pc yellow"}
  5900. PEERDIR(kernel/matrixnet)
  5901. PEERDIR(library/cpp/archive)
  5902. }
  5903. RELEV_FML_CODEGEN_INCLS=${output_include;hide:"kernel/relevfml/relev_fml.h"} ${output_include;hide:"library/cpp/sse/sse.h"}
  5904. ### @usage: GENERATE_ENUM_SERIALIZATION(File.h)
  5905. ###
  5906. ### Create serialization support for enumeration members defined in the header (String <-> Enum conversions) and compile it into the module.
  5907. ###
  5908. ### Documentation: https://wiki.yandex-team.ru/yatool/HowToWriteYaMakeFiles/
  5909. macro GENERATE_ENUM_SERIALIZATION(File) {
  5910. .CMD=$ENUM_PARSER_TOOL ${input:File} --include-path ${input;rootrel:File} --output ${output;chksum;suf=_serialized.cpp:File} ${output_include;hide:File} ${output_include;hide:"util/generic/serialized_enum.h"} ${kv;hide:"p EN"} ${kv;hide:"pc yellow"}
  5911. .SEM=generate_enum_serilization ${input:File} ${output;hide;suf=_serialized.o:File} INCLUDE_HEADERS ${input;rootrel:File} ${tool;hide:"tools/enum_parser/enum_parser/bin"}
  5912. PEERDIR(tools/enum_parser/enum_serialization_runtime)
  5913. }
  5914. ### @usage: GENERATE_ENUM_SERIALIZATION_WITH_HEADER(File.h)
  5915. ###
  5916. ### Create serialization support for enumeration members defined in the header (String <-> Enum conversions) and compile it into the module
  5917. ### Provide access to serialization functions via generated header File_serialized.h
  5918. ###
  5919. ### Documentation: https://wiki.yandex-team.ru/yatool/HowToWriteYaMakeFiles/
  5920. macro GENERATE_ENUM_SERIALIZATION_WITH_HEADER(File) {
  5921. .CMD=$ENUM_PARSER_TOOL ${input:File} --include-path ${input;rootrel:File} --output ${output;chksum;suf=_serialized.cpp:File} --header ${output;chksum;suf=_serialized.h:File} ${output_include;hide:File} ${kv;hide:"p EN"} ${kv;hide:"pc yellow"}
  5922. .SEM=generate_enum_serilization ${input:File} ${output;hide;suf=_serialized.o:File} GEN_HEADER ${output;suf=_serialized.h:File} INCLUDE_HEADERS ${input;rootrel:File} ${tool;hide:"tools/enum_parser/enum_parser/bin"}
  5923. PEERDIR(tools/enum_parser/enum_serialization_runtime)
  5924. }
  5925. ### @usage: DEB_VERSION(File)
  5926. ###
  5927. ### Creates a header file DebianVersion.h define the DEBIAN_VERSION taken from the File.
  5928. macro DEB_VERSION(File) {
  5929. .CMD=$YMAKE_PYTHON ${input:"build/scripts/mkver.py"} ${input:File} ${output;stdout:"DebianVersion.h"} ${kv;hide:"p CL"} ${kv;hide:"pc yellow"}
  5930. }
  5931. BUILD_MN_SCRIPT=build/scripts/build_mn.py
  5932. # tag:matrixnet
  5933. ### @usage: BUILD_MN([CHECK] [PTR] [MULTI] mninfo mnname) # matrixnet
  5934. ###
  5935. ### Generate MatrixNet data and access code using single command.
  5936. ### Alternative macro BUILD_MNS() works faster and better for large files.
  5937. macro BUILD_MN(MnInfo, MnName, CHECK?"fml_tool=$FML_UNUSED_TOOL CHECK":"", MULTI?, PTR?, RANKING_SUFFIX="") {
  5938. .CMD=$YMAKE_PYTHON ${input:BUILD_MN_SCRIPT} BuildMnF $ARCADIA_ROOT $ARCH_TOOL ${input:MnInfo} $MnName ranking_suffix=$RANKING_SUFFIX ${output;chksum;pre=mn.:MnName.cpp} ${output;hide;pre=MN_External_;suf=.rodata:MnName} ${output_include;hide:"kernel/matrixnet/mn_sse.h"} $CHECK $MULTI $PTR ${kv;hide:"p MN"} ${kv;hide:"pc yellow"}
  5939. }
  5940. macro _BUILD_MNS_FILE(Input, Name, Output, Suffix, Check, Fml_tool, AsmDataName) {
  5941. .CMD=$YMAKE_PYTHON ${input:BUILD_MN_SCRIPT} BuildMnsFilesF $ARCADIA_ROOT $BINDIR $ARCH_TOOL fml_tool=$Fml_tool $Name ranking_suffix=$Suffix ${input:Input} ${output;hide:Output} ${output;hide;pre=MN_External_;suf=.rodata:AsmDataName} ${output_include;hide:"kernel/matrixnet/mn_sse.h"} ${kv;hide:"p MN"} ${kv;hide:"pc yellow"}
  5942. }
  5943. MNS_OUTPUT=mnmodels
  5944. macro _BUILD_MNS_CPP(NAME="", CHECK?, RANKING_SUFFIX="", Files...) {
  5945. .CMD=$YMAKE_PYTHON ${input:BUILD_MN_SCRIPT} BuildMnsCppF $NAME ranking_suffix=$RANKING_SUFFIX ${input:MNS_OUTPUT.h} ${output:MNS_OUTPUT.cpp} ${input:Files} ${output_include;hide:MNS_OUTPUT.h} ${output_include;hide:"kernel/matrixnet/mn_sse.h"} ${kv;hide:"p MN"} ${kv;hide:"pc yellow"}
  5946. }
  5947. macro _BUILD_MNS_HEADER(NAME="", CHECK?, RANKING_SUFFIX="", Files...) {
  5948. .CMD=$YMAKE_PYTHON ${input:BUILD_MN_SCRIPT} BuildMnsHeaderF $NAME ranking_suffix=$RANKING_SUFFIX ${output:MNS_OUTPUT.h} ${input:Files} ${output_include;hide:"kernel/matrixnet/mn_sse.h"} ${output_include;hide:"kernel/matrixnet/mn_multi_categ.h"} ${kv;hide:"p MN"} ${kv;hide:"pc yellow"}
  5949. }
  5950. # TODO: support foreach_in and keywords simultaneous usage (look at BUILD_MNS_FILES)
  5951. # tag:matrixnet
  5952. ### @usage: BUILD_MNS([CHECK] NAME listname mninfos...) # matrixnet
  5953. ###
  5954. ### Generate MatrixNet data and access code using separate commands for support code, interface and data.
  5955. ### Faster version of BUILD_MN() macro for large files.
  5956. macro BUILD_MNS(Files...) {
  5957. _BUILD_MNS_HEADER($Files)
  5958. _BUILD_MNS_CPP($Files)
  5959. _BUILD_MNS_FILES($Files)
  5960. }
  5961. ### @usage: COMPILE_NLG(Src...)
  5962. ###
  5963. ### Generate and compile .nlg templates (Jinja2-based) and interface for megamind runtime.
  5964. ###
  5965. ### Alice-specific macro
  5966. macro COMPILE_NLG(Src...) {
  5967. PEERDIR(alice/nlg/runtime)
  5968. RUN_PROGRAM(alice/nlg/bin compile-cpp --import-dir ${ARCADIA_ROOT} --out-dir ${ARCADIA_BUILD_ROOT} --include-prefix ${MODDIR} ${Src} IN ${Src} OUT register.cpp register.h ${suf=.cpp:Src} ${suf=.h:Src} OUT_NOAUTO ${suf=.pb.txt:Src})
  5969. }
  5970. ### @usage: NEED_CHECK()
  5971. ###
  5972. ### Commits to the project marked with this macro will be blocked by pre-commit check and then will be
  5973. ### automatically merged to trunk only if there is no new broken build targets in check results.
  5974. ### The use of this macro is disabled by default.
  5975. macro NEED_CHECK(Flags...) {
  5976. # TODO: FIXME
  5977. ENABLE(UNUSED_MACRO)
  5978. }
  5979. ### @usage: NO_NEED_CHECK()
  5980. ###
  5981. ### Commits to the project marked with this macro will not be affected by higher-level NEED_CHECK macro.
  5982. macro NO_NEED_CHECK(Flags...) {
  5983. ENABLE(UNUSED_MACRO)
  5984. }
  5985. # tag:deprecated
  5986. ### @usage: NEED_REVIEW() # deprecated
  5987. ###
  5988. ### Mark the project as needing review.
  5989. ### Reviewers are listed in the macro OWNER. The use of this macro is disabled by default.
  5990. ### Details can be found here: https://clubs.at.yandex-team.ru/arcadia/6104
  5991. macro NEED_REVIEW(Flags...) {
  5992. # TODO: FIXME
  5993. ENABLE(UNUSED_MACRO)
  5994. }
  5995. ### @usage: VERSION(Args...)
  5996. ###
  5997. ### Specify version of a module. Currently unused by build system, only informative.
  5998. macro VERSION(Flags...) {
  5999. ENABLE(UNUSED_MACRO)
  6000. }
  6001. DATAWORK_SCHEEME_EXPORT_FLAGS=
  6002. when ($UNIX == "yes") {
  6003. SCHEEME2_CFLAGS= -E -x c++
  6004. }
  6005. when ($WIN32 == "yes") {
  6006. SCHEEME2_CFLAGS= /E /TP
  6007. }
  6008. SCHEEME2_STRUCT_INFO_FLAGS=-f "const static ui32 RecordSig" -u "RecordSig" --gcc44_no_typename --no_complex_overloaded_func_export
  6009. ### @usage: GEN_SCHEEME2(scheeme_name from_file dependent_files...)
  6010. ###
  6011. ### Generates a C++ description for structure(contains the field RecordSig) in the specified file (and connected).
  6012. ###
  6013. ### 1. ${scheeme_name}.inc - the name of the generated file.
  6014. ### 2. Use an environment variable - DATAWORK_SCHEEME_EXPORT_FLAGS that allows to specify flags to tools/structparser
  6015. ###
  6016. ### @example:
  6017. ###
  6018. ### SET(DATAWORK_SCHEEME_EXPORT_FLAGS --final_only -m "::")
  6019. ###
  6020. ### all options are passed to structparser (in this example --final_only - do not export heirs with public base that contains the required field,,- m "::" only from the root namespace)
  6021. ### sets in extra option
  6022. ###
  6023. ### @example:
  6024. ###
  6025. ### SET(EXTRACT_STRUCT_INFO_FLAGS -f \"const static ui32 RecordSig\"
  6026. ### -u \"RecordSig\" -n${scheeme_name}SchemeInfo ----gcc44_no_typename no_complex_overloaded_func_export
  6027. ### ${DATAWORK_SCHEEME_EXPORT_FLAGS})
  6028. ###
  6029. ### for compatibility with C++ compiler and the external environment.
  6030. ### See tools/structparser for more details.
  6031. macro GEN_SCHEEME2(ScheemeName, FromFile) {
  6032. .CMD=$CXX_COMPILER $C_FLAGS_PLATFORM -c ${tmp;stdout:FromFile.cph} $SCHEEME2_CFLAGS ${input:FromFile} ${pre=-I:_C__INCLUDE} $CXXFLAGS -Wno-error && ${tool:"tools/structparser"} -o ${output:ScheemeName.inc} -n N${ScheemeName}SchemeInfo $SCHEEME2_STRUCT_INFO_FLAGS $DATAWORK_SCHEEME_EXPORT_FLAGS ${tmp:FromFile.cph} ${output;stdout;noauto:ScheemeName.inc.log} ${kv;hide:"p SH"} ${kv;hide:"pc yellow"}
  6033. }
  6034. ### @usage: SYMLINK(from to)
  6035. ### Add symlink
  6036. macro SYMLINK(From, To) {
  6037. .CMD=$YMAKE_PYTHON ${input:"build/scripts/symlink.py"} ${input;dirallowed:From} ${output;noauto:To} ${kv;hide:"p LN"} ${kv;hide:"pc light-cyan"}
  6038. }
  6039. # tag:internal
  6040. ### @usage: _TARGET_SOURCES_FOR_HEADERS_IMPL([GENERATE] Args...) # internal
  6041. ### Generate prefix " && target_sources PRIVATE " before $Args when GENERATE is specified in the list of actual arguments
  6042. macro _TARGET_SOURCES_FOR_HEADERS_IMPL(GENERATE?" && target_sources PRIVATE ":"", Args...) {
  6043. .SEM=$GENERATE ${output;ext=.h:Args} ${output;ext=.hh:Args} ${output;ext=.hpp:Args} ${output;ext=.inc:Args} ${output;ext=.i:Args}
  6044. }
  6045. # tag:internal
  6046. ### @usage: _TARGET_SOURCES_FOR_HEADERS(Args...) # internal
  6047. ### Generate prefix " && target_sources PRIVATE " before $Args if Args is not empty
  6048. macro _TARGET_SOURCES_FOR_HEADERS(Args...) {
  6049. .SEM=$_TARGET_SOURCES_FOR_HEADERS_IMPL(${pre=GENERATE :Args})
  6050. }
  6051. # tag:internal
  6052. ### @usage: _TARGET_SOURCES_FOR_HEADERS_IMPL([GENERATE] Args...) # internal
  6053. ### Generate prefix " ${CMAKE_COMMAND} -E env " before $Args when GENERATE is specified in the list of actual arguments
  6054. macro _SET_ENV_FOR_CUSTOM_COMMAND_IMPL(GENERATE?" ${CMAKE_COMMAND} -E env ":"", Args...) {
  6055. .SEM=$GENERATE ${pre= :Args}
  6056. }
  6057. # tag:internal
  6058. ### @usage: _SET_ENV_FOR_CUSTOM_COMMAND(Args...) # internal
  6059. ### Generate prefix " ${CMAKE_COMMAND} -E env " before $Args if Args is not empty
  6060. macro _SET_ENV_FOR_CUSTOM_COMMAND(Args...) {
  6061. .SEM=$_SET_ENV_FOR_CUSTOM_COMMAND_IMPL(${pre=GENERATE :Args})
  6062. }
  6063. ### @usage: RUN_PROGRAM(tool_path args... [CWD dir] [ENV key=value...] [TOOL tools...] [IN[_NOPARSE] inputs...] [OUT[_NOAUTO] outputs...] [STDOUT[_NOAUTO] output] [OUTPUT_INCLUDES output_includes...])
  6064. ###
  6065. ### Run a program from arcadia.
  6066. ### These macros are similar: RUN_PROGRAM, LUA, PYTHON.
  6067. ###
  6068. ### Parameters:
  6069. ### - tool_path - Path to the directory of the tool.
  6070. ### - args... - Program arguments. Relative paths listed in TOOL, IN, OUT, STDOUT become absolute.
  6071. ### - CWD dir - Absolute path of the working directory.
  6072. ### - ENV key=value... - Environment variables.
  6073. ### - TOOL tools... - Auxiliary tool directories.
  6074. ### - IN[_NOPARSE] inputs... - Input files. NOPARSE inputs are treated as textual and not parsed for dependencies regardless of file extensions.
  6075. ### - OUT[_NOAUTO] outputs... - Output files. NOAUTO outputs are not automatically added to the build process.
  6076. ### - STDOUT[_NOAUTO] output - Redirect the standard output to the output file.
  6077. ### - OUTPUT_INCLUDES output_includes... - Includes of the output files that are needed to build them.
  6078. ###
  6079. ### For absolute paths use ${ARCADIA_ROOT} and ${ARCADIA_BUILD_ROOT}, or
  6080. ### ${CURDIR} and ${BINDIR} which are expanded where the outputs are used.
  6081. ### Note that Tool is always built for the host platform, so be careful to provide that tool can be built for all Arcadia major host platforms (Linux, MacOS and Windows).
  6082. macro RUN_PROGRAM(Tool, IN{input}[], IN_NOPARSE{input}[], OUT{output}[], OUT_NOAUTO{output}[], TOOL{tool}[], OUTPUT_INCLUDES[], IN_DEPS[], STDOUT="", STDOUT_NOAUTO="", CWD="", ENV[], Args...) {
  6083. .CMD=${cwd:CWD} ${env:ENV} ${tool:Tool} $Args ${input;hide:IN} ${input;context=TEXT;hide:IN_NOPARSE} ${input;hide:IN_DEPS} ${output_include;hide:OUTPUT_INCLUDES} ${tool;hide:TOOL} ${output;hide:OUT} ${output;noauto;hide:OUT_NOAUTO} ${output;stdout:STDOUT} ${output;stdout;noauto:STDOUT_NOAUTO} ${kv;hide:"p PR"} ${kv;hide:"pc yellow"} ${kv;hide:"show_out"}
  6084. .SEM=add_custom_command $_SET_ENV_FOR_CUSTOM_COMMAND($ENV) OUTPUT ${output:OUT} ${output;noauto:OUT_NOAUTO} ${output:STDOUT} ${output;noauto:STDOUT_NOAUTO} DEPENDS ${input:IN} ${input;context=TEXT:IN_NOPARSE} ${tool:Tool} ${tool:TOOL} ${pre=WORKING_DIRECTORY :CWD} COMMAND ${tool:Tool} $Args ${pre=> :STDOUT} ${pre=> :STDOUT_NOAUTO} $_TARGET_SOURCES_FOR_HEADERS($OUT $OUT_NOAUTO $STDOUT $STDOUT_NOAUTO)
  6085. }
  6086. # tag:lua-specific
  6087. ### @usage: LUA(script_path args... [CWD dir] [ENV key=value...] [TOOL tools...] [IN[_NOPARSE] inputs...] [OUT[_NOAUTO] outputs...] [STDOUT[_NOAUTO] output] [OUTPUT_INCLUDES output_includes...])
  6088. ###
  6089. ### Run a lua script.
  6090. ### These macros are similar: RUN_PROGRAM, LUA, PYTHON.
  6091. ###
  6092. ### Parameters:
  6093. ### - script_path - Path to the script.3
  6094. ### - args... - Program arguments. Relative paths listed in TOOL, IN, OUT, STDOUT become absolute.
  6095. ### - CWD dir - Absolute path of the working directory.
  6096. ### - ENV key=value... - Environment variables.
  6097. ### - TOOL tools... - Auxiliary tool directories.
  6098. ### - IN[_NOPARSE] inputs... - Input files. NOPARSE inputs are treated as textual and not parsed for dependencies regardless of file extensions.
  6099. ### - OUT[_NOAUTO] outputs... - Output files. NOAUTO outputs are not automatically added to the build process.
  6100. ### - STDOUT[_NOAUTO] output - Redirect the standard output to the output file.
  6101. ### - OUTPUT_INCLUDES output_includes... - Includes of the output files that are needed to build them.
  6102. ###
  6103. ### For absolute paths use ${ARCADIA_ROOT} and ${ARCADIA_BUILD_ROOT}, or
  6104. ### ${CURDIR} and ${BINDIR} which are expanded where the outputs are used.
  6105. macro LUA(ScriptPath, IN{input}[], IN_NOPARSE{input}[], OUT{output}[], OUT_NOAUTO{output}[], TOOL{tool}[], OUTPUT_INCLUDES[], STDOUT="", STDOUT_NOAUTO="", CWD="", ENV[], Args...) {
  6106. .CMD=${cwd:CWD} ${env:ENV} $LUA_TOOL ${input:ScriptPath} $Args ${input;hide:IN} ${input;context=TEXT;hide:IN_NOPARSE} ${output_include;hide:OUTPUT_INCLUDES} ${tool;hide:TOOL} ${output;hide:OUT} ${output;noauto;hide:OUT_NOAUTO} ${output;stdout:STDOUT} ${output;stdout;noauto:STDOUT_NOAUTO} ${kv;hide:"p LU"} ${kv;hide:"pc yellow"} ${kv;hide:"show_out"}
  6107. }
  6108. # tag:python-specific
  6109. ### @usage: PYTHON(script_path args... [CWD dir] [ENV key=value...] [TOOL tools...] [IN[_NOPARSE] inputs...] [OUT[_NOAUTO] outputs...] [STDOUT[_NOAUTO] output] [OUTPUT_INCLUDES output_includes...])
  6110. ###
  6111. ### Run a python script with $(PYTHON)/python built from devtools/huge_python.
  6112. ### These macros are similar: RUN_PROGRAM, LUA, PYTHON.
  6113. ###
  6114. ### Parameters:
  6115. ### - script_path - Path to the script.
  6116. ### - args... - Program arguments. Relative paths listed in TOOL, IN, OUT, STDOUT become absolute.
  6117. ### - CWD dir - Absolute path of the working directory.
  6118. ### - ENV key=value... - Environment variables.
  6119. ### - TOOL tools... - Auxiliary tool directories.
  6120. ### - IN[_NOPARSE] inputs... - Input files. NOPARSE inputs are treated as textual and not parsed for dependencies regardless of file extensions.
  6121. ### - OUT[_NOAUTO] outputs... - Output files. NOAUTO outputs are not automatically added to the build process.
  6122. ### - STDOUT[_NOAUTO] output - Redirect the standard output to the output file.
  6123. ### - OUTPUT_INCLUDES output_includes... - Includes of the output files that are needed to build them.
  6124. ###
  6125. ### For absolute paths use ${ARCADIA_ROOT} and ${ARCADIA_BUILD_ROOT}, or
  6126. ### ${CURDIR} and ${BINDIR} which are expanded where the outputs are used.
  6127. macro PYTHON(ScriptPath, IN{input}[], IN_NOPARSE{input}[], OUT{output}[], OUT_NOAUTO{output}[], TOOL{tool}[], OUTPUT_INCLUDES[], STDOUT="", STDOUT_NOAUTO="", CWD="", ENV[], Args...) {
  6128. .CMD=${cwd:CWD} ${env:ENV} $YMAKE_PYTHON ${input:ScriptPath} $Args ${input;hide:IN} ${input;context=TEXT;hide:IN_NOPARSE} ${output_include;hide:OUTPUT_INCLUDES} ${tool;hide:TOOL} ${output;hide:OUT} ${output;noauto;hide:OUT_NOAUTO} ${output;stdout:STDOUT} ${output;stdout;noauto:STDOUT_NOAUTO} ${kv;hide:"p PY"} ${kv;hide:"pc yellow"} ${kv;hide:"show_out"}
  6129. .SEM=find_package Python2 && add_custom_command $_SET_ENV_FOR_CUSTOM_COMMAND($ENV) OUTPUT ${output:OUT} ${output;noauto:OUT_NOAUTO} ${output:STDOUT} ${output;noauto:STDOUT_NOAUTO} DEPENDS ${input:IN} ${input;context=TEXT:IN_NOPARSE} ${input:ScriptPath} ${tool:TOOL} ${pre=WORKING_DIRECTORY :CWD} COMMAND Python2::Interpreter ${input:ScriptPath} $Args ${pre=> :STDOUT} ${pre=> :STDOUT_NOAUTO} $_TARGET_SOURCES_FOR_HEADERS($OUT $OUT_NOAUTO $STDOUT $STDOUT_NOAUTO)
  6130. }
  6131. # tag:python-specific
  6132. ### @usage: PYTHON3(script_path args... [CWD dir] [ENV key=value...] [TOOL tools...] [IN[_NOPARSE] inputs...] [OUT[_NOAUTO] outputs...] [STDOUT[_NOAUTO] output] [OUTPUT_INCLUDES output_includes...])
  6133. ###
  6134. ### Run a python script with prebuilt python3 interpretor built from devtools/huge_python3.
  6135. ### These macros are similar: RUN_PROGRAM, LUA, PYTHON.
  6136. ###
  6137. ### Parameters:
  6138. ### - script_path - Path to the script.
  6139. ### - args... - Program arguments. Relative paths listed in TOOL, IN, OUT, STDOUT become absolute.
  6140. ### - CWD dir - Absolute path of the working directory.
  6141. ### - ENV key=value... - Environment variables.
  6142. ### - TOOL tools... - Auxiliary tool directories.
  6143. ### - IN[_NOPARSE] inputs... - Input files. NOPARSE inputs are treated as textual and not parsed for dependencies regardless of file extensions.
  6144. ### - OUT[_NOAUTO] outputs... - Output files. NOAUTO outputs are not automatically added to the build process.
  6145. ### - STDOUT[_NOAUTO] output - Redirect the standard output to the output file.
  6146. ### - OUTPUT_INCLUDES output_includes... - Includes of the output files that are needed to build them.
  6147. ###
  6148. ### For absolute paths use ${ARCADIA_ROOT} and ${ARCADIA_BUILD_ROOT}, or
  6149. ### ${CURDIR} and ${BINDIR} which are expanded where the outputs are used.
  6150. macro PYTHON3(ScriptPath, IN{input}[], IN_NOPARSE{input}[], OUT{output}[], OUT_NOAUTO{output}[], TOOL{tool}[], OUTPUT_INCLUDES[], STDOUT="", STDOUT_NOAUTO="", CWD="", ENV[], Args...) {
  6151. .CMD=${cwd:CWD} ${env:ENV} $YMAKE_PYTHON3 ${input:ScriptPath} $Args ${input;hide:IN} ${input;context=TEXT;hide:IN_NOPARSE} ${output_include;hide:OUTPUT_INCLUDES} ${tool;hide:TOOL} ${output;hide:OUT} ${output;noauto;hide:OUT_NOAUTO} ${output;stdout:STDOUT} ${output;stdout;noauto:STDOUT_NOAUTO} ${kv;hide:"p PY"} ${kv;hide:"pc yellow"} ${kv;hide:"show_out"}
  6152. .PEERDIR=$YMAKE_PYTHON3_PEER
  6153. .SEM=find_package Python3 && add_custom_command $_SET_ENV_FOR_CUSTOM_COMMAND($ENV) OUTPUT ${output:OUT} ${output;noauto:OUT_NOAUTO} ${output:STDOUT} ${output;noauto:STDOUT_NOAUTO} DEPENDS ${input:IN} ${input;context=TEXT:IN_NOPARSE} ${input:ScriptPath} ${tool:TOOL} ${pre=WORKING_DIRECTORY :CWD} COMMAND Python3::Interpreter ${input:ScriptPath} $Args ${pre=> :STDOUT} ${pre=> :STDOUT_NOAUTO} $_TARGET_SOURCES_FOR_HEADERS($OUT $OUT_NOAUTO $STDOUT $STDOUT_NOAUTO)
  6154. }
  6155. # tag:java-specific
  6156. macro _RUN_JAVA(IN{input}[], IN_NOPARSE{input}[], OUT{output}[], OUT_NOAUTO{output}[], OUTPUT_INCLUDES[], TOOL[], STDOUT="", STDOUT_NOAUTO="", CWD="", ENV[], HIDE_OUTPUT?"stderr2stdout":"stdout2stderr", Args...) {
  6157. PEERDIR(build/platform/java/jdk $JDK_RESOURCE_PEERDIR)
  6158. .CMD=${cwd:CWD} ${env:ENV} $YMAKE_PYTHON ${input;pre=build/scripts/:HIDE_OUTPUT.py} $JDK_RESOURCE/bin/java $Args ${tool;hide:TOOL} ${input;hide:IN} ${input;context=TEXT;hide:IN_NOPARSE} ${output_include;hide:OUTPUT_INCLUDES} ${output;hide:OUT} ${output;noauto;hide:OUT_NOAUTO} ${output;stdout:STDOUT} ${output;stdout;noauto:STDOUT_NOAUTO} ${kv;hide:"p JV"} ${kv;hide:"pc light-blue"} ${kv;hide:"show_out"}
  6159. }
  6160. ### @usage: FROM_SANDBOX([FILE] resource_id [AUTOUPDATED script] [RENAME <resource files>] OUT_[NOAUTO] <output files> [EXECUTABLE] [OUTPUT_INCLUDES <include files>])
  6161. ###
  6162. ### Download the resource from the Sandbox, unpack (if not explicitly specified word FILE) and add OUT files to the build. EXECUTABLE makes them executable.
  6163. ### You may specify extra dependencies that output files bring using OUTPUT_INCLUDES. The change of these may e.g. lead to recompilation of .cpp files extracted from resource.
  6164. ### If there is no default processing for OUT files or you need process them specially use OUT_NOAUTO instead of OUT.
  6165. ###
  6166. ### It is disallowed to specify directory as OUT/OUT_NOAUTO since all outputs of commands shall be known to build system.
  6167. ###
  6168. ### RENAME renames files to the corresponding OUT and OUT_NOAUTO outputs:
  6169. ### FROM_SANDBOX(resource_id RENAME in_file1 in_file2 OUT out_file1 out_file2 out_file3)
  6170. ### FROM_SANDBOX(resource_id RENAME in_file1 OUT out_file1 RENAME in_file2 OUT out_file2)
  6171. ### FROM_SANDBOX(FILE resource_id RENAME resource_file OUT out_name)
  6172. ###
  6173. ### RENAME RESOURCE allows to rename the resource without specifying its file name.
  6174. ###
  6175. ### If AUTOUPDATED is specified than macro will be regularly updated according to autoupdate script. The dedicated Sandbox task scans the arcadia and
  6176. ### changes resource_ids in such macros if newer resource of specified type is available. Note that the task seeks AUTOUPDATED in specific position,
  6177. ### so you shall place it immediately after resource_id.
  6178. macro FROM_SANDBOX(Id, OUT{output}[], OUT_NOAUTO{output}[], OUTPUT_INCLUDES[], FILE?"--copy-to-dir":"--untar-to", AUTOUPDATED="", PREFIX=".", RENAME[], EXECUTABLE?"--executable":"", SBR="sbr:") {
  6179. .CMD=${hide:SANDBOX_FAKEID} ${cwd:BINDIR} ${resource;pre=$SBR:Id} $YMAKE_PYTHON ${input:"build/scripts/fetch_from_sandbox.py"} --resource-file $(RESOURCE_ROOT)/sbr/$Id/resource --resource-id $Id $FILE $PREFIX ${pre=--rename :RENAME} $EXECUTABLE -- $OUT $OUT_NOAUTO ${input;hide:"build/scripts/fetch_from.py"} ${output_include;hide:OUTPUT_INCLUDES} ${output;hide:OUT} ${output;noauto;hide:OUT_NOAUTO} ${requirements;hide:"network:full"} ${kv;hide:"p SB"} ${kv;hide:"pc yellow"} ${kv;hide:"show_out"}
  6180. ADD_CHECK(check.resource $Id)
  6181. }
  6182. ### @usage: FROM_MDS([FILE] key [RENAME <resource files>] OUT_[NOAUTO] <output files> [EXECUTABLE])
  6183. ###
  6184. ### Download resource from MDS with the specified key and process like [FROM_SANDBOX()](#macro_FROM_SANDBOX).
  6185. macro FROM_MDS(Key, OUT{output}[], OUT_NOAUTO{output}[], OUTPUT_INCLUDES[], FILE?"--copy-to-dir":"--untar-to", PREFIX=".", RENAME[], EXECUTABLE?"--executable":"") {
  6186. .CMD=${cwd:BINDIR} $YMAKE_PYTHON ${input:"build/scripts/fetch_from_mds.py"} --key $Key $FILE $PREFIX ${pre=--rename :RENAME} $EXECUTABLE -- $OUT $OUT_NOAUTO ${input;hide:"build/scripts/fetch_from.py"} ${output_include;hide:OUTPUT_INCLUDES} ${output;hide:OUT} ${output;noauto;hide:OUT_NOAUTO} ${requirements;hide:"network:full"} ${kv;hide:"p MD"} ${kv;hide:"pc yellow"} ${kv;hide:"show_out"}
  6187. ADD_CHECK(check.mds $Key)
  6188. }
  6189. # tag:internal
  6190. ### @usage: _FROM_EXTERNAL(ExtFile [AUTOUPDATED script] [RENAME <resource files>] OUT_[NOAUTO] <output files> [EXECUTABLE]) #internal
  6191. ###
  6192. ### Use resource described as .external file as [FROM_SANDBOX()](#macro_FROM_SANDBOX)/[FROM_MDS()](#macro_FROM_MDS).
  6193. macro _FROM_EXTERNAL(File, OutFile, OUT{output}[], OUT_NOAUTO{output}[], OUTPUT_INCLUDES[], AUTOUPDATED="", PREFIX=".", RENAME[], EXECUTABLE?"--executable":"", EXT="ext:") {
  6194. .CMD=${hide:SANDBOX_FAKEID} ${cwd:BINDIR} ${resource;pre=$EXT;suf=.external:OutFile} $YMAKE_PYTHON ${input:"build/scripts/fetch_from_external.py"} --external-file ${input:File} --resource-file $(RESOURCE_ROOT)/ext/$OutFile --copy-to-dir $PREFIX ${pre=--rename :RENAME} $EXECUTABLE -- $OUT $OUT_NOAUTO ${input;hide:"build/scripts/fetch_from.py"} ${input;hide:"build/scripts/fetch_from_sandbox.py"} ${input;hide:"build/scripts/fetch_from_mds.py"} ${output_include;hide:OUTPUT_INCLUDES} ${output;hide:OUT} ${output;noauto;hide:OUT_NOAUTO} ${requirements;hide:"network:full"} ${kv;hide:"p XT"} ${kv;hide:"pc yellow"} ${kv;hide:"show_out"}
  6195. #FIXME: add '${resource;pre=$EXT:OutFile}' when support of the scheme is added to executors
  6196. #FIXME: add 'ADD_CHECK(check.external $File)' when proper testing is implemented
  6197. }
  6198. ### @usage LARGE_FILES([AUTOUPDATED] Files...)
  6199. ###
  6200. ### Use large file ether from working copy or from remote storage via placeholder <File>.external
  6201. ### If <File> is present locally (and not a symlink!) it will be copied to build directory.
  6202. ### Otherwise macro will try to locate <File>.external, parse it retrieve ot during build phase.
  6203. macro LARGE_FILES(AUTOUPDATED?, Files...) {
  6204. # This is needed to correctly switch between remote and local modes
  6205. _GLOB($LF $Files)
  6206. }
  6207. ### @usage: FROM_ARCHIVE(Src [RENAME <resource files>] OUT_[NOAUTO] <output files> [EXECUTABLE])
  6208. ###
  6209. ### Process file archive as [FROM_SANDBOX()](#macro_FROM_SANDBOX).
  6210. macro FROM_ARCHIVE(Src, OUT{output}[], OUT_NOAUTO{output}[], OUTPUT_INCLUDES[], PREFIX=".", RENAME[], EXECUTABLE?"--executable":"") {
  6211. .CMD=${cwd:BINDIR} $YMAKE_PYTHON ${input:"build/scripts/fetch_from_archive.py"} "--archive" ${input:Src} "--file-name" ${suf=-:Src} "--untar-to" $PREFIX ${pre=--rename :RENAME} $EXECUTABLE -- $OUT $OUT_NOAUTO ${input;hide:"build/scripts/fetch_from.py"} ${output_include;hide:OUTPUT_INCLUDES} ${output;hide:OUT} ${output;noauto;hide:OUT_NOAUTO} ${kv;hide:"p FA"} ${kv;hide:"pc yellow"} ${kv;hide:"show_out"}
  6212. }
  6213. when ($MSVC == "yes") {
  6214. C_AS_CXX_FLAGS=/TP /std:c++17
  6215. }
  6216. otherwise {
  6217. C_AS_CXX_FLAGS=-x c++ -std=c++17
  6218. }
  6219. # tag:cpp-specific
  6220. ### @usage: COMPILE_C_AS_CXX()
  6221. ###
  6222. ### Compile .c files as .cpp ones within a module.
  6223. macro COMPILE_C_AS_CXX() {
  6224. SET(EXTRA_C_FLAGS $C_AS_CXX_FLAGS)
  6225. }
  6226. ### @usage: NO_DEBUG_INFO()
  6227. ###
  6228. ### Compile files without debug info collection.
  6229. macro NO_DEBUG_INFO() {
  6230. SET(NO_DEBUGINFO yes)
  6231. }
  6232. ### @usage: CTEMPLATE_VARNAMES(File)
  6233. ###
  6234. ### Generate File.varnames.h using contrib/libs/ctemplate/make_tpl_varnames_h
  6235. ###
  6236. ### Documentation: https://a.yandex-team.ru/arc/trunk/arcadia/contrib/libs/ctemplate/README.md
  6237. macro CTEMPLATE_VARNAMES(File) {
  6238. .CMD=${tool:"contrib/libs/ctemplate/make_tpl_varnames_h"} -f ${output;addincl;nopath;noallext:File.varnames.h} ${input:File}
  6239. }
  6240. LLVM_OPTS=
  6241. CLANG_ROOT=$CLANG_RESOURCE_GLOBAL
  6242. CLANG_BINARIES_ROOT=$CLANG_ROOT/bin
  6243. CLANG_CPP_COMPILER_BIN=$CLANG_BINARIES_ROOT/clang++
  6244. CLANG_C_COMPILER_BIN=$CLANG_BINARIES_ROOT/clang
  6245. when ($OS_ANDROID == "yes") {
  6246. CLANG_ROOT=$CLANG_ANDROID_RESOURCE_GLOBAL
  6247. when ($HOST_OS_DARWIN) {
  6248. CLANG_BINARIES_ROOT=$CLANG_ROOT/toolchains/llvm/prebuilt/darwin-x86_64/bin
  6249. }
  6250. otherwise {
  6251. CLANG_BINARIES_ROOT=$CLANG_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin
  6252. }
  6253. }
  6254. ### @usage: GENERATED_SRCS(srcs... PARSE_META_FROM cpp_srcs... [OUTPUT_INCLUDES output_includes...] [OPTIONS])
  6255. ###
  6256. ### Generate sources using Jinja 2 template engine.
  6257. ###
  6258. ### srcs... - list of text files which will be generated during build time by templates. Each template must be
  6259. ### placed to the place in source tree where corresponding source file should be generated. Name of
  6260. ### template must be "<name_of_src_file>.markettemplate". For example if you want to generate file "example.cpp"
  6261. ### then template should be named "example.cpp.markettemplate".
  6262. ### PARSE_META_FROM cpp_srcs... - list of C++ source files (.cpp, .h) which will be parsed using clang library
  6263. ### and metainformation extracted from the files will be made available for templates. Example of
  6264. ### template code fragment using metainformation: {{ meta.objects["@N@std@S@string"].name }}
  6265. ### OUTPUT_INCLUDES output_includes... - in cases when build system parser fails to determine all headers
  6266. ### which generated files include, you can specify additional headers here. In a normal situation this should
  6267. ### not be needed and this feature could be removed in the future.
  6268. ### OPTIONS - additional options for code_generator utility
  6269. ###
  6270. ### Examples of templates can be found in directory market/tools/code_generator/templates.
  6271. ### Metainformation does not contain entries for every object declared in C++ files specified in PARSE_META_FROM
  6272. ### parameter. To include some object into consideration you need to mark it by attribute. Attributes can
  6273. ### automatically add more attributes to dependent objects. This behavior depends on attribute definition.
  6274. ###
  6275. ### More information will be available (eventually:) here: https://wiki.yandex-team.ru/Users/denisk/codegenerator/
  6276. macro GENERATED_SRCS(PARSE_META_FROM{input}[], OUTPUT_INCLUDES[], OPTIONS[], TEMPLATES...) {
  6277. .CMD=${tool:"market/tools/code_generator"} --cpp-file ${input:PARSE_META_FROM} --templates-dir / ${ARCADIA_ROOT} --templates ${input:TEMPLATES.markettemplate} --generated-files ${output:TEMPLATES} ${output_include;hide:OUTPUT_INCLUDES} ${output_include;hide:PARSE_META_FROM} --arcadia-root ${ARCADIA_ROOT} --arcadia-build-root ${ARCADIA_BUILD_ROOT} --clang-root $CLANG_ROOT ${OPTIONS} -- $C_FLAGS_PLATFORM $CXXFLAGS ${pre=-I:_C__INCLUDE} -std=c++17 -Wno-unknown-warning-option -Wno-unused-parameter -Wno-undefined-inline -Wno-undefined-internal -Wno-unused-function $LLVM_OPTS -fno-lto
  6278. PEERDIR(build/platform/clang)
  6279. }
  6280. ### @usage: CLANG_EMIT_AST_CXX(Input Output Opts...)
  6281. ###
  6282. ### Emit Clang AST from .cpp file. CXXFLAGS and LLVM_OPTS are passed in, while CFLAGS and C_FLAGS_PLATFORM are not.
  6283. ### Note: Output name is used as is, no extension added.
  6284. macro CLANG_EMIT_AST_CXX(Input, Output, Opts...) {
  6285. .CMD=$YMAKE_PYTHON ${input:"build/scripts/clang_wrapper.py"} $WINDOWS $CLANG_CPP_COMPILER_BIN ${pre=-I:_C__INCLUDE} $CXXFLAGS $C_FLAGS_PLATFORM -Wno-unknown-warning-option $LLVM_OPTS -emit-ast -c ${input:Input} -o ${output;noauto:Output} $Opts ${kv;hide:"p ST"} ${kv;hide:"pc light-green"}
  6286. PEERDIR(build/platform/clang)
  6287. }
  6288. ### @usage: LLVM_COMPILE_CXX(Input Output Opts...)
  6289. ###
  6290. ### Emit LLVM bytecode from .cpp file. BC_CXXFLAGS, LLVM_OPTS and C_FLAGS_PLATFORM are passed in, while CFLAGS are not.
  6291. ### Note: Output name is used as is, no extension added.
  6292. macro LLVM_COMPILE_CXX(Input, Output, Opts...) {
  6293. .CMD=$YMAKE_PYTHON ${input:"build/scripts/clang_wrapper.py"} $WINDOWS $CLANG_CPP_COMPILER_BIN ${pre=-I:_C__INCLUDE} $BC_CXXFLAGS $C_FLAGS_PLATFORM -Wno-unknown-warning-option $LLVM_OPTS ${NO_LTO_CFLAGS} -emit-llvm -c ${input:Input} -o ${output;noauto:Output} $Opts ${kv;hide:"p BC"} ${kv;hide:"pc light-green"}
  6294. .SEM=llvm_compile_cxx ${input:Input} ${output;noauto:Output} ${CLANGPLUSPLUS} -Wno-unknown-warning-option $LLVM_OPTS ${NO_LTO_CFLAGS} -emit-llvm ${Opts}
  6295. PEERDIR(build/platform/clang)
  6296. }
  6297. ### @usage: LLVM_COMPILE_C(Input Output Opts...)
  6298. ###
  6299. ### Emit LLVM bytecode from .c file. BC_CFLAGS, LLVM_OPTS and C_FLAGS_PLATFORM are passed in, while CFLAGS are not.
  6300. ### Note: Output name is used as is, no extension added.
  6301. macro LLVM_COMPILE_C(Input, Output, Opts...) {
  6302. .CMD=$YMAKE_PYTHON ${input:"build/scripts/clang_wrapper.py"} $WINDOWS $CLANG_C_COMPILER_BIN ${pre=-I:_C__INCLUDE} $BC_CFLAGS $C_FLAGS_PLATFORM $LLVM_OPTS ${NO_LTO_CFLAGS} -emit-llvm -c ${input:Input} -o ${output;noauto:Output} $Opts ${kv;hide:"p BC"} ${kv;hide:"pc light-green"}
  6303. PEERDIR(build/platform/clang)
  6304. }
  6305. ### @usage: BPF(Input Output Opts...)
  6306. ###
  6307. ### Emit eBPF bytecode from .c file.
  6308. ### Note: Output name is used as is, no extension added.
  6309. macro BPF(Input, Output, Opts...) {
  6310. .CMD=$YMAKE_PYTHON ${input:"build/scripts/clang_wrapper.py"} $WINDOWS $CLANG_C_COMPILER_BIN ${pre=-I:_C__INCLUDE} $C_FLAGS_PLATFORM -target bpf -c ${input:Input} -o ${output;noauto:Output} $Opts ${kv;hide:"p BP"} ${kv;hide:"pc light-green"}
  6311. PEERDIR(build/platform/clang)
  6312. }
  6313. ### @usage: BPF_STATIC(Input Output Opts...)
  6314. ###
  6315. ### Emit eBPF bytecode from .c file.
  6316. ### Note: Output name is used as is, no extension added.
  6317. macro BPF_STATIC(Input, Output, Opts...) {
  6318. .CMD=$YMAKE_PYTHON ${input:"build/scripts/clang_wrapper.py"} $WINDOWS $CLANG_C_COMPILER_BIN ${pre=-I:_C__INCLUDE} $C_FLAGS_PLATFORM -target bpf -c ${input:Input} -o ${output;noauto:Output} $Opts ${kv;hide:"p BP"} ${kv;hide:"pc light-green"} && ${cwd:BINDIR} $LLD_ROOT_RESOURCE_GLOBAL/ld -r -b binary -m elf_x86_64 -o ${output;noauto;suf=.bpf.o:Input} ${noauto;nopath:Output}
  6319. PEERDIR(build/platform/clang build/platform/lld)
  6320. }
  6321. ### @usage: LLVM_COMPILE_LL(Input Output Opts...)
  6322. ###
  6323. ### Compile LLVM bytecode to object representation.
  6324. ### Note: Output name is used as is, no extension added.
  6325. macro LLVM_COMPILE_LL(Input, Output, Opts...) {
  6326. .CMD=$CLANG_BINARIES_ROOT/llvm-as ${input:Input} -o ${output;noauto:Output} ${kv;hide:"p BC"} ${kv;hide:"pc light-green"}
  6327. PEERDIR(build/platform/clang)
  6328. }
  6329. ### @usage: LLVM_LINK(Output Inputs...)
  6330. ###
  6331. ### Call llvm-link on set of Inputs to produce Output.
  6332. ### Note: Unlike many other macros output argument goes first. Output name is used as is, no extension added.
  6333. macro LLVM_LINK(Output, Inputs...) {
  6334. .CMD=$CLANG_BINARIES_ROOT/llvm-link ${input:Inputs} -o ${output;noauto:Output} ${kv;hide:"p LD"} ${kv;hide:"pc light-red"}
  6335. .SEM=add_custom_command OUTPUT ${output;noauto:Output} DEPENDS ${input:Inputs} COMMAND ${LLVMLINK} ${input:Inputs} -o ${output;noauto:Output}
  6336. PEERDIR(build/platform/clang)
  6337. }
  6338. ### @usage: LLVM_OPT(Input Output Opts...)
  6339. ###
  6340. ### Call llvm-opt with set of Opts on Input to produce Output.
  6341. ### Note: Output name is used as is, no extension added.
  6342. macro LLVM_OPT(Input, Output, Opts...) {
  6343. .CMD=$YMAKE_PYTHON ${input:"build/scripts/llvm_opt_wrapper.py"} $CLANG_BINARIES_ROOT/opt ${input:Input} -o ${output;noauto:Output} $Opts ${kv;hide:"p OP"} ${kv;hide:"pc yellow"}
  6344. .SEM=add_custom_command OUTPUT ${output;noauto:Output} DEPENDS ${input:Input} COMMAND ${LLVMOPT} ${input:Input} -o ${output;noauto:Output} $Opts
  6345. PEERDIR(build/platform/clang)
  6346. }
  6347. when ($NO_DEBUGINFO == "yes") {
  6348. DEBUG_INFO_FLAGS=
  6349. }
  6350. when ($CLANG && $DEBUGINFO_LINES_ONLY == "yes" && $NO_DEBUGINFO != "yes") {
  6351. DEBUG_INFO_FLAGS=-gline-tables-only
  6352. }
  6353. # TODO: configurable tar and touch
  6354. PACK_TGZ=${cwd:ARCADIA_BUILD_ROOT} tar -czf ${rootrel:OUTPUT} ${rootrel:INPUT} ${kv;hide:"p AR"} ${kv;hide:"pc light-red"}
  6355. # tag:internal
  6356. ### @usage TOUCH(Outputs...) # internal
  6357. ### Just introduce outputs
  6358. macro TOUCH(Outputs...) {
  6359. .CMD=$YMAKE_PYTHON ${input:"build/scripts/touch.py"} ${output:Outputs}
  6360. }
  6361. TOUCH_UNIT=$YMAKE_PYTHON ${input:"build/scripts/touch.py"} ${kv;hide:"p UN"} ${kv;hide:"pc light-cyan"} $TARGET
  6362. TOUCH_PACKAGE=$YMAKE_PYTHON ${input:"build/scripts/touch.py"} ${kv;hide:"pc light-red"} $TARGET && $YMAKE_PYTHON ${input:"build/scripts/copy_to_dir.py"} --dest-dir $BINDIR --build-root $ARCADIA_BUILD_ROOT $PACKED_PACKAGE_ARGS $SRCS_GLOBAL $PEERS
  6363. _P_PK=${kv;hide:"p PK"}
  6364. TOUCH_PACKAGE_MF=$GENERATE_MF && $TOUCH_PACKAGE $_P_PK
  6365. TOUCH_JAVA_UNIT=$YMAKE_PYTHON ${input:"build/scripts/touch.py"} ${kv;hide:"java $CURDIR"} $TARGET
  6366. NO_CHECK_IMPORTS_FOR_VALUE=None
  6367. ### @usage: NO_CHECK_IMPORTS([patterns])
  6368. ###
  6369. ### Do not run checks on imports of Python modules.
  6370. ### Optional parameter mask patterns describes the names of the modules that do not need to check.
  6371. macro NO_CHECK_IMPORTS(Masks...) {
  6372. SET(NO_CHECK_IMPORTS_FOR_VALUE $Masks)
  6373. }
  6374. # tag:yasm-specific
  6375. _YASM_FMT_VALUE=
  6376. _YASM_PLATFORM_FLAGS_VALUE=
  6377. _YASM_PREDEFINED_FLAGS_VALUE=
  6378. when ($OS_DARWIN || $OS_IOS) {
  6379. _YASM_FMT_VALUE=macho
  6380. _YASM_PLATFORM_FLAGS_VALUE=-D DARWIN -D UNIX
  6381. }
  6382. elsewhen ($OS_WINDOWS && $ARCH_X86_64) {
  6383. _YASM_FMT_VALUE=win
  6384. _YASM_PLATFORM_FLAGS_VALUE=-D WIN64
  6385. }
  6386. elsewhen ($OS_WINDOWS && $ARCH_I386) {
  6387. _YASM_FMT_VALUE=win
  6388. _YASM_PLATFORM_FLAGS_VALUE=-D WIN32
  6389. }
  6390. otherwise {
  6391. _YASM_FMT_VALUE=elf
  6392. _YASM_PLATFORM_FLAGS_VALUE=-D UNIX
  6393. _YASM_PREDEFINED_FLAGS_VALUE=-g dwarf2
  6394. }
  6395. when ($ASM_PREFIX) {
  6396. ASM_PREFIX_VALUE=--prefix=$ASM_PREFIX
  6397. }
  6398. otherwise {
  6399. ASM_PREFIX_VALUE=
  6400. }
  6401. # tag:yasm-specific
  6402. YASM_FLAGS=
  6403. YASM_PREINCLUDES_VALUE=
  6404. # tag:yasm-specific
  6405. macro _SRC_yasm_helper(SRC, PREINCLUDES[], SRCFLAGS...) {
  6406. .CMD=${tool:"contrib/tools/yasm"} -f ${_YASM_FMT_VALUE}${HARDWARE_ARCH} $_YASM_PLATFORM_FLAGS_VALUE $YASM_DEBUG_INFO $YASM_DEBUG_INFO_DISABLE_CACHE__NO_UID__ -D ${pre=_;suf=_:HARDWARE_TYPE} -D_YASM_ $ASM_PREFIX_VALUE $_YASM_PREDEFINED_FLAGS_VALUE $YASM_FLAGS ${pre=-I :_ASM__INCLUDE} $SRCFLAGS -o ${output;noext;suf=${OBJECT_SUF}:SRC} ${pre=-P :PREINCLUDES} ${input;hide:PREINCLUDES} ${SRC} ${kv;hide:"p AS"} ${kv;hide:"pc light-green"}
  6407. }
  6408. # tag:yasm-specific
  6409. macro _SRC_yasm(SRC, PREINCLUDES[], SRCFLAGS...) {
  6410. .CMD=$_SRC_yasm_helper(${input:SRC}, $SRCFLAGS, PREINCLUDES $PREINCLUDES)
  6411. }
  6412. ### @usage: ASM_PREINCLUDE(AsmFiles...)
  6413. ###
  6414. ### Supply additional .asm files to all assembler calls within a module
  6415. macro ASM_PREINCLUDE(PREINCLUDES...) {
  6416. SET_APPEND(YASM_PREINCLUDES_VALUE $PREINCLUDES)
  6417. }
  6418. # tag:python-specific
  6419. ### @usage: RUN_PYTHON(Args...)
  6420. ###
  6421. ### Version of RUN() macro to invoke Python scripts
  6422. ### @see: [RUN()](#macro_RUN)
  6423. macro RUN_PYTHON(Args...) {
  6424. SETUP_RUN_PYTHON()
  6425. RUN(${PYTHON_BIN} $Args)
  6426. }
  6427. ### @usage: RUN_ANTLR(Args...)
  6428. ###
  6429. ### Macro to invoke ANTLR3 generator (general case)
  6430. macro RUN_ANTLR(IN[], IN_NOPARSE[], OUT[], OUT_NOAUTO[], OUTPUT_INCLUDES[], CWD="", Args...) {
  6431. PEERDIR(build/external_resources/antlr3 build/platform/java/jdk $JDK_RESOURCE_PEERDIR)
  6432. .CMD=$_RUN_JAVA(-jar $ANTLR3_RESOURCE_GLOBAL/antlr-3.5.2-complete-no-st3.jar $Args IN $IN IN_NOPARSE $IN_NOPARSE OUT $OUT OUT_NOAUTO $OUT_NOAUTO OUTPUT_INCLUDES $OUTPUT_INCLUDES ${pre=CWD :CWD})
  6433. .SEM=run_antlr OUTPUT ${output:OUT} ${output;noauto:OUT_NOAUTO} DEPENDS ${input:IN} ${pre=WORKING_DIRECTORY :CWD} ANTLER_ARGS $Args
  6434. }
  6435. ### @usage: RUN_ANTLR4(Args...)
  6436. ###
  6437. ### Macro to invoke ANTLR4 generator (general case)
  6438. macro RUN_ANTLR4(IN[], IN_NOPARSE[], OUT[], OUT_NOAUTO[], OUTPUT_INCLUDES[], CWD="", Args...) {
  6439. PEERDIR(build/external_resources/antlr4)
  6440. _RUN_JAVA(-jar $ANTLR4_RESOURCE_GLOBAL/antlr-4.9-complete.jar $Args IN $IN IN_NOPARSE $IN_NOPARSE OUT $OUT OUT_NOAUTO $OUT_NOAUTO OUTPUT_INCLUDES $OUTPUT_INCLUDES ${pre=CWD :CWD})
  6441. }
  6442. _ANTLR4_LISTENER_GRAMMAR=-listener
  6443. _ANTLR4_LISTENER__ANTLR4_EMPTY=-no-listener
  6444. _ANTLR4_VISITOR_GRAMMAR=-visitor
  6445. _ANTLR4_VISITOR__ANTLR4_EMPTY=-no-visitor
  6446. ### @usage: RUN_ANTLR4_CPP(GRAMMAR, OUTPUT_INCLUDES, LISTENER, VISITOR, Args...)
  6447. ###
  6448. ### Macro to invoke ANTLR4 generator (Cpp)
  6449. macro RUN_ANTLR4_CPP(GRAMMAR, OUTPUT_INCLUDES[], LISTENER?"GRAMMAR":"_ANTLR4_EMPTY", VISITOR?"GRAMMAR":"_ANTLR4_EMPTY", _ANTLR4_EMPTY="", Args...) {
  6450. RUN_ANTLR4(${GRAMMAR} -Dlanguage=Cpp -o ${BINDIR} ${Args} ${_ANTLR4_VISITOR_$VISITOR} ${_ANTLR4_LISTENER_$LISTENER} CWD ${BINDIR} IN ${GRAMMAR} OUT ${noext;suf=Lexer.cpp:GRAMMAR} ${noext;suf=Lexer.h:GRAMMAR} ${noext;suf=Parser.cpp:GRAMMAR} ${noext;suf=Parser.h:GRAMMAR} ${noext;suf=Listener.h:$LISTENER} ${noext;suf=BaseListener.h:$LISTENER} ${noext;suf=Visitor.h:$VISITOR} ${noext;suf=BaseVisitor.h:$VISITOR} OUTPUT_INCLUDES ${ARCADIA_ROOT}/contrib/libs/antlr4_cpp_runtime/src/antlr4-runtime.h ${OUTPUT_INCLUDES})
  6451. PEERDIR(contrib/libs/antlr4_cpp_runtime)
  6452. }
  6453. ### @usage: RUN_ANTLR4_GO(GRAMMAR, OUTPUT_INCLUDES, LISTENER, VISITOR, Args...)
  6454. ###
  6455. ### Macro to invoke ANTLR4 generator (Go)
  6456. macro RUN_ANTLR4_GO(GRAMMAR, OUTPUT_INCLUDES[], LISTENER?"GRAMMAR":"_ANTLR4_EMPTY", VISITOR?"GRAMMAR":"_ANTLR4_EMPTY", _ANTLR4_EMPTY="", Args...) {
  6457. RUN_ANTLR4(${GRAMMAR} -Dlanguage=Go -o ${BINDIR} ${Args} ${_ANTLR4_VISITOR_$VISITOR} ${_ANTLR4_LISTENER_$LISTENER} CWD ${BINDIR} IN ${GRAMMAR} OUT ${noext;tolower;suf=_lexer.go:GRAMMAR} ${noext;tolower;suf=_parser.go:GRAMMAR} ${noext;tolower;suf=_listener.go:$LISTENER} ${noext;tolower;suf=_base_listener.go:$LISTENER} ${noext;tolower;suf=_visitor.go:$VISITOR} ${noext;tolower;suf=_base_visitor.go:$VISITOR} OUTPUT_INCLUDES ${OUTPUT_INCLUDES})
  6458. PEERDIR(${GOSTD}/fmt ${GOSTD}/reflect ${GOSTD}/strconv ${GOSTD}/unicode vendor/github.com/antlr/antlr4/runtime/Go/antlr)
  6459. }
  6460. # tag:cpp-specific
  6461. macro CPP_ADDINCL(Dirs...) {
  6462. ADDINCL($Dirs)
  6463. }
  6464. # tag:internal
  6465. _WHOLE_ARCHIVE_PEERS_VALUE=
  6466. ### @usage: WHOLE_ARCHIVE(dirnames...) # internal
  6467. macro WHOLE_ARCHIVE(PEERS...) {
  6468. SET_APPEND(_WHOLE_ARCHIVE_PEERS_VALUE ${PEERS})
  6469. REQUIRES(${PEERS})
  6470. }
  6471. ANDROID_SDK_ROOT=${ANDROID_SDK_RESOURCE_GLOBAL}/android_sdk
  6472. macro TASKLET() {
  6473. PEERDIR(tasklet/api)
  6474. # CPP
  6475. CPP_PROTO_PLUGIN(tasklet_cpp tasklet/gen/cpp .tasklet.h)
  6476. # Python
  6477. PY_PROTO_PLUGIN2(tasklet_py _tasklet.py _sbtask.py tasklet/gen/python DEPS tasklet/domain/sandbox tasklet/runtime sandbox/sdk2)
  6478. #Java
  6479. JAVA_PROTO_PLUGIN(tasket_java tasklet/gen/java DEPS tasklet/runtime/java/lib $JAVA_GRPC_STUB $JAVA_GRPC_PROTOBUF)
  6480. }
  6481. TASKLET_REG_INCLUDES= \
  6482. ${output_include;hide:"tasklet/runtime/lib/cpp_wrapper.h"} \
  6483. ${output_include;hide:"tasklet/runtime/lib/go_wrapper.h"} \
  6484. ${output_include;hide:"tasklet/runtime/lib/py_wrapper.h"} \
  6485. ${output_include;hide:"tasklet/runtime/lib/js_wrapper.h"} \
  6486. ${output_include;hide:"tasklet/runtime/lib/registry.h"}
  6487. macro TASKLET_REG(Name, Lang, Impl, Includes...) {
  6488. PEERDIR(tasklet/domain sandbox/bin sandbox/taskbox/worker)
  6489. when($Lang == "js") {
  6490. # JS runtime links the Node.js from contrib as a library, which is a bit heavy,
  6491. # so we do it, only if any JS tasklets are linked into the target
  6492. PEERDIR+=tasklet/runtime/js
  6493. }
  6494. .CMD=$YMAKE_PYTHON ${input:"build/scripts/gen_tasklet_reg.py"} $Name -l $Lang -i $Impl ${output;noauto:Name.task.cpp} $Includes ${output_include;hide:Includes} $TASKLET_REG_INCLUDES ${kv;hide:"p TT"} ${kv;hide:"pc yellow"}
  6495. SRCS(GLOBAL $Name.task.cpp)
  6496. }
  6497. # TEMPORARY METHOD FOR EXTENDED REGISTRY SETUP
  6498. # NOT COMPLETE
  6499. macro TASKLET_REG_EXT(Name, Lang, Impl, Wrapper, Includes...) {
  6500. PEERDIR(tasklet/domain sandbox/bin sandbox/taskbox/worker)
  6501. .CMD=$YMAKE_PYTHON ${input:"build/scripts/gen_tasklet_reg.py"} $Name -l $Lang -i $Impl -w $Wrapper ${output;noauto:Name.task.cpp} $Includes ${output_include;hide:Includes} $TASKLET_REG_INCLUDES ${kv;hide:"p TT"} ${kv;hide:"pc yellow"}
  6502. SRCS(GLOBAL $Name.task.cpp)
  6503. }
  6504. # tag:cpp-specific
  6505. _CPP_PROTO_MODULE_PREFIX=
  6506. _CPP_PROTO_MODULE_SUFFIX=
  6507. when ($MSVC == "yes" || $CYGWIN == "yes") {
  6508. _CPP_PROTO_MODULE_PREFIX=
  6509. _CPP_PROTO_MODULE_SUFFIX=.lib
  6510. }
  6511. otherwise {
  6512. _CPP_PROTO_MODULE_PREFIX=lib
  6513. _CPP_PROTO_MODULE_SUFFIX=.a
  6514. }
  6515. ### @usage: EXPOSE(OutputsToExport...)
  6516. ###
  6517. ### Allows to mark outputs of macro command as unused in the current module but intended
  6518. ### to be used in modules consuming current via PEERDIR.
  6519. ###
  6520. ### TODO(DEVTOOLS-9000) proper implementation needed
  6521. macro EXPOSE(Args...) {
  6522. .CMD=$YMAKE_PYTHON ${input:"build/scripts/touch.py"} ${output;suf=$_HASH_HELPER($Args).cpp:"empty_"} ${input;hide:Args}
  6523. }
  6524. # tag:proto
  6525. macro _PROTO_DESC_CMD(File) {
  6526. .CMD=${cwd;rootdir;input:File} $PROTOC -I=./$PROTO_NAMESPACE -I=$ARCADIA_ROOT/$PROTO_NAMESPACE ${pre=-I=:_PROTO__INCLUDE} -I=$ARCADIA_BUILD_ROOT -I=$PROTOBUF_PATH --descriptor_set_out=${output;suf=.desc:File} --include_source_info ${input;rootrel:File}
  6527. }
  6528. _PROTO_DESC_MERGE_CMD=$YMAKE_PYTHON ${input:"build/scripts/merge_files.py"} $TARGET $AUTO_INPUT ${kv;hide:"p PD"} ${kv;hide:"pc light-cyan"}
  6529. _PROTO_DESC_MERGE_PEERS_CMD=$YMAKE_PYTHON ${input:"build/scripts/merge_files.py"} $TARGET $PEERS $SRCS_GLOBAL ${kv;hide:"p PD"} ${kv;hide:"pc light-cyan"}
  6530. NEED_GOOGLE_PROTO_PEERDIRS=yes
  6531. PROTO_LIBRARY_SEM=$CPP_LIBRARY_SEM
  6532. # tag:proto
  6533. ### @usage: PROTO_LIBRARY()
  6534. ###
  6535. ### Build some varian of protocol buffers library.
  6536. ###
  6537. ### The particular variant is selected based on where PEERDIR to PROTO_LIBRARY comes from.
  6538. ###
  6539. ### Now supported 5 variants: C++, Java, Python 2.x, Python 3.x and Go.
  6540. ### When PEERDIR comes from module for particular language appropriate variant is selected.
  6541. ### PROTO_LIBRARY also supports emission of GRPC code if GRPC() macro is specified.
  6542. ### Notes:
  6543. ### - Python versions emit C++ code in addition to Python as optimization.
  6544. ### - In some PROTO_LIBRARY-es Java or Python versions are excluded via EXCLUDE_TAGS macros due to incompatibilities.
  6545. ### - Use from DEPENDS or BUNDLE is not allowed
  6546. ###
  6547. ### Documentation: https://wiki.yandex-team.ru/yatool/proto_library/
  6548. ###
  6549. ### See: [GRPC()](#macro_GRPC), [OPTIMIZE_PY_PROTOS()](#macro_OPTIMIZE_PY_PROTOS), [INCLUDE_TAGS()](#macro_INCLUDE_TAGS), [EXCLUDE_TAGS()](#macro_EXCLUDE_TAGS)
  6550. multimodule PROTO_LIBRARY {
  6551. module CPP_PROTO : LIBRARY {
  6552. .ALLOWED=EXPOSE
  6553. # TODO(svidyuk): think about marker which forces semantics inheritance
  6554. .SEM=PROTO_LIBRARY_SEM
  6555. ENABLE(CPP_PROTO)
  6556. ENABLE(GEN_PROTO)
  6557. NO_CLANG_TIDY()
  6558. SET(PEERDIR_TAGS CPP_PROTO)
  6559. when ($BUILD_PROTO_AS_EVLOG == "yes" && $USE_VANILLA_PROTOC == "yes") {
  6560. _OK=no
  6561. }
  6562. ASSERT(_OK BUILD_PROTO_AS_EVLOG and USE_VANILLA_PROTOC are incompatible yet)
  6563. MODULE_SUFFIX=$_CPP_PROTO_MODULE_SUFFIX
  6564. MODULE_PREFIX=$_CPP_PROTO_MODULE_PREFIX
  6565. when ($_COMMON_GOOGLE_APIS != "None") {
  6566. PEERDIR += contrib/libs/googleapis-common-protos
  6567. }
  6568. }
  6569. module JAVA_PROTO: EXTERNAL_JAVA_LIBRARY {
  6570. .EXTS=.jsrc
  6571. .ALLOWED=GRPC
  6572. .SEM=ignored
  6573. SET(PEERDIR_TAGS JAVA_PROTO)
  6574. ENABLE(JAVA_PROTO)
  6575. PEERDIR+=$JAVA_PROTOBUF_PEERS contrib/java/javax/annotation/javax.annotation-api/1.3.1
  6576. .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER USE_SKIFF CPP_PROTO_PLUGIN2 PY_PROTO_PLUGIN YMAPS_SPROTO RESOURCE
  6577. ADDINCL(FOR proto $PROTOBUF_PATH)
  6578. when ($_COMMON_GOOGLE_APIS != "None") {
  6579. PEERDIR += contrib/java/com/google/api/grpc/proto-google-common-protos/${JAVA_PROTO_COMMON_VERSION}
  6580. ADDINCL += FOR proto ${ARCADIA_ROOT}/contrib/libs/googleapis-common-protos
  6581. }
  6582. }
  6583. module PY_PROTO: PY2_LIBRARY {
  6584. .ALIASES=SRCS=PY_SRCS
  6585. .ALLOWED=OPTIMIZE_PY_PROTOS NO_OPTIMIZE_PY_PROTOS
  6586. .PEERDIRSELF=CPP_PROTO
  6587. .SEM=ignored
  6588. SET(PEERDIR_TAGS PY2 PY_PROTO)
  6589. ENABLE(PY_PROTO)
  6590. OPTIMIZE_PY_PROTOS()
  6591. OBJ_SUF=.py2
  6592. # Can not use NO_LINT(), because is not allowed outside of contrib directory
  6593. SET(LINT_LEVEL_VALUE none_internal)
  6594. when ($_COMMON_GOOGLE_APIS != "None") {
  6595. PEERDIR += contrib/libs/googleapis-common-protos
  6596. }
  6597. _IGNORE_SELF_PEERS=
  6598. _CPP_PROTO_LIBRARY=${MODDIR}/$_CPP_PROTO_MODULE_PREFIX$REALPRJNAME$_CPP_PROTO_MODULE_SUFFIX
  6599. when ($OPTIMIZE_PY_PROTOS_FLAG == "no") {
  6600. _IGNORE_PEERDIRSELF=CPP_PROTO
  6601. }
  6602. SET_APPEND(_WHOLE_ARCHIVE_LIBS_VALUE_GLOBAL $_CPP_PROTO_LIBRARY)
  6603. }
  6604. module PY3_PROTO: PY3_LIBRARY {
  6605. .ALIASES=SRCS=PY_SRCS
  6606. .ALLOWED=OPTIMIZE_PY_PROTOS NO_OPTIMIZE_PY_PROTOS
  6607. .PEERDIRSELF=CPP_PROTO
  6608. .SEM=ignored
  6609. SET(PEERDIR_TAGS PY3 PY3_PROTO)
  6610. ENABLE(PY3_PROTO)
  6611. OPTIMIZE_PY_PROTOS()
  6612. when ($MSVC == "yes" || $CYGWIN == "yes") {
  6613. MODULE_PREFIX=py3
  6614. }
  6615. otherwise {
  6616. MODULE_PREFIX=libpy3
  6617. }
  6618. OBJ_SUF=.py3
  6619. # Can not use NO_LINT(), because is not allowed outside of contrib directory
  6620. SET(LINT_LEVEL_VALUE none_internal)
  6621. when ($_COMMON_GOOGLE_APIS != "None") {
  6622. PEERDIR += contrib/libs/googleapis-common-protos
  6623. }
  6624. _IGNORE_SELF_PEERS=
  6625. _CPP_PROTO_LIBRARY=${MODDIR}/$_CPP_PROTO_MODULE_PREFIX$REALPRJNAME$_CPP_PROTO_MODULE_SUFFIX
  6626. when ($OPTIMIZE_PY_PROTOS_FLAG == "no") {
  6627. _IGNORE_PEERDIRSELF=CPP_PROTO
  6628. }
  6629. SET_APPEND(_WHOLE_ARCHIVE_LIBS_VALUE_GLOBAL $_CPP_PROTO_LIBRARY)
  6630. }
  6631. module GO_PROTO: GO_LIBRARY {
  6632. .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER YMAPS_SPROTO
  6633. .SEM=ignored
  6634. SET(PEERDIR_TAGS GO GO_PROTO)
  6635. ENABLE(GO_PROTO)
  6636. when ($_COMMON_GOOGLE_APIS == "None") {
  6637. }
  6638. elsewhen ($_COMMON_GOOGLE_APIS == "") {
  6639. PEERDIR += $_GO_COMMON_GOOGLE_APIS
  6640. ADDINCL += FOR proto ${ARCADIA_ROOT}/contrib/libs/googleapis-common-protos
  6641. }
  6642. otherwise {
  6643. PEERDIR += $_COMMON_GOOGLE_APIS
  6644. ADDINCL += FOR proto ${ARCADIA_ROOT}/contrib/libs/googleapis-common-protos
  6645. }
  6646. }
  6647. module EXT_PROTO: _BARE_UNIT {
  6648. .ALIASES=SRCS=_RAW_PROTO_SRCS
  6649. .CMD=TOUCH_UNIT_MF
  6650. .SEM=ignored
  6651. .EXTS=.*
  6652. .PROXY=yes
  6653. .PEERDIR_POLICY=as_build_from
  6654. SET(PEERDIR_TAGS EXT_PROTO)
  6655. ENABLE(EXT_PROTO)
  6656. SET(MODULE_SUFFIX .raw.fake.pkg)
  6657. SET(MODULE_TYPE LIBRARY)
  6658. when ($_COMMON_GOOGLE_APIS != "None") {
  6659. PEERDIR += contrib/libs/googleapis-common-protos
  6660. }
  6661. SET(CREDITS_FILE_EXTRA_EXT .ext_proto)
  6662. }
  6663. module DESC_PROTO: _BARE_UNIT {
  6664. .CMD=_PROTO_DESC_MERGE_CMD
  6665. .SEM=ignored
  6666. .EXTS=.desc
  6667. .NODE_TYPE=Library
  6668. .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER YMAPS_SPROTO RESOURCE GO_PROTO_PLUGIN GRPC
  6669. SET(PEERDIR_TAGS DESC_PROTO)
  6670. ENABLE(DESC_PROTO)
  6671. MODULE_SUFFIX=.self.protodesc
  6672. SET(MODULE_TYPE LIBRARY)
  6673. MACRO_ALIAS(EVLOG_CMD _PROTO_DESC_CMD)
  6674. MACRO_ALIAS(PROTO_CMD _PROTO_DESC_CMD)
  6675. when ($_COMMON_GOOGLE_APIS != "None") {
  6676. PEERDIR += contrib/libs/googleapis-common-protos
  6677. }
  6678. when ($NEED_GOOGLE_PROTO_PEERDIRS == "yes") {
  6679. when ($USE_VANILLA_PROTOC == "yes") {
  6680. PEERDIR += contrib/libs/protobuf_std/builtin_proto/protos_from_protobuf
  6681. }
  6682. otherwise {
  6683. PEERDIR += contrib/libs/protobuf/builtin_proto/protos_from_protoc
  6684. }
  6685. }
  6686. }
  6687. module PB_PY_PROTO: _PY_PACKAGE {
  6688. .INCLUDE_TAG=no
  6689. .PROXY=yes
  6690. .SEM=ignored
  6691. SET(MODULE_SUFFIX .pb_py.fake.pkg)
  6692. ENABLE(PB_PY_PROTO)
  6693. # WARN:
  6694. # _COMMON_GOOGLE_APIS aren't handled intentionally.
  6695. # PB_PY_PROTO is a legacy module type, stop using it.
  6696. }
  6697. }
  6698. # tag:proto
  6699. _EXT_PROTO_DIR=_RAW_
  6700. # tag:proto
  6701. ### This var defines the root of the tree for copied proto files from EXT_PROTO
  6702. ### submodule of PROTO_LIBRARY module
  6703. EXT_PROTO_ROOT=${ARCADIA_BUILD_ROOT}/${_EXT_PROTO_DIR}
  6704. # tag:proto
  6705. ### @usage: USE_EXT_PROTO(peerdir_tag...)
  6706. ###
  6707. ### Configure module to use proto files from existing PROTO_LIBRARY module.
  6708. ### Additional PEERDIR tags required to build a module can be passed through
  6709. ### EXTRA_TAGS vararg parameter.
  6710. macro USE_EXT_PROTO(EXTRA_TAGS...) {
  6711. SET(PEERDIR_TAGS EXT_PROTO ${EXTRA_TAGS})
  6712. SRCDIR(${EXT_PROTO_ROOT})
  6713. }
  6714. # tag:proto tag:internal
  6715. ### @usage: _RAW_PROTO_SRCS(files...) # internal
  6716. ###
  6717. ### _RAW_PROTO_SRCS is a proxy macro to FILES macro which filters out
  6718. ### GLOBAL keyword from the list of files (NOTE! The order of files listed
  6719. ### originally in call to _RAW_PROTO_SRCS() macro is changed in call to
  6720. ### FILES() macro). Currently this macro copies only files with the following
  6721. ### extensions: .proto, .gztproto, .ev
  6722. macro _RAW_PROTO_SRCS(FILES...) {
  6723. COPY_FILES_TO_BUILD_PREFIX(${ext=.proto:FILES} PREFIX ${_EXT_PROTO_DIR})
  6724. COPY_FILES_TO_BUILD_PREFIX(${ext=.gztproto:FILES} PREFIX ${_EXT_PROTO_DIR})
  6725. COPY_FILES_TO_BUILD_PREFIX(${ext=.ev:FILES} PREFIX ${_EXT_PROTO_DIR})
  6726. }
  6727. module PROTO_DESCRIPTIONS: _BARE_UNIT {
  6728. .CMD=_PROTO_DESC_MERGE_PEERS_CMD
  6729. .PEERDIR_POLICY=as_build_from
  6730. .NODE_TYPE=Library
  6731. .RESTRICTED=SRCS
  6732. .FINAL_TARGET=yes
  6733. SET(PEERDIR_TAGS DESC_PROTO)
  6734. SET(MODULE_SUFFIX .protodesc)
  6735. SET(MODULE_TYPE PROTO_DESCRIPTIONS)
  6736. }
  6737. module PROTO_REGISTRY: PROTO_DESCRIPTIONS {
  6738. SET(MODULE_TYPE PROTO_REGISTRY)
  6739. }
  6740. # tag:fbs
  6741. _FBS_NAMESPACE_MAP_GLOBAL=
  6742. # tag:fbs
  6743. macro _FBS_NAMESPACE_IMPL(NAMESPACE, PATH, DUMMY...) {
  6744. SET_APPEND(_FBS_NAMESPACE_MAP_GLOBAL ${NAMESPACE}=${PATH})
  6745. }
  6746. # tag:fbs
  6747. macro FBS_NAMESPACE(NAMESPACE, PATH...) {
  6748. _FBS_NAMESPACE_IMPL($NAMESPACE $PATH $MODDIR)
  6749. }
  6750. # tag:fbs
  6751. ### @usage: FBS_LIBRARY()
  6752. ###
  6753. ### Build some variant of Flatbuffers library.
  6754. ###
  6755. ### The particular variant is selected based on where PEERDIR to FBS_LIBRARY
  6756. ### comes from.
  6757. ###
  6758. ### Now supported 5 variants: C++, Java, Python 2.x, Python 3.x and Go.
  6759. ### When PEERDIR comes from module for particular language appropriate variant
  6760. ### is selected.
  6761. ###
  6762. ### Notes: FBS_NAMESPACE must be specified in all dependent FBS_LIBRARY modules
  6763. ### if build of Go code is requested.
  6764. multimodule FBS_LIBRARY {
  6765. module CPP_FBS: LIBRARY {
  6766. ENABLE(CPP_FBS)
  6767. SET(PEERDIR_TAGS CPP_FBS)
  6768. }
  6769. module GO_FBS: GO_LIBRARY {
  6770. .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER
  6771. ENABLE(GO_FBS)
  6772. SET(PEERDIR_TAGS GO GO_FBS)
  6773. }
  6774. module JAVA_FBS: EXTERNAL_JAVA_LIBRARY {
  6775. .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER
  6776. ENABLE(JAVA_FBS)
  6777. SET(PEERDIR_TAGS JAVA_FBS)
  6778. }
  6779. module PY2_FBS: PY2_LIBRARY {
  6780. .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER
  6781. .ALIASES=SRCS=PY_SRCS
  6782. ENABLE(PY2_FBS)
  6783. SET(PEERDIR_TAGS PY2 PY2_FBS)
  6784. # Can not use NO_LINT(), because is not allowed outside of contrib directory
  6785. SET(LINT_LEVEL_VALUE none_internal)
  6786. }
  6787. module PY3_FBS: PY3_LIBRARY {
  6788. .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER
  6789. .ALIASES=SRCS=PY_SRCS
  6790. ENABLE(PY3_FBS)
  6791. SET(PEERDIR_TAGS PY3 PY3_FBS)
  6792. # Can not use NO_LINT(), because is not allowed outside of contrib directory
  6793. SET(LINT_LEVEL_VALUE none_internal)
  6794. when ($MSVC == "yes" || $CYGWIN == "yes") {
  6795. MODULE_PREFIX=py3
  6796. }
  6797. otherwise {
  6798. MODULE_PREFIX=libpy3
  6799. }
  6800. OBJ_SUF=.py3
  6801. }
  6802. }
  6803. # tag:java-specific
  6804. _COMPILE_JSRC=${cwd:ARCADIA_BUILD_ROOT} $YMAKE_PYTHON ${input:"build/scripts/compile_jsrc.py"} --input $AUTO_INPUT --output $TARGET --prefix $BINDIR ${kv;hide:"p JC"} ${kv;hide:"pc light-blue"} ${kv;hide:"show_out"}
  6805. # tag:java-specific
  6806. COMPILE_JSRC_MF=$_COMPILE_JSRC && $GENERATE_MF
  6807. # tag:java-specific tag:internal
  6808. ### @usage: JSRC_LIBRARY() # internal
  6809. module JSRC_LIBRARY: _BARE_UNIT {
  6810. .CMD=COMPILE_JSRC_MF
  6811. .EXTS=.java
  6812. .ALL_INS_TO_OUT=no
  6813. .PEERDIR_POLICY=as_include
  6814. .FINAL_TARGET=no
  6815. .ALIASES=SRCS=FILES
  6816. PEERDIR_TAGS=JAVA_PROTO JAVA_FBS JAVA_IDL
  6817. MODULE_TYPE=Library
  6818. SET(MODULE_SUFFIX .jsrc)
  6819. SET(DONT_RESOLVE_INCLUDES yes)
  6820. SET(NEED_PLATFORM_PEERDIRS no)
  6821. SET(MODULE_LANG JAVA)
  6822. NO_RUNTIME()
  6823. }
  6824. # tag:maps-specific
  6825. @import "${CONF_ROOT}/conf/project_specific/maps/asrc.conf"
  6826. # tag:internal
  6827. ### @usage: _PROXY_LIBRARY() # internal
  6828. ###
  6829. ### The use of this module is strictly prohibited!!!
  6830. module _PROXY_LIBRARY: LIBRARY {
  6831. .EXTS=.a .lib
  6832. .PEERDIR_POLICY=as_build_from
  6833. .PROXY=yes
  6834. .FINAL_TARGET=yes
  6835. DISABLE(NEED_ADD_FAKE_SRC)
  6836. NO_UTIL()
  6837. NO_RUNTIME()
  6838. }
  6839. # tag:maps-specific
  6840. @import "${CONF_ROOT}/conf/project_specific/maps/aar.conf"
  6841. @import "${CONF_ROOT}/conf/project_specific/maps/sproto.conf"
  6842. @import "${CONF_ROOT}/conf/project_specific/maps/mapkit.conf"
  6843. _PRIMARY_OUTPUT_VALUE=
  6844. # tag:internal
  6845. ### @usage: PRIMARY_OUTPUT_VALUE(Output) # internal
  6846. ###
  6847. ### The use of this module is strictly prohibited!!!
  6848. macro PRIMARY_OUTPUT(OUTPUT) {
  6849. SET(_PRIMARY_OUTPUT_VALUE $OUTPUT)
  6850. }
  6851. _DLL_PROXY_LIBRARY_CMD=$GENERATE_MF && $COPY_CMD $_PRIMARY_OUTPUT_VALUE ${input;hide:_PRIMARY_OUTPUT_VALUE} ${TARGET}
  6852. # tag:internal
  6853. ### @usage: DLL_PROXY_LIBRARY() # internal
  6854. ###
  6855. ### The use of this module is strictly prohibited!!!
  6856. module DLL_PROXY_LIBRARY: _PROXY_LIBRARY {
  6857. .ALLOWED=PRIMARY_OUTPUT
  6858. .CMD=_DLL_PROXY_LIBRARY_CMD
  6859. }
  6860. _PREBUILT_PROGRAM_CMD=$GENERATE_MF && $COPY_CMD $_PRIMARY_OUTPUT_VALUE ${TARGET} ${kv;hide:"p ld"} ${kv;hide:"pc light-blue"} ${kv;hide:"show_out"}
  6861. # tag:internal
  6862. ### @usage: PREBUILT_PROGRAM([programname]) # internal
  6863. ###
  6864. ### Program module which uses a prebuilt prgram as its output.
  6865. module PREBUILT_PROGRAM: _LINK_UNIT {
  6866. .CMD=_PREBUILT_PROGRAM_CMD
  6867. .SYMLINK_POLICY=EXE
  6868. .ALLOWED=INDUCED_DEPS PRIMARY_OUTPUT
  6869. .RESTRICTED=SRCS
  6870. _BARE_LINK_MODULE()
  6871. SET(MODULE_TYPE PROGRAM)
  6872. when ($WIN32 == "yes" || $OS_CYGWIN == "yes") {
  6873. MODULE_SUFFIX=.exe
  6874. }
  6875. }
  6876. ### @usage COLLECT_JINJA_TEMPLATES(varname path)
  6877. ###
  6878. ### This macro collects all jinja and yaml files in the directory specified by second argument and
  6879. ### stores result in the variable with mane specified by first parameter.
  6880. macro COLLECT_JINJA_TEMPLATES(VAR, DIR) {
  6881. _GLOB($VAR ${DIR}/**/*.jinja ${DIR}/**/*.yaml)
  6882. }
  6883. # tag:go-specific
  6884. GO_HOST_OS=unknown
  6885. when ($HOST_OS_LINUX) {
  6886. GO_HOST_OS=linux
  6887. }
  6888. elsewhen ($HOST_OS_DARWIN) {
  6889. GO_HOST_OS=darwin
  6890. }
  6891. elsewhen($HOST_OS_WINDOWS) {
  6892. GO_HOST_OS=windows
  6893. }
  6894. # tag:go-specific
  6895. GO_HOST_ARCH=unknown
  6896. when ($HOST_ARCH_X86_64) {
  6897. GO_HOST_ARCH=amd64
  6898. }
  6899. elsewhen($HOST_ARCH_ARM64) {
  6900. GO_HOST_ARCH=arm64
  6901. }
  6902. # tag:go-specific
  6903. GO_TARG_OS=unknown
  6904. when ($OS_LINUX) {
  6905. GO_TARG_OS=linux
  6906. }
  6907. elsewhen ($OS_DARWIN) {
  6908. GO_TARG_OS=darwin
  6909. }
  6910. elsewhen ($OS_WINDOWS) {
  6911. GO_TARG_OS=windows
  6912. }
  6913. # tag:go-specific
  6914. GO_TARG_ARCH=unknwon
  6915. when ($ARCH_X86_64) {
  6916. GO_TARG_ARCH=amd64
  6917. }
  6918. elsewhen ($ARCH_I386) {
  6919. GO_TARG_ARCH=x86
  6920. }
  6921. elsewhen ($ARCH_ARM64) {
  6922. GO_TARG_ARCH=arm64
  6923. }
  6924. # tag:go-specific
  6925. GO_HOST_TARG_PARAMS=++host-os $GO_HOST_OS ++host-arch $GO_HOST_ARCH ++targ-os $GO_TARG_OS ++targ-arch $GO_TARG_ARCH
  6926. # tag:go-specific
  6927. GOSTD_VERSION=1.17.8
  6928. when ($GOSTD_VERSION == "1.17.8") {
  6929. GOSTD=contrib/go/_std/src
  6930. }
  6931. elsewhen ($GOSTD_VERSION == "1.18rc1") {
  6932. GOSTD=contrib/go/_std_1.18rc1/src
  6933. }
  6934. otherwise {
  6935. GOSTD=__unsupported_go_std_library_version_[$GOSTD_VERSION]__
  6936. }
  6937. # tag:go-specific
  6938. GO_DEBUG_PATH_RELATIVE=no
  6939. _GO_DEBUG_PATH__NO_UID__=
  6940. _GO_COMPILE_SYMABIS_TRIMPATH__NO_UID__=
  6941. # tag:go-specific
  6942. _GO_IMPORT_PATH=${MODDIR}
  6943. # tag:go-specific
  6944. GO_VET=yolint
  6945. GO_VET_TOOL=
  6946. GO_VET_FLAGS=
  6947. GO_VET_EXTRA_FLAGS=
  6948. # tag:go-specific
  6949. _GO_VET_ADD_CHECK=yes
  6950. _GO_FMT_ADD_CHECK=yes
  6951. _GO_YDX_FILE=
  6952. # tag:go-specific
  6953. _GO_CGO1_WRAPPER_FLAGS=--build-prefix=/-B --source-prefix=/-S
  6954. _GO_LINK_EXE_EXT_CMD=
  6955. # tag:go-specific
  6956. GO_WITH_MUSL=
  6957. # tag:go-specific
  6958. GO_TOOLS_ROOT=${GO_TOOLS_RESOURCE_GLOBAL}
  6959. GO_TEST_MINER=${tool:"tools/go_test_miner"}
  6960. GO_TEST_IMPORT_PATH=
  6961. # tag:go-specific
  6962. GO_STD_LIB_PREFIX=${GOSTD}/
  6963. GO_ARCADIA_PROJECT_PREFIX=a.yandex-team.ru/
  6964. GO_CONTRIB_PROJECT_PREFIX=vendor/
  6965. GO_SKIP_IMPORTS=unsafe C
  6966. GO_VET_INFO_EXT=.vet.out
  6967. GO_VET_REPORT_EXT=.vet.txt
  6968. GO_VET_OUTPUT_INFO=${output;rootrel;hide;pre=${MODULE_PREFIX};suf=${MODULE_SUFFIX}${GO_VET_INFO_EXT}:REALPRJNAME}
  6969. GO_VET_OUTPUT_REPORT=${output;rootrel;hide;pre=${MODULE_PREFIX};suf=${MODULE_SUFFIX}${GO_VET_REPORT_EXT}:REALPRJNAME}
  6970. # tag:go-specific tag:codenav
  6971. _GO_YNDEXER_EXT=.ydx.pb2
  6972. GO_YNDEXER_OUTPUT=${output;pre=${MODULE_PREFIX};suf=${MODULE_SUFFIX}${_GO_YNDEXER_EXT}:REALPRJNAME}
  6973. # tag:go-specific
  6974. GO_PROJECT_PREFIXES=++std-lib-prefix $GO_STD_LIB_PREFIX ++arc-project-prefix $GO_ARCADIA_PROJECT_PREFIX
  6975. # tag:go-specific
  6976. _GO_FAKEID=${FAKEID}.${BUILD_TYPE}.${GO_FAKEID}
  6977. # tag:go-specific
  6978. CGO2_CFLAGS_VALUE=
  6979. CGO2_LDFLAGS_VALUE=
  6980. # tag:go-specific
  6981. GO_ASM_FLAGS_VALUE=
  6982. ### @usage: GO_ASM_FLAGS(flags)
  6983. ### Add the specified flags to the go asm compile command line.
  6984. macro GO_ASM_FLAGS(Flags...) {
  6985. SET_APPEND(GO_ASM_FLAGS_VALUE $Flags)
  6986. }
  6987. # tag:go-specific
  6988. GO_CGO1_FLAGS_VALUE=
  6989. ### @usage: GO_CGO1_FLAGS(flags)
  6990. ### Add the specified flags to the go cgo compile command line.
  6991. macro GO_CGO1_FLAGS(Flags...) {
  6992. SET_APPEND(GO_CGO1_FLAGS_VALUE $Flags)
  6993. }
  6994. # tag:go-specific
  6995. GO_CGO2_FLAGS_VALUE=
  6996. ### @usage: GO_CGO2_FLAGS(flags)
  6997. ### Add the specified flags to the go cgo compile command line.
  6998. macro GO_CGO2_FLAGS(Flags...) {
  6999. SET_APPEND(GO_CGO2_FLAGS_VALUE $Flags)
  7000. }
  7001. # tag:go-specific
  7002. GO_COMPILE_FLAGS_VALUE=$USER_GO_COMPILE_FLAGS
  7003. ### @usage: GO_COMPILE_FLAGS(flags)
  7004. ### Add the specified flags to the go compile command line.
  7005. macro GO_COMPILE_FLAGS(Flags...) {
  7006. SET_APPEND(GO_COMPILE_FLAGS_VALUE $Flags)
  7007. }
  7008. # tag:go-specific
  7009. GO_LINK_FLAGS_VALUE=$USER_GO_LINK_FLAGS
  7010. ### @usage: GO_LINK_FLAGS(flags)
  7011. ### Add the specified flags to the go link command line.
  7012. macro GO_LINK_FLAGS(Flags...) {
  7013. SET_APPEND(GO_LINK_FLAGS_VALUE $Flags)
  7014. }
  7015. # tag:go-specific
  7016. _GO_TOOL_MODE=
  7017. # tag:go-specific
  7018. _GO_TOOL_COMMON_FLAGS=\
  7019. ++mode $_GO_TOOL_MODE \
  7020. $GO_PROJECT_PREFIXES \
  7021. ++goversion $GOSTD_VERSION \
  7022. ++source-root $ARCADIA_ROOT \
  7023. ++build-root $ARCADIA_BUILD_ROOT \
  7024. ++output-root $BINDIR \
  7025. ++toolchain-root $GO_TOOLS_ROOT \
  7026. $GO_HOST_TARG_PARAMS \
  7027. ++output $TARGET \
  7028. $GO_VET_OUTPUT \
  7029. $_GO_YDX_FILE \
  7030. $_GO_DEBUG_PATH__NO_UID__ \
  7031. ++srcs $AUTO_INPUT ${input:GO_FILES} \
  7032. ++asm-flags $GO_ASM_FLAGS_VALUE \
  7033. ++compile-flags $GO_COMPILE_FLAGS_VALUE \
  7034. ++link-flags $GO_LINK_FLAGS_VALUE \
  7035. ++cgo-srcs ${input:CGO_FILES} \
  7036. $_GO_EMBED_VALUE \
  7037. $GO_TOOLCHAIN_ENV
  7038. # tag:go-specific
  7039. macro _GO_GEN_COVER_GO(GO_FILE, VAR_ID) {
  7040. .CMD=${hide:_GO_FAKEID} $GO_TOOLS_ROOT/pkg/tool/${GO_HOST_OS}_${GO_HOST_ARCH}/cover -mode set -var $VAR_ID -o ${output;noext;suf=.cover.go:GO_FILE} ${input:GO_FILE}
  7041. }
  7042. # tag:go-specific
  7043. macro _GO_COMPILE_SYMABIS(FLAGS[], ASM_FILES...) {
  7044. .CMD=${hide:_GO_FAKEID} $GO_TOOLS_ROOT/pkg/tool/${GO_HOST_OS}_${GO_HOST_ARCH}/asm $_GO_COMPILE_SYMABIS_TRIMPATH__NO_UID__ ${pre=-I :_C__INCLUDE} -I $GO_TOOLS_ROOT/pkg/include -D GOOS_${GO_TARG_OS} -D GOARCH_${GO_TARG_ARCH} $FLAGS $GO_ASM_FLAGS_VALUE -gensymabis -o ${output:"gen.symabis"} ${input:ASM_FILES} ${kv;hide:"p go"} ${kv;hide:"pc light-blue"} ${kv;hide:"show_out"}
  7045. .ADDINCL=build/scripts/go_fake_include
  7046. }
  7047. # tag:go-specific
  7048. macro _GO_COMPILE_CGO1(NAME, FLAGS[], FILES...) {
  7049. .CMD=${hide:_GO_FAKEID} ${cwd:ARCADIA_ROOT} $YMAKE_PYTHON ${input:"build/scripts/cgo1_wrapper.py"} $_GO_CGO1_WRAPPER_FLAGS --build-root ${ARCADIA_BUILD_ROOT} --source-root ${ARCADIA_ROOT} --cgo1-files ${output;noext:FILES.cgo1.go} --cgo2-files ${output;noauto;noext:FILES.cgo2.c} -- ${GO_TOOLS_ROOT}/pkg/tool/${GO_HOST_OS}_${GO_HOST_ARCH}/cgo -objdir $BINDIR -importpath $NAME $GO_CGO1_FLAGS_VALUE $FLAGS -- $C_FLAGS_PLATFORM ${pre=-I:_C__INCLUDE} ${CGO_CFLAGS_VALUE} ${input:FILES} ${output;hide:"_cgo_export.h"} ${output;hide:"_cgo_export.c"} ${output;hide:"_cgo_gotypes.go"} ${output;noauto;hide:"_cgo_main.c"} ${output;noauto;hide:"_cgo_flags"} $GO_TOOLCHAIN_ENV ${kv;hide:"p go"} ${kv;hide:"pc light-blue"} ${kv;hide:"show_out"}
  7050. }
  7051. # tag:go-specific
  7052. macro _GO_COMPILE_CGO2(NAME, C_FILES[], S_FILES[], OBJ_FILES[], FILES...) {
  7053. .CMD=${hide:_GO_FAKEID} $C_COMPILER $C_FLAGS_PLATFORM ${pre=-I:_C__INCLUDE} $CGO_CFLAGS_VALUE ${input;tobindir:"_cgo_main.c"} -c -o ${tmp;noauto;suf=${OBJECT_SUF}:"_cgo_main.c"} && $C_COMPILER $C_FLAGS_PLATFORM ${pre=-I:_C__INCLUDE} -o ${tmp;noauto;suf=${OBJECT_SUF}:"_cgo_"} $LDFLAGS $LDFLAGS_GLOBAL $CGO2_LDFLAGS_VALUE ${input;hide:"_cgo_export.h"} ${tmp;noauto;suf=${OBJECT_SUF}:"_cgo_main.c"} ${input;suf=${OBJECT_SUF}:"_cgo_export.c"} ${input;nopath;noext;suf=.cgo2.c${OBJECT_SUF}:FILES} ${input;suf=${OBJECT_SUF}:C_FILES} ${input;suf=.o:S_FILES} ${input:OBJ_FILES} $CGO_LDFLAGS_VALUE && ${GO_TOOLS_ROOT}/pkg/tool/${GO_HOST_OS}_${GO_HOST_ARCH}/cgo -dynpackage $NAME -dynimport ${tmp;noauto;suf=${OBJECT_SUF}:"_cgo_"} -dynout ${output:"_cgo_import.go"} -dynlinker $GO_CGO2_FLAGS_VALUE $GO_TOOLCHAIN_ENV ${kv;hide:"p go"} ${kv;hide:"pc light-blue"} ${kv;hide:"show_out"}
  7054. _USE_LINKER()
  7055. }
  7056. # tag:go-specific
  7057. macro _GO_LINK_LIB_IMPL(CGO_FILES[], EXTRA_INPUTS[], GO_FILES...) {
  7058. .CMD=${hide:_GO_FAKEID} $YMAKE_PYTHON ${input:"build/scripts/go_tool.py"} ${hide;input:EXTRA_INPUTS} --ya-start-command-file $_GO_TOOL_COMMON_FLAGS ++peers ${rootrel;tags_in=local,GO|local,GO_PROTO|local,GO_FBS:PEERS} --ya-end-command-file ${kv;hide:"p GO"} ${kv;hide:"pc light-red"} ${kv;hide:"show_out"}
  7059. }
  7060. # tag:go-specific
  7061. macro _GO_LINK_EXE_IMPL(CGO_FILES[], EXTRA_INPUTS[], GO_FILES...) {
  7062. .CMD=${hide:_GO_FAKEID} $YMAKE_PYTHON ${input:"build/scripts/go_tool.py"} ${hide;input:EXTRA_INPUTS} --ya-start-command-file $_GO_TOOL_COMMON_FLAGS ++vcs $VCS_GO $GO_WITH_MUSL $GO_EXTLD ++peers ${rootrel;tags_in=local,GO|local,GO_PROTO|local,GO_FBS:PEERS} ++non-local-peers ${rootrel;tags_in=GO|GO_PROTO|GO_FBS;tags_out=local:PEERS} ++cgo-peers ${VCS_C_OBJ_RR} ${rootrel;tags_out=GO|GO_PROTO|GO_FBS:PEERS} --ya-end-command-file ${kv;hide:"p LD"} ${kv;hide:"pc light-red"} ${kv;hide:"show_out"} $_GO_LINK_EXE_EXT_CMD
  7063. }
  7064. # tag:go-specific
  7065. macro _GO_LINK_TEST_IMPL(CGO_FILES[], EXTRA_INPUTS[], GO_TEST_FILES[], GO_XTEST_FILES[], GO_FILES...) {
  7066. .CMD=${hide:_GO_FAKEID} $YMAKE_PYTHON ${input:"build/scripts/go_tool.py"} ${hide;input:EXTRA_INPUTS} --ya-start-command-file $_GO_TOOL_COMMON_FLAGS ++vcs $VCS_GO $GO_WITH_MUSL $GO_EXTLD ++test-miner $GO_TEST_MINER ++test-import-path $GO_TEST_IMPORT_PATH ++peers ${rootrel;tags_in=local,GO|local,GO_PROTO|local,GO_FBS:PEERS} ++non-local-peers ${rootrel;tags_in=GO|GO_PROTO|GO_FBS;tags_out=local:PEERS} ++cgo-peers ${VCS_C_OBJ_RR} ${rootrel;tags_out=GO|GO_PROTO|GO_FBS:PEERS} ++test_srcs ${input:GO_TEST_FILES} ++xtest_srcs ${input:GO_XTEST_FILES} ++cover_info $GO_COVER_INFO_VALUE ++skip-tests $_GO_SKIP_TEST_VALUE --ya-end-command-file ${kv;hide:"p GO"} ${kv;hide:"pc light-red"} ${kv;hide:"show_out"}
  7067. }
  7068. # tag:go-specific
  7069. GO_LINK_LIB=$GENERATE_MF && $_GO_LINK_LIB_IMPL($_GO_SRCS_VALUE CGO_FILES $_CGO_SRCS_VALUE EXTRA_INPUTS $_GO_EMBED_INPUTS)
  7070. GO_LINK_EXE=$GENERATE_MF && $GENERATE_VCS_C_INFO_NODEP && $GENERATE_VCS_GO_INFO_NODEP && $_GO_LINK_EXE_IMPL($_GO_SRCS_VALUE CGO_FILES $_CGO_SRCS_VALUE EXTRA_INPUTS $_GO_EMBED_INPUTS)
  7071. GO_LINK_TEST=$GENERATE_VCS_C_INFO_NODEP && $GENERATE_VCS_GO_INFO_NODEP && $_GO_LINK_TEST_IMPL($_GO_SRCS_VALUE CGO_FILES $_CGO_SRCS_VALUE EXTRA_INPUTS $_GO_EMBED_INPUTS GO_TEST_FILES $_GO_TEST_SRCS_VALUE GO_XTEST_FILES $_GO_XTEST_SRCS_VALUE)
  7072. GO_LINK_DLL=$GO_LINK_EXE && $COPY_CMD $BINDIR/_cgo_export.h ${output;pre=${MODULE_PREFIX};suf=.h:REALPRJNAME}
  7073. # tag:go-specific
  7074. CGO_ENABLED=yes
  7075. when ($OS_WINDOWS == "yes" || $SANITIZER_TYPE && $SANITIZER_TYPE != "no") {
  7076. CGO_ENABLED=no
  7077. }
  7078. # tag:go-specific
  7079. GO_PACKAGE_VALUE=
  7080. ### @usage: GO_PACKAGE_NAME(Name)
  7081. ### Override name of a Go package.
  7082. macro GO_PACKAGE_NAME(NAME) {
  7083. SET(GO_PACKAGE_VALUE $NAME)
  7084. }
  7085. # tag:go-specific tag:internal
  7086. _GO_SRCS_VALUE=
  7087. ### @usage: _GO_SRCS(Files...) # internal
  7088. ### This macro shouldn't be used in ya.make files, use SRCS() instead.
  7089. ### This is internal macro collecting .go sources for processing within Go modules (GO_PROGRAM and GO_LIBRARY)
  7090. macro _GO_SRCS(FILES...) {
  7091. GO_FAKE_OUTPUT($FILES)
  7092. SET_APPEND(_GO_SRCS_VALUE $FILES)
  7093. }
  7094. # tag:go-specific
  7095. _GO_TEST_SRCS_VALUE=
  7096. GO_HAS_INTERNAL_TESTS=no
  7097. ### @usage: GO_TEST_SRCS(Files...)
  7098. ### .go sources for internal tests of a module
  7099. macro GO_TEST_SRCS(FILES...) {
  7100. GO_FAKE_OUTPUT($FILES)
  7101. _SET_FIRST_VALUE(GO_HAS_INTERNAL_TESTS ${pre=yes :FILES} ${GO_HAS_INTERNAL_TESTS})
  7102. SET_APPEND(_GO_TEST_SRCS_VALUE $FILES)
  7103. }
  7104. # tag:go-specific
  7105. _GO_XTEST_SRCS_VALUE=
  7106. GO_HAS_EXTERNAL_TESTS=no
  7107. ### @usage: GO_XTEST_SRCS(Files...)
  7108. ### .go sources for external tests of a module
  7109. macro GO_XTEST_SRCS(FILES...) {
  7110. GO_FAKE_OUTPUT($FILES)
  7111. SET(GO_HAS_EXTERNAL_TESTS yes)
  7112. SET_APPEND(_GO_XTEST_SRCS_VALUE $FILES)
  7113. }
  7114. # tag:go-specific
  7115. macro _GO_UNUSED_SRCS(FLAGS...) {
  7116. ENABLE(UNUSED_MACRO)
  7117. }
  7118. # tag:go-specific
  7119. _CGO_SRCS_VALUE=
  7120. ### @usage: CGO_SRCS(Files...)
  7121. ### .go sources to be built with CGO
  7122. macro CGO_SRCS(FILES...) {
  7123. SET_APPEND(_CGO_SRCS_VALUE $FILES)
  7124. PEERDIR(${GOSTD}/syscall)
  7125. }
  7126. # tag:go-specific
  7127. GO_LDFLAGS_GLOBAL=
  7128. ### @usage: GO_LDFLAGS(Flags...)
  7129. ### Link flags for GO_PROGRAM linking from .go sources
  7130. macro GO_LDFLAGS(FLAGS...) {
  7131. SET_APPEND(GO_LDFLAGS_GLOBAL $FLAGS)
  7132. }
  7133. # tag:go-specific
  7134. CGO_CFLAGS_VALUE=
  7135. ### @usage: CGO_CFLAGS(Flags...)
  7136. ### Compiler flags specific to CGO compilation
  7137. macro CGO_CFLAGS(FLAGS...) {
  7138. SET_APPEND(CGO_CFLAGS_VALUE $FLAGS)
  7139. CFLAGS($FLAGS)
  7140. }
  7141. # tag:go-specific
  7142. CGO_LDFLAGS_VALUE=
  7143. ### @usage: CGO_LDFLAGS(Files...)
  7144. ### Linker flags specific to CGO linking
  7145. macro CGO_LDFLAGS(FLAGS...) {
  7146. SET_APPEND(CGO_LDFLAGS_VALUE $FLAGS)
  7147. GO_LDFLAGS($FLAGS)
  7148. }
  7149. # tag:go-specific
  7150. _GO_SKIP_TEST_VALUE=
  7151. ### @usage: GO_SKIP_TESTS(TestNames...)
  7152. ###
  7153. ### Define a set of tests that should not be run.
  7154. ### NB! Subtests are not taken into account!
  7155. macro GO_SKIP_TESTS(TESTS...) {
  7156. SET_APPEND(_GO_SKIP_TEST_VALUE $TESTS)
  7157. RESTRICT_PATH(vendor MSG This macro is prohibited to be used outside the vendor/ directory)
  7158. }
  7159. # tag:go-specific tag:internal
  7160. _GO_EMBED_VALUE=
  7161. _GO_EMBED_INPUTS=
  7162. ### @usage: _GO_EMBED_PATTERN(PATTERN) # internal
  7163. ###
  7164. ### Define an embed pattern.
  7165. macro _GO_EMBED_PATTERN(XTEST?"_xtest":"", PATTERN, IMPORT_PATH) {
  7166. SET(VAR_SALT1 $XTEST $PATTERN $IMPORT_PATH 1)
  7167. SET(_PATTERN_GLOB1 uniq_embed_${hash:VAR_SALT1})
  7168. _GLOB($_PATTERN_GLOB1 ${ARCADIA_ROOT}/${IMPORT_PATH}/${PATTERN}/**/* EXCLUDE ${ARCADIA_ROOT}/${IMPORT_PATH}/${PATTERN}/**/_* ${ARCADIA_ROOT}/${IMPORT_PATH}/${PATTERN}/**/.*)
  7169. SET(VAR_SALT2 $XTEST $PATTERN $IMPORT_PATH 2)
  7170. SET(_PATTERN_GLOB2 _uniq_embed_${hash:VAR_SALT2})
  7171. _GLOB($_PATTERN_GLOB2 ${ARCADIA_ROOT}/${IMPORT_PATH}/${PATTERN})
  7172. SET_APPEND(_GO_EMBED_VALUE ++embed$XTEST $PATTERN \$$_PATTERN_GLOB1 \$$_PATTERN_GLOB2)
  7173. SET_APPEND(_GO_EMBED_INPUTS \$$_PATTERN_GLOB1 \$$_PATTERN_GLOB2)
  7174. }
  7175. # tag:go-specific
  7176. ### @usage: GO_EMBED_PATTERN(PATTERN)
  7177. ###
  7178. ### Define an embed pattern.
  7179. macro GO_EMBED_PATTERN(PATTERN) {
  7180. _GO_EMBED_PATTERN($PATTERN $_GO_IMPORT_PATH)
  7181. }
  7182. # tag:go-specific
  7183. ### @usage: GO_TEST_EMBED_PATTERN(PATTERN)
  7184. ###
  7185. ### Define an embed pattern for internal go tests.
  7186. macro GO_TEST_EMBED_PATTERN(PATTERN) {
  7187. _GO_EMBED_PATTERN($PATTERN $_GO_IMPORT_PATH)
  7188. }
  7189. # tag:go-specific
  7190. ### @usage: GO_XTEST_EMBED_PATTERN(PATTERN)
  7191. ###
  7192. ### Define an embed pattern for external go tests.
  7193. macro GO_XTEST_EMBED_PATTERN(PATTERN) {
  7194. _GO_EMBED_PATTERN(XTEST $PATTERN $_GO_IMPORT_PATH)
  7195. }
  7196. # tag:go-specific tag:internal
  7197. ### @usage: _GO_EMBED_DIR(PATTERN) # internal
  7198. ###
  7199. ### Define an embed directory DIR.
  7200. macro _GO_EMBED_DIR(XTEST?"_xtest":"", DIR, IMPORT_PATH) {
  7201. SET(VAR_SALT $XTEST $DIR $IMPORT_PATH)
  7202. SET(_PATTERN_GLOB uniq_embed_${hash:VAR_SALT})
  7203. _GLOB($_PATTERN_GLOB ${ARCADIA_ROOT}/${IMPORT_PATH}/${DIR}/**/* EXCLUDE ${ARCADIA_ROOT}/${IMPORT_PATH}/${DIR}/**/_* ${ARCADIA_ROOT}/${IMPORT_PATH}/${DIR}/**/.*)
  7204. SET_APPEND(_GO_EMBED_VALUE ++embed$XTEST $DIR \$$_PATTERN_GLOB)
  7205. SET_APPEND(_GO_EMBED_INPUTS \$$_PATTERN_GLOB)
  7206. }
  7207. # tag:go-specific
  7208. ### @usage: GO_EMBED_DIR(DIR)
  7209. ###
  7210. ### Define an embed directory DIR.
  7211. macro GO_EMBED_DIR(DIR) {
  7212. _GO_EMBED_DIR($DIR $_GO_IMPORT_PATH)
  7213. }
  7214. # tag:go-specific
  7215. ### @usage: GO_TEST_EMBED_DIR(DIR)
  7216. ###
  7217. ### Define an embed directory DIR for internal go tests.
  7218. macro GO_EMBED_TEST_DIR(DIR) {
  7219. _GO_EMBED_DIR($DIR $_GO_IMPORT_PATH)
  7220. }
  7221. # tag:go-specific
  7222. ### @usage: GO_XTEST_EMBED_DIR(DIR)
  7223. ###
  7224. ### Define an embed directory DIR for external go tests.
  7225. macro GO_EMBED_XTEST_DIR(DIR) {
  7226. _GO_EMBED_DIR(XTEST $DIR $_GO_IMPORT_PATH)
  7227. }
  7228. # tag:go-specific
  7229. _GO_TOOLCHAIN_ENV_GOARCH=unknown
  7230. when ($ARCH_ARM64) {
  7231. _GO_TOOLCHAIN_ENV_GOARCH=${env:"GOARCH=arm64"}
  7232. }
  7233. elsewhen ($ARCH_X86_64) {
  7234. _GO_TOOLCHAIN_ENV_GOARCH=${env:"GOARCH=amd64"}
  7235. }
  7236. # tag:go-specific
  7237. _GO_TOOLCHAIN_ENV_GOOS=unknown
  7238. when ($OS_DARWIN) {
  7239. _GO_TOOLCHAIN_ENV_GOOS=${env:"GOOS=darwin"}
  7240. }
  7241. elsewhen ($OS_LINUX) {
  7242. _GO_TOOLCHAIN_ENV_GOOS=${env:"GOOS=linux"}
  7243. }
  7244. elsewhen ($OS_WINDOWS) {
  7245. _GO_TOOLCHAIN_ENV_GOOS=${env:"GOOS=windows"}
  7246. }
  7247. _GO_TOOLCHAIN_ENV_PATH=
  7248. # tag:go-specific
  7249. GO_TOOLCHAIN_ENV=$TOOLCHAIN_ENV $_GO_TOOLCHAIN_ENV_GOARCH $_GO_TOOLCHAIN_ENV_GOOS $_GO_TOOLCHAIN_ENV_PATH
  7250. # tag:go-specific
  7251. _GO_GRPC_WELLKNOWN=\
  7252. vendor/google.golang.org/grpc \
  7253. vendor/google.golang.org/grpc \
  7254. vendor/google.golang.org/grpc/codes \
  7255. vendor/google.golang.org/grpc/grpclog \
  7256. vendor/google.golang.org/grpc/status
  7257. # tag:go-specific
  7258. macro _GO_GRPC() {
  7259. SET(GO_PROTO_GEN_PLUGINS grpc)
  7260. PEERDIR(${GOSTD}/context ${_GO_GRPC_WELLKNOWN})
  7261. }
  7262. # tag:go-specific
  7263. ### @usage: GO_GRPC_GATEWAY_SRCS()
  7264. ###
  7265. ### Use of grpc-gateway plugin (Supported for Go only).
  7266. macro GO_GRPC_GATEWAY_SRCS(FILE...) {
  7267. ENABLE(UNUSED_MACRO)
  7268. }
  7269. # tag:go-specific
  7270. ### @usage: GO_GRPC_GATEWAY_SWAGGER_SRCS()
  7271. ###
  7272. ### Use of grpc-gateway plugin w/ swagger emission (Supported for Go only).
  7273. macro GO_GRPC_GATEWAY_SWAGGER_SRCS(FILE...) {
  7274. PEERDIR(vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options)
  7275. }
  7276. # tag:go-specific
  7277. _GO_PROTO_GRPC_GATEWAY_OPTS=
  7278. _GO_PROTO_GRPC_GATEWAY_OUTS=
  7279. # tag:go-specific
  7280. macro _GO_GRPC_GATEWAY_SRCS_IMPL(Files...) {
  7281. foreach (File : $Files) {
  7282. [.proto]=$_GO_PROTO_CMD_IMPL($File OPTS $_GO_PROTO_GRPC_GATEWAY_OPTS OUTS $_GO_PROTO_GRPC_GATEWAY_OUTS)
  7283. }
  7284. PEERDIR(${GOSTD}/context ${GOSTD}/io ${GOSTD}/net/http)
  7285. PEERDIR(vendor/github.com/golang/protobuf/descriptor)
  7286. PEERDIR(vendor/github.com/grpc-ecosystem/grpc-gateway/runtime)
  7287. PEERDIR(vendor/github.com/grpc-ecosystem/grpc-gateway/utilities)
  7288. PEERDIR(vendor/google.golang.org/grpc/metadata)
  7289. }
  7290. # tag:go-specific
  7291. macro _SETUP_GO_GRPC_GATEWAY() {
  7292. SET(_GO_PROTO_GRPC_GATEWAY_OPTS $_PROTO_PLUGIN_ARGS_BASE(go_grpc_gw vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway allow_repeated_fields_in_body=true:))
  7293. SET(_GO_PROTO_GRPC_GATEWAY_OUTS \${output;hide;norel;nopath;noext;suf=.pb.gw.go:File})
  7294. }
  7295. # tag:go-specific
  7296. macro _GO_GRPC_GATEWAY_SRCS(Files...) {
  7297. _SETUP_GO_GRPC_GATEWAY()
  7298. _GO_GRPC_GATEWAY_SRCS_IMPL($Files)
  7299. }
  7300. # tag:go-specific
  7301. macro _GO_GRPC_GATEWAY_SWAGGER_SRCS(Files...) {
  7302. _SETUP_GO_GRPC_GATEWAY()
  7303. SET_APPEND(_GO_PROTO_GRPC_GATEWAY_OPTS $_PROTO_PLUGIN_ARGS_BASE(swagger vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger logtostderr=true:))
  7304. SET_APPEND(_GO_PROTO_GRPC_GATEWAY_OUTS \${output;hide;norel;noauto;nopath;noext;suf=.swagger.json:File})
  7305. _GO_GRPC_GATEWAY_SRCS_IMPL($Files)
  7306. PEERDIR(vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options)
  7307. }
  7308. # tag:go-specific
  7309. when ($MUSL == "yes") {
  7310. _GO_DEFAULT_ALLOCATOR=$DEFAULT_ALLOCATOR
  7311. }
  7312. otherwise {
  7313. _GO_DEFAULT_ALLOCATOR=FAKE
  7314. }
  7315. # tag:go-specific tag:internal
  7316. ### @usage _GO_BASE_UNIT # internal
  7317. ###
  7318. ### The base module of all golang modules. Defines common properties, dependencies and rules for go build.
  7319. module _GO_BASE_UNIT: _BASE_UNIT {
  7320. .EXTS=.go .gosrc .o .obj .a .symabis .mf
  7321. .CMD=TOUCH_UNIT
  7322. .NODE_TYPE=Bundle
  7323. .GLOBAL=GO_LDFLAGS
  7324. .PEERDIR_POLICY=as_build_from
  7325. .ALIASES=SRCS=_GO_SRCS RESOURCE=_GO_RESOURCE GO_TEST_SRCS=_GO_UNUSED_SRCS GO_XTEST_SRCS=_GO_UNUSED_SRCS GRPC=_GO_GRPC GO_GRPC_GATEWAY_SRCS=_GO_GRPC_GATEWAY_SRCS GO_GRPC_GATEWAY_SWAGGER_SRCS=_GO_GRPC_GATEWAY_SWAGGER_SRCS CFLAGS=CGO_CFLAGS GO_TEST_EMBED_PATTERN=_GO_UNUSED_SRCS GO_XTEST_EMBED_PATTERN=_GO_UNUSED_SRCS GO_TEST_EMBED_DIR=_GO_UNUSED_SRCS GO_XTEST_EMBED_DIR=_GO_UNUSED_SRCS
  7326. .ALLOWED=GO_PROTO_PLUGIN USE_CXX USE_UTIL RESOURCE_FILES
  7327. .IGNORED=GO_SKIP_TESTS USE_SKIFF
  7328. ENABLE(_GO_MODULE)
  7329. SET(MODULE_TAG GO)
  7330. PEERDIR_TAGS=GO GO_PROTO GO_FBS __EMPTY__
  7331. DEFAULT(_GO_VET_TOOL)
  7332. DEFAULT(_GO_VET_FLAGS)
  7333. DEFAULT(_GO_VET_EXTS)
  7334. DEFAULT(_GO_SONAME)
  7335. NO_RUNTIME()
  7336. SET(COVERAGE_FLAGS)
  7337. SET(EXTRA_OUTPUT)
  7338. SET(MODULE_LANG GO)
  7339. PEERDIR(build/external_resources/go_tools)
  7340. GO_PROTO_OUTS+=${output;hide;norel;nopath;noext;suf=.pb.go:File}
  7341. when ($COMPILER_PLATFORM && $NEED_PLATFORM_PEERDIRS == "yes") {
  7342. PEERDIR+=$COMPILER_PLATFORM
  7343. }
  7344. when ($CLANG == "yes" || $GCC == "yes") {
  7345. CGO_CFLAGS_VALUE += -w -pthread -fpic
  7346. CGO2_CFLAGS_VALUE += -Wno-unused-variable
  7347. }
  7348. select ($GO_VET) {
  7349. "yes" | "on" ? {
  7350. _GO_VET=yes
  7351. _GO_VET_FLAGS+=-cgocall=false
  7352. }
  7353. "yndexer" ? {
  7354. _GO_VET=yes
  7355. PEERDIR+=build/external_resources/goyndexer
  7356. _GO_VET_TOOL=${GOYNDEXER_RESOURCE_GLOBAL}/goyndexer
  7357. _GO_YDX_FILE=++ydx-file ${_GO_YNDEXER_EXT}
  7358. _GO_VET_FLAGS=-indexer.arc ${ARCADIA_ROOT} -indexer.indexfile ${GO_YNDEXER_OUTPUT} -indexer.loglevel info
  7359. _GO_FMT_ADD_CHECK=no
  7360. _GO_VET_ADD_CHECK=no
  7361. GO_VET_INFO_EXT=.ydx.out
  7362. GO_VET_REPORT_EXT=.ydx.txt
  7363. _GO_VET_EXTS=++vet-info-ext .ydx.out ++vet-report-ext .ydx.txt
  7364. _GO_CGO1_WRAPPER_FLAGS=--build-prefix=__ARCADIA_BUILD_ROOT_PREFIX__ --source-prefix=__ARCADIA_SOURCE_ROOT_PREFIX__
  7365. }
  7366. "yolint" ? {
  7367. _GO_VET=yes
  7368. PEERDIR+=build/external_resources/yolint
  7369. _GO_VET_TOOL=${YOLINT_RESOURCE_GLOBAL}/yolint
  7370. _GO_VET_FLAGS=-migration.config=${input:"${ARCADIA_ROOT}/build/rules/go/migrations.yaml"} -scopelint.config=${input:"${ARCADIA_ROOT}/build/rules/go/extended_lint.yaml"} -importcheck=false -SA1019=false -copyproto=false -bodyclose=false -rowserrcheck=false -ytcheck=false
  7371. }
  7372. "yolint_next" ? {
  7373. _GO_VET=yes
  7374. PEERDIR+=build/external_resources/yolint
  7375. _GO_VET_TOOL=${YOLINT_NEXT_RESOURCE_GLOBAL}/yolint
  7376. _GO_VET_FLAGS=-copyproto=false
  7377. }
  7378. "local" ? {
  7379. _GO_VET=yes
  7380. _GO_VET_FLAGS=
  7381. }
  7382. default ? {
  7383. _GO_VET=no
  7384. _GO_VET_FLAGS=
  7385. }
  7386. }
  7387. SET(_GO_VET $_GO_VET)
  7388. when ($GO_VET_TOOL == "") {
  7389. _GO_VET_TOOL_REAL=$_GO_VET_TOOL
  7390. }
  7391. otherwise {
  7392. _GO_VET_TOOL_REAL=$GO_VET_TOOL
  7393. }
  7394. when ($GO_VET_FLAGS == "") {
  7395. _GO_VET_FLAGS_REAL=$_GO_VET_FLAGS
  7396. }
  7397. otherwise {
  7398. _GO_VET_FLAGS_REAL=$GO_VET_FLAGS
  7399. }
  7400. when ($_GO_VET == "yes" && $NO_GO_VET != "yes") {
  7401. GO_VET_OUTPUT=++vet $_GO_VET_TOOL_REAL ++vet-flags $_GO_VET_FLAGS_REAL $GO_VET_EXTRA_FLAGS $GO_VET_OUTPUT_INFO $GO_VET_OUTPUT_REPORT $_GO_VET_EXTS
  7402. }
  7403. otherwise {
  7404. GO_VET_OUTPUT=
  7405. _GO_VET_ADD_CHECK=no
  7406. }
  7407. when ($GO_DEBUG_PATH_RELATIVE == "yes") {
  7408. _GO_DEBUG_PATH__NO_UID__=++debug-root-map source=;build=;tools= ++tools-root $(TOOL_ROOT)
  7409. _GO_COMPILE_SYMABIS_TRIMPATH__NO_UID__=-trimpath $ARCADIA_ROOT=>;$ARCADIA_BUILD_ROOT=>;$(TOOL_ROOT)=>
  7410. }
  7411. otherwise {
  7412. _GO_DEBUG_PATH__NO_UID__=++debug-root-map source=/-S;build=/-B;tools=/-T ++tools-root $(TOOL_ROOT)
  7413. _GO_COMPILE_SYMABIS_TRIMPATH__NO_UID__=-trimpath $ARCADIA_ROOT=>/-S;$ARCADIA_BUILD_ROOT=>/-B;$(TOOL_ROOT)=>/-T
  7414. }
  7415. _GO_PROCESS_SRCS()
  7416. when ($CLANG == "yes") {
  7417. _GO_EXTLD=clang
  7418. GO_TOOLCHAIN_ENV += ${env:"CC=clang"}
  7419. }
  7420. otherwise {
  7421. _GO_EXTLD=gcc
  7422. GO_TOOLCHAIN_ENV += ${env:"CC=gcc"}
  7423. }
  7424. when ($OS_DARWIN) {
  7425. PEERDIR+=build/external_resources/go_fake_xcrun
  7426. GO_EXTLD = ++extld $_GO_EXTLD ++extldflags $_GO_SONAME $LD_SDK_VERSION -undefined dynamic_lookup $C_FLAGS_PLATFORM --sysroot=$MACOS_SDK_RESOURCE_GLOBAL --start-wa ${rootrel;ext=.a:SRCS_GLOBAL} --end-wa ${rootrel;ext=.o:SRCS_GLOBAL} --cgo-peers $LDFLAGS $LDFLAGS_GLOBAL $OBJADDE $OBJADDE_LIB $GO_LDFLAGS_GLOBAL $C_LIBRARY_PATH $C_SYSTEM_LIBRARIES_INTERCEPT $C_SYSTEM_LIBRARIES $STRIP_FLAG
  7427. CGO2_LDFLAGS_VALUE += $LD_SDK_VERSION -undefined dynamic_lookup -nodefaultlibs -lc
  7428. }
  7429. elsewhen ($OS_LINUX) {
  7430. GO_EXTLD = ++extld $_GO_EXTLD ++extldflags $_GO_SONAME $C_FLAGS_PLATFORM --sysroot=$OS_SDK_ROOT_RESOURCE_GLOBAL -Wl,--whole-archive ${rootrel;ext=.a:SRCS_GLOBAL} -Wl,--no-whole-archive ${rootrel;ext=.o:SRCS_GLOBAL} --cgo-peers $LDFLAGS $LDFLAGS_GLOBAL $OBJADDE $OBJADDE_LIB $GO_LDFLAGS_GLOBAL $C_LIBRARY_PATH $C_SYSTEM_LIBRARIES_INTERCEPT $C_SYSTEM_LIBRARIES $STRIP_FLAG
  7431. CGO2_LDFLAGS_VALUE += -Wl,--unresolved-symbols=ignore-all -nodefaultlibs -lc
  7432. }
  7433. otherwise {
  7434. GO_EXTLD = ++extld $_GO_EXTLD
  7435. }
  7436. when ($RACE == "yes") {
  7437. _GO_COMPILE_FLAGS_RACE=-race
  7438. _GO_LINK_FLAGS_RACE=-race
  7439. }
  7440. otherwise {
  7441. _GO_COMPILE_FLAGS_RACE=
  7442. _GO_LINK_FLAGS_RACE=
  7443. }
  7444. when ($PIC == "yes") {
  7445. _GO_COMPILE_FLAGS_SHARED=-shared
  7446. _GO_ASM_FLAGS_SHARED=-shared
  7447. }
  7448. otherwise {
  7449. _GO_COMPILE_FLAGS_SHARED=
  7450. _GO_ASM_FLAGS_SHARED=
  7451. }
  7452. GO_ASM_FLAGS_VALUE += $_GO_ASM_FLAGS_SHARED
  7453. GO_COMPILE_FLAGS_VALUE += $_GO_COMPILE_FLAGS_RACE $_GO_COMPILE_FLAGS_SHARED
  7454. GO_LINK_FLAGS_VALUE += $_GO_LINK_FLAGS_RACE
  7455. ADDINCL(${GOSTD}/runtime)
  7456. }
  7457. # tag:go-specific
  7458. ### @usage: GO_LIBRARY([name])
  7459. ###
  7460. ### Go library module definition.
  7461. ### Compile Go module as a library suitable for PEERDIR from other Go modules.
  7462. ### Will select Go implementation on PEERDIR to PROTO_LIBRARY.
  7463. module GO_LIBRARY: _GO_BASE_UNIT {
  7464. .CMD=GO_LINK_LIB
  7465. .NODE_TYPE=Bundle
  7466. .FINAL_TARGET=no
  7467. SET(_GO_TOOL_MODE lib)
  7468. SET(MODULE_TYPE LIBRARY)
  7469. _REQUIRE_EXPLICIT_LICENSE(vendor)
  7470. MODULE_SUFFIX=.a
  7471. }
  7472. # tag:go-specific
  7473. ### @usage: GO_PROGRAM([name])
  7474. ###
  7475. ### Go program module definition.
  7476. ### Compile and link Go module to an executable program.
  7477. ### Will select Go implementation on PEERDIR to PROTO_LIBRARY.
  7478. module GO_PROGRAM: _GO_BASE_UNIT {
  7479. .CMD=GO_LINK_EXE
  7480. .NODE_TYPE=Bundle
  7481. .SYMLINK_POLICY=EXE
  7482. .ALLOWED=INDUCED_DEPS
  7483. .FINAL_TARGET=yes
  7484. SET(_GO_TOOL_MODE exe)
  7485. SET(MODULE_TYPE PROGRAM)
  7486. SET(GO_VET_OUTPUT_INFO)
  7487. ALLOCATOR($_GO_DEFAULT_ALLOCATOR)
  7488. _USE_LINKER()
  7489. ENABLE(COMMON_LINK_SETTINGS)
  7490. when ($MUSL == "yes") {
  7491. PEERDIR += contrib/libs/musl/full
  7492. }
  7493. when ($MSVC == "yes" || $CYGWIN == "yes") {
  7494. MODULE_SUFFIX=.exe
  7495. }
  7496. PEERDIR(${GOSTD}/runtime library/go/core/buildinfo)
  7497. when ($RACE == "yes") {
  7498. PEERDIR += ${GOSTD}/runtime/cgo
  7499. PEERDIR += ${GOSTD}/runtime/race
  7500. }
  7501. when ($MUSL == "yes") {
  7502. GO_WITH_MUSL = ++musl
  7503. }
  7504. }
  7505. # tag:go-specific
  7506. module _GO_DLL_BASE_UNIT: GO_PROGRAM {
  7507. .CMD=GO_LINK_DLL
  7508. .SYMLINK_POLICY=SO
  7509. .ALLOWED=WHOLE_ARCHIVE
  7510. SET(_GO_TOOL_MODE dll)
  7511. SET(MODULE_TYPE DLL)
  7512. GO_PACKAGE_NAME(main)
  7513. when ($MSVC == "yes" || $CYGWIN == "yes") {
  7514. MODULE_SUFFIX=.dll
  7515. }
  7516. elsewhen ($DARWIN == "yes" || $OS_IOS == "yes") {
  7517. MODULE_PREFIX=lib
  7518. MODULE_SUFFIX=.dylib$MODULE_VERSION
  7519. }
  7520. otherwise {
  7521. MODULE_PREFIX=lib
  7522. MODULE_SUFFIX=.so$MODULE_VERSION
  7523. }
  7524. when ($OS_DARWIN) {
  7525. _GO_SONAME=-Wl,-install_name,$SONAME
  7526. }
  7527. elsewhen ($OS_LINUX) {
  7528. _GO_SONAME=-Wl,-soname,$SONAME
  7529. }
  7530. when ($MODULE_VERSION) {
  7531. when ($OS_LINUX || $OS_DARWIN) {
  7532. _GO_LINK_EXE_EXT_CMD+= && $LINK_OR_COPY_CMD $TARGET ${output;nopath;noext:SONAME}
  7533. }
  7534. }
  7535. }
  7536. # tag:go-specific
  7537. ### @usage: GO_DLL(name major_ver [minor_ver] [PREFIX prefix])
  7538. ###
  7539. ### Go ishared object module definition.
  7540. ### Compile and link Go module to a shared object.
  7541. ### Will select Go implementation on PEERDIR to PROTO_LIBRARY.
  7542. module GO_DLL: _GO_DLL_BASE_UNIT {
  7543. }
  7544. # tag:go-specific tag:test
  7545. ### @usage: GO_BENCH_TIMEOUT(x)
  7546. ###
  7547. ### Sets timeout in seconds for 1 Benchmark in go benchmark suite
  7548. ###
  7549. ### Documentation about the system test: https://wiki.yandex-team.ru/yatool/test/
  7550. macro GO_BENCH_TIMEOUT(bench_timeout) {
  7551. SET(GO_BENCH_TIMEOUT $bench_timeout)
  7552. }
  7553. # tag:go-specific tag:test
  7554. ### @usage: GO_TEST([name])
  7555. ###
  7556. ### Go test module definition.
  7557. ### Compile and link Go module as a test suitable for running with Arcadia testing support.
  7558. ### All usual testing support macros like DATA, DEPENDS, SIZE, REQUIREMENTS etc. are supported.
  7559. ### Will select Go implementation on PEERDIR to PROTO_LIBRARY.
  7560. module GO_TEST: GO_PROGRAM {
  7561. .CMD=GO_LINK_TEST
  7562. .ALIASES=GO_TEST_SRCS=GO_TEST_SRCS GO_XTEST_SRCS=GO_XTEST_SRCS GO_TEST_EMBED_PATTERN=GO_TEST_EMBED_PATTERN GO_XTEST_EMBED_PATTERN=GO_XTEST_EMBED_PATTERN GO_TEST_EMBED_DIR=GO_TEST_EMBED_DIR GO_XTEST_EMBED_DIR=GO_XTEST_EMBED_DIR
  7563. .ALLOWED=GO_SKIP_TESTS YT_SPEC
  7564. .FINAL_TARGET=no
  7565. SET(_GO_TOOL_MODE test)
  7566. SET(MODULE_TYPE PROGRAM)
  7567. ENABLE(GO_TEST_MODULE)
  7568. SET(GO_COVER_INFO_VALUE)
  7569. # We have to add uncoditionaly PEERDIR to ${GOSTD}/os here thouth it is really
  7570. # needed when TestMain is defined in the source code of the test
  7571. PEERDIR(${GOSTD}/os)
  7572. PEERDIR(${GOSTD}/testing/internal/testdeps)
  7573. PEERDIR(${GOSTD}/testing)
  7574. ADD_YTEST($MODULE_PREFIX$REALPRJNAME go.test)
  7575. ADD_YTEST($MODULE_PREFIX$REALPRJNAME go.bench)
  7576. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS canondata/result.json)
  7577. }
  7578. # tag:go-specific
  7579. macro GO_MOCKGEN_FROM(Path) {
  7580. SET(MOCKGEN_FROM ${Path})
  7581. }
  7582. # tag:go-specific
  7583. macro GO_MOCKGEN_TYPES(First, Rest...) {
  7584. SET(MOCKGEN_FIRST $First)
  7585. SET(MOCKGEN_REST $Rest)
  7586. }
  7587. # tag:go-specific
  7588. macro GO_MOCKGEN_REFLECT() {
  7589. PEERDIR(${GOSTD}/encoding/gob)
  7590. PEERDIR(${GOSTD}/flag)
  7591. PEERDIR(${GOSTD}/fmt)
  7592. PEERDIR(${GOSTD}/os)
  7593. PEERDIR(${GOSTD}/path)
  7594. PEERDIR(${GOSTD}/reflect)
  7595. PEERDIR(vendor/github.com/golang/mock/mockgen/model)
  7596. PEERDIR(${MOCKGEN_FROM})
  7597. RUN_PROGRAM(vendor/github.com/golang/mock/mockgen -prog_only a.yandex-team.ru/${MOCKGEN_FROM} $MOCKGEN_FIRST${pre=$__COMMA__:MOCKGEN_REST} STDOUT main.go)
  7598. }
  7599. # tag:go-specific
  7600. macro GO_MOCKGEN_MOCKS() {
  7601. PEERDIR(${GOSTD}/reflect)
  7602. PEERDIR(vendor/github.com/golang/mock/gomock)
  7603. RUN_PROGRAM(vendor/github.com/golang/mock/mockgen -package mocks -exec_only ${BINDIR}/gen/gen a.yandex-team.ru/${MOCKGEN_FROM} $MOCKGEN_FIRST${pre=$__COMMA__:MOCKGEN_REST} TOOL ${MODDIR}/gen STDOUT mocks.go)
  7604. }
  7605. # tag:java-specific
  7606. JAVA_IGNORE_CLASSPATH_CLASH_VALUE=
  7607. ### @usage: JAVA_IGNORE_CLASSPATH_CLASH_FOR([classes])
  7608. ### Ignore classpath clash test fails for classes
  7609. macro JAVA_IGNORE_CLASSPATH_CLASH_FOR(Args...) {
  7610. SET_APPEND(JAVA_IGNORE_CLASSPATH_CLASH_VALUE $Args)
  7611. }
  7612. # tag:python-specific
  7613. ### @usage: PY_SRCS({| CYTHON_C} { | TOP_LEVEL | NAMESPACE ns} Files...)
  7614. ###
  7615. ### Build specified Python sources according to Arcadia binary Python build. Basically creates precompiled and source resources keyed with module paths.
  7616. ### The resources eventually are linked into final program and can be accessed as regular Python modules.
  7617. ### This custom loader linked into the program will add them to sys.meta_path.
  7618. ###
  7619. ### PY_SRCS also support .proto, .ev, .pyx and .swg files. The .proto and .ev are compiled to .py-code by protoc and than handled as usual .py files.
  7620. ### .pyx and .swg lead to C/C++ Python extensions generation, that are automatically registered in Python as built-in modules.
  7621. ###
  7622. ### By default .pyx files are built as C++-extensions. Use CYTHON_C to build them as C (similar to BUILDWITH_CYTHON_C, but with the ability to specify namespace).
  7623. ###
  7624. ### __init__.py never required, but if present (and specified in PY_SRCS), it will be imported when you import package modules with __init__.py Oh.
  7625. ###
  7626. ### @example
  7627. ###
  7628. ### PY2_LIBRARY(mymodule)
  7629. ### PY_SRCS(a.py sub/dir/b.py e.proto sub/dir/f.proto c.pyx sub/dir/d.pyx g.swg sub/dir/h.swg)
  7630. ### END()
  7631. ###
  7632. ### PY_SRCS honors Python2 and Python3 differences and adjusts itself to Python version of a current module.
  7633. ### PY_SRCS can be used in any Arcadia Python build modules like PY*_LIBRARY, PY*_PROGRAM, PY*TEST.
  7634. ### PY_SRCS in LIBRARY or PROGRAM effectively converts these into PY2_LIBRARY and PY2_PROGRAM respectively.
  7635. ### It is strongly advised to make this conversion explicit. Never use PY_SRCS in a LIBRARY if you plan to use it from external Python extension module.
  7636. ###
  7637. ### Documentation: https://wiki.yandex-team.ru/arcadia/python/pysrcs/#modulipylibrarypy3libraryimakrospysrcs
  7638. macro PY_SRCS() {
  7639. DEFAULT(MODULE_TAG PY2)
  7640. DEFAULT(PYTHON2 yes)
  7641. DEFAULT(PYTHON3 no)
  7642. }
  7643. # tag:python-specific
  7644. _ALL_PY_FILES=
  7645. # tag:python-specific
  7646. macro _ALL_PY_SRCS2(TOP_LEVEL?"TOP_LEVEL":"", RECURSIVE?"/**":"", NAMESPACE[], REST[]) {
  7647. _GLOB(_ALL_PY_FILES ${suf=${RECURSIVE}/*.py:REST} ${suf=${RECURSIVE}/ya.make:REST} EXCLUDE ya.make)
  7648. PY_SRCS(_MR ${pre=NAMESPACE :NAMESPACE} ${TOP_LEVEL} $_ALL_PY_FILES)
  7649. }
  7650. # tag:python-specific
  7651. ### @usage: ALL_PY_SRCS([RECURSIVE] { | TOP_LEVEL | NAMESPACE ns} [Dirs...])
  7652. ###
  7653. ### Puts all .py-files from given Dirs (relative to projects') into PY_SRCS of the current module.
  7654. ### If Dirs is ommitted project directory is used
  7655. ###
  7656. ### `RECURSIVE` makes lookup recursive with resprect to Dirs
  7657. ### `TOP_LEVEL` and `NAMESPACE` are forwarded to `PY_SRCS`
  7658. ###
  7659. ### Note: Only one such macro per module is allowed
  7660. ### Note: Macro is designed to reject any ya.make files in Dirs except current one
  7661. ###
  7662. ### @see [PY_SRCS()](#macro_PY_SRCS)
  7663. macro ALL_PY_SRCS(TOP_LEVEL?"TOP_LEVEL":"", NAMESPACE="", RECURSIVE?"RECURSIVE":"", Files...) {
  7664. _ALL_PY_SRCS2(${pre=NAMESPACE :NAMESPACE} ${TOP_LEVEL} ${RECURSIVE} REST .${pre=/:Files})
  7665. }
  7666. # tag:python-specific
  7667. _PY_EXTRA_LINT_FILES_VALUE=
  7668. ### @usage: PY_EXTRA_LINT_FILES(files...)
  7669. ###
  7670. ### Add extra Python files for linting. This macro allows adding
  7671. ### Python files which has no .py extension.
  7672. macro PY_EXTRA_LINT_FILES(FILES...) {
  7673. SET_APPEND(_PY_EXTRA_LINT_FILES_VALUE $FILES)
  7674. }
  7675. # tag:python-specific
  7676. ### @usage: PY23_LIBRARY([name])
  7677. ###
  7678. ### Build PY2_LIBRARY or PY3_LIBRARY depending on incoming PEERDIR.
  7679. ### Direct build or build by RECURSE creates both variants.
  7680. ### This multimodule doesn't define any final targets, so use from DEPENDS or BUNDLE is not allowed.
  7681. ###
  7682. ### Documentation: https://wiki.yandex-team.ru/arcadia/python/pysrcs
  7683. multimodule PY23_LIBRARY {
  7684. module PY2: PY2_LIBRARY {
  7685. OBJ_SUF=.py2
  7686. RUN_CYTHON_SCRIPT=$YMAKE_PYTHON $CYTHON_SCRIPT
  7687. }
  7688. module PY3: PY3_LIBRARY {
  7689. RUN_CYTHON_SCRIPT=$YMAKE_PYTHON $CYTHON_SCRIPT
  7690. when ($MSVC == "yes" || $CYGWIN == "yes") {
  7691. MODULE_PREFIX=py3
  7692. }
  7693. otherwise {
  7694. MODULE_PREFIX=libpy3
  7695. }
  7696. OBJ_SUF=.py3
  7697. }
  7698. }
  7699. # tag:python-specific
  7700. ### @usage: PY23_NATIVE_LIBRARY([name])
  7701. ###
  7702. ### Build LIBRARY compatible with either Python 2.x or Python 3.x depending on incoming PEERDIR.
  7703. ###
  7704. ### This multimodule doesn't depend on Arcadia Python binary build. It is intended only for C++ code and cannot contain PY_SRCS and USE_PYTHON2 macros.
  7705. ### Use these multimodule instead of PY23_LIBRARY if the C++ extension defined in it will be used in PY2MODULE.
  7706. ### While it doesn't bring Arcadia Python dependency itself, it is still compatible with Arcadia Python build and can be PEERDIR-ed from PY2_LIBRARY and alikes.
  7707. ### Proper version will be selected according to Python version of the module PEERDIR comes from.
  7708. ###
  7709. ### This mulrtimodule doesn't define any final targets so cannot be used from DEPENDS or BUNDLE macros.
  7710. ###
  7711. ### For more information read https://wiki.yandex-team.ru/arcadia/python/pysrcs/#pysrcssrcsipy23nativelibrary
  7712. ###
  7713. ### @see [LIBRARY()](#module_LIBRARY), [PY2MODULE()](#module_PY2MODULE)
  7714. multimodule PY23_NATIVE_LIBRARY {
  7715. module PY2: LIBRARY {
  7716. .RESTRICTED=PY_SRCS USE_PYTHON2 USE_PYTHON3 PYTHON3_ADDINCL
  7717. OBJ_SUF=.py2
  7718. PYTHON2_ADDINCL()
  7719. SET(MODULE_LANG PY2)
  7720. }
  7721. module PY3: LIBRARY {
  7722. .RESTRICTED=PY_SRCS USE_PYTHON2 USE_PYTHON3
  7723. .ALIASES=PYTHON2_ADDINCL=PYTHON3_ADDINCL
  7724. PYTHON3_ADDINCL()
  7725. SET(MODULE_LANG PY3)
  7726. when ($MSVC == "yes" || $CYGWIN == "yes") {
  7727. MODULE_PREFIX=py3c
  7728. }
  7729. otherwise {
  7730. MODULE_PREFIX=libpy3c
  7731. }
  7732. OBJ_SUF=.py3
  7733. }
  7734. }
  7735. IBTOOL_PATH=$XCODE_TOOLS_ROOT_RESOURCE_GLOBAL/Xcode/Contents/Developer/usr/bin/ibtool
  7736. # tag:src-processing
  7737. STORYBOARD_FLAGS=--errors --warnings --notices --auto-activate-custom-fonts --output-format human-readable-text
  7738. macro _SRC("storyboard", SRC, SRCFLAGS...) {
  7739. .CMD=$IBTOOL_PATH $STORYBOARD_FLAGS --module $REALPRJNAME --output-partial-info-plist ${output;suf=.partial_plist:SRC} --compilation-directory $BINDIR ${input:SRC} && $YMAKE_PYTHON ${input:"build/scripts/tar_directory.py"} ${output;tobindir;suf=.compiled_storyboard_tar:SRC} $BINDIR/${nopath;suf=c:SRC} $BINDIR/${nopath;suf=c:SRC}
  7740. }
  7741. # tag:src-processing
  7742. macro _SRC("xib", SRC, SRCFLAGS...) {
  7743. .CMD=$IBTOOL_PATH $STORYBOARD_FLAGS --module $REALPRJNAME --output-partial-info-plist ${output;suf=.partial_plist:SRC} --compile ${output;tobindir;nopath;noext;suf=.nib:SRC} ${input:SRC}
  7744. }
  7745. ACTOOL_PATH=$XCODE_TOOLS_ROOT_RESOURCE_GLOBAL/Xcode/Contents/Developer/usr/bin/ibtool
  7746. # tag:ios-specific
  7747. ASSETS_FLAGS=--output-format human-readable-text --notices --warnings
  7748. macro _IOS_ASSETS(AssetsDir, Content...) {
  7749. .CMD=$FS_TOOLS md $BINDIR/$REALPRJNAME && $ACTOOL_PATH $ASSETS_FLAGS --export-dependency-info $BINDIR/assetcatalog_dependencies --output-partial-info-plist ${output:"assetcatalog_generated_info.partial_plist"} --product-type com.apple.product-type.application --compile $BINDIR/$REALPRJNAME $AssetsDir ${input;hide:Content} && ${cwd:BINDIR} $YMAKE_PYTHON ${input:"build/scripts/tar_directory.py"} ${output;suf=_assetes.resource_tar:REALPRJNAME} $REALPRJNAME $REALPRJNAME
  7750. }
  7751. # tag:ios-specific
  7752. macro IOS_APP_COMMON_FLAGS(Flags...) {
  7753. SET_APPEND(STORYBOARD_FLAGS $Flags)
  7754. SET_APPEND(ASSETS_FLAGS $Flags)
  7755. }
  7756. # tag:ios-specific
  7757. macro IOS_APP_ASSETS_FLAGS(Flags...) {
  7758. SET_APPEND(ASSETS_FLAGS $Flags)
  7759. }
  7760. macro DARWIN_STRINGS_RESOURCE(Resource, Relpath) {
  7761. .CMD=$COPY_CMD ${input:Resource} $BINDIR/$Relpath && $YMAKE_PYTHON ${input:"build/scripts/tar_directory.py"} ${output;tobindir;suf=.strings_tar:Relpath} $BINDIR/$Relpath $BINDIR
  7762. }
  7763. macro DARWIN_SIGNED_RESOURCE(Resource, Relpath) {
  7764. .CMD=$COPY_CMD $Resource $BINDIR/$Relpath && $YMAKE_PYTHON ${input:"build/scripts/tar_directory.py"} ${output;tobindir;suf=.signed_resource_tar:Relpath} $BINDIR/$Relpath $BINDIR
  7765. }
  7766. # tag:ios-specific
  7767. DELIM=__DELIM__
  7768. PACK_IOS_ARCHIVE=$GENERATE_MF && $YMAKE_PYTHON ${input:"build/scripts/ios_wrapper.py"} bin $IBTOOL_PATH $TARGET $REALPRJNAME $BINDIR $DELIM $AUTO_INPUT $DELIM $STORYBOARD_FLAGS
  7769. ### @usage: IOS_INTERFACE()
  7770. ### iOS GUI module definition
  7771. module IOS_INTERFACE: _BARE_UNIT {
  7772. .CMD=PACK_IOS_ARCHIVE
  7773. .EXTS=.compiled_storyboard_tar .partial_plist .plist .xcent .nib .resource_tar .signed_resource_tar .strings_tar .plist_json
  7774. .NODE_TYPE=Library
  7775. .FINAL_TARGET=no
  7776. SET(MODULE_SUFFIX .ios.interface)
  7777. PEERDIR+=build/platform/xcode/tools
  7778. }
  7779. # tag:ios-specific
  7780. module DEFAULT_IOS_INTERFACE: IOS_INTERFACE {
  7781. SET(MODULE_SUFFIX .default.ios.interface)
  7782. }
  7783. DEFAULT_IOS_TYPE=
  7784. IOS_TYPE=
  7785. when(!$IOS_TYPE) {
  7786. when($DEFAULT_IOS_TYPE) {
  7787. IOS_TYPE=$DEFAULT_IOS_TYPE
  7788. }
  7789. otherwise {
  7790. IOS_TYPE=com.apple.CoreSimulator.SimDeviceType.iPhone-X
  7791. }
  7792. }
  7793. DEFAULT_IOS_RUNTIME=
  7794. IOS_RUNTIME=
  7795. when(!$IOS_RUNTIME) {
  7796. when($DEFAULT_IOS_RUNTIME) {
  7797. IOS_RUNTIME=$DEFAULT_IOS_RUNTIME
  7798. }
  7799. otherwise {
  7800. IOS_RUNTIME=com.apple.CoreSimulator.SimRuntime.iOS-12-1
  7801. }
  7802. }
  7803. when ($ARCH_I386) {
  7804. TEST_IOS_DEVICE_TYPE_VALUE=com.apple.CoreSimulator.SimDeviceType.iPhone-5
  7805. TEST_IOS_RUNTIME_TYPE_VALUE=com.apple.CoreSimulator.SimRuntime.iOS-10-3
  7806. }
  7807. otherwise {
  7808. TEST_IOS_DEVICE_TYPE_VALUE=$IOS_TYPE
  7809. TEST_IOS_RUNTIME_TYPE_VALUE=$IOS_RUNTIME
  7810. }
  7811. # tag:java-specific
  7812. ### @usage: MODULE_JDK(Version)
  7813. ###
  7814. ### Specify JDK version for module
  7815. macro JDK_VERSION(Arg) {
  7816. SET(JDK_REAL_VERSION $Arg)
  7817. _JDK_VERSION_MACRO_CHECK($Arg)
  7818. }
  7819. # tag:java-specific
  7820. when ($JDK_REAL_VERSION == "10") {
  7821. JDK10=yes # remove this later
  7822. }
  7823. JAVA_PROGRAM_CP_USE_COMMAND_FILE=yes
  7824. when ($JDK_REAL_VERSION == "8") {
  7825. JAVA_PROGRAM_CP_USE_COMMAND_FILE=no
  7826. }
  7827. # tag:kotlin-specific
  7828. KOTLIN_JVM_TARGET=
  7829. when ($JDK_REAL_VERSION == "8") {
  7830. KOTLIN_JVM_TARGET=1.8
  7831. }
  7832. elsewhen ($JDK_REAL_VERSION == "18") {
  7833. # remove when kotlin starts supporting jdk18 bytecode
  7834. # see also devtools/ya/jbuild/gen/actions/idea.py
  7835. KOTLIN_JVM_TARGET=17
  7836. }
  7837. otherwise {
  7838. KOTLIN_JVM_TARGET=$JDK_REAL_VERSION
  7839. }
  7840. # tag:frontend-specific
  7841. ### @usage: COLLECT_FRONTEND_FILES(Varname, Dir)
  7842. ###
  7843. ### Recursively collect files with typical frontend extensions from Dir and save the result into variable Varname
  7844. macro COLLECT_FRONTEND_FILES(Varname, Dir) {
  7845. _GLOB($Varname $Dir/**/*.(css|ejs|jpg|js|jsx|png|styl|svg|ts|tsx|json|html))
  7846. }
  7847. # tag:java-specific
  7848. # local jdk and tools
  7849. USE_SYSTEM_JDK=
  7850. USE_SYSTEM_UBERJAR=
  7851. USE_SYSTEM_ERROR_PRONE=
  7852. # tag:swift-specific
  7853. CPP_XCODE_TOOLCHAIN_VERSION=9.2
  7854. SWIFT_XCODE_TOOLCHAIN_VERSION=9.2
  7855. XCODE_TOOLS_VERSION=10.1
  7856. macro COMPILE_SWIFT_MODULE(SRCS{input}[], BRIDGE_HEADER{input}="", Flags...) {
  7857. when ($BRIDGE_HEADER != "") {
  7858. SWIFT_BRIDGE_HEADER=-import-objc-header ${input:BRIDGE_HEADER}
  7859. }
  7860. otherwise {
  7861. SWIFT_BRIDGE_HEADER=
  7862. }
  7863. .PEERDIR+=build/platform/xcode/swift
  7864. # swift core libraries
  7865. LDFLAGS($SWIFT_LD_FLAGS)
  7866. .CMD=$YMAKE_PYTHON ${input:"build/scripts/gen_swiftc_output_map.py"} $(SOURCE_ROOT) $(BUILD_ROOT) $BINDIR/swift_output_map.json ${input:SRCS} && $SWIFT_COMPILER -c $SWIFT_FLAGS_PLATFORM $Flags $SWIFT_BRIDGE_HEADER ${pre=-Xcc -I:_C__INCLUDE} ${input:SRCS} -emit-objc-header -emit-objc-header-path ${output;suf=-Swift.h:REALPRJNAME} -emit-module -module-name $REALPRJNAME -output-file-map $BINDIR/swift_output_map.json ${output;hide;suf=.o:SRCS}
  7867. }
  7868. TEST_TOOL_HOST_LOCAL=
  7869. TEST_TOOL_TARGET_LOCAL=
  7870. when ($TENSORFLOW_WITH_CUDA) {
  7871. CUDA_REQUIRED=yes
  7872. }
  7873. when (!$TENSORRT_VERSION) {
  7874. TENSORRT_VERSION=5
  7875. }
  7876. ANDROID_APK_TEST_ACTIVITY_VALUE=com.yandex.test.unittests/.RunTestsActivity
  7877. MAVEN_BIN=$MAVEN_RESOURCE_GLOBAL/bin
  7878. when ($QT_REQUIRED) {
  7879. QT_BIN=${HOST_QT_RESOURCE_GLOBAL}/bin
  7880. }
  7881. when ($OPENGL_REQUIRED) {
  7882. OPENGL_VERSION=18.0.5
  7883. }
  7884. # tag:python-specific
  7885. multimodule PY23_TEST {
  7886. module PY2 : PYTEST_BIN {
  7887. MODULE_PREFIX=py2_
  7888. OBJ_SUF=.py2
  7889. CANONIZE_SUB_PATH=py2test
  7890. RUN_CYTHON_SCRIPT=$YMAKE_PYTHON $CYTHON_SCRIPT
  7891. }
  7892. module PY3TEST_PROGRAM: PY3TEST_BIN {
  7893. .FINAL_TARGET=yes
  7894. OBJ_SUF=.py3
  7895. CANONIZE_SUB_PATH=py3test
  7896. RUN_CYTHON_SCRIPT=$YMAKE_PYTHON $CYTHON_SCRIPT
  7897. }
  7898. module PY3TEST_LIBRARY: PY3_LIBRARY {
  7899. PEERDIR+=library/python/pytest
  7900. _REQUIRE_EXPLICIT_LICENSE()
  7901. RUN_CYTHON_SCRIPT=$YMAKE_PYTHON $CYTHON_SCRIPT
  7902. }
  7903. }
  7904. # tag:windows-specific
  7905. WINDOWS_MANIFEST=
  7906. macro WINDOWS_MANIFEST(Manifest) {
  7907. SET(WINDOWS_MANIFEST $Manifest)
  7908. }
  7909. # tag:windows-specific
  7910. when ($MSVC == "yes" && $WINDOWS_MANIFEST) {
  7911. LDFLAGS+=/MANIFEST:EMBED /MANIFESTINPUT:${input:WINDOWS_MANIFEST}
  7912. }
  7913. # tag:cpp-specific
  7914. _VISIBILITY_LEVEL=
  7915. ### @usage: VISIBILITY(level)
  7916. ###
  7917. ### This macro sets visibility level for symbols compiled for the current module. 'level'
  7918. ### may take only one of the following values: DEFAULT, HIDDEN.
  7919. macro VISIBILITY(LEVEL) {
  7920. SET(_VISIBILITY_LEVEL ${LEVEL})
  7921. select ($LEVEL) {
  7922. "DEFAULT" | "HIDDEN" ? {
  7923. }
  7924. default ? {
  7925. _OK = no
  7926. }
  7927. }
  7928. ASSERT(_OK Unsupported value [$LEVEL] passed to VISIBILITY macro, expected values are DEFAULT, HIDDEN.)
  7929. }
  7930. # tag:cpp-specific
  7931. _CFLAGS_VISIBILITY=
  7932. when ($_VISIBILITY_LEVEL != "" && $IGNORE_VISIBILITY != "yes") {
  7933. when ($CLANG == "yes" || $GCC == "yes") {
  7934. _CFLAGS_VISIBILITY=-fvisibility=${tolower:_VISIBILITY_LEVEL}
  7935. }
  7936. }
  7937. CFLAGS+=$_CFLAGS_VISIBILITY
  7938. # tag:cpp-specific
  7939. macro SDBUS_CPP_ADAPTOR(File) {
  7940. .CMD=${tool:"contrib/libs/sdbus-cpp/tools/xml2cpp-codegen"} --adaptor=${output;nopath;noext:File.adaptor.h} ${input:File}
  7941. .PEERDIR=contrib/libs/sdbus-cpp
  7942. }
  7943. # tag:cpp-specific
  7944. macro SDBUS_CPP_PROXY(File) {
  7945. .CMD=${tool:"contrib/libs/sdbus-cpp/tools/xml2cpp-codegen"} --proxy=${output;nopath;noext:File.proxy.h} ${input:File}
  7946. .PEERDIR=contrib/libs/sdbus-cpp
  7947. }
  7948. # tag:python-specific
  7949. macro _PY_SSQLS_SRC(EXT, SRC, SRCFLAGS...) {
  7950. #generic macro
  7951. }
  7952. # tag:python-specific
  7953. macro _PY_SSQLS_SRC("ssqls", SRC, SRCFLAGS...) {
  7954. .CMD=${tool:"metrika/core/tools/ssqls"} ${input;notransformbuilddir:SRC} -S $ARCADIA_ROOT -B $ARCADIA_BUILD_ROOT -L "python" -D $MODDIR $SRCFLAGS ${output;tobindir;noext;hide;pre=autogenerated/$MODDIR/:SRC.py}
  7955. }
  7956. # tag:python-specific
  7957. macro _PY_SSQLS_SRCS(Srcs...) {
  7958. foreach(Src: $Srcs) {
  7959. _PY_SSQLS_SRC(${lastext:Src} $Src)
  7960. }
  7961. }
  7962. # tag:python-specific
  7963. macro PY_SSQLS_SRCS(Srcs...) {
  7964. _PY_SSQLS_SRCS(KEEP_DIR_STRUCT $Srcs)
  7965. PY_SRCS(${noext;pre=autogenerated/$MODDIR/:Srcs.py})
  7966. }
  7967. # tag:python-specific
  7968. macro _PY_ENUM_SERIALIZATION_TO_JSON(File) {
  7969. .CMD=$ENUM_PARSER_TOOL ${input:File} --output ${output;chksum;noext;suf=.generated.h:File} --json-output ${output;noext:File.json} ${kv;hide:"p EN"} ${kv;hide:"pc yellow"}
  7970. }
  7971. # tag:python-specific
  7972. macro _PY_ENUM_SERIALIZATION_TO_PY(File) {
  7973. .CMD=${tool:"metrika/core/tools/python_enum_generator"} ${input;noext:File.json} -D ${MODDIR} --output ${output;noext:File.py} ${kv;hide:"p EN"} ${kv;hide:"pc yellow"}
  7974. }
  7975. # tag:metrika
  7976. multimodule SSQLS_LIBRARY {
  7977. module CPP_SSQLS : LIBRARY {
  7978. .ALIASES=ENUMS_SERIALIZATION=CPP_ENUMS_SERIALIZATION
  7979. SET(PEERDIR_TAGS CPP_SSQLS)
  7980. PEERDIR(metrika/core/libs/appmetrica/types metrika/core/libs/types)
  7981. ADDINCL(GLOBAL ${ARCADIA_BUILD_ROOT}/metrika/core/common_tables/include)
  7982. }
  7983. module PY3_SSQLS : PY3_LIBRARY {
  7984. .ALIASES=SRCS=PY_SSQLS_SRCS ENUMS_SERIALIZATION=PY_ENUMS_SERIALIZATION
  7985. SET(PEERDIR_TAGS PY3 PY3_SSQLS)
  7986. }
  7987. }
  7988. macro NGINX_MODULES(Modules...) {
  7989. PEERDIR(${Modules})
  7990. RUN_PROGRAM(nginx/module_gen ${Modules} CWD ${ARCADIA_ROOT} IN ${suf=/modules.json:Modules} OUTPUT_INCLUDES contrib/nginx/core/src/core/ngx_config.h contrib/nginx/core/src/core/ngx_core.h STDOUT ngx_modules.c)
  7991. }
  7992. # Experimental: container as output. https://st.yandex-team.ru/DTCC-179
  7993. # tag:external-build
  7994. CONTAINER_LAYER_CMD=$YMAKE_PYTHON ${input:"devtools/experimental/solar/selfcontainer/scripts/make_container_layer.py"} -o $TARGET $AUTO_INPUT ${cwd:ARCADIA_BUILD_ROOT} ${kv;hide:"p CL"} ${kv;hide:"pc blue"}
  7995. CONTAINER_CMD=$YMAKE_PYTHON ${input:"devtools/experimental/solar/selfcontainer/scripts/make_container.py"} -o $TARGET ${rootrel:PEERS} ${cwd:ARCADIA_BUILD_ROOT} ${kv;hide:"p CN"} ${kv;hide:"pc blue"}
  7996. # tag:external-build
  7997. module CONTAINER_LAYER: _BARE_UNIT {
  7998. .CMD=CONTAINER_LAYER_CMD
  7999. MODULE_SUFFIX=.container_layer
  8000. }
  8001. # tag:external-build
  8002. module CONTAINER: _BARE_UNIT {
  8003. .NODE_TYPE=Bundle
  8004. .PEERDIR_POLICY=as_build_from
  8005. .FINAL_TARGET=yes
  8006. .CMD=CONTAINER_CMD
  8007. }
  8008. # tag:external-build
  8009. CUSTOM_BUILD_LIBRARY_USE=
  8010. CUSTOM_BUILD_LIBRARY_CMD=$GENERATE_MF && ${tool:"devtools/experimental/solar/outbuild/runner"} ${hide:PEERS} --script=${input:CUSTOM_SCRIPT} --output $TARGET --python=${tool:"contrib/tools/python3"} --isolator=${tool:"devtools/experimental/solar/outbuild/isolator"} $CUSTOM_BUILD_LIBRARY_USE
  8011. # tag:external-build
  8012. module CUSTOM_BUILD_LIBRARY: LIBRARY {
  8013. .NODE_TYPE=Bundle
  8014. .PEERDIR_POLICY=as_build_from
  8015. .PROXY=yes
  8016. .CMD=CUSTOM_BUILD_LIBRARY_CMD
  8017. DISABLE(NEED_ADD_FAKE_SRC)
  8018. }
  8019. ### @usage: ORIGINAL_SOURCE(Source)
  8020. ###
  8021. ### This macro specifies the source repository for contrib
  8022. ### Does nothing now (just a placeholder for future functionality)
  8023. ### See https://st.yandex-team.ru/DTCC-316
  8024. macro ORIGINAL_SOURCE(Source) {
  8025. ENABLE(UNUSED_MACRO)
  8026. }
  8027. CMAKE_PACKAGE=
  8028. CMAKE_PACKAGE_COMPONENT=
  8029. CMAKE_PACKAGE_TARGET=
  8030. CONAN_REFERENCE=
  8031. CONAN_PKG_OPTS=
  8032. ### @usage: OPENSOURCE_EXPORT_REPLACEMENT(CMAKE PkgName CMAKE_TARGET PkgName::PkgTarget CONAN ConanRef CMAKE_COMPONENT OptCmakePkgComponent)
  8033. ###
  8034. ### Use specified conan/system pacakcge when exporting cmake build scripts for arcadia C++ project
  8035. ### for opensource publication.
  8036. macro OPENSOURCE_EXPORT_REPLACEMENT(CMAKE[], CMAKE_TARGET[], CMAKE_COMPONENET[], CONAN[], CONAN_OPTIONS[]) {
  8037. SET(CMAKE_PACKAGE $CMAKE)
  8038. SET(CMAKE_PACKAGE_COMPONENT $CMAKE_COMPONENET)
  8039. SET(CMAKE_LINK_TARGET $CMAKE_TARGET)
  8040. SET(CONAN_REFERENCE $CONAN)
  8041. SET(CONAN_PKG_OPTS $CONAN_OPTIONS)
  8042. }
  8043. # tag:licence
  8044. CREDITS_FILE_EXTRA_EXT=
  8045. CREDITS_FLAGS=
  8046. CREDITS_TEXTS_FILE=
  8047. NO_CREDITS_TEXTS_FILE=
  8048. WITH_CREDITS=
  8049. ### @usage: LICENSE_TEXTS(File)
  8050. ###
  8051. ### This macro specifies the filename with all library licenses texts
  8052. macro LICENSE_TEXTS(Source) {
  8053. SET(CREDITS_TEXTS_FILE $Source)
  8054. }
  8055. # tag:licence
  8056. ### @usage: WITHOUT_LICENSE_TEXTS()
  8057. ###
  8058. ### This macro indicates that the module has no license text
  8059. macro WITHOUT_LICENSE_TEXTS() {
  8060. ENABLE(NO_CREDITS_TEXTS_FILE)
  8061. }
  8062. # tag:licence
  8063. when ($WITH_CREDITS) {
  8064. CREDITS_FLAGS+=--credits-output ${output;suf=${CREDITS_FILE_EXTRA_EXT}".CREDITS.txt":REALPRJNAME}
  8065. }
  8066. GENERATE_MF=
  8067. when ($WITH_CREDITS) {
  8068. GENERATE_MF=$GENERATE_MF_CMD
  8069. }
  8070. macro _MCU_CONVERT(Bin) {
  8071. .CMD=${cwd:BINDIR} $OBJCOPY_TOOL -O ihex $Bin ${output;noext:Bin.hex} && ${cwd:BINDIR} $OBJCOPY_TOOL -O srec $Bin ${output;noext:Bin.s37}
  8072. }
  8073. MCU_LINK_EXE=$LINK_EXE && $_MCU_CONVERT($MODULE_PREFIX$REALPRJNAME)
  8074. ### @usage: MCU_PROGRAM([progname])
  8075. ###
  8076. ### Program module for microcontrollers. Converts binary to Intel HEX and Motorola S-record file formats.
  8077. ### If name is not specified it will be generated from the name of the containing project directory.
  8078. module MCU_PROGRAM: PROGRAM {
  8079. .CMD=MCU_LINK_EXE
  8080. }
  8081. # tag:deprecated
  8082. ### @usage: METAQUERYFILES(filenames...) #deprecated
  8083. ###
  8084. ### This macro does nothing and will be removed
  8085. macro METAQUERYFILES(Files...) {
  8086. ENABLE(UNUSED_MACRO)
  8087. }
  8088. # tag:flags tag:internal tag:windows-specific
  8089. ### @usage: _MSVC_FLAGS_WINDOWS_IMPL(target_platform compiler_flags) # internal
  8090. ###
  8091. ### Add CFLAGS when the firts argument is WINDOWS
  8092. macro _MSVC_FLAGS_WINDOWS_IMPL(WINDOWS[], FLAGS...) {
  8093. CFLAGS($WINDOWS)
  8094. }
  8095. # tag:flags tag:windows-specific tag:cpp-specific
  8096. ### @usage: MSVC_FLAGS([GLOBAL compiler_flag]* compiler_flags)
  8097. ###
  8098. ### Add the specified flags to the compilation line of C/C++files.
  8099. ### Flags apply only if the compiler used is MSVC (cl.exe)
  8100. macro MSVC_FLAGS(FLAGS...) {
  8101. _MSVC_FLAGS_WINDOWS_IMPL($TARGET_PLATFORM $FLAGS)
  8102. }
  8103. ### @usage: COLLECT_YDB_API_SPECS_LEGACY(VarName Paths...) #deprecated
  8104. ###
  8105. ### This macro is ugly hack for legacy YDB go API codegen, any other uses are prohibited
  8106. macro COLLECT_YDB_API_SPECS_LEGACY(FILES_VAR, PATHS...) {
  8107. _GLOB($FILES_VAR ${suf=/*.proto:PATHS})
  8108. RESTRICT_PATH(kikimr/public/sdk/go/ydb/api MSG This is ugly hack for legacy YDB go API codegen, any other uses are probibited)
  8109. }
  8110. # tag:proto tag:apphost
  8111. ### @usage: APPHOST()
  8112. ###
  8113. ### Emit APPHOST service code for all .proto files in a PROTO_LIBRARY.
  8114. ### This works only for C++ at the moment.
  8115. macro APPHOST() {
  8116. # C++
  8117. CPP_PROTO_PLUGIN(cpp_plugin apphost/tools/stub_generator/cpp_plugin .apphost.h)
  8118. }