ymake.core.conf 411 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560
  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 limited 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 significant time to catch up and will need to recache everything.
  7. # - Autocheck will rebuild and recache everything.
  8. # Use this with extreme care and only change if it is ultimately needed. Consider more specific XXX_FAKEIDs below instead.
  9. FAKEID=31415926535
  10. SANDBOX_FAKEID=${FAKEID}.7600000
  11. CPP_FAKEID=2023-06-06
  12. GO_FAKEID=11100371
  13. ANDROID_FAKEID=2023-05-17
  14. CLANG_TIDY_FAKEID=2023-06-06
  15. CYTHON_FAKE_ID=10784829
  16. JAVA_FAKEID=10849009
  17. # Change of this value will invalidate some parts of configure cache
  18. # but will not affect builds anyhow (except tests referring build/ directory)
  19. JSON_CACHE_FAKE_ID=11215402
  20. REPORT_ALL_DUPSRC=yes
  21. CURDIR=.
  22. MODDIR=.
  23. BINDIR=bin:/
  24. SRCDIR=
  25. YMAKE=ymake
  26. ECHO=echo
  27. INCLUDE_EXTS=.h .hh .hpp .rli .cuh .inc .i .ipp .ixx .ya_exposed
  28. CPP_EXT=.cpp
  29. OBJ_SUF=
  30. CFLAGS=
  31. EXTRA_C_FLAGS=
  32. SFLAGS=
  33. FORCE_COVERAGE_ENABLED=
  34. FORCE_COVERAGE_DISABLED=
  35. AUTOCHECK_BALANCING_OPTIONS=
  36. SO_OUTPUTS=no
  37. @import "${CONF_ROOT}/conf/settings.conf"
  38. @import "${CONF_ROOT}/conf/opensource.conf"
  39. @import "${CONF_ROOT}/conf/rules.conf"
  40. @import "${CONF_ROOT}/conf/sysincl.conf"
  41. @import "${CONF_ROOT}/conf/license.conf"
  42. @import "${CONF_ROOT}/conf/ts/ts.conf"
  43. @import "${CONF_ROOT}/conf/docs.conf"
  44. @import "${CONF_ROOT}/conf/java.conf"
  45. @import "${CONF_ROOT}/conf/project_specific/other.conf"
  46. @import "${CONF_ROOT}/conf/project_specific/uservices.conf"
  47. @import "${CONF_ROOT}/conf/project_specific/yt.conf"
  48. USE_GLOBAL_CMD=no
  49. when ($OS_WINDOWS != "yes") {
  50. USE_GLOBAL_CMD=yes
  51. }
  52. when ($USE_PYTHON) {
  53. C_DEFINES+= -DUSE_PYTHON
  54. }
  55. __COMMA__=${comma:""}
  56. ARCADIA_TEST_ROOT=../arcadia_tests_data/
  57. DEFAULT_REQUIREMENTS=network:restricted cpu:1 ram:32
  58. FAIL_PY2=no
  59. _PREBUILT_TOOLS_ROOT=build/prebuilt
  60. _TOOL_PROTOC_GEN_GO=vendor/github.com/golang/protobuf/protoc-gen-go
  61. _TOOL_PROTOC_GEN_GO_V2=vendor/google.golang.org/protobuf/cmd/protoc-gen-go
  62. _TOOL_PROTOC_GEN_GO_GRPC_V2=vendor/google.golang.org/grpc/cmd/protoc-gen-go-grpc
  63. _TOOL_RESCOMPILER=tools/rescompiler
  64. _TOOL_RESCOMPRESSOR=tools/rescompressor
  65. _TOOL_RORESCOMPILER=tools/rorescompiler
  66. when ($DISABLE_SEPARATE_AUX_CPP != "yes") {
  67. SEPARATE_AUX_CPP=yes
  68. }
  69. when ($HOST_ARCH_X86_64 == "yes") {
  70. when ($HOST_OS_DARWIN == "yes" || $HOST_OS_LINUX == "yes" || $HOST_OS_WINDOWS == "yes") {
  71. VALID_HOST_PLATFORM_FOR_COMMON_PREBUILT_TOOLS=yes
  72. when ($USE_PREBUILT_TOOLS == "yes" && $ARCH_X86_64 == "yes") {
  73. _TOOL_PROTOC_GEN_GO=${_PREBUILT_TOOLS_ROOT}/vendor/github.com/golang/protobuf/protoc-gen-go
  74. }
  75. }
  76. }
  77. FAIL_MODULE_CMD=$YMAKE_PYTHON3 ${input:"build/scripts/fail_module_cmd.py"} $TARGET ${kv;hide:"p ER"} ${kv;hide:"pc red"}
  78. DEFAULT_TIDY_CONFIG=build/config/tests/clang_tidy/config.yaml
  79. PROJECT_TIDY_CONFIG=build/config/tests/clang_tidy/config.yaml
  80. TIDY=
  81. TIDY_ENABLED=
  82. when($TIDY == "yes") {
  83. TIDY_ENABLED=yes
  84. }
  85. when ($TIDY_ENABLED == "yes") {
  86. when ($TIDY_EXPORT_FIXES=="") {
  87. TIDY_EXPORT_FIXES="no"
  88. }
  89. 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=${COMPILE_OUT_SUFFIX}${OBJ_CROSS_SUF}.tidyjson:SRC} "--export-fixes" $TIDY_EXPORT_FIXES
  90. CLANG_TIDY_ARGS+="--default-config-file" ${input:DEFAULT_TIDY_CONFIG}
  91. CLANG_TIDY_ARGS+="--project-config-file" ${input:PROJECT_TIDY_CONFIG}
  92. when ($TIDY_CHECKS) {
  93. CLANG_TIDY_ARGS+="--checks=$TIDY_CHECKS"
  94. }
  95. when ($TIDY_HEADER_FILTER) {
  96. CLANG_TIDY_ARGS+="--header-filter=$TIDY_HEADER_FILTER"
  97. }
  98. TIDY_VALUE=USE_CONDITIONAL_SRCS
  99. }
  100. otherwise {
  101. CLANG_TIDY_ARGS=
  102. TIDY_VALUE=
  103. }
  104. # tag:codenav
  105. when ($CODENAVIGATION && $NOCODENAVIGATION != "yes") {
  106. PY_PROGRAM_LINK_EXE=$LINK_EXE ${kv;hide:"pyndex $TARGET"}
  107. YNDEXER_ARGS=$YMAKE_PYTHON ${input:"build/scripts/yndexer.py"} $CPPYNDEXER_RESOURCE_GLOBAL/yndexer 1500 $(SOURCE_ROOT) $ARCADIA_BUILD_ROOT ${input:SRC}
  108. YNDEXER_OUTPUT=${output;noauto;suf=${OBJ_CROSS_SUF}${COMPILE_OUT_SUFFIX}.ydx.pb2:SRC}
  109. }
  110. otherwise {
  111. PY_PROGRAM_LINK_EXE=$LINK_EXE
  112. YNDEXER_ARGS=
  113. YNDEXER_OUTPUT=
  114. }
  115. when ($RETRY == "yes") {
  116. RETRY_ARGS=$YMAKE_PYTHON ${input:"build/scripts/wrapcc.py"}
  117. }
  118. otherwise {
  119. RETRY_ARGS=
  120. }
  121. COVERAGE_FLAGS=
  122. EXTRA_OUTPUT=
  123. when ($CLANG == "yes" || $GCC == "yes") {
  124. when ($BUILD_TYPE == "COVERAGE" || $GCOV_COVERAGE) {
  125. COVERAGE_FLAGS=-fprofile-arcs -ftest-coverage
  126. EXTRA_OUTPUT=${output;noauto;hide;suf=${COMPILE_OUT_SUFFIX}${_CROSS_SUFFIX}.gcno:SRC}
  127. }
  128. }
  129. when ($OS_CYGWIN == "yes") {
  130. CFLAGS+=-D_LDBL_EQ_DBL=1 -U__STRICT_ANSI__
  131. USE_ASMLIB=no
  132. FSTACK=
  133. }
  134. CFLAGS+=$COVERAGE_FLAGS
  135. LDFLAGS+=$COVERAGE_FLAGS
  136. CHECKFLAG=
  137. NO_MAPREDUCE=
  138. when ($NO_MAPREDUCE == "yes") {
  139. C_DEFINES+=-DNO_MAPREDUCE
  140. }
  141. when ($OS_ANDROID == "yes") {
  142. PIE=yes
  143. }
  144. # TODO: extract to conf/maps/maps.conf
  145. when ($MAPSMOBI_BUILD_TARGET == "yes" && $OS_LINUX != "yes") {
  146. USE_STL_SYSTEM=yes
  147. ARCADIA_CURL_DNS_RESOLVER=MULTITHREADED
  148. }
  149. when ($MAPSMOBI_BUILD_TARGET == "yes" && $OS_IOS == "yes") {
  150. BUILD_IOS_APP=yes
  151. when ($ARCH_ARM7 || $ARCH_ARM64) {
  152. BOOSTTEST_IS_FAT_OBJECT=yes
  153. }
  154. }
  155. when ($CLANG && $OS_DARWIN && $SANITIZER_TYPE && $SANITIZER_TYPE != "no") {
  156. SO_OUTPUTS=yes
  157. }
  158. when ($OS_NONE == "yes") {
  159. USE_STL_SYSTEM=yes
  160. }
  161. # USE_INTERNAL_STL is an internal flag (set on by default) but may be used externally to
  162. # select system standard C++ library when USE_INTERNAL_STL=no is set.
  163. #
  164. # USE_STL_SYSTEM=yes is a regular way to select system standard C++ library.
  165. #
  166. when ($USE_STL_SYSTEM == "yes") {
  167. USE_INTERNAL_STL=no
  168. }
  169. when ($USE_INTERNAL_STL == "no") {
  170. USE_STL_SYSTEM=yes
  171. }
  172. otherwise {
  173. USE_INTERNAL_STL=yes
  174. # TODO: Extract to conf/sysincl.conf
  175. # This trigger doesn't work for module level since SYSINCL is processed at
  176. # configuration stage (This means that NO_RUNTIME() macro called in ya.make
  177. # won't affect SYSINCL and the only way to make this trigger work correctly
  178. # is to define configuration variable NORUNTIME (-DNORUNTIME) on the command
  179. # line when `ya make ...` is invoked.
  180. when ($NORUNTIME != "yes") {
  181. SYSINCL+=build/sysincl/stl-to-libcxx.yml
  182. when ($MUSL == "yes") {
  183. SYSINCL+=build/sysincl/libc-musl-libcxx.yml
  184. }
  185. }
  186. }
  187. # tag:linux-specific
  188. when ($OS_LINUX && $OS_SDK == "ubuntu-14" && $MUSL != "yes") {
  189. USE_UBUNTU_COMPATIBILITY=yes
  190. }
  191. USE_ARCADIA_PYTHON=yes
  192. USE_ARCADIA_LIBM=no
  193. USE_EAT_MY_DATA=no
  194. HAVE_MKL=
  195. when ($HAVE_MKL == "") {
  196. when ($OS_LINUX && $ARCH_X86_64 && !$SANITIZER_TYPE) {
  197. HAVE_MKL=yes
  198. }
  199. otherwise {
  200. HAVE_MKL=no
  201. }
  202. }
  203. SFDL_TMP_OUT= ${output;tmp:SRC.tmp}
  204. # tag:perl-specific
  205. when ($USE_LOCAL_TOOLS == "yes") {
  206. PERL=$LOCAL_PERL
  207. PERL_VERSION=$LOCAL_PERL_VERSION
  208. PERL_PRIVLIB=$LOCAL_PERL_PRIVLIB
  209. PERL_ARCHLIB=$LOCAL_PERL_ARCHLIB
  210. when ($LOCAL_PERL_LIBS) {
  211. PERL_LIBS=$LOCAL_PERL_LIBS
  212. }
  213. }
  214. otherwise {
  215. PERL=NO-PERL-SELECTED
  216. PERL_VERSION=NO-PERL-SELECTED-VERSION
  217. PERL_PRIVLIB=NO-PERL-SELECTED-PRIVLIB
  218. PERL_ARCHLIB=NO-PERL-SELECTED-ARCHLIB
  219. }
  220. # tag:perl-specific
  221. PERL_LD_LIBRARY_PATH=
  222. PERL_INCLUDE=
  223. USE_PERL_SYSTEM=yes
  224. when ($USE_PERL_SYSTEM == "yes") {
  225. select ($PERL_SDK) {
  226. "ubuntu-12" ? {
  227. PERL_VERSION=5.14
  228. PERL_ROOT=${SYSTEM_PERL_514_RESOURCE_GLOBAL}/perl${PERL_VERSION}
  229. PERL_LIB_ARCH=
  230. }
  231. "ubuntu-14" ? {
  232. PERL_VERSION=5.18
  233. PERL_ROOT=${SYSTEM_PERL_518_RESOURCE_GLOBAL}/perl${PERL_VERSION}
  234. PERL_LIB_ARCH=
  235. }
  236. "ubuntu-16" ? {
  237. PERL_VERSION=5.22
  238. PERL_ROOT=${SYSTEM_PERL_522_RESOURCE_GLOBAL}/perl${PERL_VERSION}
  239. PERL_LIB_ARCH=/x86_64-linux-gnu
  240. }
  241. "ubuntu-18" ? {
  242. PERL_VERSION=5.26
  243. PERL_ROOT=${SYSTEM_PERL_526_RESOURCE_GLOBAL}/perl${PERL_VERSION}
  244. PERL_LIB_ARCH=/x86_64-linux-gnu
  245. }
  246. "ubuntu-20" ? {
  247. PERL_VERSION=5.30
  248. PERL_ROOT=${SYSTEM_PERL_530_RESOURCE_GLOBAL}/usr
  249. PERL_LIB_ARCH=/x86_64-linux-gnu
  250. }
  251. }
  252. PERL=${PERL_ROOT}/bin/perl
  253. PERL_ARCHLIB=${PERL_ROOT}/lib$PERL_LIB_ARCH/perl/${PERL_VERSION}
  254. PERL_PRIVLIB=${PERL_ROOT}/share/perl/${PERL_VERSION}
  255. PERL_LIBS=${PERL_ROOT}/lib${PERL_LIB_ARCH}
  256. PERL_LD_LIBRARY_PATH=${env:"LD_LIBRARY_PATH=${PERL_ROOT}/lib"}
  257. # Perl searches it's modules in INC@ paths. They can not be sysrooted or disabled (at least I haven't found a way),
  258. # so default Perl module directories should be prepended to perl command lines when using non-local perl.
  259. PERL_INCLUDE=-I${PERL_ARCHLIB} -I${PERL_PRIVLIB}
  260. }
  261. PERL_DEFAULT_PEERDIR=yes
  262. # tag:perl-specific
  263. PERLSUFFIX=-csuffix .cpp
  264. PERLOUTPUT=${stdout;output:SRC.cpp}
  265. when ($PERLC == "yes") {
  266. PERLSUFFIX=-csuffix .c
  267. PERLOUTPUT=${stdout;output:SRC.c}
  268. }
  269. XSUBPPFLAGS=
  270. _XSTYPEMAPS=
  271. macro XSTYPEMAPS(Names...) {
  272. SET_APPEND(_XSTYPEMAPS $Names)
  273. }
  274. # tag:tool-specific
  275. ARCH_TOOL=${tool:"tools/archiver"}
  276. # tag:tool-specific tag:proto
  277. PROTOC=${tool:"contrib/tools/protoc"}
  278. PROTOC_STYLEGUIDE_OUT=--cpp_styleguide_out=$ARCADIA_BUILD_ROOT/$PROTO_NAMESPACE
  279. PROTOC_PLUGIN_STYLEGUIDE=--plugin=protoc-gen-cpp_styleguide=${tool:"contrib/tools/protoc/plugins/cpp_styleguide"}
  280. PROTOBUF_PATH=${ARCADIA_ROOT}/contrib/libs/protobuf/src
  281. USE_VANILLA_PROTOC=no
  282. PROTOC_TRANSITIVE_HEADERS=yes
  283. _PROTOC_FLAGS=
  284. # tag:tool-specific
  285. FML_TOOL=${tool:"tools/relev_fml_codegen"}
  286. FML_UNUSED_TOOL=${tool:"tools/relev_fml_unused"}
  287. LUA_TOOL=${tool:"tools/lua"}
  288. ENUM_PARSER_TOOL=${tool:"tools/enum_parser/enum_parser"}
  289. # tag:python-specific tag:cython-specific
  290. CYTHON_SCRIPT=${input:"${ARCADIA_ROOT}/contrib/tools/cython/cython.py"} ${hide:CYTHON_FAKE_ID} $CYTHON_PREDEFINED_INCLUDES
  291. RUN_CYTHON_SCRIPT=$YMAKE_PYTHON $CYTHON_SCRIPT
  292. RUN_CYTHON_SCRIPT_H=$YMAKE_PYTHON $CYTHON_SCRIPT
  293. PYTHON_TYPE_FOR_CYTHON=PY2
  294. CYTHON_OUTPUT_INCLUDES=\
  295. ${output_include;hide:"contrib/libs/python/Include/compile.h"} \
  296. ${output_include;hide:"contrib/libs/python/Include/frameobject.h"} \
  297. ${output_include;hide:"contrib/libs/python/Include/longintrepr.h"} \
  298. ${output_include;hide:"contrib/libs/python/Include/pyconfig.h"} \
  299. ${output_include;hide:"contrib/libs/python/Include/Python.h"} \
  300. ${output_include;hide:"contrib/libs/python/Include/pythread.h"} \
  301. ${output_include;hide:"contrib/libs/python/Include/structmember.h"} \
  302. ${output_include;hide:"contrib/libs/python/Include/traceback.h"} \
  303. ${output_include;hide:"contrib/tools/cython/generated_c_headers.h"} \
  304. ${output_include;hide:"omp.h"}
  305. # tag:cython-specific
  306. CYTHON_CPP_OUTPUT_INCLUDES=${output_include;hide:"contrib/tools/cython/generated_cpp_headers.h"}
  307. # tag:cython-specific
  308. CYTHON_PREDEFINED_INCLUDES=\
  309. ${input;hide:"contrib/tools/cython/Cython/Utility/Buffer.c"} \
  310. ${input;hide:"contrib/tools/cython/Cython/Utility/Builtins.c"} \
  311. ${input;hide:"contrib/tools/cython/Cython/Utility/CMath.c"} \
  312. ${input;hide:"contrib/tools/cython/Cython/Utility/Capsule.c"} \
  313. ${input;hide:"contrib/tools/cython/Cython/Utility/CommonTypes.c"} \
  314. ${input;hide:"contrib/tools/cython/Cython/Utility/Complex.c"} \
  315. ${input;hide:"contrib/tools/cython/Cython/Utility/Coroutine.c"} \
  316. ${input;hide:"contrib/tools/cython/Cython/Utility/CythonFunction.c"} \
  317. ${input;hide:"contrib/tools/cython/Cython/Utility/Embed.c"} \
  318. ${input;hide:"contrib/tools/cython/Cython/Utility/Exceptions.c"} \
  319. ${input;hide:"contrib/tools/cython/Cython/Utility/ExtensionTypes.c"} \
  320. ${input;hide:"contrib/tools/cython/Cython/Utility/FunctionArguments.c"} \
  321. ${input;hide:"contrib/tools/cython/Cython/Utility/ImportExport.c"} \
  322. ${input;hide:"contrib/tools/cython/Cython/Utility/MemoryView_C.c"} \
  323. ${input;hide:"contrib/tools/cython/Cython/Utility/ModuleSetupCode.c"} \
  324. ${input;hide:"contrib/tools/cython/Cython/Utility/ObjectHandling.c"} \
  325. ${input;hide:"contrib/tools/cython/Cython/Utility/Optimize.c"} \
  326. ${input;hide:"contrib/tools/cython/Cython/Utility/Overflow.c"} \
  327. ${input;hide:"contrib/tools/cython/Cython/Utility/Printing.c"} \
  328. ${input;hide:"contrib/tools/cython/Cython/Utility/Profile.c"} \
  329. ${input;hide:"contrib/tools/cython/Cython/Utility/StringTools.c"} \
  330. ${input;hide:"contrib/tools/cython/Cython/Utility/TestUtilityLoader.c"} \
  331. ${input;hide:"contrib/tools/cython/Cython/Utility/TypeConversion.c"}
  332. # tag:cython-specific
  333. CYTHON_PREDEFINED_INDUCED=\
  334. contrib/libs/python/Include/Python.h
  335. # tag:cython-specific
  336. CYTHON_OPTIONS=
  337. when ($OS_LINUX) {
  338. CYTHON_OPTIONS += -E UNAME_SYSNAME=Linux
  339. }
  340. elsewhen ($OS_DARWIN) {
  341. CYTHON_OPTIONS += -E UNAME_SYSNAME=Darwin
  342. }
  343. elsewhen ($OS_WINDOWS) {
  344. CYTHON_OPTIONS += -E UNAME_SYSNAME=Windows
  345. }
  346. when ($USE_LOCAL_SWIG != "yes") {
  347. _SWIG_TOOL=${tool:"contrib/tools/swig"}
  348. _SWIG_LIBRARY=contrib/tools/swig/Lib
  349. _SWIG_LIBRARY_ABS=$ARCADIA_ROOT/$_SWIG_LIBRARY
  350. }
  351. otherwise {
  352. _SWIG_TOOL=$SWIG_TOOL
  353. _SWIG_LIBRARY=$SWIG_LIBRARY
  354. _SWIG_LIBRARY_ABS=$SWIG_LIBRARY
  355. }
  356. SWIG_IMPLICIT_INCLUDES = swig.swg go.swg java.swg perl5.swg python.swg
  357. FATAL_ERROR_MODULE=no
  358. FATAL_ERROR_MESSAGE=
  359. # tag:python-specific
  360. # PYTHON_DISTR={ "default" | "macos-brew" } determine python system supply
  361. # see build/platform/python/ya.make
  362. PYTHON_DISTR="default"
  363. when ($USE_SYSTEM_PYTHON) {
  364. USE_ARCADIA_PYTHON=no
  365. select ($USE_SYSTEM_PYTHON) {
  366. "2.7" ? {
  367. _SYSTEM_PYTHON27=yes
  368. PY_VERSION=2.7
  369. PY_FRAMEWORK_VERSION=2.7
  370. }
  371. "3.4" ? {
  372. _SYSTEM_PYTHON34=yes
  373. PY_VERSION=3.4m
  374. PY_FRAMEWORK_VERSION=3.4
  375. }
  376. "3.5" ? {
  377. _SYSTEM_PYTHON35=yes
  378. PY_VERSION=3.5m
  379. PY_FRAMEWORK_VERSION=3.5
  380. }
  381. "3.6" ? {
  382. _SYSTEM_PYTHON36=yes
  383. PY_VERSION=3.6m
  384. PY_FRAMEWORK_VERSION=3.6
  385. }
  386. "3.7" ? {
  387. _SYSTEM_PYTHON37=yes
  388. PY_VERSION=3.7m
  389. PY_FRAMEWORK_VERSION=3.7
  390. }
  391. "3.8" ? {
  392. _SYSTEM_PYTHON38=yes
  393. PY_VERSION=3.8
  394. PY_FRAMEWORK_VERSION=3.8
  395. }
  396. "3.9" ? {
  397. _SYSTEM_PYTHON39=yes
  398. PY_VERSION=3.9
  399. PY_FRAMEWORK_VERSION=3.9
  400. }
  401. "3.10" ? {
  402. _SYSTEM_PYTHON310=yes
  403. PY_VERSION=3.10
  404. PY_FRAMEWORK_VERSION=3.10
  405. }
  406. "3.11" ? {
  407. _SYSTEM_PYTHON311=yes
  408. PY_VERSION=3.11
  409. PY_FRAMEWORK_VERSION=3.11
  410. }
  411. default ? {
  412. FATAL_ERROR_MESSAGE+=invalid USE_SYSTEM_PYTHON value
  413. }
  414. }
  415. }
  416. ANTLR_PYTHON=Python2
  417. ### @usage: NO_LTO()
  418. ###
  419. ### Disable any lto (link-time optimizations) for the module.
  420. ### This will compile module source files as usual (without LTO) but will not prevent lto-enabled
  421. ### linking of entire program if global settings say so.
  422. macro NO_LTO() {
  423. DISABLE(USE_LTO)
  424. DISABLE(USE_THINLTO)
  425. }
  426. when ($BUILD_PYTHON3_BIN) {
  427. YMAKE_PYTHON3=${BUILD_PYTHON3_BIN}
  428. YMAKE_PYTHON3_PEERDIR=
  429. }
  430. otherwise {
  431. YMAKE_PYTHON3=${YMAKE_PYTHON3_RESOURCE_GLOBAL}/python3
  432. }
  433. # tag:python-specific
  434. when ($USE_ARCADIA_PYTHON == "no") {
  435. SYSINCL+=build/sysincl/python.yml
  436. }
  437. # tag:allocator
  438. DEFAULT_ALLOCATOR=LF
  439. # tag:allocator
  440. when ($OS_ANDROID == "yes" || $MSVC == "yes" || $ARCH_TYPE_32 == "yes" || $ARCH_AARCH64 == "yes") {
  441. DEFAULT_ALLOCATOR=J
  442. }
  443. # tag:allocator
  444. when ($OS_CYGWIN == "yes" || $ARCH_PPC64LE == "yes") {
  445. DEFAULT_ALLOCATOR=SYSTEM
  446. }
  447. # tag:allocator
  448. when ($OS_DARWIN == "yes") {
  449. DEFAULT_ALLOCATOR=SYSTEM
  450. }
  451. # tag:allocator
  452. when ($OS_LINUX == "yes") {
  453. when ($GCC) {
  454. # tcmalloc broken build
  455. }
  456. elsewhen ($SANDBOXING) {
  457. # broken
  458. }
  459. elsewhen ($ARCH_X86_64) {
  460. DEFAULT_ALLOCATOR=TCMALLOC_TC
  461. }
  462. }
  463. # tag:allocator
  464. when ($SANITIZER_TYPE) {
  465. when ($SANITIZER_TYPE != "no") {
  466. DEFAULT_ALLOCATOR=SYSTEM
  467. }
  468. }
  469. # tag:allocator
  470. when ($ARCH_XTENSA == "yes") {
  471. DEFAULT_ALLOCATOR=FAKE
  472. }
  473. # tag:internal
  474. ### @usage: CHECK_CONFIG_H(<conf_header>) # internal
  475. ###
  476. ### This internal macro adds checking code for configuration header in external (contrib) library.
  477. ### The check is needed to avoid conflicts on certain types and functions available in arcadia.
  478. ###
  479. ### @see https://a.yandex-team.ru/arc/trunk/arcadia/build/scripts/check_config_h.py for exact details
  480. macro CHECK_CONFIG_H(Conf) {
  481. .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"}
  482. OUTPUT_INCLUDES=$Conf
  483. }
  484. REQUIRED_TRANSITIVE_PEERS=
  485. ### @usage REQUIRES(dirs...)
  486. ###
  487. ### Specify list of dirs which this module must depend on indirectly.
  488. ###
  489. ### This macro can be used if module depends on the directories specified but they can't be listed
  490. ### as direct PEERDIR dependencies (due to public include order or link order issues).
  491. macro REQUIRES(DIRS[]) {
  492. SET_APPEND(REQUIRED_TRANSITIVE_PEERS $DIRS)
  493. }
  494. CHECK_DEPENDENT_DIRS_TYPES=
  495. CHECK_DEPENDENT_DIRS_RESTRICTIONS=
  496. ### @usage CHECK_DEPENDENT_DIRS(DENY|ALLOW_ONLY ([ALL|PEERDIRS|GLOB] dir)...)
  497. ###
  498. ### Specify project transitive dependencies constraints.
  499. ###
  500. ### @params:
  501. ### 1. DENY: current module can not depend on module from any specified directory neither directly nor transitively.
  502. ### 2. ALLOW_ONLY: current module can not depend on module from a dir not specified in the directory list neither directly nor transitively.
  503. ### 3. ALL: directory constraints following after this modifier are applied to both transitive PEERDIR dependencies and tool dependencies.
  504. ### 4. PEERDIRS: directory constraints following after this modifier are applied to transitive PEERDIR dependencies only.
  505. ### 5. GLOB: next directory constraint is an ANT glob pattern.
  506. ### 6. EXCEPT: next constraint is an exception for the rest of other rules.
  507. ###
  508. ### Directory constraints added before either ALL or PEERDIRS modifier is used are treated as ALL directory constraints.
  509. ###
  510. ### Note: Can be used multiple times on the same module all specified constraints will be checked.
  511. ### All macro invocation for the same module must use same constraints type (DENY or ALLOW_ONLY)
  512. macro CHECK_DEPENDENT_DIRS(TYPE, ALL?"UNUSED":"", PEERDIRS?"PEERDIRS":"ALL", RESTRICTIONS...) {
  513. SET_APPEND(CHECK_DEPENDENT_DIRS_RESTRICTIONS $PEERDIRS $RESTRICTIONS)
  514. SET_APPEND(CHECK_DEPENDENT_DIRS_TYPES $TYPE)
  515. }
  516. # tag:proto
  517. PY_PROTOS_FOR=no
  518. BUILD_PROTO_AS_EVLOG=no
  519. # tag:proto
  520. PROTO_NAMESPACE=
  521. # tag:proto tag:python-specific
  522. GEN_PY_PROTOS=$YMAKE_PYTHON ${input:"build/scripts/gen_py_protos.py"}
  523. # tag:proto tag:cpp-specific
  524. PROTO_HEADER_EXTS=.pb.h
  525. CPP_PROTO_CMDLINE=
  526. CPP_PROTO_OPTS=
  527. CPP_PROTO_OUTS=
  528. CPP_PROTO_OUTS_SEM=
  529. CPP_PROTO_SUFFIXES=.pb.h .pb.cc
  530. CPP_PROTO_PLUGINS=
  531. # tag:proto tag:cpp-specific
  532. CPP_EV_OPTS=--plugin=protoc-gen-event2cpp=${tool:"tools/event2cpp"} --event2cpp_out=$ARCADIA_BUILD_ROOT -I=$ARCADIA_ROOT/library/cpp/eventlog
  533. CPP_EV_OUTS=
  534. CPP_EV_OUTS_SEM=
  535. # tag:proto tag:python-specific
  536. PY_PROTO_OPTS=
  537. PY_PROTO_OUTS=
  538. PY_PROTO_OUTS_INTERNAL=
  539. PY_PROTO_DEPS=
  540. PY_PROTO_SUFFIXES=_pb2.py
  541. PY_EVLOG_SUFFIXES=_ev_pb2.py
  542. # tag:proto tag:java-specific
  543. JAVA_PROTO_ARGS=
  544. # tag:proto tag:python-specific
  545. OPTIMIZE_PY_PROTOS_FLAG=no
  546. macro _RESOURCE_SEM(INPUTS[], KEYS[]) {
  547. SET(RESOURCE_OUTPUT ${hash:INPUTS}.cpp)
  548. .SEM=resources ${output;global:RESOURCE_OUTPUT} INPUTS ${input:INPUTS} KEYS $KEYS ${tool;hide:"tools/rescompiler/bin"}
  549. }
  550. # tag:built-in
  551. ### @usage: RESOURCE([FORCE_TEXT ][Src Key]* [- Key=Value]*) # built-in
  552. ### Add data (resources, random files, strings) to the program)
  553. ### 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.
  554. ### Alternative syntax with '- Key=Value' allows placing Value string as resource data into binary and make it accessible by Key.
  555. ###
  556. ### This is a simpler but less flexible option than ARCHIVE(), because in the case of ARCHIVE(), you have to use the data explicitly,
  557. ### and in the case of RESOURCE(), the data will fall through SRCS() or SRCS(GLOBAL) to binary linking.
  558. ###
  559. ### Use the FORCE_TEXT parameter to explicitly mark all Src files as text files: they will not be parsed unless used elsewhere.
  560. ###
  561. ### @example: https://wiki.yandex-team.ru/yatool/howtowriteyamakefiles/#a2ispolzujjtekomanduresource
  562. ###
  563. ### @example:
  564. ###
  565. ### LIBRARY()
  566. ### OWNER(user1)
  567. ###
  568. ### RESOURCE(
  569. ### path/to/file1 /key/in/program/1
  570. ### path/to/file2 /key2
  571. ### )
  572. ### END()
  573. ###
  574. macro RESOURCE(Args...) {
  575. PEERDIR(library/cpp/resource)
  576. }
  577. # tag:internal
  578. ### @usage: _ORDER_ADDINCL([BUILD ...] [SOURCE ...] Args...) # internal
  579. ###
  580. ### Order and filter ADDINCLs (Args - is intentionally omitted in ADDINCL macro)
  581. macro _ORDER_ADDINCL(BUILD[], SOURCE[], ARGS...) {
  582. ADDINCL($BUILD $SOURCE)
  583. }
  584. # tag:proto
  585. ### @usage: PROTO_ADDINCL([GLOBAL] [WITH_GEN] Path)
  586. ###
  587. ### This macro introduces proper ADDINCLs for .proto-files found in sources and
  588. ### .cpp/.h generated files, supplying them to appropriate commands and allowing
  589. ### proper dependency resolution at configure-time.
  590. ###
  591. ### Note: you normally shouldn't use this macro. ADDINCLs should be sent to user
  592. ### from dependency via PROTO_NAMESPACE macro
  593. macro PROTO_ADDINCL(GLOBAL?"GLOBAL":"", Path, WITH_GEN?"BUILD":"") {
  594. _ORDER_ADDINCL($WITH_GEN $GLOBAL FOR proto ${ARCADIA_BUILD_ROOT}/$Path SOURCE $GLOBAL FOR proto ${ARCADIA_ROOT}/$Path)
  595. ADDINCL($GLOBAL ${ARCADIA_BUILD_ROOT}/$Path)
  596. }
  597. # tag:proto
  598. ### @usage: PROTO_NAMESPACE([WITH_GEN] Namespace)
  599. ###
  600. ### Defines protobuf namespace (import/export path prefix) which should be used for imports and
  601. ### which defines output path for .proto generation.
  602. ###
  603. ### For proper importing and configure-time dependency management it sets ADDINCLs
  604. ### for both .cpp headers includes and .proto imports. If .proto expected to be used outside of the
  605. ### processing module use GLOBAL to send proper ADDINCLs to all (transitive) users. PEERDIR to
  606. ### PROTO_LIBRARY with PROTO_NAMESPACE() is enough at user side to correctly use the library.
  607. ### If generated .proto files are going to be used for building a module than use of WITH_GEN
  608. ### parameter will add appropriate dir from the build root for .proto files search.
  609. macro PROTO_NAMESPACE(GLOBAL?"GLOBAL":"", WITH_GEN?"WITH_GEN":"", Namespace) {
  610. SET(PROTO_NAMESPACE $Namespace)
  611. PROTO_ADDINCL(GLOBAL $WITH_GEN $Namespace)
  612. }
  613. # tag:proto
  614. ### @usage PROTOC_FATAL_WARNINGS()
  615. ###
  616. ### Treat protoc warnings as fatal errors that break the build, for example, unused imports
  617. ### Adds `--fatal_warnings` argument to protoc
  618. macro PROTOC_FATAL_WARNINGS() {
  619. SET_APPEND(_PROTOC_FLAGS --fatal_warnings)
  620. }
  621. # tag:proto tag:internal tag:python-specific
  622. ### @usage: OPTIMIZE_PY_PROTOS() # internal
  623. ###
  624. ### Enable Python proto optimization by embedding corresponding C++ code into binary.
  625. ### Python protobuf runtime will use C++ implementation instead of Python one if former is available.
  626. ### This is default mode for most PROTO_LIBRARY's and PY2_LIBRARY's, some system ones being exceptions.
  627. macro OPTIMIZE_PY_PROTOS() {
  628. SET(OPTIMIZE_PY_PROTOS_FLAG yes)
  629. }
  630. # tag:proto tag:python-specific
  631. ### @usage: NO_OPTIMIZE_PY_PROTOS()
  632. ###
  633. ### Disable Python proto optimization using embedding corresponding C++ code into binary.
  634. ### Python protobuf runtime will use C++ implementation instead of Python one if former is available.
  635. ### This is default mode only for some system libraries.
  636. macro NO_OPTIMIZE_PY_PROTOS() {
  637. SET(OPTIMIZE_PY_PROTOS_FLAG no)
  638. }
  639. # tag:proto tag:python-specific
  640. macro _PROTO_PLUGIN_ARGS_BASE(Name, Tool, OutParm...) {
  641. .CMD=--plugin=protoc-gen-${Name}=\${tool:"$Tool"} --${Name}_out=$ARCADIA_BUILD_ROOT/\$PROTO_NAMESPACE ${pre=--${Name}_opt=:OutParm}
  642. .SEM=IGNORED
  643. }
  644. # tag:proto tag:python-specific
  645. macro _ADD_PY_PROTO_OUT(Suf) {
  646. SET_APPEND(PY_PROTO_OUTS \${output;hide;noauto;norel;nopath;noext;suf=$Suf:File})
  647. 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}"})
  648. # XXX fix variable expansion in plugins
  649. SET(PY_PROTO_SUFFIXES $PY_PROTO_SUFFIXES $Suf)
  650. }
  651. # tag:proto tag:python-specific
  652. ### @usage: PY_PROTO_PLUGIN(Name Ext Tool DEPS <Dependencies>)
  653. ###
  654. ### Define protoc plugin for python with given Name that emits extra output with provided Extension
  655. ### using Tool. Extra dependencies are passed via DEPS
  656. macro PY_PROTO_PLUGIN(NAME, EXT, TOOL, DEPS[]) {
  657. SET_APPEND(PY_PROTO_OPTS $_PROTO_PLUGIN_ARGS_BASE($NAME $TOOL))
  658. _ADD_PY_PROTO_OUT($EXT)
  659. # XXX fix variable expansion in plugins
  660. SET(PY_PROTO_DEPS $PY_PROTO_DEPS $DEPS)
  661. }
  662. # tag:proto tag:python-specific
  663. ### @usage: PY_PROTO_PLUGIN2(Name Ext1 Ext2 Tool DEPS <Dependencies>)
  664. ###
  665. ### Define protoc plugin for python with given Name that emits 2 extra outputs with provided Extensions
  666. ### using Tool. Extra dependencies are passed via DEPS
  667. macro PY_PROTO_PLUGIN2(NAME, EXT1, EXT2, TOOL, DEPS[]) {
  668. PY_PROTO_PLUGIN($NAME $EXT1 $TOOL DEPS $DEPS)
  669. _ADD_PY_PROTO_OUT($EXT2)
  670. }
  671. # tag:proto tag:java-specific
  672. macro _JAVA_PROTO_PLUGIN_ARGS_BASE(Name, Tool, OutParm...) {
  673. .CMD=--plugin=protoc-gen-${Name}=\${tool:"$Tool"} --${Name}_out=$ARCADIA_BUILD_ROOT/java_out
  674. }
  675. # tag:proto tag:java-specific
  676. ### @usage: JAVA_PROTO_PLUGIN(Name Tool DEPS <Dependencies>)
  677. ###
  678. ### Define protoc plugin for Java with given Name that emits extra outputs
  679. ### using Tool. Extra dependencies are passed via DEPS
  680. macro JAVA_PROTO_PLUGIN(NAME, TOOL, DEPS[]) {
  681. SET_APPEND(JAVA_PROTO_ARGS $_JAVA_PROTO_PLUGIN_ARGS_BASE($NAME $TOOL))
  682. # XXX fix variable expansion in plugins
  683. SET(JAVA_PROTOBUF_PEERS $JAVA_PROTOBUF_PEERS $DEPS)
  684. }
  685. macro _ADD_SEM_PROP_IF_NON_EMPTY(Prop, Args...) {
  686. .SEM=${pre=&& set_target_property $Prop :Args}
  687. }
  688. # tag:proto tag:cpp-specific
  689. macro _ADD_CPP_PROTO_OUT(Suf) {
  690. .SEM=append_target_property PROTOC_EXTRA_OUTS $Suf ${output;hide;suf=.o:Suf} $_ADD_SEM_PROP_IF_NON_EMPTY(PROTO_NAMESPACE $PROTO_NAMESPACE)
  691. SET_APPEND(CPP_PROTO_OUTS \${output;hide;norel;nopath;noext;suf=$Suf:File})
  692. # XXX fix variable expansion in plugins
  693. SET(CPP_PROTO_SUFFIXES $CPP_PROTO_SUFFIXES $Suf)
  694. }
  695. # tag:proto tag:cpp-specific
  696. HAS_CPP_PROTOBUF_PEERS=no
  697. CPP_PROTOBUF_PEERS=
  698. # tag:proto tag:cpp-specific
  699. ### @usage: CPP_PROTO_PLUGIN0(Name Tool DEPS <Dependencies>)
  700. ###
  701. ### Define protoc plugin for C++ with given Name that emits code into regular outputs
  702. ### using Tool. Extra dependencies are passed via DEPS.
  703. macro CPP_PROTO_PLUGIN0(NAME, TOOL, DEPS[]) {
  704. .SEM=target_proto_plugin $NAME ${tool;rootrel:TOOL} ${output;hide;suf=.fake.o:NAME}
  705. SET_APPEND(CPP_PROTO_OPTS $_PROTO_PLUGIN_ARGS_BASE($NAME $TOOL))
  706. # XXX fix variable expansion in plugins
  707. ENABLE(HAS_CPP_PROTOBUF_PEERS)
  708. SET(CPP_PROTOBUF_PEERS $CPP_PROTOBUF_PEERS $DEPS)
  709. }
  710. # tag:proto tag:cpp-specific
  711. ### @usage: CPP_PROTO_PLUGIN(Name Tool Suf DEPS <Dependencies>)
  712. ###
  713. ### Define protoc plugin for C++ with given Name that emits code into 1 extra output
  714. ### using Tool. Extra dependencies are passed via DEPS.
  715. macro CPP_PROTO_PLUGIN(NAME, TOOL, SUF, DEPS[]) {
  716. CPP_PROTO_PLUGIN0($NAME $TOOL DEPS $DEPS)
  717. _ADD_CPP_PROTO_OUT($SUF)
  718. }
  719. # tag:proto tag:cpp-specific
  720. ### @usage: CPP_PROTO_PLUGIN2(Name Tool Suf1 Suf2 DEPS <Dependencies>)
  721. ###
  722. ### Define protoc plugin for C++ with given Name that emits code into 2 extra outputs
  723. ### using Tool. Extra dependencies are passed via DEPS.
  724. macro CPP_PROTO_PLUGIN2(NAME, TOOL, SUF1, SUF2, DEPS[]) {
  725. CPP_PROTO_PLUGIN($NAME $TOOL $SUF1 DEPS $DEPS)
  726. _ADD_CPP_PROTO_OUT($SUF2)
  727. SET_APPEND(CPP_PROTO_OUTS_SEM \${output;hide;norel;nopath;noext;suf=$SUF2:File})
  728. }
  729. # tag:proto
  730. ### @usage: USE_SKIFF() #wip, do not use
  731. ###
  732. ### Use mapreduce/yt/skiff_proto/plugin for C++
  733. macro USE_SKIFF() {
  734. # Move extra includes to INDUCED_DEPS macro in mapreduce/yt/skiff_proto/plugin/ya.make
  735. CPP_PROTO_PLUGIN0(skiff mapreduce/yt/skiff_proto/plugin DEPS mapreduce/yt/skiff_proto/lib)
  736. }
  737. # tag:go-specific
  738. _GO_COMMON_GOOGLE_APIS = \
  739. vendor/google.golang.org/genproto/googleapis/api/annotations \
  740. vendor/google.golang.org/genproto/googleapis/api/configchange \
  741. vendor/google.golang.org/genproto/googleapis/api/distribution \
  742. vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1 \
  743. vendor/google.golang.org/genproto/googleapis/api/expr/v1beta1 \
  744. vendor/google.golang.org/genproto/googleapis/api/httpbody \
  745. vendor/google.golang.org/genproto/googleapis/api/label \
  746. vendor/google.golang.org/genproto/googleapis/api/metric \
  747. vendor/google.golang.org/genproto/googleapis/api/monitoredres \
  748. vendor/google.golang.org/genproto/googleapis/api/serviceconfig \
  749. vendor/google.golang.org/genproto/googleapis/api/servicecontrol/v1 \
  750. vendor/google.golang.org/genproto/googleapis/api/servicemanagement/v1 \
  751. vendor/google.golang.org/genproto/googleapis/iam/admin/v1 \
  752. vendor/google.golang.org/genproto/googleapis/iam/credentials/v1 \
  753. vendor/google.golang.org/genproto/googleapis/iam/v1 \
  754. vendor/google.golang.org/genproto/googleapis/iam/v1/logging \
  755. vendor/google.golang.org/genproto/googleapis/logging/type \
  756. vendor/google.golang.org/genproto/googleapis/logging/v2 \
  757. vendor/google.golang.org/genproto/googleapis/rpc/code \
  758. vendor/google.golang.org/genproto/googleapis/rpc/errdetails \
  759. vendor/google.golang.org/genproto/googleapis/rpc/status \
  760. vendor/google.golang.org/genproto/googleapis/type/calendarperiod \
  761. vendor/google.golang.org/genproto/googleapis/type/color \
  762. vendor/google.golang.org/genproto/googleapis/type/date \
  763. vendor/google.golang.org/genproto/googleapis/type/dayofweek \
  764. vendor/google.golang.org/genproto/googleapis/type/expr \
  765. vendor/google.golang.org/genproto/googleapis/type/fraction \
  766. vendor/google.golang.org/genproto/googleapis/type/latlng \
  767. vendor/google.golang.org/genproto/googleapis/type/money \
  768. vendor/google.golang.org/genproto/googleapis/type/postaladdress \
  769. vendor/google.golang.org/genproto/googleapis/type/quaternion \
  770. vendor/google.golang.org/genproto/googleapis/type/timeofday
  771. # tag:go-specific
  772. _COMMON_GOOGLE_APIS=None
  773. # tag:go-specific
  774. ### @usage: USE_COMMON_GOOGLE_APIS([apis...])
  775. ###
  776. ### Use common-google-apis library set. Pass optional apis list to be used or use them all.
  777. ### This macro is properly handled for all languages including Go, where apis come in
  778. ## pregenerated form. In other languages apis are generated from sources in Arcadia.
  779. macro USE_COMMON_GOOGLE_APIS(APIS...) {
  780. SET(_COMMON_GOOGLE_APIS ${pre=vendor/google.golang.org/genproto/googleapis/:APIS})
  781. }
  782. # tag:go-specific tag:proto
  783. GO_PROTO_GEN_PLUGINS=
  784. GO_PROTO_OPTS=
  785. GO_PROTO_OUTS=
  786. GO_PROTO_GRPC_OPTS=
  787. GO_PROTO_GRPC_OUTS=
  788. GO_PROTO_V2=no
  789. _GO_PROTO_CHECK_OUTPUT=
  790. # tag:go-specific tag:proto
  791. GO_PROTOBUF_IMPORTS=\
  792. ${GOSTD}/sync \
  793. ${GOSTD}/reflect \
  794. ${GOSTD}/fmt \
  795. ${GOSTD}/math \
  796. vendor/github.com/golang/protobuf/proto \
  797. vendor/google.golang.org/protobuf/types/descriptorpb \
  798. vendor/google.golang.org/protobuf/runtime/protoimpl \
  799. vendor/google.golang.org/protobuf/runtime/protoiface \
  800. vendor/google.golang.org/protobuf/reflect/protoreflect
  801. # tag:go-specific tag:proto
  802. GO_PROTOBUF_WELLKNOWN_TYPES=\
  803. vendor/google.golang.org/protobuf/types/known/anypb \
  804. vendor/google.golang.org/protobuf/types/known/apipb \
  805. vendor/google.golang.org/protobuf/types/known/durationpb \
  806. vendor/google.golang.org/protobuf/types/known/emptypb \
  807. vendor/google.golang.org/protobuf/types/known/fieldmaskpb \
  808. vendor/google.golang.org/protobuf/types/known/sourcecontextpb \
  809. vendor/google.golang.org/protobuf/types/known/structpb \
  810. vendor/google.golang.org/protobuf/types/known/timestamppb \
  811. vendor/google.golang.org/protobuf/types/known/typepb \
  812. vendor/google.golang.org/protobuf/types/known/wrapperspb
  813. # tag:go-specific tag:proto
  814. ### @usage: GO_PROTO_PLUGIN(Name Ext Tool [DEPS dependencies...])
  815. ###
  816. ### Define protoc plugin for GO with given Name that emits extra output with provided extension
  817. ### Ext using Tool. Extra dependencies are passed via DEPS.
  818. macro GO_PROTO_PLUGIN(NAME, EXT, TOOL, DEPS[]) {
  819. SET_APPEND(GO_PROTO_OPTS $_PROTO_PLUGIN_ARGS_BASE($NAME $TOOL))
  820. SET_APPEND(GO_PROTO_OUTS \${output;hide;noauto;norel;nopath;noext;suf=$EXT:File})
  821. PEERDIR(${DEPS})
  822. }
  823. # tag:go-specific tag:proto
  824. GO_PROTO_CMDLINE=${cwd;rootdir;input:File} $YMAKE_PYTHON3 ${input:"build/scripts/go_proto_wrapper.py"} --arcadia-prefix $GO_ARCADIA_PROJECT_PREFIX --contrib-prefix $GO_CONTRIB_PROJECT_PREFIX --namespace ./$PROTO_NAMESPACE $_GO_PROTO_CHECK_OUTPUT --proto ${input;rootrel:File} -- $PROTOC -I=./$PROTO_NAMESPACE -I=$ARCADIA_ROOT/$PROTO_NAMESPACE ${pre=-I=:_PROTO__INCLUDE} -I=$ARCADIA_BUILD_ROOT -I=$PROTOBUF_PATH $_PROTOC_FLAGS
  825. # tag:go-specific tag:proto
  826. macro _GO_PROTO_CMD_IMPL(File, OPTS...) {
  827. .CMD=$GO_PROTO_CMDLINE $OPTS ${kv;hide:"p PB"} ${kv;hide:"pc yellow"}
  828. .PEERDIR=${GO_PROTOBUF_IMPORTS} ${GO_PROTOBUF_WELLKNOWN_TYPES}
  829. .ADDINCL=FOR proto contrib/libs/protobuf/src
  830. }
  831. # tag:go-specific tag:proto
  832. macro _GO_PROTO_CMD(File) {
  833. .CMD=$_GO_PROTO_CMD_IMPL($File $GO_PROTO_OPTS $GO_PROTO_OUTS)
  834. }
  835. # tag:proto
  836. ### @usage: YP_PROTO_YSON(Files... OUT_OPTS Opts...)
  837. ###
  838. ### Generate .yson.go from .proto using yp/go/yson/internal/proto-yson-gen/cmd/proto-yson-gen
  839. macro YP_PROTO_YSON(OUT_OPTS[], Files...) {
  840. .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}" $_PROTOC_FLAGS ${input:Files} ${output;hide;noauto;nopath;noext;suf=.yson.go:Files}
  841. .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
  842. .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
  843. }
  844. _SEM_CPP_PROTO_CMD=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"} \
  845. && set_global_flags COMMON_PROTOC_FLAGS \
  846. && target_proto_outs --cpp_out=$ARCADIA_BUILD_ROOT/$PROTO_NAMESPACE $PROTOC_STYLEGUIDE_OUT \
  847. && target_proto_addincls ./$PROTO_NAMESPACE $ARCADIA_ROOT/$PROTO_NAMESPACE ${_PROTO__INCLUDE} $ARCADIA_BUILD_ROOT $PROTOBUF_PATH
  848. # tag:proto
  849. macro _CPP_PROTO_CMD(File) {
  850. .CMD=$CPP_PROTO_CMDLINE $CPP_PROTO_OPTS $CPP_PROTO_OUTS ${kv;hide:"p PB"} ${kv;hide:"pc yellow"}
  851. .SEM=$_SEM_CPP_PROTO_CMD
  852. .PEERDIR=contrib/libs/protobuf
  853. }
  854. # tag:proto
  855. macro _CPP_VANILLA_PROTO_CMD(File) {
  856. .CMD=$CPP_PROTO_CMDLINE $CPP_PROTO_OPTS $CPP_PROTO_OUTS ${kv;hide:"p PB"} ${kv;hide:"pc yellow"}
  857. .PEERDIR=contrib/libs/protobuf_std
  858. }
  859. _SEM_CPP_EV_CMD=target_ev_messages PRIVATE ${input:File} $CPP_EV_OUTS_SEM ${output;hide;suf=${OBJ_SUF}.pb.o:File} ${hide;tool:"tools/event2cpp/bin"} ${hide;tool:"contrib/tools/protoc/bin"} ${hide;tool:"contrib/tools/protoc/plugins/cpp_styleguide"} \
  860. && set_global_flags COMMON_PROTOC_FLAGS \
  861. && target_proto_outs --cpp_out=$ARCADIA_BUILD_ROOT/$PROTO_NAMESPACE $PROTOC_STYLEGUIDE_OUT --event2cpp_out=$ARCADIA_BUILD_ROOT/$PROTO_NAMESPACE \
  862. && target_proto_addincls ./$PROTO_NAMESPACE $ARCADIA_ROOT/$PROTO_NAMESPACE ${_PROTO__INCLUDE} $ARCADIA_BUILD_ROOT $PROTOBUF_PATH $ARCADIA_ROOT/library/cpp/eventlog
  863. # tag:proto
  864. macro _CPP_EVLOG_CMD(File) {
  865. .CMD=$CPP_PROTO_CMDLINE $CPP_EV_OPTS $CPP_EV_OUTS ${kv;hide:"p EV"} ${kv;hide:"pc yellow"}
  866. .SEM=$_SEM_CPP_EV_CMD
  867. .PEERDIR=library/cpp/eventlog contrib/libs/protobuf
  868. }
  869. # tag:proto
  870. macro _CPP_PROTO_EVLOG_CMD(File) {
  871. # process .proto as .ev
  872. .CMD=$CPP_PROTO_CMDLINE $CPP_EV_OPTS $CPP_PROTO_OUTS ${kv;hide:"p PB"} ${kv;hide:"pc yellow"}
  873. .PEERDIR=library/cpp/eventlog contrib/libs/protobuf
  874. }
  875. # tag:proto
  876. macro _CPP_CFGPROTO_CMD(File) {
  877. # keep extension in output just as in EV: this is hard-coded behaviour of protoc for non-.proto extensions
  878. .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"}
  879. .PEERDIR=library/cpp/proto_config/codegen library/cpp/proto_config/protos contrib/libs/protobuf
  880. }
  881. # tag:proto
  882. PY_PROTO_MYPY_ENABLED=yes
  883. 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
  884. # tag:proto tag:python-specific
  885. PY_PROTO_MYPY_SUFFIX=
  886. PY_PROTO_MYPY_PLUGIN=
  887. PY_PROTO_MYPY_PLUGIN_INTERNAL=
  888. # tag:proto tag:python-specific
  889. macro NO_MYPY() {
  890. DISABLE(PY_PROTO_MYPY_ENABLED)
  891. }
  892. # tag:proto tag:python-specific
  893. macro _PY_PROTO_CMD_BASE(File, Suf, Args...) {
  894. .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 $_PROTOC_FLAGS ${input;rootrel:File} ${output;hide;noauto;norel;nopath;noext;suf=$Suf:File} ${kv;hide:"p PB"} ${kv;hide:"pc yellow"} $Args
  895. }
  896. # tag:proto tag:python-specific
  897. macro _PY_PROTO_CMD(File) {
  898. .CMD=${cwd;rootdir;input:File} $_PY_PROTO_CMD_BASE($File _pb2.py $PY_PROTO_OPTS $PY_PROTO_OUTS $PY_PROTO_MYPY_PLUGIN)
  899. }
  900. # tag:proto tag:python-specific
  901. macro _PY_PROTO_CMD_INTERNAL(File) {
  902. .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)
  903. }
  904. # tag:proto tag:java-specific
  905. JAVA_PROTO_RUNTIME=
  906. # tag:proto tag:java-specific
  907. ### @usage: USE_JAVALITE()
  908. ### Use protobuf-javalite for Java
  909. macro USE_JAVALITE() {
  910. SET(JAVA_PROTO_RUNTIME javalite)
  911. }
  912. # tag:proto tag:java-specific
  913. JAVA_PROTO_RUNTIME_VERSION = 3.21.12
  914. JAVA_PROTO_COMMON_VERSION = 1.12.0
  915. KOTLIN_PROTO=no
  916. KOTLIN_PROTO_PEERS=
  917. when ($JAVA_PROTO_RUNTIME == "javalite") {
  918. _JAVA_PROTO_LITE_ARG=lite:
  919. JAVA_PROTOBUF_PEERS=contrib/java/com/google/protobuf/protobuf-javalite/${JAVA_PROTO_RUNTIME_VERSION} ${KOTLIN_PROTO_PEERS}
  920. JAVA_GRPC_STUB=contrib/java/io/grpc/grpc-stub/1.43.2
  921. JAVA_GRPC_PROTOBUF=contrib/java/io/grpc/grpc-protobuf/1.43.2
  922. }
  923. otherwise {
  924. _JAVA_PROTO_LITE_ARG=
  925. JAVA_PROTOBUF_PEERS=contrib/java/com/google/protobuf/protobuf-java/${JAVA_PROTO_RUNTIME_VERSION} ${KOTLIN_PROTO_PEERS}
  926. JAVA_GRPC_STUB=contrib/java/io/grpc/grpc-stub/1.43.2
  927. JAVA_GRPC_PROTOBUF=contrib/java/io/grpc/grpc-protobuf/1.43.2
  928. }
  929. KOTLIN_PROTO_FLAGS=
  930. # tag:proto tag:java-specific
  931. macro _JAVA_PROTO_CMD(File) {
  932. .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_out=${_JAVA_PROTO_LITE_ARG}$ARCADIA_BUILD_ROOT/java_out ${KOTLIN_PROTO_FLAGS} $_PROTOC_FLAGS ${input;rootrel:File} ${kv;hide:"p PB"} ${kv;hide:"pc yellow"} $JAVA_PROTO_ARGS
  933. .SEM=proto_files ${input;rootrel:File} ${hide;output:File.jsrc}
  934. }
  935. # tag:proto tag:perl-specific tag:deprecated
  936. ### @usage: XS_PROTO(InputProto Dir Outputs...) # deprecated
  937. ###
  938. ### Generate Perl code from protobuf.
  939. ### In order to use this macro one should predict all outputs protoc will emit from input_proto file and enlist those as outputs.
  940. macro XS_PROTO(File, Dir, Outputs...) {
  941. .CMD=$PROTOC -I=${ARCADIA_ROOT}/${Dir} ${pre=-I=:_PROTO__INCLUDE} -I=${ARCADIA_ROOT} -I=${PROTOBUF_PATH} --perlxs_out=${BINDIR} $_PROTOC_FLAGS ${input:File} ${hide;output:Outputs} ${induced_deps=h+cpp;hide;nopath;noext;suf=.pb.h:File}
  942. PEERDIR(${Dir})
  943. ADDINCL(${ARCADIA_BUILD_ROOT}/${Dir})
  944. }
  945. # tag:proto tag:fbs
  946. ### @usage: PROTO2FBS(InputProto)
  947. ###
  948. ### Produce flatbuf schema out of protobuf description.
  949. macro PROTO2FBS(File) {
  950. .CMD=${cwd:BINDIR} ${tool:"contrib/tools/flatc"} -I . -I ${ARCADIA_ROOT} --proto ${input:File} ${output;hide;norel;noext:File.fbs} ${kv;hide:"p FBS"} ${kv;hide:"pc yellow"} && $MOVE_FILE ${BINDIR}/${nopath;noext:File.fbs} ${output;norel;noext:File.fbs}
  951. }
  952. # tag:proto tag:python-specific
  953. when ($PY_PROTOS_FOR == "yes") {
  954. PEERDIR+=contrib/libs/protobuf/python
  955. }
  956. # tag:python-specific
  957. macro _PY_EVLOG_CMD_BASE(File, Suf, Args...) {
  958. .CMD=$_PY_PROTO_CMD_BASE($File $Suf $Args)
  959. .PEERDIR=library/cpp/eventlog/proto
  960. }
  961. # tag:python-specific tag:proto
  962. macro _PY_EVLOG_CMD(File) {
  963. .CMD=${cwd;rootdir;input:File} $_PY_EVLOG_CMD_BASE($File _ev_pb2.py)
  964. }
  965. # tag:python-specific tag:proto
  966. macro _PY_EVLOG_CMD_INTERNAL(File) {
  967. .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}"})
  968. }
  969. # tag:java-specific tag:proto
  970. macro _JAVA_EVLOG_CMD(File) {
  971. .CMD=$COPY_CMD ${input:File} ${output;nopath;noext;norel;suf=_ev.proto:File} ${kv;hide:"p EV"} ${kv;hide:"pc yellow"}
  972. .PEERDIR=library/cpp/eventlog/proto
  973. }
  974. # tag:sanitize
  975. RUN_NO_SANITIZE=$YMAKE_PYTHON ${input:"build/scripts/run_tool.py"} --
  976. # tag:sanitize
  977. when ($IS_CROSS_SANITIZE) {
  978. RUN_NO_SANITIZE=
  979. }
  980. YIELD=$YMAKE_PYTHON ${input:"build/scripts/yield_line.py"} -- ${BINDIR}/__args
  981. XARGS=$YMAKE_PYTHON ${input:"build/scripts/xargs.py"} -- ${BINDIR}/__args
  982. WRITER_PY=$YMAKE_PYTHON ${input:"build/scripts/writer.py"} ${input;hide:"build/scripts/process_command_files.py"}
  983. FS_TOOLS=$YMAKE_PYTHON ${input:"build/scripts/fs_tools.py"} ${input;hide:"build/scripts/process_command_files.py"}
  984. FIX_MSVC_OUTPUT=${YMAKE_PYTHON} ${input:"build/scripts/fix_msvc_output.py"} ${input;hide:"build/scripts/process_command_files.py"}
  985. _PROCESS_WHOLE_ARCHIVE_SCRIPT=${input;hide:"build/scripts/process_command_files.py"} ${input;hide:"build/scripts/process_whole_archive_option.py"}
  986. COPY_CMD=$FS_TOOLS copy
  987. LINK_OR_COPY_CMD=$FS_TOOLS link_or_copy
  988. REMOVE_FILE=$FS_TOOLS remove
  989. MOVE_FILE=$FS_TOOLS rename
  990. # tag:allocator tag:windows-specific
  991. MSVC_DYNAMICBASE=/DYNAMICBASE
  992. when ($ALLOCATOR == "LF") {
  993. MSVC_DYNAMICBASE=/DYNAMICBASE:NO
  994. }
  995. # tag:sanitize
  996. SANITIZE_HEADERS=yes
  997. SANITIZER_CFLAGS=
  998. # tag:proto tag:grpc
  999. _GRPC_ENABLED=no
  1000. # tag:proto tag:grpc
  1001. ### @usage: GRPC()
  1002. ###
  1003. ### Emit GRPC code for all .proto files in a PROTO_LIBRARY.
  1004. ### This works for all available PROTO_LIBRARY versions (C++, Python 2.x, Python 3.x, Java and Go).
  1005. macro GRPC() {
  1006. ENABLE(_GRPC_ENABLED)
  1007. # C++
  1008. CPP_PROTO_PLUGIN2(grpc_cpp contrib/tools/protoc/plugins/grpc_cpp .grpc.pb.cc .grpc.pb.h DEPS contrib/libs/grpc)
  1009. # Python
  1010. PY_PROTO_PLUGIN(grpc_py _pb2_grpc.py contrib/tools/protoc/plugins/grpc_python DEPS contrib/python/grpcio)
  1011. # Java
  1012. JAVA_PROTO_PLUGIN(grpc_java contrib/tools/protoc/plugins/grpc_java DEPS $JAVA_GRPC_STUB $JAVA_GRPC_PROTOBUF)
  1013. SET_APPEND(JAVA_PROTOBUF_PEERS contrib/java/javax/annotation/javax.annotation-api/1.3.1)
  1014. }
  1015. macro GO_PROTO_USE_V2() {
  1016. ENABLE(GO_PROTO_V2)
  1017. }
  1018. # tag:fbs
  1019. FLATC_FLAGS_VALUE=
  1020. ### @usage: FLATC_FLAGS(flags...)
  1021. ###
  1022. ### Add flags to flatc command line
  1023. macro FLATC_FLAGS(FLAGS...) {
  1024. SET_APPEND(FLATC_FLAGS_VALUE $FLAGS)
  1025. }
  1026. # tag:fbs
  1027. _PY_FBS_DEPS=contrib/python/flatbuffers
  1028. # tag:fbs tag:internal
  1029. ### @usage: FBS_TO_PYSRC(output_base_name fbs_files...) # internal
  1030. ###
  1031. ### Create a tar archive of .py files generated by flatc for Python. Output tar
  1032. ### archive will have .fbs.pysrc extension. This .fbs.pysrc extension is specially
  1033. ### processed when --add-flatbuf-result flag is specified on the command line
  1034. ### for 'ya make ...' (tar archive is extracted to output directory).
  1035. macro FBS_TO_PYSRC(OUT_NAME, IN_FBS_FILES...) {
  1036. .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_PYTHON3 ${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"}
  1037. }
  1038. # tag:fbs tag:go-specific
  1039. # Implicit dependencies of generated code for Go
  1040. _GO_FLATC_IMPORTS=\
  1041. ${GOSTD}/strconv \
  1042. vendor/github.com/google/flatbuffers/go
  1043. # tag:fbs tag:cpp-specific
  1044. macro _CPP_FLATC_CMD(SRC, SRCFLAGS...) {
  1045. .CMD=${cwd:ARCADIA_BUILD_ROOT} $YMAKE_PYTHON3 ${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"}
  1046. .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} ${input;hide:"build/scripts/cpp_flatc_wrapper.py"}
  1047. .PEERDIR=contrib/libs/flatbuffers
  1048. }
  1049. # tag:fbs tag:cpp-specific
  1050. macro _CPP_FLATC64_CMD(SRC, SRCFLAGS...) {
  1051. .CMD=${cwd:ARCADIA_BUILD_ROOT} $YMAKE_PYTHON3 ${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"}
  1052. .PEERDIR=contrib/libs/flatbuffers64
  1053. }
  1054. # tag:fbs tag:go-specific tag:internal
  1055. ### @usage: _GO_FLATC_CMD(fbs_file flags...) # internal
  1056. ###
  1057. ### Create a tar archive of .go files generated by flatc for Go. Output tar archive
  1058. ### will have .fbs.gosrc extension. This .fbs.gosrc is specially processed when
  1059. ### --add-protobuf-result flag is specified on the command line for 'ya make ...'
  1060. ### (tar archive is extracted to output directory).
  1061. macro _GO_FLATC_CMD(SRC, PACKAGE_NAME) {
  1062. .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_PYTHON3 ${input:"build/scripts/postprocess_go_fbs.py"} --input-dir ${BINDIR} --map $_FBS_NAMESPACE_MAP_GLOBAL && $YMAKE_PYTHON3 ${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"}
  1063. .PEERDIR=${_GO_FLATC_IMPORTS}
  1064. }
  1065. # tag:fbs tag:java-specific tag:internal
  1066. ### @usage: _JAVA_FLATC_CMD(fbs_file) # internal
  1067. ###
  1068. ### Create a tar archive of .java files generated by flatc for Java. Output tar
  1069. ### acrchive will have .fbs.jsrc extension. Files with .fbs.jsrc extension will
  1070. ### be added to results when --add-flatbuf-result flag is specified on the command
  1071. ### line for 'ya make ...'
  1072. macro _JAVA_FLATC_CMD(SRC) {
  1073. .CMD=${cwd:ARCADIA_BUILD_ROOT} ${tool:"contrib/tools/flatc"} --java --gen-mutable ${FLATC_FLAGS_VALUE} ${pre=-I :_FLATC__INCLUDE} -o ${BINDIR} ${input:SRC} && $YMAKE_PYTHON3 ${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"}
  1074. .PEERDIR=contrib/java/com/google/flatbuffers/flatbuffers-java/${JAVA_FLATBUFFERS_VERSION}
  1075. }
  1076. # variables must be defined for all module types to make generate_mf.py work
  1077. MODULE_PREFIX=
  1078. MODULE_SUFFIX=
  1079. NEED_PLATFORM_PEERDIRS=yes
  1080. PEERDIR_TEST_TOOL=yes
  1081. # tag:python-specific
  1082. PYTHON2=no
  1083. PYTHON3=no
  1084. # tag:python-specific
  1085. when (!$ARCADIA_PYTHON_UNICODE_SIZE) {
  1086. when ($OS_WINDOWS) {
  1087. ARCADIA_PYTHON_UNICODE_SIZE=2
  1088. }
  1089. otherwise {
  1090. ARCADIA_PYTHON_UNICODE_SIZE=4
  1091. }
  1092. }
  1093. YMAKE_PYTHON3_PEERDIR=build/platform/python/ymake_python3
  1094. macro NO_YMAKE_PYTHON3() {
  1095. SET(YMAKE_PYTHON3_PEERDIR)
  1096. }
  1097. ### @usage: _BARE_UNIT # internal
  1098. ###
  1099. ### The base of all modules describing default bare minimum for all modules.
  1100. ### To avoid surprises, all buildable modules are better to be inherited from it or its descendants.
  1101. module _BARE_UNIT {
  1102. .EXTS=.*
  1103. .CMD=TOUCH_UNIT
  1104. .IGNORED=GO_PROTO_PLUGIN
  1105. .NODE_TYPE=Bundle
  1106. .PEERDIR_POLICY=as_include
  1107. .RESTRICTED=GRPC USE_SKIFF INDUCED_DEPS FUZZ_DICTS FUZZ_OPTS PACK EXPLICIT_OUTPUTS 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 LIST_PROTO
  1108. .FINAL_TARGET=no
  1109. PEERDIR_TAGS=__EMPTY__
  1110. PEERDIR+=$YMAKE_PYTHON3_PEERDIR
  1111. when ($FATAL_ERROR_MESSAGE && $FATAL_ERROR_MODULE != "yes") {
  1112. PEERDIR+=build/conf_fatal_error
  1113. }
  1114. DEFAULT(MODULE_VERSION)
  1115. DEFAULT(MODULE_PREFIX)
  1116. DEFAULT(MODULE_SUFFIX)
  1117. }
  1118. ### @usage: GEN_LIBRARY()
  1119. ###
  1120. ### Definition of a module that brings generated artefacts. This module can PEERDIRed
  1121. ### from any module. The resulted module is empty and cleaned up during construction
  1122. ### of the build graph.
  1123. ###
  1124. ### NOTE! SRCS macro is not supported for this library.
  1125. module GEN_LIBRARY: _BARE_UNIT {
  1126. .PROXY=yes
  1127. .RESTRICTED=SRCS SRC
  1128. .SEM=IGNORED
  1129. # ENABLE(_FAKE_MODULE)
  1130. SET(MODULE_SUFFIX .pkg.fake)
  1131. }
  1132. ### @usage: _BASE_UNIT # internal
  1133. ###
  1134. ### The base of all LIBRARY/PROGRAM modules describing common logic for all modules.
  1135. ### To avoid surprises, all buildable modules are better to be inherited from it or its descendants.
  1136. module _BASE_UNIT: _BARE_UNIT {
  1137. .GLOBAL=_FBS_NAMESPACE_MAP
  1138. PEERDIR_TAGS=CPP_PROTO CPP_FBS H_IDL PY2 PY2_NATIVE YQL_UDF_STATIC __EMPTY__ DLL_LIB
  1139. 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_FLAGS $PROTOC_STYLEGUIDE_OUT $PROTOC_PLUGIN_STYLEGUIDE ${input;rootrel:File}
  1140. CPP_PROTO_OUTS+=${output;hide;norel;nopath;noext:File.pb.cc} ${output;main;hide;norel;nopath;noext:File.pb.h}
  1141. CPP_PROTO_OUTS_SEM+=${output;main;hide;norel;nopath;noext:File.pb.h}
  1142. CPP_EV_OUTS+=${output;hide;norel:File.pb.cc} ${output;hide;norel:File.pb.h}
  1143. CPP_EV_OUTS_SEM+=${output;hide;norel:File.pb.h}
  1144. when ($SWIG_LANG == "perl") {
  1145. _SWIG_CMD=$_SWIG_PERL_CMD
  1146. _SWIG_ADDINCLS=$_SWIG_PERL_ADDINCLS
  1147. _SWIG_PEERDIR=$_SWIG_PERL_PEERDIR
  1148. }
  1149. elsewhen ($SWIG_LANG == "python") {
  1150. _SWIG_CMD=$_SWIG_PYTHON_CMD
  1151. _SWIG_ADDINCLS=$_SWIG_PYTHON_ADDINCLS
  1152. _SWIG_PEERDIR=$_SWIG_PYTHON_PEERDIR
  1153. }
  1154. elsewhen ($SWIG_LANG == "jni_cpp") {
  1155. _SWIG_CMD=$_SWIG_JNI_CPP_CMD
  1156. _SWIG_ADDINCLS=$_SWIG_JNI_ADDINCLS
  1157. _SWIG_PEERDIR=$_SWIG_JNI_PEERDIR
  1158. }
  1159. elsewhen ($SWIG_LANG == "java") {
  1160. _SWIG_CMD=$_SWIG_JNI_CMD
  1161. _SWIG_ADDINCLS=$_SWIG_JNI_ADDINCLS
  1162. _SWIG_PEERDIR=$_SWIG_JNI_PEERDIR
  1163. }
  1164. when ($PY_PROTOS_FOR == "yes") {
  1165. MACRO_ALIAS(EVLOG_CMD _PY_EVLOG_CMD)
  1166. MACRO_ALIAS(PROTO_CMD _PY_PROTO_CMD)
  1167. }
  1168. otherwise {
  1169. MACRO_ALIAS(EVLOG_CMD _CPP_EVLOG_CMD)
  1170. MACRO_ALIAS(FBS_CMD _CPP_FLATC_CMD)
  1171. when ($BUILD_PROTO_AS_EVLOG == "yes") {
  1172. MACRO_ALIAS(PROTO_CMD _CPP_PROTO_EVLOG_CMD)
  1173. }
  1174. otherwise {
  1175. MACRO_ALIAS(PROTO_CMD _CPP_PROTO_CMD)
  1176. }
  1177. when ($USE_VANILLA_PROTOC == "yes") {
  1178. PROTOC=${tool:"contrib/tools/protoc_std"}
  1179. PROTOC_STYLEGUIDE_OUT=
  1180. PROTOC_PLUGIN_STYLEGUIDE=
  1181. PROTOBUF_PATH=${ARCADIA_ROOT}/contrib/libs/protobuf_std
  1182. MACRO_ALIAS(PROTO_CMD _CPP_VANILLA_PROTO_CMD)
  1183. }
  1184. when ($PROTOC_TRANSITIVE_HEADERS == "no") {
  1185. CPP_PROTO_PLUGINS=transitive_pb_h=false:${CPP_PROTO_PLUGINS}
  1186. }
  1187. }
  1188. SANITIZER_DEFINED=no
  1189. when ($SANITIZER_TYPE && $SANITIZER_TYPE != "no") {
  1190. CFLAGS+=-fsanitize=$SANITIZER_TYPE -D${SANITIZER_TYPE}_sanitizer_enabled $SANITIZER_CFLAGS -fno-omit-frame-pointer
  1191. LDFLAGS+=-fsanitize=$SANITIZER_TYPE
  1192. SANITIZER_DEFINED=yes
  1193. when ($CLANG) {
  1194. CFLAGS+=-fsanitize-blacklist=${input:"build/sanitize-blacklist.txt"} -fno-sanitize-link-runtime
  1195. LDFLAGS+=-fsanitize-blacklist=${input:"build/sanitize-blacklist.txt"} -fno-sanitize-link-runtime
  1196. }
  1197. }
  1198. when ($SANITIZE_COVERAGE && $SANITIZE_COVERAGE != "no") {
  1199. CFLAGS+=-fsanitize-coverage=$SANITIZE_COVERAGE
  1200. LDFLAGS+=-fsanitize-coverage=$SANITIZE_COVERAGE
  1201. }
  1202. POPULATE_CPP_COVERAGE_FLAGS()
  1203. when ($NLG_COVERAGE && $NLG_COVERAGE != "no") {
  1204. CFLAGS+=-DNLG_COVERAGE
  1205. }
  1206. when ($GCC) {
  1207. select ($SANITIZER_TYPE) {
  1208. "address" ? {
  1209. LDFLAGS+=-static-libasan
  1210. }
  1211. "undefined" ? {
  1212. LDFLAGS+=-static-libubsan
  1213. }
  1214. "thread" ? {
  1215. PIE=yes
  1216. LDFLAGS+=-static-libtsan
  1217. }
  1218. }
  1219. }
  1220. when ($HARDENING == "yes") {
  1221. when ($CLANG) {
  1222. CFLAGS+=-fstack-protector-all -D_hardening_enabled_
  1223. LDFLAGS+=-z relro -z now -z noexecstack
  1224. PIE=yes
  1225. }
  1226. }
  1227. when ($USE_LTO == "yes") {
  1228. when ($GCC) {
  1229. CFLAGS+=-flto -fno-fat-lto-objects
  1230. LDFLAGS+=-flto
  1231. NO_LTO_CFLAGS=-fno-lto
  1232. }
  1233. when ($CLANG) {
  1234. CFLAGS+=-flto
  1235. LDFLAGS+=-flto
  1236. NO_LTO_CFLAGS=-fno-lto
  1237. }
  1238. }
  1239. when ($USE_THINLTO == "yes") {
  1240. when ($GCC) {
  1241. CFLAGS+=-flto=thin
  1242. LDFLAGS+=-flto=thin
  1243. NO_LTO_CFLAGS=-fno-lto
  1244. }
  1245. when ($CLANG) {
  1246. CFLAGS+=-flto=thin
  1247. LDFLAGS+=-flto=thin
  1248. NO_LTO_CFLAGS=-fno-lto
  1249. }
  1250. }
  1251. when ($CLANG) {
  1252. when ($PGO_ADD == "yes") {
  1253. CFLAGS+=-fprofile-instr-generate
  1254. LDFLAGS+=-fprofile-instr-generate
  1255. }
  1256. when ($PGO_PATH) {
  1257. CFLAGS+=-fprofile-instr-use=$PGO_PATH -Wno-profile-instr-unprofiled -Wno-profile-instr-out-of-date
  1258. LDFLAGS+=-fprofile-instr-use=$PGO_PATH
  1259. }
  1260. }
  1261. when ($COMPILER_PLATFORM && $NEED_PLATFORM_PEERDIRS == "yes") {
  1262. PEERDIR+=$COMPILER_PLATFORM
  1263. }
  1264. when ($OS_LINUX && $NEED_PLATFORM_PEERDIRS == "yes") {
  1265. PEERDIR+=contrib/libs/linux-headers
  1266. }
  1267. # Adding PEERDIR from trigger doesn't always work. In this case it
  1268. # cause troubles in contrib/libs/libc_compat/ubuntu_14 under musl
  1269. # Workaround this issue by setting variable with PEERDIR in trigger
  1270. # and then adding PEERDIR to it's value unconditionally.
  1271. when ($USE_UBUNTU_COMPATIBILITY == "yes" && $NEED_PLATFORM_PEERDIRS == "yes") {
  1272. _UBUNTU_COMPAT_PEERDIR=contrib/libs/libc_compat/ubuntu_14
  1273. }
  1274. otherwise {
  1275. _UBUNTU_COMPAT_PEERDIR=
  1276. }
  1277. PEERDIR+=$_UBUNTU_COMPAT_PEERDIR
  1278. when ($NORUNTIME != "yes") {
  1279. PEERDIR+=contrib/libs/cxxsupp
  1280. when ($MAPSMOBI_BUILD_TARGET == "yes") {
  1281. PEERDIR+=build/platform/mapkit
  1282. }
  1283. }
  1284. when ($NOUTIL != "yes") {
  1285. PEERDIR+=util
  1286. }
  1287. when ($MUSL == "yes") {
  1288. CFLAGS += -D_musl_
  1289. LINK_DYN_LIB_FLAGS += --musl
  1290. LINK_SCRIPT_EXE_FLAGS += --musl
  1291. PEERDIR+=contrib/libs/musl/include
  1292. }
  1293. # g++ has proxy C-headers which are incompatible with libc++ proxy C-headers.
  1294. # The same problem exists for clang toolchain. On the other hand, the problem
  1295. # doesn't affect cl since it has united C/C++ library and doesn't need
  1296. # proxy C-headers.
  1297. # Disable all C++ headers including proxy C-headers when we use libc++.
  1298. when ($USE_INTERNAL_STL == "yes" && $MSVC != "yes") {
  1299. CXXFLAGS += -nostdinc++
  1300. }
  1301. otherwise {
  1302. CFLAGS += -DUSE_STL_SYSTEM
  1303. }
  1304. when ($CODENAVIGATION && $NOCODENAVIGATION != "yes") {
  1305. PEERDIR += build/external_resources/codenavigation
  1306. }
  1307. when ($CYTHON_COVERAGE && $CYTHON_COVERAGE == "yes") {
  1308. CFLAGS+=-DCYTHON_TRACE=1 -DCYTHON_TRACE_NOGIL=1
  1309. }
  1310. DEFAULT(USE_SSE4 yes)
  1311. when ($NOSSE != "yes") {
  1312. CFLAGS+=$SSE_CFLAGS
  1313. C_DEFINES+=$SSE_DEFINES
  1314. when ($USE_SSE4 == "yes") {
  1315. CFLAGS+=$SSE4_CFLAGS
  1316. C_DEFINES+=$SSE4_DEFINES
  1317. }
  1318. }
  1319. elsewhen ($MSVC != "yes") {
  1320. CFLAGS += -mno-sse
  1321. }
  1322. POPULATE_CPP_COVERAGE_FLAGS()
  1323. _REGISTER_NO_CHECK_IMPORTS()
  1324. DEFAULT(PACKAGE_PREFIX_ARGS)
  1325. DEFAULT(SWIG_LANG python)
  1326. DEFAULT(GP_FLAGS -CtTLANSI-C -Dk* -c)
  1327. when ($NEED_BINUTILS_PEERDIR && $BINUTILS_USED && $NEED_PLATFORM_PEERDIRS == "yes") {
  1328. PEERDIR+=build/platform/binutils
  1329. }
  1330. }
  1331. _LINKER_ID=
  1332. # GCC does not support -fuse-ld with an executable path,
  1333. # only -fuse-ld=gold or -fuse-ld=lld.
  1334. when ($_LINKER_ID != "" && $_DEFAULT_LINKER_ID != "" && $CLANG == "yes" && $NEED_PLATFORM_PEERDIRS == "yes") {
  1335. when ($_LINKER_ID in [ "gold", "lld" ]) {
  1336. PEERDIR+=build/platform/${_LINKER_ID}
  1337. }
  1338. }
  1339. macro _USE_LINKER_IMPL(LINKER_ID...) {
  1340. SET(_LINKER_ID $LINKER_ID)
  1341. }
  1342. macro _USE_LINKER() {
  1343. _USE_LINKER_IMPL($_DEFAULT_LINKER_ID)
  1344. }
  1345. ### @usage: USE_LINKER_GOLD()
  1346. ### Use gold linker for a program. This doesn't work in libraries
  1347. macro USE_LINKER_GOLD() {
  1348. _USE_LINKER_IMPL(gold)
  1349. }
  1350. COMMON_LINK_SETTINGS=
  1351. LINK_ADDITIONAL_SECTIONS=
  1352. LINK_ADDITIONAL_SECTIONS_COMMAND=
  1353. when ($COMMON_LINK_SETTINGS == "yes") {
  1354. when ($_LINKER_ID == "lld" && ($OS_LINUX == "yes" || $OS_ANDROID == "yes")) {
  1355. LDFLAGS += -Wl,--gdb-index
  1356. }
  1357. when ($EMBED_LINKER_CREF == "yes") {
  1358. LDFLAGS+=-Wl,--cref ${tmp;stdout;pre=$MODULE_PREFIX;suf=.ldcref:REALPRJNAME} -Wl,--no-demangle
  1359. LINK_ADDITIONAL_SECTIONS+=--add-section=.ya.linker_cref=${tmp;pre=$MODULE_PREFIX;suf=.ldcref:REALPRJNAME}
  1360. }
  1361. elsewhen ($DUMP_LINKER_CREF == "yes") {
  1362. LDFLAGS+=-Wl,--cref ${output;stdout;pre=$MODULE_PREFIX;suf=.ldcref:REALPRJNAME} -Wl,--no-demangle
  1363. }
  1364. when ($EMBED_LINKER_MAP == "yes") {
  1365. LDFLAGS+=-Wl,-Map=${tmp;pre=$MODULE_PREFIX;suf=.map.$_LINKER_ID:REALPRJNAME}
  1366. LINK_ADDITIONAL_SECTIONS+=--add-section=.ya.linker_map.${_LINKER_ID}=${tmp;pre=$MODULE_PREFIX;suf=.map.$_LINKER_ID:REALPRJNAME}
  1367. }
  1368. elsewhen ($DUMP_LINKER_MAP == "yes") {
  1369. LDFLAGS+=-Wl,-Map=${output;rootrel;pre=$MODULE_PREFIX;suf=.map.$_LINKER_ID:REALPRJNAME}
  1370. }
  1371. when ($USE_MKL == "yes") {
  1372. NOPLATFORM=yes
  1373. }
  1374. when (($USE_EAT_MY_DATA == "yes") && ($WIN32 != "yes") && ($DARWIN != "yes") && ($OS_ANDROID != "yes") && ($OS_IOS != "yes")) {
  1375. PEERDIR+=contrib/libs/libeatmydata/autocheck_wrapper
  1376. }
  1377. when ($USE_ARCADIA_LIBM == "yes") {
  1378. PEERDIR+=contrib/libs/libm
  1379. }
  1380. when ($USE_ARCADIA_LIBM == "no") {
  1381. C_SYSTEM_LIBRARIES+=-lm
  1382. }
  1383. when (($MUSL != "yes" && $WITH_VALGRIND == "yes") || $SANITIZER_DEFINED == "yes") {
  1384. when ($ALLOCATOR in [ "TCMALLOC", "TCMALLOC_SMALL_BUT_SLOW", "TCMALLOC_NUMA_256K", "TCMALLOC_NUMA_LARGE_PAGES", "TCMALLOC_256K", "TCMALLOC_TC", "GOOGLE", "J", "LF", "LF_YT", "LF_DBG", "B", "BM", "C", "LOCKLESS", "YT", "MIM", "HU", "PROFILED_HU" ]) {
  1385. PEERDIR+=library/cpp/malloc/system
  1386. }
  1387. }
  1388. otherwise {
  1389. select ($ALLOCATOR) {
  1390. "MIM" ? {
  1391. PEERDIR+=library/cpp/malloc/mimalloc
  1392. }
  1393. "HU" ? {
  1394. PEERDIR+=library/cpp/malloc/hu
  1395. }
  1396. "PROFILED_HU" ? {
  1397. PEERDIR+=library/cpp/malloc/profiled_hu
  1398. }
  1399. "TCMALLOC_256K" ? {
  1400. PEERDIR+=library/cpp/malloc/tcmalloc
  1401. PEERDIR+=contrib/libs/tcmalloc
  1402. }
  1403. "TCMALLOC_SMALL_BUT_SLOW" ? {
  1404. PEERDIR+=library/cpp/malloc/tcmalloc
  1405. PEERDIR+=contrib/libs/tcmalloc/small_but_slow
  1406. }
  1407. "TCMALLOC_NUMA_256K" ? {
  1408. PEERDIR+=library/cpp/malloc/tcmalloc
  1409. PEERDIR+=contrib/libs/tcmalloc/numa_256k
  1410. }
  1411. "TCMALLOC_NUMA_LARGE_PAGES" ? {
  1412. PEERDIR+=library/cpp/malloc/tcmalloc
  1413. PEERDIR+=contrib/libs/tcmalloc/numa_large_pages
  1414. }
  1415. "TCMALLOC" ? {
  1416. PEERDIR+=library/cpp/malloc/tcmalloc
  1417. PEERDIR+=contrib/libs/tcmalloc/default
  1418. }
  1419. "TCMALLOC_TC" ? {
  1420. PEERDIR+=library/cpp/malloc/tcmalloc
  1421. PEERDIR+=contrib/libs/tcmalloc/no_percpu_cache
  1422. }
  1423. "GOOGLE" ? {
  1424. PEERDIR+=library/cpp/malloc/galloc
  1425. }
  1426. "J" ? {
  1427. when ($WIN32 == "yes") {
  1428. PEERDIR+=library/cpp/malloc/system
  1429. }
  1430. otherwise {
  1431. PEERDIR+=library/cpp/malloc/jemalloc
  1432. }
  1433. }
  1434. "LF" ? {
  1435. PEERDIR+=library/cpp/lfalloc
  1436. }
  1437. "LF_YT" ? {
  1438. PEERDIR+=library/cpp/lfalloc/yt
  1439. }
  1440. "LF_DBG" ? {
  1441. PEERDIR+=library/cpp/lfalloc/dbg
  1442. }
  1443. "B" ? {
  1444. PEERDIR+=library/cpp/balloc
  1445. }
  1446. "BM" ? {
  1447. PEERDIR+=library/cpp/balloc_market
  1448. }
  1449. "C" ? {
  1450. PEERDIR+=library/cpp/malloc/calloc
  1451. }
  1452. "LOCKLESS" ? {
  1453. PEERDIR+=library/cpp/malloc/lockless
  1454. }
  1455. "YT" ? {
  1456. PEERDIR+=library/cpp/ytalloc/impl
  1457. }
  1458. }
  1459. }
  1460. when ($ALLOCATOR == "SYSTEM") {
  1461. PEERDIR+=library/cpp/malloc/system
  1462. }
  1463. when ($WERROR != "no") {
  1464. when ($WERROR_MODE == "all" || ($WERROR_MODE == "compiler_specific" && $WERROR == "yes")) {
  1465. C_WARNING_OPTS += $WERROR_FLAG
  1466. }
  1467. }
  1468. when ($ICC == "yes") {
  1469. PEERDIR+=contrib/libs/intel/core
  1470. }
  1471. when ($WITH_VALGRIND == "yes") {
  1472. PEERDIR+=contrib/libs/valgrind
  1473. # https://st.yandex-team.ru/DTCC-122
  1474. CFLAGS+=-fdebug-default-version=4
  1475. }
  1476. }
  1477. when ($EMBED_LINKER_MAP == "yes" || $EMBED_LINKER_CREF == "yes") {
  1478. LINK_ADDITIONAL_SECTIONS_COMMAND+= \
  1479. $OBJCOPY_TOOL $LINK_ADDITIONAL_SECTIONS $TARGET
  1480. }
  1481. _SO_EXT_FILTER=${ext=.so:PEERS} ${hide;late_out;nopath;ext=.so;pre=$BINDIR/:PEERS}
  1482. when ($OS_WINDOWS == "yes") {
  1483. _SO_EXT_FILTER=${ext=.dll:PEERS} ${hide;late_out;nopath;ext=.dll;pre=$BINDIR/:PEERS}
  1484. }
  1485. elsewhen ($OS_DARWIN == "yes" || $OS_IOS == "yes") {
  1486. _SO_EXT_FILTER=${ext=.dylib:PEERS} ${hide;late_out;nopath;ext=.dylib;pre=$BINDIR/:PEERS}
  1487. }
  1488. LINK_OR_COPY_SO_CMD=
  1489. RPATH_GLOBAL=
  1490. when ($SO_OUTPUTS == "yes") {
  1491. LINK_OR_COPY_SO_CMD=$FS_TOOLS link_or_copy_to_dir --no-check $_SO_EXT_FILTER ${BINDIR}
  1492. LDFLAGS+=$RPATH_GLOBAL
  1493. }
  1494. # tag:restricted tag:DLL
  1495. ### $usage: WITH_DYNAMIC_LIBS() # restricted
  1496. ###
  1497. ### Include dynamic libraries as extra PROGRAM/DLL outputs
  1498. macro WITH_DYNAMIC_LIBS() {
  1499. ENABLE(SO_OUTPUTS)
  1500. }
  1501. # tag:internal
  1502. ### $usage: REAL_LINK_EXE_IMPL(peers...) # internal
  1503. macro REAL_LINK_EXE_IMPL(WHOLE_ARCHIVE_PEERS...) {
  1504. .CMD=$REAL_LINK_EXE_CMDLINE && $LINK_OR_COPY_SO_CMD
  1505. }
  1506. # tag:internal
  1507. ### $usage: REAL_LINK_EXEC_DYN_LIB_IMPL(peers...) # internal
  1508. macro REAL_LINK_EXEC_DYN_LIB_IMPL(WHOLE_ARCHIVE_PEERS...) {
  1509. .CMD=$REAL_LINK_EXEC_DYN_LIB_CMDLINE
  1510. }
  1511. # tag:internal
  1512. ### $usage: REAL_LINK_DYN_LIB_IMPL(peers...) # internal
  1513. macro REAL_LINK_DYN_LIB_IMPL(WHOLE_ARCHIVE_PEERS...) {
  1514. .CMD=$REAL_LINK_DYN_LIB_CMDLINE && $LINK_OR_COPY_SO_CMD
  1515. }
  1516. # tag:internal
  1517. ### $usage: LINK_EXE_IMPL(peers...) # internal
  1518. macro LINK_EXE_IMPL(WHOLE_ARCHIVE_PEERS...) {
  1519. .CMD=$LINK_EXE_CMDLINE && $LINK_OR_COPY_SO_CMD
  1520. }
  1521. # tag:internal
  1522. ### $usage: LINK_EXEC_DYN_LIB_IMPL(peers...) # internal
  1523. macro LINK_EXEC_DYN_LIB_IMPL(WHOLE_ARCHIVE_PEERS...) {
  1524. .CMD=$LINK_EXEC_DYN_LIB_CMDLINE
  1525. }
  1526. # tag:internal
  1527. ### @usage: _LINK_UNIT # internal
  1528. ###
  1529. ### The base of all linkable modules: programs, DLLs etc. Describes common linking logic.
  1530. module _LINK_UNIT: _BASE_UNIT {
  1531. .EXTS=.o .obj .supp .tidyjson .ld
  1532. .CMD=LINK_EXE
  1533. .ALLOWED=EXTRALIBS OBJADDE_GLOBAL RESOURCE_FILES
  1534. .NODE_TYPE=Program
  1535. .PEERDIR_POLICY=as_build_from
  1536. .FINAL_TARGET=yes
  1537. .DEFAULT_NAME_GENERATOR=DirName
  1538. .ARGS_PARSER=Base
  1539. DEFAULT(ALLOCATOR $DEFAULT_ALLOCATOR)
  1540. _USE_LINKER()
  1541. #link with libunwind manually
  1542. when ($DARWIN == "yes" && $NOPLATFORM != "yes") {
  1543. PEERDIR += contrib/libs/cxxsupp
  1544. }
  1545. when ($USE_LIBCXXRT == "yes") {
  1546. PEERDIR += contrib/libs/cxxsupp/libcxxrt
  1547. }
  1548. when ($USE_DYNAMIC_CUDA == "yes") {
  1549. LINK_DYN_LIB_FLAGS += --dynamic-cuda
  1550. LINK_SCRIPT_EXE_FLAGS += --dynamic-cuda
  1551. }
  1552. ENABLE(COMMON_LINK_SETTINGS)
  1553. CHECK_PROVIDES()
  1554. }
  1555. MODULE_TYPE=UNKNOWN
  1556. macro ADD_CLANG_TIDY() {
  1557. ADD_YTEST($MODULE_PREFIX$REALPRJNAME clang_tidy)
  1558. when ($TIDY_ENABLED == "yes") {
  1559. _MAKEFILE_INCLUDE_LIKE_DEPS+=${ARCADIA_ROOT}/build/yandex_specific/config/clang_tidy/tidy_project_map.json
  1560. _MAKEFILE_INCLUDE_LIKE_DEPS+=${ARCADIA_ROOT}/build/yandex_specific/config/clang_tidy/tidy_default_map.json
  1561. }
  1562. }
  1563. # tag:internal
  1564. ### @usage: _BASE_PROGRAM # internal
  1565. ###
  1566. ### The base of all programs. It adds dependencies to make final artefact complete and runnable.
  1567. module _BASE_PROGRAM: _LINK_UNIT {
  1568. .SYMLINK_POLICY=EXE
  1569. .ALLOWED=INDUCED_DEPS WHOLE_ARCHIVE
  1570. .GLOBAL=LDFLAGS _WHOLE_ARCHIVE_LIBS_VALUE RPATH
  1571. SET(MODULE_TYPE PROGRAM)
  1572. SET(MODULE_LANG CPP)
  1573. FORCE_COVERAGE_ENABLED=yes
  1574. when ($OS_IOS == "yes") {
  1575. EXTS+=.ios.interface
  1576. }
  1577. when ($WIN32 == "yes" || $OS_CYGWIN == "yes") {
  1578. MODULE_SUFFIX=.exe
  1579. }
  1580. when ($TIDY_ENABLED == "yes") {
  1581. MODULE_SUFFIX=.tidyjson
  1582. }
  1583. when ($MSVC != "yes" && $NOPLATFORM != "yes" && $WITH_VALGRIND != "yes" && $USE_ASMLIB != "no" && $MIC_ARCH != "yes" && $PIC != "yes" && $PIE != "yes") {
  1584. when ($OS_LINUX == "yes" && $ARCH_X86_64 == "yes" && $MUSL != "yes" && $SANITIZER_DEFINED != "yes" && $USE_THINLTO != "yes") {
  1585. PEERDIR+=contrib/libs/glibcasm
  1586. }
  1587. otherwise {
  1588. PEERDIR+=contrib/libs/asmlib
  1589. }
  1590. }
  1591. when ($MUSL == "yes") {
  1592. when ($MUSL_LITE == "yes") {
  1593. PEERDIR += contrib/libs/musl
  1594. }
  1595. otherwise {
  1596. PEERDIR += contrib/libs/musl/full
  1597. }
  1598. }
  1599. DEFAULT(CPU_CHECK yes)
  1600. when ($USE_SSE4 != "yes" || $NOUTIL == "yes" || $ALLOCATOR == "FAKE") {
  1601. CPU_CHECK = no
  1602. }
  1603. when ($CPU_CHECK == "yes") {
  1604. PEERDIR += library/cpp/cpuid_check
  1605. }
  1606. when ($USE_ARC_PROFILE == "yes" && $NOUTIL != "yes") {
  1607. PEERDIR += library/cpp/execprofile/autostart
  1608. }
  1609. when ($SANITIZER_TYPE && $SANITIZER_TYPE != "no") {
  1610. PEERDIR += contrib/libs/cxxsupp/libsan
  1611. when ($CLANG) {
  1612. select ($TARGET_PLATFORM) {
  1613. "LINUX" ? {
  1614. PEERDIR += library/cpp/sanitizer/${SANITIZER_TYPE}/static
  1615. }
  1616. "DARWIN" ? {
  1617. # Memory sanitizer is not supported for darwin platform.
  1618. # https://clang.llvm.org/docs/MemorySanitizer.html#supported-platforms
  1619. when ($SANITIZER_TYPE != "memory") {
  1620. PEERDIR += library/cpp/sanitizer/${SANITIZER_TYPE}/dynamic
  1621. }
  1622. }
  1623. default ? {
  1624. FATAL_ERROR_MESSAGE+=Unsupported platform for sanitizer
  1625. }
  1626. }
  1627. }
  1628. when ($SANITIZE_HEADERS && $SANITIZE_HEADERS != "no") {
  1629. PEERDIR += library/cpp/sanitizer/include
  1630. }
  1631. }
  1632. when ($CLANG_COVERAGE && $CLANG_COVERAGE != "no") {
  1633. PEERDIR+=library/cpp/testing/dump_clang_coverage
  1634. }
  1635. when ($IDE_MSVS == "yes") {
  1636. PEERDIR+=build/scripts/c_templates
  1637. }
  1638. when ($_CUSTOM_LINK_STEP_SCRIPT) {
  1639. LINK_SCRIPT_EXE_FLAGS+=--python=$YMAKE_PYTHON --custom-step=${input:_CUSTOM_LINK_STEP_SCRIPT}
  1640. }
  1641. }
  1642. VCS_INFO_SEM=vcs_info ${input;hide:"build/scripts/vcs_info.py"} ${input;hide:"build/scripts/c_templates/svn_interface.c"} ${input;hide:"build/scripts/c_templates/svnversion.h"}
  1643. CPP_PROGRAM_SEM=add_executable $MODDIR $CMAKE_TARGET_NAME ${hide:TARGET} ${hide:AUTO_INPUT} $CMAKE_TARGET_ARTEFACT_RENAME_RULES \
  1644. && ${VCS_INFO_SEM} \
  1645. && target_link_options PRIVATE $LDFLAGS_GLOBAL_RAW $LDFLAGS $OBJADDE_LIB $OBJADDE \
  1646. && target_include_directories PRIVATE $_C__INCLUDE_OWNED \
  1647. && target_compile_options PRIVATE $USER_CFLAGS $USER_CXXFLAGS $_SEM_EXTRA_CXX_FLAGS \
  1648. && target_compile_options PRIVATE $USER_CFLAGS_GLOBAL_RAW $USER_CXXFLAGS_GLOBAL_RAW
  1649. ### @usage: PROGRAM([progname])
  1650. ###
  1651. ### Regular program module.
  1652. ### If name is not specified it will be generated from the name of the containing project directory.
  1653. module PROGRAM: _BASE_PROGRAM {
  1654. .SEM=CPP_PROGRAM_SEM
  1655. ADD_YTEST($MODULE_PREFIX$REALPRJNAME coverage.extractor)
  1656. ADD_CLANG_TIDY()
  1657. }
  1658. # tag:python-specific tag:deprecated tag:internal
  1659. module _PY2_PROGRAM: _BASE_PY_PROGRAM {
  1660. SET(MODULE_LANG PY2)
  1661. # Looks like we cannot avoid copy-paste util ymake supports multiple inheritance
  1662. # We need to attach coverage.extractor to every py_program target, except pytest targets
  1663. ADD_YTEST($MODULE_PREFIX$REALPRJNAME coverage.extractor)
  1664. }
  1665. # tag:python-specific tag:deprecated
  1666. ### @usage: PY2_PROGRAM([progname]) # deprecated
  1667. ###
  1668. ### Deprecated. Use PY3_PROGRAM instead.
  1669. ### Python 2.x binary program. Links all Python 2.x libraries and Python 2.x interpreter into itself to form regular executable.
  1670. ### If name is not specified it will be generated from the name of the containing project directory.
  1671. ### This only compatible with PYTHON2-tagged modules and selects those from multimodules.
  1672. ###
  1673. ### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/py_srcs/
  1674. module PY2_PROGRAM: _PY2_PROGRAM {
  1675. .RESTRICTED=STYLE_PYTHON
  1676. when ($FAIL_PY2 == "yes") {
  1677. _OK=no
  1678. }
  1679. elsewhen ($OPENSOURCE != "yes") {
  1680. PEERDIR+=build/rules/py2_deprecation
  1681. }
  1682. ASSERT(_OK You are using deprecated Python2-only code (PY2_PROGRAM). Please consider rewriting to Python 3.)
  1683. }
  1684. # tag:python-specific
  1685. ### @usage: NO_EXTENDED_SOURCE_SEARCH()
  1686. ###
  1687. ### Prevent module using in extended python source search.
  1688. ### Use the macro if module contains python2-only files (or other python sources which shouldn't be imported by python3 interpreter)
  1689. ### which resides in the same directories with python 3 useful code. contrib/python/future is a example.
  1690. ### Anyway, preferred way is to move such files into separate dir and don't use this macro at all.
  1691. ###
  1692. ### Also see: https://docs.yandex-team.ru/ya-make/manual/python/vars#y_python_extended_source_search for details
  1693. macro NO_EXTENDED_SOURCE_SEARCH() {
  1694. SET(NO_EXTENDED_SOURCE_SEARCH yes)
  1695. }
  1696. # tag:python-specific
  1697. ### @usage: PY3_PROGRAM([progname])
  1698. ###
  1699. ### Python 3.x binary program. Links all Python 3.x libraries and Python 3.x interpreter into itself to form regular executable.
  1700. ### If name is not specified it will be generated from the name of the containing project directory.
  1701. ### This only compatible with PYTHON3-tagged modules and selects those from multimodules.
  1702. ###
  1703. ### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/py_srcs/
  1704. multimodule PY3_PROGRAM {
  1705. module PY3_BIN: PY3_PROGRAM_BIN {
  1706. .PEERDIRSELF=PY3_BIN_LIB
  1707. .IGNORED=RESOURCE RESOURCE_FILES PEERDIR TASKLET_REG RUN_ANTLR4_PYTHON BUILDWITH_CYTHON_CPP _BUILDWITH_CYTHON_CPP_DEP _BUILDWITH_CYTHON_CPP_H BUILDWITH_CYTHON_C _BUILDWITH_CYTHON_C_DEP _BUILDWITH_CYTHON_C_H _BUILDWITH_CYTHON_C_API_H
  1708. # Notify pybuild to skip almost all PY_SRCS arguments except MAIN
  1709. ENABLE(PROCESS_PY_MAIN_ONLY)
  1710. _PY_PROGRAM()
  1711. }
  1712. module PY3_BIN_LIB: PY3_LIBRARY {
  1713. .IGNORED=RESTRICT_LICENSES
  1714. # Notify pybuild to skip all python main function definitions
  1715. ENABLE(IGNORE_PY_MAIN)
  1716. _REQUIRE_EXPLICIT_LICENSE()
  1717. }
  1718. }
  1719. ### @usage: EXPORTS_SCRIPT(exports_file)
  1720. ###
  1721. ### Specify exports script within PROGRAM, DLL and DLL-derived modules.
  1722. ### This accepts 2 kind of files: .exports with <lang symbol> pairs and JSON-line .symlist files.
  1723. ### The other option use EXPORTS parameter of the DLL module itself.
  1724. ###
  1725. ### @see: [DLL](#module_DLL)
  1726. macro EXPORTS_SCRIPT(Arg) {
  1727. SET(EXPORTS_FILE $Arg)
  1728. }
  1729. ### @usage: NO_EXPORT_DYNAMIC_SYMBOLS()
  1730. ###
  1731. ### Disable exporting all non-hidden symbols as dynamic when linking a PROGRAM.
  1732. macro NO_EXPORT_DYNAMIC_SYMBOLS() {
  1733. ENABLE(NO_EXPORT_DYNAMIC_SYMBOLS)
  1734. }
  1735. ### @usage: EXPORT_ALL_DYNAMIC_SYMBOLS()
  1736. ###
  1737. ### Export all non-hidden symbols as dynamic when linking a PROGRAM.
  1738. macro EXPORT_ALL_DYNAMIC_SYMBOLS() {
  1739. # Dummy: default behaviour
  1740. ENABLE(EXPORT_ALL_DYNAMIC_SYMBOLS)
  1741. }
  1742. ### @usage: USE_DYNAMIC_CUDA()
  1743. ###
  1744. ### Enable linking of PROGRAM with dynamic CUDA. By default CUDA uses static linking
  1745. macro USE_DYNAMIC_CUDA() {
  1746. LDFLAGS(-Wl,-rpath,$ORIGIN)
  1747. ENABLE(USE_DYNAMIC_CUDA)
  1748. }
  1749. ### @usage: CUSTOM_LINK_STEP_SCRIPT(name)
  1750. ###
  1751. ### Specifies name of a script for custom link step. The scripts
  1752. ### should be placed in the build/scripts directory and are subject to
  1753. ### review by devtools@.
  1754. macro CUSTOM_LINK_STEP_SCRIPT(Name) {
  1755. SET(_CUSTOM_LINK_STEP_SCRIPT build/scripts/$Name)
  1756. }
  1757. ### @usage: _BASE_UNITTEST # internal
  1758. ###
  1759. ### Module with base logic for all unit-test modules: it makes code runnable as unit-test by Arcadia testing machinery.
  1760. module _BASE_UNITTEST: _BASE_PROGRAM {
  1761. .FINAL_TARGET=no
  1762. .NODE_TYPE=Program
  1763. .ALLOWED=YT_SPEC
  1764. when ($UT_SKIP_EXCEPTIONS == "yes") {
  1765. C_DEFINES+=-DUT_SKIP_EXCEPTIONS
  1766. }
  1767. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS canondata/result.json)
  1768. }
  1769. _TEST_SPLIT_FACTOR_SEM=1
  1770. _TEST_TIMEOUT_SEM=
  1771. _TEST_PARTITION_SEM=
  1772. UNITTEST_SEM=$CPP_PROGRAM_SEM \
  1773. && set_property TARGET $REALPRJNAME PROPERTY SPLIT_FACTOR $_TEST_SPLIT_FACTOR_SEM \
  1774. $_TEST_PARTITION_SEM \
  1775. && add_yunittest NAME $REALPRJNAME TEST_TARGET $REALPRJNAME TEST_ARG --print-before-suite --print-before-test --fork-tests --print-times --show-fails \
  1776. && set_yunittest_property TEST $REALPRJNAME PROPERTY LABELS $TEST_SIZE_NAME $FILTER_ONLY_TEST_TAGS \
  1777. && add_ytest_requirements $REALPRJNAME $DEFAULT_REQUIREMENTS $TEST_REQUIREMENTS_VALUE \
  1778. $_TEST_TIMEOUT_SEM
  1779. # tag:test
  1780. ### @usage: UNITTEST([name])
  1781. ###
  1782. ### Unit test module based on library/cpp/testing/unittest.
  1783. ### It is recommended not to specify the name.
  1784. ###
  1785. ### Documentation: https://wiki.yandex-team.ru/yatool/test/#opisanievya.make1
  1786. module UNITTEST: _BASE_UNITTEST {
  1787. .SEM=UNITTEST_SEM
  1788. .DEFAULT_NAME_GENERATOR=FullPath
  1789. .ARGS_PARSER=Base
  1790. PEERDIR(library/cpp/testing/unittest_main)
  1791. ADD_YTEST($MODULE_PREFIX$REALPRJNAME unittest.py)
  1792. when ($TEST_FORK_MODE != "none") {
  1793. when ($TEST_SPLIT_FACTOR) {
  1794. _TEST_SPLIT_FACTOR_SEM=$TEST_SPLIT_FACTOR
  1795. }
  1796. otherwise {
  1797. _TEST_SPLIT_FACTOR_SEM=10
  1798. }
  1799. when ($TEST_PARTITION == "MODULO") {
  1800. _TEST_PARTITION_SEM=&& set_property TARGET $REALPRJNAME PROPERTY SPLIT_TYPE $TEST_PARTITION \
  1801. }
  1802. }
  1803. when ($TEST_TIMEOUT) {
  1804. _TEST_TIMEOUT_SEM=&& set_yunittest_property TEST $REALPRJNAME PROPERTY TIMEOUT $TEST_TIMEOUT
  1805. }
  1806. }
  1807. # tag:yt-specific tag:test
  1808. ### @usage: YT_UNITTEST([name])
  1809. ###
  1810. ### YT Unit test module based on library/cpp/testing/unittest with NYT::Initialize hook
  1811. module YT_UNITTEST: _BASE_UNITTEST {
  1812. PEERDIR(library/cpp/testing/unittest_main mapreduce/yt/tests/yt_initialize_hook)
  1813. ADD_YTEST($MODULE_PREFIX$REALPRJNAME unittest.py)
  1814. }
  1815. # tag:test
  1816. ### @usage: UNITTEST_WITH_CUSTOM_ENTRY_POINT([name])
  1817. ###
  1818. ### Generic unit test module.
  1819. module UNITTEST_WITH_CUSTOM_ENTRY_POINT: _BASE_UNITTEST {
  1820. ADD_YTEST($MODULE_PREFIX$REALPRJNAME unittest.py)
  1821. }
  1822. GTEST_SEM=$CPP_PROGRAM_SEM \
  1823. && add_test NAME $REALPRJNAME COMMAND $REALPRJNAME \
  1824. && set_property TEST $REALPRJNAME PROPERTY LABELS $TEST_SIZE_NAME $FILTER_ONLY_TEST_TAGS \
  1825. && add_test_requirements $REALPRJNAME $DEFAULT_REQUIREMENTS $TEST_REQUIREMENTS_VALUE \
  1826. $_TEST_TIMEOUT_SEM
  1827. # tag:cpp-specific tag:test
  1828. ### @usage: GTEST([name])
  1829. ###
  1830. ### Unit test module based on library/cpp/testing/gtest.
  1831. ### It is recommended not to specify the name.
  1832. ###
  1833. ### Documentation: https://docs.yandex-team.ru/arcadia-cpp/cpp_test
  1834. module GTEST: _BASE_UNITTEST {
  1835. .SEM=GTEST_SEM
  1836. .DEFAULT_NAME_GENERATOR=FullPath
  1837. .ARGS_PARSER=Base
  1838. PEERDIR(library/cpp/testing/gtest library/cpp/testing/gtest_main)
  1839. ADD_YTEST($MODULE_PREFIX$REALPRJNAME gunittest)
  1840. when ($TEST_TIMEOUT) {
  1841. _TEST_TIMEOUT_SEM=&& set_property TEST $REALPRJNAME PROPERTY TIMEOUT $TEST_TIMEOUT
  1842. }
  1843. }
  1844. USE_AFL=no
  1845. # tag:fuzzing
  1846. ### @usage: FUZZ()
  1847. ###
  1848. ### In order to start using Fuzzing in Arcadia, you need to create a FUZZ module with the implementation of the function LLVMFuzzerTestOneInput().
  1849. ### This module should be reachable by RECURSE from /autocheck project in order for the corpus to be regularly updated.
  1850. ### AFL and Libfuzzer are supported in Arcadia via a single interface, but the automatic fuzzing still works only through Libfuzzer.
  1851. ###
  1852. ### Example: https://a.yandex-team.ru/arc/trunk/arcadia/contrib/libs/re2/re2/fuzzing/re2_fuzzer.cc?rev=2919463#L58
  1853. ###
  1854. ### Documentation: https://wiki.yandex-team.ru/yatool/fuzzing/
  1855. module FUZZ: _BASE_PROGRAM {
  1856. .NODE_TYPE=Program
  1857. .FINAL_TARGET=no
  1858. .ALLOWED=FUZZ_DICTS FUZZ_OPTS
  1859. SET(LIBFUZZER_PATH contrib/libs/libfuzzer)
  1860. when ($USE_AFL == "no") {
  1861. PEERDIR+=$LIBFUZZER_PATH
  1862. }
  1863. when ($USE_AFL == "yes") {
  1864. PEERDIR+=$LIBFUZZER_PATH/afl
  1865. }
  1866. when (!$SANITIZER_TYPE || $SANITIZER_TYPE == "no") {
  1867. PEERDIR+=devtools/nofuzz
  1868. }
  1869. ADD_YTEST($MODULE_PREFIX$REALPRJNAME fuzz.test)
  1870. }
  1871. # tag:ios-specific
  1872. PACK_IOS_CMD=
  1873. when ($OS_IOS && $BUILD_IOS_APP) {
  1874. PACK_IOS_CMD=$YMAKE_PYTHON ${input:"build/scripts/pack_ios.py"} --binary $TARGET --target $TARGET --temp-dir $BINDIR $PEERS
  1875. }
  1876. LINK_BOOSTTEST_CMD=
  1877. BOOST_TEST_TYPE_STRING=
  1878. when ($BOOSTTEST_IS_FAT_OBJECT) {
  1879. LINK_BOOSTTEST_CMD=$LINK_RECURSIVE_LIBRARY
  1880. BOOST_TEST_TYPE_STRING=no.test
  1881. }
  1882. otherwise {
  1883. LINK_BOOSTTEST_CMD=$LINK_EXE
  1884. BOOST_TEST_TYPE_STRING=boost.test
  1885. }
  1886. # tag:deprecated
  1887. ### @usage: BOOSTTEST([name]) #deprecated
  1888. ###
  1889. ### Test module based on boost/test/unit_test.hpp.
  1890. ### As with entire boost library usage of this technology is deprecated in Arcadia and restricted with configuration error in most of projects.
  1891. ### No new module of this type should be introduced unless it is explicitly approved by C++ committee.
  1892. module BOOSTTEST: _BASE_PROGRAM {
  1893. .NODE_TYPE=Program
  1894. .FINAL_TARGET=no
  1895. .CMD=LINK_BOOSTTEST_CMD
  1896. PEERDIR(library/cpp/testing/boost_test)
  1897. when ($BOOSTTEST_IS_FAT_OBJECT) {
  1898. MODULE_SUFFIX=.a
  1899. }
  1900. elsewhen ($OS_IOS && $BUILD_IOS_APP) {
  1901. PEERDIR+=devtools/boosttest_ios_wrapper/library
  1902. MODULE_SUFFIX=.ios.tar
  1903. }
  1904. ADD_YTEST($MODULE_PREFIX$REALPRJNAME $BOOST_TEST_TYPE_STRING)
  1905. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS canondata/result.json)
  1906. }
  1907. # tag:deprecated
  1908. ### @usage BOOSTTEST_WITH_MAIN([name]) #deprecated
  1909. ###
  1910. ### Same as BOOSTTEST (see above), but comes with builtin int main(argc, argv) implementation
  1911. module BOOSTTEST_WITH_MAIN: BOOSTTEST {
  1912. PEERDIR(library/cpp/testing/boost_test_main)
  1913. }
  1914. FUZZ_DICTS_VALUE=
  1915. ### @usage: FUZZ_DICTS(path1 [path2...])
  1916. ###
  1917. ### Allows you to specify dictionaries, relative to the root of Arcadia, which will be used in Fuzzing.
  1918. ### Libfuzzer and AFL use a single syntax for dictionary descriptions.
  1919. ### Should only be used in FUZZ modules.
  1920. ###
  1921. ### Documentation: https://wiki.yandex-team.ru/yatool/fuzzing/
  1922. macro FUZZ_DICTS(Data...) {
  1923. SET_APPEND(FUZZ_DICTS_VALUE $Data)
  1924. }
  1925. FUZZ_OPTS_VALUE=
  1926. ### @usage: FUZZ_OPTS(opt1 [Opt2...])
  1927. ###
  1928. ### Overrides or adds options to the corpus mining and fuzzer run.
  1929. ### Currently supported only Libfuzzer, so you should use the options for it.
  1930. ### Should only be used in FUZZ modules.
  1931. ###
  1932. ### @example:
  1933. ###
  1934. ### FUZZ_OPTS (
  1935. ### -max_len=1024
  1936. ### -rss_limit_mb=8192
  1937. ### )
  1938. ###
  1939. ### Documentation: https://wiki.yandex-team.ru/yatool/fuzzing/
  1940. macro FUZZ_OPTS(Data...) {
  1941. SET_APPEND(FUZZ_OPTS_VALUE $Data)
  1942. }
  1943. # tag:yt-specific tag:test
  1944. TEST_YT_SPEC_VALUE=
  1945. ### @usage: YT_SPEC(path1 [path2...])
  1946. ###
  1947. ### Allows you to specify json-files with YT task and operation specs,
  1948. ### which will be used to run test node in the YT.
  1949. ### Test must be marked with ya:yt tag.
  1950. ### Files must be relative to the root of Arcadia.
  1951. ###
  1952. ### Documentation: https://wiki.yandex-team.ru/yatool/test/
  1953. macro YT_SPEC(Data...) {
  1954. SET_APPEND(TEST_YT_SPEC_VALUE $Data)
  1955. }
  1956. # tag:test
  1957. TEST_SRCS_VALUE=
  1958. ### @usage: TEST_SRCS(Files...)
  1959. ###
  1960. ### 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.
  1961. ###
  1962. ### Documentation: https://wiki.yandex-team.ru/yatool/test/#testynapytest
  1963. macro TEST_SRCS(Tests...) {
  1964. SET_APPEND(TEST_SRCS_VALUE $Tests)
  1965. }
  1966. macro DISABLE_DATA_VALIDATION() {
  1967. DISABLE(VALIDATE_DATA)
  1968. }
  1969. # tag:test
  1970. TEST_DATA_VALUE=
  1971. ### @usage: DATA([path...])
  1972. ###
  1973. ### Specifies the path to the data necessary test.
  1974. ### Valid values are: arcadia/<path> , arcadia_tests_data/<path> and sbr://<resource_id>.
  1975. ### In the latter case resource will be brought to the working directory of the test before it is started
  1976. ###
  1977. ### Used only inside TEST modules.
  1978. ###
  1979. ### Documentation: https://wiki.yandex-team.ru/yatool/test/#dannyeizrepozitorija
  1980. macro DATA(Data...) {
  1981. SET_APPEND(TEST_DATA_VALUE $Data)
  1982. ADD_CHECK(check.data $Data)
  1983. }
  1984. # tag:test
  1985. ### @usage: DATA_FILES([path...])
  1986. ###
  1987. ### Specifies the path to the arcadia source data necessary test.
  1988. ### Used only inside TEST modules.
  1989. ###
  1990. ### Documentation: https://wiki.yandex-team.ru/yatool/test/#dannyeizrepozitorija
  1991. macro DATA_FILES(Paths...) {
  1992. SET_APPEND(TEST_DATA_VALUE ${pre=arcadia/:Paths})
  1993. _DATA_FILES($Paths)
  1994. }
  1995. # tag:test
  1996. ### @usage: EXPLICIT_DATA()
  1997. ###
  1998. ### Disables implicit macro DATA(<module_path>).
  1999. ADD_SRCDIR_TO_TEST_DATA=yes
  2000. macro EXPLICIT_DATA() {
  2001. SET(ADD_SRCDIR_TO_TEST_DATA no)
  2002. }
  2003. # tag:test
  2004. TEST_TAGS_VALUE=
  2005. ### @usage: TAG ([tag...])
  2006. ###
  2007. ### Each test can have one or more tags used to filter tests list for running.
  2008. ### There are also special tags affecting test behaviour, for example ya:external, sb:ssd.
  2009. ###
  2010. ### Documentation: https://wiki.yandex-team.ru/yatool/test/#obshhieponjatija
  2011. macro TAG(Tags...) {
  2012. SET_APPEND(TEST_TAGS_VALUE $Tags)
  2013. }
  2014. # tag:test
  2015. TEST_REQUIREMENTS_VALUE=
  2016. ### @usage: REQUIREMENTS([cpu:<count>] [disk_usage:<size>] [ram:<size>] [ram_disk:<size>] [container:<id>] [network:<restricted|full>] [dns:dns64])
  2017. ###
  2018. ### Allows you to specify the requirements of the test.
  2019. ###
  2020. ### Documentation about the Arcadia test system: https://wiki.yandex-team.ru/yatool/test/
  2021. macro REQUIREMENTS(Tags...) {
  2022. SET_APPEND(TEST_REQUIREMENTS_VALUE $Tags)
  2023. }
  2024. # tag:test
  2025. TEST_ENV_VALUE=
  2026. ### @usage: ENV(key[=value])
  2027. ###
  2028. ### Sets env variable key to value (gets value from system env by default).
  2029. macro ENV(Data...) {
  2030. SET_APPEND(TEST_ENV_VALUE ${quo:Data})
  2031. }
  2032. ### @usage: CONFTEST_LOAD_POLICY_LOCAL()
  2033. ###
  2034. ### Loads conftest.py files in a way that pytest does it
  2035. macro CONFTEST_LOAD_POLICY_LOCAL() {
  2036. SET_APPEND(TEST_ENV_VALUE "CONFTEST_LOAD_POLICY=LOCAL")
  2037. }
  2038. # tag:test
  2039. TEST_RECIPES_VALUE=
  2040. ### @usage: USE_RECIPE(path [arg1 arg2...])
  2041. ###
  2042. ### Provides prepared environment via recipe for test.
  2043. ###
  2044. ### Documentation: https://wiki.yandex-team.ru/yatool/test/recipes
  2045. macro USE_RECIPE(Data...) {
  2046. SET_APPEND(TEST_RECIPES_VALUE $Data)
  2047. SET_APPEND(TEST_RECIPES_VALUE "USE_RECIPE_DELIM")
  2048. }
  2049. # tag:python-specific tag:test
  2050. TEST_PYTHON_PATH_VALUE=
  2051. # tag:python-specific tag:test
  2052. ### @usage: PYTHON_PATH(Path)
  2053. ###
  2054. ### Set path to Python that will be used to runs scripts in tests
  2055. macro PYTHON_PATH(Path) {
  2056. SET(TEST_PYTHON_PATH_VALUE $Path)
  2057. }
  2058. # tag:test
  2059. SKIP_TEST_VALUE=
  2060. ### @usage: SKIP_TEST(Reason)
  2061. ###
  2062. ### Skip the suite defined by test module. Provide a reason to be output in test execution report.
  2063. macro SKIP_TEST(Reason...) {
  2064. SET(SKIP_TEST_VALUE $Reason)
  2065. }
  2066. # tag:test
  2067. LINT_LEVEL_VALUE=extended
  2068. _NO_LINT_VALUE=
  2069. ### @usage: NO_LINT([ktlint])
  2070. ###
  2071. ### Do not check for style files included in PY_SRCS, TEST_SRCS, JAVA_SRCS.
  2072. ### Ktlint can be disabled using NO_LINT(ktlint) explicitly.
  2073. macro NO_LINT(ktlint?"ktlint":"none") {
  2074. SET(_NO_LINT_VALUE ${ktlint})
  2075. }
  2076. ### @usage: LINT(<none|base|strict>)
  2077. ###
  2078. ### Set linting level for sources of the module
  2079. macro LINT(level) {
  2080. SET(LINT_LEVEL_VALUE $level)
  2081. }
  2082. # tag:python-specific tag:test
  2083. STYLE_PYTHON_VALUE=no
  2084. STYLE_PYTHON_PYPROJECT_VALUE=
  2085. ### @usage: STYLE_PYTHON([pyproject])
  2086. ###
  2087. ### Check python3 sources for style issues using black.
  2088. macro STYLE_PYTHON(pyproject...) {
  2089. SET(STYLE_PYTHON_VALUE yes)
  2090. SET(STYLE_PYTHON_PYPROJECT_VALUE ${pyproject})
  2091. }
  2092. # tag:python-specific tag:test
  2093. ### @usage: NO_DOCTESTS()
  2094. ###
  2095. ### Disable doctests in PY[|3|23_]TEST
  2096. macro NO_DOCTESTS() {
  2097. ENV(YA_PYTEST_DISABLE_DOCTEST="yes")
  2098. }
  2099. # tag:python-specific tag:test
  2100. ### @usage: _BASE_PYTEST # internal
  2101. ###
  2102. ### Base logic of Python 2.x py.test modules: common module properties and dependencies.
  2103. module _BASE_PYTEST: _BASE_PY_PROGRAM {
  2104. .NODE_TYPE=Program
  2105. .FINAL_TARGET=no
  2106. .ALLOWED=YT_SPEC NO_DOCTESTS
  2107. when ($USE_ARCADIA_PYTHON == "yes") {
  2108. PEERDIR+=library/python/pytest
  2109. }
  2110. when ($USE_ARCADIA_PYTHON == "no") {
  2111. MODULE_SUFFIX=.pkg.fake
  2112. PEERDIR+=library/python/pytest/empty
  2113. }
  2114. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS canondata/result.json)
  2115. }
  2116. # tag:python-specific tag:deprecated tag:test
  2117. ### @usage: PYTEST_BIN() #deprecated
  2118. ###
  2119. ### Same as PY2TEST. Don't use this, use PY2TEST instead.
  2120. module PYTEST_BIN: _BASE_PYTEST {
  2121. .NODE_TYPE=Program
  2122. .DEFAULT_NAME_GENERATOR=FullPath
  2123. .ARGS_PARSER=Base
  2124. SETUP_PYTEST_BIN()
  2125. }
  2126. # tag:python-specific tag:test
  2127. ### @usage: PY2TEST([name])
  2128. ###
  2129. ### The test module for Python 2.x based on py.test
  2130. ###
  2131. ### This module is compatible only with PYTHON2-tagged modules and selects peers from multimodules accordingly.
  2132. ### This module is compatible with non-Arcadia Python builds.
  2133. ###
  2134. ### Documentation: https://wiki.yandex-team.ru/yatool/test/#python
  2135. ### Documentation about the Arcadia test system: https://wiki.yandex-team.ru/yatool/test/
  2136. module PY2TEST: PYTEST_BIN {
  2137. .RESTRICTED=STYLE_PYTHON
  2138. .DEFAULT_NAME_GENERATOR=FullPath
  2139. .ARGS_PARSER=Base
  2140. when ($FAIL_PY2 == "yes") {
  2141. _OK=no
  2142. }
  2143. elsewhen ($OPENSOURCE != "yes") {
  2144. PEERDIR+=build/rules/py2_deprecation
  2145. }
  2146. SET(MODULE_LANG PY2)
  2147. ASSERT(_OK You are using deprecated Python2-only code (PY2TEST). Please consider rewriting to Python 3.)
  2148. }
  2149. # tag:python-specific tag:deprecated tag:test
  2150. ### @usage: PY3TEST_BIN() #deprecated
  2151. ###
  2152. ### Same as PY3TEST. Don't use this, use PY3TEST instead.
  2153. module PY3TEST_BIN: _BASE_PY3_PROGRAM {
  2154. .NODE_TYPE=Program
  2155. .FINAL_TARGET=no
  2156. .ALLOWED=YT_SPEC NO_DOCTESTS
  2157. .DEFAULT_NAME_GENERATOR=FullPath
  2158. .ARGS_PARSER=Base
  2159. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS canondata/result.json)
  2160. SET(MODULE_LANG PY3)
  2161. SETUP_PYTEST_BIN()
  2162. PEERDIR+=library/python/pytest
  2163. }
  2164. # tag:python-specific tag:test
  2165. ### Disable submodules with the specified name(s).
  2166. ### Unlike EXCLUDE_TAGS this variable:
  2167. ### - affects all projects in the build;
  2168. ### - filter by module name and ignore MODULE_TAG.
  2169. EXCLUDE_SUBMODULES=PY3TEST_LIBRARY
  2170. # tag:python-specific tag:test
  2171. ### @usage: PY3TEST([name])
  2172. ###
  2173. ### The test module for Python 3.x based on py.test
  2174. ###
  2175. ### This module is compatible only with PYTHON3-tagged modules and selects peers from multimodules accordingly.
  2176. ### This module is only compatible with Arcadia Python build (to avoid tests duplication from Python2/3-tests). For non-Arcadia python use PYTEST.
  2177. ###
  2178. ### Documentation: https://wiki.yandex-team.ru/yatool/test/#testynapytest
  2179. ### Documentation about the Arcadia test system: https://wiki.yandex-team.ru/yatool/test/
  2180. multimodule PY3TEST {
  2181. module PY3TEST_PROGRAM: PY3TEST_BIN {
  2182. .IGNORED=RUN_ANTLR4_PYTHON
  2183. .FINAL_TARGET=yes
  2184. }
  2185. module PY3TEST_LIBRARY: PY3_LIBRARY {
  2186. PEERDIR+=library/python/pytest
  2187. _REQUIRE_EXPLICIT_LICENSE()
  2188. }
  2189. }
  2190. # tag:cpp-specific tag:test
  2191. module CPP_STYLE_TEST_14: PY3TEST_BIN {
  2192. DEPENDS(contrib/libs/clang14/tools/clang-format)
  2193. PEERDIR+=library/python/cpp_test
  2194. }
  2195. macro STYLE(Globs...) {
  2196. _GLOB(STYLE_SRCS_GLOB ${pre=${ARCADIA_ROOT}:Globs})
  2197. _STYLE(${STYLE_SRCS_GLOB})
  2198. }
  2199. # tag:cpp-specific tag:deprecated tag:test
  2200. ### @usage: GTEST_UGLY([name])
  2201. ###
  2202. ### Deprecated, do not use in new projects. Use GTEST instead.
  2203. ###
  2204. ### The test module based on gtest (contrib/libs/gtest contrib/libs/gmock).
  2205. ### Use public documentation on gtest for details.
  2206. ###
  2207. ### Documentation about the Arcadia test system: https://wiki.yandex-team.ru/yatool/test/
  2208. module GTEST_UGLY: _BASE_PROGRAM {
  2209. .NODE_TYPE=Program
  2210. .FINAL_TARGET=no
  2211. PEERDIR(contrib/restricted/googletest/googlemock contrib/restricted/googletest/googletest)
  2212. ADD_YTEST($MODULE_PREFIX$REALPRJNAME gtest)
  2213. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS canondata/result.json)
  2214. }
  2215. # tag:test
  2216. ### @usage: EXECTEST()
  2217. ###
  2218. ### Module definition of generic test that executes a binary.
  2219. ### Use macro RUN to specify binary to run.
  2220. ###
  2221. ### @example:
  2222. ###
  2223. ### EXECTEST()
  2224. ### OWNER(g:yatool)
  2225. ###
  2226. ### RUN(
  2227. ### cat input.txt
  2228. ### )
  2229. ### DATA(
  2230. ### arcadia/devtools/ya/test/tests/exectest/data
  2231. ### )
  2232. ### DEPENDS(
  2233. ### devtools/dummy_arcadia/cat
  2234. ### )
  2235. ### TEST_CWD(devtools/ya/test/tests/exectest/data)
  2236. ### END()
  2237. ###
  2238. ### More examples: https://wiki.yandex-team.ru/yatool/test/#exec-testy
  2239. ###
  2240. ### @see: [RUN()](#macro_RUN)
  2241. module EXECTEST: _BARE_UNIT {
  2242. .NODE_TYPE=Program
  2243. .FINAL_TARGET=no
  2244. .ALLOWED=YT_SPEC
  2245. .RESTRICTED=FORK_TEST_FILES
  2246. .DEFAULT_NAME_GENERATOR=FullPath
  2247. .ARGS_PARSER=Base
  2248. SET(MODULE_SUFFIX .pkg.fake)
  2249. SETUP_EXECTEST()
  2250. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS canondata/result.json)
  2251. }
  2252. # tag:cpp-specific tag:test
  2253. ### @usage: Y_BENCHMARK([benchmarkname])
  2254. ###
  2255. ### Benchmark test based on the library/cpp/testing/benchmark.
  2256. ###
  2257. ### For more details see: https://wiki.yandex-team.ru/yatool/test/#zapuskbenchmark
  2258. module Y_BENCHMARK: PROGRAM {
  2259. .SEM=CPP_PROGRAM_SEM
  2260. PEERDIR(library/cpp/testing/benchmark/main)
  2261. }
  2262. GBENCH_SEM=$CPP_PROGRAM_SEM \
  2263. && add_test NAME $REALPRJNAME COMMAND $REALPRJNAME \
  2264. && set_property TEST $REALPRJNAME PROPERTY LABELS SMALL $FILTER_ONLY_TEST_TAGS \
  2265. && add_test_requirements $REALPRJNAME $DEFAULT_REQUIREMENTS $TEST_REQUIREMENTS_VALUE \
  2266. $_TEST_TIMEOUT_SEM
  2267. # tag:cpp-specific tag:test
  2268. ### @usage: G_BENCHMARK([benchmarkname])
  2269. ###
  2270. ### Benchmark test based on the google benchmark.
  2271. ###
  2272. ### For more details see: https://a.yandex-team.ru/arc/trunk/arcadia/contrib/libs/benchmark/README.md
  2273. module G_BENCHMARK: _BASE_PROGRAM {
  2274. .SEM=GBENCH_SEM
  2275. PEERDIR(library/cpp/testing/gbenchmark)
  2276. ADD_YTEST($MODULE_PREFIX$REALPRJNAME g_benchmark)
  2277. }
  2278. # tag:test
  2279. TEST_ROOT=$(TESTS_DATA_ROOT)
  2280. RESULT_MAX_FILE=0
  2281. STRIP_FILES=--dont-strip-files
  2282. VERIFY_RESULTS=--verify-results
  2283. ADDITIONAL_PATH=
  2284. # set for tests variables to fill it by YA_DEV or YA
  2285. YA_ROOT=ya
  2286. when ($YA_DEV == "yes") {
  2287. YA_ROOT=ya-dev
  2288. }
  2289. # tag:test
  2290. ### @usage: UNITTEST_FOR(path/to/lib)
  2291. ###
  2292. ### Convenience extension of UNITTEST module.
  2293. ### The UNINTTEST module with additional SRCDIR + ADDINCL + PEERDIR on path/to/lib.
  2294. ### path/to/lib is the path to the directory with the LIBRARY project.
  2295. ###
  2296. ### Documentation about the Arcadia test system: https://wiki.yandex-team.ru/yatool/test/
  2297. module UNITTEST_FOR: UNITTEST {
  2298. .SEM=UNITTEST_SEM
  2299. PEERDIR(ADDINCL $UNITTEST_DIR)
  2300. SRCDIR($UNITTEST_DIR)
  2301. }
  2302. ### @usage: _LIBRARY # internal
  2303. ###
  2304. ### Base module definition for all libraries.
  2305. ### Contains basic logic like module properties, default variable values etc.
  2306. ### All libraries similar to C++-libraries should be inherited from it.
  2307. module _LIBRARY: _BASE_UNIT {
  2308. .CMD=LINK_LIB
  2309. .NODE_TYPE=Library
  2310. .PEERDIR_POLICY=as_include
  2311. .EXTS=.o .obj .a .mf .supp .tidyjson .ld .lib
  2312. .ALLOWED=GRPC USE_SKIFF EXTRALIBS OBJADDE_GLOBAL RESOURCE_FILES
  2313. .GLOBAL=USER_CFLAGS USER_CXXFLAGS USER_CONLYFLAGS LDFLAGS SRCS _WHOLE_ARCHIVE_LIBS_VALUE RPATH
  2314. .RESTRICTED=ALLOCATOR SIZE TAG DATA TEST_DATA DEPENDS FORK_TESTS FORK_SUBTESTS SPLIT_FACTOR TEST_CWD RUN TIMEOUT SPLIT_DWARF
  2315. .FINAL_TARGET=no
  2316. .GLOBAL_CMD=GLOBAL_LINK_LIB
  2317. .GLOBAL_EXTS=.o .obj .tidyjson
  2318. GLOBAL_SUFFIX=.global$MODULE_SUFFIX
  2319. #TODO: Remove this hack (really we do not need add fake src at all)
  2320. ENABLE(NEED_ADD_FAKE_SRC)
  2321. _REQUIRE_EXPLICIT_LICENSE(contrib/deprecated contrib/libs contrib/restricted contrib/python)
  2322. CHECK_CONTRIB_CREDITS(contrib/clickhouse contrib/libs contrib/deprecated EXCEPT contrib/deprecated/python)
  2323. when ($USE_MKL == "yes") {
  2324. NOPLATFORM=yes
  2325. }
  2326. when ($MSVC == "yes" || $CYGWIN == "yes") {
  2327. MODULE_PREFIX=
  2328. MODULE_SUFFIX=.lib
  2329. }
  2330. otherwise {
  2331. when ($TIDY_ENABLED == "yes") {
  2332. MODULE_PREFIX=
  2333. MODULE_SUFFIX=.tidyjson
  2334. }
  2335. otherwise {
  2336. MODULE_PREFIX=lib
  2337. MODULE_SUFFIX=.a
  2338. }
  2339. }
  2340. when ($WERROR != "no") {
  2341. when ($WERROR_MODE == "all" || ($WERROR_MODE == "compiler_specific" && $WERROR == "yes")) {
  2342. C_WARNING_OPTS += $WERROR_FLAG
  2343. }
  2344. }
  2345. when ($WITH_VALGRIND == "yes") {
  2346. PEERDIR+=contrib/libs/valgrind
  2347. # https://st.yandex-team.ru/DTCC-1227
  2348. CFLAGS+=-fdebug-default-version=4
  2349. }
  2350. when ($USE_ARCADIA_LIBM == "yes") {
  2351. PEERDIR+=contrib/libs/libm
  2352. }
  2353. }
  2354. CPP_LIBRARY_INDUCED_SEM_PROPERTY=consumer_link_library
  2355. CPP_LIBRARY_SEM=add_library ${MODDIR} $CMAKE_TARGET_NAME ${hide:TARGET} ${hide:AUTO_INPUT} $CMAKE_TARGET_ARTEFACT_RENAME_RULES \
  2356. && library_fake_marker FAKE_MODULE ${FAKE_MODULE} \
  2357. && ${CPP_LIBRARY_INDUCED_SEM_PROPERTY} PUBLIC $CMAKE_LINK_TARGET \
  2358. && target_include_directories PUBLIC $_C__INCLUDE_GLOBAL \
  2359. && target_include_directories PRIVATE $_C__INCLUDE_OWNED \
  2360. && target_compile_options PRIVATE $USER_CFLAGS $USER_CXXFLAGS $_SEM_EXTRA_CXX_FLAGS \
  2361. && target_compile_options PUBLIC $USER_CFLAGS_GLOBAL_RAW $USER_CXXFLAGS_GLOBAL_RAW \
  2362. && target_link_options INTERFACE $LDFLAGS_GLOBAL_RAW \
  2363. && add_language C && add_language CXX
  2364. CPP_OBJ_LIBRARY_SEM=add_global_library_for ${MODDIR} ${suf=.global:CMAKE_TARGET_NAME} $CMAKE_TARGET_NAME ${hide:GLOBAL_TARGET} ${hide:AUTO_INPUT} \
  2365. && target_include_directories PUBLIC $_C__INCLUDE_GLOBAL \
  2366. && target_include_directories PRIVATE $_C__INCLUDE_OWNED \
  2367. && target_compile_options PRIVATE $USER_CFLAGS $USER_CXXFLAGS $_SEM_EXTRA_CXX_FLAGS \
  2368. && target_compile_options PUBLIC $USER_CFLAGS_GLOBAL_RAW $USER_CXXFLAGS_GLOBAL_RAW
  2369. CMAKE_FIND_PKG=
  2370. CMAKE_LINK_TARGET=$REALPRJNAME
  2371. CMAKE_FIND_PKG_COMP=
  2372. CONAN_REQUIRE=
  2373. CONAN_OPTS_SEM=
  2374. ### @usage: LIBRARY()
  2375. ###
  2376. ### The regular static library module.
  2377. ###
  2378. ### The LIBRARY() is intermediate module, so when built directly it won't build its dependencies.
  2379. ### It transitively provides its PEERDIRs to ultimate final target, where all LIBRARY() modules are built and linked together.
  2380. ###
  2381. ### This is C++ library, and it selects peers from multimodules accordingly.
  2382. ###
  2383. ### It makes little sense to mention LIBRARY in DEPENDS or BUNDLE, package and deploy it since it is not a standalone entity.
  2384. ### In order to use library in tests PEERDIR it to link into tests.
  2385. ### If you think you need to distribute static library please contact devtools@ for assistance.
  2386. module LIBRARY: _LIBRARY {
  2387. .GLOBAL=_AARS _PROGUARD_RULES
  2388. .SEM=CPP_LIBRARY_SEM
  2389. .GLOBAL_SEM=CPP_OBJ_LIBRARY_SEM
  2390. .DEFAULT_NAME_GENERATOR=ThreeDirNames
  2391. .ARGS_PARSER=Base
  2392. when ($CMAKE_PACKAGE_COMPONENT != "") {
  2393. CMAKE_FIND_PKG_COMP=COMPONENTS $CMAKE_PACKAGE_COMPONENT
  2394. }
  2395. when ($CMAKE_PACKAGE != "") {
  2396. CMAKE_FIND_PKG=find_package $CMAKE_PACKAGE $CMAKE_FIND_PKG_COMP
  2397. CPP_LIBRARY_SEM=$CMAKE_FIND_PKG && ${CPP_LIBRARY_INDUCED_SEM_PROPERTY} PUBLIC $CMAKE_LINK_TARGET $CONAN_REQUIRE $CONAN_OPTS_SEM && IGNORED
  2398. }
  2399. when ($CONAN_REFERENCE != "") {
  2400. CONAN_REQUIRE=&& conan_require $CONAN_REFERENCE
  2401. CPP_LIBRARY_SEM=$CMAKE_FIND_PKG && ${CPP_LIBRARY_INDUCED_SEM_PROPERTY} PUBLIC $CMAKE_LINK_TARGET $CONAN_REQUIRE $CONAN_OPTS_SEM && IGNORED
  2402. }
  2403. when ($CONAN_PKG_OPTS != "") {
  2404. CONAN_OPTS_SEM=&& conan_options $CONAN_PKG_OPTS
  2405. }
  2406. when ($OPENSOURCE_EXPORT == "no") {
  2407. CPP_LIBRARY_SEM=IGNORED
  2408. }
  2409. when ($SANITIZER_TYPE && $SANITIZER_TYPE != "no" && $SANITIZE_HEADERS && $SANITIZE_HEADERS != "no") {
  2410. PEERDIR += library/cpp/sanitizer/include
  2411. }
  2412. when ($HAS_CPP_PROTOBUF_PEERS == "yes") {
  2413. PEERDIR+=$CPP_PROTOBUF_PEERS
  2414. }
  2415. SET(MODULE_TYPE LIBRARY)
  2416. SET(MODULE_LANG CPP)
  2417. ADD_CLANG_TIDY()
  2418. }
  2419. # tag:internal
  2420. ### @usage: _BARE_MODULE() # internal
  2421. ###
  2422. ### Remove unwanted dependencies for "empty" library module
  2423. macro _BARE_MODULE() {
  2424. SET(NEED_PLATFORM_PEERDIRS no)
  2425. SET(PEERDIR_TEST_TOOL no)
  2426. DISABLE(WITH_VALGRIND)
  2427. NO_CODENAVIGATION()
  2428. NO_PLATFORM()
  2429. NO_RUNTIME()
  2430. NO_UTIL()
  2431. NO_CLANG_TIDY()
  2432. }
  2433. # tag:internal
  2434. ### @usage: _BARE_LINK_MODULE() # internal
  2435. ###
  2436. ### Remove unwanted dependencies for "empty" link module
  2437. macro _BARE_LINK_MODULE() {
  2438. _BARE_MODULE()
  2439. DISABLE(COMMON_LINK_SETTINGS)
  2440. ALLOCATOR(FAKE)
  2441. }
  2442. # tag:internal
  2443. ### @usage: _CONDITIONAL_SRCS([USE_CONDITIONAL_SRCS] Files...) # internal
  2444. ###
  2445. ### Adds Files... to SRCS if first word is `USE_CONDITIONAL_SRCS`
  2446. ### To be used with some variable which is set to `USE_CONDITIONAL_SRCS` under condition
  2447. macro _CONDITIONAL_SRCS(USE_CONDITIONAL_SRCS[], DYMMY...) {
  2448. SRCS($USE_CONDITIONAL_SRCS)
  2449. }
  2450. # XXX: dirty hack for correct LDFLAGS passing
  2451. RESOURCES_LIBRARY_LINK=$TOUCH_UNIT
  2452. RESOURCES_LIBRARY_SEM=IGNORED
  2453. ### @usage: RESOURCES_LIBRARY()
  2454. ###
  2455. ### Definition of a module that brings its content from external source (Sandbox) via DECLARE_EXTERNAL_RESOURCE macro.
  2456. ### This can participate in PEERDIRs of others as library but it cannot have own sources and PEERDIRs.
  2457. ###
  2458. ### @see: [DECLARE_EXTERNAL_RESOURCE()](#macro_DECLARE_EXTERNAL_RESOURCE)
  2459. module RESOURCES_LIBRARY: _BARE_UNIT {
  2460. .CMD=RESOURCES_LIBRARY_LINK
  2461. .SEM=RESOURCES_LIBRARY_SEM
  2462. .ALLOWED=DECLARE_EXTERNAL_RESOURCE EXTRALIBS OBJADDE_GLOBAL
  2463. .RESTRICTED=ALLOCATOR SIZE TAG DATA TEST_DATA DEPENDS FORK_TESTS FORK_SUBTESTS SPLIT_FACTOR TEST_CWD RUN TIMEOUT SRC SRCS PEERDIR SPLIT_DWARF
  2464. .NODE_TYPE=Library
  2465. .PEERDIR_POLICY=as_include
  2466. .EXTS=.o .obj .a .mf .supp .tidyjson .ld .lib
  2467. .GLOBAL=USER_CFLAGS USER_CXXFLAGS USER_CONLYFLAGS LDFLAGS _WHOLE_ARCHIVE_LIBS_VALUE RPATH
  2468. when ($CMAKE_PACKAGE_COMPONENT != "") {
  2469. CMAKE_FIND_PKG_COMP=COMPONENTS $CMAKE_PACKAGE_COMPONENT
  2470. }
  2471. when ($CMAKE_PACKAGE != "") {
  2472. CMAKE_FIND_PKG=find_package $CMAKE_PACKAGE $CMAKE_FIND_PKG_COMP
  2473. RESOURCES_LIBRARY_SEM=$CMAKE_FIND_PKG && ${CPP_LIBRARY_INDUCED_SEM_PROPERTY} PUBLIC $CMAKE_LINK_TARGET $CONAN_REQUIRE $CONAN_OPTS_SEM && IGNORED
  2474. }
  2475. when ($CONAN_REFERENCE != "") {
  2476. CONAN_REQUIRE=&& conan_require $CONAN_REFERENCE
  2477. RESOURCES_LIBRARY_SEM=$CMAKE_FIND_PKG && ${CPP_LIBRARY_INDUCED_SEM_PROPERTY} PUBLIC $CMAKE_LINK_TARGET $CONAN_REQUIRE $CONAN_OPTS_SEM && IGNORED
  2478. }
  2479. when ($CONAN_PKG_OPTS != "") {
  2480. CONAN_OPTS_SEM=&& conan_options $CONAN_PKG_OPTS
  2481. }
  2482. MODULE_SUFFIX=.pkg.fake
  2483. ENABLE(NEED_ADD_FAKE_SRC)
  2484. WITHOUT_LICENSE_TEXTS()
  2485. }
  2486. FAT_OBJECT_SEM=add_fat_object ${MODDIR} ${CMAKE_TARGET_NAME} ${hide:TARGET} ${hide:AUTO_INPUT} ${CMAKE_TARGET_ARTEFACT_RENAME_RULES} \
  2487. && target_include_directories PRIVATE $_C__INCLUDE_OWNED \
  2488. && target_compile_options PRIVATE $USER_CFLAGS $USER_CXXFLAGS $_SEM_EXTRA_CXX_FLAGS \
  2489. && set_global_flags FAT_OBJECT_PREFIX ${MODULE_PREFIX} \
  2490. && set_global_flags FAT_OBJECT_SUFFIX ${MODULE_SUFFIX}
  2491. ### Do not turn visibility=hidden symbos into static symbos of partially linked object file
  2492. ###
  2493. ### Note: This variable do not have any effect on platforms other than MacOS and iOS.
  2494. KEEP_FAT_OBJECT_SYMBOLS=no
  2495. ### @usage: FAT_OBJECT()
  2496. ###
  2497. ### The "fat" object module. It will contain all its transitive dependencies reachable by PEERDIRs:
  2498. ### static libraries, local (from own SRCS) and global (from peers') object files.
  2499. ###
  2500. ### Designed for use in XCode projects for iOS.
  2501. module FAT_OBJECT: LIBRARY {
  2502. .ALLOWED=PACK_GLOBALS_IN_LIBRARY
  2503. .CMD=LINK_FAT_OBJECT
  2504. .SEM=FAT_OBJECT_SEM
  2505. .PEERDIR_POLICY=as_build_from
  2506. when ($MSVC == "yes" || $CYGWIN == "yes") {
  2507. MODULE_SUFFIX=.lib
  2508. }
  2509. otherwise {
  2510. MODULE_SUFFIX=.a
  2511. }
  2512. when (($OS_DARWIN == "yes" || $OS_IOS == "yes") && $KEEP_FAT_OBJECT_SYMBOLS == "yes") {
  2513. LDFLAGS_GLOBAL += -keep_private_externs
  2514. }
  2515. # FIXME: This is weird legacy
  2516. when ($OS_ANDROID == "yes") {
  2517. MODULE_PREFIX=lib
  2518. }
  2519. otherwise {
  2520. MODULE_PREFIX=
  2521. }
  2522. _USE_LINKER()
  2523. # This module requires at least one .o which is not subject to removal so just add _fake_src.cpp as SRCS
  2524. # ymake's handling of NEED_ADD_FAKE_SRC may insert arbitrary command, not necessarily compilation
  2525. DISABLE(NEED_ADD_FAKE_SRC)
  2526. SRCS(build/scripts/_fake_src.cpp)
  2527. }
  2528. RECURSIVE_LIBRARY_SEM=add_recursive_library ${MODDIR} ${CMAKE_TARGET_NAME} ${hide:TARGET} ${hide:AUTO_INPUT} ${CMAKE_TARGET_ARTEFACT_RENAME_RULES} \
  2529. && target_include_directories PUBLIC $_C__INCLUDE_GLOBAL \
  2530. && target_include_directories PRIVATE $_C__INCLUDE_OWNED \
  2531. && target_compile_options PRIVATE $USER_CFLAGS $USER_CXXFLAGS $_SEM_EXTRA_CXX_FLAGS \
  2532. && target_compile_options PUBLIC $USER_CFLAGS_GLOBAL_RAW $USER_CXXFLAGS_GLOBAL_RAW \
  2533. && target_link_options INTERFACE $LDFLAGS_GLOBAL_RAW
  2534. ### @usage: RECURSIVE_LIBRARY()
  2535. ###
  2536. ### The recursive ("fat") library module. It will contain all its transitive dependencies reachable by PEERDIRs:
  2537. ### from static libraries, local (from own SRCS) and global (from peers') object files.
  2538. ###
  2539. ### Designed for use in XCode projects for iOS.
  2540. module RECURSIVE_LIBRARY: LIBRARY {
  2541. .CMD=LINK_RECURSIVE_LIBRARY
  2542. .SEM=RECURSIVE_LIBRARY_SEM
  2543. .PEERDIR_POLICY=as_build_from
  2544. # This module requires at least one .o which is not subject to removal so just add _fake_src.cpp as SRCS
  2545. # ymake's handling of NEED_ADD_FAKE_SRC may insert arbitrary command, not necessarily compilation
  2546. DISABLE(NEED_ADD_FAKE_SRC)
  2547. SRCS(build/scripts/_fake_src.cpp)
  2548. }
  2549. _SONAME=
  2550. _EXPORT_SCRIPT_SEM=
  2551. _CLEAN_TEXTREL=
  2552. macro _ADD_DYNLYB_SEM(Libname) {
  2553. .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 $_SEM_EXTRA_CXX_FLAGS && target_compile_options PUBLIC $USER_CFLAGS_GLOBAL_RAW $USER_CXXFLAGS_GLOBAL_RAW && target_link_options PRIVATE $LDFLAGS_GLOBAL_RAW $LDFLAGS $OBJADDE_LIB $OBJADDE && ${VCS_INFO_SEM} $_EXPORT_SCRIPT_SEM
  2554. }
  2555. CPP_DYN_LIBRARY_SEM=$_ADD_DYNLYB_SEM($CMAKE_TARGET_NAME) $CMAKE_TARGET_ARTEFACT_RENAME_RULES
  2556. macro CLEAN_TEXTREL() {
  2557. SET(_CLEAN_TEXTREL yes)
  2558. }
  2559. ### @usage: DLL_UNIT # internal
  2560. ###
  2561. ### Base module for all dynamically linked libraries as final artifacts.
  2562. ### Contains all general logic for such kind of modules. Supports versioning and export files.
  2563. ### Cannot participate in linking to programs, intended to be used as final artifact (packaged and deployed).
  2564. module DLL_UNIT: _LINK_UNIT {
  2565. .CMD=LINK_DYN_LIB
  2566. .SEM=CPP_DYN_LIBRARY_SEM
  2567. .NODE_TYPE=Library
  2568. .SYMLINK_POLICY=SO
  2569. .GLOBAL=USER_CFLAGS USER_CXXFLAGS USER_CONLYFLAGS LDFLAGS _WHOLE_ARCHIVE_LIBS_VALUE RPATH
  2570. .ALLOWED=WHOLE_ARCHIVE
  2571. .DEFAULT_NAME_GENERATOR=TwoDirNames
  2572. .ARGS_PARSER=DLL
  2573. DYNAMIC_LINK=yes
  2574. ALLOCATOR(FAKE)
  2575. SET(MODULE_TYPE DLL)
  2576. SET(MODULE_TAG DLL)
  2577. SET(MODULE_LANG CPP)
  2578. ADD_CLANG_TIDY()
  2579. when ($EXPORTS_FILE) {
  2580. _EXPORT_SCRIPT_SEM=&& use_export_script ${input:EXPORTS_FILE}
  2581. }
  2582. when ($MSVC == "yes" || $CYGWIN == "yes") {
  2583. MODULE_SUFFIX=.dll
  2584. }
  2585. elsewhen ($DARWIN == "yes" || $OS_IOS == "yes") {
  2586. MODULE_PREFIX=lib
  2587. MODULE_SUFFIX=.dylib
  2588. }
  2589. elsewhen ($TIDY_ENABLED == "yes") {
  2590. MODULE_PREFIX=
  2591. MODULE_SUFFIX=.tidyjson
  2592. }
  2593. otherwise {
  2594. MODULE_PREFIX=lib
  2595. MODULE_SUFFIX=.so
  2596. }
  2597. # This by now replicates ymake's behavior. We'll get rid of SONAME setting in ymake and fix this code altogether
  2598. SONAME=${pre=$MODULE_PREFIX;suf=$MODULE_SUFFIX:REALPRJNAME}
  2599. when ($MODULE_VERSION) {
  2600. LINK_DYN_LIB_FLAGS=--soname ${output;pre=$MODULE_PREFIX;suf=$MODULE_SUFFIX$MODULE_VERSION:REALPRJNAME}
  2601. }
  2602. _SONAME=$SONAME$MODULE_VERSION
  2603. when ($LINUX == "yes") {
  2604. # '-z notext' is needed for linking mkl into shared libraries
  2605. when ($_CLEAN_TEXTREL != "yes") {
  2606. LDFLAGS += -Wl,-z,notext
  2607. }
  2608. }
  2609. when ($OS_LINUX == "yes" && $ARCH_X86_64 == "yes") {
  2610. when ($_NO_FIX_ELF != "yes") {
  2611. LINK_DYN_LIB_FLAGS+=--fix-elf ${tool:"tools/fix_elf"}
  2612. }
  2613. }
  2614. when ($DARWIN == "yes") {
  2615. LDFLAGS += -undefined dynamic_lookup
  2616. }
  2617. when ($CLANG_COVERAGE && $CLANG_COVERAGE != "no") {
  2618. PEERDIR+=library/cpp/testing/dump_clang_coverage
  2619. }
  2620. when ($IDE_MSVS == "yes") {
  2621. PEERDIR+=build/scripts/c_templates
  2622. }
  2623. when ($_CUSTOM_LINK_STEP_SCRIPT) {
  2624. LINK_DYN_LIB_FLAGS+=--python=$YMAKE_PYTHON --custom-step=${input:_CUSTOM_LINK_STEP_SCRIPT}
  2625. }
  2626. }
  2627. # tag:python-specific
  2628. ### @usage: PY_ANY_MODULE(name major_ver [minor_ver] [EXPORTS symlist_file] [PREFIX prefix])
  2629. ###
  2630. ### The Python external module for any versio of Arcadia or system Python.
  2631. ### 1. major_ver and minor_ver must be integers.
  2632. ### 2. The resulting .so will have the prefix "lib".
  2633. ### 3. Processing EXPORTS and PREFIX is the same as for DLL module
  2634. ### This is native DLL, so it will select C++ version from PROTO_LIBRARY.
  2635. ###
  2636. ### Note: Use PYTHON2_MODULE()/PYTHON3_MODULE() in order to PEERDIR proper version of PY23_NATIVE_LIBRARY.
  2637. ### Do not PEERDIR any PY*_LIBRARY: this will link Python in and render artifact unusable as Python module.
  2638. ###
  2639. ### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/py_srcs/
  2640. module PY_ANY_MODULE: DLL_UNIT {
  2641. .SEM=CPP_DYN_LIBRARY_SEM
  2642. when ($MSVC != "yes" && $DARWIN != "yes") {
  2643. LDFLAGS+= -Wl,-Bsymbolic
  2644. }
  2645. when ($USE_ARCADIA_PYTHON == "no") {
  2646. when ($USE_SYSTEM_PYTHON) {
  2647. PEERDIR+=build/platform/python
  2648. }
  2649. otherwise {
  2650. when ($MSVC == "yes" || $CYGWIN == "yes") {
  2651. LDFLAGS+=$PYTHON_LIBRARIES
  2652. }
  2653. }
  2654. }
  2655. # This by now replicates ymake's behavior. We'll get rid of SONAME setting in ymake and fix this code altogether
  2656. SONAME=${pre=$MODULE_PREFIX;suf=$MODULE_SUFFIX:REALPRJNAME}
  2657. when ($MODULE_VERSION) {
  2658. LINK_DYN_LIB_FLAGS=--soname ${output;pre=$MODULE_PREFIX;suf=$MODULE_SUFFIX$MODULE_VERSION:REALPRJNAME}
  2659. }
  2660. _SONAME=$SONAME$MODULE_VERSION
  2661. # -bundle
  2662. when ($DARWIN == "yes") {
  2663. LDFLAGS+=-flat_namespace
  2664. }
  2665. when ($MSVC == "yes" || $CYGWIN == "yes") {
  2666. MODULE_PREFIX=
  2667. MODULE_SUFFIX=.pyd
  2668. }
  2669. otherwise {
  2670. MODULE_PREFIX=
  2671. MODULE_SUFFIX=.so
  2672. }
  2673. .RESTRICTED=USE_PYTHON2 USE_PYTHON3 PY_SRCS PY_MAIN
  2674. }
  2675. # tag:python-specific
  2676. ### @usage: PY2MODULE(name major_ver [minor_ver] [EXPORTS symlist_file] [PREFIX prefix])
  2677. ###
  2678. ### The Python external module for Python2 and any system Python
  2679. ### 1. major_ver and minor_ver must be integers.
  2680. ### 2. The resulting .so will have the prefix "lib".
  2681. ### 3. Processing EXPORTS and PREFIX is the same as for DLL module
  2682. ### This is native DLL, so it will select C++ version from PROTO_LIBRARY.
  2683. ###
  2684. ### Note: this module will always PEERDIR Python2 version of PY23_NATIVE_LIBRARY.
  2685. ### Do not PEERDIR PY2_LIBRARY or PY23_LIBRARY: this will link Python in and render artifact unusable as Python module.
  2686. ###
  2687. ### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/py_srcs/
  2688. module PY2MODULE: PY_ANY_MODULE {
  2689. PYTHON2_MODULE()
  2690. SET(MODULE_LANG PY2)
  2691. .RESTRICTED=PYTHON3_MODULE PYTHON3_ADDINCL
  2692. }
  2693. # tag:python-specific
  2694. ### @usage: PY3MODULE(name major_ver [minor_ver] [EXPORTS symlist_file] [PREFIX prefix])
  2695. ###
  2696. ### The Python external module for Python3 and any system Python
  2697. ### 1. major_ver and minor_ver must be integers.
  2698. ### 2. The resulting .so will have the prefix "lib".
  2699. ### 3. Processing EXPORTS and PREFIX is the same as for DLL module
  2700. ### This is native DLL, so it will select C++ version from PROTO_LIBRARY.
  2701. ###
  2702. ### Note: this module will always PEERDIR Python3 version of PY23_NATIVE_LIBRARY.
  2703. ### Do not PEERDIR PY3_LIBRARY or PY23_LIBRARY: this will link Python in and render artifact unusable as Python module.
  2704. ###
  2705. ### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/py_srcs/
  2706. module PY3MODULE: PY_ANY_MODULE {
  2707. PYTHON3_MODULE()
  2708. SET(MODULE_LANG PY3)
  2709. .RESTRICTED=PYTHON2_MODULE PYTHON2_ADDINCL
  2710. }
  2711. # tag:python-specific
  2712. ### @usage: PYTHON2_MODULE()
  2713. ###
  2714. ### Use in PY_ANY_MODULE to set it up for Python 2.x.
  2715. macro PYTHON2_MODULE() {
  2716. when ($USE_ARCADIA_PYTHON == "yes" && $MSVC == "yes" || $IS_CROSS_TOOLS == "yes") {
  2717. PEERDIR+=contrib/tools/python/lib
  2718. }
  2719. SET(ANTLR_PYTHON Python2)
  2720. PYTHON2_ADDINCL()
  2721. }
  2722. # tag:python-specific
  2723. ### @usage: PYTHON3_MODULE()
  2724. ###
  2725. ### Use in PY_ANY_MODULE to set it up for Python 3.x.
  2726. macro PYTHON3_MODULE() {
  2727. when ($USE_ARCADIA_PYTHON == "yes" && $MSVC == "yes" || $IS_CROSS_TOOLS == "yes") {
  2728. PEERDIR+=contrib/tools/python3/lib
  2729. }
  2730. SET(ANTLR_PYTHON Python3)
  2731. PYTHON3_ADDINCL()
  2732. }
  2733. # tag:r-specific
  2734. ### @usage: R_MODULE(name major_ver [minor_ver] [EXPORTS symlist_file] [PREFIX prefix])
  2735. ###
  2736. ### The external module for R language.
  2737. ### 1. major_ver and minor_ver must be integers.
  2738. ### 2. The resulting .so will have the prefix "lib".
  2739. ### 3. Processing EXPORTS and PREFIX is the same as for DLL module
  2740. ### This is native DLL, so it will select C++ version from PROTO_LIBRARY.
  2741. module R_MODULE: DLL_UNIT {
  2742. .SEM=CPP_DYN_LIBRARY_SEM
  2743. when ($DARWIN == "yes") {
  2744. LDFLAGS+=-flat_namespace -dynamiclib
  2745. }
  2746. when ($MSVC == "yes" || $CYGWIN == "yes") {
  2747. MODULE_PREFIX=lib
  2748. MODULE_SUFFIX=.dll
  2749. }
  2750. ADDINCL(contrib/libs/r-lang)
  2751. }
  2752. ### @usage: DYNAMIC_LIBRARY_FROM(Paths)
  2753. ###
  2754. ### Use specified libraries as sources of DLL
  2755. macro DYNAMIC_LIBRARY_FROM(Path...) {
  2756. PEERDIR($Path)
  2757. WHOLE_ARCHIVE($Path)
  2758. }
  2759. ### @usage: DLL(name major_ver [minor_ver] [EXPORTS symlist_file] [PREFIX prefix])
  2760. ###
  2761. ### Dynamic library module definition.
  2762. ### 1. major_ver and minor_ver must be integers.
  2763. ### 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
  2764. ### 3. PREFIX allows you to change the prefix of the output file (default DLL has the prefix "lib").
  2765. ###
  2766. ### DLL cannot participate in linking to programs but can be used from Java or as final artifact (packaged and deployed).
  2767. module DLL: DLL_UNIT {
  2768. .SEM=CPP_DYN_LIBRARY_SEM
  2769. SET(MAKE_ONLY_SHARED_LIB yes)
  2770. when ($OS_WINDOWS) {
  2771. MODULE_SUFFIX=.dll
  2772. }
  2773. # TODO: Make it possible to use this syntax
  2774. # DEFAULT(DLL_FOR_DIR no)
  2775. ### FIXME: XXX
  2776. ###when ($DLL_FOR_DIR != "no") {
  2777. ### SRCDIR($DLL_FOR_DIR)
  2778. ### ADDINCL($DLL_FOR_DIR)
  2779. ###}
  2780. }
  2781. ### DLL_TOOL is a DLL that can be used as a LD_PRELOAD tool.
  2782. module DLL_TOOL: DLL {
  2783. .SEM=CPP_DYN_LIBRARY_SEM
  2784. # ymake resolves only program nodes as tools.
  2785. .NODE_TYPE=Program
  2786. }
  2787. ### @usage: SO_PROGRAM(name major_ver [minor_ver] [EXPORTS symlist_file] [PREFIX prefix])
  2788. ###
  2789. ### Executable dynamic library module definition.
  2790. ### 1. major_ver and minor_ver must be integers.
  2791. ### 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
  2792. ### 3. PREFIX allows you to change the prefix of the output file.
  2793. module SO_PROGRAM: DLL {
  2794. .CMD=LINK_EXEC_DYN_LIB
  2795. SET(MODULE_TYPE PROGRAM)
  2796. MODULE_PREFIX=
  2797. when ($MSVC == "yes" || $CYGWIN == "yes") {
  2798. MODULE_SUFFIX=.exe
  2799. }
  2800. otherwise {
  2801. MODULE_SUFFIX=
  2802. }
  2803. }
  2804. DLL_PROXY_CMD_MF=$GENERATE_MF && $COPY_CMD $AUTO_INPUT $TARGET
  2805. # tag:internal
  2806. ### @usage: DEV_DLL_PROXY() # internal
  2807. ###
  2808. ### The use of this module is strictly prohibited!!!
  2809. ### This is a temporary and project-specific solution.
  2810. module DEV_DLL_PROXY: _BARE_UNIT {
  2811. .NODE_TYPE=Library
  2812. .EXTS=.so .dll .dylib .mf
  2813. .CMD=DLL_PROXY_CMD_MF
  2814. DYNAMIC_LINK=yes
  2815. when ($OS_WINDOWS == "yes") {
  2816. MODULE_SUFFIX=.dll
  2817. }
  2818. elsewhen ($DARWIN == "yes" || $OS_IOS == "yes") {
  2819. MODULE_PREFIX=lib
  2820. MODULE_SUFFIX=.dylib$MODULE_VERSION
  2821. }
  2822. otherwise {
  2823. MODULE_PREFIX=lib
  2824. MODULE_SUFFIX=.so$MODULE_VERSION
  2825. }
  2826. }
  2827. # tag:internal
  2828. ### @usage: DLL_PROXY() # internal
  2829. ###
  2830. ### The use of this module is strictly prohibited!!!
  2831. ### This is a temporary and project-specific solution.
  2832. module DLL_PROXY: DEV_DLL_PROXY {
  2833. .EXTS=.so .dylib .lib .mf
  2834. .PROXY=yes
  2835. .PEERDIR_POLICY=as_build_from
  2836. SET(PEERDIR_TAGS DLL __EMPTY__)
  2837. when ($OS_WINDOWS == "yes") {
  2838. MODULE_SUFFIX=.lib
  2839. }
  2840. }
  2841. # tag:internal
  2842. ### @usage: DYNAMIC_DEPS(Path...) # internal, temporary
  2843. ###
  2844. ### Enlist paths to all DYNAMIC_LIBRARY dependencies of the DYNAMIC_LIBRARY
  2845. ### This it needed to transfer their outputs through the library to PROGRAM
  2846. ### or dependent DLL/DYNAMIC_LIBRARY.
  2847. ###
  2848. ### Note: this is temporary solution until support of `super-global` variables come
  2849. ### which will enable transfer of some properties though final targets like DLLs.
  2850. macro DYNAMIC_DEPS(Path...) {
  2851. # PEERDIR as macro completely ignored in place where this macro applies
  2852. SET_APPEND(PEERDIR $Path)
  2853. }
  2854. # tag:internal
  2855. ### @usage: DYNAMIC_LIBRARY() # internal
  2856. ###
  2857. ### The use of this module is strictly prohibited except LGPL-related opensourcing
  2858. ### This provides linkable DLL module which brings its results to programs and tests
  2859. ### for seamless testing and packaging
  2860. multimodule DYNAMIC_LIBRARY {
  2861. module DLL_BIN: DLL {
  2862. .PROXY=yes
  2863. .IGNORED=PROVIDES
  2864. SET(MODULE_TAG DLL)
  2865. }
  2866. module DLL_LIB: _DLL_COMPATIBLE_LIBRARY {
  2867. .CMD=TOUCH_UNIT_MF
  2868. .PEERDIRSELF=DLL_BIN
  2869. .IGNORED=SRCS PEERDIR RUN_PROGRAM PYTHON DYNAMIC_LIBRARY_FROM GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER USE_PYTHON2 USE_PYTHON3
  2870. .ALLOWED=DYNAMIC_DEPS
  2871. SET(PEERDIR_TAGS DLL_LIB __EMPTY__)
  2872. _BARE_MODULE()
  2873. DYNAMIC_LINK=yes
  2874. MODULE_SUFFIX=.pkg.fake
  2875. PEERDIR+=build/platform/local_so
  2876. when ($SANITIZER_TYPE && $SANITIZER_TYPE != "no" && $SANITIZE_HEADERS && $SANITIZE_HEADERS != "no") {
  2877. PEERDIR += library/cpp/sanitizer/include
  2878. }
  2879. # disable credits generation for static library
  2880. SET(CREDITS_FLAGS)
  2881. }
  2882. }
  2883. ### @usage: GLOBAL_SRCS(filenames...)
  2884. ###
  2885. ### Make all source files listed as GLOBAL.
  2886. ### Call to GLOBAL_SRCS macro is equivalent to call to SRCS macro when each source file is marked with GLOBAL keyword.
  2887. ### Arcadia root relative or project dir relative paths are supported for filenames arguments. GLOBAL keyword is not
  2888. ### recognized for GLOBAL_SRCS in contrast to SRCS macro.
  2889. ###
  2890. ### @example:
  2891. ### Consider the file to ya.make:
  2892. ###
  2893. ### LIBRARY()
  2894. ### GLOBAL_SRCS(foo.cpp bar.cpp)
  2895. ### END()
  2896. ###
  2897. ### @see: [SRCS()](#macro_SRCS)
  2898. macro GLOBAL_SRCS(Files...) {
  2899. SRCS(${pre=GLOBAL :Files})
  2900. }
  2901. ### @usage: ALL_SRCS([GLOBAL] filenames...)
  2902. ###
  2903. ### Make all source files listed as GLOBAL or not depending on the keyword GLOBAL
  2904. ### Call to ALL_SRCS macro is equivalent to call to GLOBAL_SRCS macro when GLOBAL keyword is specified
  2905. ### as the first argument and is equivalent to call to SRCS macro otherwise.
  2906. ###
  2907. ### @example:
  2908. ###
  2909. ### LIBRARY()
  2910. ### SET(MAKE_IT_GLOBAL GLOBAL)
  2911. ### ALL_SRCS(${MAKE_IT_GLOBAL} foo.cpp bar.cpp)
  2912. ### END()
  2913. ###
  2914. ### @see: [GLOBAL_SRCS()](#macro_GLOBAL_SRCS), [SRCS()](#macro_SRCS)
  2915. macro ALL_SRCS(GLOBAL?"GLOBAL":"", Files...) {
  2916. SRCS(${pre=$GLOBAL :Files})
  2917. }
  2918. ### @usage: _DLL_COMPATIBLE_LIBRARY # internal
  2919. ###
  2920. ### Base module to place DLLs into multimodules back to back with libraries.
  2921. ### In order to function properly all modules in multimodule shall have the
  2922. ### same set of arguments. So this module is just library that accepts but
  2923. ### ignores all DLL arguments.
  2924. module _DLL_COMPATIBLE_LIBRARY: LIBRARY {
  2925. .DEFAULT_NAME_GENERATOR=TwoDirNames
  2926. .ARGS_PARSER=DLL
  2927. }
  2928. @import "${CONF_ROOT}/conf/project_specific/yql_udf.conf"
  2929. # as SRCS in packages use macro BUNDLE_SRCS!
  2930. PACKED_PACKAGE_ARGS=
  2931. PACKED_PACKAGE_EXT=
  2932. ### @usage: PACK(archive_type)
  2933. ###
  2934. ### 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`
  2935. ###
  2936. ### Is not allowed other module types than PACKAGE().
  2937. ###
  2938. ### @see: [PACKAGE()](#module_PACKAGE)
  2939. macro PACK(Ext) {
  2940. SET(PACKED_PACKAGE_EXT $Ext)
  2941. }
  2942. PACKAGE_STRICT_VALUE=
  2943. macro PACKAGE_STRICT() {
  2944. SET(PACKAGE_STRICT_VALUE yes)
  2945. }
  2946. ### @usage: PACKAGE(name)
  2947. ###
  2948. ### Module collects what is described directly inside it, builds and collects all its transitively available PEERDIRs.
  2949. ### 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.
  2950. ### The data can be optionally packed if macro PACK() is used.
  2951. ###
  2952. ### Is only used together with the macros FILES(), PEERDIR(), COPY(), FROM_SANDBOX(), RUN_PROGRAM or BUNDLE(). Don't use SRCS inside a PACKAGE.
  2953. ###
  2954. ### Documentation: https://wiki.yandex-team.ru/yatool/large-data/
  2955. ###
  2956. ### @see: [PACK()](#macro_PACK)
  2957. multimodule PACKAGE {
  2958. module PACKAGE_FINAL: _BASE_UNIT {
  2959. .CMD=TOUCH_PACKAGE_MF
  2960. .ALIASES=SRCS=FILES
  2961. .ALLOWED=PACK
  2962. .PEERDIRSELF=PACKAGE_UNION
  2963. .USE_PEERS_LATE_OUTS=yes
  2964. .PEERDIR_POLICY=as_build_from
  2965. .FINAL_TARGET=yes
  2966. SET(PEERDIR_TAGS CPP_PROTO CPP_FBS PY2 PY3 PY2_NATIVE YQL_UDF_SHARED __EMPTY__ DOCSBOOK JAR_RUNNABLE PY3_BIN PY3TEST_PROGRAM DLL GO_PROGRAM PACKAGE_UNION)
  2967. SET(MODULE_SUFFIX .final.pkg.fake)
  2968. SET(DONT_RESOLVE_INCLUDES yes)
  2969. NO_PLATFORM()
  2970. when ($PACKED_PACKAGE_EXT) {
  2971. PACKED_PACKAGE_ARGS+=--dest-arch ${output;pre=$MODULE_PREFIX;suf=.$PACKED_PACKAGE_EXT:REALPRJNAME}
  2972. }
  2973. SET(NEED_PLATFORM_PEERDIRS no)
  2974. }
  2975. module PACKAGE_UNION: UNION {
  2976. .CMD=UNION_CMD
  2977. .FINAL_TARGET=no
  2978. .ALLOWED=PACK
  2979. .IGNORED=VCS_INFO_FILE
  2980. SET(MODULE_SUFFIX .pkg.fake)
  2981. SET(PEERDIR_TAGS CPP_PROTO CPP_FBS PY2 PY3 PY2_NATIVE YQL_UDF_SHARED __EMPTY__ DOCSBOOK JAR_RUNNABLE PY3_BIN PY3TEST_PROGRAM DLL GO_PROGRAM PACKAGE_UNION)
  2982. DISABLE(START_TARGET)
  2983. }
  2984. }
  2985. TOUCH_GROUP=$TOUCH_PACKAGE ${kv;hide:"p CI"}
  2986. ### @usage: CI_GROUP()
  2987. ###
  2988. ### Module collects what is described directly inside it transitively by PEERDIRs.
  2989. ### No particular layout of built artifacts is implied. This module is needed primarily for CI dependency analysis and may not trigger builds at all.
  2990. ###
  2991. ### Is only used together with the macro PEERDIR() and FILES(). Don't use SRCS inside CI_GROUP().
  2992. module CI_GROUP: _BARE_UNIT {
  2993. .CMD=TOUCH_GROUP
  2994. .PEERDIR_POLICY=as_build_from
  2995. .FINAL_TARGET=yes
  2996. .RESTRICTED=SRCS
  2997. .USE_PEERS_LATE_OUTS=yes
  2998. MODULE_SUFFIX=.ci.pkg.fake
  2999. PEERDIR_TAGS=CPP_PROTO PY3 PY3_NATIVE PY3_BIN PY3TEST_PROGRAM YQL_UDF_SHARED __EMPTY__ DOCSBOOK JAR_RUNNABLE DLL
  3000. }
  3001. # tag:generic tag:internal
  3002. TOUCH_UNIT_MF=$TOUCH_UNIT && $GENERATE_MF
  3003. # tag:proto
  3004. ### @usage: RESOLVE_PROTO()
  3005. ###
  3006. ### Enable include resolving within UNIONs and let system .proto being resolved
  3007. ### among .proto/.gztproto imports
  3008. ###
  3009. ### Note: it is currently impossible to enable resolving only for .proto, so resolving is enabled for all supported files
  3010. ### also we only add ADDINCL for stock protobuf. So use this macro with care: it may cause resolving problems those are
  3011. ### to be addressed by either ADDINCLs or marking them as TEXT. Please contact devtools for details.
  3012. macro RESOLVE_PROTO() {
  3013. SET(DONT_RESOLVE_INCLUDES no)
  3014. ADDINCL(FOR proto $PROTOBUF_PATH)
  3015. }
  3016. ### @usage: UNION(name)
  3017. ###
  3018. ### Collection of PEERDIR dependencies, files and artifacts.
  3019. ### UNION doesn't build its peers, just provides those to modules depending on it.
  3020. ### When specified 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).
  3021. ###
  3022. ### Is only used together with the macros like FILES(), PEERDIR(), COPY(), FROM_SANDBOX(), RUN_PROGRAM or BUNDLE(). Don't use SRCS inside a UNION.
  3023. ###
  3024. ### Documentation: https://wiki.yandex-team.ru/yatool/large-data/
  3025. module UNION: _BASE_UNIT {
  3026. .CMD=UNION_CMD_MF
  3027. .FINAL_TARGET=no
  3028. .ALIASES=SRCS=FILES
  3029. .ALLOWED=EXPLICIT_OUTPUTS
  3030. .IGNORED=VCS_INFO_FILE
  3031. NO_PLATFORM()
  3032. SET(MODULE_SUFFIX .pkg.fake)
  3033. SET(DONT_RESOLVE_INCLUDES yes)
  3034. SET(NEED_PLATFORM_PEERDIRS no)
  3035. PEERDIR_TAGS=CPP_PROTO CPP_FBS PY2 PY2_NATIVE YQL_UDF_SHARED __EMPTY__ DOCSBOOK JAR_RUNNABLE PY3_BIN DLL PACKAGE_UNION
  3036. UNION_OUTS=${hide;late_out:AUTO_INPUT}
  3037. when ($_UNION_EXPLICIT_OUTPUTS) {
  3038. UNION_OUTS=$_EXPAND_INS_OUTS($_UNION_EXPLICIT_OUTPUTS)
  3039. }
  3040. }
  3041. # tag:python-specific
  3042. module _PY_PACKAGE: UNION {
  3043. .EXTS=.py
  3044. .ALLOWED=GRPC USE_SKIFF
  3045. .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER
  3046. ENABLE(PY_PROTOS_FOR)
  3047. SET(PEERDIR_TAGS PY_PROTO)
  3048. SET(DONT_RESOLVE_INCLUDES no)
  3049. }
  3050. # tag:python-specific tag:deprecated tag:internal
  3051. ### @usage: PY_PACKAGE(name) # internal, deprecated
  3052. ###
  3053. ### This is module created via PY_PROTOS_FOR() macro
  3054. module PY_PACKAGE: _PY_PACKAGE {
  3055. .ALIASES=SRCS=SRCS
  3056. .FINAL_TARGET=yes
  3057. }
  3058. # tag:internal
  3059. ### @usage: _SET_FIRST_VALUE(name args...) # internal
  3060. ###
  3061. ### This macro sets the value of `name` variable to the value of next argument
  3062. macro _SET_FIRST_VALUE(NAME, VALUE, OTHER...) {
  3063. SET($NAME $VALUE)
  3064. }
  3065. # tag:python-specific
  3066. PY_NAMESPACE_VALUE=
  3067. # tag:python-specific
  3068. ### @usage: PY_NAMESPACE(prefix)
  3069. ###
  3070. ### Sets default Python namespace for all python sources in the module.
  3071. ### Especially suitable in PROTO_LIBRARY where Python sources are generated and there is no PY_SRCS to place NAMESPACE parameter.
  3072. macro PY_NAMESPACE(Arg) {
  3073. SET(PY_NAMESPACE_VALUE $Arg)
  3074. }
  3075. # tag:internal
  3076. ### @usage: _SRCS_NO_GLOBAL(files...) # internal
  3077. ###
  3078. ### Proxy macro to SRCS macro which filters out GLOBAL keyword from the list of source files.
  3079. ### Useful for modules like EXTERNAL_JAVA_LIBRARY, where GLOBAL keyword cannot be applied properly.
  3080. ### Note: this macro changes order of source files.
  3081. macro _SRCS_NO_GLOBAL(GLOBAL[], FILES...) {
  3082. SRCS($GLOBAL $FILES)
  3083. }
  3084. # tag:java-specific
  3085. JAVA_VCS_MF_ARG=
  3086. COMPILE_JAVA_MF=${hide:JAVA_FAKEID} $COMPILE_JAVA $MAVEN_EXPORT_CMD
  3087. # tag:java-specific
  3088. when ($EXT_JAVA_VCS_INFO == "yes") {
  3089. JAVA_VCS_MF_ARG=--vcs-mf $VCS_JAVA
  3090. COMPILE_JAVA_MF=${hide:JAVA_FAKEID} $GENERATE_VCS_JAVA_INFO_NODEP && $COMPILE_JAVA $MAVEN_EXPORT_CMD
  3091. }
  3092. # tag:java-specific
  3093. EXT_JAVA_VCS_INFO=no
  3094. ### @usage: EMBED_JAVA_VCS_INFO()
  3095. ###
  3096. ### Embed manifest with vcs info into `EXTERNAL_JAVA_LIBRARY`
  3097. ### By default this is disabled.
  3098. macro EMBED_JAVA_VCS_INFO() {
  3099. .SEM=add_vcs_info_to_mf ${hide;output:"VcsInfoMfDummy.java"}
  3100. ENABLE(EXT_JAVA_VCS_INFO)
  3101. }
  3102. # tag:java-specific tag:internal
  3103. ### @usage: EXTERNAL_JAVA_LIBRARY() #internal
  3104. ###
  3105. ### EXTERNAL_JAVA_LIBRARY() is a module for creating a .jar file using non-Java code (generators etc.)
  3106. ### Unlike regular JAVA_LIBRARY this module doesn't produce .pom file, so it cannot be exported to Maven itself.
  3107. ### PEERDIR it from JAVA_LIBRARY or JAVA_PROGRAM for export to Maven.
  3108. module EXTERNAL_JAVA_LIBRARY: _BASE_UNIT {
  3109. .EXTS=.jsrc .java .jar .mf
  3110. .NODE_TYPE=Bundle
  3111. .CMD=COMPILE_JAVA_MF
  3112. # TODO(YMAKE-27) all contribs involved into opensource export must be JAVA_CONTRIB modules
  3113. # and this module must not be intended for export. Such hange will break JBUILD and thus is
  3114. # blocked on YMAKE-27
  3115. .SEM=JAVA_CONTRIB_SEM
  3116. .PEERDIR_POLICY=as_build_from
  3117. .FINAL_TARGET=no
  3118. .ALIASES=SRCS=_SRCS_NO_GLOBAL
  3119. .ALLOWED=EMBED_JAVA_VCS_INFO
  3120. .RESTRICTED=EXTERNAL_JAR
  3121. .GLOBAL=MAVEN_EXPORT_COORDS
  3122. PEERDIR(build/platform/java/jdk)
  3123. PEERDIR+=$JDK_RESOURCE_PEERDIR $EXTERNAL_JAVA_EXTRA_PEERDIR
  3124. when ($KOTLIN_PROTO == "yes") {
  3125. PEERDIR+=build/platform/java/kotlin contrib/java/org/jetbrains/kotlin/kotlin-stdlib-jdk8/${KOTLIN_VERSION}
  3126. }
  3127. when ($MAVEN_EXPORT == "yes") {
  3128. when ($MAVEN_DEPLOY == "yes") {
  3129. PEERDIR+=build/external_resources/maven
  3130. MAVEN_EXPORT_CMD= && $MAVEN_EXPORT_GEN_DEPLST && $MAVEN_EXPORT_GEN_POM && $MAVEN_DEPLOY_CMD
  3131. }
  3132. otherwise {
  3133. MAVEN_EXPORT_CMD= && $MAVEN_EXPORT_GEN_DEPLST && $MAVEN_EXPORT_GEN_POM
  3134. }
  3135. MAVEN_EXPORT_COORDS_GLOBAL=$MAVEN_EXPORT_GOUP_ID:${MODULE_PREFIX}${REALPRJNAME}:${MAVEN_EXPORT_VERSION}:
  3136. }
  3137. PEERDIR_TAGS=JAVA_PROTO JAVA_FBS JAVA_IDL PACKAGE_UNION
  3138. HAS_MANAGEABLE_PEERS=yes
  3139. DYNAMIC_LINK=yes
  3140. MACRO_ALIAS(PROTO_CMD _JAVA_PROTO_CMD)
  3141. MACRO_ALIAS(EVLOG_CMD _JAVA_EVLOG_CMD)
  3142. MACRO_ALIAS(FBS_CMD _JAVA_FLATC_CMD)
  3143. when ($PACKAGE_PREFIX) {
  3144. PACKAGE_PREFIX_ARGS=--package-prefix=$PACKAGE_PREFIX
  3145. }
  3146. DISABLE(NEED_PLATFORM_PEERDIRS)
  3147. NO_PLATFORM()
  3148. SET(MODULE_SUFFIX .jar)
  3149. SET(MODULE_LANG JAVA)
  3150. _WHEN_EXPORT_GRADLE()
  3151. }
  3152. # tag:java-specific
  3153. ALL_JAR_SOURCES=
  3154. LINT_JAVA_SOURCES=
  3155. ALL_SRCDIRS=
  3156. LINK_JAR_RESOURCES=
  3157. LINK_JAR_JSOURCES=
  3158. JAR_GEN_SRCS=
  3159. JAR_GEN_JSRCS=
  3160. macro _JAR_SRCS(SRCDIR=".", PACKAGE_PREFIX="", EXCLUDE[], FILES[], RESOURCES?"yes":"no", Globs...) {
  3161. _CHECK_JAVA_SRCDIR($SRCDIR)
  3162. SET_APPEND(ALL_SRCDIRS $SRCDIR)
  3163. SET(VAR_SALT $SRCDIR $Globs $EXCLUDE $PACKAGE_PREFIX $RESOURCES $FILES)
  3164. SET(JAR_SRCS_GLOB uniq_${hash:VAR_SALT})
  3165. _LATE_GLOB(${JAR_SRCS_GLOB} ${pre=${SRCDIR}/:Globs} EXCLUDE ${EXCLUDE})
  3166. SET_APPEND(LINT_JAVA_SOURCES \${input;rootrel;ext=.java:${JAR_SRCS_GLOB}})
  3167. 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})
  3168. _FILL_JAR_COPY_RESOURCES_CMD(LINK_JAR_RESOURCES ${quo:SRCDIR} ${BINDIR}/cls ${PACKAGE_PREFIX} ${BINDIR}/misc/${tolower:JAR_SRCS_GLOB}.res.txt)
  3169. _FILL_JAR_COPY_RESOURCES_CMD(LINK_JAR_JSOURCES ${quo:SRCDIR} ${BINDIR}/src ${PACKAGE_PREFIX} ${BINDIR}/misc/${tolower:JAR_SRCS_GLOB}.src.txt)
  3170. _FILL_JAR_GEN_SRCS(JAR_GEN_SRCS JAR $SRCDIR ${BINDIR}/cls ${BINDIR}/all-java.srclst $KT_SRCLIST ${BINDIR}/misc/all-gr-sources.txt ${BINDIR}/misc/${tolower:JAR_SRCS_GLOB}.res.txt $Globs EXCLUDE $EXCLUDE)
  3171. _FILL_JAR_GEN_SRCS(JAR_GEN_JSRCS SRC_JAR $SRCDIR ${BINDIR}/cls ${BINDIR}/all-java.srclst $KT_SRCLIST ${BINDIR}/misc/all-gr-sources.txt ${BINDIR}/misc/${tolower:JAR_SRCS_GLOB}.src.txt $Globs EXCLUDE $EXCLUDE)
  3172. }
  3173. macro IDEA_JAR_SRCS(Args...) {
  3174. _JAR_SRCS($Args)
  3175. SET_APPEND(JAVA_SRCS_VALUE $ARGS_DELIM $Args)
  3176. }
  3177. macro _HASH_HELPER(Args...) {
  3178. .CMD=${hash:Args}
  3179. .SEM=${hash:Args}
  3180. }
  3181. macro _GENTAR_HELPER(OUT_DIR[], Args...) {
  3182. .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"}
  3183. }
  3184. # tag:java-specific
  3185. RUN_JAR_PROG_CP_PRE=@
  3186. RUN_JAR_PROG_CP_SUF=.cplst
  3187. when($JDK_VERSION == "8") {
  3188. RUN_JAR_PROG_CP_PRE=
  3189. RUN_JAR_PROG_CP_SUF=
  3190. }
  3191. # tag:java-specific
  3192. JDK_LATEST_VERSION=19
  3193. JDK_LATEST_PEERDIR=build/platform/java/jdk/jdk${JDK_LATEST_VERSION}
  3194. # tag:java-specific
  3195. 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...) {
  3196. _LATE_GLOB(${IN_DIRS_VAR} ${suf=/**/*:IN_DIR})
  3197. _CHECK_RUN_JAVA_PROG_CLASSPATH($CLASSPATH)
  3198. .PEERDIR=build/platform/java/jdk $JDK_RESOURCE_PEERDIR
  3199. .CMD=${kv;hide:"p RJ"} ${kv;hide:"pc blue"} ${hide:JAVA_FAKEID} ${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}
  3200. }
  3201. # tag:java-specific
  3202. macro _DO_1_RUN_JAR_PROGRAM(IN_DIRS_VAR="uniq", Args...) {
  3203. _DO_2_RUN_JAR_PROGRAM($Args IN_DIRS_VAR $IN_DIRS_VAR IN_DIRS_INPUTS ${"$"}{input;hide:$IN_DIRS_VAR})
  3204. }
  3205. # tag:java-specific
  3206. macro RUN_JAVA_PROGRAM(Args...) {
  3207. _DO_1_RUN_JAR_PROGRAM($Args IN_DIRS_VAR uniq_${hash:Args})
  3208. }
  3209. # tag:java-specific
  3210. _JAR_ANN_PROCESSORS=
  3211. _JAR_ANN_PROC_OPT_PREFIX=
  3212. macro JAR_ANNOTATION_PROCESSOR(Classes...) {
  3213. SET_APPEND(_JAR_ANN_PROCESSORS $Classes)
  3214. SET(_JAR_ANN_PROC_OPT_PREFIX -processor)
  3215. # for ya ide idea only
  3216. SET_APPEND(ANNOTATION_PROCESSOR_VALUE $ARGS_DELIM $Classes)
  3217. }
  3218. # tag:java-specific
  3219. macro _JAR_ANN_PROC_OPTS(Classes...) {
  3220. .CMD=$_JAR_ANN_PROC_OPT_PREFIX ${join=,:Classes}
  3221. }
  3222. # tag:java-specific
  3223. macro _NOOP_MACRO(Args...) {
  3224. ENABLE(UNUSED_MACRO)
  3225. }
  3226. # tag:java-specific
  3227. module _JAR_BASE: _BARE_UNIT {
  3228. .NODE_TYPE=Bundle
  3229. .CMD=TOUCH_UNIT
  3230. .PEERDIR_POLICY=as_build_from
  3231. .FINAL_TARGET=no
  3232. .ALIASES=SRCS=_SRCS_NO_GLOBAL
  3233. .ALLOWED=EMBED_JAVA_VCS_INFO DEPENDENCY_MANAGEMENT EXCLUDE
  3234. .DEFAULT_NAME_GENERATOR=TwoDirNames
  3235. .RESTRICTED=WITH_JDK RESOURCE RESOURCE_FILES
  3236. PEERDIR_TAGS=JAVA_PROTO JAVA_FBS JAVA_IDL DLL JAR_COMPILATION __EMPTY__
  3237. HAS_MANAGEABLE_PEERS=yes
  3238. DYNAMIC_LINK=yes
  3239. MACRO_ALIAS(PROTO_CMD _JAVA_PROTO_CMD)
  3240. MACRO_ALIAS(EVLOG_CMD _JAVA_EVLOG_CMD)
  3241. MACRO_ALIAS(FBS_CMD _JAVA_FLATC_CMD)
  3242. DISABLE(NEED_PLATFORM_PEERDIRS)
  3243. NO_PLATFORM()
  3244. VCS_JAVA=${suf=.__vcs_version__.mf:TARGET}
  3245. SET(MODULE_LANG JAVA)
  3246. _WHEN_EXPORT_GRADLE()
  3247. }
  3248. JAVA_CONTRIB_PROXY_SEM=IGNORED
  3249. # tag:java-specific
  3250. module JAVA_CONTRIB_PROXY: _JAR_BASE {
  3251. .SEM=JAVA_CONTRIB_PROXY_SEM
  3252. }
  3253. # tag:java-specific
  3254. macro _FETCH_CONTRIB(Id, Out, SBR="sbr:") {
  3255. .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"}
  3256. ADD_CHECK(check.resource $Id)
  3257. }
  3258. # tag:java-specific
  3259. LOCAL_JAR_PATH=
  3260. LOCAL_SOURCES_JAR_PATH=
  3261. JAR_RESOURCE_ID=
  3262. SRC_RESOURCE_ID=
  3263. FETCH_SRCS_JAR=
  3264. FETCH_TARGET_JAR=
  3265. FETCH_CONTRIB_JAR=${hide:JAVA_FAKEID} $FETCH_TARGET_JAR $FETCH_SRCS_JAR
  3266. # tag:java-specific
  3267. macro JAR_RESOURCE(Id) {
  3268. SET(JAR_RESOURCE_ID $Id)
  3269. }
  3270. # tag:java-specific
  3271. macro SRC_RESOURCE(Id) {
  3272. SET(SRC_RESOURCE_ID $Id)
  3273. }
  3274. # tag:java-specific
  3275. macro LOCAL_JAR(File) {
  3276. SET(LOCAL_JAR_PATH $File)
  3277. }
  3278. # tag:java-specific
  3279. macro LOCAL_SOURCES_JAR(File) {
  3280. SET(LOCAL_SOURCES_JAR_PATH $File)
  3281. }
  3282. JAVA_CONTRIB_SEM=consumer_classpath $_EXPORT_GRADLE_PROJECT_COORDS ${hide:TARGET} ${hide:AUTO_INPUT} && IGNORED
  3283. # tag:java-specific
  3284. module JAVA_CONTRIB: _JAR_BASE {
  3285. .CMD=FETCH_CONTRIB_JAR
  3286. .SEM=JAVA_CONTRIB_SEM
  3287. .FINAL_TARGET=yes
  3288. .GLOBAL=MAVEN_EXPORT_COORDS
  3289. when ($JAR_RESOURCE_ID) {
  3290. FETCH_TARGET_JAR= && $_FETCH_CONTRIB($JAR_RESOURCE_ID ${BINDIR}/${MODULE_PREFIX}${REALPRJNAME}${MODULE_SUFFIX})
  3291. }
  3292. otherwise {
  3293. when ($LOCAL_JAR_PATH) {
  3294. FETCH_TARGET_JAR= && $FS_TOOLS copy ${input:LOCAL_JAR_PATH} $TARGET
  3295. }
  3296. otherwise {
  3297. FETCH_TARGET_JAR= && $GENERATE_VCS_JAVA_INFO_NODEP && ${cwd:BINDIR} $JDK_RESOURCE/bin/jar cfvm $TARGET $VCS_JAVA .
  3298. PEERDIR+=build/platform/java/jdk
  3299. PEERDIR+=$JDK_RESOURCE_PEERDIR
  3300. }
  3301. }
  3302. when ($SRC_RESOURCE_ID) {
  3303. FETCH_SRCS_JAR= && $_FETCH_CONTRIB($SRC_RESOURCE_ID ${BINDIR}/${REALPRJNAME}-sources.jar)
  3304. }
  3305. otherwise {
  3306. when ($LOCAL_SOURCES_JAR_PATH) {
  3307. FETCH_SRCS_JAR= && $FS_TOOLS copy ${input:LOCAL_SOURCES_JAR_PATH} {output;pre=${BINDIR}/;suf=-sources.jar:REALPRJNAME}
  3308. }
  3309. otherwise {
  3310. 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 .
  3311. PEERDIR+=build/platform/java/jdk
  3312. PEERDIR+=$JDK_RESOURCE_PEERDIR
  3313. }
  3314. }
  3315. when ($MAVEN_EXPORT == "yes") {
  3316. _MAKEFILE_INCLUDE_LIKE_DEPS+=pom.xml
  3317. FETCH_CONTRIB_JAR+= && $MAVEN_EXPORT_GEN_DEPLST
  3318. }
  3319. SET(MODULE_SUFFIX .jar)
  3320. _SETUP_MAVEN_EXPORT_COORDS_IF_NEED($MODDIR)
  3321. }
  3322. MAKE_JAVA_CLASSPATH_FILE=$YMAKE_PYTHON ${input:"build/scripts/make_java_classpath_file.py"} ${input;hide:"build/scripts/process_command_files.py"}
  3323. # tag:kotlin-specific
  3324. KOTLINC_OPTS_VALUE=
  3325. # tag:kotlin-specific
  3326. KT_SRCLIST=${BINDIR}/misc/all-kt-sources.txt
  3327. KT_SRSCLIST_FLAG=--kotlin $KT_SRCLIST
  3328. KT_CLASSES_DIR=${BINDIR}/kt_cls
  3329. KT_CLASSPATH=${BINDIR}/kt_cp.txt
  3330. COLLECT_KT_CLASSPATH=${WRITER_PY} --file ${BINDIR}/kt_bfg.txt -m --ya-start-command-file ${ext=.jar:MANAGED_PEERS_CLOSURE} --ya-end-command-file
  3331. LINK_KT_CLASSPATH=${MAKE_JAVA_CLASSPATH_FILE} ${BINDIR}/kt_bfg.txt $KT_CLASSPATH && $FS_TOOLS md $KT_CLASSES_DIR
  3332. COMPILE_KT= \
  3333. ${cwd:ARCADIA_BUILD_ROOT} ${env:"LC_ALL=en_US.UTF-8"} $YMAKE_PYTHON ${input:"build/scripts/with_pathsep_resolve.py"} $YMAKE_PYTHON ${input:"build/scripts/run_javac.py"} --kotlin --sources-list $KT_SRCLIST \
  3334. $JDK_RESOURCE/bin/java -jar $KOTLIN_COMPILER_RESOURCE_GLOBAL/kotlin-compiler.jar -no-stdlib -module-name $REALPRJNAME -jvm-target ${KOTLIN_JVM_TARGET} \
  3335. @$KT_SRCLIST -classpath @$KT_CLASSPATH $KOTLINC_FLAGS_VALUE -d $KT_CLASSES_DIR $KOTLINC_OPTS_VALUE
  3336. ALL_KT_COMMANDS=
  3337. KT_CLASSPATH_ITEM=
  3338. # tag:kotlin-specific
  3339. KT_KAPT_SOURCES_DIR=${BINDIR}/kapt_gen_src
  3340. KT_KAPT_STUBS_DIR=${BINDIR}/kapt_gen_stubs
  3341. KT_KAPT_AP_CLASSPATH=
  3342. KT_KAPT_PLUGIN_OPTS=-P plugin:org.jetbrains.kotlin.kapt3:sources=${KT_KAPT_SOURCES_DIR} -P plugin:org.jetbrains.kotlin.kapt3:classes=${KT_CLASSES_DIR} -P plugin:org.jetbrains.kotlin.kapt3:stubs=${KT_KAPT_STUBS_DIR} -P plugin:org.jetbrains.kotlin.kapt3:aptMode=stubsAndApt
  3343. ### @usage: KAPT_OPTS(opts...)
  3344. ###
  3345. ### Used to specify annotation processor qualified class names.
  3346. ### If specified multiple times, only last specification is used.
  3347. macro KAPT_OPTS(Args...) {
  3348. SET_APPEND(KT_KAPT_PLUGIN_OPTS ${pre=-P :Args})
  3349. }
  3350. ### @usage: KAPT_ANNOTATION_PROCESSOR(processors...)
  3351. ###
  3352. ### Used to specify annotation processor qualified class names.
  3353. ### If specified multiple times, only last specification is used.
  3354. macro KAPT_ANNOTATION_PROCESSOR(Args...) {
  3355. KAPT_OPTS(${pre="plugin:org.jetbrains.kotlin.kapt3:processors=":Args})
  3356. }
  3357. ### @usage: KAPT_ANNOTATION_PROCESSOR_CLASSPATH(jars...)
  3358. ###
  3359. ### Used to specify classpath for annotation processors.
  3360. ### If specified multiple times, all specifications are used.
  3361. macro KAPT_ANNOTATION_PROCESSOR_CLASSPATH(Args...) {
  3362. PEERDIR($Args)
  3363. SET_APPEND(KT_KAPT_AP_CLASSPATH $Args)
  3364. }
  3365. # tag:java-specific
  3366. JAVAC_CMD=$JDK_RESOURCE/bin/javac
  3367. 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
  3368. # tag:java-specific tag:codenav
  3369. JAVA_YNDEXING=no
  3370. # tag:java-specific
  3371. when ($USE_SYSTEM_KYTHE) {
  3372. KYTHE_RESOURCE=$USE_SYSTEM_KYTHE
  3373. }
  3374. otherwise {
  3375. KYTHE_RESOURCE=$KYTHE_RESOURCE_GLOBAL
  3376. }
  3377. # tag:java-specific tag:codenav
  3378. _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
  3379. _DO_JAVA_YNDEXING=
  3380. # tag:java-specific
  3381. SOURCES_JAR=no
  3382. when ($BUILD_TYPE == "DEBUG" && $NO_DEBUGINFO != "yes") {
  3383. SOURCES_JAR=yes
  3384. }
  3385. _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 .
  3386. _PACK_SRC_JAR=
  3387. # tag:java-specific
  3388. _PACK_JNI=
  3389. _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
  3390. # tag:java-specific
  3391. _MAKE_JSTYLE_FILE_LIST=
  3392. # tag:java-specific
  3393. _LINK_UBERJAR=
  3394. _UBERJAR_SELF=
  3395. _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} \
  3396. && $YMAKE_PYTHON ${input:"build/scripts/mkdir.py"} $BINDIR/_empty/META-INF \
  3397. && $YMAKE_PYTHON ${input:"build/scripts/touch.py"} $BINDIR/_empty/META-INF/MANIFEST.MF \
  3398. && $UPDATE_VCS_JAVA_INFO_NODEP($TARGET) \
  3399. && ${cwd;suf=/_empty:BINDIR} ${JDK_RESOURCE}/bin/jar ufv ${TARGET} META-INF/MANIFEST.MF \
  3400. && $JDK_RESOURCE/bin/jar ufvm $TARGET $VCS_JAVA
  3401. # tag:java-specific
  3402. macro _PACK_JAR_HELPER(Out) {
  3403. .CMD=${cwd;suf=/cls:BINDIR} ${env:"LC_ALL=en_US.UTF-8"} $JDK_RESOURCE/bin/jar cfvm $Out $VCS_JAVA .
  3404. }
  3405. # tag:java-specific
  3406. macro _JAVAC_RUN_HELPER(JAVAC_CMD_WITH_ARGS...) {
  3407. .CMD=${cwd:ARCADIA_BUILD_ROOT} ${env:"LC_ALL=en_US.UTF-8"} $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
  3408. }
  3409. macro _ADD_HIDDEN_INPUTS(Inputs...) {
  3410. .CMD=${input;hide:Inputs}
  3411. }
  3412. # tag:java-specific
  3413. 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
  3414. ERROR_PRONE_2_7_1_FORCED_OPTS=-Xep:InlineMeInliner:OFF -Xep:SameNameButDifferent:OFF
  3415. # tag:java-specific
  3416. macro _ADD_OPTS_IF_NON_EMPTY(Opt, Args...) {
  3417. .CMD=${pre=$Opt :Args}
  3418. }
  3419. macro _ADD_GEN_POM_FROM_COORD_FILES_ARGS(Deps...) {
  3420. .CMD=${pre=--deps-coords ;ext=.jar;suf=.mvn_coords:Deps}
  3421. }
  3422. MAVEN_EXPORT_OUT_DIR_FLAG=$_ADD_OPTS_IF_NON_EMPTY(--output-dir ${MAVEN_EXPORT_OUT_DIR})
  3423. MAVEN_EXPORT_SOURCE_DIRS=$_ADD_OPTS_IF_NON_EMPTY(--source-dirs ${ALL_SRCDIRS})
  3424. MAVEN_EXPORT_DEPS_COORS=$_ADD_GEN_POM_FROM_COORD_FILES_ARGS(${MANAGED_PEERS_CLOSURE})
  3425. MAVEN_EXPORT_OUT_DIR=
  3426. MAVEN_EXPORT=no
  3427. MAVEN_DEPLOY=no
  3428. MAVEN_DEPLOY_SOURCES=
  3429. MAVEN_EXPORT_VERSION={vcs_revision}
  3430. MAVEN_EXPORT_GEN_DEPLST= \
  3431. $WRITER_PY \
  3432. --file ${output;pre=$MODULE_PREFIX;suf=$MODULE_SUFFIX.mvn_coords:REALPRJNAME} \
  3433. --ya-start-command-file -m ${pre=D=:MAVEN_EXPORT_COORDS_GLOBAL} ${pre=E=:EXCLUDED_MAVEN_EXPORT_COORDS_GLOBAL} --ya-end-command-file \
  3434. ${hide:APPLIED_EXCLUDES}
  3435. MAVEN_EXPORT_GEN_POM=${kv;hide:"mvn_export yes"} \
  3436. $YMAKE_PYTHON ${input:"build/scripts/generate_pom.py"} \
  3437. --from-coord-files \
  3438. --vcs-info $(VCS)/vcs.json \
  3439. --target-path $MODDIR \
  3440. $MAVEN_EXPORT_SOURCE_DIRS \
  3441. $MAVEN_EXPORT_DEPS_COORS \
  3442. $MAVEN_EXPORT_OUT_DIR_FLAG \
  3443. --target-coords ${suf=.mvn_coords:TARGET} \
  3444. --pom-path ${output:"pom.xml"}
  3445. MAVEN_DEPLOY_CMD=$YMAKE_PYTHON ${input:"build/scripts/stdout2stderr.py"} $MAVEN_BIN \
  3446. deploy:deploy-file -DpomFile=$BINDIR/pom.xml \
  3447. -Dfile=$TARGET -DrepositoryId=$MAVEN_REPO_ID -Durl=$MAVEN_REPO_URL -Djava.net.preferIPv4Addresses=false -Djava.net.preferIPv6Addresses=true \
  3448. ${MAVEN_DEPLOY_SOURCES} \
  3449. $_ADD_OPTS_IF_NON_EMPTY(-gs $MAVEN_EXPORT_SETTINGS) \
  3450. $_ADD_OPTS_IF_NON_EMPTY(-s $MAVEN_EXPORT_SETTINGS)
  3451. MAVEN_EXPORT_CMD=
  3452. # tag:java-specific
  3453. JAVA_COVERAGE_SRCLIST_FLAG=--coverage ${output;pre=${MODULE_PREFIX};suf=.cpsf:REALPRJNAME} --source-root ${ARCADIA_ROOT}
  3454. JAVA_COVERAGE_SRCLIST=
  3455. PREPARE_JAVA_BUILD_DIRS=$FS_TOOLS md ${BINDIR}/cls && $FS_TOOLS md ${BINDIR}/misc
  3456. EXTRACT_GENDIRS=${cwd:BINDIR} $YMAKE_PYTHON ${input:"build/scripts/autotar_gendirs.py"} --unpack --ext .gentar ${ext=.gentar:AUTO_INPUT}
  3457. COLLECT_JAVA_SRCLIST=${YMAKE_PYTHON} ${input:"build/scripts/make_java_srclists.py"} ${input;hide:"build/scripts/process_command_files.py"} ${input;hide:"build/scripts/java_pack_to_file.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
  3458. COLLECT_CLASSPATH=${WRITER_PY} --file ${BINDIR}/bfg.txt -m --ya-start-command-file ${rootrel:MANAGED_PEERS_CLOSURE} $KT_CLASSPATH_ITEM --ya-end-command-file
  3459. LINK_CLASSPATH=${YMAKE_PYTHON} ${input:"build/scripts/make_manifest_from_bf.py"} ${BINDIR}/bfg.txt ${ARCADIA_BUILD_ROOT}/bfg.jar
  3460. COMPILE_JAVA_SRCLIST=$_JAVAC_RUN_HELPER($JAVAC_CMD)
  3461. PACK_JAR=$_PACK_JAR_HELPER($TARGET)
  3462. # NOTE: No && before LINK_JAR_RESOURCES, ALL_KT_COMMANDS and JAR_GEN_SRCS needed since those vars either empty or starts with &&
  3463. LINK_JAR=${hide:JAVA_FAKEID} ${kv;hide:"p JV"} ${kv;hide:"pc light-blue"} ${kv;hide:"show_out"} ${requirements;hide:"cpu:2"} \
  3464. $PREPARE_JAVA_BUILD_DIRS \
  3465. && $EXTRACT_GENDIRS \
  3466. && $COLLECT_JAVA_SRCLIST \
  3467. $JAR_GEN_SRCS \
  3468. $ALL_KT_COMMANDS \
  3469. && $COLLECT_CLASSPATH \
  3470. && $LINK_CLASSPATH \
  3471. && $COMPILE_JAVA_SRCLIST \
  3472. $LINK_JAR_RESOURCES \
  3473. && ${cwd;suf=/cls:BINDIR} $GENERATE_VCS_JAVA_INFO_NODEP . \
  3474. $_PACK_SRC_JAR \
  3475. $_PACK_JNI \
  3476. && $PACK_JAR \
  3477. $_DO_JAVA_YNDEXING \
  3478. $_MAKE_JSTYLE_FILE_LIST \
  3479. $_LINK_UBERJAR \
  3480. $MAVEN_EXPORT_CMD \
  3481. $_ADD_HIDDEN_INPUTS($JAVA_EXTERNAL_DEPENDENCIES_VALUE)
  3482. # tag:java-specific
  3483. _EXT_SRC_JAR=
  3484. _EXT_JAR=
  3485. _COPY_EXT_SRC_JAR= && $FS_TOOLS md ${BINDIR}/empty && ${cwd;suf=/empty:BINDIR} $JDK_RESOURCE/bin/jar cfvM ${output;pre=${BINDIR}/${MODULE_PREFIX};suf=-sources.jar:REALPRJNAME} .
  3486. _DO_USE_EXT_JAR=${hide:JAVA_FAKEID} $FS_TOOLS copy ${input:_EXT_JAR} $TARGET $_COPY_EXT_SRC_JAR $MAVEN_EXPORT_CMD
  3487. _DO_COPY_EXT_SRC_JAR= && $FS_TOOLS copy $_EXT_SRC_JAR ${output;pre=${BINDIR}/${MODULE_PREFIX};suf=-sources.jar:REALPRJNAME}
  3488. macro JAVA_RESOURCE(JAR, SOURCES="") {
  3489. SET(_EXT_SRC_JAR $SOURCES)
  3490. SET(_EXT_JAR $JAR)
  3491. }
  3492. # tag:java-specific tag:fbs
  3493. JAVA_FLATBUFFERS_VERSION = 2.0.0
  3494. # tag:java-specific
  3495. module _COMPILABLE_JAR_BASE : _JAR_BASE {
  3496. # flatbuffers-java
  3497. DEPENDENCY_MANAGEMENT(contrib/java/com/google/flatbuffers/flatbuffers-java/${JAVA_FLATBUFFERS_VERSION})
  3498. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/com/google/flatbuffers/flatbuffers-java EXCEPT contrib/java/com/google/flatbuffers/flatbuffers-java/${JAVA_FLATBUFFERS_VERSION})
  3499. # protobuf-java
  3500. DEPENDENCY_MANAGEMENT(contrib/java/com/google/protobuf/protobuf-java/${JAVA_PROTO_RUNTIME_VERSION})
  3501. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/com/google/protobuf/protobuf-java EXCEPT contrib/java/com/google/protobuf/protobuf-java/${JAVA_PROTO_RUNTIME_VERSION})
  3502. # protobuf-javalite
  3503. DEPENDENCY_MANAGEMENT(contrib/java/com/google/protobuf/protobuf-javalite/${JAVA_PROTO_RUNTIME_VERSION})
  3504. CHECK_DEPENDENT_DIRS(DENY PEERDIRS contrib/java/com/google/protobuf/protobuf-javalite EXCEPT contrib/java/com/google/protobuf/protobuf-javalite/${JAVA_PROTO_RUNTIME_VERSION})
  3505. # protobuf-java-util
  3506. DEPENDENCY_MANAGEMENT(contrib/java/com/google/protobuf/protobuf-java-util/${JAVA_PROTO_RUNTIME_VERSION})
  3507. 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})
  3508. }
  3509. _JAR_MAIN_CLASS=
  3510. macro JAR_MAIN_CLASS(Class) {
  3511. SET(_JAR_MAIN_CLASS ${Class})
  3512. }
  3513. _JAR_MAIN_SEM=
  3514. _ADD_JAR_MAIN_SEM= && app_main_class ${_JAR_MAIN_CLASS}
  3515. GRADLE_EXPORT_PUBLISHING=no
  3516. _GRADLE_EXPORT_PUBLISHING_SEM=
  3517. PUBLISH_MAVEN_VERSION=no
  3518. _DO_GRADLE_EXPORT_PUBLISHING_SEM= && publish True && publish_group $MAVEN_EXPORT_GOUP_ID && publish_version $PUBLISH_MAVEN_VERSION
  3519. BUILD_JAR_SEM=jar $MODDIR $REALPRJNAME ${hide:TARGET} ${hide:AUTO_INPUT} && applied_excludes $APPLIED_EXCLUDES && consumer_classpath $_EXPORT_GRADLE_PROJECT_COORDS $_JAR_MAIN_SEM $_GRADLE_EXPORT_PUBLISHING_SEM
  3520. ### _EXPORT_GRADLE_TARGET_ATTR(NAME, VALUE...)
  3521. ###
  3522. ### Add target attribute `NAME` for .SEM if `VALUE` is non-empty
  3523. ### ` && $Name $Value
  3524. macro _EXPORT_GRADLE_TARGET_ATTR(NAME, VALUE...) {
  3525. .SEM=${pre= && $NAME :VALUE}
  3526. }
  3527. BUILD_PROTO_JAR_SEM=jar_proto $MODDIR $REALPRJNAME ${hide:target} ${hide:AUTO_INPUT} && consumer_classpath $_EXPORT_GRADLE_PROJECT_COORDS $_EXPORT_GRADLE_TARGET_ATTR(proto_namespace $PROTO_NAMESPACE) $_EXPORT_GRADLE_TARGET_ATTR(proto_grpc ${ext=yes:_GRPC_ENABLED})
  3528. # tag:java-specific tag:internal
  3529. ### @usage: JAR_LIBRARY() #internal
  3530. ###
  3531. ### Reimplementation of the JAVA_LIBRARY with ymake.core.conf and ymake based dependency management
  3532. module JAR_LIBRARY: _COMPILABLE_JAR_BASE {
  3533. .EXTS=.jsrc .java .jar .mf .gentar .kt
  3534. .CMD=LINK_JAR
  3535. .SEM=BUILD_JAR_SEM
  3536. .FINAL_TARGET=yes
  3537. .ALIASES=JAVA_SRCS=IDEA_JAR_SRCS ANNOTATION_PROCESSOR=JAR_ANNOTATION_PROCESSOR
  3538. .RESTRICTED=EXTERNAL_JAR
  3539. .GLOBAL=MAVEN_EXPORT_COORDS
  3540. MODULE_SUFFIX=.jar
  3541. PEERDIR(build/platform/java/jdk)
  3542. PEERDIR+=$JDK_RESOURCE_PEERDIR
  3543. when ($_EXT_SRC_JAR) {
  3544. _COPY_EXT_SRC_JAR=_DO_COPY_EXT_SRC_JAR
  3545. }
  3546. when ($_EXT_JAR) {
  3547. LINK_JAR=$_DO_USE_EXT_JAR
  3548. }
  3549. when ($OPENSOURCE_EXPORT == "no") {
  3550. BUILD_JAR_SEM=IGNORED
  3551. }
  3552. when ($_JAR_MAIN_CLASS) {
  3553. _JAR_MAIN_SEM=$_ADD_JAR_MAIN_SEM
  3554. }
  3555. when ($GRADLE_EXPORT_PUBLISHING == "yes") {
  3556. _GRADLE_EXPORT_PUBLISHING_SEM=$_DO_GRADLE_EXPORT_PUBLISHING_SEM
  3557. }
  3558. # in the ideal world this statement must be under condition bellow
  3559. DEPENDENCY_MANAGEMENT(contrib/java/org/jetbrains/kotlin/kotlin-stdlib-jdk8/${KOTLIN_VERSION})
  3560. when ($WITH_KOTLIN_VALUE) {
  3561. KT_SRSCLIST=$KT_SRSCLIST_FLAG
  3562. _MAKE_LINT_KT_FILES_LIST = $YMAKE_PYTHON ${input:"build/scripts/kt_copy.py"} $KT_SRCLIST ${output;noauto:"all-kt-sources.txt"} $(SOURCE_ROOT) $(BUILD_ROOT)
  3563. ALL_KT_COMMANDS=&& $COLLECT_KT_CLASSPATH && $LINK_KT_CLASSPATH
  3564. when ($WITH_KAPT_VALUE == "yes") {
  3565. # For Kapt usage see: https://kotlinlang.org/docs/kapt.html#using-in-cli
  3566. # See for kapt.kotlin.generated: https://github.com/JetBrains/kotlin/blob/master/plugins/kapt3/kapt3-cli/testData/integration/kotlinFileGeneration/build.txt
  3567. _KAPT_OPTS=-Xplugin=${tool:"contrib/java/org/jetbrains/kotlin/kotlin-annotation-processing/1.8.20"} $KT_KAPT_PLUGIN_OPTS
  3568. _RUN_KAPT=${YMAKE_PYTHON} ${input:"build/scripts/with_kapt_args.py"} ${pre=--ap-classpath :KT_KAPT_AP_CLASSPATH} -- $COMPILE_KT $_KAPT_OPTS
  3569. _APPEND_KAPT_GENERATED_SRCS=$YMAKE_PYTHON ${input:"build/scripts/resolve_java_srcs.py"} -d $KT_KAPT_SOURCES_DIR --include-patterns '**/*.java' '**/*.kt' --resolve-kotlin --append -s ${BINDIR}/all-java.srclst -k $KT_SRCLIST -r ${BINDIR}/not-used.txt
  3570. ALL_KT_COMMANDS+=&& $_RUN_KAPT && $_APPEND_KAPT_GENERATED_SRCS
  3571. }
  3572. ALL_KT_COMMANDS+=&& $COMPILE_KT && $_MAKE_LINT_KT_FILES_LIST
  3573. LINK_JAR_RESOURCES+=&& $FS_TOOLS copy_all_files ${KT_CLASSES_DIR} ${BINDIR}/cls
  3574. PEERDIR+=build/platform/java/kotlin contrib/java/org/jetbrains/kotlin/kotlin-stdlib-jdk8
  3575. when($WITH_KOTLINC_PLUGIN_ALLOPEN) {
  3576. KOTLINC_OPTS_VALUE+=-Xplugin=${KOTLIN_COMPILER_RESOURCE_GLOBAL}/plugins/kotlin-allopen-plugin.jar
  3577. }
  3578. when($WITH_KOTLINC_PLUGIN_LOMBOK) {
  3579. KOTLINC_OPTS_VALUE+=-Xplugin=${KOTLIN_COMPILER_RESOURCE_GLOBAL}/plugins/kotlin-lombok-plugin.jar
  3580. }
  3581. when($WITH_KOTLINC_PLUGIN_NOARG) {
  3582. KOTLINC_OPTS_VALUE+=-Xplugin=${KOTLIN_COMPILER_RESOURCE_GLOBAL}/plugins/kotlin-noarg-plugin.jar
  3583. }
  3584. when($WITH_KOTLINC_PLUGIN_SERIALIZATION) {
  3585. KOTLINC_OPTS_VALUE+=-Xplugin=${KOTLIN_COMPILER_RESOURCE_GLOBAL}/plugins/kotlin-serialization-plugin.jar
  3586. }
  3587. # Must be in sync with KT_CLASSES_DIR!
  3588. # There are problems in JDK13 with abs paths in classpath baked into jar file manifest. Using relative path
  3589. # here assumes that jar file with classpath for javac located in the $ARCADIA_BUILD_ROOT
  3590. KT_CLASSPATH_ITEM=$MODDIR/kt_cls
  3591. }
  3592. otherwise {
  3593. KT_SRSCLIST=
  3594. ALL_KT_COMMANDS=
  3595. KT_CLASSES=
  3596. }
  3597. when ($MAVEN_EXPORT == "yes") {
  3598. when ($MAVEN_DEPLOY == "yes") {
  3599. PEERDIR+=build/external_resources/maven
  3600. MAVEN_EXPORT_CMD= && $MAVEN_EXPORT_GEN_DEPLST && $MAVEN_EXPORT_GEN_POM && $MAVEN_DEPLOY_CMD
  3601. }
  3602. otherwise {
  3603. MAVEN_EXPORT_CMD= && $MAVEN_EXPORT_GEN_DEPLST && $MAVEN_EXPORT_GEN_POM
  3604. }
  3605. MAVEN_EXPORT_COORDS_GLOBAL=$MAVEN_EXPORT_GOUP_ID:${MODULE_PREFIX}${REALPRJNAME}:${MAVEN_EXPORT_VERSION}:
  3606. }
  3607. when ($SOURCES_JAR == "yes") {
  3608. _PACK_SRC_JAR=$_PACK_SRC_JAR_IMPL
  3609. MAVEN_DEPLOY_SOURCES=-Dsources=${output;pre=${BINDIR}/${MODULE_PREFIX};suf=-sources.jar:REALPRJNAME}
  3610. }
  3611. when ($JAVA_COVERAGE == "yes") {
  3612. JAVA_COVERAGE_SRCLIST=$JAVA_COVERAGE_SRCLIST_FLAG
  3613. }
  3614. when ($MAKE_UBERJAR_VALUE == "yes") {
  3615. _LINK_UBERJAR=$_DO_LINK_UBERJAR
  3616. PACK_JAR=$_PACK_JAR_HELPER(${BINDIR}/${REALPRJNAME}.lib.jar)
  3617. # TODO: This condition is incorrect in case of autoinputs _UBERJAR_SELF should be empty only for
  3618. # modules without AUTO_INPUT and without JAVA_SRCS added inputs.
  3619. when($ALL_JAR_SOURCES) {
  3620. _UBERJAR_SELF=--jar ${BINDIR}/${REALPRJNAME}.lib.jar
  3621. }
  3622. PEERDIR+=build/platform/java/uberjar
  3623. PEERDIR+=$UBERJAR_RESOURCE_PEERDIR
  3624. }
  3625. when($JAVA_YNDEXING == "yes") {
  3626. PEERDIR+=build/platform/java/kythe
  3627. _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"}
  3628. }
  3629. when($ERROR_PRONE_VALUE) {
  3630. PEERDIR+=$ERROR_PRONE_PEERDIR
  3631. JAVAC_CMD=$ERROR_PRONE_JAVAC_CMD
  3632. }
  3633. when($ERROR_PRONE_VALUE && $JDK_REAL_VERSION == "16") {
  3634. JAVAC_FLAGS_VALUE+=$ERROR_PRONE_JDK16_ADD_OPENS
  3635. JAVAC_OPTS+=$ERROR_PRONE_JDK16_ADD_OPENS
  3636. }
  3637. when($ERROR_PRONE_VALUE && $JDK_REAL_VERSION == "17") {
  3638. JAVAC_FLAGS_VALUE+=$ERROR_PRONE_JDK16_ADD_OPENS
  3639. JAVAC_OPTS+=$ERROR_PRONE_JDK16_ADD_OPENS
  3640. }
  3641. when($ERROR_PRONE_VALUE && $JDK_REAL_VERSION == "18") {
  3642. JAVAC_FLAGS_VALUE+=$ERROR_PRONE_JDK16_ADD_OPENS
  3643. JAVAC_OPTS+=$ERROR_PRONE_JDK16_ADD_OPENS
  3644. }
  3645. when($ERROR_PRONE_VALUE && $JDK_REAL_VERSION == "19") {
  3646. JAVAC_FLAGS_VALUE+=$ERROR_PRONE_JDK16_ADD_OPENS
  3647. JAVAC_OPTS+=$ERROR_PRONE_JDK16_ADD_OPENS
  3648. }
  3649. when($ERROR_PRONE_VALUE && $JDK_REAL_VERSION == "20") {
  3650. JAVAC_FLAGS_VALUE+=$ERROR_PRONE_JDK16_ADD_OPENS
  3651. JAVAC_OPTS+=$ERROR_PRONE_JDK16_ADD_OPENS
  3652. }
  3653. when($ERROR_PRONE_VALUE && $ERROR_PRONE_VERSION == "2.7.1") {
  3654. JAVAC_FLAGS_VALUE+=$ERROR_PRONE_2_7_1_FORCED_OPTS
  3655. JAVAC_OPTS+=$ERROR_PRONE_2_7_1_FORCED_OPTS
  3656. }
  3657. when ($JAVA_ADD_DLLS_VALUE == "yes") {
  3658. CONSUME_NON_MANAGEABLE_PEERS=yes
  3659. _PACK_JNI=$_PACK_JNI_CMD
  3660. }
  3661. when ($LINT_LEVEL_VALUE != "none") {
  3662. _MAKE_JSTYLE_FILE_LIST= && ${WRITER_PY} --file ${output;noauto:"lint-java.srclst"} -m --ya-start-command-file $LINT_JAVA_SOURCES --ya-end-command-file
  3663. }
  3664. SET(MODULE_TYPE JAVA_LIBRARY)
  3665. ENABLE(YMAKE_JAVA_TEST)
  3666. _ADD_KOTLIN_STYLE_CHECKS($(BUILD_ROOT)/$MODDIR/all-kt-sources.txt REQUIREMENTS cpu:2)
  3667. _ADD_JAVA_STYLE_CHECKS($(BUILD_ROOT)/$MODDIR/lint-java.srclst::$(SOURCE_ROOT))
  3668. _ADD_CLASSPATH_CLASH_CHECK()
  3669. JAVA_MODULE()
  3670. }
  3671. # tag:java-specific
  3672. _SCRIPTGEN_FLAGS=
  3673. macro _GEN_JAVA_SCRIPT_IMPL(Out, Template, Props...) {
  3674. .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
  3675. }
  3676. # tag:java-specific
  3677. _GEN_USERSCRIPTS=
  3678. macro _ADD_GEN_JAVA_SCRIPT(Out, Template, Props...) {
  3679. SET_APPEND(_GEN_USERSCRIPTS && \$_GEN_JAVA_SCRIPT_IMPL($Out $Template $Props))
  3680. }
  3681. # tag:java-specific
  3682. _PACK_JDK=
  3683. # tag:java-specific
  3684. DO_GEN_JAVA_RUN_SH=
  3685. _SOURCE_JARS=
  3686. _SOURCE_JARS_CPLIST=
  3687. 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} -D JAR_BASENAME=${REALPRJNAME}
  3688. GEN_RUN_CP=${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}
  3689. 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}
  3690. MAKE_JAR_PROGRAM_CPLST=${MAKE_JAVA_CLASSPATH_FILE} --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
  3691. TAR_CLASSPATH= && $YMAKE_PYTHON ${input:"build/scripts/find_and_tar.py"} ${output;pre=$MODULE_PREFIX;suf=.tar:REALPRJNAME} ${cwd;pre=$BINDIR/:REALPRJNAME}
  3692. DO_TAR_CLASSPATH=
  3693. LINK_JAR_PROGRAM=${hide:JAVA_FAKEID} $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"}
  3694. # tag:java-specific
  3695. # UBERJAR program link command
  3696. LINK_UBERJAR_PROGRAM=${hide:JAVA_FAKEID} ${kv;hide:"p UJ"} ${MAKE_JAVA_CLASSPATH_FILE} --from-args ${output;pre=$MODULE_PREFIX;suf=${MODULE_SUFFIX}.cplst:REALPRJNAME} $TARGET \
  3697. && $FS_TOOLS md ${BINDIR}/${REALPRJNAME} \
  3698. && $FS_TOOLS link_or_copy ${BINDIR}/${REALPRJNAME}.jar $TARGET \
  3699. && $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;output;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} \
  3700. $DO_TAR_CLASSPATH \
  3701. $_GEN_USERSCRIPTS \
  3702. $_PACK_JDK
  3703. # tag:java-specific
  3704. RUN_WITH_SOURCES=no
  3705. # 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 default in future
  3706. TARED_CLASSPATH=yes
  3707. _JAR_SRCS_CALLED=no
  3708. # tag:java-specific
  3709. macro _MARK_JAVA_PROG_WITH_SOURCES(Args...) {
  3710. ENABLE(_JAR_SRCS_CALLED)
  3711. }
  3712. # tag:java-specific
  3713. module _JAR_RUNNABLE: _COMPILABLE_JAR_BASE {
  3714. .FINAL_TARGET=yes
  3715. .CMD=LINK_JAR_PROGRAM
  3716. .SEM=IGNORED
  3717. .ALIASES=JAVA_SRCS=_MARK_JAVA_PROG_WITH_SOURCES GENERATE_SCRIPT=_YMAKE_GENERATE_SCRIPT
  3718. .ALLOWED=WITH_JDK
  3719. MODULE_SUFFIX=.run.cp.jar
  3720. CONSUME_NON_MANAGEABLE_PEERS=yes
  3721. when ($RUN_WITH_SOURCES == "yes") {
  3722. _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}
  3723. _SOURCE_JARS_CPLIST=${nopath;rootrel;ext=.jar;pre=$BINDIR/$REALPRJNAME/;noext;suf=-sources.jar:MANAGED_PEERS_CLOSURE}
  3724. }
  3725. when ($TARED_CLASSPATH == "yes") {
  3726. DO_TAR_CLASSPATH=$TAR_CLASSPATH
  3727. }
  3728. when ($DISABLE_SCRIPTGEN) {
  3729. DO_GEN_JAVA_RUN_SH=
  3730. }
  3731. otherwise {
  3732. DO_GEN_JAVA_RUN_SH=$GEN_JAVA_RUN_SH
  3733. PEERDIR+=build/platform/java/scriptgen
  3734. }
  3735. when ($WITH_JDK_VALUE) {
  3736. _PACK_JDK= && ${YMAKE_PYTHON} ${input:"build/scripts/tar_directory.py"} ${output;tared:"jdk.tar"} $WITH_JDK_RESOURCE $WITH_JDK_RESOURCE
  3737. }
  3738. when ($MAKE_UBERJAR_VALUE == "yes") {
  3739. LINK_JAR_PROGRAM=$LINK_UBERJAR_PROGRAM
  3740. DYNAMIC_LINK=no
  3741. _SCRIPTGEN_FLAGS=-D IS_UBERJAR=yes
  3742. }
  3743. otherwise {
  3744. _SCRIPTGEN_FLAGS=-D IS_UBERJAR=no
  3745. }
  3746. CHECK_PROVIDES()
  3747. }
  3748. # tag:java-specific
  3749. multimodule JAR_PROGRAM {
  3750. module JAR_RUNNABLE: _JAR_RUNNABLE {
  3751. .ALLOWED=JAVA_RUNTIME_PEERDIR JAVA_RUNTIME_EXCLUDE
  3752. .IGNORED=JAVA_SRCS RUN_JAVA_PROGRAM
  3753. .ALIASES=EXCLUDE=_NOOP_MACRO PEERDIR=_NOOP_MACRO DEPENDENCY_MANAGEMENT=_NOOP_MACRO JAVA_RUNTIME_PEERDIR=PEERDIR JAVA_RUNTIME_EXCLUDE=EXCLUDE
  3754. .PEERDIRSELF=JAR_COMPILATION
  3755. SET(MODULE_TYPE JAVA_PROGRAM)
  3756. }
  3757. module JAR_COMPILATION: JAR_LIBRARY {
  3758. .ALIASES=JAVA_RUNTIME_PEERDIR=_NOOP_MACRO JAVA_RUNTIME_EXCLUDE=_NOOP_MACRO
  3759. .FINAL_TARGET=no
  3760. SET(MODULE_TYPE JAVA_PROGRAM)
  3761. }
  3762. }
  3763. # tag:java-specific
  3764. LINK_JAR_TEST=${hide:JAVA_FAKEID} ${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} ${kv;hide:"p JT"}
  3765. YMAKE_JAVA_TEST=
  3766. module _JAR_TEST: _COMPILABLE_JAR_BASE {
  3767. .FINAL_TARGET=yes
  3768. .CMD=LINK_JAR_TEST
  3769. .DEFAULT_NAME_GENERATOR=FullPath
  3770. CONSUME_NON_MANAGEABLE_PEERS=yes
  3771. SET(MODULE_SUFFIX .test.cp.jar)
  3772. ENABLE(YMAKE_JAVA_TEST)
  3773. JAVA_TEST()
  3774. CHECK_PROVIDES()
  3775. }
  3776. # tag:java-specific
  3777. multimodule JUNIT5_YMAKE {
  3778. module JAR_TESTABLE: _JAR_TEST {
  3779. .ALLOWED=JAVA_TEST_PEERDIR
  3780. .IGNORED=JAVA_SRCS RUN_JAVA_PROGRAM
  3781. .ALIASES=EXCLUDE=_NOOP_MACRO PEERDIR=_NOOP_MACRO DEPENDENCY_MANAGEMENT=_NOOP_MACRO JAVA_TEST_PEERDIR=PEERDIR
  3782. .PEERDIRSELF=JAR_COMPILATION
  3783. SET(MODULE_TYPE JUNIT5)
  3784. }
  3785. module JAR_COMPILATION: JAR_LIBRARY {
  3786. .IGNORED=JAVA_TEST_PEERDIR
  3787. .ALIASES=JAVA_TEST_PEERDIR=_NOOP_MACRO
  3788. .FINAL_TARGET=no
  3789. PEERDIR(devtools/junit5-runner build/platform/java/jacoco-agent)
  3790. }
  3791. }
  3792. # tag:java-specific
  3793. multimodule JTEST_YMAKE {
  3794. module JAR_TESTABLE: _JAR_TEST {
  3795. .ALLOWED=YT_SPEC
  3796. .IGNORED=JAVA_SRCS RUN_JAVA_PROGRAM
  3797. .ALIASES=EXCLUDE=_NOOP_MACRO PEERDIR=_NOOP_MACRO DEPENDENCY_MANAGEMENT=_NOOP_MACRO JAVA_TEST_PEERDIR=PEERDIR
  3798. .PEERDIRSELF=JAR_COMPILATION
  3799. SET(MODULE_TYPE JTEST)
  3800. PEERDIR(devtools/junit-runner)
  3801. 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)
  3802. }
  3803. module JAR_COMPILATION: JAR_LIBRARY {
  3804. .ALIASES=JAVA_TEST_PEERDIR=_NOOP_MACRO
  3805. .ALLOWED=YT_SPEC
  3806. .FINAL_TARGET=no
  3807. DEPENDS(contrib/java/org/sonarsource/scanner/cli/sonar-scanner-cli/2.8)
  3808. PEERDIR(build/platform/java/jacoco-agent)
  3809. }
  3810. }
  3811. # tag:python-specific tag:deprecated
  3812. ### @usage: PY2_LIBRARY() # deprecated
  3813. ###
  3814. ### Deprecated. Use PY23_LIBRARY or PY3_LIBRARY instead.
  3815. ### Python 2.x binary built library. Builds sources from PY_SRCS to data suitable for PY2_PROGRAM.
  3816. ### Adds dependencies to Python 2.x runtime library from Arcadia.
  3817. ### This module is only compatible with PYTHON2-tagged modules and selects those from multimodules.
  3818. ### This module is only compatible with Arcadia Python build.
  3819. ###
  3820. ### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/py_srcs/
  3821. module PY2_LIBRARY: _LIBRARY {
  3822. _ARCADIA_PYTHON_ADDINCL()
  3823. when ($NO_PYTHON_INCLS != "yes") {
  3824. PEERDIR+=contrib/libs/python
  3825. }
  3826. when ($MSVC == "yes" || $CYGWIN == "yes") {
  3827. MODULE_PREFIX=py
  3828. }
  3829. otherwise {
  3830. MODULE_PREFIX=libpy
  3831. }
  3832. .ALLOWED=FORK_TESTS
  3833. .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER USE_PYTHON2
  3834. .RESTRICTED=PYTHON3_ADDINCL USE_PYTHON3 PYTHON2_ADDINCL OPTIMIZE_PY_PROTOS NO_OPTIMIZE_PY_PROTOS STYLE_PYTHON
  3835. USE_GLOBAL_CMD=yes
  3836. when ($PY_PROTO_MYPY_ENABLED == "yes") {
  3837. PY_PROTO_MYPY_SUFFIX=_pb2.pyi
  3838. PY_PROTO_MYPY_PLUGIN=$PY_PROTO_MYPY_PLUGIN_BASE ${output;hide;noauto;norel;nopath;noext;suf=_pb2.pyi:File}
  3839. 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}"})
  3840. }
  3841. SET(MODULE_LANG PY2)
  3842. ADD_CLANG_TIDY()
  3843. }
  3844. # tag:python-specific
  3845. ### @usage: PY3_LIBRARY()
  3846. ###
  3847. ### Python 3.x binary library. Builds sources from PY_SRCS to data suitable for PY2_PROGRAM
  3848. ### Adds dependencies to Python 2.x runtime library from Arcadia.
  3849. ### This module is only compatible with PYTHON3-tagged modules and selects those from multimodules.
  3850. ### This module is only compatible with Arcadia Python build.
  3851. ###
  3852. ### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/py_srcs/
  3853. module PY3_LIBRARY: _LIBRARY {
  3854. _ARCADIA_PYTHON3_ADDINCL()
  3855. when ($NO_PYTHON_INCLS != "yes") {
  3856. PEERDIR+=contrib/libs/python
  3857. }
  3858. when ($MSVC == "yes" || $CYGWIN == "yes") {
  3859. MODULE_PREFIX=py
  3860. }
  3861. otherwise {
  3862. MODULE_PREFIX=libpy
  3863. }
  3864. .ALLOWED=FORK_TESTS
  3865. .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER
  3866. .RESTRICTED=PYTHON3_ADDINCL USE_PYTHON3 PYTHON2_ADDINCL USE_PYTHON2 OPTIMIZE_PY_PROTOS NO_OPTIMIZE_PY_PROTOS
  3867. USE_GLOBAL_CMD=yes
  3868. RUN_CYTHON_SCRIPT=$YMAKE_PYTHON3 $CYTHON_SCRIPT
  3869. RUN_CYTHON_SCRIPT_H=$YMAKE_PYTHON3 $CYTHON_SCRIPT
  3870. PYTHON_TYPE_FOR_CYTHON=PY3
  3871. ANTLR_PYTHON=Python3
  3872. when ($PY_PROTO_MYPY_ENABLED == "yes") {
  3873. PY_PROTO_MYPY_SUFFIX=_pb2.pyi
  3874. PY_PROTO_MYPY_PLUGIN=$PY_PROTO_MYPY_PLUGIN_BASE ${output;hide;noauto;norel;nopath;noext;suf=_pb2.pyi:File}
  3875. 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}"})
  3876. }
  3877. SET(MODULE_LANG PY3)
  3878. ADD_CLANG_TIDY()
  3879. }
  3880. # tag:python-specific
  3881. ### @usage: _BASE_PY_PROGRAM #internal
  3882. ###
  3883. ### The base module for all Python 2.x binary programs. Adds linking logic, relevant module properties and
  3884. ### dependency on Python 2.x interpreter. Also adds import tests on all sources including PEERDIR'ed libraries.
  3885. ### Links all Python 2.x libraries and Python 2.x interpreter into itself to form regular executable.
  3886. ### This only compatible with PYTHON2-tagged modules and selects those from multimodules.
  3887. ###
  3888. ### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/py_srcs/
  3889. module _BASE_PY_PROGRAM: _BASE_PROGRAM {
  3890. .CMD=PY_PROGRAM_LINK_EXE
  3891. _ARCADIA_PYTHON_ADDINCL()
  3892. when ($SANITIZER_TYPE && $SANITIZER_TYPE != "no") {
  3893. NO_CHECK_IMPORTS_FOR_VALUE=
  3894. }
  3895. ADD_CHECK_PY_IMPORTS()
  3896. when ($NO_PYTHON_INCLS != "yes") {
  3897. PEERDIR += contrib/libs/python
  3898. }
  3899. when ($USE_ARCADIA_PYTHON == "yes") {
  3900. PEERDIR += library/python/runtime/main
  3901. PEERDIR += contrib/deprecated/python/subprocess32
  3902. when ($PYTHON_SQLITE3 != "no") {
  3903. PEERDIR += contrib/tools/python/src/Modules/_sqlite
  3904. }
  3905. }
  3906. when ($PYTHON_COVERAGE == "yes") {
  3907. PEERDIR+=library/python/coverage
  3908. }
  3909. when ($ARCH_PPC64LE == "yes") {
  3910. _MY_ALLOCATOR=SYSTEM
  3911. }
  3912. otherwise {
  3913. _MY_ALLOCATOR=J
  3914. }
  3915. ALLOCATOR($_MY_ALLOCATOR)
  3916. STRIP()
  3917. when ($BUILD_TYPE == "DEBUG") {
  3918. NO_STRIP=yes
  3919. }
  3920. when ($SANITIZER_TYPE && $SANITIZER_TYPE != "no") {
  3921. NO_STRIP=yes
  3922. }
  3923. .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER USE_PYTHON2
  3924. .RESTRICTED=PYTHON3_ADDINCL USE_PYTHON3 PYTHON2_ADDINCL OPTIMIZE_PY_PROTOS NO_OPTIMIZE_PY_PROTOS
  3925. SET(MODULE_LANG PY2)
  3926. }
  3927. # tag:python-specific tag:codenav
  3928. when ($CODENAVIGATION && $NOCODENAVIGATION != "yes") {
  3929. PY3_PROGRAM_LINK_EXE=$LINK_EXE ${kv;hide:"py3yndex $TARGET"}
  3930. }
  3931. otherwise {
  3932. PY3_PROGRAM_LINK_EXE=$LINK_EXE
  3933. }
  3934. # tag:python-specific
  3935. ### @usage: _BASE_PY_PROGRAM #internal
  3936. ###
  3937. ### The base module for all Python 3.x binary programs. Adds linking logic, relevant module properties and
  3938. ### dependency on Python 3.x interpreter. Also adds import tests on all sources including libraries.
  3939. ### Links all Python 3.x libraries and Python 3.x interpreter into itself to form regular executable.
  3940. ### This only compatible with PYTHON3-tagged modules and selects those from multimodules
  3941. ###
  3942. ### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/py_srcs/
  3943. module _BASE_PY3_PROGRAM: _BASE_PROGRAM {
  3944. .CMD=PY3_PROGRAM_LINK_EXE
  3945. _ARCADIA_PYTHON3_ADDINCL()
  3946. RUN_CYTHON_SCRIPT=$YMAKE_PYTHON3 $CYTHON_SCRIPT
  3947. RUN_CYTHON_SCRIPT_H=$YMAKE_PYTHON3 $CYTHON_SCRIPT
  3948. PYTHON_TYPE_FOR_CYTHON=PY3
  3949. PEERDIR(library/python/runtime_py3/main)
  3950. when ($PYTHON_SQLITE3 != "no") {
  3951. PEERDIR += contrib/tools/python3/src/Modules/_sqlite
  3952. }
  3953. when ($SANITIZER_TYPE && $SANITIZER_TYPE != "no") {
  3954. NO_CHECK_IMPORTS_FOR_VALUE=
  3955. }
  3956. ADD_CHECK_PY_IMPORTS()
  3957. when ($ARCH_PPC64LE == "yes") {
  3958. _MY_ALLOCATOR=SYSTEM
  3959. }
  3960. otherwise {
  3961. _MY_ALLOCATOR=J
  3962. }
  3963. ALLOCATOR($_MY_ALLOCATOR)
  3964. STRIP()
  3965. when ($NO_PYTHON_INCLS != "yes") {
  3966. PEERDIR+=contrib/libs/python
  3967. }
  3968. when ($BUILD_TYPE == "DEBUG") {
  3969. NO_STRIP=yes
  3970. }
  3971. when ($SANITIZER_TYPE && $SANITIZER_TYPE != "no") {
  3972. NO_STRIP=yes
  3973. }
  3974. when ($PYTHON_COVERAGE == "yes") {
  3975. PEERDIR+=library/python/coverage
  3976. }
  3977. when ($CODENAVIGATION && $NOCODENAVIGATION != "yes") {
  3978. PEERDIR += contrib/python/six
  3979. }
  3980. .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER
  3981. .RESTRICTED=PYTHON3_ADDINCL USE_PYTHON3 PYTHON2_ADDINCL USE_PYTHON2
  3982. SET(MODULE_LANG PY3)
  3983. SET(ANTLR_PYTHON Python3)
  3984. }
  3985. # tag:python-specific
  3986. ### @usage: PY3_PROGRAM_BIN([progname])
  3987. ### Use instead of PY3_PROGRAM only if ya.make with PY3_PROGRAM() included in another ya.make
  3988. ### In all other cases use PY3_PROGRAM
  3989. module PY3_PROGRAM_BIN: _BASE_PY3_PROGRAM {
  3990. # Look's like we cannot avoid copy-paste util ymake supports multiple inheritance
  3991. # We need to attach coverage.extractor to every py_program target, except pytest targets
  3992. ADD_YTEST($MODULE_PREFIX$REALPRJNAME coverage.extractor)
  3993. }
  3994. # tag:java-specific
  3995. JAVA_SWIG_DELIM=JAVA_SWIG_DELIM
  3996. # tag:java-specific
  3997. JDK_REAL_VERSION=
  3998. JDK_VERSION=
  3999. when ($JDK_VERSION == "20") {
  4000. JDK_REAL_VERSION=20
  4001. }
  4002. elsewhen ($JDK_VERSION == "19") {
  4003. JDK_REAL_VERSION=19
  4004. }
  4005. elsewhen ($JDK_VERSION == "18") {
  4006. JDK_REAL_VERSION=18
  4007. }
  4008. elsewhen ($JDK_VERSION == "17") {
  4009. JDK_REAL_VERSION=17
  4010. }
  4011. elsewhen ($JDK_VERSION == "16") {
  4012. JDK_REAL_VERSION=16
  4013. }
  4014. elsewhen ($JDK_VERSION == "15") {
  4015. JDK_REAL_VERSION=15
  4016. }
  4017. elsewhen ($JDK_VERSION == "11") {
  4018. JDK_REAL_VERSION=11
  4019. }
  4020. elsewhen ($JDK_VERSION == "10") {
  4021. JDK_REAL_VERSION=10
  4022. }
  4023. elsewhen ($JDK_VERSION == "8") {
  4024. JDK_REAL_VERSION=8
  4025. }
  4026. elsewhen ($MAPSMOBI_BUILD_TARGET && $OS_ANDROID) {
  4027. JDK_REAL_VERSION=11
  4028. }
  4029. otherwise {
  4030. JDK_REAL_VERSION=17
  4031. }
  4032. # tag:java-specific
  4033. # remove extra peerdir to jdk11 after https://st.yandex-team.ru/DEVTOOLS-8851 is done
  4034. when ($USE_SYSTEM_JDK) {
  4035. JDK_RESOURCE_PEERDIR=
  4036. }
  4037. otherwise {
  4038. when ($JDK_REAL_VERSION == "20") {
  4039. JDK_RESOURCE_PEERDIR=build/platform/java/jdk/jdk20 build/platform/java/jdk/jdk17
  4040. }
  4041. when ($JDK_REAL_VERSION == "19") {
  4042. JDK_RESOURCE_PEERDIR=build/platform/java/jdk/jdk19 build/platform/java/jdk/jdk17
  4043. }
  4044. when ($JDK_REAL_VERSION == "18") {
  4045. JDK_RESOURCE_PEERDIR=build/platform/java/jdk/jdk18 build/platform/java/jdk/jdk17
  4046. }
  4047. when ($JDK_REAL_VERSION == "17") {
  4048. # need jdk11 for spare parts in "host" platform
  4049. JDK_RESOURCE_PEERDIR=build/platform/java/jdk/jdk17 build/platform/java/jdk/jdk11
  4050. }
  4051. when ($JDK_REAL_VERSION == "16") {
  4052. JDK_RESOURCE_PEERDIR=build/platform/java/jdk/jdk16 build/platform/java/jdk/jdk17
  4053. }
  4054. when ($JDK_REAL_VERSION == "15") {
  4055. JDK_RESOURCE_PEERDIR=build/platform/java/jdk/jdk15 build/platform/java/jdk/jdk17
  4056. }
  4057. when ($JDK_REAL_VERSION == "11") {
  4058. JDK_RESOURCE_PEERDIR=build/platform/java/jdk/jdk11 build/platform/java/jdk/jdk17
  4059. }
  4060. when ($JDK_REAL_VERSION == "10") {
  4061. JDK_RESOURCE_PEERDIR=build/platform/java/jdk/jdk10 build/platform/java/jdk/jdk17
  4062. }
  4063. when ($JDK_REAL_VERSION == "8") {
  4064. JDK_RESOURCE_PEERDIR=build/platform/java/jdk/jdk8 build/platform/java/jdk/jdk17
  4065. }
  4066. }
  4067. # tag:java-specific
  4068. when ($JDK_REAL_VERSION == "20") {
  4069. UBERJAR_RESOURCE_PEERDIR=build/platform/java/uberjar/uberjar20
  4070. }
  4071. when ($JDK_REAL_VERSION == "19") {
  4072. UBERJAR_RESOURCE_PEERDIR=build/platform/java/uberjar/uberjar18
  4073. }
  4074. when ($JDK_REAL_VERSION == "18") {
  4075. UBERJAR_RESOURCE_PEERDIR=build/platform/java/uberjar/uberjar18
  4076. }
  4077. when ($JDK_REAL_VERSION == "17") {
  4078. UBERJAR_RESOURCE_PEERDIR=build/platform/java/uberjar/uberjar17
  4079. }
  4080. when ($JDK_REAL_VERSION == "16") {
  4081. UBERJAR_RESOURCE_PEERDIR=build/platform/java/uberjar/uberjar16
  4082. }
  4083. when ($JDK_REAL_VERSION == "15") {
  4084. UBERJAR_RESOURCE_PEERDIR=build/platform/java/uberjar/uberjar15
  4085. }
  4086. when ($JDK_REAL_VERSION == "11") {
  4087. UBERJAR_RESOURCE_PEERDIR=build/platform/java/uberjar/uberjar11
  4088. }
  4089. when ($JDK_REAL_VERSION == "10") {
  4090. UBERJAR_RESOURCE_PEERDIR=build/platform/java/uberjar/uberjar10
  4091. }
  4092. when ($JDK_REAL_VERSION == "8") {
  4093. UBERJAR_RESOURCE_PEERDIR=build/platform/java/uberjar/uberjar8
  4094. }
  4095. # tag:java-specific
  4096. JAVAC_OPTS=
  4097. when ($USE_SYSTEM_JDK) {
  4098. JDK_RESOURCE=$USE_SYSTEM_JDK
  4099. }
  4100. otherwise {
  4101. when ($JDK_REAL_VERSION == "20") {
  4102. JDK_RESOURCE=$JDK20_RESOURCE_GLOBAL
  4103. }
  4104. when ($JDK_REAL_VERSION == "19") {
  4105. JDK_RESOURCE=$JDK19_RESOURCE_GLOBAL
  4106. }
  4107. when ($JDK_REAL_VERSION == "18") {
  4108. JDK_RESOURCE=$JDK18_RESOURCE_GLOBAL
  4109. }
  4110. when ($JDK_REAL_VERSION == "17") {
  4111. JDK_RESOURCE=$JDK17_RESOURCE_GLOBAL
  4112. }
  4113. when ($JDK_REAL_VERSION == "16") {
  4114. JDK_RESOURCE=$JDK16_RESOURCE_GLOBAL
  4115. }
  4116. when ($JDK_REAL_VERSION == "15") {
  4117. JDK_RESOURCE=$JDK15_RESOURCE_GLOBAL
  4118. }
  4119. when ($JDK_REAL_VERSION == "11") {
  4120. JDK_RESOURCE=$JDK11_RESOURCE_GLOBAL
  4121. }
  4122. when ($JDK_REAL_VERSION == "10") {
  4123. JDK_RESOURCE=$JDK10_RESOURCE_GLOBAL
  4124. }
  4125. when ($JDK_REAL_VERSION == "8") {
  4126. JDK_RESOURCE=$JDK8_RESOURCE_GLOBAL
  4127. }
  4128. }
  4129. # tag:java-specific
  4130. when (!$USE_SYSTEM_ERROR_PRONE) {
  4131. # Still not done: DTCC-667
  4132. when ($JDK_REAL_VERSION == "8" || $JDK_REAL_VERSION == "10") {
  4133. ERROR_PRONE_VERSION=2.3.1
  4134. ERROR_PRONE_PEERDIR=build/platform/java/error_prone/2.3.1
  4135. ERROR_PRONE_RESOURCE=$ERROR_PRONE_2_3_1_RESOURCE_GLOBAL
  4136. }
  4137. elsewhen ($JDK_REAL_VERSION == "11" || $JDK_REAL_VERSION == "15" || $JDK_REAL_VERSION == "16") {
  4138. ERROR_PRONE_VERSION=2.7.1
  4139. ERROR_PRONE_PEERDIR=build/platform/java/error_prone/2.7.1
  4140. ERROR_PRONE_RESOURCE=$ERROR_PRONE_2_7_1_RESOURCE_GLOBAL
  4141. }
  4142. elsewhen ($JDK_REAL_VERSION == "17") {
  4143. ERROR_PRONE_VERSION=2.10.0
  4144. ERROR_PRONE_PEERDIR=build/platform/java/error_prone/2.10.0
  4145. ERROR_PRONE_RESOURCE=$ERROR_PRONE_2_10_0_RESOURCE_GLOBAL
  4146. }
  4147. elsewhen ($JDK_REAL_VERSION == "18") {
  4148. ERROR_PRONE_VERSION=2.14.0
  4149. ERROR_PRONE_PEERDIR=build/platform/java/error_prone/2.14.0
  4150. ERROR_PRONE_RESOURCE=$ERROR_PRONE_2_14_0_RESOURCE_GLOBAL
  4151. }
  4152. elsewhen ($JDK_REAL_VERSION == "19") {
  4153. ERROR_PRONE_VERSION=2.18.0
  4154. ERROR_PRONE_PEERDIR=build/platform/java/error_prone/2.18.0
  4155. ERROR_PRONE_RESOURCE=$ERROR_PRONE_2_18_0_RESOURCE_GLOBAL
  4156. }
  4157. elsewhen ($JDK_REAL_VERSION == "20") {
  4158. ERROR_PRONE_VERSION=2.18.0
  4159. ERROR_PRONE_PEERDIR=build/platform/java/error_prone/2.18.0
  4160. ERROR_PRONE_RESOURCE=$ERROR_PRONE_2_18_0_RESOURCE_GLOBAL
  4161. }
  4162. otherwise {
  4163. ERROR_PRONE_VERSION=2.7.1
  4164. ERROR_PRONE_PEERDIR=build/platform/java/error_prone
  4165. ERROR_PRONE_RESOURCE=$ERROR_PRONE_RESOURCE_GLOBAL
  4166. }
  4167. }
  4168. otherwise {
  4169. ERROR_PRONE_VERSION=2.7.1
  4170. ERROR_PRONE_PEERDIR=build/platform/java/error_prone
  4171. ERROR_PRONE_RESOURCE=$ERROR_PRONE_RESOURCE_GLOBAL
  4172. }
  4173. # tag:java-specific
  4174. when ($USE_SYSTEM_UBERJAR) {
  4175. UBERJAR_RESOURCE=$USE_SYSTEM_UBERJAR
  4176. }
  4177. otherwise {
  4178. when ($JDK_REAL_VERSION == "20") {
  4179. UBERJAR_RESOURCE=$UBERJAR20_RESOURCE_GLOBAL
  4180. }
  4181. when ($JDK_REAL_VERSION == "19") {
  4182. UBERJAR_RESOURCE=$UBERJAR18_RESOURCE_GLOBAL
  4183. }
  4184. when ($JDK_REAL_VERSION == "18") {
  4185. UBERJAR_RESOURCE=$UBERJAR18_RESOURCE_GLOBAL
  4186. }
  4187. when ($JDK_REAL_VERSION == "17") {
  4188. UBERJAR_RESOURCE=$UBERJAR17_RESOURCE_GLOBAL
  4189. }
  4190. when ($JDK_REAL_VERSION == "16") {
  4191. UBERJAR_RESOURCE=$UBERJAR16_RESOURCE_GLOBAL
  4192. }
  4193. when ($JDK_REAL_VERSION == "15") {
  4194. UBERJAR_RESOURCE=$UBERJAR15_RESOURCE_GLOBAL
  4195. }
  4196. when ($JDK_REAL_VERSION == "11") {
  4197. UBERJAR_RESOURCE=$UBERJAR11_RESOURCE_GLOBAL
  4198. }
  4199. when ($JDK_REAL_VERSION == "10") {
  4200. UBERJAR_RESOURCE=$UBERJAR10_RESOURCE_GLOBAL
  4201. }
  4202. when ($JDK_REAL_VERSION == "8") {
  4203. UBERJAR_RESOURCE=$UBERJAR8_RESOURCE_GLOBAL
  4204. }
  4205. }
  4206. # tag:java-specific
  4207. when ($JDK_REAL_VERSION == "20") {
  4208. WITH_JDK_RESOURCE=$WITH_JDK20_RESOURCE_GLOBAL
  4209. }
  4210. when ($JDK_REAL_VERSION == "19") {
  4211. WITH_JDK_RESOURCE=$WITH_JDK19_RESOURCE_GLOBAL
  4212. }
  4213. when ($JDK_REAL_VERSION == "18") {
  4214. WITH_JDK_RESOURCE=$WITH_JDK18_RESOURCE_GLOBAL
  4215. }
  4216. when ($JDK_REAL_VERSION == "17") {
  4217. WITH_JDK_RESOURCE=$WITH_JDK17_RESOURCE_GLOBAL
  4218. }
  4219. when ($JDK_REAL_VERSION == "16") {
  4220. WITH_JDK_RESOURCE=$WITH_JDK16_RESOURCE_GLOBAL
  4221. }
  4222. when ($JDK_REAL_VERSION == "15") {
  4223. WITH_JDK_RESOURCE=$WITH_JDK15_RESOURCE_GLOBAL
  4224. }
  4225. when ($JDK_REAL_VERSION == "11") {
  4226. WITH_JDK_RESOURCE=$WITH_JDK11_RESOURCE_GLOBAL
  4227. }
  4228. when ($JDK_REAL_VERSION == "10") {
  4229. WITH_JDK_RESOURCE=$WITH_JDK10_RESOURCE_GLOBAL
  4230. }
  4231. when ($JDK_REAL_VERSION == "8") {
  4232. WITH_JDK_RESOURCE=$WITH_JDK8_RESOURCE_GLOBAL
  4233. }
  4234. # tag:java-specific
  4235. EXTERNAL_JAVA_JDK_RESOURCE=
  4236. EXTERNAL_JAVA_EXTRA_PEERDIR=
  4237. when ($USE_SYSTEM_JDK) {
  4238. EXTERNAL_JAVA_EXTRA_PEERDIR=
  4239. EXTERNAL_JAVA_JDK_RESOURCE=$USE_SYSTEM_JDK
  4240. }
  4241. elsewhen ($JDK_VERSION == "") {
  4242. EXTERNAL_JAVA_JDK_RESOURCE=$JDK11_RESOURCE_GLOBAL
  4243. EXTERNAL_JAVA_EXTRA_PEERDIR=build/platform/java/jdk/jdk11
  4244. }
  4245. otherwise {
  4246. EXTERNAL_JAVA_JDK_RESOURCE=$JDK_RESOURCE
  4247. }
  4248. COMPILE_JAVA=${cwd:ARCADIA_BUILD_ROOT} $YMAKE_PYTHON ${input:"build/scripts/compile_java.py"} --java-bin $EXTERNAL_JAVA_JDK_RESOURCE/bin/java --javac-bin $EXTERNAL_JAVA_JDK_RESOURCE/bin/javac --jar-bin $JDK_RESOURCE/bin/jar --kotlin-compiler $KOTLIN_COMPILER_RESOURCE_GLOBAL/kotlin-compiler.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 DELIM -no-stdlib -module-name $REALPRJNAME -jvm-target ${KOTLIN_JVM_TARGET} ${KOTLINC_OPTS_VALUE} ${kv;hide:"p JV"} ${kv;hide:"pc light-blue"} ${kv;hide:"show_out"} ${requirements;hide:"cpu:2"}
  4249. 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
  4250. ARGS_DELIM="MACRO_CALLS_DELIM"
  4251. SYSTEM_PROPERTIES_VALUE=
  4252. ### @usage: SYSTEM_PROPERTIES([<Key Value>...] [<File Path>...])
  4253. ###
  4254. ### List of Key,Value pairs that will be available to test via System.getProperty().
  4255. ### FILE means that parst should be read from file specifies as Path.
  4256. ###
  4257. ### Documentation: https://wiki.yandex-team.ru/yatool/test/
  4258. macro SYSTEM_PROPERTIES(Args...) {
  4259. SET_APPEND(SYSTEM_PROPERTIES_VALUE $Args)
  4260. }
  4261. # tag:java-specific
  4262. JVM_ARGS_VALUE=
  4263. ### @usage: JVM_ARGS(Args...)
  4264. ###
  4265. ### Arguments to run Java programs in tests.
  4266. ###
  4267. ### Documentation: https://wiki.yandex-team.ru/yatool/test/
  4268. macro JVM_ARGS(Args...) {
  4269. SET_APPEND(JVM_ARGS_VALUE $Args)
  4270. }
  4271. # tag:java-specific
  4272. CHECK_JAVA_DEPS_VALUE=
  4273. ### @usage: CHECK_JAVA_DEPS(<yes|no>)
  4274. ###
  4275. ### Check for different classes with duplicate name in classpath.
  4276. ###
  4277. ### Documentation: https://wiki.yandex-team.ru/yatool/test/
  4278. macro CHECK_JAVA_DEPS(Arg) {
  4279. SET(CHECK_JAVA_DEPS_VALUE $Arg)
  4280. }
  4281. ERROR_PRONE_VALUE=
  4282. ### @usage: USE_ERROR_PRONE()
  4283. ###
  4284. ### Use errorprone instead of javac for .java compilation.
  4285. macro USE_ERROR_PRONE() {
  4286. SET(ERROR_PRONE_VALUE yes)
  4287. }
  4288. TEST_CWD_VALUE=
  4289. ### @usage: TEST_CWD(path)
  4290. ###
  4291. ### Defines working directory for test runs. Often used in conjunction with DATA() macro.
  4292. ### Is only used inside of the TEST modules.
  4293. ###
  4294. ### Documentation: https://wiki.yandex-team.ru/yatool/test/
  4295. macro TEST_CWD(Arg) {
  4296. SET(TEST_CWD_VALUE $Arg)
  4297. }
  4298. # tag:java-specific
  4299. MAKE_UBERJAR_VALUE=
  4300. ### @usage: UBERJAR()
  4301. ###
  4302. ### UBERJAR is a single all-in-one jar-archive that includes all its Java dependencies (reachable PEERDIR).
  4303. ### It also supports shading classes inside the archive by moving them to a different package (similar to the maven-shade-plugin).
  4304. ### Use UBERJAR inside JAVA_PROGRAM module.
  4305. ###
  4306. ### You can use the following macros to configure the archive:
  4307. ### 1. UBERJAR_HIDING_PREFIX prefix for classes to shade (classes remain in their packages by default)
  4308. ### 2. UBERJAR_HIDE_EXCLUDE_PATTERN exclude classes matching this patterns from shading (if enabled).
  4309. ### 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)
  4310. ### 4. UBERJAR_MANIFEST_TRANSFORMER_MAIN add ManifestResourceTransformer class to uberjar processing and specify main-class
  4311. ### 5. UBERJAR_MANIFEST_TRANSFORMER_ATTRIBUTE add ManifestResourceTransformer class to uberjar processing and specify some attribute
  4312. ### 6. UBERJAR_APPENDING_TRANSFORMER add AppendingTransformer class to uberjar processing
  4313. ### 7. UBERJAR_SERVICES_RESOURCE_TRANSFORMER add ServicesResourceTransformer class to uberjar processing
  4314. ###
  4315. ### Documentation: https://wiki.yandex-team.ru/yatool/java/
  4316. ###
  4317. ### @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)
  4318. macro UBERJAR() {
  4319. SET(MAKE_UBERJAR_VALUE yes)
  4320. DISABLE(PASS_PEERS)
  4321. }
  4322. # tag:java-specific
  4323. UBERJAR_PREFIX_VALUE=
  4324. UBERJAR_PREFIX_FLAG=
  4325. ### @usage: UBERJAR_HIDING_PREFIX(Arg)
  4326. ###
  4327. ### Set prefix for classes to shade. All classes in UBERJAR will be moved into package prefixed with Arg.
  4328. ### Classes remain in their packages by default.
  4329. ###
  4330. ### @see: [UBERJAR](#macro_UBERJAR)
  4331. macro UBERJAR_HIDING_PREFIX(Arg) {
  4332. SET(UBERJAR_PREFIX_VALUE $Arg)
  4333. SET(UBERJAR_PREFIX_FLAG ${pre=--shade-prefix :Arg})
  4334. }
  4335. # tag:java-specific
  4336. UBERJAR_HIDE_EXCLUDE_VALUE=
  4337. UBERJAR_HIDE_EXCLUDE_FLAGS=
  4338. ### @usage: UBERJAR_HIDE_EXCLUDE_PATTERN(Args...)
  4339. ###
  4340. ### Exclude classes matching this patterns from shading (if enabled).
  4341. ### Pattern may contain '*' and '**' globs.
  4342. ### Shading is enabled for UBERJAR program using UBERJAR_HIDING_PREFIX macro. If this macro is not specified all classes are shaded.
  4343. ###
  4344. ### @see: [UBERJAR](#macro_UBERJAR), [UBERJAR_HIDING_PREFIX](#macro_UBERJAR_HIDING_PREFIX)
  4345. macro UBERJAR_HIDE_EXCLUDE_PATTERN(Args...) {
  4346. SET_APPEND(UBERJAR_HIDE_EXCLUDE_VALUE $ARGS_DELIM $Args)
  4347. SET_APPEND(UBERJAR_HIDE_EXCLUDE_FLAGS ${pre=--shade-exclude :Args})
  4348. }
  4349. # tag:java-specific
  4350. UBERJAR_PATH_EXCLUDES=
  4351. UBERJAR_PATH_EXCLUDE_VALUE=
  4352. ### @usage: UBERJAR_PATH_EXCLUDE_PREFIX(Args...)
  4353. ###
  4354. ### Exclude classes matching this patterns from UBERJAR.
  4355. ### By default all dependencies of UBERJAR program will lend in a .jar archive.
  4356. ###
  4357. ### @see: [UBERJAR](#macro_UBERJAR)
  4358. macro UBERJAR_PATH_EXCLUDE_PREFIX(Args...) {
  4359. SET_APPEND(UBERJAR_PATH_EXCLUDE_VALUE $ARGS_DELIM $Args)
  4360. SET_APPEND(UBERJAR_PATH_EXCLUDES ${pre=--uber-exclude :Args})
  4361. }
  4362. # tag:java-specific
  4363. UBERJAR_MANIFEST_TRANSFORMER_MAIN_VALUE=
  4364. UBERJAR_MANIFEST_TRANSFORMER_MAIN_FLAG=
  4365. ### @usage: UBERJAR_MANIFEST_TRANSFORMER_MAIN(Main)
  4366. ###
  4367. ### Transform manifest.mf for UBERJAR() java programs, set main-class attribute
  4368. ###
  4369. ### @see: [UBERJAR](#macro_UBERJAR)
  4370. macro UBERJAR_MANIFEST_TRANSFORMER_MAIN(Main) {
  4371. SET(UBERJAR_MANIFEST_TRANSFORMER_MAIN_VALUE $Main)
  4372. SET(UBERJAR_MANIFEST_TRANSFORMER_MAIN_FLAG --manifest-main $Main)
  4373. }
  4374. # tag:java-specific
  4375. UBERJAR_MANIFEST_TRANSFORMER_ATTRIBUTE_VALUE=
  4376. UBERJAR_MANIFEST_TRANSFORMER_ATTRIBUTE_FLAGS=
  4377. ### @usage: UBERJAR_MANIFEST_TRANSFORMER_ATTRIBUTE(Key, Value)
  4378. ###
  4379. ### Transform manifest.mf for UBERJAR() java programs, set attribute
  4380. ###
  4381. ### @see: [UBERJAR](#macro_UBERJAR)
  4382. macro UBERJAR_MANIFEST_TRANSFORMER_ATTRIBUTE(Key, Value) {
  4383. SET_APPEND(UBERJAR_MANIFEST_TRANSFORMER_ATTRIBUTE_VALUE $ARGS_DELIM $Key : $Value)
  4384. SET_APPEND(UBERJAR_MANIFEST_TRANSFORMER_ATTRIBUTE_FLAGS --manifest-attribute ${Key}:${Value})
  4385. }
  4386. # tag:java-specific
  4387. UBERJAR_APPENDING_TRANSFORMER_VALUE=
  4388. UBERJAR_APPENDING_TRANSFORMER_FLAGS=
  4389. ### @usage: UBERJAR_APPENDING_TRANSFORMER(Resource)
  4390. ###
  4391. ### Add AppendingTransformer for UBERJAR() java programs
  4392. ###
  4393. ### Parameters:
  4394. ### - Resource - Resource name
  4395. ###
  4396. ### @see: [UBERJAR](#macro_UBERJAR)
  4397. macro UBERJAR_APPENDING_TRANSFORMER(Resources...) {
  4398. SET_APPEND(UBERJAR_APPENDING_TRANSFORMER_VALUE $ARGS_DELIM $Resources)
  4399. SET_APPEND(UBERJAR_APPENDING_TRANSFORMER_FLAGS ${pre=--append-transformer :Resources})
  4400. }
  4401. # tag:java-specific
  4402. UBERJAR_SERVICES_RESOURCE_TRANSFORMER_VALUE=
  4403. UBERJAR_SERVICES_RESOURCE_TRANSFORMER_FLAG=
  4404. ### @usage: UBERJAR_SERVICES_RESOURCE_TRANSFORMER()
  4405. ###
  4406. ### Add ServicesResourceTransformer for UBERJAR() java programs
  4407. ###
  4408. ### @see: [UBERJAR](#macro_UBERJAR)
  4409. macro UBERJAR_SERVICES_RESOURCE_TRANSFORMER() {
  4410. SET(UBERJAR_SERVICES_RESOURCE_TRANSFORMER_VALUE yes)
  4411. SET(UBERJAR_SERVICES_RESOURCE_TRANSFORMER_FLAG --service-transformer)
  4412. }
  4413. # tag:idea-specific
  4414. IDEA_EXCLUDE_DIRS_VALUE=
  4415. ### @usage: IDEA_EXCLUDE_DIRS(<excluded dirs>)
  4416. ###
  4417. ### Exclude specified directories from an idea project generated by ya ide idea
  4418. ### Have no effect on regular build.
  4419. macro IDEA_EXCLUDE_DIRS(Args...) {
  4420. SET_APPEND(IDEA_EXCLUDE_DIRS_VALUE $Args)
  4421. }
  4422. # tag:idea-specific
  4423. IDEA_RESOURCE_DIRS_VALUE=
  4424. ### @usage: IDEA_RESOURCE_DIRS(<additional dirs>)
  4425. ###
  4426. ### Set specified resource directories in an idea project generated by ya ide idea
  4427. ### Have no effect on regular build.
  4428. macro IDEA_RESOURCE_DIRS(Args...) {
  4429. SET_APPEND(IDEA_RESOURCE_DIRS_VALUE $Args)
  4430. }
  4431. # tag:idea-specific
  4432. IDEA_MODULE_NAME_VALUE=
  4433. ### @usage: IDEA_MODULE_NAME(module_name)
  4434. ###
  4435. ### Set module name in an idea project generated by ya ide idea
  4436. ### Have no effect on regular build.
  4437. macro IDEA_MODULE_NAME(Name) {
  4438. SET(IDEA_MODULE_NAME_VALUE $Name)
  4439. }
  4440. # tag:java-specific
  4441. JAVAC_FLAGS_VALUE=
  4442. ### @usage: JAVAC_FLAGS(Args...)
  4443. ###
  4444. ### Set additional Java compilation flags.
  4445. macro JAVAC_FLAGS(Args...) {
  4446. SET_APPEND(JAVAC_OPTS $Args)
  4447. SET_APPEND(JAVAC_FLAGS_VALUE $ARGS_DELIM $Args)
  4448. }
  4449. # tag:java-specific
  4450. ENABLE_PREVIEW_VALUE=
  4451. ### @usage: ENABLE_PREVIEW()
  4452. ###
  4453. ### Enable java preview features.
  4454. macro ENABLE_PREVIEW() {
  4455. SET_APPEND(JVM_ARGS_VALUE --enable-preview)
  4456. SET_APPEND(JAVAC_OPTS --enable-preview --release $JDK_REAL_VERSION)
  4457. SET_APPEND(JAVAC_FLAGS_VALUE --enable-preview --release $JDK_REAL_VERSION)
  4458. SET(ENABLE_PREVIEW_VALUE yes)
  4459. }
  4460. # tag:java-specific
  4461. SAVE_JAVAC_GENERATED_SRCS=
  4462. SAVE_JAVAC_GENERATED_SRCS_DIR=
  4463. SAVE_JAVAC_GENERATED_SRCS_TAR=
  4464. when ($SAVE_JAVAC_GENERATED_SRCS) {
  4465. SAVE_JAVAC_GENERATED_SRCS_DIR=${BINDIR}/__javac_generated_srcs__
  4466. SAVE_JAVAC_GENERATED_SRCS_TAR=${BINDIR}/javac_generated.tar
  4467. JAVAC_FLAGS_VALUE+=-s $SAVE_JAVAC_GENERATED_SRCS_DIR
  4468. }
  4469. # tag:java-specific
  4470. # TODO: MAVEN_GROUP_ID_VALUE is only used by jbuild remove it after YMAKE-45 and YMAKE-46
  4471. MAVEN_GROUP_ID_VALUE=
  4472. MAVEN_EXPORT_GOUP_ID=ru.yandex
  4473. ### @usage: MAVEN_GROUP_ID(group_id_for_maven_export)
  4474. ###
  4475. ### Set maven export group id for JAVA_PROGRAM() and JAVA_LIBRARY().
  4476. ### Have no effect on regular build.
  4477. macro MAVEN_GROUP_ID(Arg, VERSION="no") {
  4478. SET(MAVEN_GROUP_ID_VALUE $Arg)
  4479. SET(MAVEN_EXPORT_GOUP_ID $Arg)
  4480. SET(PUBLISH_MAVEN_VERSION $VERSION)
  4481. }
  4482. # tag:java-specific
  4483. ANNOTATION_PROCESSOR_VALUE=
  4484. ### @usage: ANNOTATION_PROCESSOR(processors...)
  4485. ###
  4486. ### The macro is in development.
  4487. ### Used to specify annotation processors to build JAVA_PROGRAM() and JAVA_LIBRARY().
  4488. macro ANNOTATION_PROCESSOR(Args...) {
  4489. SET_APPEND(ANNOTATION_PROCESSOR_VALUE $ARGS_DELIM $Args)
  4490. }
  4491. EXCLUDE_VALUE=
  4492. ### EXCLUDE(prefixes)
  4493. ###
  4494. ### The macro is in development.
  4495. ### Specifies which libraries should be excluded from the classpath.
  4496. macro EXCLUDE(Args...) {
  4497. SET_APPEND(EXCLUDE_VALUE $ARGS_DELIM $Args)
  4498. }
  4499. # tag:java-specific
  4500. JAVA_SRCS_VALUE=
  4501. ### @usage: JAVA_SRCS(srcs)
  4502. ###
  4503. ### Specify java source files and resources. A macro can be contained in any of four java modules.
  4504. ### Keywords:
  4505. ### 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.
  4506. ### 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.
  4507. ###
  4508. ### @example:
  4509. ### - example/ya.make
  4510. ###
  4511. ### JAVA_PROGRAM()
  4512. ### JAVA_SRCS(SRCDIR src/main/java **/*)
  4513. ### END()
  4514. ###
  4515. ### - example/src/main/java/ru/yandex/example/HelloWorld.java
  4516. ###
  4517. ### package ru.yandex.example;
  4518. ### public class HelloWorld {
  4519. ### public static void main(String[] args) {
  4520. ### System.out.println("Hello, World!");
  4521. ### }
  4522. ### }
  4523. ###
  4524. ### Documentation: https://wiki.yandex-team.ru/yatool/java/#javasrcs
  4525. macro JAVA_SRCS(Args...) {
  4526. SET_APPEND(JAVA_SRCS_VALUE $ARGS_DELIM $Args)
  4527. }
  4528. # tag:java-specific
  4529. JAVA_ADD_DLLS_VALUE=no
  4530. macro ADD_DLLS_TO_JAR() {
  4531. SET(JAVA_ADD_DLLS_VALUE yes)
  4532. }
  4533. # tag:java-specific
  4534. MANAGED_PEERS=
  4535. MANAGED_PEERS_CLOSURE=
  4536. RUN_JAVA_PROGRAM_MANAGED=
  4537. MANAGEABLE_PEERS_ROOTS=contrib/java
  4538. HAS_MANAGEABLE_PEERS=no
  4539. PROPAGATES_MANAGEABLE_PEERS=no
  4540. # All items of this list must be PEERS, GHOST PEERS or TOOLS of the test module or module itself.
  4541. # All items of this list must has at least one of HAS_MANAGEABLE_PEERS or PROPAGATES_MANAGEABLE_PEERS flags set yes.
  4542. # This variable is used by JUnit tests but not TestNG.
  4543. TEST_CLASSPATH_VALUE=
  4544. # Calculated and replaced by ymake can be used in DART DATA
  4545. TEST_CLASSPATH_MANAGED=
  4546. # tag:java-specific
  4547. DEPENDENCY_MANAGEMENT_VALUE=
  4548. ### @usage: DEPENDENCY_MANAGEMENT(path/to/lib1 path/to/lib2 ...)
  4549. ###
  4550. ### 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.
  4551. ###
  4552. ### For example, if the module has PEERDIR (contrib/java/junit/junit), and
  4553. ### 1. specifies DEPENDENCY_MANAGEMENT(contrib/java/junit/junit/4.12),
  4554. ### the PEERDIR is automatically replaced by contrib/java/junit/junit/4.12;
  4555. ### 2. doesn't specify DEPENDENCY_MANAGEMENT, PEERDIR automatically replaced
  4556. ### with the default from contrib/java/junit/junit/ya.make.
  4557. ### These defaults are always there and are supported by maven-import, which puts
  4558. ### there the maximum version available in contrib/java.
  4559. ###
  4560. ### 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.
  4561. ###
  4562. ### If some module has both DEPENDENCY_MANAGEMENT(contrib/java/junit/junit/4.12) and PERDIR(contrib/java/junit/junit/4.11), the PEERDIR wins.
  4563. ###
  4564. ### Documentation: https://wiki.yandex-team.ru/yatool/java/
  4565. macro DEPENDENCY_MANAGEMENT(Args...) {
  4566. SET_APPEND(DEPENDENCY_MANAGEMENT_VALUE $ARGS_DELIM $Args)
  4567. _GHOST_PEERDIR($Args)
  4568. }
  4569. # tag:java-specific
  4570. WITH_JDK_VALUE=
  4571. ### @usage: WITH_JDK()
  4572. ###
  4573. ### Add directory with JDK to JAVA_PROGRAM output
  4574. macro WITH_JDK() {
  4575. SET(WITH_JDK_VALUE yes)
  4576. }
  4577. # tag:kotlin-specific
  4578. WITH_KOTLIN_VALUE=
  4579. ### @usage: WITH_KOTLIN()
  4580. ###
  4581. ### Compile kotlin source code in this java module
  4582. macro WITH_KOTLIN() {
  4583. SET(WITH_KOTLIN_VALUE yes)
  4584. }
  4585. # tag:kotlin-specific
  4586. WITH_KAPT_VALUE=
  4587. ### @usage: WITH_KAPT()
  4588. ###
  4589. ### Use kapt for as annotation processor
  4590. macro WITH_KAPT() {
  4591. SET(WITH_KAPT_VALUE yes)
  4592. }
  4593. # tag:java-specific
  4594. WITH_GROOVY_VALUE=
  4595. ### @usage: WITH_GROOVY()
  4596. ###
  4597. ### Compile groovy source code in this java module
  4598. macro WITH_GROOVY() {
  4599. SET(WITH_GROOVY_VALUE yes)
  4600. }
  4601. # tag:kotlin-specific
  4602. KOTLINC_FLAGS_VALUE=-Xjvm-default=all
  4603. ### @usage: KOTLINC_FLAGS(-flags)
  4604. ###
  4605. ### Set additional Kotlin compilation flags.
  4606. macro KOTLINC_FLAGS(Args...) {
  4607. SET_APPEND(KOTLINC_OPTS_VALUE $Args)
  4608. }
  4609. # tag:kotlin-sppecific
  4610. WITH_KOTLINC_PLUGIN_ALLOPEN=
  4611. macro _WITH_KOTLINC_ALLOPEN(Options...) {
  4612. SET_APPEND(KOTLINC_OPTS_VALUE ${pre=-P plugin\:org.jetbrains.kotlin.allopen\::Options})
  4613. SET(WITH_KOTLINC_PLUGIN_ALLOPEN yes)
  4614. }
  4615. # tag:kotlin-specific
  4616. ### @usage: WITH_KOTLINC_ALLOPEN(-flags)
  4617. ###
  4618. ### Enable allopen kotlin compiler plugin https://kotlinlang.org/docs/all-open-plugin.html
  4619. macro WITH_KOTLINC_ALLOPEN(HEAD, TAIL...) {
  4620. _WITH_KOTLINC_ALLOPEN($HEAD $TAIL)
  4621. }
  4622. # tag:kotlin-specific
  4623. WITH_KOTLINC_PLUGIN_LOMBOK=
  4624. ### @usage: WITH_KOTLINC_LOMBOK(-flags)
  4625. ###
  4626. ### Enable lombok kotlin compiler plugin https://kotlinlang.org/docs/lombok.html
  4627. macro WITH_KOTLINC_LOMBOK(Options...) {
  4628. SET_APPEND(KOTLINC_OPTS_VALUE ${pre=-P plugin\:org.jetbrains.kotlin.lombok\::Options})
  4629. SET(WITH_KOTLINC_PLUGIN_LOMBOK yes)
  4630. }
  4631. # tag:kotlin-specific
  4632. WITH_KOTLINC_PLUGIN_NOARG=
  4633. ### @usage: WITH_KOTLINC_NOARG(-flags)
  4634. ###
  4635. ### Enable noarg kotlin compiler plugin https://kotlinlang.org/docs/no-arg-plugin.html
  4636. macro WITH_KOTLINC_NOARG(Options...) {
  4637. SET_APPEND(KOTLINC_OPTS_VALUE ${pre=-P plugin\:org.jetbrains.kotlin.noarg\::Options})
  4638. SET(WITH_KOTLINC_PLUGIN_NOARG yes)
  4639. }
  4640. # tag:kotlin-specific
  4641. WITH_KOTLINC_PLUGIN_SERIALIZATION=
  4642. ### @usage: WITH_KOTLINC_SERIALIZATION()
  4643. ###
  4644. ### Enable serialization kotlin compiler plugin https://kotlinlang.org/docs/serialization.html
  4645. macro WITH_KOTLINC_SERIALIZATION() {
  4646. SET(WITH_KOTLINC_PLUGIN_SERIALIZATION yes)
  4647. }
  4648. # tag:kotlin-specific
  4649. ### Also search for _KAPT_OPTS and change version there
  4650. KOTLIN_VERSION=1.8.20
  4651. KOTLIN_BOM_FILE=${ARCADIA_ROOT}/contrib/java/org/jetbrains/kotlin/kotlin-bom/1.8.20/ya.dependency_management.inc
  4652. GROOVY_VERSION=3.0.5
  4653. # tag:java-specific
  4654. DIRECT_DEPS_ONLY_VALUE=
  4655. ### @usage: DIRECT_DEPS_ONLY
  4656. ###
  4657. ### Add direct PEERDIR's only in java compile classpath
  4658. macro DIRECT_DEPS_ONLY() {
  4659. SET(DIRECT_DEPS_ONLY_VALUE yes)
  4660. }
  4661. # tag:java-specific
  4662. JAVA_EXTERNAL_DEPENDENCIES_VALUE=
  4663. ### @usage: JAVA_EXTERNAL_DEPENDENCIES(file1 file2 ...)
  4664. ###
  4665. ### Add non-source java external build dependency (like lombok config file)
  4666. macro JAVA_EXTERNAL_DEPENDENCIES(Args...) {
  4667. SET_APPEND(JAVA_EXTERNAL_DEPENDENCIES_VALUE $Args)
  4668. }
  4669. # tag:java-specific
  4670. JAVA_CLASSPATH_CMD_TYPE_VALUE=
  4671. # tag:java-specific
  4672. ### @usage:TEST_JAVA_CLASSPATH_CMD_TYPE(Type)
  4673. ### Available types: MANIFEST(default), COMMAND_FILE, LIST
  4674. ### Method for passing a classpath value to a java command line
  4675. ### MANIFEST via empty jar file with manifest that contains Class-Path attribute
  4676. ### COMMAND_FILE via @command_file
  4677. ### LIST via flat args
  4678. macro TEST_JAVA_CLASSPATH_CMD_TYPE(Type) {
  4679. SET(JAVA_CLASSPATH_CMD_TYPE_VALUE $Type)
  4680. }
  4681. # tag:java-specific
  4682. IGNORE_JAVA_DEPENDENCIES_CONFIGURATION=no
  4683. JAVA_DEPENDENCIES_CONFIGURATION_VALUE=
  4684. # tag:java-specific
  4685. ### @usage JAVA_DEPENDENCIES_CONFIGURATION(Vetos...)
  4686. ### Validate contrib/java dependencies
  4687. ### Valid arguments
  4688. ### FORBID_DIRECT_PEERDIRS - fail when module have direct PEERDIR (with version) (non-transitive)
  4689. ### FORBID_CONFLICT - fail when module have resolved without DEPENDENCY_MANAGEMENT version conflict (transitive)
  4690. ### FORBID_CONFLICT_DM - fail when module have resolved with DEPENDENCY_MANAGEMENT version conflict (transitive)
  4691. ### FORBID_CONFLICT_DM_RECENT - like FORBID_CONFLICT_DM but fail only when dependency have more recent version than specified in DEPENDENCY_MANAGEMENT
  4692. ### REQUIRE_DM - all dependencies must be specified in DEPENDENCY_MANAGEMENT (transitive)
  4693. macro JAVA_DEPENDENCIES_CONFIGURATION(Args...) {
  4694. SET_APPEND(JAVA_DEPENDENCIES_CONFIGURATION_VALUE $Args)
  4695. }
  4696. # tag:java-specific
  4697. # TODO(DEVTOOLS-6901): remove this variable when there are no more references to it in jbuild
  4698. JAVA_FORBIDDEN_LIBRARIES_VALUE=
  4699. # tag:java-specific
  4700. JAR_INCLUDE_FILTER_VALUE=
  4701. JAR_EXCLUDE_FILTER_VALUE=
  4702. # tag:java-specific
  4703. ### @usage:JAR_INCLUDE(Filters...)
  4704. ### Filter .jar file content: keep only matched files
  4705. ### * and ** patterns are supported (like JAVA_SRCS)
  4706. macro JAR_INCLUDE(Filters...) {
  4707. SET_APPEND(JAR_INCLUDE_FILTER_VALUE $Filters)
  4708. }
  4709. # tag:java-specific
  4710. ### @usage:JAR_EXCLUDE(Filters...)
  4711. ### Filter .jar file content: remove matched files
  4712. ### * and ** patterns are supported (like JAVA_SRCS)
  4713. macro JAR_EXCLUDE(Filters...) {
  4714. SET_APPEND(JAR_EXCLUDE_FILTER_VALUE $Filters)
  4715. }
  4716. # tag:sandbox-specific
  4717. ### @usage: SANDBOX_TASK([Name])
  4718. ###
  4719. ### Multimodule describing Sandbox task (Python code that can be executed by Sandbox system).
  4720. ###
  4721. ### When being a final target, this multimodule builds Sandbox binary task. It may PEERDIR other SANDBOX_TASKs as libraries.
  4722. ### The final artifact is provided when SANDBOX_TASK is referred to by DEPENDS and BUNDLE macros.
  4723. ### As PEERDIR target, it works like regular PY2_LIBRARY with predefined dependencies on Sandbox SDK to allow code reuse among SANDBOX_TASKs.
  4724. ###
  4725. ### Currently Sandbox supports only Python 2.x, so both variants will be compatible only with Python 2.x modules
  4726. ### and will select multimodule variants accordingly.
  4727. ###
  4728. ### Documentation: https://wiki.yandex-team.ru/sandbox/tasks/binary
  4729. multimodule SANDBOX_TASK {
  4730. module SB_TASK_BIN: _PY2_PROGRAM {
  4731. PY_MAIN(sandbox.taskbox.binary)
  4732. PEERDIR(sandbox/bin sandbox/sdk2 sandbox/sandboxsdk sandbox/taskbox/worker)
  4733. SET_APPEND(NO_CHECK_IMPORTS_FOR_VALUE api.*)
  4734. SET_APPEND(NO_CHECK_IMPORTS_FOR_VALUE kernel.*)
  4735. SET_APPEND(NO_CHECK_IMPORTS_FOR_VALUE library.*)
  4736. SET_APPEND(NO_CHECK_IMPORTS_FOR_VALUE sky*)
  4737. REGISTER_SANDBOX_IMPORT(${MODDIR})
  4738. when ($FAIL_PY2 == "yes") {
  4739. _OK=no
  4740. }
  4741. elsewhen ($OPENSOURCE != "yes") {
  4742. PEERDIR+=build/rules/py2_deprecation
  4743. }
  4744. ASSERT(_OK You are using deprecated Python2-only code (SANDBOX_TASK). Please consider rewriting to 2/3-compatible code.)
  4745. }
  4746. module PY2: PY2_LIBRARY {
  4747. PEERDIR(sandbox/sdk2 sandbox/sandboxsdk)
  4748. REGISTER_SANDBOX_IMPORT(${MODDIR})
  4749. }
  4750. }
  4751. # tag:sandbox-specific
  4752. multimodule SANDBOX_PY23_TASK {
  4753. module SB_TASK_BIN: _PY2_PROGRAM {
  4754. .RESTRICTED=RUN_ANTLR4_PYTHON
  4755. PY_MAIN(sandbox.taskbox.binary)
  4756. PEERDIR(sandbox/bin sandbox/sdk2 sandbox/sandboxsdk sandbox/taskbox/worker)
  4757. SET_APPEND(NO_CHECK_IMPORTS_FOR_VALUE api.*)
  4758. SET_APPEND(NO_CHECK_IMPORTS_FOR_VALUE kernel.*)
  4759. SET_APPEND(NO_CHECK_IMPORTS_FOR_VALUE library.*)
  4760. SET_APPEND(NO_CHECK_IMPORTS_FOR_VALUE sky*)
  4761. REGISTER_SANDBOX_IMPORT(${MODDIR})
  4762. }
  4763. module PY2: PY2_LIBRARY {
  4764. .RESTRICTED=RUN_ANTLR4_PYTHON
  4765. PEERDIR(sandbox/sdk2 sandbox/sandboxsdk)
  4766. REGISTER_SANDBOX_IMPORT(${MODDIR})
  4767. OBJ_SUF=.py2
  4768. }
  4769. module PY3: PY3_LIBRARY {
  4770. .RESTRICTED=RUN_ANTLR4_PYTHON
  4771. when ($MSVC == "yes" || $CYGWIN == "yes") {
  4772. MODULE_PREFIX=py3
  4773. }
  4774. otherwise {
  4775. MODULE_PREFIX=libpy3
  4776. }
  4777. OBJ_SUF=.py3
  4778. RUN_CYTHON_SCRIPT_H=$YMAKE_PYTHON $CYTHON_SCRIPT
  4779. PEERDIR(sandbox/sdk2)
  4780. REGISTER_SANDBOX_IMPORT(${MODDIR})
  4781. }
  4782. }
  4783. # tag:sandbox-specific
  4784. ### @usage: SANDBOX_PY3_TASK([Name])
  4785. ###
  4786. ### Multimodule describing Sandbox task (Python3 code that can be executed by Sandbox system).
  4787. ###
  4788. ### When being a final target, this multimodule builds Sandbox binary task. It may PEERDIR other SANDBOX_PY3_TASKs as libraries.
  4789. ### The final artifact is provided when SANDBOX_PY3_TASK is referred to by DEPENDS and BUNDLE macros.
  4790. ### As PEERDIR target, it works like regular PY3_LIBRARY with predefined dependencies on Sandbox SDK to allow code reuse among SANDBOX_PY3_TASKs.
  4791. ###
  4792. ### Currently Sandbox supports Python 3.x only in binary tasks, both variants will be compatible only with Python 3.x and py23 libraries
  4793. ### and will select multimodule variants accordingly.
  4794. ###
  4795. ### Documentation: https://wiki.yandex-team.ru/sandbox/tasks/binary
  4796. multimodule SANDBOX_PY3_TASK {
  4797. module SB_TASK_BIN: PY3_PROGRAM_BIN {
  4798. .IGNORED=RUN_ANTLR4_PYTHON
  4799. PY_MAIN(sandbox.taskbox.binary)
  4800. PEERDIR(sandbox/bin sandbox/sdk2 sandbox/taskbox/worker)
  4801. SET_APPEND(NO_CHECK_IMPORTS_FOR_VALUE api.*)
  4802. SET_APPEND(NO_CHECK_IMPORTS_FOR_VALUE kernel.*)
  4803. SET_APPEND(NO_CHECK_IMPORTS_FOR_VALUE library.*)
  4804. SET_APPEND(NO_CHECK_IMPORTS_FOR_VALUE sky*)
  4805. REGISTER_SANDBOX_IMPORT(${MODDIR})
  4806. }
  4807. module PY3: PY3_LIBRARY {
  4808. PEERDIR(sandbox/sdk2)
  4809. REGISTER_SANDBOX_IMPORT(${MODDIR})
  4810. }
  4811. }
  4812. # tag:python-specific tag:internal
  4813. NO_PYTHON_INCLS=no
  4814. ### @usage: NO_PYTHON_INCLUDES() # internal
  4815. ###
  4816. ### Disable dependencies on libraries providing Python headers.
  4817. ### This is only used in Python libraries themselves to avoid PEERDIR loops.
  4818. macro NO_PYTHON_INCLUDES() {
  4819. ENABLE(NO_PYTHON_INCLS)
  4820. }
  4821. # tag:python-specific
  4822. ### @usage: PYTHON2_ADDINCL()
  4823. ###
  4824. ### This macro adds include path for Python headers (Python 2.x variant) without PEERDIR.
  4825. ### This should be used in 2 cases only:
  4826. ### - In PY2MODULE since it compiles into .so and uses external Python runtime;
  4827. ### - In system Python libraries themselves since proper PEERDIR there may create a loop;
  4828. ### In all other cases use USE_PYTHON2 macro instead.
  4829. ###
  4830. ### Never use this macro in PY2_PROGRAM, PY2_LIBRARY and PY23_LIBRARY: they have everything needed by default.
  4831. ###
  4832. ### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/py_srcs
  4833. macro PYTHON2_ADDINCL() {
  4834. _PYTHON_ADDINCL()
  4835. SET(MODULE_TAG PY2_NATIVE)
  4836. SET(PEERDIR_TAGS CPP_PROTO CPP_FBS PY2_NATIVE YQL_UDF_STATIC __EMPTY__ DLL_LIB)
  4837. }
  4838. # tag:python-specific tag:internal
  4839. ### @usage: _ARCADIA_PYTHON_ADDINCL() # internal
  4840. ### This macro sets up Python headers for modules with Arcadia python (e.g. PY2_LIBRARY) and configures module as Python 2.x.
  4841. macro _ARCADIA_PYTHON_ADDINCL() {
  4842. _PYTHON_ADDINCL()
  4843. SET(MODULE_TAG PY2)
  4844. SET(PEERDIR_TAGS PY2 PY2_NATIVE PY_PROTO PY2_FBS YQL_UDF_STATIC __EMPTY__ DLL_LIB)
  4845. }
  4846. # tag:python-specific tag:internal
  4847. ### @usage: _PYTHON_ADDINCL() # internal
  4848. ### This macro sets up Python 2.x headers for both Arcadia and non-Arcadia python.
  4849. macro _PYTHON_ADDINCL() {
  4850. SET(PYTHON2 yes)
  4851. SET(PYTHON3 no)
  4852. when ($USE_ARCADIA_PYTHON == "yes") {
  4853. ADDINCL+=GLOBAL contrib/libs/python/Include
  4854. CFLAGS+=-DARCADIA_PYTHON_UNICODE_SIZE=$ARCADIA_PYTHON_UNICODE_SIZE
  4855. }
  4856. otherwise {
  4857. when ($USE_SYSTEM_PYTHON) {
  4858. PEERDIR+=build/platform/python
  4859. }
  4860. otherwise {
  4861. CFLAGS+=$PYTHON_INCLUDE
  4862. }
  4863. }
  4864. }
  4865. # tag:python-specific
  4866. ### @usage: PYTHON3_ADDINCL()
  4867. ###
  4868. ### This macro adds include path for Python headers (Python 3.x variant).
  4869. ### This should be used in 2 cases only:
  4870. ### - In PY2MODULE since it compiles into .so and uses external Python runtime;
  4871. ### - In system Python libraries themselves since peerdir there may create a loop;
  4872. ### In all other cases use USE_PYTHON3() macro instead.
  4873. ###
  4874. ### Never use this macro in PY3_PROGRAM and PY3_LIBRARY and PY23_LIBRARY: they have everything by default.
  4875. ###
  4876. ### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/py_srcs
  4877. macro PYTHON3_ADDINCL() {
  4878. _PYTHON3_ADDINCL()
  4879. SET(MODULE_TAG PY3_NATIVE)
  4880. SET(PEERDIR_TAGS CPP_PROTO CPP_FBS PY3_NATIVE YQL_UDF_STATIC __EMPTY__ DLL_LIB)
  4881. }
  4882. # tag:python-specific tag:internal
  4883. ### @usage: _ARCADIA_PYTHON3_ADDINCL() # internal
  4884. ###
  4885. ### This macro sets up Python3 headers for modules with Arcadia python (e.g. PY3_LIBRARY) and configures module as Python 3.x.
  4886. macro _ARCADIA_PYTHON3_ADDINCL() {
  4887. _PYTHON3_ADDINCL()
  4888. SET(MODULE_TAG PY3)
  4889. SET(MODULE_LANG PY3)
  4890. SET(PEERDIR_TAGS PY3 PY3_BIN_LIB PY3TEST_LIBRARY PY3_NATIVE PY3_PROTO PY3_FBS YQL_UDF_STATIC __EMPTY__ DLL_LIB)
  4891. }
  4892. # tag:python-specific tag:internal
  4893. ### @usage: _PYTHON_ADDINCL() # internal
  4894. ###
  4895. ### This macro sets up Python 3.x headers for both Arcadia and non-Arcadia python.
  4896. macro _PYTHON3_ADDINCL() {
  4897. SET(PYTHON3 yes)
  4898. SET(PYTHON2 no)
  4899. when ($USE_ARCADIA_PYTHON == "yes") {
  4900. CFLAGS+=-DUSE_PYTHON3
  4901. ADDINCL+=GLOBAL contrib/libs/python/Include
  4902. }
  4903. otherwise {
  4904. when ($USE_SYSTEM_PYTHON) {
  4905. PEERDIR+=build/platform/python
  4906. }
  4907. otherwise {
  4908. CFLAGS+=$PYTHON_INCLUDE
  4909. }
  4910. }
  4911. }
  4912. # tag:python-specific
  4913. ### @usage: USE_PYTHON2()
  4914. ###
  4915. ### This adds Python 2.x runtime library to your LIBRARY and makes it Python2-compatible.
  4916. ### Compatibility means proper PEERDIRs, ADDINCLs and variant selection on PEERDIRs to multimodules.
  4917. ###
  4918. ### If you'd like to use #include <Python.h> with Python2 specify USE_PYTHON2 or better make it PY2_LIBRARY.
  4919. ### If you'd like to use #include <Python.h> with Python3 specify USE_PYTHON3 or better make it PY3_LIBRARY.
  4920. ### If you'd like to use #include <Python.h> with both Python2 and Python3 convert your LIBRARY to PY23_LIBRARY.
  4921. ###
  4922. ### @see: [PY2_LIBRARY](#module_PY2_LIBRARY), [PY3_LIBRARY](#module_PY3_LIBRARY), [PY23_LIBRARY](#multimodule_PY23_LIBRARY)
  4923. macro USE_PYTHON2() {
  4924. _ARCADIA_PYTHON_ADDINCL()
  4925. SET(PEERDIR_TAGS PY2 PY2_NATIVE CPP_PROTO CPP_FBS YQL_UDF_STATIC __EMPTY__ DLL_LIB)
  4926. PEERDIR(contrib/libs/python)
  4927. }
  4928. # tag:python-specific
  4929. ### @usage: USE_PYTHON3()
  4930. ###
  4931. ### This adds Python3 library to your LIBRARY and makes it Python3-compatible.
  4932. ### Compatibility means proper PEERDIRs, ADDINCLs and variant selection on PEERDIRs to multimodules.
  4933. ###
  4934. ### If you'd like to use #include <Python.h> with Python3 specify USE_PYTHON3 or better make it PY3_LIBRARY.
  4935. ### If you'd like to use #include <Python.h> with Python2 specify USE_PYTHON2 or better make it PY2_LIBRARY.
  4936. ### If you'd like to use #include <Python.h> with both Python2 and Python3 convert your LIBRARY to PY23_LIBRARY.
  4937. ###
  4938. ### @see: [PY2_LIBRARY](#module_PY2_LIBRARY), [PY3_LIBRARY](#module_PY3_LIBRARY), [PY23_LIBRARY](#multimodule_PY23_LIBRARY)
  4939. macro USE_PYTHON3() {
  4940. _ARCADIA_PYTHON3_ADDINCL()
  4941. SET(PEERDIR_TAGS PY3 PY3_BIN_LIB PY3TEST_LIBRARY PY3_NATIVE CPP_PROTO CPP_FBS YQL_UDF_STATIC __EMPTY__ DLL_LIB)
  4942. PEERDIR(contrib/libs/python)
  4943. when ($USE_ARCADIA_PYTHON == "yes") {
  4944. PEERDIR+=library/python/runtime_py3
  4945. }
  4946. }
  4947. # tag:python-specific
  4948. when ($PERL_DEFAULT_PEERDIR == "yes") {
  4949. when (($PERLXS == "yes") || ($PERLXSCPP == "yes") || ($USE_PERL == "yes")) {
  4950. PEERDIR+=build/platform/perl
  4951. }
  4952. }
  4953. # tag:perl-specific
  4954. ### @usage: USE_PERL_LIB()
  4955. ### Add dependency on Perl to your LIBRARY
  4956. macro USE_PERL_LIB() {
  4957. PEERDIR(build/platform/perl)
  4958. }
  4959. # tag:perl-specific
  4960. ### @usage: USE_PERL_514_LIB()
  4961. ### Add dependency on Perl 5.14 to your LIBRARY
  4962. macro USE_PERL_514_LIB() {
  4963. SET(PERL_SDK ubuntu-12)
  4964. SET(PERL_DEFAULT_PEERDIR no)
  4965. PEERDIR(build/platform/perl/5.14)
  4966. }
  4967. # tag:perl-specific
  4968. ### @usage: ADD_PERL_MODULE(Dir ModuleName)
  4969. ### Add dependency on specified Perl module to the library
  4970. macro ADD_PERL_MODULE(Dir, Module) {
  4971. PEERDIR($Dir)
  4972. SET_APPEND(modules $Module)
  4973. }
  4974. # tag:allocator
  4975. ### @usage: ALLOCATOR(Alloc) # Default: LF
  4976. ###
  4977. ### Set memory allocator implementation for the PROGRAM()/DLL() module.
  4978. ### This may only be specified for programs and dlls, use in other modules leads to configuration errors.
  4979. ###
  4980. ### Available allocators are: "LF", "LF_YT", "LF_DBG", "YT", "J", "B", "BM", "C", "TCMALLOC", "GOOGLE", "LOCKLESS", "SYSTEM", "FAKE", "MIM", "HU", "PROFILED_HU".
  4981. ### - LF - lfalloc (https://a.yandex-team.ru/arc/trunk/arcadia/library/cpp/lfalloc)
  4982. ### - LF_YT - Allocator selection for YT (https://a.yandex-team.ru/arc/trunk/arcadia/library/cpp/lfalloc/yt/ya.make)
  4983. ### - LF_DBG - Debug allocator selection (https://a.yandex-team.ru/arc/trunk/arcadia/library/cpp/lfalloc/dbg/ya.make)
  4984. ### - YT - The YTAlloc allocator (https://a.yandex-team.ru/arc/trunk/arcadia/library/cpp/ytalloc/impl/ya.make)
  4985. ### - J - The JEMalloc allocator (https://a.yandex-team.ru/arc/trunk/arcadia/library/malloc/jemalloc)
  4986. ### - B - The balloc allocator named Pyotr Popov and Anton Samokhvalov
  4987. ### - Discussion: https://ironpeter.at.yandex-team.ru/replies.xml?item_no=126
  4988. ### - Code: https://a.yandex-team.ru/arc/trunk/arcadia/library/cpp/balloc
  4989. ### - BM - The balloc for market (agri@ commits from july 2018 till November 2018 saved)
  4990. ### - C - Like B, but can be disabled for each thread to LF or SYSTEM one (B can be disabled only to SYSTEM)
  4991. ### - MIM - Microsoft's mimalloc (actual version) (https://a.yandex-team.ru/arc/trunk/arcadia/library/malloc/mimalloc)
  4992. ### - TCMALLOC - Google TCMalloc (actual version) (https://a.yandex-team.ru/arc/trunk/arcadia/library/malloc/tcmalloc)
  4993. ### - GOOGLE - Google TCMalloc (https://a.yandex-team.ru/arc/trunk/arcadia/library/malloc/galloc)
  4994. ### - LOCKLESS - Allocator based upon lockless queues (https://a.yandex-team.ru/arc/trunk/arcadia/library/malloc/lockless)
  4995. ### - SYSTEM - Use target system allocator
  4996. ### - FAKE - Don't link with any allocator
  4997. ### - HU - Huge page allocator by @gulin.
  4998. ### - PROFILED_HU - patched HU. It is a bit slower but has metrics of memory consumption.
  4999. ###
  5000. ### More about allocators in Arcadia: https://wiki.yandex-team.ru/arcadia/allocators/
  5001. macro ALLOCATOR(Alloc) {
  5002. SET(ALLOCATOR $Alloc)
  5003. 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", "TCMALLOC_TC", "GOOGLE", "LOCKLESS", "SYSTEM", "FAKE", "MIM", "HU", "PROFILED_HU" ]) {
  5004. }
  5005. otherwise {
  5006. PEERDIR+=___configure_error___unknown_allocator_type___$ALLOCATOR
  5007. }
  5008. }
  5009. when ($MIC_ARCH == "yes") {
  5010. CFLAGS+=-mmic
  5011. LDFLAGS+=-mmic
  5012. }
  5013. when ($USE_OPENMP == "yes") {
  5014. PEERDIR+=contrib/libs/openmp
  5015. }
  5016. when ($STRIP == "yes" && $NO_STRIP != "yes") {
  5017. STRIP_FLAG=$LD_STRIP_FLAG
  5018. DWARF_COMMAND=
  5019. GO_LINK_FLAGS_VALUE+=-s
  5020. }
  5021. when ($NO_LINKER_DCE != "yes") {
  5022. DCE_FLAG=$LD_DCE_FLAG
  5023. }
  5024. when ($BT_MINSIZEREL == "yes" || $LINKER_ICF == "yes") {
  5025. ICF_FLAG=$LD_ICF_FLAG
  5026. }
  5027. OBJCOPY_TOOL=$OBJCOPY_TOOL_VENDOR
  5028. OBJDUMP_TOOL=$OBJDUMP_TOOL_VENDOR
  5029. STRIP_TOOL=$STRIP_TOOL_VENDOR
  5030. NEED_BINUTILS_PEERDIR=
  5031. BINUTILS_USED=
  5032. when (!$OBJCOPY_TOOL_VENDOR) {
  5033. OBJCOPY_TOOL=$BINUTILS_ROOT_RESOURCE_GLOBAL/bin/objcopy
  5034. NEED_BINUTILS_PEERDIR=yes
  5035. }
  5036. when (!$OBJDUMP_TOOL_VENDOR) {
  5037. OBJDUMP_TOOL=$BINUTILS_ROOT_RESOURCE_GLOBAL/bin/objdump
  5038. NEED_BINUTILS_PEERDIR=yes
  5039. }
  5040. when (!$STRIP_TOOL_VENDOR) {
  5041. STRIP_TOOL=$BINUTILS_ROOT_RESOURCE_GLOBAL/bin/strip
  5042. NEED_BINUTILS_PEERDIR=yes
  5043. }
  5044. SPLIT_DWARF_VALUE=no
  5045. NO_SPLIT_DWARF=no
  5046. when ($OS_DARWIN) {
  5047. SPLIT_DWARF_VALUE=yes
  5048. }
  5049. when ($STRIP_DEBUG_INFO) {
  5050. SPLIT_DWARF_VALUE=yes
  5051. NO_SPLIT_DWARF=no
  5052. }
  5053. ### @usage: SPLIT_DWARF()
  5054. ###
  5055. ### Emit debug info for the PROGRAM/DLL as a separate file <module_name>.debug.
  5056. ### NB: It does not help you to save process RSS but can add problems (see e.g. BEGEMOT-2147).
  5057. macro SPLIT_DWARF() {
  5058. SET(SPLIT_DWARF_VALUE yes)
  5059. }
  5060. ### @usage: NO_SPLIT_DWARF()
  5061. ###
  5062. ### Do NOT emit debug info for the PROGRAM/DLL as a separate file.
  5063. ### On macOS this also means do NOT generate dSym files (faster linkage)
  5064. macro NO_SPLIT_DWARF() {
  5065. SET(SPLIT_DWARF_VALUE no)
  5066. }
  5067. SPLIT_DWARF_OUTPUT=${output;tobindir;pre=$MODULE_PREFIX;suf=$MODULE_SUFFIX.debug:REALPRJNAME}
  5068. when ($SPLIT_DWARF_VALUE == "yes" && $NO_SPLIT_DWARF != "yes" && $NO_DEBUGINFO != "yes" && $HOST_OS_LINUX == "yes" && $TARGET_PLATFORM == "LINUX") {
  5069. DWARF_COMMAND+= \
  5070. $OBJCOPY_TOOL --only-keep-debug $TARGET $SPLIT_DWARF_OUTPUT && \
  5071. $STRIP_TOOL --strip-debug $TARGET && \
  5072. $OBJCOPY_TOOL --remove-section=.gnu_debuglink --add-gnu-debuglink $SPLIT_DWARF_OUTPUT $TARGET
  5073. BINUTILS_USED=yes
  5074. }
  5075. ### @usage: EXTRALIBS_STATIC(Libs...)
  5076. ###
  5077. ### Add the specified external static libraries to the program link
  5078. macro EXTRALIBS_STATIC(Args...) {
  5079. LDFLAGS(-Wl,-Bstatic ${Args} -Wl,-Bdynamic)
  5080. }
  5081. ### @usage ADD_COMPILABLE_TRANSLATE(Dict Name Options...)
  5082. ###
  5083. ### Generate translation dictionary code to transdict.LOWER(Name).cpp that will than be compiled into library
  5084. macro ADD_COMPILABLE_TRANSLATE(Dict, Name, MakeTransDictOptions...) {
  5085. __translatename_lower=${tolower:Name}
  5086. __translate_dict=${BINDIR}/transdict.${__translatename_lower}.cpp
  5087. RUN_PROGRAM(dict/tools/maketransdict -i ${Dict} ${MakeTransDictOptions} ${Name} STDOUT_NOAUTO ${__translate_dict} IN ${Dict})
  5088. }
  5089. ### @usage ADD_COMPILABLE_TRANSLIT(TranslitTable NGrams Name Options...)
  5090. ###
  5091. ### Generate transliteration dictionary code
  5092. ### This will emit both translit, untranslit and ngrams table codes those will be than further compiled into library
  5093. macro ADD_COMPILABLE_TRANSLIT(TranslitTable, NGrams, Name, Options...) {
  5094. __translitname_lower=${tolower:Name}
  5095. __translit_table=${BINDIR}/translit_trie_${__translitname_lower}.cpp
  5096. __untranslit_table=${BINDIR}/untranslit_trie_${__translitname_lower}.cpp
  5097. __ngrams_table=${BINDIR}/ngr_arr_${__translitname_lower}.cpp
  5098. __gentrie_dir=dict/tools/make_untranslit_trie
  5099. RUN_PROGRAM(${__gentrie_dir} -i ${TranslitTable} ${Options} ${__translitname_lower} IN ${TranslitTable} STDOUT ${__untranslit_table})
  5100. RUN_PROGRAM(${__gentrie_dir} -i ${TranslitTable} -n ${Options} ${__translitname_lower} IN ${TranslitTable} STDOUT ${__translit_table})
  5101. RUN_PROGRAM(dict/tools/make_ngrams -i ${NGrams} ${Options} ${__translitname_lower} IN ${NGrams} STDOUT ${__ngrams_table})
  5102. }
  5103. # tag:python-specific tag:proto tag:deprecated
  5104. ### @usage GENERATE_PY_PROTOS(ProtoFiles...) # deprecated
  5105. ###
  5106. ### Generate python bindings for protobuf files.
  5107. ### Macro is obsolete and not recommended for use!
  5108. macro GENERATE_PY_PROTOS(FILES...) {
  5109. foreach (FILE : $FILES) {
  5110. _PY_PROTO_CMD($FILE)
  5111. }
  5112. }
  5113. # tag:python-specific tag:proto
  5114. macro _GENERATE_PY_PROTOS_INTERNAL(FILES...) {
  5115. foreach (FILE : $FILES) {
  5116. _PY_PROTO_CMD_INTERNAL($FILE)
  5117. }
  5118. }
  5119. # tag:python-specific
  5120. macro _GENERATE_PY_EVS_INTERNAL(FILES...) {
  5121. foreach (FILE : $FILES) {
  5122. _PY_EVLOG_CMD_INTERNAL($FILE)
  5123. }
  5124. }
  5125. macro _COPY_FILE_IMPL(FILE, AUTO_DST="", NOAUTO_DST="", OUTPUT_INCLUDES[], INDUCED_DEPS[], OUTPUT_INCLUDES_INP[]) {
  5126. .CMD=$COPY_CMD ${input:FILE} ${output:AUTO_DST} ${output;noauto:NOAUTO_DST} ${output_include;hide:OUTPUT_INCLUDES} ${output_include;from_input;hide:OUTPUT_INCLUDES_INP} $INDUCED_DEPS ${kv;hide:"p CP"} ${kv;hide:"pc light-cyan"}
  5127. .SEM=copy_file ${input:FILE} ${output:AUTO_DST} ${output;noauto:NOAUTO_DST}
  5128. }
  5129. ### @usage: COPY_FILE(File Destination [AUTO] [OUTPUT_INCLUDES Deps...])
  5130. ###
  5131. ### Copy file to build root. It is possible to change both location and the name.
  5132. ###
  5133. ### Parameters:
  5134. ### - File - Source file name.
  5135. ### - Destination - Output file name.
  5136. ### - AUTO - Consider copied file for further processing automatically.
  5137. ### - OUTPUT_INCLUDES output_includes... - Output file dependencies.
  5138. ### - INDUCED_DEPS $VARs... - Dependencies for generated files. Unlike `OUTPUT_INCLUDES` these may target files further in processing chain.
  5139. ### In order to do so VAR should be filled by PREPARE_INDUCED_DEPS macro, stating target files (by type)
  5140. ### and set of dependencies
  5141. ###
  5142. ### The file will be just copied if AUTO boolean parameter is not specified. You should explicitly
  5143. ### mention it in SRCS under new name (or specify AUTO boolean parameter) for further processing.
  5144. macro COPY_FILE(File, Destination, AUTO?"AUTO_DST":"NOAUTO_DST", OUTPUT_INCLUDES[], INDUCED_DEPS[]) {
  5145. .CMD=$_COPY_FILE_IMPL($File $AUTO $Destination OUTPUT_INCLUDES $OUTPUT_INCLUDES INDUCED_DEPS $INDUCED_DEPS)
  5146. .SEM=$_COPY_FILE_IMPL($File $AUTO $Destination)
  5147. }
  5148. ### @usage: COPY_FILE_WITH_CONTEXT(FILE DEST [AUTO] [OUTPUT_INCLUDES DEPS...])
  5149. ###
  5150. ### Copy file to build root the same way as it is done for COPY_FILE, but also
  5151. ### propagates the context of the source file.
  5152. macro COPY_FILE_WITH_CONTEXT(FILE, DEST, AUTO?"AUTO_DST":"NOAUTO_DST", OUTPUT_INCLUDES[], INDUCED_DEPS[]) {
  5153. .CMD=$_COPY_FILE_IMPL($FILE $AUTO $DEST OUTPUT_INCLUDES_INP $FILE OUTPUT_INCLUDES $OUTPUT_INCLUDES INDUCED_DEPS $INDUCED_DEPS)
  5154. }
  5155. ### This is to join $ALL_RES_ and $EXT
  5156. macro _ARF_HELPER(Args...) {
  5157. RESOURCE_FILES($Args)
  5158. }
  5159. ### @usage ALL_RESOURCE_FILES(Ext [PREFIX {prefix}] [STRIP {strip}] Dirs...)
  5160. ###
  5161. ### This macro collects all files with extension `Ext` and
  5162. ### Passes them to `RESOURCE_FILES` macro as relative to current directory
  5163. ###
  5164. ### `PREFIX` and `STRIP` have the same meaning as in `ROURCES_FILES`, both are applied over moddir-relative paths
  5165. ###
  5166. ### Note: This macro can be used multiple times per ya.make, but only once for each Ext value
  5167. ### Note: Wildcards are not allowed neither as Ext nor in Dirs
  5168. macro ALL_RESOURCE_FILES(EXT, PREFIX="", STRIP="", DIRS...) {
  5169. _GLOB(ALL_RES_$EXT ${suf=/*.$EXT:DIRS})
  5170. _ARF_HELPER(${pre=PREFIX :PREFIX} STRIP ${ARCADIA_ROOT}/${MODDIR}/${STRIP} ${pre=$ALL_RES_:EXT})
  5171. }
  5172. macro _BUNDLE_TARGET(Target, Destination) {
  5173. .CMD=$MOVE_FILE ${result:Target} ${output;noauto:Destination} ${kv;hide:"p BN"} ${kv;hide:"pc light-cyan"} $VCS_INFO_DISABLE_CACHE__NO_UID__
  5174. }
  5175. ### @usage: TIMEOUT(TIMEOUT)
  5176. ###
  5177. ### Sets a timeout on test execution
  5178. ###
  5179. ### Documentation about the system test: https://wiki.yandex-team.ru/yatool/test/
  5180. macro TIMEOUT(Time) {
  5181. SET(TEST_TIMEOUT $Time)
  5182. }
  5183. SBR_UID_EXT=""
  5184. # tag:test
  5185. ### @usage: VALIDATE_DATA_RESTART(ext)
  5186. ###
  5187. ### Change uid for resource validation tests. May be useful when sandbox resource ttl is changed, but test status is cached in CI.
  5188. ### You can change ext to change test's uid. For example VALIDATE_DATA_RESTART(X), where is X is current revision.
  5189. macro VALIDATE_DATA_RESTART(Ext) {
  5190. SET(SBR_UID_EXT $Ext)
  5191. }
  5192. # tag:test
  5193. TEST_FORK_MODE=none
  5194. TEST_PARTITION=SEQUENTIAL
  5195. # tag:test
  5196. ### @usage: FORK_TESTS()
  5197. ###
  5198. ### Splits a test run on chunks by test classes.
  5199. ### The number of chunks can be overridden using the macro SPLIT_FACTOR.
  5200. ###
  5201. ### Allows to run tests in parallel. Supported in UNITTEST, JTEST/JUNIT5 and PY2TEST/PY3TEST modules.
  5202. ###
  5203. ### Documentation about the system test: https://wiki.yandex-team.ru/yatool/test/
  5204. macro FORK_TESTS(MODE...) {
  5205. SET(TEST_FORK_MODE tests)
  5206. SET(TEST_PARTITION $MODE)
  5207. }
  5208. # tag:test
  5209. ### @usage: FORK_SUBTESTS()
  5210. ###
  5211. ### Splits the test run in chunks on subtests.
  5212. ### The number of chunks can be overridden using the macro SPLIT_FACTOR.
  5213. ###
  5214. ### Allows to run tests in parallel. Supported in UNITTEST, JTEST/JUNIT5 and PY2TEST/PY3TEST modules.
  5215. ###
  5216. ### Documentation about the system test: https://wiki.yandex-team.ru/yatool/test/
  5217. macro FORK_SUBTESTS(MODE...) {
  5218. SET(TEST_FORK_MODE subtests)
  5219. SET(TEST_PARTITION $MODE)
  5220. }
  5221. # tag:test
  5222. ### @usage: SPLIT_FACTOR(x)
  5223. ###
  5224. ### Sets the number of chunks for parallel run tests when used in test module with FORK_TESTS() or FORK_SUBTESTS().
  5225. ### If none of those is specified this macro implies FORK_TESTS().
  5226. ###
  5227. ### Supports C++ ut and PyTest.
  5228. ###
  5229. ### Documentation about the system test: https://wiki.yandex-team.ru/yatool/test/
  5230. macro SPLIT_FACTOR(Factor) {
  5231. SET(TEST_SPLIT_FACTOR $Factor)
  5232. }
  5233. # tag:test
  5234. FORK_TEST_FILES_MODE=
  5235. ### @usage: FORK_TEST_FILES()
  5236. ###
  5237. ### Only for PY2TEST and PY3TEST: splits a file executable with the tests on chunks in the files listed in TEST_SRCS
  5238. ### Compatible with FORK_(SUB)TESTS.
  5239. ###
  5240. ### Documentation about the system test: https://wiki.yandex-team.ru/yatool/test/
  5241. macro FORK_TEST_FILES() {
  5242. SET(FORK_TEST_FILES_MODE on)
  5243. }
  5244. # tag:test
  5245. TEST_SIZE_NAME=SMALL
  5246. ### @usage: SIZE(SMALL/MEDIUM/LARGE)
  5247. ###
  5248. ### Set the 'size' for the test. Each 'size' has own set of resrtictions, SMALL bein the most restricted and LARGE being the list.
  5249. ### See documentation on test system for more details.
  5250. ###
  5251. ### Documentation about the system test: https://wiki.yandex-team.ru/yatool/test/
  5252. macro SIZE(Type) {
  5253. SET(TEST_SIZE_NAME $Type)
  5254. }
  5255. ### @usage: JOIN_SRCS(Out Src...)
  5256. ###
  5257. ### Join set of sources into single file named Out and send it for further processing.
  5258. ### This macro doesn't place all file into Out, it emits #include<Src>... Use the for C++ source files only.
  5259. ### You should specify file name with the extension as Out. Further processing will be done according this extension.
  5260. macro JOIN_SRCS(Out, Src...) {
  5261. .CMD=$YMAKE_PYTHON3 ${input:"build/scripts/gen_join_srcs.py"} ${input;hide:"build/scripts/process_command_files.py"} ${output:Out} --ya-start-command-file ${input;rootrel:Src} --ya-end-command-file ${output_include;from_input;hide:Src} ${kv;hide:"p JS"} ${kv;hide:"pc magenta"}
  5262. .SEM=target_joined_source $Out ${input:Src} ${output;hide;suf=.o:Out} ${input;hide:"build/scripts/gen_join_srcs.py"} ${input;hide:"build/scripts/process_command_files.py"}
  5263. _CONDITIONAL_SRCS($TIDY_VALUE $Src)
  5264. }
  5265. ### @usage: JOIN_SRCS_GLOBAL(Out Src...)
  5266. ###
  5267. ### Join set of sources into single file named Out and send it for further processing as if it were listed as SRCS(GLOBAL Out).
  5268. ### This macro doesn't place all file into Out, it emits #include<Src>... Use the for C++ source files only.
  5269. ### You should specify file name with the extension as Out. Further processing will be done according to this extension.
  5270. macro JOIN_SRCS_GLOBAL(Out, Src...) {
  5271. .CMD=$YMAKE_PYTHON3 ${input:"build/scripts/gen_join_srcs.py"} ${input;hide:"build/scripts/process_command_files.py"} ${output;noauto:Out} --ya-start-command-file ${input;rootrel:Src} --ya-end-command-file ${output_include;from_input;hide:Src} ${kv;hide:"p JS"} ${kv;hide:"pc magenta"}
  5272. SRCS(GLOBAL $Out)
  5273. }
  5274. ### @usage: FLAT_JOIN_SRCS_GLOBAL(Out Src...)
  5275. ###
  5276. ### Join set of sources into single file named Out and send it for further processing as if it were listed as SRCS(GLOBAL Out).
  5277. ### This macro places all files into single file, so will work with any sources.
  5278. ### You should specify file name with the extension as Out. Further processing will be done according to this extension.
  5279. macro FLAT_JOIN_SRCS_GLOBAL(Out, Src...) {
  5280. .CMD=$FS_TOOLS cat ${output;noauto:Out} --ya-start-command-file ${input:Src} --ya-end-command-file ${output_include;from_input;hide:Src} ${kv;hide:"p JS"} ${kv;hide:"pc magenta"}
  5281. SRCS(GLOBAL $Out)
  5282. }
  5283. # tag:cpu
  5284. PIC_CFLAGS=
  5285. SSE2_CFLAGS=
  5286. SSE3_CFLAGS=
  5287. SSSE3_CFLAGS=
  5288. SSE41_CFLAGS=
  5289. SSE42_CFLAGS=
  5290. POPCNT_CFLAGS=
  5291. PCLMUL_CFLAGS=
  5292. CX16_FLAGS=
  5293. AVX_CFLAGS=
  5294. AVX2_CFLAGS=
  5295. AVX512_CFLAGS=
  5296. AMX_CFLAGS=
  5297. # tag:cpu
  5298. SSE_DEFINES=
  5299. SSE_CFLAGS=
  5300. SSE4_DEFINES=
  5301. SSE4_CFLAGS=
  5302. XOP_CFLAGS=
  5303. NO_LTO_CFLAGS=
  5304. # tag:cpu
  5305. when (($ARCH_X86_64 || $ARCH_I386) && $DISABLE_INSTRUCTION_SETS != "yes") {
  5306. when ($CLANG || $CLANG_CL || $GCC) {
  5307. PIC_CFLAGS=-fPIC
  5308. SSE2_CFLAGS=-msse2
  5309. SSE3_CFLAGS=-msse3
  5310. SSSE3_CFLAGS=-mssse3
  5311. SSE41_CFLAGS=-msse4.1
  5312. SSE42_CFLAGS=-msse4.2
  5313. XOP_CFLAGS=-mxop
  5314. POPCNT_CFLAGS=-mpopcnt
  5315. PCLMUL_CFLAGS=-mpclmul
  5316. AVX_CFLAGS=-mavx
  5317. # On Intel BMI1, BMI2 and FMA3 instruction sets come together with AVX-2 extension starting with Broadwell / Haswell.
  5318. # See:
  5319. # https://en.wikipedia.org/wiki/FMA_instruction_set
  5320. # https://en.wikipedia.org/wiki/X86_Bit_manipulation_instruction_set
  5321. #
  5322. # AMD implemented FMA3 in Piledriver architecture over AVX (that is, prior to AVX-2 which was introduced in Zen).
  5323. # BMI2 implementation was released by AMD along with AVX-2 support.
  5324. # See:
  5325. # https://en.wikipedia.org/wiki/Template:AMD_x86_CPU_features
  5326. #
  5327. # Due to the above, it looks safe to enable all three extensions whenever AVX-2 is enabled.
  5328. AVX2_CFLAGS=-mavx2 -mfma -mbmi -mbmi2
  5329. # All Intel CPUS with AVX-512 have these instructions except for the Knights Landing / Knights Mill
  5330. # (these are Xeon Phi)
  5331. # See:
  5332. # https://en.wikichip.org/wiki/x86/avx-512
  5333. AVX512_CFLAGS=-mavx512f -mavx512cd -mavx512bw -mavx512dq -mavx512vl
  5334. # AMX stands Advanced Matrix Extension supported by modern Intel architectures
  5335. # See:
  5336. # https://en.wikipedia.org/wiki/Advanced_Matrix_Extensions
  5337. # https://en.wikichip.org/wiki/x86/amx
  5338. AMX_CFLAGS=-mamx-tile -mamx-int8 ${AVX512_CFLAGS}
  5339. when ($ARCH_X86_64 && $OS_ANDROID != "yes") {
  5340. CX16_FLAGS=-mcx16
  5341. }
  5342. SSE_DEFINES=-DSSE_ENABLED=1 -DSSE3_ENABLED=1 -DSSSE3_ENABLED=1
  5343. SSE4_DEFINES=-DSSE41_ENABLED=1 -DSSE42_ENABLED=1 -DPOPCNT_ENABLED=1 -DCX16_ENABLED=1
  5344. }
  5345. elsewhen ($MSVC) {
  5346. SSE2_CFLAGS=/D__SSE2__=1
  5347. SSE3_CFLAGS=/D__SSE3__=1
  5348. SSSE3_CFLAGS=/D__SSSE3__=1
  5349. SSE41_CFLAGS=/D__SSE4_1__=1
  5350. SSE42_CFLAGS=/D__SSE4_2__=1
  5351. POPCNT_CFLAGS=/D__POPCNT__=1
  5352. PCLMUL_CFLAGS=/D__PCLMUL__=1
  5353. AVX_CFLAGS=/arch:AVX /DAVX_ENABLED=1
  5354. AVX2_CFLAGS=/arch:AVX2 /DAVX2_ENABLED=1
  5355. AVX512_CFLAGS=/arch:AVX512 /DAVX512_ENABLED=1
  5356. SSE_DEFINES=/DSSE_ENABLED=1 /DSSE3_ENABLED=1 /DSSSE3_ENABLED=1
  5357. SSE4_DEFINES=/DSSE41_ENABLED=1 /DSSE42_ENABLED=1 /DPOPCNT_ENABLED=1 /DCX16_ENABLED=1
  5358. }
  5359. SSE_CFLAGS=$SSE2_CFLAGS $SSE3_CFLAGS $SSSE3_CFLAGS
  5360. SSE4_CFLAGS=$SSE41_CFLAGS $SSE42_CFLAGS $POPCNT_CFLAGS $CX16_FLAGS
  5361. when ($ARCH_I386 && $OS_ANDROID == "yes") {
  5362. USE_SSE4=no
  5363. }
  5364. }
  5365. otherwise {
  5366. USE_SSE4=no
  5367. CPU_CHECK=no
  5368. }
  5369. # tag:cpu
  5370. when ($NOSSE == "yes") {
  5371. USE_SSE4=no
  5372. }
  5373. # tag:cpu
  5374. ### @usage: NO_SSE4()
  5375. ###
  5376. ### Compile module without SSE4
  5377. macro NO_SSE4() {
  5378. SET(USE_SSE4 no)
  5379. }
  5380. # tag:cpu
  5381. ### @usage: NO_CPU_CHECK()
  5382. ###
  5383. ### Compile module without startup CPU features check
  5384. macro NO_CPU_CHECK() {
  5385. SET(CPU_CHECK no)
  5386. }
  5387. ### @usage: ADDINCLSELF()
  5388. ###
  5389. ### The macro adds the -I<project source path> flag to the source compilation flags of the current project.
  5390. macro ADDINCLSELF(FOR="") {
  5391. when($FOR) {
  5392. ADDINCL+=FOR $FOR ${MODDIR}
  5393. }
  5394. otherwise {
  5395. ADDINCL+=${MODDIR}
  5396. }
  5397. }
  5398. COMPILE_OUT_SUFFIX=
  5399. _COMPILE_OUTPUTS=${output;suf=${COMPILE_OUT_SUFFIX}${OBJECT_SUF}:SRC}
  5400. _COMPILE_TIME_TRACE_OUTPUTS=${output;noauto;suf=${COMPILE_OUT_SUFFIX}${OBJECT_SUF}.time_trace.json:SRC}
  5401. macro SET_COMPILE_OUTPUTS_MODIFIERS(NOREL?";norel":"") {
  5402. SET(_COMPILE_OUTPUTS \${output;suf=\${OBJECT_SUF}$NOREL:SRC})
  5403. SET(_COMPILE_TIME_TRACE_OUTPUTS \${output;noauto;suf=\${OBJECT_SUF}.time_trace.json$NOREL:SRC})
  5404. }
  5405. # tag:internal
  5406. ### @usage: _ADD_EXTRA_FLAGS_IMPL([GENERATE] Args...) # internal
  5407. ### Generate prefix = " && set_property SOURCE ${input:SRC} APPEND PROPERTY COMPILE_OPTIONS " before $Args when GENERATE
  5408. ### is specified in the list of actual arguments
  5409. macro _ADD_EXTRA_FLAGS_IMPL(GENERATE?" && set_property SOURCE ${input:SRC} APPEND PROPERTY COMPILE_OPTIONS ":"", Args...) {
  5410. .SEM=$GENERATE $Args
  5411. }
  5412. # tag:internal
  5413. ### @usage: _ADD_EXTRA_FLAGS([GENERATE] Args...) # internal
  5414. ### Generate prefix = " && set_property SOURCE ${input:SRC} APPEND PROPERTY COMPILE_OPTIONS " if Args is not empty
  5415. macro _ADD_EXTRA_FLAGS(COMPILE_OUT_SUFFIX="", Args...) {
  5416. .SEM=$_ADD_EXTRA_FLAGS_IMPL(${pre=GENERATE :Args})
  5417. }
  5418. _EMPTY_CMD=
  5419. # tag:src-processing tag:internal
  5420. ### @usage: _SRC(Ext Src Flags) # internal
  5421. ###
  5422. ### Basic building block of extension-based command dispatching
  5423. ### To enable specific extension processing define _SRC() macro with fixed first argument (Ext).
  5424. ### Internal logic will apply this macro to all files with this Ext listed in SRC/SRCS macros or outputs
  5425. ### of other commands (except ones marked as noauto)
  5426. macro _SRC(EXT, SRC, SRCFLAGS...) {
  5427. # Generic macro definition for _SRC (just a placeholder, it does nothing)
  5428. }
  5429. _SWIG_CMD=$_SWIG_PYTHON_CMD
  5430. _SWIG_ADDINCLS=$_SWIG_PYTHON_ADDINCLS
  5431. _SWIG_PEERDIR=$_SWIG_PYTHON_PEERDIR
  5432. _SWIG_SEM_TO_MODULE_LINK=${output;hide;suf=.o:SRC}
  5433. _SWIG_PYTHON_CMD=${_SWIG_TOOL} -module ${REALPRJNAME} -cpperraswarn -c++ -python -interface ${MODULE_PREFIX}${REALPRJNAME} -o ${output;noext;main;suf=_wrap.swg.cpp:SRC} ${output;noauto;add_to_outs;hide;tobindir;suf=.py:REALPRJNAME} -outdir ${BINDIR} ${pre=-I:_SWIG__INCLUDE} ${input:SRC} ${kv;hide:"p SW"} ${kv;hide:"pc yellow"}
  5434. _SWIG_PYTHON_ADDINCLS=FOR swig ${_SWIG_LIBRARY}/python FOR swig ${_SWIG_LIBRARY}
  5435. _SWIG_PYTHON_PEERDIR=
  5436. _SWIG_PERL_CMD=${_SWIG_TOOL} -c++ -cpperraswarn -module ${REALPRJNAME} -shadow -perl -o ${output;noext;main;suf=_wrap.swg.cpp:SRC} ${output;noauto;add_to_outs;hide;tobindir;suf=.pm:REALPRJNAME} -outdir ${ARCADIA_BUILD_ROOT}/${MODDIR} ${pre=-I:_SWIG__INCLUDE} ${input:SRC} ${kv;hide:"p SW"} ${kv;hide:"pc yellow"}
  5437. _SWIG_PERL_ADDINCLS=FOR swig ${_SWIG_LIBRARY}/perl5 FOR swig ${_SWIG_LIBRARY}
  5438. _SWIG_PERL_PEERDIR=build/platform/perl
  5439. _SWIG_JNI_CPP_CMD=$YMAKE_PYTHON3 ${input:"build/scripts/jni_swig.py"} --swig ${_SWIG_TOOL} --default-module ${nopath;noext:SRC} --src ${input:SRC} --out-header ${output;main;noext;suf=_wrap.swg.h:SRC} --package-by-file ru/yandex/${input;rootrel:SRC} -- ${pre=-I:_SWIG__INCLUDE} -o ${output;noext;suf=_wrap.swg.cpp:SRC} ${kv;hide:"p SW"} ${kv;hide:"pc yellow"}
  5440. _SWIG_JNI_JAVA_CMD=$YMAKE_PYTHON3 ${input:"build/scripts/jni_swig.py"} --swig ${_SWIG_TOOL} --default-module ${nopath;noext:SRC} --src ${input:SRC} --package-by-file ru/yandex/${input;rootrel:SRC} --jsrc ${output;main;suf=.jsrc:SRC} -- ${pre=-I:_SWIG__INCLUDE} -o ${BINDIR}/unused.cpp ${kv;hide:"p SW"} ${kv;hide:"pc yellow"}
  5441. _SWIG_JNI_CMD=$YMAKE_PYTHON3 ${input:"build/scripts/jni_swig.py"} --swig ${_SWIG_TOOL} --default-module ${nopath;noext:SRC} --src ${input:SRC} --out-header ${output;main;noext;suf=_wrap.swg.h:SRC} --package-by-file ru/yandex/${input;rootrel:SRC} --jsrc ${output;suf=.jsrc:SRC} -- ${pre=-I:_SWIG__INCLUDE} -o ${output;noext;suf=_wrap.swg.cpp:SRC} ${kv;hide:"p SW"} ${kv;hide:"pc yellow"}
  5442. _SWIG_JNI_ADDINCLS=FOR swig ${_SWIG_LIBRARY}/java FOR swig $_SWIG_LIBRARY
  5443. _SWIG_JNI_PEERDIR=contrib/libs/jdk
  5444. when ($USE_LOCAL_SWIG == "yes") {
  5445. _SWIG_JNI_ADDINCLS=
  5446. }
  5447. when ($USE_SYSTEM_JDK == "yes" || $OS_ANDROID == "yes") {
  5448. _SWIG_JNI_PEERDIR=
  5449. }
  5450. # tag:src-processing
  5451. macro _SRC("swg", SRC, SRCFLAGS...) {
  5452. .CMD=${_SWIG_CMD}
  5453. .ADDINCL=${_SWIG_ADDINCLS}
  5454. .PEERDIR=${_SWIG_PEERDIR}
  5455. .SEM=conan_require_tool swig/4.0.2 && conan_import '"bin, *swig* -> ./bin"' ${input;hide:SRC} ${_SWIG_SEM_TO_MODULE_LINK}
  5456. }
  5457. RODATA_SYMBOL_PREFIX=
  5458. when ($DARWIN == "yes" || $IOS == "yes" || ($WINDOWS == "yes" && $ARCH_TYPE_32 == "yes")) {
  5459. RODATA_SYMBOL_PREFIX=_
  5460. }
  5461. RODATA_ELF_FLAGS=
  5462. when($LINUX == "yes" || $ANDROID == "yes") {
  5463. RODATA_ELF_FLAGS=--elf
  5464. }
  5465. 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})
  5466. when (($ARCH_AARCH64 || $ARCH_ARM || $ARCH_PPC64LE || $ARCH_RISCV32) == "yes") {
  5467. RODATA_COMPILE=$YMAKE_PYTHON3 ${input:"build/scripts/rodata2cpp.py"} ${noext;nopath:SRC} ${input:SRC} ${output;suf=.cpp:SRC}
  5468. }
  5469. # tag:src-processing
  5470. macro _SRC("rodata", SRC, SRCFLAGS...) {
  5471. .CMD=$RODATA_COMPILE ${hide;kv:"p RD"} ${hide;kv:"pc light-green"}
  5472. .SEM=target_rodata_sources PRIVATE ${input:SRC} ${output;hide;suf=${OBJ_SUF}.o:SRC} ${input;hide:"build/scripts/rodata2cpp.py"}
  5473. }
  5474. # tag:src-processing
  5475. macro _SRC("S", SRC, SRCFLAGS...) {
  5476. .CMD=$C_COMPILER $C_FLAGS_PLATFORM $CFLAGS $SFLAGS $SRCFLAGS -c -o ${output:SRC.o} ${input:SRC} ${pre=-I:_C__INCLUDE}
  5477. .SEM=target_sources PRIVATE ${input:SRC} ${output;hide;suf=${OBJ_SUF}.o:SRC} $_ADD_EXTRA_FLAGS($SRCFLAGS) && add_language ASM
  5478. }
  5479. # tag:src-processing
  5480. macro _SRC("s", SRC, SRCFLAGS...) {
  5481. .CMD=$_SRC(S, $SRC $SRCFLAGS)
  5482. }
  5483. # tag:src-processing
  5484. macro _SRC("s79", SRC, SRCFLAGS...) {
  5485. .CMD=$_SRC(S, $SRC $SRCFLAGS -x assembler-with-cpp)
  5486. }
  5487. # tag:src-processing
  5488. macro _SRC("mm", SRC, SRCFLAGS...) {
  5489. .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
  5490. }
  5491. # tag:src-processing
  5492. macro _SRC("fml", SRC, SRCFLAGS...) {
  5493. .CMD=$FML_TOOL $CHECKFLAG -b -o ${output:SRC.inc} -T ${input:SRC} ${SRCFLAGS} ${kv;hide:"p FM"} ${kv;hide:"pc yellow"}
  5494. }
  5495. # tag:src-processing
  5496. macro _SRC("fml2", SRC, SRCFLAGS...) {
  5497. .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"}
  5498. }
  5499. # tag:src-processing
  5500. macro _SRC("fml3", SRC, SRCFLAGS...) {
  5501. .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"}
  5502. }
  5503. # tag:src-processing
  5504. macro _SRC("sfdl", SRC, SRCFLAGS...) {
  5505. .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
  5506. }
  5507. macro _XS_SRCS(SRC, TYPEMAPS[], SRCFLAGS...) {
  5508. .CMD=$PERL_LD_LIBRARY_PATH $PERL $PERL_INCLUDE ${suf=/ExtUtils/xsubpp:PERL_PRIVLIB} -typemap ${suf=/ExtUtils/typemap:PERL_PRIVLIB} $PERLSUFFIX $XSUBPPFLAGS ${pre=-typemap :TYPEMAPS} ${input;hide:TYPEMAPS} ${SRCFLAGS} ${input:SRC} ${PERLOUTPUT} ${kv;hide:"p XS"} ${kv;hide:"pc yellow"}
  5509. }
  5510. # tag:src-processing
  5511. macro _SRC("xs", SRC, SRCFLAGS...) {
  5512. .CMD=$_XS_SRCS($SRC TYPEMAPS $_XSTYPEMAPS $SRCFLAGS)
  5513. }
  5514. # tag:src-processing
  5515. macro _SRC("gperf", SRC, SRCFLAGS...) {
  5516. .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"}
  5517. }
  5518. # tag:src-processing
  5519. macro _SRC("rl", SRC, SRCFLAGS...) {
  5520. .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"}
  5521. }
  5522. macro _SRC("xsyn", SRC, SRCFLAGS...) {
  5523. .CMD=$YMAKE_PYTHON ${input:"library/cpp/xml/parslib/xsyn2ragel.py"} ${input:SRC} ${input:"library/cpp/xml/parslib/xmlpars.xh"} dontuse ${output;stdout;suf=.h.rl5:SRC} ${kv;hide:"p XN"} ${kv;hide:"pc yellow"}
  5524. }
  5525. # tag:src-processing
  5526. macro _SRC("rl5", SRC, SRCFLAGS...) {
  5527. .CMD=$_SRC(rl $SRC $SRCFLAGS)
  5528. }
  5529. # tag:src-processing
  5530. macro _SRC("asp", SRC, SRCFLAGS...) {
  5531. .CMD=$RUN_NO_SANITIZE ${tool:"tools/html2cpp"} ${input:SRC} ${output:SRC.cpp} ${kv;hide:"p HT"} ${kv;hide:"pc yellow"}
  5532. }
  5533. # tag:src-processing
  5534. macro _SRC("rl6", SRC, SRCFLAGS...) {
  5535. .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"}
  5536. .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_tool ragel/6.10 && conan_import '"bin, ragel* -> ./bin"' ${input;hide:"build/scripts/run_tool.py"}
  5537. }
  5538. # tag:src-processing
  5539. macro _SRC("pln", SRC, SRCFLAGS...) {
  5540. .CMD=$FML_TOOL -b -o ${output;pre=pln.;nopath;noext:SRC.cpp} -f ${input:SRC} ${SRCFLAGS} ${kv;hide:"p FM"} ${kv;hide:"pc yellow"}
  5541. }
  5542. # tag:src-processing
  5543. macro _SRC("xsyn", SRC, SRCFLAGS...) {
  5544. .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"}
  5545. }
  5546. # tag:src-processing
  5547. macro _SRC("ev", SRC, SRCFLAGS...) {
  5548. .CMD=$EVLOG_CMD($SRC)
  5549. .SEM=$EVLOG_CMD($SRC)
  5550. }
  5551. # tag:src-processing
  5552. macro _SRC("proto", SRC, SRCFLAGS...) {
  5553. .CMD=$PROTO_CMD($SRC)
  5554. .SEM=$PROTO_CMD($SRC)
  5555. }
  5556. # tag:src-processing
  5557. macro _SRC("gztproto", SRC, SRCFLAGS...) {
  5558. # _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.
  5559. # descriptor.proto must be resolved as google/protobuf/descriptor.proto
  5560. .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"}
  5561. .PEERDIR=kernel/gazetteer/proto
  5562. }
  5563. # tag:src-processing
  5564. macro _SRC("cfgproto", SRC, SRCFLAGS...) {
  5565. .CMD=$_CPP_CFGPROTO_CMD($SRC)
  5566. }
  5567. # tag:src-processing
  5568. macro _SRC("pyx", SRC, SRCFLAGS...) {
  5569. # Copy-paste from BUILDWITH_CYTHON
  5570. .CMD=$RUN_CYTHON_SCRIPT $CYTHON_OPTIONS --cplus ${CYTHON_CPP_OUTPUT_INCLUDES} ${pre=-I:_CYTHON__INCLUDE} ${input:SRC} -o ${output;tobindir;suf=${OBJ_SUF}.cpp:SRC} $CYTHON_OUTPUT_INCLUDES ${SRCFLAGS} ${kv;hide:"p CY"} ${kv;hide:"pc yellow"}
  5571. .SEM=target_cython_sources PRIVATE ${input:Src} ${output;hide;tobindir:Src.fake.o} && target_cython_options $CYTHON_OPTIONS --cplus ${SRCFLAGS} ${CYTHON_CPP_OUTPUT_INCLUDES} && target_cython_include_directories $_CYTHON__INCLUDE && set_python_type_for_cython $PYTHON_TYPE_FOR_CYTHON
  5572. .ADDINCL=FOR cython contrib/tools/cython/Cython/Includes
  5573. }
  5574. # tag:src-processing
  5575. macro _SRC("in", SRC, SRCFLAGS...) {
  5576. .CMD=$CONFIGURE_FILE(${SRC} ${nopath;noext:SRC})
  5577. .SEM=$CONFIGURE_FILE(${SRC} ${nopath;noext:SRC})
  5578. }
  5579. macro MANUAL_GENERATION(Outs...) {
  5580. .SEM=IGNORED ${output;hide;noauto:Outs}
  5581. }
  5582. # tag:src-processing
  5583. macro _SRC("sc", SRC, SRCFLAGS...) {
  5584. .CMD=${tool:"tools/domschemec"} --in ${input:SRC} --out ${output;norel:SRC.h} ${output_include;hide:"util/generic/strbuf.h"} ${output_include;hide:"array"} ${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"}
  5585. }
  5586. # tag:src-processing
  5587. macro _SRC("ssqls", SRC, SRCFLAGS...) {
  5588. .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"}
  5589. }
  5590. # tag:src-processing
  5591. macro _SRC("f", SRC, SRCFLAGS...) {
  5592. .CMD=$YMAKE_PYTHON ${input:"build/scripts/f2c.py"} -t ${tool:"contrib/tools/f2c"} -c ${input:SRC} -o ${output:SRC.c} ${output_include;hide:"f2c.h"} ${kv;hide:"p FT"} ${kv;hide:"pc light-green"}
  5593. .PEERDIR=contrib/libs/libf2c
  5594. .ADDINCL=contrib/libs/libf2c
  5595. }
  5596. # tag:src-processing
  5597. macro _SRC("cpp", SRC, SRCFLAGS...) {
  5598. .CMD=$_SRC_cpp($SRC $SRCFLAGS)
  5599. .SEM=target_sources PRIVATE ${input:SRC} ${output;hide;suf=${OBJ_SUF}.o:SRC} $_ADD_EXTRA_FLAGS($SRCFLAGS)
  5600. }
  5601. # tag:src-processing
  5602. macro _SRC("cxx", SRC, SRCFLAGS...) {
  5603. .CMD=$_SRC(cpp $SRC $SRCFLAGS)
  5604. }
  5605. # tag:src-processing
  5606. macro _SRC("cc", SRC, SRCFLAGS...) {
  5607. .CMD=$_SRC(cpp $SRC $SRCFLAGS)
  5608. .SEM=target_sources PRIVATE ${input:SRC} ${output;hide;suf=${OBJ_SUF}.o:SRC} $_ADD_EXTRA_FLAGS($SRCFLAGS)
  5609. }
  5610. # tag:src-processing
  5611. macro _SRC("auxcpp", SRC, SRCFLAGS...) {
  5612. .CMD=$_SRC_cpp($SRC $_FORCE_CPP_FLAGS $SRCFLAGS)
  5613. .SEM=target_sources PRIVATE ${input:SRC} ${output;hide;suf=${OBJ_SUF}.o:SRC} $_ADD_EXTRA_FLAGS($_FORCE_CPP_FLAGS $SRCFLAGS)
  5614. }
  5615. # tag:src-processing
  5616. macro _SRC("C", SRC, SRCFLAGS...) {
  5617. .CMD=$_SRC(cpp $SRC $SRCFLAGS)
  5618. }
  5619. # tag:src-processing
  5620. macro _SRC("c", SRC, SRCFLAGS...) {
  5621. .CMD=$_SRC_c($SRC $SRCFLAGS)
  5622. .SEM=target_sources PRIVATE ${input:SRC} ${output;hide;suf=${OBJ_SUF}.o:SRC} $_ADD_EXTRA_FLAGS($SRCFLAGS $USER_CONLYFLAGS $USER_CONLYFLAGS_GLOBAL)
  5623. }
  5624. # tag:src-processing
  5625. macro _SRC("m", SRC, SRCFLAGS...) {
  5626. .CMD=$_SRC(c $SRC $SRCFLAGS)
  5627. }
  5628. # tag:src-processing
  5629. macro _SRC("masm", SRC, SRCFLAGS...) {
  5630. .CMD=$_SRC_masm($SRC $SRCFLAGS)
  5631. }
  5632. 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} ${input;hide:"build/scripts/run_tool.py"} \
  5633. && 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 \
  5634. && add_language ASM \
  5635. && conan_require_tool yasm/1.3.0 && conan_import '"bin, *yasm* -> ./bin"' && conan_import '"bin, ytasm* -> ./bin"'
  5636. ASM_SEM=target_yasm_source PRIVATE ${input:SRC} ${output;hide;suf=${OBJ_SUF}.o:SRC} $YASM_FLAGS ${pre=-I :_ASM__INCLUDE} $SRCFLAGS ${input;hide:"build/scripts/run_tool.py"} \
  5637. && 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 \
  5638. && add_language ASM \
  5639. && conan_require_tool yasm/1.3.0 && conan_import '"bin, *yasm* -> ./bin"' && conan_import '"bin, ytasm* -> ./bin"'
  5640. # tag:src-processing
  5641. macro _SRC("yasm", SRC, SRCFLAGS...) {
  5642. .CMD=$_SRC_yasm($SRC $SRCFLAGS PREINCLUDES $YASM_PREINCLUDES_VALUE)
  5643. .SEM=$YASM_SEM
  5644. }
  5645. # tag:src-processing
  5646. macro _SRC("asm", SRC, SRCFLAGS...) {
  5647. .CMD=$_SRC_ASM($SRC $SRCFLAGS PREINCLUDES $YASM_PREINCLUDES_VALUE)
  5648. .SEM=$ASM_SEM
  5649. }
  5650. # tag:src-processing
  5651. macro _SRC("lua", SRC, SRCFLAGS...) {
  5652. .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"}
  5653. .PEERDIR=$LUAJIT_PATH
  5654. }
  5655. NVCC_CFLAGS=
  5656. when ($IDE_MSVS_CALL == "yes") {
  5657. # This is to avoid issues with .pdb from MSVC calling nvcc calling cl
  5658. NVCC_CFLAGS+=/Fd$(TEMP)
  5659. }
  5660. NVCC_STD_VER=14
  5661. when ($MSVC == "yes") {
  5662. NVCC_STD=/std:c++${NVCC_STD_VER}
  5663. }
  5664. otherwise {
  5665. NVCC_STD=-std=c++${NVCC_STD_VER}
  5666. }
  5667. # tag:src-processing
  5668. macro _SRC("cu", SRC, SRCFLAGS...) {
  5669. .CMD=$_SRC_CU_CMD
  5670. .SEM=target_cuda_sources PRIVATE ${input:SRC} ${output;hide;suf=${OBJ_SUF}.o:SRC} && set_global_flags CMAKE_CUDA_STANDARD ${NVCC_STD_VER} && target_cuda_flags $CUDA_NVCC_FLAGS && target_cuda_cflags $USER_CXXFLAGS $SRCFLAGS $_SEM_EXTRA_CXX_FLAGS
  5671. .PEERDIR=$_SRC_CU_PEERDIR
  5672. }
  5673. # tag:src-processing
  5674. macro _SRC("fbs", SRC, SRCFLAGS...) {
  5675. .CMD=$FBS_CMD($SRC, $SRCFLAGS)
  5676. .SEM=$FBS_CMD($SRC, $SRCFLAGS)
  5677. }
  5678. # tag:src-processing
  5679. macro _SRC("fbs64", SRC, SRCFLAGS...) {
  5680. .CMD=$_CPP_FLATC64_CMD($SRC, $SRCFLAGS)
  5681. }
  5682. # tag:src-processing
  5683. macro _SRC("pysrc", SRC, SRCFLAGS...) {
  5684. .CMD=$_SRC_PYSRC($SRC, $SRCFLAGS)
  5685. }
  5686. # tag:src-processing
  5687. # This triggers configure error in attempt to add `ya.make` to SRCS macro or apply automatic processing by extension from codegen
  5688. macro _SRC("make", SRC, SRCFLAGS...) {
  5689. .CMD=
  5690. }
  5691. @import "${CONF_ROOT}/conf/bison_lex.conf"
  5692. # tag:src-processing
  5693. macro _SRC_py2src(SRC, SRCFLAGS...) {
  5694. .CMD=${cwd:BINDIR} $YMAKE_PYTHON3 ${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"}
  5695. }
  5696. # tag:src-processing
  5697. macro _SRC_py3src(SRC, SRCFLAGS...) {
  5698. .CMD=${cwd:BINDIR} $YMAKE_PYTHON3 ${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"}
  5699. }
  5700. # tag:src-processing python-specific
  5701. when ($PYTHON3 == "yes") {
  5702. MACRO_ALIAS(_SRC_PYSRC _SRC_py3src)
  5703. }
  5704. otherwise {
  5705. MACRO_ALIAS(_SRC_PYSRC _SRC_py2src)
  5706. }
  5707. # tag:src-processing
  5708. macro _SRC_c_nodeps(SRC, OUTFILE, INC...) {
  5709. .CMD=$_SRC_C_NODEPS_CMD
  5710. }
  5711. # Custom flags for generated cpp-files. To support another generator:
  5712. # - insert additional file extension before .cpp into generated cpp-file name
  5713. # - update _LANG_CFLAGS_FILTER variable. Don't forget to add ' SKIP ' after flag list
  5714. #
  5715. # ragel5 and ragel6 generated terrible code which makes use of goto's in switch statements.
  5716. # This triggers -Werror-implicit-fallthrough due to `unannotated fall-through between switch labels`.
  5717. #
  5718. # cython generated code also fails to pass this diagnostics due to `fallthrough annotation in unreachable code`.
  5719. # We use cython==0.29.26 at the time. This issue might be fixed in further versions.
  5720. #
  5721. # flags -fno-profile-instr-generate -fno-coverage-mapping needed to always disable coverage for .pyx, .rl5, .rl6
  5722. # generated sources
  5723. ## tag:src-processing
  5724. when ($CLANG == "yes") {
  5725. _LANG_CFLAGS_FILTER=\
  5726. ${pre=-Wno-implicit-fallthrough -fno-profile-instr-generate -fno-coverage-mapping SKIP ;ext=.rl5:SRC} \
  5727. ${pre=-Wno-implicit-fallthrough -fno-profile-instr-generate -fno-coverage-mapping SKIP ;ext=.rl6:SRC} \
  5728. ${pre=-Wno-implicit-fallthrough -fno-profile-instr-generate -fno-coverage-mapping SKIP ;ext=.pyx:SRC}
  5729. }
  5730. otherwise {
  5731. _LANG_CFLAGS_FILTER=\
  5732. ${pre=-Wno-implicit-fallthrough SKIP ;ext=.rl5:SRC} \
  5733. ${pre=-Wno-implicit-fallthrough SKIP ;ext=.rl6:SRC} \
  5734. ${pre=-Wno-implicit-fallthrough SKIP ;ext=.pyx:SRC}
  5735. }
  5736. # tag:src-processing
  5737. # Magic macro for removing file name from result (file name is passed as unused SKIP parameter)
  5738. macro _FILTER_EXTS(SKIP="", FLAGS...) {
  5739. .CMD=$FLAGS
  5740. }
  5741. # tag:src-processing
  5742. macro _LANG_CFLAGS(SRC) {
  5743. .CMD=$_FILTER_EXTS($_LANG_CFLAGS_FILTER)
  5744. }
  5745. # tag:src-processing
  5746. # ymake bug workaround: variables followed a macros call in .CMD are not substituted and are placed in result as is
  5747. # Pack macro call into a variable and use it in _SRC_CPP_CMD instead of macro call
  5748. _LANG_CFLAGS_VALUE=
  5749. when ($CLANG == "yes" || $CLANG_CL == "yes" || $GCC == "yes") {
  5750. _LANG_CFLAGS_VALUE=$_LANG_CFLAGS(${noext:SRC})
  5751. }
  5752. # Allows to add single compilation unit name to the node's 'kv' section.
  5753. # This is used by the coverage machinery to instrument only the necessary sources
  5754. # when --coverage-prefix-filter <rootrelpath> is specified. For more info see DEVTOOLSSUPPORT-16891
  5755. SCU_NAME_KV=
  5756. when ($CLANG_COVERAGE && $CLANG_COVERAGE != "no" && $USE_SCU_VALUE == "yes") {
  5757. SCU_NAME_KV=${hide;kv:"scu_name $KV_VAL"}
  5758. }
  5759. macro _ADD_SCU_NAME(KV_VAL) {
  5760. .CMD=$SCU_NAME_KV
  5761. }
  5762. # tag:src-processing
  5763. macro _SRC_cpp(SRC, COMPILE_OUT_SUFFIX="", SRCFLAGS...) {
  5764. .CMD=$_SRC_CPP_CMD $_ADD_SCU_NAME(${input:SRC})
  5765. }
  5766. # tag:src-processing
  5767. macro _SRC_c(SRC, COMPILE_OUT_SUFFIX="", SRCFLAGS...) {
  5768. .CMD=$_SRC_C_CMD $_ADD_SCU_NAME(${input:SRC})
  5769. }
  5770. # tag:src-processing
  5771. macro _SRC_m(SRC, SRCFLAGS...) {
  5772. .CMD=$_SRC_M_CMD
  5773. }
  5774. # tag:src-processing
  5775. macro _SRC_masm(SRC, SRCFLAGS...) {
  5776. .CMD=$_SRC_MASM_CMD
  5777. }
  5778. # tag:lua-specific
  5779. ### @usage: COMPILE_LUA(Src, [NAME <import_name>])
  5780. ###
  5781. ### Compile LUA source file to object code using LUA 2.0
  5782. ### Optionally override import name which is by default reflects Src name
  5783. macro COMPILE_LUA(Src, NAME="") {
  5784. .CMD=$_SRC(lua, $Src, ${pre=-n :NAME})
  5785. }
  5786. # tag:lua-specific
  5787. ### @usage: _SRC_lua_21(SRC [SRCFLAGS...]) # internal
  5788. ###
  5789. ### Compile LUA source file to object code using LUA 2.1
  5790. macro _SRC_lua_21(SRC, SRCFLAGS...) {
  5791. .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"}
  5792. .PEERDIR=$LUAJIT_21_PATH
  5793. }
  5794. # tag:lua-specific
  5795. ### @usage: COMPILE_LUA_21(Src, [NAME <import_name>])
  5796. ###
  5797. ### Compile LUA source file to object code using LUA 2.1
  5798. ### Optionally override import name which is by default reflects Src name
  5799. macro COMPILE_LUA_21(Src, NAME="") {
  5800. .CMD=$_SRC_lua_21($Src, ${pre=-n :NAME})
  5801. }
  5802. GETTEXT_KEEP_PATH=no
  5803. _MO_OUTPUT=
  5804. when ($GETTEXT_KEEP_PATH == "yes") {
  5805. _MO_OUTPUT=${output;noauto;norel;noext:SRC.mo}
  5806. }
  5807. otherwise {
  5808. _MO_OUTPUT=${output;noauto;nopath;noext;tobindir:SRC.mo}
  5809. }
  5810. # tag:src-processing
  5811. macro _SRC("po", SRC, SRCFLAGS...) {
  5812. .CMD=$YMAKE_PYTHON ${input:"contrib/tools/python/src/Tools/i18n/msgfmt.py"} -o $_MO_OUTPUT ${input:SRC}
  5813. }
  5814. # tag:ydl-specific
  5815. YDL_FLAGS= --force-color -I ${ARCADIA_ROOT}
  5816. YDL_DESC_FLAGS=
  5817. # tag:src-processing tag:ydl-specific
  5818. macro _SRC("ydl", SRC, SRCFLAGS...) {
  5819. .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"}
  5820. .PEERDIR+=statbox/ydl/runtime/cpp
  5821. }
  5822. # tag:ydl-specific
  5823. ### @usage BUILD_YDL_DESC(Input Symbol Output)
  5824. ###
  5825. ### Generate a descriptor for a Symbol located in a ydl module Input, and put it to the file Output.
  5826. ###
  5827. ### @example:
  5828. ###
  5829. ### PACKAGE()
  5830. ### BUILD_YDL_DESC(../types.ydl Event Event.ydld)
  5831. ### END()
  5832. ###
  5833. ### 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.
  5834. macro BUILD_YDL_DESC(Input, Symbol, Output) {
  5835. .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"}
  5836. }
  5837. # tag:ydl-specific
  5838. ### @usage: YDL_DESC_USE_BINARY()
  5839. ###
  5840. ### Used in conjunction with BUILD_YDL_DESC. When enabled, all generated descriptors are binary.
  5841. ###
  5842. ### @example:
  5843. ###
  5844. ### PACKAGE()
  5845. ### YDL_DESC_USE_BINARY()
  5846. ### BUILD_YDL_DESC(../types.ydl Event Event.ydld)
  5847. ### END()
  5848. ###
  5849. ### This will generate descriptor Event.ydld in a binary format.
  5850. macro YDL_DESC_USE_BINARY() {
  5851. YDL_DESC_FLAGS_BINARY= --binary
  5852. SET_APPEND(YDL_DESC_FLAGS $YDL_DESC_FLAGS_BINARY)
  5853. }
  5854. ### @usage SRC(File Flags...)
  5855. ###
  5856. ### Compile single file with extra Flags.
  5857. ### Compilation is driven by the last extension of the File and Flags are specific to corresponding compilation command
  5858. macro SRC(FILE, FLAGS...) {
  5859. _SRC(${lastext:FILE} $FILE $FLAGS)
  5860. }
  5861. ### @usage: SRCS(<[GLOBAL] File> ...)
  5862. ###
  5863. ### 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.
  5864. ### Arcadia Paths from the root and is relative to the project's LIST are supported
  5865. ###
  5866. ### 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.
  5867. ### 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)
  5868. ###
  5869. ### @example:
  5870. ###
  5871. ### LIBRARY(test_global)
  5872. ### SRCS(GLOBAL foo.cpp)
  5873. ### END()
  5874. ###
  5875. ### 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.
  5876. macro SRCS(FILES...) {
  5877. foreach (FILE : $FILES) {
  5878. _SRC(${lastext:FILE} $FILE)
  5879. }
  5880. }
  5881. # tag:c-specific
  5882. macro _SRC_C_CUSTOM_FLAGS(SRC, COMPILE_OUT_SUFFIX, CUSTOM_FLAGS...) {
  5883. .CMD=$_SRC_c($SRC COMPILE_OUT_SUFFIX ${COMPILE_OUT_SUFFIX} ${CUSTOM_FLAGS})
  5884. .SEM=target_sources_custom $COMPILE_OUT_SUFFIX SRCS ${input:SRC} ${hide;output;suf=${COMPILE_OUT_SUFFIX}.o:SRC} CUSTOM_FLAGS $CUSTOM_FLAGS $USER_CONLYFLAGS $USER_CONLYFLAGS_GLOBAL
  5885. }
  5886. macro _SRC_CPP_CUSTOM_FLAGS(SRC, COMPILE_OUT_SUFFIX, CUSTOM_FLAGS...) {
  5887. .CMD=$_SRC_cpp($SRC COMPILE_OUT_SUFFIX ${COMPILE_OUT_SUFFIX} ${CUSTOM_FLAGS})
  5888. .SEM=target_sources_custom $COMPILE_OUT_SUFFIX SRCS ${input:SRC} ${hide;output;suf=${COMPILE_OUT_SUFFIX}.o:SRC} CUSTOM_FLAGS $CUSTOM_FLAGS
  5889. }
  5890. # tag:src-specific tag:cpp-specific
  5891. ### @usage: _SRC_CUSTOM_C_CPP(Ext MacroName File Flags...) # internal
  5892. ###
  5893. ### Defenition of generic macro. Report an error that the File with Ext is not
  5894. ### supported by macro MacroName if no appropriate macro specialization is found.
  5895. macro _SRC_CUSTOM_C_CPP(EXT, MACRO_NAME, FILE, COMPILE_OUT_SUFFIX, FLAGS...) {
  5896. MESSAGE(FATAL_ERROR macro [[alt1]]$MACRO_NAME[[rst]] does not support files with [[imp]].$EXT[[rst]] extension)
  5897. }
  5898. # tag:src-specific tag:cpp-specific
  5899. ### @usage: _SRC_CUSTOM_C_CPP(Ext MacroName File Flags...) # internal
  5900. ###
  5901. ### Specialization of genreric macro _SRC_CUSTOM_C_CPP which compiles a single C file (with .c extension)
  5902. macro _SRC_CUSTOM_C_CPP("c", MACRO_NAME, FILE, COMPILE_OUT_SUFFIX, FLAGS...) {
  5903. _SRC_C_CUSTOM_FLAGS($FILE $COMPILE_OUT_SUFFIX $FLAGS)
  5904. }
  5905. # tag:src-specific tag:cpp-specific
  5906. ### @usage: _SRC_CUSTOM_C_CPP(Ext MacroName File Flags...) # internal
  5907. ###
  5908. ### Specialization of genreric macro _SRC_CUSTOM_C_CPP which compiles a single Cpp file (with .cpp extension)
  5909. macro _SRC_CUSTOM_C_CPP("cpp", MACRO_NAME, FILE, COMPILE_OUT_SUFFIX, FLAGS...) {
  5910. _SRC_CPP_CUSTOM_FLAGS($FILE $COMPILE_OUT_SUFFIX $FLAGS)
  5911. }
  5912. # tag:src-specific tag:cpp-specific
  5913. ### @usage: _SRC_CUSTOM_C_CPP(Ext MacroName File Flags...) # internal
  5914. ###
  5915. ### Specialization of genreric macro _SRC_CUSTOM_C_CPP which compiles a single Cpp file (with .cxx extension)
  5916. macro _SRC_CUSTOM_C_CPP("cxx", MACRO_NAME, FILE, COMPILE_OUT_SUFFIX, FLAGS...) {
  5917. _SRC_CPP_CUSTOM_FLAGS($FILE $COMPILE_OUT_SUFFIX $FLAGS)
  5918. }
  5919. # tag:src-specific tag:cpp-specific
  5920. ### @usage: _SRC_CUSTOM_C_CPP(Ext MacroName File Flags...) # internal
  5921. ###
  5922. ### Specialization of genreric macro _SRC_CUSTOM_C_CPP which compiles a single Cpp file (with .cc extension)
  5923. macro _SRC_CUSTOM_C_CPP("cc", MACRO_NAME, FILE, COMPILE_OUT_SUFFIX, FLAGS...) {
  5924. _SRC_CPP_CUSTOM_FLAGS($FILE $COMPILE_OUT_SUFFIX $FLAGS)
  5925. }
  5926. # tag:src-specific tag:cpp-specific
  5927. ### @usage: _SRC_CUSTOM_C_CPP(Ext MacroName File Flags...) # internal
  5928. ###
  5929. ### Specialization of genreric macro _SRC_CUSTOM_C_CPP which compiles a single Cpp file (with .C extension)
  5930. macro _SRC_CUSTOM_C_CPP("C", MACRO_NAME, FILE, COMPILE_OUT_SUFFIX, FLAGS...) {
  5931. _SRC_CPP_CUSTOM_FLAGS($FILE $COMPILE_OUT_SUFFIX $FLAGS)
  5932. }
  5933. # tag:src-specific tag:cpp-specific tag:cpu
  5934. ### @uasge SRC_C_SSE2(File Flags...)
  5935. ###
  5936. ### Compile a single C/C++ file with SSE2 and additional Flags
  5937. macro SRC_C_SSE2(FILE, FLAGS...) {
  5938. _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_SSE2 $FILE .sse2 $SSE2_CFLAGS $FLAGS)
  5939. }
  5940. # tag:src-specific tag:cpp-specific tag:cpu
  5941. ### @uasge SRC_C_SSE3(File Flags...)
  5942. ###
  5943. ### Compile a single C/C++ file with SSE3 and additional Flags
  5944. macro SRC_C_SSE3(FILE, FLAGS...) {
  5945. _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_SSE3 $FILE .sse3 $SSE3_CFLAGS $FLAGS)
  5946. }
  5947. # tag:src-specific tag:cpp-specific tag:cpu
  5948. ### @uasge SRC_C_SSSE3(File Flags...)
  5949. ###
  5950. ### Compile a single C/C++ file with SSSE3 and additional Flags
  5951. macro SRC_C_SSSE3(FILE, FLAGS...) {
  5952. _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_SSSE3 $FILE .ssse3 $SSSE3_CFLAGS $FLAGS)
  5953. }
  5954. # tag:src-specific tag:cpp-specific tag:cpu
  5955. ### @uasge SRC_C_SSE4(File Flags...)
  5956. ###
  5957. ### Compile a single C/C++ file with SSE4 and additional Flags
  5958. macro SRC_C_SSE4(FILE, FLAGS...) {
  5959. _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_SSE4 $FILE .sse4 $SSE4_CFLAGS $FLAGS)
  5960. }
  5961. # tag:src-specific tag:cpp-specific tag:cpu
  5962. ### @uasge SRC_C_SSE41(File Flags...)
  5963. ###
  5964. ### Compile a single C/C++ file with SSE4.1 and additional Flags
  5965. macro SRC_C_SSE41(FILE, FLAGS...) {
  5966. _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_SSE41 $FILE .sse41 $SSE41_CFLAGS $FLAGS)
  5967. }
  5968. # tag:src-specific tag:cpp-specific tag:cpu
  5969. ### @uasge SRC_C_AVX(File Flags...)
  5970. ###
  5971. ### Compile a single C/C++ file with AVX and additional Flags
  5972. macro SRC_C_AVX(FILE, FLAGS...) {
  5973. _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_AVX $FILE .avx $AVX_CFLAGS $FLAGS)
  5974. }
  5975. # tag:src-specific tag:cpp-specific tag:cpu
  5976. ### @uasge SRC_C_AVX2(File Flags...)
  5977. ###
  5978. ### Compile a single C/C++ file with AVX2 and additional Flags
  5979. macro SRC_C_AVX2(FILE, FLAGS...) {
  5980. _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_AVX2 $FILE .avx2 $AVX2_CFLAGS $FLAGS)
  5981. }
  5982. # tag:src-specific tag:cpp-specific tag:cpu
  5983. ### @uasge SRC_C_AVX512(File Flags...)
  5984. ###
  5985. ### Compile a single C/C++ file with AVX512 and additional Flags
  5986. macro SRC_C_AVX512(FILE, FLAGS...) {
  5987. _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_AVX512 $FILE .avx512 $AVX512_CFLAGS $FLAGS)
  5988. }
  5989. # tag:src-specific tag:cpp-specific tag:cpu
  5990. ### @uasge SRC_C_AVX512(File Flags...)
  5991. ###
  5992. ### Compile a single C/C++ file with AVX512 and additional Flags
  5993. macro SRC_C_AMX(FILE, FLAGS...) {
  5994. _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_AMX $FILE .amx $AMX_CFLAGS $FLAGS)
  5995. }
  5996. # tag:src-specific tag:cpp-specific tag:cpu
  5997. ### @uasge SRC_C_XOP(File Flags...)
  5998. ###
  5999. ### Compile a single C/C++ file with (an AMD-specific instruction set,
  6000. ### see https://en.wikipedia.org/wiki/XOP_instruction_set) and additional Flags
  6001. macro SRC_C_XOP(FILE, FLAGS...) {
  6002. _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_XOP $FILE .xop $XOP_CFLAGS $FLAGS)
  6003. }
  6004. # tag:src-specific tag:cpp-specific tag:cpu
  6005. ### @uasge SRC_C_PCLMUL(File Flags...)
  6006. ###
  6007. ### Compile a single C/C++ file with PCLMUL and additional Flags
  6008. macro SRC_C_PCLMUL(FILE, FLAGS...) {
  6009. _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_PCLMUL $FILE .pclmul $PCLMUL_CFLAGS $FLAGS )
  6010. }
  6011. # tag:src-specific tag:cpp-specific
  6012. ### @usage: _SRC_STRICT_C_CPP(Ext MacroName File Flags...) # internal
  6013. ###
  6014. ### Defenition of generic macro. Report an error that the File with Ext is not
  6015. ### supported by macro MacroName if no appropriate macro specialization is found.
  6016. macro _SRC_STRICT_C_CPP(EXT, MACRO_NAME, FILE, FLAGS...) {
  6017. MESSAGE(FATAL_ERROR macro [[alt1]]$MACRO_NAME[[rst]] does not support files with [[imp]].$EXT[[rst]] extension)
  6018. }
  6019. # tag:src-specific tag:cpp-specific
  6020. ### @usage: _SRC_STRICT_C_CPP(Ext MacroName File Flags...) # internal
  6021. ###
  6022. ### Specialization of genreric macro _SRC_STRICT_C_CPP which compiles a single C file (with .c extension)
  6023. macro _SRC_STRICT_C_CPP("c", MACRO_NAME, FILE, FLAGS...) {
  6024. _SRC(c $FILE $FLAGS)
  6025. }
  6026. # tag:src-specific tag:cpp-specific
  6027. ### @usage: _SRC_STRICT_C_CPP(Ext MacroName File Flags...) # internal
  6028. ###
  6029. ### Specialization of genreric macro _SRC_STRICT_C_CPP which compiles a single Cpp file (with .cpp extension)
  6030. macro _SRC_STRICT_C_CPP("cpp", MACRO_NAME, FILE, FLAGS...) {
  6031. _SRC(cpp $FILE $FLAGS)
  6032. }
  6033. # tag:src-specific tag:cpp-specific
  6034. ### @usage: _SRC_STRICT_C_CPP(Ext MacroName File Flags...) # internal
  6035. ###
  6036. ### Specialization of genreric macro _SRC_STRICT_C_CPP which compiles a single Cpp file (with .cxx extension)
  6037. macro _SRC_STRICT_C_CPP("cxx", MACRO_NAME, FILE, FLAGS...) {
  6038. _SRC(cpp $FILE $FLAGS)
  6039. }
  6040. # tag:src-specific tag:cpp-specific
  6041. ### @usage: _SRC_STRICT_C_CPP(Ext MacroName File Flags...) # internal
  6042. ###
  6043. ### Specialization of genreric macro _SRC_STRICT_C_CPP which compiles a single Cpp file (with .cc extension)
  6044. macro _SRC_STRICT_C_CPP("cc", MACRO_NAME, FILE, FLAGS...) {
  6045. _SRC(cpp $FILE $FLAGS)
  6046. }
  6047. # tag:src-specific tag:cpp-specific
  6048. ### @usage: _SRC_STRICT_C_CPP(Ext MacroName File Flags...) # internal
  6049. ###
  6050. ### Specialization of genreric macro _SRC_STRICT_C_CPP which compiles a single Cpp file (with .C extension)
  6051. macro _SRC_STRICT_C_CPP("C", MACRO_NAME, FILE, FLAGS...) {
  6052. _SRC(cpp $FILE $FLAGS)
  6053. }
  6054. # tag:src-specific tag:cpp-specific
  6055. ### @uasge SRC_C_PIC(File Flags...)
  6056. ###
  6057. ### Compile a single C/C++ file with -fPIC and additional Flags
  6058. macro SRC_C_PIC(FILE, FLAGS...) {
  6059. _SRC_STRICT_C_CPP(${lastext:FILE} SRC_C_PIC $FILE $PIC_CFLAGS $FLAGS)
  6060. }
  6061. # tag:src-specific tag:cpp-specific
  6062. ### @uasge SRC_C_NO_LTO(File Flags...)
  6063. ###
  6064. ### Compile a single C/C++ file with link-time-optimization disabling and additional Flags
  6065. macro SRC_C_NO_LTO(FILE, FLAGS...) {
  6066. _SRC_STRICT_C_CPP(${lastext:FILE} SRC_C_NO_LTO $FILE $NO_LTO_CFLAGS $FLAGS)
  6067. }
  6068. # tag:python-processing tag:cython
  6069. # TODO: use it in [.pyx] cmd
  6070. ### @usage: BUILDWITH_CYTHON_CPP(Src Options...)
  6071. ###
  6072. ### Generates .cpp file from .pyx.
  6073. macro BUILDWITH_CYTHON_CPP(Src, Options...) {
  6074. .CMD=$RUN_CYTHON_SCRIPT $CYTHON_OPTIONS ${Options} --cplus ${CYTHON_CPP_OUTPUT_INCLUDES} ${pre=-I:_CYTHON__INCLUDE} ${input:Src} -o ${output;tobindir;suf=${OBJ_SUF}.cpp:Src} $CYTHON_OUTPUT_INCLUDES ${kv;hide:"p CY"} ${kv;hide:"pc yellow"}
  6075. .SEM=target_cython_sources PRIVATE ${input:Src} ${output;hide;tobindir:Src.fake.o} && target_cython_options $CYTHON_OPTIONS ${Options} --cplus ${CYTHON_CPP_OUTPUT_INCLUDES} && target_cython_include_directories $_CYTHON__INCLUDE && set_python_type_for_cython $PYTHON_TYPE_FOR_CYTHON
  6076. ADDINCL(FOR cython contrib/tools/cython/Cython/Includes)
  6077. }
  6078. # tag:python-processing tag:cython tag:internal
  6079. ### @usage: _BUILDWITH_CYTHON_CPP_DEP(Src Dep Options...) # internal
  6080. ###
  6081. ### Generates .cpp file from .pyx and attach extra input Dep.
  6082. ### If Dep changes the .cpp file will be re-generated.
  6083. macro _BUILDWITH_CYTHON_CPP_DEP(Src, Dep, Options...) {
  6084. .CMD=$RUN_CYTHON_SCRIPT $CYTHON_OPTIONS ${Options} --cplus ${CYTHON_CPP_OUTPUT_INCLUDES} ${pre=-I:_CYTHON__INCLUDE} ${input:Src} ${input;hide:Dep} -o ${output;tobindir;suf=${OBJ_SUF}.cpp:Src} $CYTHON_OUTPUT_INCLUDES ${kv;hide:"p CY"} ${kv;hide:"pc yellow"}
  6085. .SEM=target_cython_sources PRIVATE ${input:Src} ${input;hide:Dep} ${output;hide;tobindir:Src.fake.o} && target_cython_options $CYTHON_OPTIONS ${Options} --cplus ${CYTHON_CPP_OUTPUT_INCLUDES} && target_cython_include_directories $_CYTHON__INCLUDE && set_python_type_for_cython $PYTHON_TYPE_FOR_CYTHON
  6086. ADDINCL(FOR cython contrib/tools/cython/Cython/Includes)
  6087. }
  6088. # tag:python-processing tag:cython tag:internal
  6089. ### @usage: _BUILDWITH_CYTHON_CPP_H(Src Dep Options...) # internal
  6090. ###
  6091. ### BUILDWITH_CYTHON_CPP without .pyx infix and with cdef public .h file.
  6092. macro _BUILDWITH_CYTHON_CPP_H(Src, Dep, Options...) {
  6093. .CMD=$RUN_CYTHON_SCRIPT_H $CYTHON_OPTIONS ${Options} --cplus ${CYTHON_CPP_OUTPUT_INCLUDES} ${pre=-I:_CYTHON__INCLUDE} ${input:Src} ${input;hide:Dep} -o ${output;noext;tobindir:Src.cpp} ${output;hide;addincl;noext;tobindir:Src.h} ${kv;hide:"p CY"} ${kv;hide:"pc yellow"}
  6094. ADDINCL(FOR cython contrib/tools/cython/Cython/Includes)
  6095. }
  6096. # tag:python-processing tag:cython
  6097. ### @usage: BUILDWITH_CYTHON_C(Src Options...)
  6098. ###
  6099. ### Generates .c file from .pyx.
  6100. macro BUILDWITH_CYTHON_C(Src, Options...) {
  6101. .CMD=$RUN_CYTHON_SCRIPT $CYTHON_OPTIONS ${Options} ${pre=-I:_CYTHON__INCLUDE} ${input:Src} -o ${output;tobindir;suf=${OBJ_SUF}.c:Src} $CYTHON_OUTPUT_INCLUDES ${kv;hide:"p CY"} ${kv;hide:"pc yellow"}
  6102. .SEM=target_cython_sources PRIVATE ${input:Src} ${output;hide;tobindir:Src.fake.o} && target_cython_options $CYTHON_OPTIONS ${Options} ${CYTHON_OUTPUT_INCLUDES} && target_cython_include_directories $_CYTHON__INCLUDE && set_python_type_for_cython $PYTHON_TYPE_FOR_CYTHON
  6103. ADDINCL(FOR cython contrib/tools/cython/Cython/Includes)
  6104. }
  6105. # tag:python-processing tag:cython tag:internal
  6106. ### @usage: _BUILDWITH_CYTHON_C_DEP(Src Dep Options...) # internal
  6107. ###
  6108. ### Generates .c file from .pyx and attach extra input Dep.
  6109. ### If Dep changes the .c file will be re-generated.
  6110. macro _BUILDWITH_CYTHON_C_DEP(Src, Dep, Options...) {
  6111. .CMD=$RUN_CYTHON_SCRIPT $CYTHON_OPTIONS ${Options} ${pre=-I:_CYTHON__INCLUDE} ${input:Src} ${input;hide:Dep} -o ${output;tobindir;suf=${OBJ_SUF}.c:Src} $CYTHON_OUTPUT_INCLUDES ${kv;hide:"p CY"} ${kv;hide:"pc yellow"}
  6112. .SEM=target_cython_sources PRIVATE ${input:Src} ${input;hide:Dep} ${output;hide;tobindir:Src.fake.o} && target_cython_options $CYTHON_OPTIONS ${Options} ${CYTHON_OUTPUT_INCLUDES} && target_cython_include_directories $_CYTHON__INCLUDE && set_python_type_for_cython $PYTHON_TYPE_FOR_CYTHON
  6113. ADDINCL(FOR cython contrib/tools/cython/Cython/Includes)
  6114. }
  6115. # tag:python-processing tag:cython tag:internal
  6116. ### @usage: _BUILDWITH_CYTHON_C_H(Src Dep Options...) # internal
  6117. ###
  6118. ### BUILDWITH_CYTHON_C without .pyx infix and with cdef public .h file.
  6119. macro _BUILDWITH_CYTHON_C_H(Src, Dep, Options...) {
  6120. .CMD=$RUN_CYTHON_SCRIPT_H $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"}
  6121. ADDINCL(FOR cython contrib/tools/cython/Cython/Includes)
  6122. }
  6123. # tag:python-processing tag:cython tag:internal
  6124. ### @usage: _BUILDWITH_CYTHON_C_API_H(Src Dep Options...) # internal
  6125. ###
  6126. ### BUILDWITH_CYTHON_C_H with cdef api _api.h file.
  6127. macro _BUILDWITH_CYTHON_C_API_H(Src, Dep, Options...) {
  6128. .CMD=$RUN_CYTHON_SCRIPT_H $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"}
  6129. ADDINCL(FOR cython contrib/tools/cython/Cython/Includes)
  6130. }
  6131. # tag:python-processing tag:internal
  6132. ### @usage: _SWIG_PYTHON_CPP(Src, DstSubPrefix) # internal
  6133. ###
  6134. ### Run swig on Src to produce DstSubPrefix.py and DstSubPrefix_swg.cpp that
  6135. ### provides DstSubPrefix_swg python module.
  6136. macro _SWIG_PYTHON_CPP(Src, DstSubPrefix) {
  6137. .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"}
  6138. ADDINCL(FOR swig $_SWIG_LIBRARY/python FOR swig $_SWIG_LIBRARY)
  6139. }
  6140. # tag:python-processing tag:internal
  6141. ### @usage: _SWIG_PYTHON_C(Src, DstSubPrefix) # internal
  6142. ###
  6143. ### Like _SWIG_PYTHON_CPP but generate DstSubPrefix_swg.c.
  6144. macro _SWIG_PYTHON_C(Src, DstSubPrefix) {
  6145. .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"}
  6146. ADDINCL(FOR swig $_SWIG_LIBRARY/python FOR swig $_SWIG_LIBRARY)
  6147. }
  6148. ### @usage: BUILDWITH_RAGEL6(Src Options...)
  6149. ###
  6150. ### Compile .rl file using Ragel6.
  6151. macro BUILDWITH_RAGEL6(Src, Options...) {
  6152. .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"}
  6153. }
  6154. # tag:python-processing tag:internal
  6155. # TODO: use it in [.pyx] cmd
  6156. ### @usage: _PY_REGISTER() # internal
  6157. ###
  6158. ### Register Python 2.x module in internal resource file system. Arcadia Python 2.x importer will be retrieve these on import directive.
  6159. ###
  6160. ### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/pysrcs/#makrospyregister
  6161. macro _PY_REGISTER(Func) {
  6162. .CMD=$YMAKE_PYTHON ${input:"build/scripts/gen_py_reg.py"} $Func ${output;noauto:Func.reg.cpp} ${kv;hide:"p PY"} ${kv;hide:"pc yellow"}
  6163. SRCS(GLOBAL $Func.reg.cpp)
  6164. }
  6165. # tag:python-processing tag:internal
  6166. ### @usage: _PY3_REGISTER() # internal
  6167. ###
  6168. ### Register Python 3.x module in internal resource file system. Arcadia Python 3.x importer will be retrieve these on import directive
  6169. ###
  6170. ### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/pysrcs/#makrospyregister
  6171. macro _PY3_REGISTER(Func) {
  6172. .CMD=$YMAKE_PYTHON ${input:"build/scripts/gen_py3_reg.py"} $Func ${output;noauto:Func.reg3.cpp} ${kv;hide:"p PY"} ${kv;hide:"pc yellow"}
  6173. SRCS(GLOBAL $Func.reg3.cpp)
  6174. }
  6175. # tag:python-processing tag:internal
  6176. ### @usage: _PY_COMPILE_BYTECODE(SrcX Src) # internal
  6177. ###
  6178. ### Compile Python 2.x .py source file into Arcadia binary form suitable for PY2_PROGRAM
  6179. ###
  6180. ### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/pysrcs/#makrospyregister
  6181. macro _PY_COMPILE_BYTECODE(SrcX, Src, Dst) {
  6182. .CMD=$YMAKE_PYTHON ${input:"build/scripts/py_compile.py"} $SrcX ${input:Src} ${output;noauto:Dst.yapyc} ${kv;hide:"p PY"} ${kv;hide:"pc yellow"}
  6183. }
  6184. # tag:python-processing tag:internal
  6185. ### @usage: _PY3_COMPILE_BYTECODE(SrcX Src) # internal
  6186. ###
  6187. ### Compile Python 3.x .py source file into Arcadia binary form suitable for PY3_PROGRAM
  6188. ###
  6189. ### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/pysrcs/#makrospyregister
  6190. macro _PY3_COMPILE_BYTECODE(SrcX, Src, Dst) {
  6191. .CMD=${env:"PYTHONHASHSEED=0"} ${tool:"contrib/tools/python3/pycc"} $SrcX ${input:Src} ${output;noauto:Dst.yapyc3} ${kv;hide:"p PY"} ${kv;hide:"pc yellow"}
  6192. }
  6193. macro _ARCHIVE_SEM_HELPER(FLAGS[], OUT, Files...) {
  6194. .SEM=add_custom_command OUTPUT ${OUT} DEPENDS $ARCH_TOOL ${join= :Files} COMMAND $ARCH_TOOL $FLAGS ${join=\: :Files}: -o ${OUT}
  6195. }
  6196. ### @usage: ARCHIVE_ASM(NAME archive_name files...)
  6197. ###
  6198. ### Similar to the macro ARCHIVE, but:
  6199. ### 1. works faster and it is better to use for large files.
  6200. ### 2. Different syntax (see examples in codesearch or users/pg/tests/archive_test)
  6201. macro ARCHIVE_ASM(NAME="", DONTCOMPRESS?"-p":"", Files...) {
  6202. .CMD=$ARCH_TOOL -q $DONTCOMPRESS ${input;join=\: :Files}: -o ${output;suf=$OBJ_SUF.rodata:NAME} ${kv;hide:"p AR"} ${kv;hide:"pc light-cyan"}
  6203. .SEM=$_ARCHIVE_SEM_HELPER(${output;suf=$OBJ_SUF.rodata:NAME} ${input:Files} FLAGS -q $DONTCOMPRESS)
  6204. }
  6205. # tag:yweb-specific
  6206. macro PIRE_INLINE_CMD(SRC) {
  6207. .CMD=${tool:"library/cpp/regex/pire/inline"} -o ${output:SRC} ${input:SRC} ${output_include;hide:SRC} ${kv;hide:"p PI"} ${kv;hide:"pc yellow"}
  6208. }
  6209. # tag:yweb-specific
  6210. macro PIRE_INLINE(FILES...) {
  6211. foreach (FILE : $FILES) {
  6212. PIRE_INLINE_CMD($FILE)
  6213. }
  6214. }
  6215. ### @usage: ARCHIVE(archive_name [DONT_COMPRESS] files...)
  6216. ###
  6217. ### Add arbitrary data to a modules. Unlike RESOURCE macro the result should be futher processed by othet macros in the module.
  6218. ###
  6219. ### Example: https://wiki.yandex-team.ru/yatool/howtowriteyamakefiles/#a1ispolzujjtekomanduarchive
  6220. macro ARCHIVE(NAME="", DONTCOMPRESS?"-p":"", Files...) {
  6221. .CMD=$ARCH_TOOL -q -x $DONTCOMPRESS ${input;join=\: :Files}: -o ${output;addincl;noauto:NAME} ${kv;hide:"p AR"} ${kv;hide:"pc light-red"}
  6222. .SEM=$_ARCHIVE_SEM_HELPER(${output;addincl;noauto:NAME} ${input:Files} FLAGS -q -x $DONTCOMPRESS) && target_sources PRIVATE $BINDIR/$NAME
  6223. }
  6224. ### @usage: ARCHIVE_BY_KEYS(archive_name key [DONT_COMPRESS] files...)
  6225. ###
  6226. ### Add arbitrary data to a module be accessible by specified key.
  6227. ### Unlike RESOURCE macro the result should be futher processed by othet macros in the module.
  6228. ###
  6229. ### Example: https://wiki.yandex-team.ru/yatool/howtowriteyamakefiles/#a1ispolzujjtekomanduarchive
  6230. macro ARCHIVE_BY_KEYS(NAME="", KEYS="", DONTCOMPRESS?"-p":"", Files...) {
  6231. .CMD=$ARCH_TOOL -q -x $DONTCOMPRESS ${input:Files} -k $KEYS -o ${output;addincl;noauto:NAME} ${kv;hide:"p AR"} ${kv;hide:"pc light-red"}
  6232. }
  6233. #scripts
  6234. #special commands
  6235. BUILDVERSION_SCRIPT=build/scripts/build_info_gen.py
  6236. SVNVERSION_JAVA_MARKER=output-java-class
  6237. SVNVERSION_GO_MARKER=output-go
  6238. VCS_C_OBJ=$BINDIR/__vcs_version__.c$OBJECT_SUF
  6239. VCS_C_OBJ_RR=$MODDIR/__vcs_version__.c$OBJECT_SUF
  6240. VCS_C=$BINDIR/__vcs_version__.c
  6241. VCS_GO=$BINDIR/__vcs_version__.go
  6242. VCS_JAVA=$BINDIR/__vcs_version__.mf
  6243. VCS_INFO_DISABLE_CACHE__NO_UID__=
  6244. YASM_DEBUG_INFO_DISABLE_CACHE__NO_UID__=
  6245. CL_DEBUG_INFO_DISABLE_CACHE__NO_UID__=
  6246. CL_MACRO_INFO_DISABLE_CACHE__NO_UID__=
  6247. YASM_DEBUG_INFO=
  6248. CL_DEBUG_INFO=
  6249. CL_MACRO_INFO=
  6250. when ($FORCE_VCS_INFO_UPDATE == "yes") {
  6251. VCS_INFO_DISABLE_CACHE__NO_UID__=${hide;kv:"disable_cache"}
  6252. }
  6253. ### Works for pyton too.
  6254. GENERATE_VCS_C_INFO_NODEP=$YMAKE_PYTHON3 ${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))
  6255. GENERATE_VCS_GO_INFO_NODEP=$YMAKE_PYTHON3 ${input:"build/scripts/vcs_info.py"} output-go $(VCS)/vcs.json $VCS_GO $VCS_INFO_DISABLE_CACHE__NO_UID__
  6256. 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__
  6257. macro UPDATE_VCS_JAVA_INFO_NODEP(Jar) {
  6258. .CMD=$YMAKE_PYTHON3 ${input:"build/scripts/vcs_info.py"} output-java $(VCS)/vcs.json $VCS_JAVA $Jar $VCS_INFO_DISABLE_CACHE__NO_UID__
  6259. }
  6260. VCS_INFO_FILE=
  6261. ### @usage VCS_INFO_FILE([FILE out_file])
  6262. ###
  6263. ### Enable saving vcs info as a json-file into PACKAGE
  6264. ###
  6265. ### Info is saved to 'vcs_info.json' by default.
  6266. ### Use FILE parameter if you want another name.
  6267. ###
  6268. ### Note: macro can be used only once per module
  6269. macro VCS_INFO_FILE(FILE="vcs_info.json") {
  6270. SET(VCS_INFO_FILE $FILE)
  6271. }
  6272. ADD_VCS_INFO_FILE_CMD=
  6273. when ($VCS_INFO_FILE) {
  6274. ADD_VCS_INFO_FILE_CMD=$YMAKE_PYTHON3 ${input:"build/scripts/vcs_info.py"} output-json $(VCS)/vcs.json ${output:VCS_INFO_FILE} $VCS_INFO_DISABLE_CACHE__NO_UID__
  6275. }
  6276. ### @usage: CREATE_BUILDINFO_FOR(GenHdr)
  6277. ###
  6278. ### Creates header file to access some information about build specified via configuration variables.
  6279. ### Unlike CREATE_SVNVERSION_FOR() it doesn't take revion information from VCS, it uses revision and SandboxTaskId passed via -D options to ya make
  6280. macro CREATE_BUILDINFO_FOR(GenHdr) {
  6281. .CMD=$YIELD $CXX_COMPILER && $YIELD $CXXFLAGS && $XARGS $YMAKE_PYTHON3 ${input:BUILDVERSION_SCRIPT} ${output:GenHdr} ${kv;hide:"p BI"} ${kv;hide:"pc yellow"} ${hide;kv:"show_out"} $SVN_DEPENDS_CACHE__NO_UID__
  6282. .SEM=$RUN_PYTHON3($BUILDVERSION_SCRIPT $GenHdr \\\"${CMAKE_CXX_COMPILER}\\\" \\\"${CMAKE_CXX_FLAGS}\\\" OUT $GenHdr)
  6283. }
  6284. DECIMAL_MD5_SCRIPT=build/scripts/decimal_md5.py
  6285. DECIMAL_MD5_FIXED=
  6286. ### @usage: DECIMAL_MD5_LOWER_32_BITS(<fileName> [FUNCNAME funcName] [inputs...])
  6287. ###
  6288. ### Generates .cpp file <fileName> with one defined function 'const char* <funcName>() { return "<calculated_md5_hash>"; }'.
  6289. ### <calculated_md5_hash> will be md5 hash for all inputs passed to this macro.
  6290. macro DECIMAL_MD5_LOWER_32_BITS(File, FUNCNAME="", Opts...) {
  6291. .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:File} ${kv;hide:"p SV"} ${kv;hide:"pc yellow"} ${hide;kv:"show_out"}
  6292. }
  6293. # tag:internal
  6294. ### @usage $CFG_VARS # internal
  6295. ###
  6296. ### Mark commands that embed Configuration variables into files
  6297. macro CFG_VARS() {
  6298. .GEN_FROM_FILE=yes
  6299. }
  6300. ### @usage: CONFIGURE_FILE(from to)
  6301. ###
  6302. ### Copy file with the replacement of configuration variables in form of @ANY_CONF_VAR@ with their values.
  6303. ### The values are collected during configure stage, while replacement itself happens during build stage.
  6304. ### Used implicitly for .in-files processing.
  6305. macro CONFIGURE_FILE(Src, Dst) {
  6306. .CMD=$YMAKE_PYTHON ${input:"build/scripts/configure_file.py"} ${input:Src} ${output;addincl:Dst} $CFG_VARS ${kv;hide:"p CF"} ${kv;hide:"pc yellow"}
  6307. .SEM=set_vars ${CFG_VARS} && configure_file $S/${input;rootrel:Src} $B/${output;addincl;rootrel:Dst}
  6308. }
  6309. ### @usage: BASE_CODEGEN(tool_path prefix)
  6310. ###
  6311. ### Generator ${prefix}.cpp + ${prefix}.h files based on ${prefix}.in.
  6312. macro BASE_CODEGEN(Tool, Prefix, Opts...) {
  6313. .CMD=${tool:Tool} ${input:Prefix.in} ${output;nopath;noauto:Prefix.cpp} ${output;nopath:Prefix.h} $Opts ${kv;hide:"p BC"} ${kv;hide:"pc yellow"}
  6314. }
  6315. # tag:internal
  6316. ### @usage: _SPLIT_CODEGEN_BASE(tool prefix OUTS[] OUTPUT_INCLUDES[]) # internal
  6317. ###
  6318. ### Generator of a certain number .the. cpp file + one header .h file from .in.
  6319. ### This is the call of the generator. Python macro SPLIT_CODEGEN() is defined in order to properly fill command outputs from OUT_NUM argument.
  6320. macro _SPLIT_CODEGEN_BASE(Tool, Prefix, OUT[], OPTS[], OUTPUT_INCLUDES[]) {
  6321. .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"}
  6322. }
  6323. STRUCT_CODEGEN_OUTPUT_INCLUDES=${output_include;hide:"util/generic/singleton.h"} \
  6324. ${output_include;hide:"util/generic/strbuf.h"} \
  6325. ${output_include;hide:"util/generic/vector.h"} \
  6326. ${output_include;hide:"util/generic/ptr.h"} \
  6327. ${output_include;hide:"util/generic/yexception.h"} \
  6328. ${output_include;hide:"kernel/struct_codegen/reflection/reflection.h"} \
  6329. ${output_include;hide:"kernel/struct_codegen/reflection/floats.h"}
  6330. ### @usage: STRUCT_CODEGEN(Prefix)
  6331. ### A special case BASE_CODEGEN, in which the kernel/struct_codegen/codegen_tool tool is used.
  6332. macro STRUCT_CODEGEN(Prefix) {
  6333. .CMD=$BASE_CODEGEN(kernel/struct_codegen/codegen_tool, $Prefix, $STRUCT_CODEGEN_OUTPUT_INCLUDES)
  6334. .PEERDIR=kernel/struct_codegen/metadata kernel/struct_codegen/reflection
  6335. }
  6336. ### @usage: DUMPERF_CODEGEN(Prefix)
  6337. ### A special case BASE_CODEGEN, in which the extsearch/images/robot/tools/dumperf/codegen tool is used
  6338. macro DUMPERF_CODEGEN(Prefix) {
  6339. .CMD=$BASE_CODEGEN(extsearch/images/robot/tools/dumperf/codegen, $Prefix, ${output_include;hide:"extsearch/images/kernel/erf/erf_format.h"})
  6340. }
  6341. # tag:flags
  6342. ### @usage: LDFLAGS(LinkerFlags...)
  6343. ###
  6344. ### Add flags to the link command line of executable or shared library/dll.
  6345. ### Note: LDFLAGS are always global. When set in the LIBRARY module they will affect all programs/dlls/tests the library is linked into.
  6346. ### Note: remember about the incompatibility of flags for gcc and cl.
  6347. macro LDFLAGS(Flags...) {
  6348. SET_APPEND(LDFLAGS_GLOBAL $Flags)
  6349. }
  6350. # tag:flags
  6351. ### @usage: CFLAGS([GLOBAL compiler_flag]* compiler_flags)
  6352. ###
  6353. ### Add the specified flags to the compilation command of C and C++ files.
  6354. ### @params: GLOBAL - Propagates these flags to dependent projects
  6355. ### Note: remember about the incompatibility flags for clang and cl (to set flags specifically for cl.exe use MSVC_FLAGS).
  6356. macro CFLAGS(Flags...) {
  6357. SET_APPEND_WITH_GLOBAL(USER_CFLAGS $Flags)
  6358. }
  6359. # tag:flags
  6360. ### @usage: MASMFLAGS(compiler flags)
  6361. ### Add the specified flags to the compilation command of .masm files.
  6362. macro MASMFLAGS(Flags...) {
  6363. SET_APPEND(MASMFLAGS $Flags)
  6364. }
  6365. # tag:flags
  6366. ### @usage: CONLYFLAGS([GLOBAL compiler_flag]* compiler_flags)
  6367. ### Add the specified flags to the compilation command of .c (but not .cpp) files.
  6368. ### @params: GLOBAL - Distributes these flags on dependent projects
  6369. macro CONLYFLAGS(Flags...) {
  6370. SET_APPEND_WITH_GLOBAL(USER_CONLYFLAGS $Flags)
  6371. }
  6372. # tag:flags
  6373. ### @usage: CXXFLAGS(compiler_flags)
  6374. ### Add the specified flags to the compilation command of .cpp (but not .c) files.
  6375. macro CXXFLAGS(Flags...) {
  6376. SET_APPEND_WITH_GLOBAL(USER_CXXFLAGS $Flags)
  6377. }
  6378. # tag:flags
  6379. ### @usage: CUDA_NVCC_FLAGS(compiler flags)
  6380. ### Add the specified flags to the compile line .cu-files.
  6381. macro CUDA_NVCC_FLAGS(Flags...) {
  6382. SET_APPEND(CUDA_NVCC_FLAGS $Flags)
  6383. }
  6384. # tag:flags
  6385. ### @usage: NVCC_DEVICE_LINK(file.cu...)
  6386. ### Run nvcc --device-link on objects compiled from srcs with --device-c.
  6387. ### This generates a stub object devlink.o that supplies missing pieces for the
  6388. ### host linker to link relocatable device objects into the final executable.
  6389. macro NVCC_DEVICE_LINK(Srcs...) {
  6390. .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"}
  6391. }
  6392. # tag:flags
  6393. ### @usage: CYTHON_FLAGS(compiler_flags)
  6394. ### Add the specified flags to the compilation command of .pyx files.
  6395. macro CYTHON_FLAGS(Flags...) {
  6396. SET_APPEND(CYTHON_OPTIONS $Flags)
  6397. }
  6398. ### @usage: STRIP()
  6399. ### Strip debug info from a PROGRAM, DLL or TEST.
  6400. ### This macro doesn't work in LIBRARY's, UNION's and PACKAGE's.
  6401. macro STRIP() {
  6402. ENABLE(STRIP)
  6403. }
  6404. ### @usage: NO_OPTIMIZE()
  6405. ### Build code without any optimizations (-O0 mode).
  6406. macro NO_OPTIMIZE() {
  6407. ENABLE(NO_OPTIMIZE)
  6408. }
  6409. #TODO(YMAKE-91) read proper compile flags instead of sending explicit flags to semgraph directly
  6410. _SEM_EXTRA_CXX_FLAGS=
  6411. ### @usage: NO_COMPILER_WARNINGS()
  6412. ### Disable all compiler warnings in the module.
  6413. ### Priorities: NO_COMPILER_WARNINGS > NO_WERROR > WERROR_MODE > WERROR.
  6414. macro NO_COMPILER_WARNINGS() {
  6415. ENABLE(NO_COMPILER_WARNINGS)
  6416. SET(_SEM_EXTRA_CXX_FLAGS "$<IF:$<CXX_COMPILER_ID:MSVC>,,-Wno-everything>")
  6417. }
  6418. ### @usage: WERROR()
  6419. ### Consider warnings as errors in the current module.
  6420. ### In the bright future will be removed, since WERROR is the default.
  6421. ### Priorities: NO_COMPILER_WARNINGS > NO_WERROR > WERROR_MODE > WERROR.
  6422. macro WERROR() {
  6423. ENABLE(WERROR)
  6424. }
  6425. ### @usage: NO_WERROR()
  6426. ### Override WERROR() behavior
  6427. ### Priorities: NO_COMPILER_WARNINGS > NO_WERROR > WERROR_MODE > WERROR.
  6428. macro NO_WERROR() {
  6429. DISABLE(WERROR)
  6430. }
  6431. ### @usage: NO_WSHADOW()
  6432. ### Disable C++ shadowing warnings.
  6433. macro NO_WSHADOW() {
  6434. ENABLE(NO_WSHADOW)
  6435. }
  6436. # tag:internal
  6437. ### @usage: NO_PLATFORM_RESOURCES() # internal
  6438. ### Exclude dependency on platform resources libraries.
  6439. ### Most probably you'll never need this. If you think you need, please contact devtools@ for assistance.
  6440. macro NO_PLATFORM_RESOURCES() {
  6441. ENABLE(NOPLATFORM_RESOURCES)
  6442. }
  6443. # tag:internal tag:codenav
  6444. ### @usage: NO_CODENAVIGATION() # internal
  6445. ### Disable codenaviagtion for a module. Needed to avoid PEERDIR loops in codenavigation support.
  6446. ### Most probably you'll never need this. If you think you need, please contact devtools@ for assistance.
  6447. macro NO_CODENAVIGATION() {
  6448. ENABLE(NOCODENAVIGATION)
  6449. }
  6450. ### @usage: NO_UTIL()
  6451. ### Build module without dependency on util.
  6452. ### Note: use this with care. Util most likely will be linked into executable anyway,
  6453. ### so using util headers/functions/classes may not be detected at build time and may lead to unpredictable behavors at configure time.
  6454. macro NO_UTIL() {
  6455. ENABLE(NOUTIL)
  6456. }
  6457. ### @usage: NO_RUNTIME()
  6458. ###
  6459. ### This macro:
  6460. ### 1. Sets the ENABLE(NOUTIL) + DISABLE(USE_INTERNAL_STL);
  6461. ### 2. If the project that contains the macro NO_RUNTIME(), peerdir-it project does not contain NO_RUNTIME() => Warning.
  6462. ### Note: use this with care. Arcadia STL most likely will be linked into executable anyway, so using STL headers/functions/classes
  6463. ### may not be detected at build time and may lead to unpredictable behavors at configure time.
  6464. macro NO_RUNTIME() {
  6465. SET(USE_ARCADIA_LIBM no)
  6466. NO_UTIL()
  6467. ENABLE(NORUNTIME)
  6468. }
  6469. ### @usage: NO_LIBC()
  6470. ###
  6471. ### Exclude dependencies on C++ and C runtimes (including util, musl and libeatmydata).
  6472. ### Note: use this with care. libc most likely will be linked into executable anyway,
  6473. ### so using libc headers/functions may not be detected at build time and may lead to unpredictable behavors at configure time.
  6474. macro NO_LIBC() {
  6475. NO_RUNTIME()
  6476. DISABLE(MUSL)
  6477. }
  6478. ### @usage: NO_PLATFORM()
  6479. ###
  6480. ### Exclude dependencies on C++ and C runtimes (including util, musl and libeatmydata) and set NO_PLATFORM variable for special processing.
  6481. ### Note: use this with care. libc most likely will be linked into executable anyway,
  6482. ### so using libc headers/functions may not be detected at build time and may lead to unpredictable behavors at configure time.
  6483. macro NO_PLATFORM() {
  6484. NO_LIBC()
  6485. ENABLE(NOPLATFORM)
  6486. }
  6487. # tag:cpp-specific
  6488. ### @usage: USE_CXX()
  6489. ###
  6490. ### Add dependency on C++ runtime
  6491. ### Note: This macro is inteneded for use in _GO_BASE_UNIT like module when the module is built without C++ runtime by default
  6492. macro USE_CXX() {
  6493. DISABLE(NORUNTIME)
  6494. }
  6495. ### @usage: USE_UTIL()
  6496. ###
  6497. ### Add dependency on util and C++ runtime
  6498. ### Note: This macro is intended for use in _GO_BASE_UNIT like module when the module is build without util by default
  6499. macro USE_UTIL() {
  6500. USE_CXX()
  6501. DISABLE(NOUTIL)
  6502. }
  6503. ### @usage: USE_NASM()
  6504. ###
  6505. ### Build only .asm files with nasm toolchain instead of yasm
  6506. ### Add to ya.make file ADDINCL(asm ...) with all folders where .asm files include smth
  6507. macro USE_NASM() {
  6508. ENABLE(USE_NASM_ASSEMBLER)
  6509. PEERDIR(build/external_resources/nasm)
  6510. }
  6511. # tag:deprecated
  6512. ### @usage: NO_JOIN_SRC() # deprecated, does-nothing
  6513. ### This macro currently does nothing. This is default behavior which cannot be overridden at module level.
  6514. macro NO_JOIN_SRC() {
  6515. ENABLE(UNUSED_MACRO)
  6516. }
  6517. # tag:sanitize
  6518. ### @usage: NO_SANITIZE()
  6519. ###
  6520. ### Disable all sanitizers for the module.
  6521. macro NO_SANITIZE() {
  6522. DISABLE(SANITIZER_TYPE)
  6523. }
  6524. # tag:coverage tag:sanitize
  6525. ### @usage: NO_SANITIZE_COVERAGE()
  6526. ###
  6527. ### Disable lightweight coverage (-fsanitize-coverage) for the module.
  6528. ### Sanitize coverage is commonly used with fuzzing.
  6529. ### It might be useful to disable it for libraries that should never
  6530. ### be the main targets for fuzzing, like libfuzzer library itself.
  6531. ### Sanitize coverage instrumentation is enabled by the --sanitize-coverage option.
  6532. macro NO_SANITIZE_COVERAGE() {
  6533. DISABLE(SANITIZE_COVERAGE)
  6534. }
  6535. # tag:sanitize
  6536. ### @usage: NO_SANITIZE_HEADERS()
  6537. ###
  6538. ### Disable dependency on sanitizer headers for the module.
  6539. macro NO_SANITIZE_HEADERS() {
  6540. DISABLE(SANITIZE_HEADERS)
  6541. }
  6542. # tag:coverage
  6543. ### @usage: NO_CLANG_COVERAGE()
  6544. ###
  6545. ### Disable heavyweight clang coverage for the module. Clang coverage instrumentation is enabled by the --clang-coverage option.
  6546. macro NO_CLANG_COVERAGE() {
  6547. DISABLE(CLANG_COVERAGE)
  6548. }
  6549. macro NO_CLANG_TIDY() {
  6550. DISABLE(TIDY_ENABLED)
  6551. }
  6552. # tag:python-specific tag:coverage
  6553. ### @usage: NO_PYTHON_COVERAGE()
  6554. ###
  6555. ### Disable python coverage for module
  6556. macro NO_PYTHON_COVERAGE() {
  6557. DISABLE(PYTHON_COVERAGE)
  6558. }
  6559. # tag:python-specific tag:coverage tag:cython
  6560. ### @usage: NO_CYTHON_COVERAGE()
  6561. ###
  6562. ### Disable cython and cythonized python coverage (CYTHONIZE_PY)
  6563. ### Implies NO_CLANG_COVERAGE() - right now, we can't disable instrumentation for .py.cpp files, but enable for .cpp
  6564. macro NO_CYTHON_COVERAGE() {
  6565. DISABLE(CYTHON_COVERAGE)
  6566. NO_CLANG_COVERAGE()
  6567. }
  6568. # tag:lua-specific
  6569. LUAJIT_PATH=${ARCADIA_ROOT}/contrib/libs/luajit
  6570. macro _LUAJIT_OBJDUMP(Src, OUT="") {
  6571. .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"}
  6572. }
  6573. # tag:lua-specific
  6574. LUAJIT_21_PATH=${ARCADIA_ROOT}/contrib/libs/luajit_21
  6575. macro _LUAJIT_21_OBJDUMP(Src, OUT="") {
  6576. .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"}
  6577. }
  6578. macro _MX_BIN_TO_INFO(Src) {
  6579. .CMD=${tool:"tools/mx_bin2info"} ${input:Src} ${output;nopath;noext;noauto:Src.info} ${kv;hide:"p MX"} ${kv;hide:"pc yellow"}
  6580. }
  6581. MX_GEN_TABLE_INCLS=${output_include;hide:"yabs_mx_calc_table.h"} \
  6582. ${output_include;hide:"kernel/matrixnet/mn_sse.h"} \
  6583. ${output_include;hide:"library/cpp/archive/yarchive.h"} \
  6584. ${output_include;hide:"util/memory/blob.h"} \
  6585. ${output_include;hide:"util/generic/hash.h"} \
  6586. ${output_include;hide:"util/generic/ptr.h"} \
  6587. ${output_include;hide:"util/generic/singleton.h"}
  6588. macro _MX_GEN_TABLE(Srcs...) {
  6589. .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"}
  6590. PEERDIR(kernel/matrixnet)
  6591. PEERDIR(library/cpp/archive)
  6592. }
  6593. RELEV_FML_CODEGEN_INCLS=${output_include;hide:"kernel/relevfml/relev_fml.h"} ${output_include;hide:"library/cpp/sse/sse.h"}
  6594. ### @usage: GENERATE_ENUM_SERIALIZATION(File.h)
  6595. ###
  6596. ### Create serialization support for enumeration members defined in the header (String <-> Enum conversions) and compile it into the module.
  6597. ###
  6598. ### Documentation: https://wiki.yandex-team.ru/yatool/HowToWriteYaMakeFiles/
  6599. macro GENERATE_ENUM_SERIALIZATION(File) {
  6600. .CMD=$ENUM_PARSER_TOOL ${input:File} --include-path ${input;rootrel:File} --output ${output;suf=_serialized.cpp:File} ${output_include;from_input;hide:File} ${output_include;hide:"util/generic/serialized_enum.h"} ${kv;hide:"p EN"} ${kv;hide:"pc yellow"}
  6601. .SEM=generate_enum_serilization ${input:File} ${output;hide;suf=_serialized.o:File} INCLUDE_HEADERS ${input;rootrel:File} ${tool;hide:"tools/enum_parser/enum_parser"}
  6602. PEERDIR(tools/enum_parser/enum_serialization_runtime)
  6603. }
  6604. ### @usage: GENERATE_ENUM_SERIALIZATION_WITH_HEADER(File.h)
  6605. ###
  6606. ### Create serialization support for enumeration members defined in the header (String <-> Enum conversions) and compile it into the module
  6607. ### Provide access to serialization functions via generated header File_serialized.h
  6608. ###
  6609. ### Documentation: https://wiki.yandex-team.ru/yatool/HowToWriteYaMakeFiles/
  6610. macro GENERATE_ENUM_SERIALIZATION_WITH_HEADER(File) {
  6611. .CMD=$ENUM_PARSER_TOOL ${input:File} --include-path ${input;rootrel:File} --output ${output;suf=_serialized.cpp:File} --header ${output;suf=_serialized.h:File} ${output_include;from_input;hide:File} ${kv;hide:"p EN"} ${kv;hide:"pc yellow"}
  6612. .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"}
  6613. PEERDIR(tools/enum_parser/enum_serialization_runtime)
  6614. }
  6615. ### @usage: DEB_VERSION(File)
  6616. ###
  6617. ### Creates a header file DebianVersion.h define the DEBIAN_VERSION taken from the File.
  6618. macro DEB_VERSION(File) {
  6619. .CMD=$YMAKE_PYTHON ${input:"build/scripts/mkver.py"} ${input:File} ${output;stdout:"DebianVersion.h"} ${kv;hide:"p CL"} ${kv;hide:"pc yellow"}
  6620. }
  6621. BUILD_MN_SCRIPT=build/scripts/build_mn.py
  6622. # tag:matrixnet
  6623. ### @usage: BUILD_MN([CHECK] [PTR] [MULTI] mninfo mnname) # matrixnet
  6624. ###
  6625. ### Generate MatrixNet data and access code using single command.
  6626. ### Alternative macro BUILD_MNS() works faster and better for large files.
  6627. macro BUILD_MN(MnInfo, MnName, CHECK?"fml_tool=$FML_UNUSED_TOOL CHECK":"", MULTI?, PTR?, RANKING_SUFFIX="") {
  6628. .CMD=$YMAKE_PYTHON ${input:BUILD_MN_SCRIPT} BuildMnF $ARCADIA_ROOT $ARCH_TOOL ${input:MnInfo} $MnName ranking_suffix=$RANKING_SUFFIX ${output;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"}
  6629. }
  6630. macro _BUILD_MNS_FILE(Input, Name, Output, Suffix, Check, Fml_tool, AsmDataName) {
  6631. .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"}
  6632. }
  6633. MNS_OUTPUT=mnmodels
  6634. macro _BUILD_MNS_CPP(NAME="", CHECK?, RANKING_SUFFIX="", Files...) {
  6635. .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"}
  6636. }
  6637. macro _BUILD_MNS_HEADER(NAME="", CHECK?, RANKING_SUFFIX="", Files...) {
  6638. .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"}
  6639. }
  6640. # TODO: support foreach_in and keywords simultaneous usage (look at BUILD_MNS_FILES)
  6641. # tag:matrixnet
  6642. ### @usage: BUILD_MNS([CHECK] NAME listname mninfos...) # matrixnet
  6643. ###
  6644. ### Generate MatrixNet data and access code using separate commands for support code, interface and data.
  6645. ### Faster version of BUILD_MN() macro for large files.
  6646. macro BUILD_MNS(Files...) {
  6647. _BUILD_MNS_HEADER($Files)
  6648. _BUILD_MNS_CPP($Files)
  6649. _BUILD_MNS_FILES($Files)
  6650. }
  6651. ### @usage: COMPILE_NLG(nlg_config.json, [TRANSLATIONS_JSON translations.json], Src...)
  6652. ###
  6653. ### Generate and compile .nlg templates (Jinja2-based) and interface for megamind runtime in localized mode.
  6654. ###
  6655. ### Alice-specific macro
  6656. macro COMPILE_NLG(NLG_CONFIG_JSON, TRANSLATIONS_JSON="", Src...) {
  6657. when ($TRANSLATIONS_JSON) {
  6658. TRANSLATIONS_JSON_ARG=--translations-json
  6659. }
  6660. otherwise {
  6661. TRANSLATIONS_JSON_ARG=
  6662. }
  6663. PEERDIR(alice/nlg/library/nlg_project_runtime)
  6664. RUN_PROGRAM(alice/nlg/tools/codegen compile-cpp --import-dir ${ARCADIA_ROOT} --out-dir ${ARCADIA_BUILD_ROOT} --include-prefix ${MODDIR} --nlg-config-json ${NLG_CONFIG_JSON} ${TRANSLATIONS_JSON_ARG} ${TRANSLATIONS_JSON} ${Src} IN ${TRANSLATIONS_JSON} ${NLG_CONFIG_JSON} ${Src} OUT_NOAUTO nlg_renderer_factory.cpp nlg_renderer_factory.h register.cpp translations.cpp translations.h localizable_phrases.pb.txt ${suf=.cpp:Src} ${suf=.h:Src} ${suf=.pb.txt:Src})
  6665. SRCS(GLOBAL register.cpp nlg_renderer_factory.cpp translations.cpp ${suf=.cpp:Src})
  6666. }
  6667. ### @usage: NEED_CHECK()
  6668. ###
  6669. ### Commits to the project marked with this macro will be blocked by pre-commit check and then will be
  6670. ### automatically merged to trunk only if there is no new broken build targets in check results.
  6671. ### The use of this macro is disabled by default.
  6672. macro NEED_CHECK(Flags...) {
  6673. # TODO: FIXME
  6674. ENABLE(UNUSED_MACRO)
  6675. }
  6676. ### @usage: NO_NEED_CHECK()
  6677. ###
  6678. ### Commits to the project marked with this macro will not be affected by higher-level NEED_CHECK macro.
  6679. macro NO_NEED_CHECK(Flags...) {
  6680. ENABLE(UNUSED_MACRO)
  6681. }
  6682. # tag:deprecated
  6683. ### @usage: NEED_REVIEW() # deprecated
  6684. ###
  6685. ### Mark the project as needing review.
  6686. ### Reviewers are listed in the macro OWNER. The use of this macro is disabled by default.
  6687. ### Details can be found here: https://clubs.at.yandex-team.ru/arcadia/6104
  6688. macro NEED_REVIEW(Flags...) {
  6689. # TODO: FIXME
  6690. ENABLE(UNUSED_MACRO)
  6691. }
  6692. ### @usage: VERSION(Args...)
  6693. ###
  6694. ### Specify version of a module. Currently unused by build system, only informative.
  6695. macro VERSION(Flags...) {
  6696. ENABLE(UNUSED_MACRO)
  6697. }
  6698. DATAWORK_SCHEEME_EXPORT_FLAGS=
  6699. when ($UNIX == "yes") {
  6700. SCHEEME2_CFLAGS= -E -x c++
  6701. }
  6702. when ($WIN32 == "yes") {
  6703. SCHEEME2_CFLAGS= /E /TP
  6704. }
  6705. SCHEEME2_STRUCT_INFO_FLAGS=-f "const static ui32 RecordSig" -u "RecordSig" --gcc44_no_typename --no_complex_overloaded_func_export
  6706. ### @usage: GEN_SCHEEME2(scheeme_name from_file dependent_files...)
  6707. ###
  6708. ### Generates a C++ description for structure(contains the field RecordSig) in the specified file (and connected).
  6709. ###
  6710. ### 1. ${scheeme_name}.inc - the name of the generated file.
  6711. ### 2. Use an environment variable - DATAWORK_SCHEEME_EXPORT_FLAGS that allows to specify flags to tools/structparser
  6712. ###
  6713. ### @example:
  6714. ###
  6715. ### SET(DATAWORK_SCHEEME_EXPORT_FLAGS --final_only -m "::")
  6716. ###
  6717. ### 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)
  6718. ### sets in extra option
  6719. ###
  6720. ### @example:
  6721. ###
  6722. ### SET(EXTRACT_STRUCT_INFO_FLAGS -f \"const static ui32 RecordSig\"
  6723. ### -u \"RecordSig\" -n${scheeme_name}SchemeInfo ----gcc44_no_typename no_complex_overloaded_func_export
  6724. ### ${DATAWORK_SCHEEME_EXPORT_FLAGS})
  6725. ###
  6726. ### for compatibility with C++ compiler and the external environment.
  6727. ### See tools/structparser for more details.
  6728. macro GEN_SCHEEME2(ScheemeName, FromFile) {
  6729. .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"}
  6730. }
  6731. ### @usage: SYMLINK(from to)
  6732. ### Add symlink
  6733. macro SYMLINK(From, To) {
  6734. .CMD=$YMAKE_PYTHON ${input:"build/scripts/symlink.py"} ${input;dirallowed:From} ${output;noauto:To} ${kv;hide:"p LN"} ${kv;hide:"pc light-cyan"}
  6735. }
  6736. # tag:internal
  6737. ### @usage: _TARGET_SOURCES_FOR_HEADERS_IMPL([GENERATE] Args...) # internal
  6738. ### Generate prefix " && target_sources PRIVATE " before $Args when GENERATE is specified in the list of actual arguments
  6739. macro _TARGET_SOURCES_FOR_HEADERS_IMPL(GENERATE?" && target_sources PRIVATE ":"", Args...) {
  6740. .SEM=$GENERATE ${output;ext=.h:Args} ${output;ext=.hh:Args} ${output;ext=.hpp:Args} ${output;ext=.inc:Args} ${output;ext=.i:Args}
  6741. }
  6742. # tag:internal
  6743. ### @usage: _TARGET_SOURCES_FOR_HEADERS(Args...) # internal
  6744. ### Generate prefix " && target_sources PRIVATE " before $Args if Args is not empty
  6745. macro _TARGET_SOURCES_FOR_HEADERS(Args...) {
  6746. .SEM=$_TARGET_SOURCES_FOR_HEADERS_IMPL(${pre=GENERATE :Args})
  6747. }
  6748. # tag:internal
  6749. ### @usage: _TARGET_SOURCES_FOR_HEADERS_IMPL([GENERATE] Args...) # internal
  6750. ### Generate prefix " ${CMAKE_COMMAND} -E env " before $Args when GENERATE is specified in the list of actual arguments
  6751. macro _SET_ENV_FOR_CUSTOM_COMMAND_IMPL(GENERATE?" ${CMAKE_COMMAND} -E env ":"", Args...) {
  6752. .SEM=$GENERATE ${pre= :Args}
  6753. }
  6754. # tag:internal
  6755. ### @usage: _SET_ENV_FOR_CUSTOM_COMMAND(Args...) # internal
  6756. ### Generate prefix " ${CMAKE_COMMAND} -E env " before $Args if Args is not empty
  6757. macro _SET_ENV_FOR_CUSTOM_COMMAND(Args...) {
  6758. .SEM=$_SET_ENV_FOR_CUSTOM_COMMAND_IMPL(${pre=GENERATE :Args})
  6759. }
  6760. macro _FMT_INDUCED_DEPS(For, Deps...) {
  6761. .CMD=${induced_deps=$For;hide:Deps}
  6762. }
  6763. ### @usage: PREPARE_INDUCED_DEPS(VAR Type Files...)
  6764. ###
  6765. ### Format value for `INDUCED_DEPS` param in certain macros and assign to `VAR`
  6766. ### This tells that files of Type resulted from code generation macros (not neccessarily directly,
  6767. ### but in processing chain of generated files) should have extra dependencies from list of Files...
  6768. ###
  6769. ### Prominent example here is Cython: one can generate .pyx file that may depend on .pxd and have cimpot from
  6770. ### certain .h. The former is dependency for .pyx itself, while the latter is dependency for .pyx.cpp
  6771. ### resulted from Cython-processing of generated pyx. The code ganeration will look like:
  6772. ### ```
  6773. ### PREPARE_INDUCED_DEPS(PYX_DEPS pyx imported.pxd)
  6774. ### PREPARE_INDUCED_DEPS(CPP_DEPS cpp cdefed.h)
  6775. ### RUN_PYTHON3(generate_pyx.py genereted.pyx OUT generated.pyx INDUCED_DEPS $PYX_DEPS $CPP_DEPS)
  6776. ### ```
  6777. ###
  6778. ### The VAR will basically contain pair of `Type:[Files...]` in a form suitable for passing
  6779. ### as an element of array parameter. This is needed because language of ya.make doesn't support
  6780. ### Dict params right now and so it is impossible to directly pass something
  6781. ### like `{Type1:[Files2...], Type2:[Files2...]}`
  6782. ###
  6783. macro PREPARE_INDUCED_DEPS(VAR, For, Deps...) {
  6784. SET($VAR \$_FMT_INDUCED_DEPS($For $Deps))
  6785. }
  6786. ### @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...] [INDUCED_DEPS $VARs...])
  6787. ###
  6788. ### Run a program from arcadia.
  6789. ### These macros are similar: RUN_PROGRAM, RUN_LUA, PYTHON.
  6790. ###
  6791. ### Parameters:
  6792. ### - tool_path - Path to the directory of the tool.
  6793. ### - args... - Program arguments. Relative paths listed in TOOL, IN, OUT, STDOUT become absolute.
  6794. ### - CWD dir - Absolute path of the working directory.
  6795. ### - ENV key=value... - Environment variables.
  6796. ### - TOOL tools... - Auxiliary tool directories.
  6797. ### - IN[_NOPARSE] inputs... - Input files. NOPARSE inputs are treated as textual and not parsed for dependencies regardless of file extensions.
  6798. ### - OUT[_NOAUTO] outputs... - Output files. NOAUTO outputs are not automatically added to the build process.
  6799. ### - STDOUT[_NOAUTO] output - Redirect the standard output to the output file.
  6800. ### - OUTPUT_INCLUDES output_includes... - Includes of the output files that are needed to build them.
  6801. ### - INDUCED_DEPS $VARs... - Dependencies for generated files. Unlike `OUTPUT_INCLUDES` these may target files further in processing chain.
  6802. ### In order to do so VAR should be filled by PREPARE_INDUCED_DEPS macro, stating target files (by type) and set of dependencies
  6803. ###
  6804. ### For absolute paths use ${ARCADIA_ROOT} and ${ARCADIA_BUILD_ROOT}, or
  6805. ### ${CURDIR} and ${BINDIR} which are expanded where the outputs are used.
  6806. ### 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).
  6807. macro RUN_PROGRAM(Tool, IN{input}[], IN_NOPARSE{input}[], OUT{output}[], OUT_NOAUTO{output}[], TOOL{tool}[], OUTPUT_INCLUDES[], INDUCED_DEPS[], IN_DEPS[], STDOUT="", STDOUT_NOAUTO="", CWD="", ENV[], Args...) {
  6808. .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} $INDUCED_DEPS ${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"}
  6809. .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)
  6810. }
  6811. # tag:lua-specific
  6812. ### @usage: RUN_LUA(script_path args... [CWD dir] [ENV key=value...] [TOOL tools...] [IN[_NOPARSE] inputs...] [OUT[_NOAUTO] outputs...] [STDOUT[_NOAUTO] output] [OUTPUT_INCLUDES output_includes...] [INDUCED_DEPS $VARs...])
  6813. ###
  6814. ### Run a lua script.
  6815. ### These macros are similar: RUN_PROGRAM, RUN_LUA, PYTHON.
  6816. ###
  6817. ### Parameters:
  6818. ### - script_path - Path to the script.3
  6819. ### - args... - Program arguments. Relative paths listed in TOOL, IN, OUT, STDOUT become absolute.
  6820. ### - CWD dir - Absolute path of the working directory.
  6821. ### - ENV key=value... - Environment variables.
  6822. ### - TOOL tools... - Auxiliary tool directories.
  6823. ### - IN[_NOPARSE] inputs... - Input files. NOPARSE inputs are treated as textual and not parsed for dependencies regardless of file extensions.
  6824. ### - OUT[_NOAUTO] outputs... - Output files. NOAUTO outputs are not automatically added to the build process.
  6825. ### - STDOUT[_NOAUTO] output - Redirect the standard output to the output file.
  6826. ### - OUTPUT_INCLUDES output_includes... - Includes of the output files that are needed to build them.
  6827. ### - INDUCED_DEPS $VARs... - Dependencies for generated files. Unlike `OUTPUT_INCLUDES` these may target files further in processing chain.
  6828. ### In order to do so VAR should be filled by PREPARE_INDUCED_DEPS macro, stating target files (by type) and set of dependencies
  6829. ###
  6830. ### For absolute paths use ${ARCADIA_ROOT} and ${ARCADIA_BUILD_ROOT}, or
  6831. ### ${CURDIR} and ${BINDIR} which are expanded where the outputs are used.
  6832. macro RUN_LUA(ScriptPath, IN{input}[], IN_NOPARSE{input}[], OUT{output}[], OUT_NOAUTO{output}[], TOOL{tool}[], OUTPUT_INCLUDES[], INDUCED_DEPS[], STDOUT="", STDOUT_NOAUTO="", CWD="", ENV[], Args...) {
  6833. .CMD=${cwd:CWD} ${env:ENV} $LUA_TOOL ${input:ScriptPath} $Args ${input;hide:IN} ${input;context=TEXT;hide:IN_NOPARSE} ${output_include;hide:OUTPUT_INCLUDES} $INDUCED_DEPS ${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"}
  6834. }
  6835. # tag:python-specific
  6836. ### @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...] [INDUCED_DEPS $VARs...])
  6837. ###
  6838. ### Run a python script with $(PYTHON)/python built from devtools/huge_python.
  6839. ### These macros are similar: RUN_PROGRAM, RUN_LUA, PYTHON.
  6840. ###
  6841. ### Parameters:
  6842. ### - script_path - Path to the script.
  6843. ### - args... - Program arguments. Relative paths listed in TOOL, IN, OUT, STDOUT become absolute.
  6844. ### - CWD dir - Absolute path of the working directory.
  6845. ### - ENV key=value... - Environment variables.
  6846. ### - TOOL tools... - Auxiliary tool directories.
  6847. ### - IN[_NOPARSE] inputs... - Input files. NOPARSE inputs are treated as textual and not parsed for dependencies regardless of file extensions.
  6848. ### - OUT[_NOAUTO] outputs... - Output files. NOAUTO outputs are not automatically added to the build process.
  6849. ### - STDOUT[_NOAUTO] output - Redirect the standard output to the output file.
  6850. ### - OUTPUT_INCLUDES output_includes... - Includes of the output files that are needed to build them.
  6851. ### - INDUCED_DEPS $VARs... - Dependencies for generated files. Unlike `OUTPUT_INCLUDES` these may target files further in processing chain.
  6852. ### In order to do so VAR should be filled by PREPARE_INDUCED_DEPS macro, stating target files (by type) and set of dependencies
  6853. ###
  6854. ### For absolute paths use ${ARCADIA_ROOT} and ${ARCADIA_BUILD_ROOT}, or
  6855. ### ${CURDIR} and ${BINDIR} which are expanded where the outputs are used.
  6856. macro PYTHON(ScriptPath, IN{input}[], IN_NOPARSE{input}[], OUT{output}[], OUT_NOAUTO{output}[], TOOL{tool}[], OUTPUT_INCLUDES[], INDUCED_DEPS[], STDOUT="", STDOUT_NOAUTO="", CWD="", ENV[], Args...) {
  6857. .CMD=${cwd:CWD} ${env:ENV} $YMAKE_PYTHON ${input:ScriptPath} $Args ${input;hide:IN} ${input;context=TEXT;hide:IN_NOPARSE} ${output_include;hide:OUTPUT_INCLUDES} $INDUCED_DEPS ${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"}
  6858. .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)
  6859. }
  6860. # tag:python-specific
  6861. ### @usage: RUN_PYTHON3(script_path args... [CWD dir] [ENV key=value...] [TOOL tools...] [IN[_NOPARSE] inputs...] [OUT[_NOAUTO] outputs...] [STDOUT[_NOAUTO] output] [OUTPUT_INCLUDES output_includes...] [INDUCED_DEPS $VARs...])
  6862. ###
  6863. ### Run a python script with prebuilt python3 interpretor built from devtools/huge_python3.
  6864. ### These macros are similar: RUN_PROGRAM, RUN_LUA, PYTHON.
  6865. ###
  6866. ### Parameters:
  6867. ### - script_path - Path to the script.
  6868. ### - args... - Program arguments. Relative paths listed in TOOL, IN, OUT, STDOUT become absolute.
  6869. ### - CWD dir - Absolute path of the working directory.
  6870. ### - ENV key=value... - Environment variables.
  6871. ### - TOOL tools... - Auxiliary tool directories.
  6872. ### - IN[_NOPARSE] inputs... - Input files. NOPARSE inputs are treated as textual and not parsed for dependencies regardless of file extensions.
  6873. ### - OUT[_NOAUTO] outputs... - Output files. NOAUTO outputs are not automatically added to the build process.
  6874. ### - STDOUT[_NOAUTO] output - Redirect the standard output to the output file.
  6875. ### - OUTPUT_INCLUDES output_includes... - Includes of the output files that are needed to build them.
  6876. ### - INDUCED_DEPS $VARs... - Dependencies for generated files. Unlike `OUTPUT_INCLUDES` these may target files further in processing chain.
  6877. ### In order to do so VAR should be filled by PREPARE_INDUCED_DEPS macro, stating target files (by type) and set of dependencies
  6878. ###
  6879. ### For absolute paths use ${ARCADIA_ROOT} and ${ARCADIA_BUILD_ROOT}, or
  6880. ### ${CURDIR} and ${BINDIR} which are expanded where the outputs are used.
  6881. macro RUN_PYTHON3(ScriptPath, IN{input}[], IN_NOPARSE{input}[], OUT{output}[], OUT_NOAUTO{output}[], TOOL{tool}[], OUTPUT_INCLUDES[], INDUCED_DEPS[], STDOUT="", STDOUT_NOAUTO="", CWD="", ENV[], Args...) {
  6882. .CMD=${cwd:CWD} ${env:ENV} $YMAKE_PYTHON3 ${input:ScriptPath} $Args ${input;hide:IN} ${input;context=TEXT;hide:IN_NOPARSE} ${output_include;hide:OUTPUT_INCLUDES} $INDUCED_DEPS ${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"}
  6883. .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)
  6884. }
  6885. # tag:java-specific
  6886. macro _RUN_JAVA(IN{input}[], IN_NOPARSE{input}[], OUT{output}[], OUT_NOAUTO{output}[], OUTPUT_INCLUDES[], INDUCED_DEPS[], TOOL[], STDOUT="", STDOUT_NOAUTO="", CWD="", ENV[], HIDE_OUTPUT?"stderr2stdout":"stdout2stderr", Args...) {
  6887. PEERDIR(build/platform/java/jdk $JDK_RESOURCE_PEERDIR)
  6888. .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} $INDUCED_DEPS ${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"}
  6889. }
  6890. ### @usage: FROM_SANDBOX([FILE] resource_id [AUTOUPDATED script] [RENAME <resource files>] OUT_[NOAUTO] <output files> [EXECUTABLE] [OUTPUT_INCLUDES <include files>] [INDUCED_DEPS $VARs...])
  6891. ###
  6892. ### Download the resource from the Sandbox, unpack (if not explicitly specified word FILE) and add OUT files to the build. EXECUTABLE makes them executable.
  6893. ### You may specify extra dependencies that output files bring using OUTPUT_INCLUDES or INDUCED_DEPS. The change of these may e.g. lead to recompilation of .cpp files extracted from resource.
  6894. ### If there is no default processing for OUT files or you need process them specially use OUT_NOAUTO instead of OUT.
  6895. ###
  6896. ### It is disallowed to specify directory as OUT/OUT_NOAUTO since all outputs of commands shall be known to build system.
  6897. ###
  6898. ### RENAME renames files to the corresponding OUT and OUT_NOAUTO outputs:
  6899. ### FROM_SANDBOX(resource_id RENAME in_file1 in_file2 OUT out_file1 out_file2 out_file3)
  6900. ### FROM_SANDBOX(resource_id RENAME in_file1 OUT out_file1 RENAME in_file2 OUT out_file2)
  6901. ### FROM_SANDBOX(FILE resource_id RENAME resource_file OUT out_name)
  6902. ###
  6903. ### RENAME RESOURCE allows to rename the resource without specifying its file name.
  6904. ###
  6905. ### OUTPUT_INCLUDES output_includes... - Includes of the output files that are needed to build them.
  6906. ### INDUCED_DEPS $VARs... - Dependencies for generated files. Unlike `OUTPUT_INCLUDES` these may target files further in processing chain.
  6907. ### In order to do so VAR should be filled by PREPARE_INDUCED_DEPS macro, stating target files (by type) and set of dependencies
  6908. ###
  6909. ### If AUTOUPDATED is specified than macro will be regularly updated according to autoupdate script. The dedicated Sandbox task scans the arcadia and
  6910. ### changes resource_ids in such macros if newer resource of specified type is available. Note that the task seeks AUTOUPDATED in specific position,
  6911. ### so you shall place it immediately after resource_id.
  6912. macro FROM_SANDBOX(Id, OUT{output}[], OUT_NOAUTO{output}[], OUTPUT_INCLUDES[], INDUCED_DEPS[], FILE?"--copy-to-dir":"--untar-to", AUTOUPDATED="", PREFIX=".", RENAME[], EXECUTABLE?"--executable":"", SBR="sbr:") {
  6913. .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} $INDUCED_DEPS ${output;hide:OUT} ${output;noauto;hide:OUT_NOAUTO} ${requirements;hide:"network:full"} ${kv;hide:"p SB"} ${kv;hide:"pc yellow"} ${kv;hide:"show_out"}
  6914. ADD_CHECK(check.resource $Id)
  6915. }
  6916. ### @usage: FROM_MDS([FILE] key [RENAME <resource files>] OUT_[NOAUTO] <output files> [EXECUTABLE] [OUTPUT_INCLUDES <include files>] [INDUCED_DEPS $VARs...])
  6917. ###
  6918. ### Download resource from MDS with the specified key and process like [FROM_SANDBOX()](#macro_FROM_SANDBOX).
  6919. macro FROM_MDS(Key, OUT{output}[], OUT_NOAUTO{output}[], OUTPUT_INCLUDES[], INDUCED_DEPS[], FILE?"--copy-to-dir":"--untar-to", PREFIX=".", RENAME[], EXECUTABLE?"--executable":"") {
  6920. .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} $INDUCED_DEPS ${output;hide:OUT} ${output;noauto;hide:OUT_NOAUTO} ${requirements;hide:"network:full"} ${kv;hide:"p MD"} ${kv;hide:"pc yellow"} ${kv;hide:"show_out"}
  6921. ADD_CHECK(check.mds $Key)
  6922. }
  6923. # tag:internal
  6924. ### @usage: _FROM_EXTERNAL(ExtFile [AUTOUPDATED script] [RENAME <resource files>] OUT_[NOAUTO] <output files> [EXECUTABLE]) #internal
  6925. ###
  6926. ### Use resource described as .external file as [FROM_SANDBOX()](#macro_FROM_SANDBOX)/[FROM_MDS()](#macro_FROM_MDS).
  6927. macro _FROM_EXTERNAL(File, OutFile, OUT{output}[], OUT_NOAUTO{output}[], OUTPUT_INCLUDES[], INDUCED_DEPS[], AUTOUPDATED="", PREFIX=".", RENAME[], EXECUTABLE?"--executable":"", EXT="ext:") {
  6928. .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} $INDUCED_DEPS ${output;hide:OUT} ${output;noauto;hide:OUT_NOAUTO} ${requirements;hide:"network:full"} ${kv;hide:"p XT"} ${kv;hide:"pc yellow"} ${kv;hide:"show_out"}
  6929. #FIXME: add '${resource;pre=$EXT:OutFile}' when support of the scheme is added to executors
  6930. #FIXME: add 'ADD_CHECK(check.external $File)' when proper testing is implemented
  6931. }
  6932. ### @usage LARGE_FILES([AUTOUPDATED] Files...)
  6933. ###
  6934. ### Use large file ether from working copy or from remote storage via placeholder <File>.external
  6935. ### If <File> is present locally (and not a symlink!) it will be copied to build directory.
  6936. ### Otherwise macro will try to locate <File>.external, parse it retrieve ot during build phase.
  6937. macro LARGE_FILES(AUTOUPDATED?, Files...) {
  6938. # This is needed to correctly switch between remote and local modes
  6939. _GLOB($LF $Files)
  6940. }
  6941. ### @usage: FROM_ARCHIVE(Src [RENAME <resource files>] OUT_[NOAUTO] <output files> [EXECUTABLE] [OUTPUT_INCLUDES <include files>] [INDUCED_DEPS $VARs...])
  6942. ###
  6943. ### Process file archive as [FROM_SANDBOX()](#macro_FROM_SANDBOX).
  6944. macro FROM_ARCHIVE(Src, OUT{output}[], OUT_NOAUTO{output}[], OUTPUT_INCLUDES[], INDUCED_DEPS[], PREFIX=".", RENAME[], EXECUTABLE?"--executable":"") {
  6945. .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} $INDUCED_DEPS ${output;hide:OUT} ${output;noauto;hide:OUT_NOAUTO} ${kv;hide:"p FA"} ${kv;hide:"pc yellow"} ${kv;hide:"show_out"}
  6946. }
  6947. when ($MSVC == "yes") {
  6948. C_AS_CXX_FLAGS=/TP /std:c++17
  6949. }
  6950. otherwise {
  6951. C_AS_CXX_FLAGS=-x c++ -std=c++17
  6952. }
  6953. # tag:cpp-specific
  6954. ### @usage: COMPILE_C_AS_CXX()
  6955. ###
  6956. ### Compile .c files as .cpp ones within a module.
  6957. macro COMPILE_C_AS_CXX() {
  6958. SET(EXTRA_C_FLAGS $C_AS_CXX_FLAGS)
  6959. }
  6960. ### @usage: NO_DEBUG_INFO()
  6961. ###
  6962. ### Compile files without debug info collection.
  6963. macro NO_DEBUG_INFO() {
  6964. SET(NO_DEBUGINFO yes)
  6965. }
  6966. ### @usage: CTEMPLATE_VARNAMES(File)
  6967. ###
  6968. ### Generate File.varnames.h using contrib/libs/ctemplate/make_tpl_varnames_h
  6969. ###
  6970. ### Documentation: https://a.yandex-team.ru/arc/trunk/arcadia/contrib/libs/ctemplate/README.md
  6971. macro CTEMPLATE_VARNAMES(File) {
  6972. .CMD=${tool:"contrib/libs/ctemplate/make_tpl_varnames_h"} -f ${output;addincl;nopath;noallext:File.varnames.h} ${input:File}
  6973. }
  6974. LLVM_OPTS=
  6975. CLANG_BC_ROOT=${CLANG11_RESOURCE_GLOBAL}
  6976. macro USE_LLVM_BC12() {
  6977. SET(CLANG_BC_ROOT ${CLANG12_RESOURCE_GLOBAL})
  6978. }
  6979. CLANG_DEFAULT_ROOT=${CLANG_RESOURCE_GLOBAL}
  6980. CLANG_C_COMPILER_BIN=${CLANG_RESOURCE_GLOBAL}/bin/clang
  6981. CLANG_CPP_COMPILER_BIN=${CLANG_RESOURCE_GLOBAL}/bin/clang++
  6982. CLANG_EMIT_EXTRA_OPTS=
  6983. when ($OS_WINDOWS == "yes") {
  6984. # we can't use c++latest for clang14 now
  6985. # so we set c++20 for it
  6986. # for clang11 (actual clang for CLANG_EMIT_AST_CXX and LLVM_COMPILE_* macroses) /std:c++20 provokes "unused-command-line-argument" error
  6987. # !do not forget to change this flag when updating build/platform/clang
  6988. CLANG_EMIT_EXTRA_OPTS+=/std:c++latest
  6989. }
  6990. when ($OS_ANDROID == "yes") {
  6991. # We use clang shipped with android-ndk which has different layout
  6992. CLANG_DEFAULT_ROOT=$CLANG_ANDROID_RESOURCE_GLOBAL
  6993. when ($HOST_OS_DARWIN) {
  6994. CLANG_C_COMPILER_BIN=${CLANG_ANDROID_RESOURCE_GLOBAL}/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang
  6995. CLANG_CPP_COMPILER_BIN=${CLANG_ANDROID_RESOURCE_GLOBAL}/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++
  6996. }
  6997. otherwise {
  6998. CLANG_C_COMPILER_BIN=${CLANG_ANDROID_RESOURCE_GLOBAL}/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
  6999. CLANG_CPP_COMPILER_BIN=${CLANG_ANDROID_RESOURCE_GLOBAL}/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++
  7000. }
  7001. }
  7002. ### @usage: CLANG_EMIT_AST_CXX(Input Output Opts...)
  7003. ###
  7004. ### Emit Clang AST from .cpp file. CXXFLAGS and LLVM_OPTS are passed in, while CFLAGS and C_FLAGS_PLATFORM are not.
  7005. ### Note: Output name is used as is, no extension added.
  7006. macro CLANG_EMIT_AST_CXX(Input, Output, Opts...) {
  7007. .CMD=$YMAKE_PYTHON ${input:"build/scripts/clang_wrapper.py"} $WINDOWS ${CLANG_CPP_COMPILER_BIN} ${pre=-I:_C__INCLUDE} $CXXFLAGS $C_FLAGS_PLATFORM $LLVM_OPTS -emit-ast -c ${input:Input} -o ${output;noauto:Output} $Opts ${kv;hide:"p ST"} ${kv;hide:"pc light-green"}
  7008. PEERDIR(build/platform/clang)
  7009. }
  7010. ### @usage: LLVM_COMPILE_CXX(Input Output Opts...)
  7011. ###
  7012. ### Emit LLVM bytecode from .cpp file. BC_CXXFLAGS, LLVM_OPTS and C_FLAGS_PLATFORM are passed in, while CFLAGS are not.
  7013. ### Note: Output name is used as is, no extension added.
  7014. macro LLVM_COMPILE_CXX(Input, Output, Opts...) {
  7015. .CMD=$YMAKE_PYTHON ${input:"build/scripts/clang_wrapper.py"} $WINDOWS ${CLANG_BC_ROOT}/bin/clang++ ${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 $CLANG_EMIT_EXTRA_OPTS ${kv;hide:"p BC"} ${kv;hide:"pc light-green"}
  7016. .SEM=llvm_compile_cxx ${input:Input} ${output;noauto:Output} ${"${CLANGPLUSPLUS}"} -Wno-unknown-warning-option $LLVM_OPTS ${NO_LTO_CFLAGS} -emit-llvm ${Opts}
  7017. PEERDIR(build/platform/clang)
  7018. }
  7019. ### @usage: LLVM_COMPILE_C(Input Output Opts...)
  7020. ###
  7021. ### Emit LLVM bytecode from .c file. BC_CFLAGS, LLVM_OPTS and C_FLAGS_PLATFORM are passed in, while CFLAGS are not.
  7022. ### Note: Output name is used as is, no extension added.
  7023. macro LLVM_COMPILE_C(Input, Output, Opts...) {
  7024. .CMD=$YMAKE_PYTHON ${input:"build/scripts/clang_wrapper.py"} $WINDOWS ${CLANG_BC_ROOT}/bin/clang ${pre=-I:_C__INCLUDE} $BC_CFLAGS $C_FLAGS_PLATFORM $LLVM_OPTS ${NO_LTO_CFLAGS} -emit-llvm -c ${input:Input} -o ${output;noauto:Output} $Opts $CLANG_EMIT_EXTRA_OPTS ${kv;hide:"p BC"} ${kv;hide:"pc light-green"}
  7025. .SEM=llvm_compile_c ${input:Input} ${output;noauto:Output} ${"${CLANGC}"} -Wno-unknown-warning-option $LLVM_OPTS ${NO_LTO_CFLAGS} -emit-llvm ${Opts}
  7026. PEERDIR(build/platform/clang)
  7027. }
  7028. ### @usage: BPF(Input Output Opts...)
  7029. ###
  7030. ### Emit eBPF bytecode from .c file.
  7031. ### Note: Output name is used as is, no extension added.
  7032. macro BPF(Input, Output, Opts...) {
  7033. .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 $CLANG_EMIT_EXTRA_OPTS ${kv;hide:"p BP"} ${kv;hide:"pc light-green"}
  7034. PEERDIR(build/platform/clang)
  7035. }
  7036. LD_BINARY_NAME=ld
  7037. when($OS_LINUX) {
  7038. LD_BINARY_NAME=ld.lld
  7039. }
  7040. ### @usage: BPF_STATIC(Input Output Opts...)
  7041. ###
  7042. ### Emit eBPF bytecode from .c file.
  7043. ### Note: Output name is used as is, no extension added.
  7044. macro BPF_STATIC(Input, Output, Opts...) {
  7045. .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_BINARY_NAME -r -b binary -m elf_x86_64 -o ${output;noauto;suf=.bpf.o:Input} ${noauto;nopath:Output}
  7046. PEERDIR(build/platform/clang build/platform/lld)
  7047. }
  7048. ### @usage: LLVM_COMPILE_LL(Input Output Opts...)
  7049. ###
  7050. ### Compile LLVM bytecode to object representation.
  7051. ### Note: Output name is used as is, no extension added.
  7052. macro LLVM_COMPILE_LL(Input, Output, Opts...) {
  7053. .CMD=${CLANG_BC_ROOT}/bin/llvm-as ${input:Input} -o ${output;noauto:Output} ${kv;hide:"p BC"} ${kv;hide:"pc light-green"}
  7054. PEERDIR(build/platform/clang)
  7055. }
  7056. ### @usage: LLVM_LINK(Output Inputs...)
  7057. ###
  7058. ### Call llvm-link on set of Inputs to produce Output.
  7059. ### Note: Unlike many other macros output argument goes first. Output name is used as is, no extension added.
  7060. macro LLVM_LINK(Output, Inputs...) {
  7061. .CMD=${CLANG_BC_ROOT}/bin/llvm-link ${input:Inputs} -o ${output;noauto:Output} ${kv;hide:"p LD"} ${kv;hide:"pc light-red"}
  7062. .SEM=add_custom_command OUTPUT ${output;noauto:Output} DEPENDS ${input:Inputs} COMMAND ${LLVMLINK} ${input:Inputs} -o ${output;noauto:Output}
  7063. PEERDIR(build/platform/clang)
  7064. }
  7065. ### @usage: LLVM_OPT(Input Output Opts...)
  7066. ###
  7067. ### Call llvm-opt with set of Opts on Input to produce Output.
  7068. ### Note: Output name is used as is, no extension added.
  7069. macro LLVM_OPT(Input, Output, Opts...) {
  7070. .CMD=$YMAKE_PYTHON ${input:"build/scripts/llvm_opt_wrapper.py"} ${CLANG_BC_ROOT}/bin/opt ${input:Input} -o ${output;noauto:Output} $Opts ${kv;hide:"p OP"} ${kv;hide:"pc yellow"}
  7071. .SEM=add_custom_command OUTPUT ${output;noauto:Output} DEPENDS ${input:Input} COMMAND ${LLVMOPT} ${input:Input} -o ${output;noauto:Output} $Opts
  7072. PEERDIR(build/platform/clang)
  7073. }
  7074. ### @usage: LLVM_LLC(Src Opts...)
  7075. ###
  7076. ### Call llvm-llc with set of Opts on Src to produce object file.
  7077. ###
  7078. ### Note: Output name is calculated as concatenation of Src name and platform specific object file extension.
  7079. macro LLVM_LLC(Src, Opts...) {
  7080. .CMD=${tool:"contrib/libs/llvm14/tools/llc"} ${input:Src} --filetype obj -o ${output;suf=$OBJECT_SUF;noauto:Src} $Opts ${kv;hide:"p LC"} ${kv;hide:"pc yellow"}
  7081. .SEM=add_custom_command OUTPUT ${output;suf=$OBJECT_SUF;noauto:Src} DEPENDS ${input:Src} COMMAND ${LLVMLLC} --filetype obj ${input:Src} -o ${output;suf=$OBJECT_SUF;noauto:Src} $Opts
  7082. PEERDIR(build/platform/clang)
  7083. }
  7084. when ($NO_DEBUGINFO == "yes") {
  7085. DEBUG_INFO_FLAGS=
  7086. }
  7087. when ($CLANG && $DEBUGINFO_LINES_ONLY == "yes" && $NO_DEBUGINFO != "yes") {
  7088. DEBUG_INFO_FLAGS=-gline-tables-only
  7089. }
  7090. # TODO: configurable tar and touch
  7091. PACK_TGZ=${cwd:ARCADIA_BUILD_ROOT} tar -czf ${rootrel:OUTPUT} ${rootrel:INPUT} ${kv;hide:"p AR"} ${kv;hide:"pc light-red"}
  7092. # tag:internal
  7093. ### @usage TOUCH(Outputs...) # internal
  7094. ### Just introduce outputs
  7095. macro TOUCH(Outputs...) {
  7096. .CMD=$YMAKE_PYTHON ${input:"build/scripts/touch.py"} ${output:Outputs}
  7097. }
  7098. TOUCH_UNIT=$YMAKE_PYTHON ${input:"build/scripts/touch.py"} ${kv;hide:"p UN"} ${kv;hide:"pc light-cyan"} $TARGET
  7099. FAKE_PACKAGE_CMD=$YMAKE_PYTHON ${input:"build/scripts/touch.py"} ${kv;hide:"pc light-red"} $TARGET
  7100. COPY_PACKAGE_CMD=$YMAKE_PYTHON ${input:"build/scripts/copy_to_dir.py"} --dest-dir $BINDIR --build-root $ARCADIA_BUILD_ROOT $PACKED_PACKAGE_ARGS $SRCS_GLOBAL $PEERS_LATE_OUTS ${skip_by_ext=.pkg.fake:PEERS} ${hide;late_out:AUTO_INPUT} ${hide;late_out;to_namespace=$BINDIR/:SRCS_GLOBAL} ${hide;late_out;to_namespace=$BINDIR/:PEERS_LATE_OUTS} ${hide;late_out;skip_by_ext=.pkg.fake;to_namespace=$BINDIR/:PEERS} ${kv;hide:"package PACKAGE"}
  7101. TOUCH_PACKAGE=$FAKE_PACKAGE_CMD $VCS_INFO_DISABLE_CACHE__NO_UID__ && $COPY_PACKAGE_CMD
  7102. _P_PK=${kv;hide:"p PK"}
  7103. TOUCH_PACKAGE_MF=$GENERATE_MF && $TOUCH_PACKAGE $_P_PK && $ADD_VCS_INFO_FILE_CMD
  7104. # Note: we don't use touch.py in the command below to avoid introduction of undesired input
  7105. UNION_CMD=$YMAKE_PYTHON -c open(\'$TARGET\',\'w\').close() ${kv;hide:"p UN"} ${kv;hide:"package UNION"} ${kv;hide:"pc light-cyan"} $UNION_OUTS $VCS_INFO_DISABLE_CACHE__NO_UID__
  7106. UNION_CMD_MF=$UNION_CMD && $GENERATE_MF
  7107. macro _EXPAND_INS_OUTS(FILES{input}[]) {
  7108. .CMD=${input;hide:FILES} ${late_out;hide:INPUT}
  7109. }
  7110. _UNION_EXPLICIT_OUTPUTS=
  7111. ### @usage: EXPLICIT_OUTPUTS(Files...)
  7112. ###
  7113. ### Let UNION has only explicitly specified outputs listed in this macro
  7114. ### The list of files shall contain results of commands in this UNION.
  7115. ### Only these files will be outputs of the UNION. This allows to eliminate
  7116. ### intermediate files being result of the UNION
  7117. macro EXPLICIT_OUTPUTS(Files...) {
  7118. SET_APPEND(_UNION_EXPLICIT_OUTPUTS ${Files})
  7119. }
  7120. NO_CHECK_IMPORTS_FOR_VALUE=None
  7121. ### @usage: NO_CHECK_IMPORTS([patterns])
  7122. ###
  7123. ### Do not run checks on imports of Python modules.
  7124. ### Optional parameter mask patterns describes the names of the modules that do not need to check.
  7125. macro NO_CHECK_IMPORTS(Masks...) {
  7126. SET(NO_CHECK_IMPORTS_FOR_VALUE $Masks)
  7127. }
  7128. # tag:yasm-specific
  7129. _YASM_FMT_VALUE=
  7130. _YASM_PLATFORM_FLAGS_VALUE=
  7131. _YASM_PREDEFINED_FLAGS_VALUE=
  7132. when ($OS_DARWIN || $OS_IOS) {
  7133. _YASM_FMT_VALUE=macho
  7134. _YASM_PLATFORM_FLAGS_VALUE=-D DARWIN -D UNIX
  7135. }
  7136. elsewhen ($OS_WINDOWS && $ARCH_X86_64) {
  7137. _YASM_FMT_VALUE=win
  7138. _YASM_PLATFORM_FLAGS_VALUE=-D WIN64
  7139. }
  7140. elsewhen ($OS_WINDOWS && $ARCH_I386) {
  7141. _YASM_FMT_VALUE=win
  7142. _YASM_PLATFORM_FLAGS_VALUE=-D WIN32
  7143. }
  7144. otherwise {
  7145. _YASM_FMT_VALUE=elf
  7146. _YASM_PLATFORM_FLAGS_VALUE=-D UNIX
  7147. _YASM_PREDEFINED_FLAGS_VALUE=-g dwarf2
  7148. }
  7149. when ($ASM_PREFIX) {
  7150. ASM_PREFIX_VALUE=--prefix=$ASM_PREFIX
  7151. }
  7152. otherwise {
  7153. ASM_PREFIX_VALUE=
  7154. }
  7155. # tag:yasm-specific
  7156. YASM_FLAGS=
  7157. YASM_PREINCLUDES_VALUE=
  7158. # tag:yasm-specific
  7159. macro _SRC_yasm_helper(SRC, PREINCLUDES[], SRCFLAGS...) {
  7160. .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"}
  7161. }
  7162. # tag:yasm-specific
  7163. macro _SRC_yasm(SRC, PREINCLUDES[], SRCFLAGS...) {
  7164. .CMD=$_SRC_yasm_helper(${input:SRC}, $SRCFLAGS, PREINCLUDES $PREINCLUDES)
  7165. }
  7166. # tag:nasm-specific
  7167. NASM_FLAGS=
  7168. # tag:nasm-specific
  7169. macro _SRC_nasm_helper(SRC, SRCFLAGS...) {
  7170. .CMD=${NASM_RESOURCE_GLOBAL}/bin/nasm -f ${_YASM_FMT_VALUE}${HARDWARE_ARCH} -D ${pre=_;suf=_:HARDWARE_TYPE} $NASM_FLAGS ${pre=-I :_ASM__INCLUDE} $SRCFLAGS -o ${output;noext;suf=${OBJECT_SUF}:SRC} ${SRC}
  7171. }
  7172. # tag:nasm-specific
  7173. macro _SRC_nasm(SRC, PREINCLUDES[], SRCFLAGS...) {
  7174. .CMD=$_SRC_nasm_helper(${input:SRC}, $SRCFLAGS)
  7175. }
  7176. # tag:src-processing
  7177. when ($USE_NASM_ASSEMBLER == "yes") {
  7178. MACRO_ALIAS(_SRC_ASM _SRC_nasm)
  7179. }
  7180. otherwise {
  7181. MACRO_ALIAS(_SRC_ASM _SRC_yasm)
  7182. }
  7183. ### @usage: ASM_PREINCLUDE(AsmFiles...)
  7184. ###
  7185. ### Supply additional .asm files to all assembler calls within a module
  7186. macro ASM_PREINCLUDE(PREINCLUDES...) {
  7187. SET_APPEND(YASM_PREINCLUDES_VALUE $PREINCLUDES)
  7188. }
  7189. ### @usage: RUN_ANTLR(Args...)
  7190. ###
  7191. ### Macro to invoke ANTLR3 generator (general case)
  7192. macro RUN_ANTLR(IN[], IN_NOPARSE[], OUT[], OUT_NOAUTO[], OUTPUT_INCLUDES[], INDUCED_DEPS[], CWD="", Args...) {
  7193. PEERDIR(build/external_resources/antlr3 build/platform/java/jdk $JDK_RESOURCE_PEERDIR)
  7194. .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 INDUCED_DEPS $INDUCED_DEPS ${pre=CWD :CWD})
  7195. .SEM=run_antlr OUTPUT ${output:OUT} ${output;noauto:OUT_NOAUTO} DEPENDS ${input:IN} ${pre=WORKING_DIRECTORY :CWD} ANTLER_ARGS $Args
  7196. }
  7197. ### @usage: RUN_ANTLR4(Args...)
  7198. ###
  7199. ### Macro to invoke ANTLR4 generator (general case)
  7200. macro RUN_ANTLR4(IN[], IN_NOPARSE[], OUT[], OUT_NOAUTO[], OUTPUT_INCLUDES[], INDUCED_DEPS[], CWD="", Args...) {
  7201. _RUN_JAVA(-jar ${input:"contrib/java/antlr/antlr4/antlr.jar"} $Args IN $IN IN_NOPARSE $IN_NOPARSE OUT $OUT OUT_NOAUTO $OUT_NOAUTO OUTPUT_INCLUDES $OUTPUT_INCLUDES INDUCED_DEPS $INDUCED_DEPS ${pre=CWD :CWD})
  7202. }
  7203. _ANTLR4_LISTENER_GRAMMAR=-listener
  7204. _ANTLR4_LISTENER__ANTLR4_EMPTY=-no-listener
  7205. _ANTLR4_VISITOR_GRAMMAR=-visitor
  7206. _ANTLR4_VISITOR__ANTLR4_EMPTY=-no-visitor
  7207. ### @usage: RUN_ANTLR4_CPP(GRAMMAR, OUTPUT_INCLUDES, LISTENER, VISITOR, Args...)
  7208. ###
  7209. ### Macro to invoke ANTLR4 generator (Cpp)
  7210. macro RUN_ANTLR4_CPP(GRAMMAR, OUTPUT_INCLUDES[], LISTENER?"GRAMMAR":"_ANTLR4_EMPTY", VISITOR?"GRAMMAR":"_ANTLR4_EMPTY", _ANTLR4_EMPTY="", Args...) {
  7211. RUN_ANTLR4(${GRAMMAR} -Dlanguage=Cpp -o ${BINDIR} ${_ANTLR4_VISITOR_$VISITOR} ${_ANTLR4_LISTENER_$LISTENER} ${Args} 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})
  7212. PEERDIR(contrib/libs/antlr4_cpp_runtime)
  7213. }
  7214. ### @usage: RUN_ANTLR4_GO(GRAMMAR, DEPS <extra_go_deps>, LISTENER, VISITOR, Args...)
  7215. ###
  7216. ### Macro to invoke ANTLR4 generator (Go)
  7217. macro RUN_ANTLR4_GO(GRAMMAR, DEPS[], LISTENER?"GRAMMAR":"_ANTLR4_EMPTY", VISITOR?"GRAMMAR":"_ANTLR4_EMPTY", _ANTLR4_EMPTY="", Args...) {
  7218. RUN_ANTLR4(${GRAMMAR} -Dlanguage=Go -o ${BINDIR} ${_ANTLR4_VISITOR_$VISITOR} ${_ANTLR4_LISTENER_$LISTENER} ${Args} 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})
  7219. PEERDIR(${GOSTD}/fmt ${GOSTD}/reflect ${GOSTD}/strconv ${GOSTD}/sync ${GOSTD}/unicode vendor/github.com/antlr/antlr4/runtime/Go/antlr/v4 $DEPS)
  7220. }
  7221. ### @usage: RUN_ANTLR4_PYTHON(Grammar [LISTENER] [VISITOR] [SUBDIR] [EXTRA_OUTS Outs...] Args...)
  7222. ###
  7223. ### `LISTENER` - emit grammar listener
  7224. ### `VISITOR` - emit grammar visitor
  7225. ### `SUBDIR` - place generated files to specified subdirectory of BINDIR
  7226. ### `EXTRA_OUTS` - list extra outputs produced by Antlr (e.g. .interp and .token files) if they are needed. If `SUBDIR` is specied it will affect these as well. Use file names only.
  7227. ###
  7228. ### Macro to invoke ANTLR4 generator (Python). The Python3 will be used for PY3_LIBRARY/PY3_PROGRAM/PY3TEST, Python2 will be used in all other cases.
  7229. macro RUN_ANTLR4_PYTHON(GRAMMAR, LISTENER?"GRAMMAR":"_ANTLR4_EMPTY", VISITOR?"GRAMMAR":"_ANTLR4_EMPTY", SUBDIR=".", EXTRA_OUTS[], _ANTLR4_EMPTY="", Args...) {
  7230. RUN_ANTLR4(${GRAMMAR} -Dlanguage=$ANTLR_PYTHON -o ${BINDIR}/${SUBDIR} ${_ANTLR4_VISITOR_$VISITOR} ${_ANTLR4_LISTENER_$LISTENER} ${Args} CWD ${BINDIR} IN ${GRAMMAR} OUT_NOAUTO ${nopath;noext;pre=${SUBDIR}/;suf=Lexer.py:GRAMMAR} ${nopath;noext;pre=${SUBDIR}/;suf=Parser.py:GRAMMAR} ${nopath;noext;pre=${SUBDIR}/;suf=Listener.py:$LISTENER} ${nopath;noext;pre=${SUBDIR}/;suf=Visitor.py:$VISITOR} ${pre=${SUBDIR}/:EXTRA_OUTS})
  7231. PEERDIR(contrib/python/antlr4)
  7232. }
  7233. # tag:cpp-specific
  7234. macro CPP_ADDINCL(Dirs...) {
  7235. ADDINCL($Dirs)
  7236. }
  7237. # tag:internal
  7238. _WHOLE_ARCHIVE_PEERS_VALUE=
  7239. ### @usage: WHOLE_ARCHIVE(dirnames...) # internal
  7240. macro WHOLE_ARCHIVE(PEERS...) {
  7241. SET_APPEND(_WHOLE_ARCHIVE_PEERS_VALUE ${PEERS})
  7242. REQUIRES(${PEERS})
  7243. }
  7244. ANDROID_SDK_ROOT=${ANDROID_SDK_RESOURCE_GLOBAL}/android_sdk
  7245. macro TASKLET() {
  7246. PEERDIR(tasklet/api)
  7247. # CPP
  7248. CPP_PROTO_PLUGIN(tasklet_cpp tasklet/v1/gen/cpp .tasklet.h)
  7249. # Python
  7250. PY_PROTO_PLUGIN2(tasklet_py _tasklet.py _sbtask.py tasklet/v1/gen/python DEPS tasklet/v1/domain/sandbox tasklet/v1/runtime sandbox/sdk2)
  7251. }
  7252. TASKLET_REG_INCLUDES= \
  7253. ${output_include;hide:"tasklet/v1/runtime/lib/cpp_wrapper.h"} \
  7254. ${output_include;hide:"tasklet/v1/runtime/lib/go_wrapper.h"} \
  7255. ${output_include;hide:"tasklet/v1/runtime/lib/py_wrapper.h"} \
  7256. ${output_include;hide:"tasklet/v1/runtime/lib/js_wrapper.h"} \
  7257. ${output_include;hide:"tasklet/v1/runtime/lib/registry.h"}
  7258. macro TASKLET_REG(Name, Lang, Impl, Includes...) {
  7259. PEERDIR(tasklet/v1/domain sandbox/bin sandbox/taskbox/worker)
  7260. when($Lang == "js") {
  7261. # JS runtime links the Node.js from contrib as a library, which is a bit heavy,
  7262. # so we do it, only if any JS tasklets are linked into the target
  7263. PEERDIR+=tasklet/v1/runtime/js
  7264. }
  7265. .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"}
  7266. SRCS(GLOBAL $Name.task.cpp)
  7267. }
  7268. # TEMPORARY METHOD FOR EXTENDED REGISTRY SETUP
  7269. # NOT COMPLETE
  7270. macro TASKLET_REG_EXT(Name, Lang, Impl, Wrapper, Includes...) {
  7271. PEERDIR(tasklet/v1/domain sandbox/bin sandbox/taskbox/worker)
  7272. .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"}
  7273. SRCS(GLOBAL $Name.task.cpp)
  7274. }
  7275. # tag:cpp-specific
  7276. _CPP_PROTO_MODULE_PREFIX=
  7277. _CPP_PROTO_MODULE_SUFFIX=
  7278. when ($MSVC == "yes" || $CYGWIN == "yes") {
  7279. _CPP_PROTO_MODULE_PREFIX=
  7280. _CPP_PROTO_MODULE_SUFFIX=.lib
  7281. }
  7282. otherwise {
  7283. _CPP_PROTO_MODULE_PREFIX=lib
  7284. _CPP_PROTO_MODULE_SUFFIX=.a
  7285. }
  7286. ### @usage: _EXPOSE(OutputsToExport...)
  7287. ###
  7288. ### Allows to mark outputs of macro command as unused in the current module but intended
  7289. ### to be used in modules consuming current via PEERDIR.
  7290. ###
  7291. ### TODO(DEVTOOLS-9000) proper implementation needed
  7292. macro _EXPOSE(Args...) {
  7293. .CMD=$YMAKE_PYTHON ${input:"build/scripts/touch.py"} ${output;suf=$_HASH_HELPER($Args).ya_exposed:"empty_"} ${input;hide:Args}
  7294. }
  7295. ### @usage: LIST_PROTO([TO list.proto] Files...) # deprecated
  7296. ###
  7297. ### Create list of .proto files in a list-file (should be .proto, files.proto by default)
  7298. ### with original .proto-files as list's dependencies.
  7299. ###
  7300. ### This allows to process files listed, passing list as an argument to the processor
  7301. ###
  7302. ### TODO: proper implementation needed
  7303. macro LIST_PROTO(TO="files.proto", Files...) {
  7304. .CMD=$YMAKE_PYTHON3 ${input:"build/scripts/list.py"} ${Files} ${input;hide:Files} ${stdout;output;noauto:TO} ${output_include;from_input;hide:Files} && $YMAKE_PYTHON ${input:"build/scripts/touch.py"} ${output;noext;suf=.pb.h:TO}
  7305. _EXPOSE(${TO})
  7306. }
  7307. # tag:proto
  7308. macro _PROTO_DESC_CMD(File) {
  7309. .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 $_PROTOC_FLAGS ${input;rootrel:File}
  7310. }
  7311. _PROTO_DESC_MERGE_CMD=$YMAKE_PYTHON ${input:"build/scripts/merge_files.py"} $TARGET $AUTO_INPUT ${kv;hide:"p PD"} ${kv;hide:"pc light-cyan"}
  7312. _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"}
  7313. NEED_GOOGLE_PROTO_PEERDIRS=yes
  7314. CPP_PROTO_LIBRARY_SEM=$CPP_LIBRARY_SEM
  7315. JAVA_PROTO_LIBRARY_SEM=$BUILD_PROTO_JAR_SEM $_GRADLE_EXPORT_PUBLISHING_SEM
  7316. # tag:proto
  7317. ### @usage: PROTO_LIBRARY()
  7318. ###
  7319. ### Build some varian of protocol buffers library.
  7320. ###
  7321. ### The particular variant is selected based on where PEERDIR to PROTO_LIBRARY comes from.
  7322. ###
  7323. ### Now supported 5 variants: C++, Java, Python 2.x, Python 3.x and Go.
  7324. ### When PEERDIR comes from module for particular language appropriate variant is selected.
  7325. ### PROTO_LIBRARY also supports emission of GRPC code if GRPC() macro is specified.
  7326. ### Notes:
  7327. ### - Python versions emit C++ code in addition to Python as optimization.
  7328. ### - In some PROTO_LIBRARY-es Java or Python versions are excluded via EXCLUDE_TAGS macros due to incompatibilities.
  7329. ### - Use from DEPENDS or BUNDLE is not allowed
  7330. ###
  7331. ### Documentation: https://wiki.yandex-team.ru/yatool/proto_library/
  7332. ###
  7333. ### See: [GRPC()](#macro_GRPC), [OPTIMIZE_PY_PROTOS()](#macro_OPTIMIZE_PY_PROTOS), [INCLUDE_TAGS()](#macro_INCLUDE_TAGS), [EXCLUDE_TAGS()](#macro_EXCLUDE_TAGS)
  7334. multimodule PROTO_LIBRARY {
  7335. module CPP_PROTO : LIBRARY {
  7336. .ALLOWED=_EXPOSE LIST_PROTO
  7337. # TODO(svidyuk): think about marker which forces semantics inheritance
  7338. .SEM=CPP_PROTO_LIBRARY_SEM
  7339. FORCE_COVERAGE_DISABLED=yes
  7340. ENABLE(CPP_PROTO)
  7341. ENABLE(GEN_PROTO)
  7342. NO_CLANG_TIDY()
  7343. SET(PEERDIR_TAGS CPP_PROTO)
  7344. when ($BUILD_PROTO_AS_EVLOG == "yes" && $USE_VANILLA_PROTOC == "yes") {
  7345. _OK=no
  7346. }
  7347. ASSERT(_OK BUILD_PROTO_AS_EVLOG and USE_VANILLA_PROTOC are incompatible yet)
  7348. MODULE_SUFFIX=$_CPP_PROTO_MODULE_SUFFIX
  7349. MODULE_PREFIX=$_CPP_PROTO_MODULE_PREFIX
  7350. when ($_COMMON_GOOGLE_APIS != "None") {
  7351. PEERDIR += contrib/libs/googleapis-common-protos
  7352. }
  7353. }
  7354. module JAVA_PROTO: EXTERNAL_JAVA_LIBRARY {
  7355. .EXTS=.jsrc
  7356. .ALLOWED=GRPC
  7357. .SEM=JAVA_PROTO_LIBRARY_SEM
  7358. SET(PEERDIR_TAGS JAVA_PROTO)
  7359. ENABLE(JAVA_PROTO)
  7360. PEERDIR+=$JAVA_PROTOBUF_PEERS
  7361. when ($KOTLIN_PROTO == "yes") {
  7362. KOTLIN_PROTO_PEERS=contrib/java/com/google/protobuf/protobuf-kotlin/${JAVA_PROTO_RUNTIME_VERSION}
  7363. KOTLIN_PROTO_FLAGS=--kotlin_out=$ARCADIA_BUILD_ROOT/java_out
  7364. }
  7365. when ($GRADLE_EXPORT_PUBLISHING == "yes") {
  7366. _GRADLE_EXPORT_PUBLISHING_SEM=$_DO_GRADLE_EXPORT_PUBLISHING_SEM
  7367. }
  7368. .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER USE_SKIFF CPP_PROTO_PLUGIN2 PY_PROTO_PLUGIN YMAPS_SPROTO RESOURCE
  7369. ADDINCL(FOR proto $PROTOBUF_PATH)
  7370. when ($_COMMON_GOOGLE_APIS != "None") {
  7371. PEERDIR += contrib/java/com/google/api/grpc/proto-google-common-protos/${JAVA_PROTO_COMMON_VERSION}
  7372. ADDINCL += GLOBAL FOR proto ${ARCADIA_ROOT}/contrib/libs/googleapis-common-protos
  7373. }
  7374. }
  7375. module PY_PROTO: PY2_LIBRARY {
  7376. .ALIASES=SRCS=PY_SRCS
  7377. .ALLOWED=OPTIMIZE_PY_PROTOS NO_OPTIMIZE_PY_PROTOS
  7378. .PEERDIRSELF=CPP_PROTO
  7379. .SEM=IGNORED
  7380. SET(PEERDIR_TAGS PY2 PY_PROTO)
  7381. ENABLE(PY_PROTO)
  7382. OPTIMIZE_PY_PROTOS()
  7383. OBJ_SUF=.py2
  7384. # Can not use NO_LINT(), because is not allowed outside of contrib directory
  7385. SET(_NO_LINT_VALUE none_internal)
  7386. when ($_COMMON_GOOGLE_APIS != "None") {
  7387. PEERDIR += contrib/libs/googleapis-common-protos
  7388. }
  7389. _IGNORE_SELF_PEERS=
  7390. _CPP_PROTO_LIBRARY=${MODDIR}/$_CPP_PROTO_MODULE_PREFIX$REALPRJNAME$_CPP_PROTO_MODULE_SUFFIX
  7391. when ($OPTIMIZE_PY_PROTOS_FLAG == "no") {
  7392. _IGNORE_PEERDIRSELF=CPP_PROTO
  7393. }
  7394. SET_APPEND(_WHOLE_ARCHIVE_LIBS_VALUE_GLOBAL $_CPP_PROTO_LIBRARY)
  7395. }
  7396. module PY3_PROTO: PY3_LIBRARY {
  7397. .ALIASES=SRCS=PY_SRCS
  7398. .ALLOWED=OPTIMIZE_PY_PROTOS NO_OPTIMIZE_PY_PROTOS
  7399. .PEERDIRSELF=CPP_PROTO
  7400. .SEM=IGNORED
  7401. SET(PEERDIR_TAGS PY3 PY3_PROTO)
  7402. ENABLE(PY3_PROTO)
  7403. OPTIMIZE_PY_PROTOS()
  7404. when ($MSVC == "yes" || $CYGWIN == "yes") {
  7405. MODULE_PREFIX=py3
  7406. }
  7407. otherwise {
  7408. MODULE_PREFIX=libpy3
  7409. }
  7410. OBJ_SUF=.py3
  7411. # Can not use NO_LINT(), because is not allowed outside of contrib directory
  7412. SET(_NO_LINT_VALUE none_internal)
  7413. when ($_COMMON_GOOGLE_APIS != "None") {
  7414. PEERDIR += contrib/libs/googleapis-common-protos
  7415. }
  7416. _IGNORE_SELF_PEERS=
  7417. _CPP_PROTO_LIBRARY=${MODDIR}/$_CPP_PROTO_MODULE_PREFIX$REALPRJNAME$_CPP_PROTO_MODULE_SUFFIX
  7418. when ($OPTIMIZE_PY_PROTOS_FLAG == "no") {
  7419. _IGNORE_PEERDIRSELF=CPP_PROTO
  7420. }
  7421. SET_APPEND(_WHOLE_ARCHIVE_LIBS_VALUE_GLOBAL $_CPP_PROTO_LIBRARY)
  7422. }
  7423. module GO_PROTO: GO_LIBRARY {
  7424. .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER YMAPS_SPROTO
  7425. .SEM=IGNORED
  7426. SET(PEERDIR_TAGS GO GO_PROTO)
  7427. ENABLE(GO_PROTO)
  7428. when ($_COMMON_GOOGLE_APIS == "None") {
  7429. }
  7430. elsewhen ($_COMMON_GOOGLE_APIS == "") {
  7431. PEERDIR += $_GO_COMMON_GOOGLE_APIS
  7432. ADDINCL += GLOBAL FOR proto ${ARCADIA_ROOT}/contrib/libs/googleapis-common-protos
  7433. }
  7434. otherwise {
  7435. PEERDIR += $_COMMON_GOOGLE_APIS
  7436. ADDINCL += GLOBAL FOR proto ${ARCADIA_ROOT}/contrib/libs/googleapis-common-protos
  7437. }
  7438. }
  7439. module DESC_PROTO: _BARE_UNIT {
  7440. .CMD=_PROTO_DESC_MERGE_CMD
  7441. .SEM=IGNORED
  7442. .EXTS=.desc
  7443. .NODE_TYPE=Library
  7444. .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER YMAPS_SPROTO RESOURCE GO_PROTO_PLUGIN GRPC
  7445. SET(PEERDIR_TAGS DESC_PROTO)
  7446. ENABLE(DESC_PROTO)
  7447. MODULE_SUFFIX=.self.protodesc
  7448. SET(MODULE_TYPE LIBRARY)
  7449. MACRO_ALIAS(EVLOG_CMD _PROTO_DESC_CMD)
  7450. MACRO_ALIAS(PROTO_CMD _PROTO_DESC_CMD)
  7451. when ($_COMMON_GOOGLE_APIS != "None") {
  7452. PEERDIR += contrib/libs/googleapis-common-protos
  7453. }
  7454. when ($NEED_GOOGLE_PROTO_PEERDIRS == "yes") {
  7455. when ($USE_VANILLA_PROTOC == "yes") {
  7456. PEERDIR += contrib/libs/protobuf_std/builtin_proto/protos_from_protobuf
  7457. }
  7458. otherwise {
  7459. PEERDIR += contrib/libs/protobuf/builtin_proto/protos_from_protoc
  7460. }
  7461. }
  7462. }
  7463. }
  7464. module PROTO_DESCRIPTIONS: _BARE_UNIT {
  7465. .CMD=_PROTO_DESC_MERGE_PEERS_CMD
  7466. .PEERDIR_POLICY=as_build_from
  7467. .NODE_TYPE=Library
  7468. .RESTRICTED=SRCS
  7469. .FINAL_TARGET=yes
  7470. SET(PEERDIR_TAGS DESC_PROTO)
  7471. SET(MODULE_SUFFIX .protodesc)
  7472. SET(MODULE_TYPE PROTO_DESCRIPTIONS)
  7473. }
  7474. module PROTO_REGISTRY: PROTO_DESCRIPTIONS {
  7475. SET(MODULE_TYPE PROTO_REGISTRY)
  7476. }
  7477. # tag:fbs
  7478. _FBS_NAMESPACE_MAP_GLOBAL=
  7479. # tag:fbs
  7480. macro _FBS_NAMESPACE_IMPL(NAMESPACE, PATH, DUMMY...) {
  7481. SET_APPEND(_FBS_NAMESPACE_MAP_GLOBAL ${NAMESPACE}=${PATH})
  7482. }
  7483. # tag:fbs
  7484. macro FBS_NAMESPACE(NAMESPACE, PATH...) {
  7485. _FBS_NAMESPACE_IMPL($NAMESPACE $PATH $MODDIR)
  7486. }
  7487. # tag:fbs
  7488. ### @usage: FBS_LIBRARY()
  7489. ###
  7490. ### Build some variant of Flatbuffers library.
  7491. ###
  7492. ### The particular variant is selected based on where PEERDIR to FBS_LIBRARY
  7493. ### comes from.
  7494. ###
  7495. ### Now supported 5 variants: C++, Java, Python 2.x, Python 3.x and Go.
  7496. ### When PEERDIR comes from module for particular language appropriate variant
  7497. ### is selected.
  7498. ###
  7499. ### Notes: FBS_NAMESPACE must be specified in all dependent FBS_LIBRARY modules
  7500. ### if build of Go code is requested.
  7501. multimodule FBS_LIBRARY {
  7502. module CPP_FBS: LIBRARY {
  7503. ENABLE(CPP_FBS)
  7504. SET(PEERDIR_TAGS CPP_FBS)
  7505. }
  7506. module GO_FBS: GO_LIBRARY {
  7507. .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER
  7508. ENABLE(GO_FBS)
  7509. SET(PEERDIR_TAGS GO GO_FBS)
  7510. }
  7511. module JAVA_FBS: EXTERNAL_JAVA_LIBRARY {
  7512. .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER
  7513. ENABLE(JAVA_FBS)
  7514. SET(PEERDIR_TAGS JAVA_FBS)
  7515. }
  7516. module PY2_FBS: PY2_LIBRARY {
  7517. .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER
  7518. .ALIASES=SRCS=PY_SRCS
  7519. ENABLE(PY2_FBS)
  7520. SET(PEERDIR_TAGS PY2 PY2_FBS)
  7521. # Can not use NO_LINT(), because is not allowed outside of contrib directory
  7522. SET(_NO_LINT_VALUE none_internal)
  7523. }
  7524. module PY3_FBS: PY3_LIBRARY {
  7525. .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER
  7526. .ALIASES=SRCS=PY_SRCS
  7527. ENABLE(PY3_FBS)
  7528. SET(PEERDIR_TAGS PY3 PY3_FBS)
  7529. # Can not use NO_LINT(), because is not allowed outside of contrib directory
  7530. SET(_NO_LINT_VALUE none_internal)
  7531. when ($MSVC == "yes" || $CYGWIN == "yes") {
  7532. MODULE_PREFIX=py3
  7533. }
  7534. otherwise {
  7535. MODULE_PREFIX=libpy3
  7536. }
  7537. OBJ_SUF=.py3
  7538. }
  7539. }
  7540. # tag:java-specific
  7541. _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"}
  7542. # tag:java-specific
  7543. COMPILE_JSRC_MF=$_COMPILE_JSRC && $GENERATE_MF
  7544. # tag:java-specific tag:internal
  7545. ### @usage: JSRC_LIBRARY() # internal
  7546. module JSRC_LIBRARY: _BARE_UNIT {
  7547. .CMD=COMPILE_JSRC_MF
  7548. .EXTS=.java
  7549. .PEERDIR_POLICY=as_include
  7550. .FINAL_TARGET=no
  7551. .ALIASES=SRCS=FILES
  7552. PEERDIR_TAGS=JAVA_PROTO JAVA_FBS JAVA_IDL
  7553. MODULE_TYPE=LIBRARY
  7554. SET(MODULE_SUFFIX .jsrc)
  7555. SET(DONT_RESOLVE_INCLUDES yes)
  7556. SET(NEED_PLATFORM_PEERDIRS no)
  7557. SET(MODULE_LANG JAVA)
  7558. NO_RUNTIME()
  7559. }
  7560. # tag:maps-specific
  7561. @import "${CONF_ROOT}/conf/project_specific/maps/asrc.conf"
  7562. # tag:internal
  7563. ### @usage: _PROXY_LIBRARY() # internal
  7564. ###
  7565. ### The use of this module is strictly prohibited!!!
  7566. module _PROXY_LIBRARY: LIBRARY {
  7567. .EXTS=.a .lib
  7568. .PEERDIR_POLICY=as_build_from
  7569. .PROXY=yes
  7570. .FINAL_TARGET=yes
  7571. DISABLE(NEED_ADD_FAKE_SRC)
  7572. NO_UTIL()
  7573. NO_RUNTIME()
  7574. }
  7575. # tag:maps-specific
  7576. @import "${CONF_ROOT}/conf/project_specific/maps/aar.conf"
  7577. @import "${CONF_ROOT}/conf/project_specific/maps/sproto.conf"
  7578. @import "${CONF_ROOT}/conf/project_specific/maps/mapkit.conf"
  7579. _PRIMARY_OUTPUT_VALUE=
  7580. # tag:internal
  7581. ### @usage: PRIMARY_OUTPUT_VALUE(Output) # internal
  7582. ###
  7583. ### The use of this module is strictly prohibited!!!
  7584. macro PRIMARY_OUTPUT(OUTPUT) {
  7585. SET(_PRIMARY_OUTPUT_VALUE $OUTPUT)
  7586. }
  7587. _DLL_PROXY_LIBRARY_CMD=$GENERATE_MF && $COPY_CMD $_PRIMARY_OUTPUT_VALUE ${input;hide:_PRIMARY_OUTPUT_VALUE} ${TARGET}
  7588. # tag:internal
  7589. ### @usage: DLL_PROXY_LIBRARY() # internal
  7590. ###
  7591. ### The use of this module is strictly prohibited!!!
  7592. module DLL_PROXY_LIBRARY: _PROXY_LIBRARY {
  7593. .ALLOWED=PRIMARY_OUTPUT
  7594. .CMD=_DLL_PROXY_LIBRARY_CMD
  7595. }
  7596. _PREBUILT_PROGRAM_CMD=$GENERATE_MF && $COPY_CMD $_PRIMARY_OUTPUT_VALUE ${TARGET} ${kv;hide:"p ld"} ${kv;hide:"pc light-blue"} ${kv;hide:"show_out"}
  7597. # tag:internal
  7598. ### @usage: PREBUILT_PROGRAM([programname]) # internal
  7599. ###
  7600. ### Program module which uses a prebuilt prgram as its output.
  7601. module PREBUILT_PROGRAM: _LINK_UNIT {
  7602. .CMD=_PREBUILT_PROGRAM_CMD
  7603. .SYMLINK_POLICY=EXE
  7604. .ALLOWED=INDUCED_DEPS PRIMARY_OUTPUT
  7605. .RESTRICTED=SRCS
  7606. _BARE_LINK_MODULE()
  7607. SET(MODULE_TYPE PROGRAM)
  7608. when ($WIN32 == "yes" || $OS_CYGWIN == "yes") {
  7609. MODULE_SUFFIX=.exe
  7610. }
  7611. }
  7612. ### @usage COLLECT_JINJA_TEMPLATES(varname path)
  7613. ###
  7614. ### This macro collects all jinja and yaml files in the directory specified by second argument and
  7615. ### stores result in the variable with mane specified by first parameter.
  7616. macro COLLECT_JINJA_TEMPLATES(VAR, DIR) {
  7617. _GLOB($VAR ${DIR}/**/*.jinja ${DIR}/**/*.yaml)
  7618. }
  7619. # tag:go-specific
  7620. ### @usage: COLLECT_GO_SWAGGER_FILES(Varname, Dir)
  7621. ###
  7622. ### Recursively collect files for swagger config creation
  7623. macro COLLECT_GO_SWAGGER_FILES(Varname, Dir) {
  7624. _GLOB($Varname $Dir/**/*.go ${ARCADIA_ROOT}/go.mod)
  7625. }
  7626. # tag:go-specific
  7627. GO_HOST_OS=unknown
  7628. when ($HOST_OS_LINUX) {
  7629. GO_HOST_OS=linux
  7630. }
  7631. elsewhen ($HOST_OS_DARWIN) {
  7632. GO_HOST_OS=darwin
  7633. }
  7634. elsewhen($HOST_OS_WINDOWS) {
  7635. GO_HOST_OS=windows
  7636. }
  7637. # tag:go-specific
  7638. GO_HOST_ARCH=unknown
  7639. when ($HOST_ARCH_X86_64) {
  7640. GO_HOST_ARCH=amd64
  7641. }
  7642. elsewhen($HOST_ARCH_ARM64) {
  7643. GO_HOST_ARCH=arm64
  7644. }
  7645. # tag:go-specific
  7646. GO_TARG_OS=unknown
  7647. when ($OS_LINUX) {
  7648. GO_TARG_OS=linux
  7649. }
  7650. elsewhen ($OS_DARWIN) {
  7651. GO_TARG_OS=darwin
  7652. }
  7653. elsewhen ($OS_WINDOWS) {
  7654. GO_TARG_OS=windows
  7655. }
  7656. # tag:go-specific
  7657. GO_TARG_ARCH=unknwon
  7658. when ($ARCH_X86_64) {
  7659. GO_TARG_ARCH=amd64
  7660. }
  7661. elsewhen ($ARCH_I386) {
  7662. GO_TARG_ARCH=x86
  7663. }
  7664. elsewhen ($ARCH_ARM64) {
  7665. GO_TARG_ARCH=arm64
  7666. }
  7667. # tag:go-specific
  7668. GO_HOST_TARG_PARAMS=++host-os $GO_HOST_OS ++host-arch $GO_HOST_ARCH ++targ-os $GO_TARG_OS ++targ-arch $GO_TARG_ARCH
  7669. # tag:go-specific
  7670. GOSTD_VERSION=1.20
  7671. when ($GOSTD_VERSION == "1.20") {
  7672. GOSTD=contrib/go/_std_1.20/src
  7673. }
  7674. otherwise {
  7675. GOSTD=__unsupported_go_std_library_version_[$GOSTD_VERSION]__
  7676. }
  7677. # tag:go-specific
  7678. GO_DEBUG_PATH_RELATIVE=no
  7679. _GO_DEBUG_PATH__NO_UID__=
  7680. _GO_COMPILE_SYMABIS_TRIMPATH__NO_UID__=
  7681. # tag:go-specific
  7682. _GO_BUILDMODE=
  7683. _GO_IMPORT_PATH=${MODDIR}
  7684. # tag:go-specific
  7685. GO_VET=yolint
  7686. GO_VET_TOOL=
  7687. GO_VET_FLAGS=
  7688. GO_VET_EXTRA_FLAGS=
  7689. # tag:go-specific
  7690. _GO_VET_ADD_CHECK=yes
  7691. _GO_FMT_ADD_CHECK=yes
  7692. _GO_YDX_FILE=
  7693. # tag:go-specific
  7694. _GO_CGO1_WRAPPER_FLAGS=--build-prefix=/-B --source-prefix=/-S
  7695. _GO_LINK_EXE_EXT_CMD=
  7696. # tag:go-specific
  7697. GO_WITH_MUSL=
  7698. # tag:go-specific
  7699. GO_TOOLS_ROOT=${GO_TOOLS_RESOURCE_GLOBAL}
  7700. GO_TEST_MINER=${tool:"tools/go_test_miner"}
  7701. GO_TEST_IMPORT_PATH=
  7702. # tag:go-specific
  7703. GO_STD_LIB_PREFIX=${GOSTD}/
  7704. GO_STD_CMD_PREFIX=${GOSTD}/cmd/
  7705. GO_ARCADIA_PROJECT_PREFIX=a.yandex-team.ru/
  7706. GO_CONTRIB_PROJECT_PREFIX=vendor/
  7707. GO_SKIP_IMPORTS=unsafe C
  7708. GO_VET_INFO_EXT=.vet.out
  7709. GO_VET_REPORT_EXT=.vet.txt
  7710. GO_VET_OUTPUT_INFO=${output;rootrel;hide;pre=${MODULE_PREFIX};suf=${MODULE_SUFFIX}${GO_VET_INFO_EXT}:REALPRJNAME}
  7711. GO_VET_OUTPUT_REPORT=${output;rootrel;hide;pre=${MODULE_PREFIX};suf=${MODULE_SUFFIX}${GO_VET_REPORT_EXT}:REALPRJNAME}
  7712. # tag:go-specific tag:codenav
  7713. _GO_YNDEXER_EXT=.ydx.pb2
  7714. GO_YNDEXER_OUTPUT=${output;pre=${MODULE_PREFIX};suf=${MODULE_SUFFIX}${_GO_YNDEXER_EXT}:REALPRJNAME}
  7715. # tag:go-specific
  7716. GO_PROJECT_PREFIXES=++std-lib-prefix $GO_STD_LIB_PREFIX ++arc-project-prefix $GO_ARCADIA_PROJECT_PREFIX
  7717. # tag:go-specific
  7718. _GO_FAKEID=${FAKEID}.${BUILD_TYPE}.${GOSTD_VERSION}.${GO_FAKEID}
  7719. _CGO_FAKEID=${_GO_FAKEID}.${CPP_FAKEID}
  7720. # tag:go-specific
  7721. CGO2_CFLAGS_VALUE=
  7722. CGO2_LDFLAGS_VALUE=
  7723. # tag:go-specific
  7724. GO_ASM_FLAGS_VALUE=
  7725. ### @usage: GO_ASM_FLAGS(flags)
  7726. ### Add the specified flags to the go asm compile command line.
  7727. macro GO_ASM_FLAGS(Flags...) {
  7728. SET_APPEND(GO_ASM_FLAGS_VALUE $Flags)
  7729. }
  7730. # tag:go-specific
  7731. GO_CGO1_FLAGS_VALUE=
  7732. ### @usage: GO_CGO1_FLAGS(flags)
  7733. ### Add the specified flags to the go cgo compile command line.
  7734. macro GO_CGO1_FLAGS(Flags...) {
  7735. SET_APPEND(GO_CGO1_FLAGS_VALUE $Flags)
  7736. }
  7737. # tag:go-specific
  7738. GO_CGO2_FLAGS_VALUE=
  7739. ### @usage: GO_CGO2_FLAGS(flags)
  7740. ### Add the specified flags to the go cgo compile command line.
  7741. macro GO_CGO2_FLAGS(Flags...) {
  7742. SET_APPEND(GO_CGO2_FLAGS_VALUE $Flags)
  7743. }
  7744. # tag:go-specific
  7745. GO_COMPILE_FLAGS_VALUE=$USER_GO_COMPILE_FLAGS
  7746. ### @usage: GO_COMPILE_FLAGS(flags)
  7747. ### Add the specified flags to the go compile command line.
  7748. macro GO_COMPILE_FLAGS(Flags...) {
  7749. SET_APPEND(GO_COMPILE_FLAGS_VALUE $Flags)
  7750. }
  7751. # tag:go-specific
  7752. GO_LINK_FLAGS_VALUE=$USER_GO_LINK_FLAGS
  7753. ### @usage: GO_LINK_FLAGS(flags)
  7754. ### Add the specified flags to the go link command line.
  7755. macro GO_LINK_FLAGS(Flags...) {
  7756. SET_APPEND(GO_LINK_FLAGS_VALUE $Flags)
  7757. }
  7758. # tag:go-specific
  7759. _GO_LANG_VERSION_VALUE=
  7760. macro GOLANG_VERSION(Arg) {
  7761. SET(_GO_LANG_VERSION_VALUE $Arg)
  7762. }
  7763. # tag:go-specific
  7764. _GO_TOOL_MODE=
  7765. # tag:go-specific
  7766. _GO_TOOL_COMMON_FLAGS=\
  7767. ++mode $_GO_TOOL_MODE \
  7768. $GO_PROJECT_PREFIXES \
  7769. ++goversion $GOSTD_VERSION \
  7770. ++lang $_GO_LANG_VERSION_VALUE \
  7771. ++source-root $ARCADIA_ROOT \
  7772. ++build-root $ARCADIA_BUILD_ROOT \
  7773. ++output-root $BINDIR \
  7774. ++toolchain-root $GO_TOOLS_ROOT \
  7775. $GO_HOST_TARG_PARAMS \
  7776. ++output $TARGET \
  7777. $GO_VET_OUTPUT \
  7778. $_GO_YDX_FILE \
  7779. $_GO_DEBUG_PATH__NO_UID__ \
  7780. ++srcs $AUTO_INPUT ${input:GO_FILES} \
  7781. ++asm-flags $GO_ASM_FLAGS_VALUE \
  7782. ++compile-flags $GO_COMPILE_FLAGS_VALUE \
  7783. ++link-flags $GO_LINK_FLAGS_VALUE \
  7784. ++cgo-srcs ${input:CGO_FILES} \
  7785. $_GO_EMBED_VALUE \
  7786. $_GO_BUILDMODE \
  7787. $GO_TOOLCHAIN_ENV
  7788. # tag:go-specific
  7789. macro _GO_GEN_COVER_GO(GO_FILE, GO_COVER_OUTPUT, VAR_ID) {
  7790. .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_COVER_OUTPUT} ${input:GO_FILE}
  7791. }
  7792. # tag:go-specific
  7793. macro _GO_COMPILE_SYMABIS(FLAGS[], ASM_FILES...) {
  7794. .CMD=${hide:_CGO_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"}
  7795. .ADDINCL=build/scripts/go_fake_include
  7796. }
  7797. # tag:go-specific
  7798. macro _GO_COMPILE_CGO1(NAME, FLAGS[], FILES...) {
  7799. .CMD=${hide:_CGO_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"}
  7800. }
  7801. # tag:go-specific
  7802. macro _GO_COMPILE_CGO2(NAME, C_FILES[], S_FILES[], OBJ_FILES[], FILES...) {
  7803. .CMD=${hide:_CGO_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"}
  7804. _USE_LINKER()
  7805. }
  7806. GO_TOOL=$YMAKE_PYTHON3 ${input:"build/scripts/go_tool.py"} $_PROCESS_WHOLE_ARCHIVE_SCRIPT
  7807. # tag:go-specific
  7808. macro _GO_LINK_LIB_IMPL(CGO_FILES[], EXTRA_INPUTS[], GO_FILES...) {
  7809. .CMD=${hide:_GO_FAKEID} $GO_TOOL ${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"}
  7810. }
  7811. # tag:go-specific
  7812. macro _GO_LINK_EXE_IMPL(CGO_FILES[], EXTRA_INPUTS[], GO_FILES...) {
  7813. .CMD=${hide:_GO_FAKEID} $GO_TOOL ${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
  7814. }
  7815. # tag:go-specific
  7816. macro _GO_LINK_TEST_IMPL(CGO_FILES[], EXTRA_INPUTS[], GO_TEST_FILES[], GO_XTEST_FILES[], GO_FILES...) {
  7817. .CMD=${hide:_GO_FAKEID} $GO_TOOL ${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_PROGRAM|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_PROGRAM|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"}
  7818. }
  7819. # tag:go-specific
  7820. GO_LINK_LIB=$GENERATE_MF && $_GO_LINK_LIB_IMPL($_GO_SRCS_VALUE CGO_FILES $_CGO_SRCS_VALUE EXTRA_INPUTS $_GO_EMBED_INPUTS)
  7821. 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)
  7822. 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)
  7823. GO_LINK_DLL=$GO_LINK_EXE && $COPY_CMD $BINDIR/_cgo_export.h ${output;pre=${MODULE_PREFIX};suf=.h:REALPRJNAME}
  7824. # tag:go-specific
  7825. CGO_ENABLED=yes
  7826. when ($OS_WINDOWS == "yes" || $SANITIZER_TYPE && $SANITIZER_TYPE != "no") {
  7827. CGO_ENABLED=no
  7828. }
  7829. elsewhen ($CGO_ENABLED == "yes") {
  7830. GO_LINK_FLAGS_VALUE+=-linkmode=external
  7831. }
  7832. # tag:go-specific
  7833. GO_PACKAGE_VALUE=
  7834. ### @usage: GO_PACKAGE_NAME(Name)
  7835. ### Override name of a Go package.
  7836. macro GO_PACKAGE_NAME(NAME) {
  7837. SET(GO_PACKAGE_VALUE $NAME)
  7838. }
  7839. # tag:go-specific tag:internal
  7840. _GO_SRCS_VALUE=
  7841. ### @usage: _GO_SRCS(Files...) # internal
  7842. ### This macro shouldn't be used in ya.make files, use SRCS() instead.
  7843. ### This is internal macro collecting .go sources for processing within Go modules (GO_PROGRAM and GO_LIBRARY)
  7844. macro _GO_SRCS(FILES...) {
  7845. GO_FAKE_OUTPUT($FILES)
  7846. SET_APPEND(_GO_SRCS_VALUE $FILES)
  7847. }
  7848. # tag:go-specific
  7849. _GO_TEST_SRCS_VALUE=
  7850. GO_HAS_INTERNAL_TESTS=no
  7851. ### @usage: GO_TEST_SRCS(Files...)
  7852. ### .go sources for internal tests of a module
  7853. macro GO_TEST_SRCS(FILES...) {
  7854. GO_FAKE_OUTPUT($FILES)
  7855. _SET_FIRST_VALUE(GO_HAS_INTERNAL_TESTS ${pre=yes :FILES} ${GO_HAS_INTERNAL_TESTS})
  7856. SET_APPEND(_GO_TEST_SRCS_VALUE $FILES)
  7857. }
  7858. # tag:go-specific
  7859. _GO_XTEST_SRCS_VALUE=
  7860. GO_HAS_EXTERNAL_TESTS=no
  7861. ### @usage: GO_XTEST_SRCS(Files...)
  7862. ### .go sources for external tests of a module
  7863. macro GO_XTEST_SRCS(FILES...) {
  7864. GO_FAKE_OUTPUT($FILES)
  7865. SET(GO_HAS_EXTERNAL_TESTS yes)
  7866. SET_APPEND(_GO_XTEST_SRCS_VALUE $FILES)
  7867. }
  7868. # tag:go-specific
  7869. macro _GO_UNUSED_SRCS(FLAGS...) {
  7870. ENABLE(UNUSED_MACRO)
  7871. }
  7872. # tag:go-specific
  7873. _CGO_SRCS_VALUE=
  7874. ### @usage: CGO_SRCS(Files...)
  7875. ### .go sources to be built with CGO
  7876. macro CGO_SRCS(FILES...) {
  7877. SET_APPEND(_CGO_SRCS_VALUE $FILES)
  7878. PEERDIR(${GOSTD}/syscall)
  7879. }
  7880. # tag:go-specific
  7881. GO_LDFLAGS_GLOBAL=
  7882. ### @usage: GO_LDFLAGS(Flags...)
  7883. ### Link flags for GO_PROGRAM linking from .go sources
  7884. macro GO_LDFLAGS(FLAGS...) {
  7885. SET_APPEND(GO_LDFLAGS_GLOBAL $FLAGS)
  7886. }
  7887. # tag:go-specific
  7888. CGO_CFLAGS_VALUE=
  7889. ### @usage: CGO_CFLAGS(Flags...)
  7890. ### Compiler flags specific to CGO compilation
  7891. macro CGO_CFLAGS(FLAGS...) {
  7892. SET_APPEND(CGO_CFLAGS_VALUE $FLAGS)
  7893. CFLAGS($FLAGS)
  7894. }
  7895. # tag:go-specific
  7896. CGO_LDFLAGS_VALUE=
  7897. ### @usage: CGO_LDFLAGS(Files...)
  7898. ### Linker flags specific to CGO linking
  7899. macro CGO_LDFLAGS(FLAGS...) {
  7900. SET_APPEND(CGO_LDFLAGS_VALUE $FLAGS)
  7901. GO_LDFLAGS($FLAGS)
  7902. }
  7903. # tag:go-specific
  7904. _GO_SKIP_TEST_VALUE=
  7905. ### @usage: GO_SKIP_TESTS(TestNames...)
  7906. ###
  7907. ### Define a set of tests that should not be run.
  7908. ### NB! Subtests are not taken into account!
  7909. macro GO_SKIP_TESTS(TESTS...) {
  7910. SET_APPEND(_GO_SKIP_TEST_VALUE $TESTS)
  7911. RESTRICT_PATH(vendor MSG This macro is prohibited to be used outside the vendor/ directory)
  7912. }
  7913. # tag:go-specific tag:internal
  7914. _GO_EMBED_VALUE=
  7915. _GO_EMBED_INPUTS=
  7916. ### @usage: _GO_EMBED_PATTERN(PATTERN) # internal
  7917. ###
  7918. ### Define an embed pattern.
  7919. macro _GO_EMBED_PATTERN(XTEST?"_xtest":"", PATTERN, IMPORT_PATH) {
  7920. SET(VAR_SALT1 $XTEST $PATTERN $IMPORT_PATH 1)
  7921. SET(_PATTERN_GLOB1 uniq_embed_${hash:VAR_SALT1})
  7922. _GLOB($_PATTERN_GLOB1 ${ARCADIA_ROOT}/${IMPORT_PATH}/${PATTERN}/**/* EXCLUDE ${ARCADIA_ROOT}/${IMPORT_PATH}/${PATTERN}/**/_* ${ARCADIA_ROOT}/${IMPORT_PATH}/${PATTERN}/**/.*)
  7923. SET(VAR_SALT2 $XTEST $PATTERN $IMPORT_PATH 2)
  7924. SET(_PATTERN_GLOB2 _uniq_embed_${hash:VAR_SALT2})
  7925. _GLOB($_PATTERN_GLOB2 ${ARCADIA_ROOT}/${IMPORT_PATH}/${PATTERN})
  7926. SET_APPEND(_GO_EMBED_VALUE ++embed$XTEST $PATTERN \$$_PATTERN_GLOB1 \$$_PATTERN_GLOB2)
  7927. SET_APPEND(_GO_EMBED_INPUTS \$$_PATTERN_GLOB1 \$$_PATTERN_GLOB2)
  7928. }
  7929. # tag:go-specific
  7930. ### @usage: GO_EMBED_PATTERN(PATTERN)
  7931. ###
  7932. ### Define an embed pattern.
  7933. macro GO_EMBED_PATTERN(PATTERN) {
  7934. _GO_EMBED_PATTERN($PATTERN $_GO_IMPORT_PATH)
  7935. }
  7936. # tag:go-specific
  7937. ### @usage: GO_TEST_EMBED_PATTERN(PATTERN)
  7938. ###
  7939. ### Define an embed pattern for internal go tests.
  7940. macro GO_TEST_EMBED_PATTERN(PATTERN) {
  7941. _GO_EMBED_PATTERN($PATTERN $_GO_IMPORT_PATH)
  7942. }
  7943. # tag:go-specific
  7944. ### @usage: GO_XTEST_EMBED_PATTERN(PATTERN)
  7945. ###
  7946. ### Define an embed pattern for external go tests.
  7947. macro GO_XTEST_EMBED_PATTERN(PATTERN) {
  7948. _GO_EMBED_PATTERN(XTEST $PATTERN $_GO_IMPORT_PATH)
  7949. }
  7950. # tag:go-specific tag:internal
  7951. ### @usage: _GO_EMBED_DIR(PATTERN) # internal
  7952. ###
  7953. ### Define an embed directory DIR.
  7954. macro _GO_EMBED_DIR(XTEST?"_xtest":"", DIR, IMPORT_PATH, ALL?"all:":"", EXCLUDES...) {
  7955. SET(VAR_SALT $XTEST $DIR $IMPORT_PATH)
  7956. SET(_PATTERN_GLOB uniq_embed_${hash:VAR_SALT})
  7957. _GLOB($_PATTERN_GLOB ${ARCADIA_ROOT}/${IMPORT_PATH}/${DIR}/**/* EXCLUDE ${pre=${ARCADIA_ROOT}/${IMPORT_PATH}/${DIR}/**/:EXCLUDES})
  7958. SET_APPEND(_GO_EMBED_VALUE ++embed$XTEST $ALL$DIR \$$_PATTERN_GLOB)
  7959. SET_APPEND(_GO_EMBED_INPUTS \$$_PATTERN_GLOB)
  7960. }
  7961. # tag:go-specific
  7962. ### @usage: GO_EMBED_DIR(DIR)
  7963. ###
  7964. ### Define an embed directory DIR.
  7965. macro GO_EMBED_DIR(ALL?"ALL":"_* .*", DIR) {
  7966. _GO_EMBED_DIR($DIR $_GO_IMPORT_PATH ${ALL})
  7967. }
  7968. # tag:go-specific
  7969. ### @usage: GO_EMBED_TEST_DIR(DIR)
  7970. ###
  7971. ### Define an embed directory DIR for internal go tests.
  7972. macro GO_EMBED_TEST_DIR(ALL?"ALL":"_* .*", DIR) {
  7973. _GO_EMBED_DIR($DIR $_GO_IMPORT_PATH ${ALL})
  7974. }
  7975. # tag:go-specific
  7976. ### @usage: GO_EMBED_XTEST_DIR(DIR)
  7977. ###
  7978. ### Define an embed directory DIR for external go tests.
  7979. macro GO_EMBED_XTEST_DIR(ALL?"ALL":"_* .*", DIR) {
  7980. _GO_EMBED_DIR(XTEST $DIR $_GO_IMPORT_PATH ${ALL})
  7981. }
  7982. # tag:go-specific
  7983. _GO_TOOLCHAIN_ENV_GOARCH=unknown
  7984. when ($ARCH_ARM64) {
  7985. _GO_TOOLCHAIN_ENV_GOARCH=${env:"GOARCH=arm64"}
  7986. }
  7987. elsewhen ($ARCH_X86_64) {
  7988. _GO_TOOLCHAIN_ENV_GOARCH=${env:"GOARCH=amd64"}
  7989. }
  7990. # tag:go-specific
  7991. _GO_TOOLCHAIN_ENV_GOOS=unknown
  7992. when ($OS_DARWIN) {
  7993. _GO_TOOLCHAIN_ENV_GOOS=${env:"GOOS=darwin"}
  7994. }
  7995. elsewhen ($OS_LINUX) {
  7996. _GO_TOOLCHAIN_ENV_GOOS=${env:"GOOS=linux"}
  7997. }
  7998. elsewhen ($OS_WINDOWS) {
  7999. _GO_TOOLCHAIN_ENV_GOOS=${env:"GOOS=windows"}
  8000. }
  8001. _GO_TOOLCHAIN_ENV_PATH=
  8002. # tag:go-specific
  8003. GO_TOOLCHAIN_ENV=$TOOLCHAIN_ENV $_GO_TOOLCHAIN_ENV_GOARCH $_GO_TOOLCHAIN_ENV_GOOS $_GO_TOOLCHAIN_ENV_PATH
  8004. # tag:go-specific
  8005. _GO_GRPC_WELLKNOWN=\
  8006. vendor/google.golang.org/grpc \
  8007. vendor/google.golang.org/grpc \
  8008. vendor/google.golang.org/grpc/codes \
  8009. vendor/google.golang.org/grpc/grpclog \
  8010. vendor/google.golang.org/grpc/status
  8011. # tag:go-specific
  8012. macro _GO_GRPC() {
  8013. SET(GO_PROTO_GEN_PLUGINS plugins=grpc)
  8014. SET(GO_PROTO_GRPC_OPTS \$GO_PROTO_GRPC_OPTS_V2)
  8015. SET(GO_PROTO_GRPC_OUTS \$GO_PROTO_GRPC_OUTS_V2)
  8016. PEERDIR(${GOSTD}/context ${_GO_GRPC_WELLKNOWN})
  8017. }
  8018. # tag:go-specific
  8019. ### @usage: GO_GRPC_GATEWAY_SRCS()
  8020. ###
  8021. ### Use of grpc-gateway plugin (Supported for Go only).
  8022. macro GO_GRPC_GATEWAY_SRCS(FILE...) {
  8023. ENABLE(UNUSED_MACRO)
  8024. }
  8025. # tag:go-specific
  8026. ### @usage: GO_GRPC_GATEWAY_SWAGGER_SRCS()
  8027. ###
  8028. ### Use of grpc-gateway plugin w/ swagger emission (Supported for Go only).
  8029. macro GO_GRPC_GATEWAY_SWAGGER_SRCS(FILE...) {
  8030. PEERDIR(vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options)
  8031. }
  8032. # tag:go-specific
  8033. _GO_PROTO_GRPC_GATEWAY_OPTS=
  8034. _GO_PROTO_GRPC_GATEWAY_OUTS=
  8035. # tag:go-specific
  8036. macro _GO_GRPC_GATEWAY_SRCS_IMPL(Files...) {
  8037. foreach (File : $Files) {
  8038. [.proto]=$_GO_PROTO_CMD_IMPL($File $_GO_PROTO_GRPC_GATEWAY_OPTS $_GO_PROTO_GRPC_GATEWAY_OUTS)
  8039. }
  8040. PEERDIR(${GOSTD}/context ${GOSTD}/io ${GOSTD}/net/http)
  8041. PEERDIR(vendor/github.com/golang/protobuf/descriptor)
  8042. PEERDIR(vendor/github.com/grpc-ecosystem/grpc-gateway/runtime)
  8043. PEERDIR(vendor/github.com/grpc-ecosystem/grpc-gateway/utilities)
  8044. PEERDIR(vendor/google.golang.org/grpc/metadata)
  8045. }
  8046. # tag:go-specific
  8047. macro _SETUP_GO_GRPC_GATEWAY() {
  8048. 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))
  8049. SET(_GO_PROTO_GRPC_GATEWAY_OUTS \${output;hide;norel;nopath;noext;suf=.pb.gw.go:File})
  8050. }
  8051. # tag:go-specific
  8052. macro _GO_GRPC_GATEWAY_SRCS(Files...) {
  8053. _SETUP_GO_GRPC_GATEWAY()
  8054. _GO_GRPC_GATEWAY_SRCS_IMPL($Files)
  8055. }
  8056. # tag:go-specific
  8057. macro _GO_GRPC_GATEWAY_SWAGGER_SRCS(Files...) {
  8058. _SETUP_GO_GRPC_GATEWAY()
  8059. SET_APPEND(_GO_PROTO_GRPC_GATEWAY_OPTS $_PROTO_PLUGIN_ARGS_BASE(swagger vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger logtostderr=true allow_repeated_fields_in_body=true))
  8060. SET_APPEND(_GO_PROTO_GRPC_GATEWAY_OUTS \${output;hide;norel;noauto;nopath;noext;suf=.swagger.json:File})
  8061. _GO_GRPC_GATEWAY_SRCS_IMPL($Files)
  8062. PEERDIR(vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options)
  8063. }
  8064. #tag:go-specific
  8065. ### @usage: GO_GRPC_GATEWAY_V2_OPENAPI_SRCS(Files...)
  8066. ###
  8067. ### Use of grpc-gateway plugin w/ openapi v2 emission (Supported for Go only).
  8068. macro GO_GRPC_GATEWAY_V2_OPENAPI_SRCS(NO_JSON_NAMES_FOR_FIELDS?"":"", Files...) {
  8069. PEERDIR(vendor/github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options)
  8070. }
  8071. macro _GO_GRPC_GATEWAY_V2_OPENAPI_SRCS(NO_JSON_NAMES_FOR_FIELDS?"json_names_for_fields=false":"", Files...) {
  8072. _SETUP_GO_GRPC_GATEWAY_V2()
  8073. SET_APPEND(_GO_PROTO_GRPC_GATEWAY_V2_OPTS $_PROTO_PLUGIN_ARGS_BASE(openapiv2 vendor/github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 $NO_JSON_NAMES_FOR_FIELDS logtostderr=true))
  8074. SET_APPEND(_GO_PROTO_GRPC_GATEWAY_V2_OPTS \${output;hide;norel;noauto;nopath;noext;suf=.swagger.json:File})
  8075. _GO_GRPC_GATEWAY_V2_SRCS_IMPL($Files)
  8076. PEERDIR(vendor/github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options)
  8077. }
  8078. # tag:go-specific
  8079. ### @usage: GO_GRPC_GATEWAY_V2_SRCS()
  8080. ###
  8081. ### Use of grpc-gateway plugin (Supported for Go only).
  8082. macro GO_GRPC_GATEWAY_V2_SRCS(FILE...) {
  8083. ENABLE(UNUSED_MACRO)
  8084. }
  8085. # tag:go-specific
  8086. _GO_PROTO_GRPC_GATEWAY_V2_OPTS=
  8087. _GO_PROTO_GRPC_GATEWAY_V2_OUTS=
  8088. # tag:go-specific
  8089. macro _GO_GRPC_GATEWAY_V2_SRCS_IMPL(Files...) {
  8090. foreach (File : $Files) {
  8091. [.proto]=$_GO_PROTO_CMD_IMPL($File $_GO_PROTO_GRPC_GATEWAY_V2_OPTS $_GO_PROTO_GRPC_GATEWAY_V2_OUTS)
  8092. }
  8093. PEERDIR(${GOSTD}/context ${GOSTD}/io ${GOSTD}/net/http)
  8094. PEERDIR(vendor/github.com/golang/protobuf/descriptor)
  8095. PEERDIR(vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime)
  8096. PEERDIR(vendor/github.com/grpc-ecosystem/grpc-gateway/v2/utilities)
  8097. PEERDIR(vendor/google.golang.org/grpc/metadata)
  8098. PEERDIR(vendor/google.golang.org/protobuf/proto)
  8099. }
  8100. # tag:go-specific
  8101. macro _SETUP_GO_GRPC_GATEWAY_V2() {
  8102. SET(_GO_PROTO_GRPC_GATEWAY_V2_OPTS $_PROTO_PLUGIN_ARGS_BASE(go_grpc_gw vendor/github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway allow_repeated_fields_in_body=true))
  8103. SET(_GO_PROTO_GRPC_GATEWAY_V2_OUTS \${output;hide;norel;nopath;noext;suf=.pb.gw.go:File})
  8104. }
  8105. # tag:go-specific
  8106. macro _GO_GRPC_GATEWAY_V2_SRCS(Files...) {
  8107. _SETUP_GO_GRPC_GATEWAY_V2()
  8108. _GO_GRPC_GATEWAY_V2_SRCS_IMPL($Files)
  8109. }
  8110. # tag:go-specific
  8111. when ($MUSL == "yes") {
  8112. _GO_DEFAULT_ALLOCATOR=LF
  8113. }
  8114. otherwise {
  8115. _GO_DEFAULT_ALLOCATOR=FAKE
  8116. }
  8117. # tag:go-specific tag:internal
  8118. ### @usage _GO_BASE_UNIT # internal
  8119. ###
  8120. ### The base module of all golang modules. Defines common properties, dependencies and rules for go build.
  8121. module _GO_BASE_UNIT: _BASE_UNIT {
  8122. .EXTS=.go .gosrc .o .obj .a .symabis .mf
  8123. .CMD=TOUCH_UNIT
  8124. .NODE_TYPE=Bundle
  8125. .GLOBAL=GO_LDFLAGS
  8126. .PEERDIR_POLICY=as_build_from
  8127. .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 GO_GRPC_GATEWAY_V2_SRCS=_GO_GRPC_GATEWAY_V2_SRCS GO_GRPC_GATEWAY_V2_OPENAPI_SRCS=_GO_GRPC_GATEWAY_V2_OPENAPI_SRCS
  8128. .ALLOWED=GO_PROTO_PLUGIN USE_CXX USE_UTIL RESOURCE_FILES
  8129. .IGNORED=GO_SKIP_TESTS USE_SKIFF
  8130. .RESTRICTED=TEST_SRCS
  8131. .DEFAULT_NAME_GENERATOR=UseDirNameOrSetGoPackage
  8132. ENABLE(_GO_MODULE)
  8133. SET(MODULE_TAG GO)
  8134. PEERDIR_TAGS=GO GO_PROTO GO_FBS __EMPTY__
  8135. DEFAULT(_GO_VET_TOOL)
  8136. DEFAULT(_GO_VET_FLAGS)
  8137. DEFAULT(_GO_VET_EXTS)
  8138. DEFAULT(_GO_SONAME)
  8139. NO_RUNTIME()
  8140. SET(COVERAGE_FLAGS)
  8141. SET(EXTRA_OUTPUT)
  8142. SET(MODULE_LANG GO)
  8143. ENABLE(FORCE_CONSISTENT_DEBUG)
  8144. PEERDIR(build/external_resources/go_tools)
  8145. GO_PROTO_GRPC_OPTS_V2=--plugin=protoc-gen-go-grpc=${tool:_TOOL_PROTOC_GEN_GO_GRPC_V2} --go-grpc_out=${ARCADIA_BUILD_ROOT}/$PROTO_NAMESPACE
  8146. GO_PROTO_GRPC_OUTS_V2=${output;norel;nopath;noext;suf=_grpc.pb.go:File}
  8147. select ($GO_PROTO_V2) {
  8148. "yes" | "on" ? {
  8149. GO_PROTO_OUTS+=${output;hide;norel;nopath;noext;suf=.pb.go:File}
  8150. GO_PROTO_OPTS+=--plugin=protoc-gen-go=${tool:_TOOL_PROTOC_GEN_GO_V2} --go_out=${ARCADIA_BUILD_ROOT}/$PROTO_NAMESPACE
  8151. _GO_PROTO_CHECK_OUTPUT=--check $GO_PROTO_GRPC_OUTS_V2
  8152. GO_PROTO_OPTS+=$GO_PROTO_GRPC_OPTS
  8153. }
  8154. default ? {
  8155. GO_PROTO_OUTS+=${output;hide;norel;nopath;noext;suf=.pb.go:File}
  8156. GO_PROTO_OPTS+=--plugin=protoc-gen-go=${tool:_TOOL_PROTOC_GEN_GO} --go_out=$GO_PROTO_GEN_PLUGINS:${ARCADIA_BUILD_ROOT}/$PROTO_NAMESPACE
  8157. }
  8158. }
  8159. when ($COMPILER_PLATFORM && $NEED_PLATFORM_PEERDIRS == "yes") {
  8160. PEERDIR+=$COMPILER_PLATFORM
  8161. }
  8162. when ($CLANG == "yes" || $GCC == "yes") {
  8163. CGO_CFLAGS_VALUE += -w -pthread -fpic
  8164. CGO2_CFLAGS_VALUE += -Wno-unused-variable
  8165. }
  8166. select ($GO_VET) {
  8167. "yes" | "on" ? {
  8168. _GO_VET=yes
  8169. _GO_VET_FLAGS+=-cgocall=false
  8170. }
  8171. "yndexer" ? {
  8172. _GO_VET=yes
  8173. PEERDIR+=build/external_resources/goyndexer
  8174. _GO_VET_TOOL=${GOYNDEXER_RESOURCE_GLOBAL}/goyndexer
  8175. _GO_YDX_FILE=++ydx-file ${_GO_YNDEXER_EXT}
  8176. _GO_VET_FLAGS=-indexer.arc ${ARCADIA_ROOT} -indexer.indexfile ${GO_YNDEXER_OUTPUT} -indexer.loglevel info
  8177. _GO_FMT_ADD_CHECK=no
  8178. _GO_VET_ADD_CHECK=no
  8179. GO_VET_INFO_EXT=.ydx.out
  8180. GO_VET_REPORT_EXT=.ydx.txt
  8181. _GO_VET_EXTS=++vet-info-ext .ydx.out ++vet-report-ext .ydx.txt
  8182. _GO_CGO1_WRAPPER_FLAGS=--build-prefix=__ARCADIA_BUILD_ROOT_PREFIX__ --source-prefix=__ARCADIA_SOURCE_ROOT_PREFIX__
  8183. }
  8184. "yolint" ? {
  8185. _GO_VET=yes
  8186. PEERDIR+=build/external_resources/yolint
  8187. _GO_VET_TOOL=${YOLINT_RESOURCE_GLOBAL}/yolint
  8188. _GO_VET_FLAGS=-migration.config=${input:"${ARCADIA_ROOT}/build/rules/go/migrations.yaml"} -scopelint.config=${input:"${ARCADIA_ROOT}/build/rules/go/extended_lint.yaml"}
  8189. }
  8190. "yolint_next" ? {
  8191. _GO_VET=yes
  8192. PEERDIR+=build/external_resources/yolint
  8193. _GO_VET_TOOL=${YOLINT_NEXT_RESOURCE_GLOBAL}/yolint
  8194. _GO_VET_FLAGS=-scopelint.config=${input:"${ARCADIA_ROOT}/build/rules/go/extended_lint.yaml"}
  8195. }
  8196. "local" ? {
  8197. _GO_VET=yes
  8198. _GO_VET_FLAGS=
  8199. }
  8200. default ? {
  8201. _GO_VET=no
  8202. _GO_VET_FLAGS=
  8203. }
  8204. }
  8205. SET(_GO_VET $_GO_VET)
  8206. when ($GO_VET_TOOL == "") {
  8207. _GO_VET_TOOL_REAL=$_GO_VET_TOOL
  8208. }
  8209. otherwise {
  8210. _GO_VET_TOOL_REAL=$GO_VET_TOOL
  8211. }
  8212. when ($GO_VET_FLAGS == "") {
  8213. _GO_VET_FLAGS_REAL=$_GO_VET_FLAGS
  8214. }
  8215. otherwise {
  8216. _GO_VET_FLAGS_REAL=$GO_VET_FLAGS
  8217. }
  8218. when ($_GO_VET == "yes" && $NO_GO_VET != "yes") {
  8219. 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
  8220. }
  8221. otherwise {
  8222. GO_VET_OUTPUT=
  8223. _GO_VET_ADD_CHECK=no
  8224. }
  8225. when ($GO_DEBUG_PATH_RELATIVE == "yes") {
  8226. _GO_DEBUG_PATH__NO_UID__=++debug-root-map source=;build=;tools= ++tools-root $(TOOL_ROOT)
  8227. _GO_COMPILE_SYMABIS_TRIMPATH__NO_UID__=-trimpath $ARCADIA_ROOT=>;$ARCADIA_BUILD_ROOT=>;$(TOOL_ROOT)=>
  8228. }
  8229. otherwise {
  8230. _GO_DEBUG_PATH__NO_UID__=++debug-root-map source=/-S;build=/-B;tools=/-T ++tools-root $(TOOL_ROOT)
  8231. _GO_COMPILE_SYMABIS_TRIMPATH__NO_UID__=-trimpath $ARCADIA_ROOT=>/-S;$ARCADIA_BUILD_ROOT=>/-B;$(TOOL_ROOT)=>/-T
  8232. }
  8233. _GO_PROCESS_SRCS()
  8234. when ($CLANG == "yes") {
  8235. _GO_EXTLD=clang
  8236. GO_TOOLCHAIN_ENV += ${env:"CC=clang"}
  8237. }
  8238. otherwise {
  8239. _GO_EXTLD=gcc
  8240. GO_TOOLCHAIN_ENV += ${env:"CC=gcc"}
  8241. }
  8242. when ($OS_DARWIN) {
  8243. PEERDIR+=build/external_resources/go_fake_xcrun
  8244. 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
  8245. CGO2_LDFLAGS_VALUE += $LD_SDK_VERSION -undefined dynamic_lookup -nodefaultlibs -lc
  8246. }
  8247. elsewhen ($OS_LINUX) {
  8248. 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
  8249. CGO2_LDFLAGS_VALUE += -Wl,--unresolved-symbols=ignore-all -nodefaultlibs -lc
  8250. }
  8251. otherwise {
  8252. GO_EXTLD = ++extld $_GO_EXTLD
  8253. }
  8254. when ($RACE == "yes") {
  8255. _GO_COMPILE_FLAGS_RACE=-race
  8256. _GO_LINK_FLAGS_RACE=-race
  8257. }
  8258. otherwise {
  8259. _GO_COMPILE_FLAGS_RACE=
  8260. _GO_LINK_FLAGS_RACE=
  8261. }
  8262. when ($PIC == "yes" || $PIE == "yes") {
  8263. _GO_COMPILE_FLAGS_SHARED=-shared
  8264. _GO_ASM_FLAGS_SHARED=-shared
  8265. }
  8266. otherwise {
  8267. _GO_COMPILE_FLAGS_SHARED=
  8268. _GO_ASM_FLAGS_SHARED=
  8269. }
  8270. GO_ASM_FLAGS_VALUE += $_GO_ASM_FLAGS_SHARED
  8271. GO_COMPILE_FLAGS_VALUE += $_GO_COMPILE_FLAGS_RACE $_GO_COMPILE_FLAGS_SHARED
  8272. GO_LINK_FLAGS_VALUE += $_GO_LINK_FLAGS_RACE
  8273. ADDINCL(${GOSTD}/runtime)
  8274. }
  8275. # tag:go-specific
  8276. ### @usage: GO_LIBRARY([name])
  8277. ###
  8278. ### Go library module definition.
  8279. ### Compile Go module as a library suitable for PEERDIR from other Go modules.
  8280. ### Will select Go implementation on PEERDIR to PROTO_LIBRARY.
  8281. module GO_LIBRARY: _GO_BASE_UNIT {
  8282. .CMD=GO_LINK_LIB
  8283. .NODE_TYPE=Bundle
  8284. .FINAL_TARGET=no
  8285. SET(_GO_TOOL_MODE lib)
  8286. SET(MODULE_TYPE LIBRARY)
  8287. SET(PEERDIR_TAGS GO GO_PROTO GO_FBS __EMPTY__ PACKAGE_UNION)
  8288. _REQUIRE_EXPLICIT_LICENSE(vendor)
  8289. MODULE_SUFFIX=.a
  8290. }
  8291. # tag:go-specific
  8292. ### @usage: GO_PROGRAM([name])
  8293. ###
  8294. ### Go program module definition.
  8295. ### Compile and link Go module to an executable program.
  8296. ### Will select Go implementation on PEERDIR to PROTO_LIBRARY.
  8297. module GO_PROGRAM: _GO_BASE_UNIT {
  8298. .CMD=GO_LINK_EXE
  8299. .NODE_TYPE=Program
  8300. .PROXY=yes
  8301. .SYMLINK_POLICY=EXE
  8302. .ALLOWED=INDUCED_DEPS
  8303. .FINAL_TARGET=yes
  8304. SET(MODULE_TAG GO_PROGRAM)
  8305. SET(_GO_TOOL_MODE exe)
  8306. SET(MODULE_TYPE PROGRAM)
  8307. SET(GO_VET_OUTPUT_INFO)
  8308. ALLOCATOR($_GO_DEFAULT_ALLOCATOR)
  8309. _USE_LINKER()
  8310. ENABLE(COMMON_LINK_SETTINGS)
  8311. when ($MUSL == "yes") {
  8312. PEERDIR += contrib/libs/musl/full
  8313. }
  8314. when ($RACE == "yes") {
  8315. PEERDIR += contrib/libs/cxxsupp/builtins
  8316. }
  8317. when ($MSVC == "yes" || $CYGWIN == "yes") {
  8318. MODULE_SUFFIX=.exe
  8319. }
  8320. PEERDIR(${GOSTD}/runtime library/go/core/buildinfo)
  8321. when ($RACE == "yes") {
  8322. PEERDIR += ${GOSTD}/runtime/cgo
  8323. PEERDIR += ${GOSTD}/runtime/race
  8324. }
  8325. when ($MUSL == "yes") {
  8326. GO_WITH_MUSL = ++musl
  8327. }
  8328. when ($HARDENING == "yes") {
  8329. _GO_BUILDMODE=++buildmode=pie
  8330. }
  8331. }
  8332. # tag:go-specific
  8333. module _GO_DLL_BASE_UNIT: GO_PROGRAM {
  8334. .CMD=GO_LINK_DLL
  8335. .SYMLINK_POLICY=SO
  8336. .ALLOWED=WHOLE_ARCHIVE
  8337. .ARGS_PARSER=DLL
  8338. .NODE_TYPE=Library
  8339. .PROXY=yes
  8340. SET(_GO_TOOL_MODE dll)
  8341. SET(MODULE_TYPE DLL)
  8342. GO_PACKAGE_NAME(main)
  8343. when ($MSVC == "yes" || $CYGWIN == "yes") {
  8344. MODULE_SUFFIX=.dll
  8345. }
  8346. elsewhen ($DARWIN == "yes" || $OS_IOS == "yes") {
  8347. MODULE_PREFIX=lib
  8348. MODULE_SUFFIX=.dylib$MODULE_VERSION
  8349. }
  8350. otherwise {
  8351. MODULE_PREFIX=lib
  8352. MODULE_SUFFIX=.so$MODULE_VERSION
  8353. }
  8354. when ($OS_DARWIN) {
  8355. _GO_SONAME=-Wl,-install_name,$SONAME
  8356. }
  8357. elsewhen ($OS_LINUX) {
  8358. _GO_SONAME=-Wl,-soname,$SONAME
  8359. }
  8360. when ($MODULE_VERSION) {
  8361. when ($OS_LINUX || $OS_DARWIN) {
  8362. _GO_LINK_EXE_EXT_CMD+= && $LINK_OR_COPY_CMD $TARGET ${output;nopath;noext:SONAME}
  8363. }
  8364. }
  8365. }
  8366. # tag:go-specific
  8367. ### @usage: GO_DLL(name major_ver [minor_ver] [PREFIX prefix])
  8368. ###
  8369. ### Go ishared object module definition.
  8370. ### Compile and link Go module to a shared object.
  8371. ### Will select Go implementation on PEERDIR to PROTO_LIBRARY.
  8372. module GO_DLL: _GO_DLL_BASE_UNIT {
  8373. }
  8374. # tag:go-specific tag:test
  8375. ### @usage: GO_BENCH_TIMEOUT(x)
  8376. ###
  8377. ### Sets timeout in seconds for 1 Benchmark in go benchmark suite
  8378. ###
  8379. ### Documentation about the system test: https://wiki.yandex-team.ru/yatool/test/
  8380. macro GO_BENCH_TIMEOUT(bench_timeout) {
  8381. SET(GO_BENCH_TIMEOUT $bench_timeout)
  8382. }
  8383. # tag:go-specific tag:test
  8384. ### @usage: GO_TEST([name])
  8385. ###
  8386. ### Go test module definition.
  8387. ### Compile and link Go module as a test suitable for running with Arcadia testing support.
  8388. ### All usual testing support macros like DATA, DEPENDS, SIZE, REQUIREMENTS etc. are supported.
  8389. ### Will select Go implementation on PEERDIR to PROTO_LIBRARY.
  8390. module GO_TEST: GO_PROGRAM {
  8391. .CMD=GO_LINK_TEST
  8392. .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
  8393. .ALLOWED=GO_SKIP_TESTS YT_SPEC
  8394. .FINAL_TARGET=no
  8395. SET(MODULE_TAG GO_TEST)
  8396. SET(PEERDIR_TAGS GO GO_PROGRAM GO_PROTO GO_FBS __EMPTY__)
  8397. SET(_GO_TOOL_MODE test)
  8398. SET(MODULE_TYPE PROGRAM)
  8399. ENABLE(GO_TEST_MODULE)
  8400. SET(GO_COVER_INFO_VALUE)
  8401. # We have to add uncoditionaly PEERDIR to ${GOSTD}/os here thouth it is really
  8402. # needed when TestMain is defined in the source code of the test
  8403. PEERDIR(${GOSTD}/os)
  8404. PEERDIR(${GOSTD}/testing/internal/testdeps)
  8405. PEERDIR(${GOSTD}/testing)
  8406. ADD_YTEST($MODULE_PREFIX$REALPRJNAME go.test)
  8407. ADD_YTEST($MODULE_PREFIX$REALPRJNAME go.bench)
  8408. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS canondata/result.json)
  8409. }
  8410. # tag:go-specific
  8411. macro GO_MOCKGEN_FROM(Path) {
  8412. SET(MOCKGEN_FROM ${Path})
  8413. }
  8414. # tag:go-specific
  8415. macro GO_MOCKGEN_TYPES(Types...) {
  8416. SET(MOCKGEN_TYPES ${join=\\${__COMMA__}:Types})
  8417. }
  8418. # tag:go-specific
  8419. macro GO_MOCKGEN_REFLECT() {
  8420. PEERDIR(${GOSTD}/encoding/gob)
  8421. PEERDIR(${GOSTD}/flag)
  8422. PEERDIR(${GOSTD}/fmt)
  8423. PEERDIR(${GOSTD}/os)
  8424. PEERDIR(${GOSTD}/path)
  8425. PEERDIR(${GOSTD}/reflect)
  8426. PEERDIR(vendor/github.com/golang/mock/mockgen/model)
  8427. PEERDIR(${MOCKGEN_FROM})
  8428. RUN_PROGRAM(vendor/github.com/golang/mock/mockgen -prog_only a.yandex-team.ru/${MOCKGEN_FROM} $MOCKGEN_TYPES STDOUT main.go)
  8429. }
  8430. # tag:internal
  8431. macro _TOOL(TOOL) {
  8432. .CMD=${tool:TOOL}
  8433. }
  8434. # tag:go-specific
  8435. macro GO_MOCKGEN_MOCKS() {
  8436. PEERDIR(${GOSTD}/reflect)
  8437. PEERDIR(vendor/github.com/golang/mock/gomock)
  8438. .CMD=${tool:"vendor/github.com/golang/mock/mockgen"} -package mocks -exec_only $_TOOL($MODDIR/gen) a.yandex-team.ru/${MOCKGEN_FROM} $MOCKGEN_TYPES ${output;stdout:"main.go"}
  8439. }
  8440. # Conflict between protobuf-java and protobuf-javalite ¯\_(ツ)_/¯
  8441. # both libraries are required by grpc
  8442. JAVA_IGNORE_CLASSPATH_CLASH_DEFAULE_VALUE=\
  8443. com.google.protobuf.AbstractMessageLite \
  8444. com.google.protobuf.AbstractMessageLite$Builder \
  8445. com.google.protobuf.AbstractMessageLite$Builder$LimitedInputStream \
  8446. com.google.protobuf.AbstractMessageLite$InternalOneOfEnum \
  8447. com.google.protobuf.AbstractParser \
  8448. com.google.protobuf.AbstractProtobufList \
  8449. com.google.protobuf.AllocatedBuffer \
  8450. com.google.protobuf.AllocatedBuffer$1 \
  8451. com.google.protobuf.AllocatedBuffer$2 \
  8452. com.google.protobuf.Android \
  8453. com.google.protobuf.Any \
  8454. com.google.protobuf.Any$1 \
  8455. com.google.protobuf.Any$Builder \
  8456. com.google.protobuf.AnyOrBuilder \
  8457. com.google.protobuf.AnyProto \
  8458. com.google.protobuf.Api \
  8459. com.google.protobuf.Api$1 \
  8460. com.google.protobuf.Api$Builder \
  8461. com.google.protobuf.ApiOrBuilder \
  8462. com.google.protobuf.ApiProto \
  8463. com.google.protobuf.ArrayDecoders \
  8464. com.google.protobuf.ArrayDecoders$1 \
  8465. com.google.protobuf.ArrayDecoders$Registers \
  8466. com.google.protobuf.BinaryReader \
  8467. com.google.protobuf.BinaryReader$1 \
  8468. com.google.protobuf.BinaryReader$SafeHeapReader \
  8469. com.google.protobuf.BinaryWriter \
  8470. com.google.protobuf.BinaryWriter$1 \
  8471. com.google.protobuf.BinaryWriter$SafeDirectWriter \
  8472. com.google.protobuf.BinaryWriter$SafeHeapWriter \
  8473. com.google.protobuf.BinaryWriter$UnsafeDirectWriter \
  8474. com.google.protobuf.BinaryWriter$UnsafeHeapWriter \
  8475. com.google.protobuf.BooleanArrayList \
  8476. com.google.protobuf.BoolValue \
  8477. com.google.protobuf.BoolValue$1 \
  8478. com.google.protobuf.BoolValue$Builder \
  8479. com.google.protobuf.BoolValueOrBuilder \
  8480. com.google.protobuf.BufferAllocator \
  8481. com.google.protobuf.BufferAllocator$1 \
  8482. com.google.protobuf.ByteBufferWriter \
  8483. com.google.protobuf.ByteOutput \
  8484. com.google.protobuf.ByteString \
  8485. com.google.protobuf.ByteString$1 \
  8486. com.google.protobuf.ByteString$2 \
  8487. com.google.protobuf.ByteString$AbstractByteIterator \
  8488. com.google.protobuf.ByteString$ArraysByteArrayCopier \
  8489. com.google.protobuf.ByteString$BoundedByteString \
  8490. com.google.protobuf.ByteString$ByteArrayCopier \
  8491. com.google.protobuf.ByteString$ByteIterator \
  8492. com.google.protobuf.ByteString$CodedBuilder \
  8493. com.google.protobuf.ByteString$LeafByteString \
  8494. com.google.protobuf.ByteString$LiteralByteString \
  8495. com.google.protobuf.ByteString$Output \
  8496. com.google.protobuf.ByteString$SystemByteArrayCopier \
  8497. com.google.protobuf.BytesValue \
  8498. com.google.protobuf.BytesValue$1 \
  8499. com.google.protobuf.BytesValue$Builder \
  8500. com.google.protobuf.BytesValueOrBuilder \
  8501. com.google.protobuf.CanIgnoreReturnValue \
  8502. com.google.protobuf.CheckReturnValue \
  8503. com.google.protobuf.CodedInputStream \
  8504. com.google.protobuf.CodedInputStream$1 \
  8505. com.google.protobuf.CodedInputStream$ArrayDecoder \
  8506. com.google.protobuf.CodedInputStream$IterableDirectByteBufferDecoder \
  8507. com.google.protobuf.CodedInputStream$StreamDecoder \
  8508. com.google.protobuf.CodedInputStream$StreamDecoder$RefillCallback \
  8509. com.google.protobuf.CodedInputStream$StreamDecoder$SkippedDataSink \
  8510. com.google.protobuf.CodedInputStream$UnsafeDirectNioDecoder \
  8511. com.google.protobuf.CodedInputStreamReader \
  8512. com.google.protobuf.CodedInputStreamReader$1 \
  8513. com.google.protobuf.CodedOutputStream \
  8514. com.google.protobuf.CodedOutputStream$1 \
  8515. com.google.protobuf.CodedOutputStream$AbstractBufferedEncoder \
  8516. com.google.protobuf.CodedOutputStream$ArrayEncoder \
  8517. com.google.protobuf.CodedOutputStream$ByteOutputEncoder \
  8518. com.google.protobuf.CodedOutputStream$HeapNioEncoder \
  8519. com.google.protobuf.CodedOutputStream$OutOfSpaceException \
  8520. com.google.protobuf.CodedOutputStream$OutputStreamEncoder \
  8521. com.google.protobuf.CodedOutputStream$SafeDirectNioEncoder \
  8522. com.google.protobuf.CodedOutputStream$UnsafeDirectNioEncoder \
  8523. com.google.protobuf.CodedOutputStreamWriter \
  8524. com.google.protobuf.CodedOutputStreamWriter$1 \
  8525. com.google.protobuf.DoubleArrayList \
  8526. com.google.protobuf.DoubleValue \
  8527. com.google.protobuf.DoubleValue$1 \
  8528. com.google.protobuf.DoubleValue$Builder \
  8529. com.google.protobuf.DoubleValueOrBuilder \
  8530. com.google.protobuf.Duration \
  8531. com.google.protobuf.Duration$1 \
  8532. com.google.protobuf.Duration$Builder \
  8533. com.google.protobuf.DurationOrBuilder \
  8534. com.google.protobuf.DurationProto \
  8535. com.google.protobuf.Empty \
  8536. com.google.protobuf.Empty$1 \
  8537. com.google.protobuf.Empty$Builder \
  8538. com.google.protobuf.EmptyOrBuilder \
  8539. com.google.protobuf.EmptyProto \
  8540. com.google.protobuf.Enum \
  8541. com.google.protobuf.Enum$1 \
  8542. com.google.protobuf.Enum$Builder \
  8543. com.google.protobuf.EnumOrBuilder \
  8544. com.google.protobuf.EnumValue \
  8545. com.google.protobuf.EnumValue$1 \
  8546. com.google.protobuf.EnumValue$Builder \
  8547. com.google.protobuf.EnumValueOrBuilder \
  8548. com.google.protobuf.ExperimentalApi \
  8549. com.google.protobuf.ExtensionLite \
  8550. com.google.protobuf.ExtensionRegistryFactory \
  8551. com.google.protobuf.ExtensionRegistryLite \
  8552. com.google.protobuf.ExtensionRegistryLite$ExtensionClassHolder \
  8553. com.google.protobuf.ExtensionRegistryLite$ObjectIntPair \
  8554. com.google.protobuf.ExtensionSchema \
  8555. com.google.protobuf.ExtensionSchemaLite \
  8556. com.google.protobuf.ExtensionSchemaLite$1 \
  8557. com.google.protobuf.ExtensionSchemas \
  8558. com.google.protobuf.Field \
  8559. com.google.protobuf.Field$1 \
  8560. com.google.protobuf.Field$Builder \
  8561. com.google.protobuf.Field$Cardinality \
  8562. com.google.protobuf.Field$Cardinality$1 \
  8563. com.google.protobuf.Field$Kind \
  8564. com.google.protobuf.Field$Kind$1 \
  8565. com.google.protobuf.FieldInfo \
  8566. com.google.protobuf.FieldInfo$1 \
  8567. com.google.protobuf.FieldInfo$Builder \
  8568. com.google.protobuf.FieldMask \
  8569. com.google.protobuf.FieldMask$1 \
  8570. com.google.protobuf.FieldMask$Builder \
  8571. com.google.protobuf.FieldMaskOrBuilder \
  8572. com.google.protobuf.FieldMaskProto \
  8573. com.google.protobuf.FieldOrBuilder \
  8574. com.google.protobuf.FieldSet \
  8575. com.google.protobuf.FieldSet$1 \
  8576. com.google.protobuf.FieldSet$Builder \
  8577. com.google.protobuf.FieldSet$FieldDescriptorLite \
  8578. com.google.protobuf.FieldType \
  8579. com.google.protobuf.FieldType$1 \
  8580. com.google.protobuf.FieldType$Collection \
  8581. com.google.protobuf.FloatArrayList \
  8582. com.google.protobuf.FloatValue \
  8583. com.google.protobuf.FloatValue$1 \
  8584. com.google.protobuf.FloatValue$Builder \
  8585. com.google.protobuf.FloatValueOrBuilder \
  8586. com.google.protobuf.GeneratedMessageInfoFactory \
  8587. com.google.protobuf.GeneratedMessageLite \
  8588. com.google.protobuf.GeneratedMessageLite$1 \
  8589. com.google.protobuf.GeneratedMessageLite$Builder \
  8590. com.google.protobuf.GeneratedMessageLite$DefaultInstanceBasedParser \
  8591. com.google.protobuf.GeneratedMessageLite$ExtendableBuilder \
  8592. com.google.protobuf.GeneratedMessageLite$ExtendableMessage \
  8593. com.google.protobuf.GeneratedMessageLite$ExtendableMessage$ExtensionWriter \
  8594. com.google.protobuf.GeneratedMessageLite$ExtendableMessageOrBuilder \
  8595. com.google.protobuf.GeneratedMessageLite$ExtensionDescriptor \
  8596. com.google.protobuf.GeneratedMessageLite$GeneratedExtension \
  8597. com.google.protobuf.GeneratedMessageLite$MethodToInvoke \
  8598. com.google.protobuf.GeneratedMessageLite$SerializedForm \
  8599. com.google.protobuf.Int32Value \
  8600. com.google.protobuf.Int32Value$1 \
  8601. com.google.protobuf.Int32Value$Builder \
  8602. com.google.protobuf.Int32ValueOrBuilder \
  8603. com.google.protobuf.Int64Value \
  8604. com.google.protobuf.Int64Value$1 \
  8605. com.google.protobuf.Int64Value$Builder \
  8606. com.google.protobuf.Int64ValueOrBuilder \
  8607. com.google.protobuf.IntArrayList \
  8608. com.google.protobuf.Internal \
  8609. com.google.protobuf.Internal$BooleanList \
  8610. com.google.protobuf.Internal$DoubleList \
  8611. com.google.protobuf.Internal$EnumLite \
  8612. com.google.protobuf.Internal$EnumLiteMap \
  8613. com.google.protobuf.Internal$EnumVerifier \
  8614. com.google.protobuf.Internal$FloatList \
  8615. com.google.protobuf.Internal$IntList \
  8616. com.google.protobuf.Internal$ListAdapter \
  8617. com.google.protobuf.Internal$ListAdapter$Converter \
  8618. com.google.protobuf.Internal$LongList \
  8619. com.google.protobuf.Internal$MapAdapter \
  8620. com.google.protobuf.Internal$MapAdapter$1 \
  8621. com.google.protobuf.Internal$MapAdapter$Converter \
  8622. com.google.protobuf.Internal$MapAdapter$EntryAdapter \
  8623. com.google.protobuf.Internal$MapAdapter$IteratorAdapter \
  8624. com.google.protobuf.Internal$MapAdapter$SetAdapter \
  8625. com.google.protobuf.Internal$ProtobufList \
  8626. com.google.protobuf.InvalidProtocolBufferException \
  8627. com.google.protobuf.InvalidProtocolBufferException$InvalidWireTypeException \
  8628. com.google.protobuf.IterableByteBufferInputStream \
  8629. com.google.protobuf.JavaType \
  8630. com.google.protobuf.LazyField \
  8631. com.google.protobuf.LazyField$1 \
  8632. com.google.protobuf.LazyField$LazyEntry \
  8633. com.google.protobuf.LazyField$LazyIterator \
  8634. com.google.protobuf.LazyFieldLite \
  8635. com.google.protobuf.LazyStringArrayList \
  8636. com.google.protobuf.LazyStringArrayList$ByteArrayListView \
  8637. com.google.protobuf.LazyStringArrayList$ByteStringListView \
  8638. com.google.protobuf.LazyStringList \
  8639. com.google.protobuf.ListFieldSchema \
  8640. com.google.protobuf.ListFieldSchema$1 \
  8641. com.google.protobuf.ListFieldSchema$ListFieldSchemaFull \
  8642. com.google.protobuf.ListFieldSchema$ListFieldSchemaLite \
  8643. com.google.protobuf.ListValue \
  8644. com.google.protobuf.ListValue$1 \
  8645. com.google.protobuf.ListValue$Builder \
  8646. com.google.protobuf.ListValueOrBuilder \
  8647. com.google.protobuf.LongArrayList \
  8648. com.google.protobuf.ManifestSchemaFactory \
  8649. com.google.protobuf.ManifestSchemaFactory$1 \
  8650. com.google.protobuf.ManifestSchemaFactory$CompositeMessageInfoFactory \
  8651. com.google.protobuf.MapEntryLite \
  8652. com.google.protobuf.MapEntryLite$1 \
  8653. com.google.protobuf.MapEntryLite$Metadata \
  8654. com.google.protobuf.MapFieldLite \
  8655. com.google.protobuf.MapFieldSchema \
  8656. com.google.protobuf.MapFieldSchemaLite \
  8657. com.google.protobuf.MapFieldSchemas \
  8658. com.google.protobuf.MessageInfo \
  8659. com.google.protobuf.MessageInfoFactory \
  8660. com.google.protobuf.MessageLite \
  8661. com.google.protobuf.MessageLite$Builder \
  8662. com.google.protobuf.MessageLiteOrBuilder \
  8663. com.google.protobuf.MessageLiteToString \
  8664. com.google.protobuf.MessageSchema \
  8665. com.google.protobuf.MessageSchema$1 \
  8666. com.google.protobuf.MessageSetSchema \
  8667. com.google.protobuf.Method \
  8668. com.google.protobuf.Method$1 \
  8669. com.google.protobuf.Method$Builder \
  8670. com.google.protobuf.MethodOrBuilder \
  8671. com.google.protobuf.Mixin \
  8672. com.google.protobuf.Mixin$1 \
  8673. com.google.protobuf.Mixin$Builder \
  8674. com.google.protobuf.MixinOrBuilder \
  8675. com.google.protobuf.MutabilityOracle \
  8676. com.google.protobuf.MutabilityOracle$1 \
  8677. com.google.protobuf.NewInstanceSchema \
  8678. com.google.protobuf.NewInstanceSchemaLite \
  8679. com.google.protobuf.NewInstanceSchemas \
  8680. com.google.protobuf.NioByteString \
  8681. com.google.protobuf.NioByteString$1 \
  8682. com.google.protobuf.NullValue \
  8683. com.google.protobuf.NullValue$1 \
  8684. com.google.protobuf.OneofInfo \
  8685. com.google.protobuf.Option \
  8686. com.google.protobuf.Option$1 \
  8687. com.google.protobuf.Option$Builder \
  8688. com.google.protobuf.OptionOrBuilder \
  8689. com.google.protobuf.Parser \
  8690. com.google.protobuf.PrimitiveNonBoxingCollection \
  8691. com.google.protobuf.Protobuf \
  8692. com.google.protobuf.ProtobufArrayList \
  8693. com.google.protobuf.ProtobufLists \
  8694. com.google.protobuf.ProtocolStringList \
  8695. com.google.protobuf.ProtoSyntax \
  8696. com.google.protobuf.RawMessageInfo \
  8697. com.google.protobuf.Reader \
  8698. com.google.protobuf.RopeByteString \
  8699. com.google.protobuf.RopeByteString$1 \
  8700. com.google.protobuf.RopeByteString$Balancer \
  8701. com.google.protobuf.RopeByteString$PieceIterator \
  8702. com.google.protobuf.RopeByteString$RopeInputStream \
  8703. com.google.protobuf.Schema \
  8704. com.google.protobuf.SchemaFactory \
  8705. com.google.protobuf.SchemaUtil \
  8706. com.google.protobuf.SmallSortedMap \
  8707. com.google.protobuf.SmallSortedMap$1 \
  8708. com.google.protobuf.SmallSortedMap$DescendingEntryIterator \
  8709. com.google.protobuf.SmallSortedMap$DescendingEntrySet \
  8710. com.google.protobuf.SmallSortedMap$EmptySet \
  8711. com.google.protobuf.SmallSortedMap$EmptySet$1 \
  8712. com.google.protobuf.SmallSortedMap$EmptySet$2 \
  8713. com.google.protobuf.SmallSortedMap$Entry \
  8714. com.google.protobuf.SmallSortedMap$EntryIterator \
  8715. com.google.protobuf.SmallSortedMap$EntrySet \
  8716. com.google.protobuf.SourceContext \
  8717. com.google.protobuf.SourceContext$1 \
  8718. com.google.protobuf.SourceContext$Builder \
  8719. com.google.protobuf.SourceContextOrBuilder \
  8720. com.google.protobuf.SourceContextProto \
  8721. com.google.protobuf.StringValue \
  8722. com.google.protobuf.StringValue$1 \
  8723. com.google.protobuf.StringValue$Builder \
  8724. com.google.protobuf.StringValueOrBuilder \
  8725. com.google.protobuf.Struct \
  8726. com.google.protobuf.Struct$1 \
  8727. com.google.protobuf.Struct$Builder \
  8728. com.google.protobuf.Struct$FieldsDefaultEntryHolder \
  8729. com.google.protobuf.StructOrBuilder \
  8730. com.google.protobuf.StructProto \
  8731. com.google.protobuf.StructuralMessageInfo \
  8732. com.google.protobuf.StructuralMessageInfo$Builder \
  8733. com.google.protobuf.Syntax \
  8734. com.google.protobuf.Syntax$1 \
  8735. com.google.protobuf.TextFormatEscaper \
  8736. com.google.protobuf.TextFormatEscaper$1 \
  8737. com.google.protobuf.TextFormatEscaper$2 \
  8738. com.google.protobuf.TextFormatEscaper$ByteSequence \
  8739. com.google.protobuf.Timestamp \
  8740. com.google.protobuf.Timestamp$1 \
  8741. com.google.protobuf.Timestamp$Builder \
  8742. com.google.protobuf.TimestampOrBuilder \
  8743. com.google.protobuf.TimestampProto \
  8744. com.google.protobuf.Type \
  8745. com.google.protobuf.Type$1 \
  8746. com.google.protobuf.Type$Builder \
  8747. com.google.protobuf.TypeOrBuilder \
  8748. com.google.protobuf.TypeProto \
  8749. com.google.protobuf.UInt32Value \
  8750. com.google.protobuf.UInt32Value$1 \
  8751. com.google.protobuf.UInt32Value$Builder \
  8752. com.google.protobuf.UInt32ValueOrBuilder \
  8753. com.google.protobuf.UInt64Value \
  8754. com.google.protobuf.UInt64Value$1 \
  8755. com.google.protobuf.UInt64Value$Builder \
  8756. com.google.protobuf.UInt64ValueOrBuilder \
  8757. com.google.protobuf.UninitializedMessageException \
  8758. com.google.protobuf.UnknownFieldSchema \
  8759. com.google.protobuf.UnknownFieldSetLite \
  8760. com.google.protobuf.UnknownFieldSetLiteSchema \
  8761. com.google.protobuf.UnmodifiableLazyStringList \
  8762. com.google.protobuf.UnmodifiableLazyStringList$1 \
  8763. com.google.protobuf.UnmodifiableLazyStringList$2 \
  8764. com.google.protobuf.UnsafeByteOperations \
  8765. com.google.protobuf.UnsafeUtil \
  8766. com.google.protobuf.UnsafeUtil$1 \
  8767. com.google.protobuf.UnsafeUtil$Android32MemoryAccessor \
  8768. com.google.protobuf.UnsafeUtil$Android64MemoryAccessor \
  8769. com.google.protobuf.UnsafeUtil$JvmMemoryAccessor \
  8770. com.google.protobuf.UnsafeUtil$MemoryAccessor \
  8771. com.google.protobuf.Utf8 \
  8772. com.google.protobuf.Utf8$DecodeUtil \
  8773. com.google.protobuf.Utf8$Processor \
  8774. com.google.protobuf.Utf8$SafeProcessor \
  8775. com.google.protobuf.Utf8$UnpairedSurrogateException \
  8776. com.google.protobuf.Utf8$UnsafeProcessor \
  8777. com.google.protobuf.Value \
  8778. com.google.protobuf.Value$1 \
  8779. com.google.protobuf.Value$Builder \
  8780. com.google.protobuf.Value$KindCase \
  8781. com.google.protobuf.ValueOrBuilder \
  8782. com.google.protobuf.WireFormat \
  8783. com.google.protobuf.WireFormat$1 \
  8784. com.google.protobuf.WireFormat$FieldType \
  8785. com.google.protobuf.WireFormat$FieldType$1 \
  8786. com.google.protobuf.WireFormat$FieldType$2 \
  8787. com.google.protobuf.WireFormat$FieldType$3 \
  8788. com.google.protobuf.WireFormat$FieldType$4 \
  8789. com.google.protobuf.WireFormat$JavaType \
  8790. com.google.protobuf.WireFormat$Utf8Validation \
  8791. com.google.protobuf.WireFormat$Utf8Validation$1 \
  8792. com.google.protobuf.WireFormat$Utf8Validation$2 \
  8793. com.google.protobuf.WireFormat$Utf8Validation$3 \
  8794. com.google.protobuf.WrappersProto \
  8795. com.google.protobuf.Writer \
  8796. com.google.protobuf.Writer$FieldOrder
  8797. # tag:java-specific
  8798. JAVA_IGNORE_CLASSPATH_CLASH_VALUE=$JAVA_IGNORE_CLASSPATH_CLASH_DEFAULE_VALUE
  8799. ### @usage: JAVA_IGNORE_CLASSPATH_CLASH_FOR([classes])
  8800. ### Ignore classpath clash test fails for classes
  8801. macro JAVA_IGNORE_CLASSPATH_CLASH_FOR(Args...) {
  8802. SET_APPEND(JAVA_IGNORE_CLASSPATH_CLASH_VALUE $Args $JAVA_IGNORE_CLASSPATH_CLASH_DEFAULE_VALUE)
  8803. }
  8804. # tag:python-specific
  8805. ### @usage: PY_SRCS({| CYTHON_C} { | TOP_LEVEL | NAMESPACE ns} Files...)
  8806. ###
  8807. ### Build specified Python sources according to Arcadia binary Python build. Basically creates precompiled and source resources keyed with module paths.
  8808. ### The resources eventually are linked into final program and can be accessed as regular Python modules.
  8809. ### This custom loader linked into the program will add them to sys.meta_path.
  8810. ###
  8811. ### 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.
  8812. ### .pyx and .swg lead to C/C++ Python extensions generation, that are automatically registered in Python as built-in modules.
  8813. ###
  8814. ### 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).
  8815. ###
  8816. ### __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.
  8817. ###
  8818. ### @example
  8819. ###
  8820. ### PY2_LIBRARY(mymodule)
  8821. ### 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)
  8822. ### END()
  8823. ###
  8824. ### PY_SRCS honors Python2 and Python3 differences and adjusts itself to Python version of a current module.
  8825. ### PY_SRCS can be used in any Arcadia Python build modules like PY*_LIBRARY, PY*_PROGRAM, PY*TEST.
  8826. ### PY_SRCS in LIBRARY or PROGRAM effectively converts these into PY2_LIBRARY and PY2_PROGRAM respectively.
  8827. ### 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.
  8828. ###
  8829. ### Documentation: https://wiki.yandex-team.ru/arcadia/python/pysrcs/#modulipylibrarypy3libraryimakrospysrcs
  8830. macro PY_SRCS() {
  8831. DEFAULT(MODULE_TAG PY2)
  8832. DEFAULT(PYTHON2 yes)
  8833. DEFAULT(PYTHON3 no)
  8834. }
  8835. # tag:python-specific
  8836. _ALL_PY_FILES=
  8837. # tag:python-specific
  8838. macro _ALL_PY_SRCS2(TOP_LEVEL?"TOP_LEVEL":"", RECURSIVE?"/**":"", ONLY_TEST_FILES?"test_*.py":"*.py", ONLY_TEST_FILES2?"*_test.py":"***", NO_TEST_FILES?"**/test_*.py **/*_test.py":"", NAMESPACE[], REST[], REST2[], EAT_TAIL[]) {
  8839. _GLOB(_ALL_PY_FILES ${suf=${RECURSIVE}/${ONLY_TEST_FILES}:REST} ${suf=${RECURSIVE}/${ONLY_TEST_FILES2}:REST2} ${suf=${RECURSIVE}/ya.make:REST} EXCLUDE ya.make ${NO_TEST_FILES})
  8840. }
  8841. # tag:python-specific
  8842. ### @usage: ALL_PY_SRCS([RECURSIVE] [NO_TEST_FILES] { | TOP_LEVEL | NAMESPACE ns} [Dirs...])
  8843. ###
  8844. ### Puts all .py-files from given Dirs (relative to projects') into PY_SRCS of the current module.
  8845. ### If Dirs is ommitted project directory is used
  8846. ###
  8847. ### `RECURSIVE` makes lookup recursive with resprect to Dirs
  8848. ### `NO_TEST_FILES` excludes files `test_*.py` and `*_test.py` those are normally subject to `TEST_SRCS`
  8849. ### `TOP_LEVEL` and `NAMESPACE` are forwarded to `PY_SRCS`
  8850. ###
  8851. ### Note: Only one such macro per module is allowed
  8852. ### Note: Macro is designed to reject any ya.make files in Dirs except current one
  8853. ###
  8854. ### @see [PY_SRCS()](#macro_PY_SRCS)
  8855. macro ALL_PY_SRCS(TOP_LEVEL?"TOP_LEVEL":"", NAMESPACE="", RECURSIVE?"RECURSIVE":"", NO_TEST_FILES?"NO_TEST_FILES":"", Files...) {
  8856. _ALL_PY_SRCS2(${pre=NAMESPACE :NAMESPACE} ${TOP_LEVEL} ${RECURSIVE} ${NO_TEST_FILES} REST .${pre=/:Files})
  8857. PY_SRCS(_MR ${pre=NAMESPACE :NAMESPACE} ${TOP_LEVEL} $_ALL_PY_FILES)
  8858. }
  8859. # tag:python-specific
  8860. ### @usage: ALL_PYTEST_SRCS([RECURSIVE] [Dirs...])
  8861. ###
  8862. ### Puts all .py-files from given Dirs (relative to projects') into TEST_SRCS of the current module.
  8863. ### If Dirs is omitted project directory is used
  8864. ###
  8865. ### `RECURSIVE` makes lookup recursive with respect to Dirs
  8866. ### `ONLY_TEST_FILES` includes only files `test_*.py` and `*_test.py`, others are normally subject to `PY_SRCS`
  8867. ###
  8868. ### Note: Only one such macro per module is allowed
  8869. ### Note: Macro is designed to reject any ya.make files in Dirs except current one
  8870. ###
  8871. ### @see [TEST_SRCS()](#macro_TEST_SRCS)
  8872. macro ALL_PYTEST_SRCS(TOP_LEVEL?"TOP_LEVEL":"", NAMESPACE="", RECURSIVE?"RECURSIVE":"", ONLY_TEST_FILES?"ONLY_TEST_FILES ONLY_TEST_FILES2 REST2":"EAT_TAIL", Files...) {
  8873. _ALL_PY_SRCS2(${pre=NAMESPACE :NAMESPACE} ${TOP_LEVEL} ${RECURSIVE} REST .${pre=/:Files} ${ONLY_TEST_FILES} .${pre=/:Files})
  8874. TEST_SRCS(_MR $_ALL_PY_FILES)
  8875. }
  8876. # tag:python-specific
  8877. _PY_EXTRA_LINT_FILES_VALUE=
  8878. ### @usage: PY_EXTRA_LINT_FILES(files...)
  8879. ###
  8880. ### Add extra Python files for linting. This macro allows adding
  8881. ### Python files which has no .py extension.
  8882. macro PY_EXTRA_LINT_FILES(FILES...) {
  8883. SET_APPEND(_PY_EXTRA_LINT_FILES_VALUE $FILES)
  8884. }
  8885. # tag:python-specific
  8886. ### @usage: PY23_LIBRARY([name])
  8887. ###
  8888. ### Build PY2_LIBRARY or PY3_LIBRARY depending on incoming PEERDIR.
  8889. ### Direct build or build by RECURSE creates both variants.
  8890. ### This multimodule doesn't define any final targets, so use from DEPENDS or BUNDLE is not allowed.
  8891. ###
  8892. ### Documentation: https://wiki.yandex-team.ru/arcadia/python/pysrcs
  8893. multimodule PY23_LIBRARY {
  8894. module PY2: PY2_LIBRARY {
  8895. .RESTRICTED=RUN_ANTLR4_PYTHON
  8896. OBJ_SUF=.py2
  8897. }
  8898. module PY3: PY3_LIBRARY {
  8899. .RESTRICTED=RUN_ANTLR4_PYTHON
  8900. RUN_CYTHON_SCRIPT_H=$YMAKE_PYTHON $CYTHON_SCRIPT
  8901. when ($MSVC == "yes" || $CYGWIN == "yes") {
  8902. MODULE_PREFIX=py3
  8903. }
  8904. otherwise {
  8905. MODULE_PREFIX=libpy3
  8906. }
  8907. OBJ_SUF=.py3
  8908. }
  8909. }
  8910. # tag:python-specific
  8911. ### @usage: PY23_NATIVE_LIBRARY([name])
  8912. ###
  8913. ### Build LIBRARY compatible with either Python 2.x or Python 3.x depending on incoming PEERDIR.
  8914. ###
  8915. ### 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.
  8916. ### Use these multimodule instead of PY23_LIBRARY if the C++ extension defined in it will be used in PY2MODULE.
  8917. ### 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.
  8918. ### Proper version will be selected according to Python version of the module PEERDIR comes from.
  8919. ###
  8920. ### This mulrtimodule doesn't define any final targets so cannot be used from DEPENDS or BUNDLE macros.
  8921. ###
  8922. ### For more information read https://wiki.yandex-team.ru/arcadia/python/pysrcs/#pysrcssrcsipy23nativelibrary
  8923. ###
  8924. ### @see [LIBRARY()](#module_LIBRARY), [PY2MODULE()](#module_PY2MODULE)
  8925. multimodule PY23_NATIVE_LIBRARY {
  8926. module PY2: LIBRARY {
  8927. .RESTRICTED=PY_SRCS USE_PYTHON2 USE_PYTHON3 PYTHON3_ADDINCL RUN_ANTLR4_PYTHON
  8928. OBJ_SUF=.py2
  8929. PYTHON2_ADDINCL()
  8930. SET(MODULE_LANG PY2)
  8931. }
  8932. module PY3: LIBRARY {
  8933. .RESTRICTED=PY_SRCS USE_PYTHON2 USE_PYTHON3 RUN_ANTLR4_PYTHON
  8934. .ALIASES=PYTHON2_ADDINCL=PYTHON3_ADDINCL
  8935. .SEM=CPP_LIBRARY_SEM
  8936. .GLOBAL_SEM=CPP_OBJ_LIBRARY_SEM
  8937. PYTHON3_ADDINCL()
  8938. SET(MODULE_LANG PY3)
  8939. when ($MSVC == "yes" || $CYGWIN == "yes") {
  8940. MODULE_PREFIX=py3c
  8941. }
  8942. otherwise {
  8943. MODULE_PREFIX=libpy3c
  8944. }
  8945. OBJ_SUF=.py3
  8946. }
  8947. }
  8948. IBTOOL_PATH=$XCODE_TOOLS_ROOT_RESOURCE_GLOBAL/Xcode/Contents/Developer/usr/bin/ibtool
  8949. # tag:src-processing
  8950. STORYBOARD_FLAGS=--errors --warnings --notices --auto-activate-custom-fonts --output-format human-readable-text
  8951. macro _SRC("storyboard", SRC, SRCFLAGS...) {
  8952. .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}
  8953. }
  8954. # tag:src-processing
  8955. macro _SRC("xib", SRC, SRCFLAGS...) {
  8956. .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}
  8957. }
  8958. ACTOOL_PATH=$XCODE_TOOLS_ROOT_RESOURCE_GLOBAL/Xcode/Contents/Developer/usr/bin/ibtool
  8959. # tag:ios-specific
  8960. ASSETS_FLAGS=--output-format human-readable-text --notices --warnings
  8961. macro _IOS_ASSETS(AssetsDir, Content...) {
  8962. .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
  8963. }
  8964. # tag:ios-specific
  8965. macro IOS_APP_COMMON_FLAGS(Flags...) {
  8966. SET_APPEND(STORYBOARD_FLAGS $Flags)
  8967. SET_APPEND(ASSETS_FLAGS $Flags)
  8968. }
  8969. # tag:ios-specific
  8970. macro IOS_APP_ASSETS_FLAGS(Flags...) {
  8971. SET_APPEND(ASSETS_FLAGS $Flags)
  8972. }
  8973. macro DARWIN_STRINGS_RESOURCE(Resource, Relpath) {
  8974. .CMD=$COPY_CMD ${input:Resource} $BINDIR/$Relpath && $YMAKE_PYTHON ${input:"build/scripts/tar_directory.py"} ${output;tobindir;suf=.strings_tar:Relpath} $BINDIR/$Relpath $BINDIR
  8975. }
  8976. macro DARWIN_SIGNED_RESOURCE(Resource, Relpath) {
  8977. .CMD=$COPY_CMD $Resource $BINDIR/$Relpath && $YMAKE_PYTHON ${input:"build/scripts/tar_directory.py"} ${output;tobindir;suf=.signed_resource_tar:Relpath} $BINDIR/$Relpath $BINDIR
  8978. }
  8979. # tag:ios-specific
  8980. DELIM=__DELIM__
  8981. 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
  8982. ### @usage: IOS_INTERFACE()
  8983. ### iOS GUI module definition
  8984. module IOS_INTERFACE: _BARE_UNIT {
  8985. .CMD=PACK_IOS_ARCHIVE
  8986. .EXTS=.compiled_storyboard_tar .partial_plist .plist .xcent .nib .resource_tar .signed_resource_tar .strings_tar .plist_json
  8987. .NODE_TYPE=Library
  8988. .FINAL_TARGET=no
  8989. SET(MODULE_SUFFIX .ios.interface)
  8990. PEERDIR+=build/platform/xcode/tools
  8991. }
  8992. # tag:ios-specific
  8993. module DEFAULT_IOS_INTERFACE: IOS_INTERFACE {
  8994. SET(MODULE_SUFFIX .default.ios.interface)
  8995. }
  8996. DEFAULT_IOS_TYPE=
  8997. IOS_TYPE=
  8998. when(!$IOS_TYPE) {
  8999. when($DEFAULT_IOS_TYPE) {
  9000. IOS_TYPE=$DEFAULT_IOS_TYPE
  9001. }
  9002. otherwise {
  9003. IOS_TYPE=com.apple.CoreSimulator.SimDeviceType.iPhone-X
  9004. }
  9005. }
  9006. DEFAULT_IOS_RUNTIME=
  9007. IOS_RUNTIME=
  9008. when(!$IOS_RUNTIME) {
  9009. when($DEFAULT_IOS_RUNTIME) {
  9010. IOS_RUNTIME=$DEFAULT_IOS_RUNTIME
  9011. }
  9012. otherwise {
  9013. IOS_RUNTIME=com.apple.CoreSimulator.SimRuntime.iOS-12-1
  9014. }
  9015. }
  9016. when ($ARCH_I386) {
  9017. TEST_IOS_DEVICE_TYPE_VALUE=com.apple.CoreSimulator.SimDeviceType.iPhone-5
  9018. TEST_IOS_RUNTIME_TYPE_VALUE=com.apple.CoreSimulator.SimRuntime.iOS-10-3
  9019. }
  9020. otherwise {
  9021. TEST_IOS_DEVICE_TYPE_VALUE=$IOS_TYPE
  9022. TEST_IOS_RUNTIME_TYPE_VALUE=$IOS_RUNTIME
  9023. }
  9024. # tag:java-specific
  9025. ### @usage: JDK_VERSION(Version)
  9026. ###
  9027. ### Specify JDK version for module
  9028. macro JDK_VERSION(Arg) {
  9029. .SEM=required_jdk $Arg ${output;hide:"JdkVersionFakeProp.java"}
  9030. SET(JDK_REAL_VERSION $Arg)
  9031. _JDK_VERSION_MACRO_CHECK($Arg)
  9032. }
  9033. # tag:java-specific
  9034. when ($JDK_REAL_VERSION == "10") {
  9035. JDK10=yes # remove this later
  9036. }
  9037. JAVA_PROGRAM_CP_USE_COMMAND_FILE=yes
  9038. when ($JDK_REAL_VERSION == "8") {
  9039. JAVA_PROGRAM_CP_USE_COMMAND_FILE=no
  9040. }
  9041. # tag:kotlin-specific
  9042. KOTLIN_JVM_TARGET=
  9043. when ($JDK_REAL_VERSION == "8") {
  9044. KOTLIN_JVM_TARGET=1.8
  9045. }
  9046. elsewhen ($JDK_REAL_VERSION == "20") {
  9047. # remove when kotlin starts supporting jdk20 bytecode
  9048. # see also devtools/ya/jbuild/gen/actions/idea.py
  9049. KOTLIN_JVM_TARGET=19
  9050. }
  9051. otherwise {
  9052. KOTLIN_JVM_TARGET=$JDK_REAL_VERSION
  9053. }
  9054. # tag:frontend-specific
  9055. ### @usage: COLLECT_FRONTEND_FILES(Varname, Dir)
  9056. ###
  9057. ### Recursively collect files with typical frontend extensions from Dir and save the result into variable Varname
  9058. macro COLLECT_FRONTEND_FILES(Varname, Dir) {
  9059. _GLOB($Varname $Dir/**/*.(css|ejs|jpg|js|jsx|png|styl|svg|ts|tsx|json|html))
  9060. }
  9061. # tag:java-specific
  9062. # local jdk and tools
  9063. USE_SYSTEM_JDK=
  9064. USE_SYSTEM_UBERJAR=
  9065. USE_SYSTEM_ERROR_PRONE=
  9066. # tag:swift-specific
  9067. CPP_XCODE_TOOLCHAIN_VERSION=9.2
  9068. SWIFT_XCODE_TOOLCHAIN_VERSION=9.2
  9069. XCODE_TOOLS_VERSION=10.1
  9070. macro COMPILE_SWIFT_MODULE(SRCS{input}[], BRIDGE_HEADER{input}="", Flags...) {
  9071. when ($BRIDGE_HEADER != "") {
  9072. SWIFT_BRIDGE_HEADER=-import-objc-header ${input:BRIDGE_HEADER}
  9073. }
  9074. otherwise {
  9075. SWIFT_BRIDGE_HEADER=
  9076. }
  9077. .PEERDIR+=build/platform/xcode/swift
  9078. # swift core libraries
  9079. LDFLAGS($SWIFT_LD_FLAGS)
  9080. .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}
  9081. }
  9082. TEST_TOOL_HOST_LOCAL=
  9083. TEST_TOOL_TARGET_LOCAL=
  9084. when ($MOST_USED_CUDA) {
  9085. CUDA_VERSION=11.4
  9086. CUDNN_VERSION=8.0.5
  9087. TENSORRT_VERSION=7
  9088. }
  9089. when ($TENSORFLOW_WITH_CUDA) {
  9090. CUDA_REQUIRED=yes
  9091. }
  9092. when (!$TENSORRT_VERSION) {
  9093. TENSORRT_VERSION=5
  9094. }
  9095. ANDROID_APK_TEST_ACTIVITY_VALUE=com.yandex.test.unittests/.RunTestsActivity
  9096. MAVEN_BIN=$MAVEN_RESOURCE_GLOBAL/bin/mvn
  9097. when ($QT_REQUIRED) {
  9098. QT_BIN=${HOST_QT_RESOURCE_GLOBAL}/bin
  9099. }
  9100. when ($OPENGL_REQUIRED) {
  9101. OPENGL_VERSION=18.0.5
  9102. }
  9103. # tag:python-specific
  9104. multimodule PY23_TEST {
  9105. module PY2 : PYTEST_BIN {
  9106. .RESTRICTED=RUN_ANTLR4_PYTHON
  9107. MODULE_PREFIX=py2_
  9108. OBJ_SUF=.py2
  9109. CANONIZE_SUB_PATH=py2test
  9110. RUN_CYTHON_SCRIPT_H=$YMAKE_PYTHON $CYTHON_SCRIPT
  9111. }
  9112. module PY3TEST_PROGRAM: PY3TEST_BIN {
  9113. .FINAL_TARGET=yes
  9114. .RESTRICTED=RUN_ANTLR4_PYTHON
  9115. OBJ_SUF=.py3
  9116. CANONIZE_SUB_PATH=py3test
  9117. RUN_CYTHON_SCRIPT_H=$YMAKE_PYTHON $CYTHON_SCRIPT
  9118. }
  9119. module PY3TEST_LIBRARY: PY3_LIBRARY {
  9120. .RESTRICTED=RUN_ANTLR4_PYTHON
  9121. PEERDIR+=library/python/pytest
  9122. _REQUIRE_EXPLICIT_LICENSE()
  9123. RUN_CYTHON_SCRIPT_H=$YMAKE_PYTHON $CYTHON_SCRIPT
  9124. }
  9125. }
  9126. # tag:windows-specific
  9127. WINDOWS_MANIFEST=
  9128. macro WINDOWS_MANIFEST(Manifest) {
  9129. SET(WINDOWS_MANIFEST $Manifest)
  9130. }
  9131. # https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation#enable-long-paths-in-windows-10-version-1607-and-later
  9132. macro WINDOWS_LONG_PATH_MANIFEST() {
  9133. SET(WINDOWS_MANIFEST build/long-path.manifest)
  9134. }
  9135. # tag:windows-specific
  9136. when ($MSVC == "yes" && $WINDOWS_MANIFEST) {
  9137. LDFLAGS+=/MANIFEST:EMBED /MANIFESTINPUT:${input:WINDOWS_MANIFEST}
  9138. }
  9139. # tag:cpp-specific
  9140. _VISIBILITY_LEVEL=
  9141. ### @usage: VISIBILITY(level)
  9142. ###
  9143. ### This macro sets visibility level for symbols compiled for the current module. 'level'
  9144. ### may take only one of the following values: DEFAULT, HIDDEN.
  9145. macro VISIBILITY(LEVEL) {
  9146. SET(_VISIBILITY_LEVEL ${LEVEL})
  9147. select ($LEVEL) {
  9148. "DEFAULT" | "HIDDEN" ? {
  9149. }
  9150. default ? {
  9151. _OK = no
  9152. }
  9153. }
  9154. ASSERT(_OK Unsupported value [$LEVEL] passed to VISIBILITY macro, expected values are DEFAULT, HIDDEN.)
  9155. }
  9156. # tag:cpp-specific
  9157. _CFLAGS_VISIBILITY=
  9158. when ($_VISIBILITY_LEVEL != "" && $IGNORE_VISIBILITY != "yes") {
  9159. when ($CLANG == "yes" || $GCC == "yes") {
  9160. _CFLAGS_VISIBILITY=-fvisibility=${tolower:_VISIBILITY_LEVEL}
  9161. }
  9162. }
  9163. CFLAGS+=$_CFLAGS_VISIBILITY
  9164. # tag:cpp-specific
  9165. macro SDBUS_CPP_ADAPTOR(File) {
  9166. .CMD=${tool:"contrib/libs/sdbus-cpp/tools/xml2cpp-codegen"} --adaptor=${output;nopath;noext:File.adaptor.h} ${input:File}
  9167. .PEERDIR=contrib/libs/sdbus-cpp
  9168. }
  9169. # tag:cpp-specific
  9170. macro SDBUS_CPP_PROXY(File) {
  9171. .CMD=${tool:"contrib/libs/sdbus-cpp/tools/xml2cpp-codegen"} --proxy=${output;nopath;noext:File.proxy.h} ${input:File}
  9172. .PEERDIR=contrib/libs/sdbus-cpp
  9173. }
  9174. # tag:python-specific
  9175. macro _PY_ENUM_SERIALIZATION_TO_JSON(File) {
  9176. .CMD=$ENUM_PARSER_TOOL ${input:File} --output ${output;noext;suf=.generated.h:File} --json-output ${output;noext:File.json} ${kv;hide:"p EN"} ${kv;hide:"pc yellow"}
  9177. }
  9178. # tag:python-specific
  9179. macro _PY_ENUM_SERIALIZATION_TO_PY(File) {
  9180. .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"}
  9181. }
  9182. macro NGINX_MODULES(Modules...) {
  9183. PEERDIR(${Modules})
  9184. 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)
  9185. }
  9186. # tag:external-build
  9187. CONTAINER_LAYER_CMD=$YMAKE_PYTHON ${input:"build/scripts/make_container_layer.py"} -s $SQUASHFS_RESOURCE_GLOBAL -o $TARGET $AUTO_INPUT ${cwd:ARCADIA_BUILD_ROOT} ${kv;hide:"p CL"} ${kv;hide:"pc blue"}
  9188. CONTAINER_CMD=$YMAKE_PYTHON ${input:"build/scripts/make_container.py"} -s $SQUASHFS_RESOURCE_GLOBAL -o $TARGET ${rootrel:PEERS} ${cwd:ARCADIA_BUILD_ROOT} ${kv;hide:"p CN"} ${kv;hide:"pc blue"}
  9189. # tag:external-build
  9190. module CONTAINER_LAYER: _BARE_UNIT {
  9191. .CMD=CONTAINER_LAYER_CMD
  9192. PEERDIR(build/external_resources/squashfs_tools)
  9193. MODULE_SUFFIX=.container_layer
  9194. CHECK_ALLOWED_PATH()
  9195. CHECK_DEPENDENT_DIRS(ALLOW_ONLY PEERDIRS base_layers build/external_resources/squashfs_tools build/platform/python/ymake_python3 junk)
  9196. }
  9197. # tag:external-build
  9198. module CONTAINER: _BARE_UNIT {
  9199. .NODE_TYPE=Bundle
  9200. .PEERDIR_POLICY=as_build_from
  9201. .FINAL_TARGET=yes
  9202. .CMD=CONTAINER_CMD
  9203. PEERDIR(build/external_resources/squashfs_tools)
  9204. PEERDIR(devtools/contrib/cake/entry)
  9205. }
  9206. # tag:external-build
  9207. CUSTOM_BUILD_LIBRARY_USE=
  9208. 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
  9209. # tag:external-build
  9210. module CUSTOM_BUILD_LIBRARY: LIBRARY {
  9211. .NODE_TYPE=Bundle
  9212. .PEERDIR_POLICY=as_build_from
  9213. .PROXY=yes
  9214. .CMD=CUSTOM_BUILD_LIBRARY_CMD
  9215. DISABLE(NEED_ADD_FAKE_SRC)
  9216. }
  9217. ### @usage: ORIGINAL_SOURCE(Source)
  9218. ###
  9219. ### This macro specifies the source repository for contrib
  9220. ### Does nothing now (just a placeholder for future functionality)
  9221. ### See https://st.yandex-team.ru/DTCC-316
  9222. macro ORIGINAL_SOURCE(Source) {
  9223. ENABLE(UNUSED_MACRO)
  9224. }
  9225. # tag:licence
  9226. CREDITS_FILE_EXTRA_EXT=
  9227. CREDITS_FLAGS=
  9228. CREDITS_TEXTS_FILE=
  9229. NO_CREDITS_TEXTS_FILE=
  9230. WITH_CREDITS=
  9231. ### @usage: LICENSE_TEXTS(File)
  9232. ###
  9233. ### This macro specifies the filename with all library licenses texts
  9234. macro LICENSE_TEXTS(Source) {
  9235. SET(CREDITS_TEXTS_FILE $Source)
  9236. }
  9237. # tag:licence
  9238. ### @usage: WITHOUT_LICENSE_TEXTS()
  9239. ###
  9240. ### This macro indicates that the module has no license text
  9241. macro WITHOUT_LICENSE_TEXTS() {
  9242. ENABLE(NO_CREDITS_TEXTS_FILE)
  9243. }
  9244. # tag:licence
  9245. when ($WITH_CREDITS) {
  9246. CREDITS_FLAGS+=--credits-output ${output;suf=${CREDITS_FILE_EXTRA_EXT}".CREDITS.txt":REALPRJNAME}
  9247. }
  9248. GENERATE_MF=
  9249. when ($WITH_CREDITS) {
  9250. GENERATE_MF=$GENERATE_MF_CMD
  9251. }
  9252. macro _MCU_CONVERT(Bin) {
  9253. .CMD=${cwd:BINDIR} $OBJCOPY_TOOL -O ihex $Bin ${output;noext:Bin.hex} && ${cwd:BINDIR} $OBJCOPY_TOOL -O srec $Bin ${output;noext:Bin.s37} && ${cwd:BINDIR} $OBJCOPY_TOOL -O binary $Bin ${output;noext:Bin.bin}
  9254. }
  9255. MCU_LINK_EXE=$LINK_EXE && $_MCU_CONVERT($MODULE_PREFIX$REALPRJNAME)
  9256. ### @usage: MCU_PROGRAM([progname])
  9257. ###
  9258. ### Program module for microcontrollers. Converts ELF to Intel HEX, Motorola S-record and raw binary file formats.
  9259. ### If name is not specified it will be generated from the name of the containing project directory.
  9260. module MCU_PROGRAM: PROGRAM {
  9261. .CMD=MCU_LINK_EXE
  9262. }
  9263. @import "${CONF_ROOT}/conf/project_specific/esp.conf"
  9264. # tag:flags tag:internal tag:windows-specific
  9265. ### @usage: _MSVC_FLAGS_WINDOWS_IMPL(target_platform compiler_flags) # internal
  9266. ###
  9267. ### Add CFLAGS when the firts argument is WINDOWS
  9268. macro _MSVC_FLAGS_WINDOWS_IMPL(WINDOWS[], FLAGS...) {
  9269. CFLAGS($WINDOWS)
  9270. }
  9271. # tag:flags tag:windows-specific tag:cpp-specific
  9272. ### @usage: MSVC_FLAGS([GLOBAL compiler_flag]* compiler_flags)
  9273. ###
  9274. ### Add the specified flags to the compilation line of C/C++files.
  9275. ### Flags apply only if the compiler used is MSVC (cl.exe)
  9276. macro MSVC_FLAGS(FLAGS...) {
  9277. _MSVC_FLAGS_WINDOWS_IMPL($TARGET_PLATFORM $FLAGS)
  9278. }
  9279. ### @usage: COLLECT_YDB_API_SPECS_LEGACY(VarName Paths...) #deprecated
  9280. ###
  9281. ### This macro is ugly hack for legacy YDB go API codegen, any other uses are prohibited
  9282. macro COLLECT_YDB_API_SPECS_LEGACY(FILES_VAR, PATHS...) {
  9283. _GLOB($FILES_VAR ${suf=/*.proto:PATHS})
  9284. RESTRICT_PATH(kikimr/public/sdk/go/ydb/api MSG This is ugly hack for legacy YDB go API codegen, any other uses are probibited)
  9285. }
  9286. # tag:proto tag:apphost
  9287. ### @usage: APPHOST()
  9288. ###
  9289. ### Emit APPHOST service code for all .proto files in a PROTO_LIBRARY.
  9290. ### This works only for C++ and Java at the moment.
  9291. macro APPHOST() {
  9292. # C++
  9293. CPP_PROTO_PLUGIN(cpp_plugin apphost/tools/stub_generator/cpp_plugin .apphost.h DEPS apphost/tools/stub_generator/cpp_includes)
  9294. # Java
  9295. JAVA_PROTO_PLUGIN(java_plugin apphost/tools/stub_generator/java_plugin DEPS apphost/api/service/java/apphost)
  9296. }
  9297. # tag:internal
  9298. ### Add passed ya.conf.json and all bottle's formula external files to resources
  9299. ### File MUST be arcadia root relative path (without "${ARCADIA_ROOT}/" prefix).
  9300. ### NOTE:
  9301. ### An external formula file referenced from ya.conf.json must be passed as an arcadia root relative path and
  9302. ### should be located in any subdirectory of the ya.conf.json location ("build/" if we consider a production).
  9303. ### The later restriction prevents problems in selectively checkouted arcadia.
  9304. macro YA_CONF_JSON(File) {
  9305. _YA_CONF_JSON($File)
  9306. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS ${ARCADIA_ROOT}/$File)
  9307. }
  9308. # tag:internal
  9309. # Don't use directly - wrap with custom macros
  9310. macro ADD_LINTER_CHECK(CheckName, Linter, DEPENDS[], EXCLUDE[], FILES[], CONFIGS[]) {
  9311. SET(_FILES_VAR uniq_${hash:VAR_SALT})
  9312. _GLOB($_FILES_VAR $FILES EXCLUDE $EXCLUDE)
  9313. _ADD_LINTER_CHECK($CheckName $Linter ${pre=DEPENDS :DEPENDS} FILES $$_FILES_VAR CONFIGS $CONFIGS)
  9314. }
  9315. # tag:internal
  9316. # Draft. Don't use.
  9317. macro _CPP_STYLE(EXCLUDE[], Files...) {
  9318. ADD_LINTER_CHECK(cpp_style tools/cpp_style_checker/cpp_style_checker DEPENDS contrib/libs/clang12/tools/clang-format EXCLUDE $EXCLUDE FILES $Files CONFIGS devtools/ya/handlers/style/style_config)
  9319. }
  9320. # tag:proto
  9321. macro ALICE_CAPABILITY() {
  9322. CPP_PROTO_PLUGIN(alice_capability_cpp yandex_io/tools/capability_gen .cap.h DEPS yandex_io/libs/protobuf_utils)
  9323. JAVA_PROTO_PLUGIN(alice_capability_java alice/library/go/java_marker_interface_protoc_plugin DEPS alice/protos/endpoint/java_interface alice/megamind/protos/scenarios/java_interface)
  9324. }