ymake.core.conf 251 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901
  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=628318530716
  10. SANDBOX_FAKEID=${FAKEID}.7600000
  11. CPP_FAKEID=2024-01-23
  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=108490091
  17. PROTO_FAKEID=0
  18. FBS_FAKEID=2024-03-13
  19. # Change of this value will invalidate some parts of configure cache
  20. # but will not affect builds anyhow (except tests referring build/ directory)
  21. JSON_CACHE_FAKE_ID=20240414
  22. STRUCT_CMD=yes
  23. CURDIR=.
  24. MODDIR=.
  25. BINDIR=bin:/
  26. SRCDIR=
  27. YMAKE=ymake
  28. ECHO=echo
  29. INCLUDE_EXTS=.h .hh .hpp .rli .cuh .inc .i .ipp .ixx .ya_exposed .hxx .H
  30. CPP_EXT=.cpp
  31. OBJ_SUF=
  32. CFLAGS=
  33. EXTRA_C_FLAGS=
  34. SFLAGS=
  35. SRCFLAGS=
  36. FORCE_COVERAGE_ENABLED=
  37. FORCE_COVERAGE_DISABLED=
  38. OBJADDE_LIB=
  39. OBJADDE_LIB_GLOBAL=
  40. TRUE=yes
  41. FALSE=no
  42. MODULE_PREFIX=
  43. MODULE_SUFFIX=
  44. # tag:src-processing tag:internal
  45. ### @usage: _SRC(Ext Src Flags) # internal
  46. ###
  47. ### Basic building block of extension-based command dispatching
  48. ### To enable specific extension processing define _SRC() macro with fixed first argument (Ext).
  49. ### Internal logic will apply this macro to all files with this Ext listed in SRC/SRCS macros or outputs
  50. ### of other commands (except ones marked as noauto)
  51. macro _SRC(EXT, SRC, SRCFLAGS...) {
  52. # Generic macro definition for _SRC (just a placeholder, it does nothing)
  53. }
  54. CLANG_VER=14
  55. when ($CLANG16 == "yes") {
  56. CLANG_VER=16
  57. }
  58. USE_ARCADIA_COMPILER_RUNTIME=yes
  59. when ($LOCAL && $XCODE) {
  60. USE_ARCADIA_COMPILER_RUNTIME=no
  61. }
  62. @import "${CONF_ROOT}/conf/settings.conf"
  63. @import "${CONF_ROOT}/conf/opensource.conf"
  64. @import "${CONF_ROOT}/conf/opensource_export.conf"
  65. @import "${CONF_ROOT}/conf/sysincl.conf"
  66. @import "${CONF_ROOT}/conf/license.conf"
  67. @import "${CONF_ROOT}/conf/docs.conf"
  68. @import "${CONF_ROOT}/conf/swig.conf"
  69. @import "${CONF_ROOT}/conf/proto.conf"
  70. @import "${CONF_ROOT}/conf/fbs.conf"
  71. @import "${CONF_ROOT}/conf/ts/ts.conf"
  72. @import "${CONF_ROOT}/conf/project_specific/other.conf"
  73. @import "${CONF_ROOT}/conf/project_specific/yt.conf"
  74. SO_OUTPUTS=no
  75. USE_GLOBAL_CMD=no
  76. when ($OS_WINDOWS != "yes") {
  77. USE_GLOBAL_CMD=yes
  78. }
  79. when ($USE_PYTHON) {
  80. C_DEFINES+= -DUSE_PYTHON
  81. }
  82. __COMMA__=${comma:""}
  83. __BSDQ__=\"
  84. when ($STRUCT_CMD == "yes") {
  85. __BSDQ__=\\\"
  86. }
  87. ARCADIA_TEST_ROOT=../arcadia_tests_data/
  88. DEFAULT_REQUIREMENTS=network:restricted cpu:1 ram:32
  89. FAIL_PY2=no
  90. _PREBUILT_TOOLS_ROOT=build/prebuilt
  91. _TOOL_PROTOC_GEN_GO=vendor/github.com/golang/protobuf/protoc-gen-go
  92. _TOOL_PROTOC_GEN_GO_V2=vendor/google.golang.org/protobuf/cmd/protoc-gen-go
  93. _TOOL_PROTOC_GEN_GO_GRPC_V2=vendor/google.golang.org/grpc/cmd/protoc-gen-go-grpc
  94. _TOOL_RESCOMPILER=tools/rescompiler
  95. _TOOL_RESCOMPRESSOR=tools/rescompressor
  96. _TOOL_RORESCOMPILER=tools/rorescompiler
  97. when ($DISABLE_SEPARATE_AUX_CPP != "yes") {
  98. SEPARATE_AUX_CPP=yes
  99. }
  100. _HOST_SUPPORTS_PREBUILT_PROTOC_GEN_GO=no
  101. _TARGET_SUPPORTS_PREBUILT_PROTOC_GEN_GO=no
  102. when ($USE_PREBUILT_TOOLS == "yes") {
  103. when ($HOST_ARCH_X86_64 == "yes" && ($HOST_OS_LINUX == "yes" || $HOST_OS_WINDOWS == "yes" || $HOST_OS_DARWIN == "yes")) {
  104. _HOST_SUPPORTS_PREBUILT_PROTOC_GEN_GO=yes
  105. }
  106. when ($HOST_ARCH_ARM64 == "yes" && $HOST_OS_DARWIN == "yes") {
  107. _HOST_SUPPORTS_PREBUILT_PROTOC_GEN_GO=yes
  108. }
  109. when ($ARCH_X86_64 == "yes" && ($OS_LINUX == "yes" || $OS_WINDOWS == "yes" || $OS_DARWIN == "yes")) {
  110. _TARGET_SUPPORTS_PREBUILT_PROTOC_GEN_GO=yes
  111. }
  112. when ($ARCH_ARM64 == "yes" && $OS_DARWIN == "yes") {
  113. _TARGET_SUPPORTS_PREBUILT_PROTOC_GEN_GO=yes
  114. }
  115. when ($_HOST_SUPPORTS_PREBUILT_PROTOC_GEN_GO == "yes" && $_TARGET_SUPPORTS_PREBUILT_PROTOC_GEN_GO == "yes") {
  116. _TOOL_PROTOC_GEN_GO=${_PREBUILT_TOOLS_ROOT}/vendor/github.com/golang/protobuf/protoc-gen-go
  117. }
  118. }
  119. ### @usage: FUNCTION_ORDERING_FILE(VAR_NAME)
  120. ###
  121. ### Select file for function reordering. Works only with lld linker.
  122. ### VAR_NAME should be the same value that was passed into DECLARE_EXTERNAL_HOST_RESOURCES_BUNDLE library.
  123. macro FUNCTION_ORDERING_FILE(ORDERING_FILE) {
  124. select ($_LINKER_ID) {
  125. "lld" ? {
  126. }
  127. default ? {
  128. _OK = no
  129. }
  130. }
  131. ASSERT(_OK FUNCTION_ORDERING_FILE macro can be used only with `lld` linker, but you chose `$_LINKER_ID`.)
  132. LDFLAGS("-Wl,--symbol-ordering-file=${suf=_RESOURCE_GLOBAL/funcs.ord;pre=$:ORDERING_FILE}")
  133. }
  134. ### @usage: SELECT_CLANG_SA_CONFIG(static_analyzer.yaml)
  135. ###
  136. ### Select config file for clang static analyzer.
  137. ### The file should be called static_analyzer.yaml.
  138. macro SELECT_CLANG_SA_CONFIG(config) {
  139. SET(_CLANG_SA_CONFIG ${input:config})
  140. }
  141. ### @usage: USE_SA_PLUGINS(FROM path/to/external/module1 NAME VAR_NAME1 FROM path/to/external/module2 NAME VAR_NAME2 ...)
  142. ###
  143. ### Select additional plugins for clang static analyzer, each path/to/external/module should declare target RESOURCES_LIBRARY.
  144. ### VAR_NAME should be the same value that was passed into DECLARE_EXTERNAL_HOST_RESOURCES_BUNDLE as first argument.
  145. ### See example in market/report/csa_checks/static_analyzer_ymake.inc
  146. macro USE_SA_PLUGINS(FROM[], NAME[]) {
  147. PEERDIR($FROM)
  148. SET_APPEND(CLANG_SA_PLUGINS ${suf=_RESOURCE_GLOBAL/plugin.so;pre=$:NAME})
  149. }
  150. # Helper macro for unwrapping sequence of files
  151. macro _CLANG_SA_UNWRAP_PLUGINS(Plugins{input}[]) {
  152. .CMD=${Plugins}
  153. }
  154. CLANG_SA_PLUGINS=
  155. CLANG_CSA_ROOT=${CLANG_CSA16_RESOURCE_GLOBAL}
  156. CLANG_CSA_BIN=${CLANG_CSA16_RESOURCE_GLOBAL}/bin/clang
  157. when ($CLANG_SA_ENABLE == "yes" && $_CLANG_SA_CONFIG && $CLANG_CSA_ROOT) {
  158. PEERDIR+=build/platform/clang/clang-static-analyzer
  159. CLANG_STATIC_ANALYZER_OPTIONS=$YMAKE_PYTHON3 ${input:"build/scripts/clang_static_analyzer.py"} \
  160. "--testing-src" ${input:SRC} \
  161. "--clang-bin" $CLANG_CSA_BIN \
  162. "--source-root" $(SOURCE_ROOT) \
  163. "--config-file" ${input:_CLANG_SA_CONFIG} \
  164. "--plugins-begin" "dummy_param" $_CLANG_SA_UNWRAP_PLUGINS($CLANG_SA_PLUGINS) "--plugins-end" \
  165. $GCC_COMPILE_FLAGS $CXXFLAGS $SRCFLAGS
  166. CLANG_STATIC_ANALYZER_OPTIONS_NEW=$YMAKE_PYTHON3 ${input:"build/scripts/clang_static_analyzer.py"} \
  167. "--testing-src" ${input:SRC} \
  168. "--clang-bin" $CLANG_CSA_BIN \
  169. "--source-root" $(SOURCE_ROOT) \
  170. "--config-file" ${input:_CLANG_SA_CONFIG} \
  171. "--plugins-begin" "dummy_param" $CLANG_SA_PLUGINS "--plugins-end" \
  172. $GCC_COMPILE_FLAGS $CXXFLAGS $SRCFLAGS
  173. CLANG_STATIC_ANALYZER_OPTIONS_NEW_FORCED=$_FORCE_CPP_FLAGS
  174. }
  175. otherwise {
  176. CLANG_STATIC_ANALYZER_OPTIONS=
  177. CLANG_STATIC_ANALYZER_OPTIONS_NEW=
  178. CLANG_STATIC_ANALYZER_OPTIONS_NEW_FORCED=
  179. }
  180. FAIL_MODULE_CMD=$YMAKE_PYTHON3 ${input:"build/scripts/fail_module_cmd.py"} $TARGET ${hide;kv:"p ER"} ${hide;kv:"pc red"}
  181. DEFAULT_TIDY_CONFIG=build/config/tests/clang_tidy/config.yaml
  182. PROJECT_TIDY_CONFIG=build/config/tests/clang_tidy/config.yaml
  183. TIDY=
  184. TIDY_ENABLED=
  185. when($TIDY == "yes") {
  186. TIDY_ENABLED=yes
  187. }
  188. CLANG_TIDY_BIN=${CLANG_TIDY_RESOURCE_GLOBAL}/bin/clang-tidy
  189. when ($TIDY_ENABLED == "yes") {
  190. when ($TIDY_EXPORT_FIXES=="") {
  191. TIDY_EXPORT_FIXES="no"
  192. }
  193. 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 "--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" ${noauto;output;suf=${COMPILE_OUT_SUFFIX}${OBJ_CROSS_SUF}.tidyjson:SRC} "--export-fixes" $TIDY_EXPORT_FIXES
  194. CLANG_TIDY_ARGS+="--default-config-file" ${input:DEFAULT_TIDY_CONFIG}
  195. CLANG_TIDY_ARGS+="--project-config-file" ${input:PROJECT_TIDY_CONFIG}
  196. when ($TIDY_CHECKS) {
  197. CLANG_TIDY_ARGS+="--checks=$TIDY_CHECKS"
  198. }
  199. when ($TIDY_HEADER_FILTER) {
  200. CLANG_TIDY_ARGS+="--header-filter=$TIDY_HEADER_FILTER"
  201. }
  202. TIDY_VALUE=USE_CONDITIONAL_SRCS
  203. }
  204. otherwise {
  205. CLANG_TIDY_ARGS=
  206. TIDY_VALUE=
  207. }
  208. # tag:profile
  209. NEED_PROFILE_RUNTIME=no
  210. when ($BUILD_TYPE == "PROFILE" || $BUILD_TYPE == "COVERAGE" || ($CLANG_COVERAGE && $CLANG_COVERAGE != "no") || $GCOV_COVERAGE == "yes" || $PGO_ADD == "yes") {
  211. when($CLANG && ($TARGET_PLATFORM == "LINUX" || $TARGET_PLATFORM == "DARWIN")) {
  212. NEED_PROFILE_RUNTIME=yes
  213. }
  214. }
  215. otherwise {
  216. NEED_PROFILE_RUNTIME=no
  217. }
  218. when ($NEED_PROFILE_RUNTIME == "yes") {
  219. COPY_PROFILE_RUNTIME=\
  220. $YMAKE_PYTHON3 ${input:"build/scripts/copy_clang_profile_rt.py"} \
  221. --arch $TARGET_PLATFORM \
  222. --build-root $ARCADIA_BUILD_ROOT --
  223. COPY_PROFILE_RUNTIME+=\
  224. ${rootrel:PEERS} \
  225. $LDFLAGS
  226. }
  227. otherwise {
  228. COPY_PROFILE_RUNTIME=
  229. }
  230. # tag:codenav
  231. when ($CODENAVIGATION && $NOCODENAVIGATION != "yes") {
  232. PY_PROGRAM_LINK_EXE=$LINK_EXE ${hide;kv:"pyndex $TARGET"}
  233. YNDEXER_ARGS=$YMAKE_PYTHON ${input:"build/scripts/yndexer.py"} $CPPYNDEXER_RESOURCE_GLOBAL/yndexer 1500 $(SOURCE_ROOT) $ARCADIA_BUILD_ROOT ${input:SRC}
  234. YNDEXER_OUTPUT=${noauto;output;suf=${OBJ_CROSS_SUF}${COMPILE_OUT_SUFFIX}.ydx.pb2:SRC}
  235. }
  236. otherwise {
  237. PY_PROGRAM_LINK_EXE=$LINK_EXE
  238. YNDEXER_ARGS=
  239. YNDEXER_OUTPUT=
  240. }
  241. when ($RETRY == "yes") {
  242. RETRY_ARGS=$YMAKE_PYTHON ${input:"build/scripts/wrapcc.py"}
  243. }
  244. otherwise {
  245. RETRY_ARGS=
  246. }
  247. COVERAGE_FLAGS=
  248. EXTRA_OUTPUT=
  249. when ($CLANG == "yes" || $GCC == "yes") {
  250. when ($BUILD_TYPE == "COVERAGE" || $GCOV_COVERAGE) {
  251. COVERAGE_FLAGS=-fprofile-arcs -ftest-coverage
  252. EXTRA_OUTPUT=${hide;noauto;output;suf=${COMPILE_OUT_SUFFIX}${OBJ_SUF}${_CROSS_SUFFIX}.gcno:SRC}
  253. }
  254. }
  255. when ($OS_CYGWIN == "yes") {
  256. CFLAGS+=-D_LDBL_EQ_DBL=1 -U__STRICT_ANSI__
  257. USE_ASMLIB=no
  258. FSTACK=
  259. }
  260. when ($OS_IOS == "yes" || $OS_ANDROID == "yes") {
  261. USE_ASMLIB=no
  262. }
  263. CFLAGS+=$COVERAGE_FLAGS
  264. LDFLAGS+=$COVERAGE_FLAGS
  265. CHECKFLAG=
  266. NO_MAPREDUCE=
  267. when ($NO_MAPREDUCE == "yes") {
  268. C_DEFINES+=-DNO_MAPREDUCE
  269. }
  270. when ($OS_ANDROID == "yes") {
  271. PIE=yes
  272. }
  273. when ($CLANG && $OS_DARWIN && $SANITIZER_TYPE && $SANITIZER_TYPE != "no") {
  274. SO_OUTPUTS=yes
  275. }
  276. when ($OS_NONE == "yes" || $MAPSMOBI_BUILD_TARGET == "yes" && $OS_LINUX != "yes") {
  277. USE_STL_SYSTEM=yes
  278. }
  279. # USE_INTERNAL_STL is an internal flag (set on by default) but may be used externally to
  280. # select system standard C++ library when USE_INTERNAL_STL=no is set.
  281. #
  282. # USE_STL_SYSTEM=yes is a regular way to select system standard C++ library.
  283. #
  284. when ($USE_STL_SYSTEM == "yes") {
  285. USE_INTERNAL_STL=no
  286. }
  287. when ($USE_INTERNAL_STL == "no") {
  288. USE_STL_SYSTEM=yes
  289. }
  290. otherwise {
  291. USE_INTERNAL_STL=yes
  292. # TODO: Extract to conf/sysincl.conf
  293. # This trigger doesn't work for module level since SYSINCL is processed at
  294. # configuration stage (This means that NO_RUNTIME() macro called in ya.make
  295. # won't affect SYSINCL and the only way to make this trigger work correctly
  296. # is to define configuration variable NORUNTIME (-DNORUNTIME) on the command
  297. # line when `ya make ...` is invoked.
  298. when ($NORUNTIME != "yes") {
  299. SYSINCL+=build/sysincl/stl-to-libcxx.yml
  300. when ($MSVC == "yes" && $CLANG_CL != "yes") {
  301. SYSINCL+=build/sysincl/stl-to-libcxxmsvc.yml
  302. }
  303. when ($MUSL == "yes") {
  304. SYSINCL+=build/sysincl/libc-musl-libcxx.yml
  305. }
  306. }
  307. }
  308. USE_ARCADIA_PYTHON=yes
  309. USE_ARCADIA_LIBM=no
  310. USE_EAT_MY_DATA=no
  311. HAVE_MKL=
  312. when ($HAVE_MKL == "") {
  313. when ($OS_LINUX && $ARCH_X86_64 && !$SANITIZER_TYPE) {
  314. HAVE_MKL=yes
  315. }
  316. otherwise {
  317. HAVE_MKL=no
  318. }
  319. }
  320. SFDL_TMP_OUT= ${output;tmp:SRC.tmp}
  321. # tag:tool-specific
  322. ARCH_TOOL=${tool:"tools/archiver"}
  323. # tag:tool-specific
  324. LUA_TOOL=${tool:"tools/lua"}
  325. ENUM_PARSER_TOOL=${tool:"tools/enum_parser/enum_parser"}
  326. FATAL_ERROR_MODULE=no
  327. FATAL_ERROR_MESSAGE=
  328. ANTLR_PYTHON=Python2
  329. ### @usage: NO_LTO()
  330. ###
  331. ### Disable any lto (link-time optimizations) for the module.
  332. ### This will compile module source files as usual (without LTO) but will not prevent lto-enabled
  333. ### linking of entire program if global settings say so.
  334. macro NO_LTO() {
  335. DISABLE(USE_LTO)
  336. DISABLE(USE_THINLTO)
  337. }
  338. # tag:allocator
  339. DEFAULT_ALLOCATOR=LF
  340. # tag:allocator
  341. when ($OS_ANDROID == "yes" || $MSVC == "yes" || $ARCH_TYPE_32 == "yes" || $ARCH_AARCH64 == "yes") {
  342. DEFAULT_ALLOCATOR=J
  343. }
  344. # tag:allocator
  345. when ($OS_CYGWIN == "yes" || $ARCH_PPC64LE == "yes") {
  346. DEFAULT_ALLOCATOR=SYSTEM
  347. }
  348. # tag:allocator
  349. when ($OS_DARWIN == "yes") {
  350. DEFAULT_ALLOCATOR=SYSTEM
  351. }
  352. # tag:allocator
  353. when ($OS_LINUX == "yes") {
  354. when ($GCC) {
  355. # tcmalloc broken build
  356. }
  357. elsewhen ($ARCH_X86_64) {
  358. DEFAULT_ALLOCATOR=TCMALLOC_TC
  359. }
  360. }
  361. # tag:allocator
  362. when ($SANITIZER_TYPE) {
  363. when ($SANITIZER_TYPE != "no") {
  364. DEFAULT_ALLOCATOR=SYSTEM
  365. }
  366. }
  367. # tag:allocator
  368. when ($ARCH_XTENSA == "yes") {
  369. DEFAULT_ALLOCATOR=FAKE
  370. }
  371. # tag:internal
  372. ### @usage: CHECK_CONFIG_H(<conf_header>) # internal
  373. ###
  374. ### This internal macro adds checking code for configuration header in external (contrib) library.
  375. ### The check is needed to avoid conflicts on certain types and functions available in arcadia.
  376. ###
  377. ### @see https://a.yandex-team.ru/arc/trunk/arcadia/build/scripts/check_config_h.py for exact details
  378. macro CHECK_CONFIG_H(Conf) {
  379. .CMD=$YMAKE_PYTHON ${input:"build/scripts/check_config_h.py"} ${input;rootrel:Conf} ${output;nopath;noext:Conf.config.cpp} ${hide;kv:"p CH"} ${hide;kv:"pc yellow"}
  380. OUTPUT_INCLUDES=$Conf
  381. }
  382. REQUIRED_TRANSITIVE_PEERS=
  383. ### @usage REQUIRES(dirs...)
  384. ###
  385. ### Specify list of dirs which this module must depend on indirectly.
  386. ###
  387. ### This macro can be used if module depends on the directories specified but they can't be listed
  388. ### as direct PEERDIR dependencies (due to public include order or link order issues).
  389. macro REQUIRES(DIRS[]) {
  390. SET_APPEND(REQUIRED_TRANSITIVE_PEERS $DIRS)
  391. }
  392. CHECK_DEPENDENT_DIRS_TYPES=
  393. CHECK_DEPENDENT_DIRS_RESTRICTIONS=
  394. ### @usage CHECK_DEPENDENT_DIRS(DENY|ALLOW_ONLY ([ALL|PEERDIRS|GLOB] dir)...)
  395. ###
  396. ### Specify project transitive dependencies constraints.
  397. ###
  398. ### @params:
  399. ### 1. DENY: current module can not depend on module from any specified directory neither directly nor transitively.
  400. ### 2. ALLOW_ONLY: current module can not depend on module from a dir not specified in the directory list neither directly nor transitively.
  401. ### 3. ALL: directory constraints following after this modifier are applied to both transitive PEERDIR dependencies and tool dependencies.
  402. ### 4. PEERDIRS: directory constraints following after this modifier are applied to transitive PEERDIR dependencies only.
  403. ### 5. GLOB: next directory constraint is an ANT glob pattern.
  404. ### 6. EXCEPT: next constraint is an exception for the rest of other rules.
  405. ###
  406. ### Directory constraints added before either ALL or PEERDIRS modifier is used are treated as ALL directory constraints.
  407. ###
  408. ### Note: Can be used multiple times on the same module all specified constraints will be checked.
  409. ### All macro invocation for the same module must use same constraints type (DENY or ALLOW_ONLY)
  410. macro CHECK_DEPENDENT_DIRS(TYPE, ALL?"UNUSED":"", PEERDIRS?"PEERDIRS":"ALL", RESTRICTIONS...) {
  411. SET_APPEND(CHECK_DEPENDENT_DIRS_RESTRICTIONS $PEERDIRS $RESTRICTIONS)
  412. SET_APPEND(CHECK_DEPENDENT_DIRS_TYPES $TYPE)
  413. }
  414. macro _RESOURCE_SEM(INPUTS[], KEYS[]) {
  415. SET(RESOURCE_OUTPUT ${hash:INPUTS}.cpp)
  416. .SEM=resources ${output;global:RESOURCE_OUTPUT} INPUTS ${input:INPUTS} KEYS $KEYS ${hide;tool:"tools/rescompiler/bin"} && target_macroses-ITEM && target_macroses-macro resources && target_macroses-args ${output;global:RESOURCE_OUTPUT} INPUTS ${input:INPUTS} KEYS $KEYS ${hide;tool:"tools/rescompiler/bin"}
  417. }
  418. # tag:built-in
  419. ### @usage: RESOURCE([FORCE_TEXT ][Src Key]* [- Key=Value]*) # built-in
  420. ### Add data (resources, random files, strings) to the program)
  421. ### 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.
  422. ### Alternative syntax with '- Key=Value' allows placing Value string as resource data into binary and make it accessible by Key.
  423. ###
  424. ### This is a simpler but less flexible option than ARCHIVE(), because in the case of ARCHIVE(), you have to use the data explicitly,
  425. ### and in the case of RESOURCE(), the data will fall through SRCS() or SRCS(GLOBAL) to binary linking.
  426. ###
  427. ### Use the FORCE_TEXT parameter to explicitly mark all Src files as text files: they will not be parsed unless used elsewhere.
  428. ###
  429. ### @example: https://wiki.yandex-team.ru/yatool/howtowriteyamakefiles/#a2ispolzujjtekomanduresource
  430. ###
  431. ### @example:
  432. ###
  433. ### LIBRARY()
  434. ### OWNER(user1)
  435. ###
  436. ### RESOURCE(
  437. ### path/to/file1 /key/in/program/1
  438. ### path/to/file2 /key2
  439. ### )
  440. ### END()
  441. ###
  442. macro RESOURCE(Args...) {
  443. PEERDIR(library/cpp/resource)
  444. }
  445. # tag:sanitize
  446. RUN_NO_SANITIZE=$YMAKE_PYTHON ${input:"build/scripts/run_tool.py"} --
  447. # tag:sanitize
  448. when ($IS_CROSS_SANITIZE) {
  449. RUN_NO_SANITIZE=
  450. }
  451. YIELD=$YMAKE_PYTHON ${input:"build/scripts/yield_line.py"} -- ${BINDIR}/__args
  452. XARGS=$YMAKE_PYTHON ${input:"build/scripts/xargs.py"} -- ${BINDIR}/__args
  453. WRITER_PY=$YMAKE_PYTHON ${input:"build/scripts/writer.py"} ${hide;input:"build/scripts/process_command_files.py"}
  454. FS_TOOLS=$YMAKE_PYTHON3 ${input:"build/scripts/fs_tools.py"} ${hide;input:"build/scripts/process_command_files.py"}
  455. FIX_MSVC_OUTPUT=${YMAKE_PYTHON} ${input:"build/scripts/fix_msvc_output.py"} ${hide;input:"build/scripts/process_command_files.py"} ${hide;input:"build/scripts/fix_py2_protobuf.py"}
  456. _PROCESS_WHOLE_ARCHIVE_SCRIPT=${hide;input:"build/scripts/process_command_files.py"} ${hide;input:"build/scripts/process_whole_archive_option.py"}
  457. COPY_CMD=$FS_TOOLS copy
  458. LINK_OR_COPY_CMD=$FS_TOOLS link_or_copy
  459. REMOVE_FILE=$FS_TOOLS remove
  460. MOVE_FILE=$FS_TOOLS rename
  461. # tag:allocator tag:windows-specific
  462. MSVC_DYNAMICBASE=/DYNAMICBASE
  463. when ($ALLOCATOR == "LF") {
  464. MSVC_DYNAMICBASE=/DYNAMICBASE:NO
  465. }
  466. # tag:sanitize
  467. SANITIZER_CFLAGS=
  468. # variables must be defined for all module types to make generate_mf.py work
  469. NEED_PLATFORM_PEERDIRS=yes
  470. PEERDIR_TEST_TOOL=yes
  471. ### @usage: _BARE_UNIT # internal
  472. ###
  473. ### The base of all modules describing default bare minimum for all modules.
  474. ### To avoid surprises, all buildable modules are better to be inherited from it or its descendants.
  475. module _BARE_UNIT {
  476. .EXTS=.*
  477. .CMD=TOUCH_UNIT
  478. .IGNORED=GO_PROTO_PLUGIN
  479. .NODE_TYPE=Bundle
  480. .PEERDIR_POLICY=as_include
  481. .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
  482. .FINAL_TARGET=no
  483. PEERDIR_TAGS=__EMPTY__ RESOURCE_LIB
  484. PEERDIR+=$YMAKE_PYTHON3_PEERDIR
  485. when ($FATAL_ERROR_MESSAGE && $FATAL_ERROR_MODULE != "yes") {
  486. PEERDIR+=build/conf_fatal_error
  487. }
  488. DEFAULT(MODULE_VERSION)
  489. DEFAULT(MODULE_PREFIX)
  490. DEFAULT(MODULE_SUFFIX)
  491. }
  492. ### @usage: GEN_LIBRARY()
  493. ###
  494. ### Definition of a module that brings generated artefacts. This module can PEERDIRed
  495. ### from any module. The resulted module is empty and cleaned up during construction
  496. ### of the build graph.
  497. ###
  498. ### NOTE! SRCS macro is not supported for this library.
  499. module GEN_LIBRARY: _BARE_UNIT {
  500. .PROXY=yes
  501. .RESTRICTED=SRCS SRC
  502. .SEM=IGNORED
  503. # ENABLE(_FAKE_MODULE)
  504. SET(MODULE_SUFFIX .pkg.fake)
  505. }
  506. ### @usage: _BASE_UNIT # internal
  507. ###
  508. ### The base of all LIBRARY/PROGRAM modules describing common logic for all modules.
  509. ### To avoid surprises, all buildable modules are better to be inherited from it or its descendants.
  510. module _BASE_UNIT: _BARE_UNIT {
  511. .GLOBAL=_FBS_NAMESPACE_MAP _SBOM_INFO
  512. PEERDIR_TAGS=CPP_PROTO CPP_FBS CPP_ROS H_IDL PY2 PY2_NATIVE YQL_UDF_STATIC __EMPTY__ RESOURCE_LIB DLL_LIB
  513. _CPP_PROTO_WRAPPER_BASE=$YMAKE_PYTHON3 ${input:"build/scripts/cpp_proto_wrapper.py"}
  514. _CPP_PROTO_CMDLINE_BASE=${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 ${hide:PROTO_FAKEID} ${input;rootrel:File}
  515. CPP_PROTO_CMDLINE=$_CPP_PROTO_WRAPPER_BASE --outputs $CPP_PROTO_OUTS -- $_CPP_PROTO_CMDLINE_BASE
  516. CPP_PROTO_OUTS+=${output;norel;nopath;noext:File.pb.cc} ${output;main;norel;nopath;noext:File.pb.h}
  517. CPP_PROTO_OUTS_SEM+=${output;main;hide;norel;nopath;noext:File.pb.h}
  518. CPP_EV_CMDLINE=$_CPP_PROTO_WRAPPER_BASE --outputs $CPP_EV_OUTS -- $_CPP_PROTO_CMDLINE_BASE
  519. CPP_EV_OUTS+=${output;norel:File.pb.cc} ${output;norel:File.pb.h}
  520. CPP_EV_OUTS_SEM+=${hide;output;norel:File.pb.h}
  521. when ($SWIG_LANG == "perl") {
  522. _SWIG_CMD=$_SWIG_PERL_CMD
  523. _SWIG_PEERDIR=contrib/tools/swig/Lib/perl5 build/platform/perl
  524. }
  525. elsewhen ($SWIG_LANG == "python") {
  526. _SWIG_CMD=$_SWIG_PYTHON_CMD
  527. _SWIG_PEERDIR=contrib/tools/swig/Lib/python
  528. }
  529. elsewhen ($SWIG_LANG == "jni_cpp") {
  530. _SWIG_CMD=$_SWIG_JNI_CPP_CMD
  531. _SWIG_PEERDIR=contrib/tools/swig/Lib/java $_SWIG_JNI_PEERDIR
  532. }
  533. elsewhen ($SWIG_LANG == "java") {
  534. _SWIG_CMD=$_SWIG_JNI_CMD
  535. _SWIG_PEERDIR=contrib/tools/swig/Lib/java $_SWIG_JNI_PEERDIR
  536. }
  537. when ($PY_PROTOS_FOR == "yes") {
  538. _EVLOG_CMDLINE=$_PY_EVLOG_CMDLINE
  539. _PROTO_CMDLINE=$_PY_PROTO_CMDLINE
  540. }
  541. otherwise {
  542. _EVLOG_CMDLINE=$_CPP_EVLOG_CMDLINE
  543. _FBS_CMDLINE=$_CPP_FLATC_CMDLINE
  544. when ($BUILD_PROTO_AS_EVLOG == "yes") {
  545. _PROTO_CMDLINE=$_CPP_PROTO_EVLOG_CMDLINE
  546. }
  547. otherwise {
  548. _PROTO_CMDLINE=$_CPP_PROTO_CMDLINE
  549. }
  550. when ($USE_VANILLA_PROTOC == "yes") {
  551. PROTOC=${tool:"contrib/tools/protoc_std"}
  552. PROTOC_STYLEGUIDE_OUT=
  553. PROTOC_PLUGIN_STYLEGUIDE=
  554. PROTOBUF_PATH=${ARCADIA_ROOT}/contrib/libs/protobuf_std
  555. _PROTO_CMDLINE=$_CPP_VANILLA_PROTO_CMDLINE
  556. }
  557. when ($PROTOC_TRANSITIVE_HEADERS == "no") {
  558. CPP_PROTO_PLUGINS=transitive_pb_h=false:${CPP_PROTO_PLUGINS}
  559. CPP_PROTO_OUTS+=${output;main;norel;nopath;noext:File.deps.pb.h}
  560. }
  561. }
  562. SANITIZER_DEFINED=no
  563. when ($SANITIZER_TYPE && $SANITIZER_TYPE != "no") {
  564. CFLAGS+=-fsanitize=$SANITIZER_TYPE -D${SANITIZER_TYPE}_sanitizer_enabled $SANITIZER_CFLAGS -fno-omit-frame-pointer
  565. LDFLAGS+=-fsanitize=$SANITIZER_TYPE
  566. SANITIZER_DEFINED=yes
  567. when ($CLANG) {
  568. CFLAGS+=-fsanitize-blacklist=${input:"build/sanitize-blacklist.txt"} -fno-sanitize-link-runtime
  569. LDFLAGS+=-fsanitize-blacklist=${input:"build/sanitize-blacklist.txt"} -fno-sanitize-link-runtime
  570. }
  571. }
  572. when ($SANITIZER_TYPE && $SANITIZER_TYPE == "memory") {
  573. CFLAGS+=-fno-sanitize-memory-use-after-dtor -Wno-unused-command-line-argument
  574. }
  575. when ($SANITIZE_COVERAGE && $SANITIZE_COVERAGE != "no") {
  576. CFLAGS+=-fsanitize-coverage=$SANITIZE_COVERAGE
  577. LDFLAGS+=-fsanitize-coverage=$SANITIZE_COVERAGE
  578. }
  579. POPULATE_CPP_COVERAGE_FLAGS()
  580. when ($NLG_COVERAGE && $NLG_COVERAGE != "no") {
  581. CFLAGS+=-DNLG_COVERAGE
  582. }
  583. when ($GCC) {
  584. select ($SANITIZER_TYPE) {
  585. "address" ? {
  586. LDFLAGS+=-static-libasan
  587. }
  588. "undefined" ? {
  589. LDFLAGS+=-static-libubsan
  590. }
  591. "thread" ? {
  592. PIE=yes
  593. LDFLAGS+=-static-libtsan
  594. }
  595. }
  596. }
  597. when ($HARDENING == "yes") {
  598. when ($CLANG) {
  599. CFLAGS+=-fstack-protector-all -D_hardening_enabled_
  600. LDFLAGS+=-z relro -z now -z noexecstack
  601. PIE=yes
  602. }
  603. }
  604. when ($USE_LTO == "yes") {
  605. when ($GCC) {
  606. CFLAGS+=-flto -fno-fat-lto-objects
  607. LDFLAGS+=-flto
  608. NO_LTO_CFLAGS=-fno-lto
  609. }
  610. when ($CLANG) {
  611. CFLAGS+=-flto
  612. LDFLAGS+=-flto
  613. NO_LTO_CFLAGS=-fno-lto
  614. }
  615. }
  616. when ($USE_THINLTO == "yes") {
  617. when ($GCC) {
  618. CFLAGS+=-flto=thin
  619. LDFLAGS+=-flto=thin
  620. NO_LTO_CFLAGS=-fno-lto
  621. }
  622. when ($CLANG) {
  623. CFLAGS+=-flto=thin
  624. LDFLAGS+=-flto=thin
  625. NO_LTO_CFLAGS=-fno-lto
  626. }
  627. }
  628. when ($CLANG) {
  629. when ($PGO_ADD == "yes") {
  630. CFLAGS+=-fprofile-instr-generate
  631. LDFLAGS+=-fprofile-instr-generate
  632. }
  633. when ($PGO_PATH) {
  634. CFLAGS+=-fprofile-instr-use=$PGO_PATH -Wno-profile-instr-unprofiled -Wno-profile-instr-out-of-date
  635. LDFLAGS+=-fprofile-instr-use=$PGO_PATH
  636. }
  637. }
  638. when ($COMPILER_PLATFORM && $NEED_PLATFORM_PEERDIRS == "yes") {
  639. PEERDIR+=$COMPILER_PLATFORM
  640. }
  641. when ($OS_LINUX && $NEED_PLATFORM_PEERDIRS == "yes") {
  642. PEERDIR+=contrib/libs/linux-headers
  643. }
  644. when ($NORUNTIME != "yes") {
  645. PEERDIR+=contrib/libs/cxxsupp
  646. when ($MAPSMOBI_BUILD_TARGET == "yes") {
  647. PEERDIR+=build/platform/mapkit
  648. }
  649. }
  650. when ($NOUTIL != "yes") {
  651. PEERDIR+=util
  652. }
  653. when ($MUSL == "yes") {
  654. CFLAGS += -D_musl_
  655. LINK_DYN_LIB_FLAGS += --musl
  656. LINK_SCRIPT_EXE_FLAGS += --musl
  657. PEERDIR+=contrib/libs/musl/include
  658. }
  659. when ($OS_EMSCRIPTEN == "yes") {
  660. when ($NOLIBC != "yes") {
  661. PEERDIR+=contrib/restricted/emscripten/include
  662. }
  663. }
  664. # g++ has proxy C-headers which are incompatible with libc++ proxy C-headers.
  665. # The same problem exists for clang toolchain. On the other hand, the problem
  666. # doesn't affect cl since it has united C/C++ library and doesn't need
  667. # proxy C-headers.
  668. # Disable all C++ headers including proxy C-headers when we use libc++.
  669. when ($USE_INTERNAL_STL == "yes" && $MSVC != "yes") {
  670. CXXFLAGS += -nostdinc++
  671. }
  672. otherwise {
  673. CFLAGS += -DUSE_STL_SYSTEM
  674. }
  675. when ($CODENAVIGATION && $NOCODENAVIGATION != "yes") {
  676. PEERDIR += build/external_resources/codenavigation
  677. }
  678. when ($CYTHON_COVERAGE && $CYTHON_COVERAGE == "yes") {
  679. CFLAGS+=-DCYTHON_TRACE=1 -DCYTHON_TRACE_NOGIL=1
  680. }
  681. DEFAULT(USE_SSE4 yes)
  682. when ($NOSSE != "yes") {
  683. CFLAGS+=$SSE_CFLAGS
  684. C_DEFINES+=$SSE_DEFINES
  685. when ($USE_SSE4 == "yes") {
  686. CFLAGS+=$SSE4_CFLAGS
  687. C_DEFINES+=$SSE4_DEFINES
  688. }
  689. }
  690. elsewhen ($MSVC != "yes") {
  691. CFLAGS += -mno-sse
  692. }
  693. POPULATE_CPP_COVERAGE_FLAGS()
  694. _REGISTER_NO_CHECK_IMPORTS()
  695. DEFAULT(PACKAGE_PREFIX_ARGS)
  696. DEFAULT(SWIG_LANG python)
  697. DEFAULT(GP_FLAGS -CtTLANSI-C -Dk* -c)
  698. when ($NEED_BINUTILS_PEERDIR && $BINUTILS_USED && $NEED_PLATFORM_PEERDIRS == "yes") {
  699. PEERDIR+=build/platform/binutils
  700. }
  701. when ($TIDY_ENABLED == "yes") {
  702. PEERDIR+=build/platform/clang/clang-tidy
  703. }
  704. ENABLE(USE_YASM_ASSEMBLER)
  705. ENABLE(_BISON_FLEX_SET_DEFAULTS)
  706. }
  707. _LINKER_ID=
  708. # GCC does not support -fuse-ld with an executable path,
  709. # only -fuse-ld=gold or -fuse-ld=lld.
  710. when ($_LINKER_ID != "" && $_DEFAULT_LINKER_ID != "" && $CLANG == "yes" && $NEED_PLATFORM_PEERDIRS == "yes") {
  711. when ($_LINKER_ID in [ "gold", "lld" ]) {
  712. PEERDIR+=build/platform/${_LINKER_ID}
  713. }
  714. }
  715. macro _USE_LINKER_IMPL(LINKER_ID...) {
  716. SET(_LINKER_ID $LINKER_ID)
  717. }
  718. macro _USE_LINKER() {
  719. _USE_LINKER_IMPL($_DEFAULT_LINKER_ID)
  720. }
  721. ### @usage: USE_LINKER_GOLD()
  722. ### Use gold linker for a program. This doesn't work in libraries
  723. macro USE_LINKER_GOLD() {
  724. _USE_LINKER_IMPL(gold)
  725. }
  726. COMMON_LINK_SETTINGS=
  727. LINK_ADDITIONAL_SECTIONS=
  728. LINK_ADDITIONAL_SECTIONS_COMMAND=
  729. when ($COMMON_LINK_SETTINGS == "yes") {
  730. when ($_LINKER_ID == "lld" && ($OS_LINUX == "yes" || $OS_ANDROID == "yes")) {
  731. LDFLAGS += -Wl,--gdb-index
  732. }
  733. when ($EMBED_LINKER_CREF == "yes") {
  734. LDFLAGS+=-Wl,--cref ${tmp;stdout;pre=$MODULE_PREFIX;suf=.ldcref:REALPRJNAME} -Wl,--no-demangle
  735. LINK_ADDITIONAL_SECTIONS+=--add-section=.ya.linker_cref=${tmp;pre=$MODULE_PREFIX;suf=.ldcref:REALPRJNAME}
  736. }
  737. elsewhen ($DUMP_LINKER_CREF == "yes") {
  738. LDFLAGS+=-Wl,--cref ${output;stdout;pre=$MODULE_PREFIX;suf=.ldcref:REALPRJNAME} -Wl,--no-demangle
  739. }
  740. when ($EMBED_LINKER_MAP == "yes") {
  741. LDFLAGS+=-Wl,-Map=${tmp;pre=$MODULE_PREFIX;suf=.map.$_LINKER_ID:REALPRJNAME}
  742. LINK_ADDITIONAL_SECTIONS+=--add-section=.ya.linker_map.${_LINKER_ID}=${tmp;pre=$MODULE_PREFIX;suf=.map.$_LINKER_ID:REALPRJNAME}
  743. }
  744. elsewhen ($DUMP_LINKER_MAP == "yes") {
  745. LDFLAGS+=-Wl,-Map=${output;rootrel;pre=$MODULE_PREFIX;suf=.map.$_LINKER_ID:REALPRJNAME}
  746. }
  747. when ($USE_MKL == "yes") {
  748. NOPLATFORM=yes
  749. }
  750. when ($AUTOCHECK == "yes" && $OS_LINUX == "yes") {
  751. PEERDIR+=contrib/libs/libeatmydata
  752. # We can not use LICENSE_RESTRICTION_EXCEPTIONS() macro inside a trigger.
  753. # Duplicate its implementation here
  754. MODULE_LICENSES_RESTRICTION_EXCEPTIONS+=contrib/libs/libeatmydata
  755. }
  756. when ($OS_EMSCRIPTEN == "yes") {
  757. # Do nothing.
  758. }
  759. otherwise {
  760. when ($USE_ARCADIA_LIBM == "yes") {
  761. PEERDIR+=contrib/libs/libm
  762. }
  763. when ($USE_ARCADIA_LIBM == "no") {
  764. C_SYSTEM_LIBRARIES+=-lm
  765. }
  766. }
  767. when (($MUSL != "yes" && $WITH_VALGRIND == "yes") || $SANITIZER_DEFINED == "yes") {
  768. 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", "YT_TCMALLOC", "YT_TCMALLOC_256K", "MIM", "MIM_SDC", "HU", "PROFILED_HU", "THREAD_PROFILED_HU" ]) {
  769. PEERDIR+=library/cpp/malloc/system
  770. }
  771. }
  772. otherwise {
  773. select ($ALLOCATOR) {
  774. "MIM" ? {
  775. PEERDIR+=library/cpp/malloc/mimalloc
  776. }
  777. "MIM_SDC" ? {
  778. PEERDIR+=library/cpp/malloc/mimalloc_sdc
  779. }
  780. "HU" ? {
  781. PEERDIR+=library/cpp/malloc/hu
  782. }
  783. "PROFILED_HU" ? {
  784. PEERDIR+=library/cpp/malloc/profiled_hu
  785. }
  786. "THREAD_PROFILED_HU" ? {
  787. PEERDIR+=library/cpp/malloc/thread_profiled_hu
  788. }
  789. "TCMALLOC_256K" ? {
  790. PEERDIR+=library/cpp/malloc/tcmalloc
  791. PEERDIR+=contrib/libs/tcmalloc
  792. }
  793. "TCMALLOC_SMALL_BUT_SLOW" ? {
  794. PEERDIR+=library/cpp/malloc/tcmalloc
  795. PEERDIR+=contrib/libs/tcmalloc/small_but_slow
  796. }
  797. "TCMALLOC_NUMA_256K" ? {
  798. PEERDIR+=library/cpp/malloc/tcmalloc
  799. PEERDIR+=contrib/libs/tcmalloc/numa_256k
  800. }
  801. "TCMALLOC_NUMA_LARGE_PAGES" ? {
  802. PEERDIR+=library/cpp/malloc/tcmalloc
  803. PEERDIR+=contrib/libs/tcmalloc/numa_large_pages
  804. }
  805. "TCMALLOC" ? {
  806. PEERDIR+=library/cpp/malloc/tcmalloc
  807. PEERDIR+=contrib/libs/tcmalloc/default
  808. }
  809. "TCMALLOC_TC" ? {
  810. PEERDIR+=library/cpp/malloc/tcmalloc
  811. PEERDIR+=contrib/libs/tcmalloc/no_percpu_cache
  812. }
  813. "GOOGLE" ? {
  814. PEERDIR+=library/cpp/malloc/galloc
  815. }
  816. "J" ? {
  817. when ($WIN32 == "yes") {
  818. PEERDIR+=library/cpp/malloc/system
  819. }
  820. otherwise {
  821. PEERDIR+=library/cpp/malloc/jemalloc
  822. }
  823. }
  824. "LF" ? {
  825. PEERDIR+=library/cpp/lfalloc
  826. }
  827. "LF_YT" ? {
  828. PEERDIR+=library/cpp/lfalloc/yt
  829. }
  830. "LF_DBG" ? {
  831. PEERDIR+=library/cpp/lfalloc/dbg
  832. }
  833. "B" ? {
  834. PEERDIR+=library/cpp/balloc
  835. }
  836. "BM" ? {
  837. PEERDIR+=library/cpp/balloc_market
  838. }
  839. "C" ? {
  840. PEERDIR+=library/cpp/malloc/calloc
  841. }
  842. "LOCKLESS" ? {
  843. PEERDIR+=library/cpp/malloc/lockless
  844. }
  845. "YT" ? {
  846. PEERDIR+=library/cpp/ytalloc/impl
  847. }
  848. "YT_TCMALLOC" ? {
  849. PEERDIR+=library/cpp/malloc/tcmalloc
  850. PEERDIR+=contrib/libs/yt_tcmalloc/default
  851. }
  852. "YT_TCMALLOC_256K" ? {
  853. PEERDIR+=library/cpp/malloc/tcmalloc
  854. PEERDIR+=contrib/libs/yt_tcmalloc
  855. }
  856. }
  857. }
  858. when ($ALLOCATOR == "SYSTEM") {
  859. PEERDIR+=library/cpp/malloc/system
  860. }
  861. when ($WERROR != "no") {
  862. when ($WERROR_MODE == "all" || ($WERROR_MODE == "compiler_specific" && $WERROR == "yes")) {
  863. C_WARNING_OPTS += $WERROR_FLAG
  864. }
  865. }
  866. when ($ICC == "yes") {
  867. PEERDIR+=contrib/libs/intel/core
  868. }
  869. when ($WITH_VALGRIND == "yes") {
  870. PEERDIR+=contrib/libs/valgrind
  871. # https://st.yandex-team.ru/DTCC-122
  872. CFLAGS+=-fdebug-default-version=4
  873. }
  874. }
  875. when ($EMBED_LINKER_MAP == "yes" || $EMBED_LINKER_CREF == "yes") {
  876. LINK_ADDITIONAL_SECTIONS_COMMAND+= \
  877. $OBJCOPY_TOOL $LINK_ADDITIONAL_SECTIONS $TARGET
  878. }
  879. _SO_EXT_FILTER=${ext=.so:PEERS} ${hide;late_out;nopath;ext=.so;pre=$BINDIR/:PEERS}
  880. when ($OS_WINDOWS == "yes") {
  881. _SO_EXT_FILTER=${ext=.dll:PEERS} ${hide;late_out;nopath;ext=.dll;pre=$BINDIR/:PEERS}
  882. }
  883. elsewhen ($OS_DARWIN == "yes" || $OS_IOS == "yes") {
  884. _SO_EXT_FILTER=${ext=.dylib:PEERS} ${hide;late_out;nopath;ext=.dylib;pre=$BINDIR/:PEERS}
  885. }
  886. LINK_OR_COPY_SO_CMD=
  887. RPATH_GLOBAL=
  888. when ($SO_OUTPUTS == "yes") {
  889. LINK_OR_COPY_SO_CMD=$FS_TOOLS link_or_copy_to_dir --no-check $_SO_EXT_FILTER ${BINDIR}
  890. LDFLAGS+=$RPATH_GLOBAL
  891. }
  892. # tag:restricted tag:DLL
  893. ### $usage: WITH_DYNAMIC_LIBS() # restricted
  894. ###
  895. ### Include dynamic libraries as extra PROGRAM/DLL outputs
  896. macro WITH_DYNAMIC_LIBS() {
  897. ENABLE(SO_OUTPUTS)
  898. }
  899. # tag:internal
  900. ### $usage: REAL_LINK_EXE_IMPL(peers...) # internal
  901. macro REAL_LINK_EXE_IMPL(WHOLE_ARCHIVE_PEERS...) {
  902. .CMD=$REAL_LINK_EXE_CMDLINE && $LINK_OR_COPY_SO_CMD
  903. }
  904. # tag:internal
  905. ### $usage: REAL_LINK_EXEC_DYN_LIB_IMPL(peers...) # internal
  906. macro REAL_LINK_EXEC_DYN_LIB_IMPL(WHOLE_ARCHIVE_PEERS...) {
  907. .CMD=$REAL_LINK_EXEC_DYN_LIB_CMDLINE
  908. }
  909. # tag:internal
  910. ### $usage: REAL_LINK_DYN_LIB_IMPL(peers...) # internal
  911. macro REAL_LINK_DYN_LIB_IMPL(WHOLE_ARCHIVE_PEERS...) {
  912. .CMD=$REAL_LINK_DYN_LIB_CMDLINE && $LINK_OR_COPY_SO_CMD
  913. }
  914. # tag:internal
  915. ### $usage: LINK_EXE_IMPL(peers...) # internal
  916. macro LINK_EXE_IMPL(WHOLE_ARCHIVE_PEERS...) {
  917. .CMD=$LINK_EXE_CMDLINE && $LINK_OR_COPY_SO_CMD
  918. }
  919. # tag:internal
  920. ### $usage: LINK_EXEC_DYN_LIB_IMPL(peers...) # internal
  921. macro LINK_EXEC_DYN_LIB_IMPL(WHOLE_ARCHIVE_PEERS...) {
  922. .CMD=$LINK_EXEC_DYN_LIB_CMDLINE
  923. }
  924. # tag:internal
  925. ### @usage: _LINK_UNIT # internal
  926. ###
  927. ### The base of all linkable modules: programs, DLLs etc. Describes common linking logic.
  928. module _LINK_UNIT: _BASE_UNIT {
  929. .EXTS=.o .obj .supp .tidyjson .ld
  930. .CMD=LINK_EXE
  931. .ALLOWED=EXTRALIBS OBJADDE_GLOBAL RESOURCE_FILES
  932. .NODE_TYPE=Program
  933. .PEERDIR_POLICY=as_build_from
  934. .FINAL_TARGET=yes
  935. .DEFAULT_NAME_GENERATOR=DirName
  936. .ARGS_PARSER=Base
  937. DEFAULT(ALLOCATOR $DEFAULT_ALLOCATOR)
  938. _USE_LINKER()
  939. #link with libunwind manually
  940. when ($DARWIN == "yes" && $NOPLATFORM != "yes") {
  941. PEERDIR += contrib/libs/cxxsupp
  942. }
  943. when ($NEED_PROFILE_RUNTIME == "yes") {
  944. LDFLAGS+=-resource-dir=contrib/libs/clang-rt
  945. PEERDIR+=contrib/libs/clang${CLANG_VER}-rt/lib/profile
  946. }
  947. when ($USE_LIBCXXRT == "yes") {
  948. PEERDIR += contrib/libs/cxxsupp/libcxxrt
  949. }
  950. when ($USE_DYNAMIC_CUDA == "yes") {
  951. LINK_DYN_LIB_FLAGS += --dynamic-cuda
  952. LINK_SCRIPT_EXE_FLAGS += --dynamic-cuda
  953. }
  954. when ($USE_DYNAMIC_CUDA != "yes") {
  955. when ($CUDA_ARCHITECTURES) {
  956. LINK_SCRIPT_EXE_FLAGS+=--cuda-architectures $CUDA_ARCHITECTURES
  957. LINK_SCRIPT_EXE_FLAGS+=--nvprune-exe $CUDA_ROOT/bin/nvprune
  958. }
  959. LINK_SCRIPT_EXE_FLAGS+=--objcopy-exe $OBJCOPY_TOOL
  960. }
  961. LINK_SCRIPT_EXE_FLAGS+=--build-root $(BUILD_ROOT)
  962. when ($OPENSOURCE == "yes" && $AUTOCHECK == "yes") {
  963. # FIXME: Replace AUTOCHECK == yes with _not a host platform_ check after YMAKE-218
  964. MODULE_LICENSES_RESTRICTION_TYPES = ALLOW_ONLY
  965. MODULE_LICENSES_RESTRICTIONS = SERVICE REQUIRE_CITATION REQUIRE_MODIFICATIONS_DISCLOSURE
  966. }
  967. when ($OS_IOS == "yes" || $OS_ANDROID == "yes" || $MAPSMOBI_BUILD_TARGET == "yes") {
  968. MODULE_LICENSES_RESTRICTION_TYPES = ALLOW_ONLY
  969. MODULE_LICENSES_RESTRICTIONS = SERVICE REQUIRE_CITATION
  970. }
  971. ENABLE(COMMON_LINK_SETTINGS)
  972. CHECK_PROVIDES()
  973. ADD_CLANG_TIDY()
  974. when ($TIDY_ENABLED == "yes") {
  975. MODULE_PREFIX=
  976. MODULE_SUFFIX=.tidyjson
  977. _MAKEFILE_INCLUDE_LIKE_DEPS+=${ARCADIA_ROOT}/build/yandex_specific/config/clang_tidy/tidy_project_map.json
  978. _MAKEFILE_INCLUDE_LIKE_DEPS+=${ARCADIA_ROOT}/build/yandex_specific/config/clang_tidy/tidy_default_map.json
  979. }
  980. }
  981. MODULE_TYPE=UNKNOWN
  982. macro ADD_CLANG_TIDY() {
  983. ADD_YTEST($MODULE_PREFIX$REALPRJNAME$MODULE_SUFFIX clang_tidy)
  984. }
  985. # tag:internal
  986. ### @usage: _BASE_PROGRAM # internal
  987. ###
  988. ### The base of all programs. It adds dependencies to make final artefact complete and runnable.
  989. module _BASE_PROGRAM: _LINK_UNIT {
  990. .SYMLINK_POLICY=EXE
  991. .ALLOWED=INDUCED_DEPS WHOLE_ARCHIVE
  992. .GLOBAL=LDFLAGS _WHOLE_ARCHIVE_LIBS_VALUE RPATH OBJADDE_LIB
  993. SET(MODULE_TYPE PROGRAM)
  994. SET(MODULE_LANG CPP)
  995. FORCE_COVERAGE_ENABLED=yes
  996. when ($OS_IOS == "yes") {
  997. EXTS+=.ios.interface
  998. }
  999. when ($WIN32 == "yes" || $OS_CYGWIN == "yes") {
  1000. MODULE_SUFFIX=.exe
  1001. }
  1002. when ($MSVC != "yes" && $NOPLATFORM != "yes" && $WITH_VALGRIND != "yes" && $USE_ASMLIB != "no" && $MIC_ARCH != "yes" && $PIC != "yes" && $PIE != "yes") {
  1003. when ($OS_LINUX == "yes" && $ARCH_X86_64 == "yes" && $MUSL != "yes" && $SANITIZER_DEFINED != "yes" && $USE_THINLTO != "yes") {
  1004. PEERDIR+=contrib/libs/glibcasm
  1005. }
  1006. otherwise {
  1007. PEERDIR+=contrib/libs/asmlib
  1008. }
  1009. }
  1010. when ($MUSL == "yes") {
  1011. when ($MUSL_LITE == "yes") {
  1012. PEERDIR += contrib/libs/musl
  1013. }
  1014. otherwise {
  1015. PEERDIR += contrib/libs/musl/full
  1016. }
  1017. }
  1018. DEFAULT(CPU_CHECK yes)
  1019. when ($USE_SSE4 != "yes" || $NOUTIL == "yes" || $ALLOCATOR == "FAKE") {
  1020. CPU_CHECK = no
  1021. }
  1022. when ($CPU_CHECK == "yes") {
  1023. PEERDIR += library/cpp/cpuid_check
  1024. }
  1025. when ($USE_ARC_PROFILE == "yes" && $NOUTIL != "yes") {
  1026. PEERDIR += library/cpp/execprofile/autostart
  1027. }
  1028. when ($SANITIZER_TYPE && $SANITIZER_TYPE != "no") {
  1029. PEERDIR += contrib/libs/cxxsupp/libsan
  1030. when ($CLANG) {
  1031. select ($TARGET_PLATFORM) {
  1032. "LINUX" ? {
  1033. PEERDIR += library/cpp/sanitizer/${SANITIZER_TYPE}/static
  1034. }
  1035. "DARWIN" ? {
  1036. # Memory sanitizer is not supported for darwin platform.
  1037. # https://clang.llvm.org/docs/MemorySanitizer.html#supported-platforms
  1038. when ($SANITIZER_TYPE != "memory") {
  1039. PEERDIR += library/cpp/sanitizer/${SANITIZER_TYPE}/dynamic
  1040. }
  1041. }
  1042. default ? {
  1043. FATAL_ERROR_MESSAGE+=Unsupported platform for sanitizer
  1044. }
  1045. }
  1046. }
  1047. }
  1048. when ($CLANG_COVERAGE && $CLANG_COVERAGE != "no") {
  1049. PEERDIR+=library/cpp/testing/dump_clang_coverage
  1050. }
  1051. when ($IDE_MSVS == "yes") {
  1052. PEERDIR+=build/scripts/c_templates
  1053. }
  1054. when ($_CUSTOM_LINK_STEP_SCRIPT) {
  1055. LINK_SCRIPT_EXE_FLAGS+=--python=$YMAKE_PYTHON --custom-step=${input:_CUSTOM_LINK_STEP_SCRIPT}
  1056. }
  1057. }
  1058. VCS_INFO_SEM=vcs_info ${hide;input:"build/scripts/vcs_info.py"} ${hide;input:"build/scripts/c_templates/svn_interface.c"} ${hide;input:"build/scripts/c_templates/svnversion.h"} && target_macroses-ITEM && target_macroses-macro vcs_info && target_macroses-args ${hide;input:"build/scripts/vcs_info.py"} ${hide;input:"build/scripts/c_templates/svn_interface.c"} ${hide;input:"build/scripts/c_templates/svnversion.h"}
  1059. CPP_PROGRAM_SEM=add_executable $MODDIR $CMAKE_TARGET_NAME ${hide:TARGET} ${hide:AUTO_INPUT} $CMAKE_TARGET_ARTEFACT_RENAME_RULES \
  1060. && ${VCS_INFO_SEM} \
  1061. && target_link_options PRIVATE $LDFLAGS_GLOBAL_RAW $LDFLAGS $OBJADDE_LIB $OBJADDE_LIB_GLOBAL $OBJADDE \
  1062. && target_options-privates-ITEM && target_options-privates-option target_link_options && target_options-privates-args $LDFLAGS_GLOBAL_RAW $LDFLAGS $OBJADDE_LIB $OBJADDE_LIB_GLOBAL $OBJADDE \
  1063. && target_include_directories PRIVATE $_C__INCLUDE_OWNED \
  1064. && target_options-privates-ITEM && target_options-privates-option target_include_directories && target_options-privates-args $_C__INCLUDE_OWNED \
  1065. && target_compile_options PRIVATE $USER_CFLAGS $USER_CXXFLAGS $_SEM_EXTRA_CXX_FLAGS \
  1066. && target_options-privates-ITEM && target_options-privates-option target_compile_options && target_options-privates-args $USER_CFLAGS $USER_CXXFLAGS $_SEM_EXTRA_CXX_FLAGS \
  1067. && target_compile_options PRIVATE $USER_CFLAGS_GLOBAL_RAW $USER_CXXFLAGS_GLOBAL_RAW \
  1068. && target_options-privates-ITEM && target_options-privates-option target_compile_options && target_options-privates-args $USER_CFLAGS_GLOBAL_RAW $USER_CXXFLAGS_GLOBAL_RAW \
  1069. && target_sources PRIVATE ${MODULE_EXPLICIT_HEADERS} \
  1070. && target_options-privates-ITEM && target_options-privates-option target_sources && target_options-privates-args ${MODULE_EXPLICIT_HEADERS}
  1071. ### @usage: PROGRAM([progname])
  1072. ###
  1073. ### Regular program module.
  1074. ### If name is not specified it will be generated from the name of the containing project directory.
  1075. module PROGRAM: _BASE_PROGRAM {
  1076. .SEM=CPP_PROGRAM_SEM
  1077. .ALIASES=EXTRALIBS=PY_EXTRALIBS
  1078. ADD_YTEST($MODULE_PREFIX$REALPRJNAME coverage.extractor)
  1079. _DONT_REQUIRE_LICENSE()
  1080. }
  1081. ### @usage: EXPORTS_SCRIPT(exports_file)
  1082. ###
  1083. ### Specify exports script within PROGRAM, DLL and DLL-derived modules.
  1084. ### This accepts 2 kind of files: .exports with <lang symbol> pairs and JSON-line .symlist files.
  1085. ### The other option use EXPORTS parameter of the DLL module itself.
  1086. ###
  1087. ### @see: [DLL](#module_DLL)
  1088. macro EXPORTS_SCRIPT(Arg) {
  1089. SET(EXPORTS_FILE $Arg)
  1090. }
  1091. ### @usage: NO_EXPORT_DYNAMIC_SYMBOLS()
  1092. ###
  1093. ### Disable exporting all non-hidden symbols as dynamic when linking a PROGRAM.
  1094. macro NO_EXPORT_DYNAMIC_SYMBOLS() {
  1095. ENABLE(NO_EXPORT_DYNAMIC_SYMBOLS)
  1096. }
  1097. ### @usage: EXPORT_ALL_DYNAMIC_SYMBOLS()
  1098. ###
  1099. ### Export all non-hidden symbols as dynamic when linking a PROGRAM.
  1100. macro EXPORT_ALL_DYNAMIC_SYMBOLS() {
  1101. # Dummy: default behaviour
  1102. ENABLE(EXPORT_ALL_DYNAMIC_SYMBOLS)
  1103. }
  1104. ### @usage: USE_DYNAMIC_CUDA()
  1105. ###
  1106. ### Enable linking of PROGRAM with dynamic CUDA. By default CUDA uses static linking
  1107. macro USE_DYNAMIC_CUDA() {
  1108. LDFLAGS(-Wl,-rpath,$ORIGIN)
  1109. ENABLE(USE_DYNAMIC_CUDA)
  1110. }
  1111. ### @usage: CUSTOM_LINK_STEP_SCRIPT(name)
  1112. ###
  1113. ### Specifies name of a script for custom link step. The scripts
  1114. ### should be placed in the build/scripts directory and are subject to
  1115. ### review by devtools@.
  1116. macro CUSTOM_LINK_STEP_SCRIPT(Name) {
  1117. SET(_CUSTOM_LINK_STEP_SCRIPT build/scripts/$Name)
  1118. }
  1119. ### @usage: _BASE_UNITTEST # internal
  1120. ###
  1121. ### Module with base logic for all unit-test modules: it makes code runnable as unit-test by Arcadia testing machinery.
  1122. module _BASE_UNITTEST: _BASE_PROGRAM {
  1123. .FINAL_TARGET=no
  1124. .NODE_TYPE=Program
  1125. .ALLOWED=YT_SPEC
  1126. .DEFAULT_NAME_GENERATOR=FullPath
  1127. when ($UT_SKIP_EXCEPTIONS == "yes") {
  1128. C_DEFINES+=-DUT_SKIP_EXCEPTIONS
  1129. }
  1130. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS canondata/result.json)
  1131. # Assume that no code may depend on unit test output and thus
  1132. # do not mandate license markup in such modules.
  1133. _DONT_REQUIRE_LICENSE()
  1134. }
  1135. _TEST_SPLIT_FACTOR_SEM=1
  1136. _TEST_TIMEOUT_SEM=
  1137. _TEST_PARTITION_SEM=
  1138. UNITTEST_SEM=$CPP_PROGRAM_SEM \
  1139. && set_property TARGET $REALPRJNAME PROPERTY SPLIT_FACTOR $_TEST_SPLIT_FACTOR_SEM \
  1140. && target_commands-ITEM && target_commands-macro set_property && target_commands-args TARGET $REALPRJNAME PROPERTY SPLIT_FACTOR $_TEST_SPLIT_FACTOR_SEM \
  1141. $_TEST_PARTITION_SEM \
  1142. && add_yunittest NAME $REALPRJNAME TEST_TARGET $REALPRJNAME TEST_ARG --print-before-suite --print-before-test --fork-tests --print-times --show-fails \
  1143. && target_commands-ITEM && target_commands-macro add_yunittest && target_commands-args NAME $REALPRJNAME TEST_TARGET $REALPRJNAME TEST_ARG --print-before-suite --print-before-test --fork-tests --print-times --show-fails \
  1144. && set_yunittest_property TEST $REALPRJNAME PROPERTY LABELS $TEST_SIZE_NAME $FILTER_ONLY_TEST_TAGS \
  1145. && target_commands-ITEM && target_commands-macro set_yunittest_property && target_commands-args TEST $REALPRJNAME PROPERTY LABELS $TEST_SIZE_NAME $FILTER_ONLY_TEST_TAGS \
  1146. && add_ytest_requirements $REALPRJNAME $DEFAULT_REQUIREMENTS $TEST_REQUIREMENTS_VALUE \
  1147. && set_yunittest_property_escaped TEST $REALPRJNAME PROPERTY ENVIRONMENT $TEST_ENV_VALUE \
  1148. && target_commands-ITEM && target_commands-macro set_yunittest_property && target_commands-args TEST $REALPRJNAME PROPERTY ENVIRONMENT && target_commands-args_escaped $TEST_ENV_VALUE \
  1149. $_TEST_TIMEOUT_SEM
  1150. # tag:test
  1151. ### @usage: UNITTEST([name])
  1152. ###
  1153. ### Unit test module based on library/cpp/testing/unittest.
  1154. ### It is recommended not to specify the name.
  1155. ###
  1156. ### Documentation: https://wiki.yandex-team.ru/yatool/test/#opisanievya.make1
  1157. module UNITTEST: _BASE_UNITTEST {
  1158. .SEM=UNITTEST_SEM
  1159. .ARGS_PARSER=Base
  1160. PEERDIR(library/cpp/testing/unittest_main)
  1161. ADD_YTEST($MODULE_PREFIX$REALPRJNAME unittest.py)
  1162. when ($TEST_FORK_MODE != "none") {
  1163. when ($TEST_SPLIT_FACTOR) {
  1164. _TEST_SPLIT_FACTOR_SEM=$TEST_SPLIT_FACTOR
  1165. }
  1166. otherwise {
  1167. _TEST_SPLIT_FACTOR_SEM=10
  1168. }
  1169. when ($TEST_PARTITION == "MODULO") {
  1170. _TEST_PARTITION_SEM=&& set_property TARGET $REALPRJNAME PROPERTY SPLIT_TYPE $TEST_PARTITION && target_commands-ITEM && target_commands-macro set_property && target_commands-args TARGET $REALPRJNAME PROPERTY SPLIT_TYPE $TEST_PARTITION \
  1171. }
  1172. }
  1173. when ($TEST_TIMEOUT) {
  1174. _TEST_TIMEOUT_SEM=&& set_yunittest_property TEST $REALPRJNAME PROPERTY TIMEOUT $TEST_TIMEOUT && target_commands-ITEM && target_commands-macro set_yunittest_property && target_commands-args TEST $REALPRJNAME PROPERTY TIMEOUT $TEST_TIMEOUT
  1175. }
  1176. }
  1177. # tag:yt-specific tag:test
  1178. ### @usage: YT_UNITTEST([name])
  1179. ###
  1180. ### YT Unit test module based on library/cpp/testing/unittest with NYT::Initialize hook
  1181. module YT_UNITTEST: _BASE_UNITTEST {
  1182. .SEM=UNITTEST_SEM
  1183. PEERDIR(library/cpp/testing/unittest_main yt/cpp/mapreduce/tests/yt_initialize_hook)
  1184. ADD_YTEST($MODULE_PREFIX$REALPRJNAME unittest.py)
  1185. }
  1186. # tag:test
  1187. ### @usage: UNITTEST_WITH_CUSTOM_ENTRY_POINT([name])
  1188. ###
  1189. ### Generic unit test module.
  1190. module UNITTEST_WITH_CUSTOM_ENTRY_POINT: _BASE_UNITTEST {
  1191. .SEM=UNITTEST_SEM
  1192. ADD_YTEST($MODULE_PREFIX$REALPRJNAME unittest.py)
  1193. }
  1194. GTEST_SEM=$CPP_PROGRAM_SEM \
  1195. && add_test NAME $REALPRJNAME COMMAND $REALPRJNAME \
  1196. && target_commands-ITEM && target_commands-macro add_test && target_commands-args NAME $REALPRJNAME COMMAND $REALPRJNAME \
  1197. && set_property TEST $REALPRJNAME PROPERTY LABELS $TEST_SIZE_NAME $FILTER_ONLY_TEST_TAGS \
  1198. && target_commands-ITEM && target_commands-macro set_property && target_commands-args TEST $REALPRJNAME PROPERTY LABELS $TEST_SIZE_NAME $FILTER_ONLY_TEST_TAGS \
  1199. && add_test_requirements $REALPRJNAME $DEFAULT_REQUIREMENTS $TEST_REQUIREMENTS_VALUE \
  1200. && set_property_escaped TEST $REALPRJNAME PROPERTY ENVIRONMENT $TEST_ENV_VALUE \
  1201. && target_commands-ITEM && target_commands-macro set_property && target_commands-args TEST $REALPRJNAME PROPERTY ENVIRONMENT && target_commands-args_escaped $TEST_ENV_VALUE \
  1202. $_TEST_TIMEOUT_SEM
  1203. # tag:cpp-specific tag:test
  1204. ### @usage: GTEST([name])
  1205. ###
  1206. ### Unit test module based on library/cpp/testing/gtest.
  1207. ### It is recommended not to specify the name.
  1208. ###
  1209. ### Documentation: https://docs.yandex-team.ru/arcadia-cpp/docs/build/manual/tests/cpp#gtest
  1210. module GTEST: _BASE_UNITTEST {
  1211. .SEM=GTEST_SEM
  1212. .DEFAULT_NAME_GENERATOR=FullPath
  1213. .ARGS_PARSER=Base
  1214. PEERDIR(library/cpp/testing/gtest library/cpp/testing/gtest_main)
  1215. ADD_YTEST($MODULE_PREFIX$REALPRJNAME gunittest)
  1216. when ($TEST_TIMEOUT) {
  1217. _TEST_TIMEOUT_SEM=&& set_property TEST $REALPRJNAME PROPERTY TIMEOUT $TEST_TIMEOUT && target_commands-ITEM && target_commands-macro set_property && target_commands-args TEST $REALPRJNAME PROPERTY TIMEOUT $TEST_TIMEOUT
  1218. }
  1219. }
  1220. USE_AFL=no
  1221. # tag:fuzzing
  1222. ### @usage: FUZZ()
  1223. ###
  1224. ### In order to start using Fuzzing in Arcadia, you need to create a FUZZ module with the implementation of the function LLVMFuzzerTestOneInput().
  1225. ### This module should be reachable by RECURSE from /autocheck project in order for the corpus to be regularly updated.
  1226. ### AFL and Libfuzzer are supported in Arcadia via a single interface, but the automatic fuzzing still works only through Libfuzzer.
  1227. ###
  1228. ### Example: https://a.yandex-team.ru/arc/trunk/arcadia/contrib/libs/re2/re2/fuzzing/re2_fuzzer.cc?rev=2919463#L58
  1229. ###
  1230. ### Documentation: https://wiki.yandex-team.ru/yatool/fuzzing/
  1231. module FUZZ: _BASE_PROGRAM {
  1232. .NODE_TYPE=Program
  1233. .FINAL_TARGET=no
  1234. .ALLOWED=FUZZ_DICTS FUZZ_OPTS
  1235. SET(LIBFUZZER_PATH contrib/libs/libfuzzer)
  1236. when ($USE_AFL == "no") {
  1237. PEERDIR+=$LIBFUZZER_PATH
  1238. }
  1239. when ($USE_AFL == "yes") {
  1240. PEERDIR+=$LIBFUZZER_PATH/afl
  1241. }
  1242. when (!$SANITIZER_TYPE || $SANITIZER_TYPE == "no") {
  1243. PEERDIR+=library/cpp/testing/nofuzz
  1244. }
  1245. ADD_YTEST($MODULE_PREFIX$REALPRJNAME fuzz.test)
  1246. }
  1247. # tag:ios-specific
  1248. PACK_IOS_CMD=
  1249. when ($OS_IOS && $BUILD_IOS_APP) {
  1250. PACK_IOS_CMD=$YMAKE_PYTHON ${input:"build/scripts/pack_ios.py"} --binary $TARGET --target $TARGET --temp-dir $BINDIR $PEERS
  1251. }
  1252. LINK_BOOSTTEST_CMD=
  1253. BOOST_TEST_TYPE_STRING=
  1254. when ($BOOSTTEST_IS_FAT_OBJECT) {
  1255. LINK_BOOSTTEST_CMD=$LINK_RECURSIVE_LIBRARY
  1256. BOOST_TEST_TYPE_STRING=no.test
  1257. }
  1258. otherwise {
  1259. LINK_BOOSTTEST_CMD=$LINK_EXE
  1260. BOOST_TEST_TYPE_STRING=boost.test
  1261. }
  1262. # tag:deprecated
  1263. ### @usage: BOOSTTEST([name]) #deprecated
  1264. ###
  1265. ### Test module based on boost/test/unit_test.hpp.
  1266. ### As with entire boost library usage of this technology is deprecated in Arcadia and restricted with configuration error in most of projects.
  1267. ### No new module of this type should be introduced unless it is explicitly approved by C++ committee.
  1268. module BOOSTTEST: _BASE_PROGRAM {
  1269. .NODE_TYPE=Program
  1270. .FINAL_TARGET=no
  1271. .CMD=LINK_BOOSTTEST_CMD
  1272. PEERDIR(library/cpp/testing/boost_test)
  1273. when ($BOOSTTEST_IS_FAT_OBJECT) {
  1274. MODULE_SUFFIX=.a
  1275. }
  1276. elsewhen ($OS_IOS && $BUILD_IOS_APP) {
  1277. PEERDIR+=devtools/boosttest_ios_wrapper/library
  1278. MODULE_SUFFIX=.ios.tar
  1279. }
  1280. ADD_YTEST($MODULE_PREFIX$REALPRJNAME $BOOST_TEST_TYPE_STRING)
  1281. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS canondata/result.json)
  1282. _DONT_REQUIRE_LICENSE()
  1283. }
  1284. # tag:deprecated
  1285. ### @usage BOOSTTEST_WITH_MAIN([name]) #deprecated
  1286. ###
  1287. ### Same as BOOSTTEST (see above), but comes with builtin int main(argc, argv) implementation
  1288. module BOOSTTEST_WITH_MAIN: BOOSTTEST {
  1289. PEERDIR(library/cpp/testing/boost_test_main)
  1290. }
  1291. FUZZ_DICTS_VALUE=
  1292. ### @usage: FUZZ_DICTS(path1 [path2...])
  1293. ###
  1294. ### Allows you to specify dictionaries, relative to the root of Arcadia, which will be used in Fuzzing.
  1295. ### Libfuzzer and AFL use a single syntax for dictionary descriptions.
  1296. ### Should only be used in FUZZ modules.
  1297. ###
  1298. ### Documentation: https://wiki.yandex-team.ru/yatool/fuzzing/
  1299. macro FUZZ_DICTS(Data...) {
  1300. SET_APPEND(FUZZ_DICTS_VALUE $Data)
  1301. }
  1302. FUZZ_OPTS_VALUE=
  1303. ### @usage: FUZZ_OPTS(opt1 [Opt2...])
  1304. ###
  1305. ### Overrides or adds options to the corpus mining and fuzzer run.
  1306. ### Currently supported only Libfuzzer, so you should use the options for it.
  1307. ### Should only be used in FUZZ modules.
  1308. ###
  1309. ### @example:
  1310. ###
  1311. ### FUZZ_OPTS (
  1312. ### -max_len=1024
  1313. ### -rss_limit_mb=8192
  1314. ### )
  1315. ###
  1316. ### Documentation: https://wiki.yandex-team.ru/yatool/fuzzing/
  1317. macro FUZZ_OPTS(Data...) {
  1318. SET_APPEND(FUZZ_OPTS_VALUE $Data)
  1319. }
  1320. # tag:yt-specific tag:test
  1321. TEST_YT_SPEC_VALUE=
  1322. ### @usage: YT_SPEC(path1 [path2...])
  1323. ###
  1324. ### Allows you to specify json-files with YT task and operation specs,
  1325. ### which will be used to run test node in the YT.
  1326. ### Test must be marked with ya:yt tag.
  1327. ### Files must be relative to the root of Arcadia.
  1328. ###
  1329. ### Documentation: https://wiki.yandex-team.ru/yatool/test/
  1330. macro YT_SPEC(Data...) {
  1331. SET_APPEND(TEST_YT_SPEC_VALUE $Data)
  1332. }
  1333. # tag:test
  1334. TEST_SRCS_VALUE=
  1335. ### @usage: TEST_SRCS(Files...)
  1336. ###
  1337. ### 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.
  1338. ###
  1339. ### Documentation: https://wiki.yandex-team.ru/yatool/test/#testynapytest
  1340. macro TEST_SRCS(Tests...) {
  1341. SET_APPEND(TEST_SRCS_VALUE $Tests)
  1342. }
  1343. macro DISABLE_DATA_VALIDATION() {
  1344. DISABLE(VALIDATE_DATA)
  1345. }
  1346. # tag:test
  1347. TEST_DATA_VALUE=
  1348. ### @usage: DATA([path...])
  1349. ###
  1350. ### Specifies the path to the data necessary test.
  1351. ### Valid values are: arcadia/<path> , arcadia_tests_data/<path> and sbr://<resource_id>.
  1352. ### In the latter case resource will be brought to the working directory of the test before it is started
  1353. ###
  1354. ### Used only inside TEST modules.
  1355. ###
  1356. ### Documentation: https://wiki.yandex-team.ru/yatool/test/#dannyeizrepozitorija
  1357. macro DATA(Data...) {
  1358. SET_APPEND(TEST_DATA_VALUE $Data)
  1359. ADD_CHECK(check.data $Data)
  1360. }
  1361. # tag:test
  1362. ### @usage: DATA_FILES([path...])
  1363. ###
  1364. ### Specifies the path to the arcadia source data necessary test.
  1365. ### Used only inside TEST modules.
  1366. ###
  1367. ### Documentation: https://wiki.yandex-team.ru/yatool/test/#dannyeizrepozitorija
  1368. macro DATA_FILES(Paths...) {
  1369. SET_APPEND(TEST_DATA_VALUE ${pre=arcadia/:Paths})
  1370. _DATA_FILES($Paths)
  1371. }
  1372. # tag:test
  1373. ### @usage: EXPLICIT_DATA()
  1374. ###
  1375. ### Disables implicit macro DATA(<module_path>).
  1376. ADD_SRCDIR_TO_TEST_DATA=yes
  1377. macro EXPLICIT_DATA() {
  1378. SET(ADD_SRCDIR_TO_TEST_DATA no)
  1379. }
  1380. # tag:test
  1381. TEST_TAGS_VALUE=
  1382. ### @usage: TAG ([tag...])
  1383. ###
  1384. ### Each test can have one or more tags used to filter tests list for running.
  1385. ### There are also special tags affecting test behaviour, for example ya:external, sb:ssd.
  1386. ###
  1387. ### Documentation: https://wiki.yandex-team.ru/yatool/test/#obshhieponjatija
  1388. macro TAG(Tags...) {
  1389. SET_APPEND(TEST_TAGS_VALUE $Tags)
  1390. }
  1391. # tag:test
  1392. TEST_REQUIREMENTS_VALUE=
  1393. ### @usage: REQUIREMENTS([cpu:<count>] [disk_usage:<size>] [ram:<size>] [ram_disk:<size>] [container:<id>] [network:<restricted|full>] [dns:dns64])
  1394. ###
  1395. ### Allows you to specify the requirements of the test.
  1396. ###
  1397. ### Documentation about the Arcadia test system: https://wiki.yandex-team.ru/yatool/test/
  1398. macro REQUIREMENTS(Tags...) {
  1399. SET_APPEND(TEST_REQUIREMENTS_VALUE $Tags)
  1400. }
  1401. # tag:test
  1402. TEST_ENV_VALUE=
  1403. ### @usage: ENV(key[=value])
  1404. ###
  1405. ### Sets env variable key to value (gets value from system env by default).
  1406. macro ENV(Data...) {
  1407. SET_APPEND(TEST_ENV_VALUE ${quo:Data})
  1408. }
  1409. ### @usage: CONFTEST_LOAD_POLICY_LOCAL()
  1410. ###
  1411. ### Loads conftest.py files in a way that pytest does it
  1412. macro CONFTEST_LOAD_POLICY_LOCAL() {
  1413. SET_APPEND(TEST_ENV_VALUE "CONFTEST_LOAD_POLICY=LOCAL")
  1414. }
  1415. # tag:test
  1416. TEST_RECIPES_VALUE=
  1417. ### @usage: USE_RECIPE(path [arg1 arg2...])
  1418. ###
  1419. ### Provides prepared environment via recipe for test.
  1420. ###
  1421. ### Documentation: https://wiki.yandex-team.ru/yatool/test/recipes
  1422. macro USE_RECIPE(Data...) {
  1423. SET_APPEND(TEST_RECIPES_VALUE $Data)
  1424. SET_APPEND(TEST_RECIPES_VALUE "USE_RECIPE_DELIM")
  1425. }
  1426. # tag:python-specific tag:test
  1427. TEST_PYTHON_PATH_VALUE=
  1428. # tag:python-specific tag:test
  1429. ### @usage: PYTHON_PATH(Path)
  1430. ###
  1431. ### Set path to Python that will be used to runs scripts in tests
  1432. macro PYTHON_PATH(Path) {
  1433. SET(TEST_PYTHON_PATH_VALUE $Path)
  1434. }
  1435. # tag:test
  1436. SKIP_TEST_VALUE=
  1437. ### @usage: SKIP_TEST(Reason)
  1438. ###
  1439. ### Skip the suite defined by test module. Provide a reason to be output in test execution report.
  1440. macro SKIP_TEST(Reason...) {
  1441. SET(SKIP_TEST_VALUE $Reason)
  1442. }
  1443. # tag:test
  1444. LINT_LEVEL_VALUE=extended
  1445. _NO_LINT_VALUE=
  1446. ### @usage: NO_LINT([ktlint])
  1447. ###
  1448. ### Do not check for style files included in PY_SRCS, TEST_SRCS, JAVA_SRCS.
  1449. ### Ktlint can be disabled using NO_LINT(ktlint) explicitly.
  1450. macro NO_LINT(ktlint?"ktlint":"none") {
  1451. SET(_NO_LINT_VALUE ${ktlint})
  1452. }
  1453. ### @usage: LINT(<none|base|strict|extended>)
  1454. ###
  1455. ### Set linting level for sources of the module
  1456. macro LINT(level) {
  1457. SET(LINT_LEVEL_VALUE $level)
  1458. }
  1459. # tag:cpp-specific tag:test
  1460. module CPP_STYLE_TEST_16: PY3TEST_BIN {
  1461. DEPENDS(contrib/libs/clang16/tools/clang-format)
  1462. PEERDIR+=library/python/cpp_test
  1463. }
  1464. macro STYLE(Globs...) {
  1465. _GLOB(STYLE_SRCS_GLOB ${pre=${ARCADIA_ROOT}:Globs})
  1466. _STYLE(${STYLE_SRCS_GLOB})
  1467. }
  1468. # tag:test
  1469. ### @usage: EXECTEST()
  1470. ###
  1471. ### Module definition of generic test that executes a binary.
  1472. ### Use macro RUN to specify binary to run.
  1473. ###
  1474. ### @example:
  1475. ###
  1476. ### EXECTEST()
  1477. ### OWNER(g:yatool)
  1478. ###
  1479. ### RUN(
  1480. ### cat input.txt
  1481. ### )
  1482. ### DATA(
  1483. ### arcadia/devtools/ya/test/tests/exectest/data
  1484. ### )
  1485. ### DEPENDS(
  1486. ### devtools/dummy_arcadia/cat
  1487. ### )
  1488. ### TEST_CWD(devtools/ya/test/tests/exectest/data)
  1489. ### END()
  1490. ###
  1491. ### More examples: https://wiki.yandex-team.ru/yatool/test/#exec-testy
  1492. ###
  1493. ### @see: [RUN()](#macro_RUN)
  1494. module EXECTEST: _BARE_UNIT {
  1495. .NODE_TYPE=Program
  1496. .FINAL_TARGET=no
  1497. .ALLOWED=YT_SPEC
  1498. .RESTRICTED=FORK_TEST_FILES
  1499. .DEFAULT_NAME_GENERATOR=FullPath
  1500. .ARGS_PARSER=Base
  1501. SET(MODULE_SUFFIX .pkg.fake)
  1502. SETUP_EXECTEST()
  1503. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS canondata/result.json)
  1504. }
  1505. # tag:cpp-specific tag:test
  1506. ### @usage: Y_BENCHMARK([benchmarkname])
  1507. ###
  1508. ### Benchmark test based on the library/cpp/testing/benchmark.
  1509. ###
  1510. ### For more details see: https://wiki.yandex-team.ru/yatool/test/#zapuskbenchmark
  1511. module Y_BENCHMARK: PROGRAM {
  1512. .SEM=CPP_PROGRAM_SEM
  1513. PEERDIR(library/cpp/testing/benchmark/main)
  1514. ADD_YTEST($MODULE_PREFIX$REALPRJNAME y_benchmark)
  1515. }
  1516. GBENCH_SEM=$CPP_PROGRAM_SEM \
  1517. && add_test NAME $REALPRJNAME COMMAND $REALPRJNAME \
  1518. && target_commands-ITEM && target_commands-macro add_test && target_commands-args NAME $REALPRJNAME COMMAND $REALPRJNAME \
  1519. && set_property TEST $REALPRJNAME PROPERTY LABELS SMALL $FILTER_ONLY_TEST_TAGS \
  1520. && target_commands-ITEM && target_commands-macro set_property && target_commands-args TEST $REALPRJNAME PROPERTY LABELS SMALL $FILTER_ONLY_TEST_TAGS \
  1521. && add_test_requirements $REALPRJNAME $DEFAULT_REQUIREMENTS $TEST_REQUIREMENTS_VALUE \
  1522. $_TEST_TIMEOUT_SEM
  1523. # tag:cpp-specific tag:test
  1524. ### @usage: G_BENCHMARK([benchmarkname])
  1525. ###
  1526. ### Benchmark test based on the google benchmark.
  1527. ###
  1528. ### For more details see: https://a.yandex-team.ru/arc/trunk/arcadia/contrib/libs/benchmark/README.md
  1529. module G_BENCHMARK: _BASE_PROGRAM {
  1530. .SEM=GBENCH_SEM
  1531. .ALLOWED=YT_SPEC
  1532. PEERDIR(library/cpp/testing/gbenchmark)
  1533. ADD_YTEST($MODULE_PREFIX$REALPRJNAME g_benchmark)
  1534. }
  1535. BENCHMARK_OPTS_VALUE=
  1536. ### @usage: BENCHMARK_OPTS(opt1 [opt2...])
  1537. ###
  1538. ### Allows to specify extra args to benchmark binary.
  1539. ### Supported for G_BENCHMARK and Y_BENCHMARK
  1540. ###
  1541. ### @example:
  1542. ### BENCHMARK_OPTS (
  1543. ### --benchmark_min_time=0
  1544. ### )
  1545. ###
  1546. ### Documentation: https://docs.yandex-team.ru/ya-make/manual/tests/benchmark
  1547. macro BENCHMARK_OPTS(Data...) {
  1548. SET_APPEND(BENCHMARK_OPTS_VALUE $Data)
  1549. }
  1550. # tag:test
  1551. TEST_ROOT=$(TESTS_DATA_ROOT)
  1552. RESULT_MAX_FILE=0
  1553. STRIP_FILES=--dont-strip-files
  1554. VERIFY_RESULTS=--verify-results
  1555. ADDITIONAL_PATH=
  1556. # set for tests variables to fill it by YA_DEV or YA
  1557. YA_ROOT=ya
  1558. when ($YA_DEV == "yes") {
  1559. YA_ROOT=ya-dev
  1560. }
  1561. # tag:test
  1562. ### @usage: UNITTEST_FOR(path/to/lib)
  1563. ###
  1564. ### Convenience extension of UNITTEST module.
  1565. ### The UNINTTEST module with additional SRCDIR + ADDINCL + PEERDIR on path/to/lib.
  1566. ### path/to/lib is the path to the directory with the LIBRARY project.
  1567. ###
  1568. ### Documentation about the Arcadia test system: https://wiki.yandex-team.ru/yatool/test/
  1569. module UNITTEST_FOR: UNITTEST {
  1570. .SEM=UNITTEST_SEM
  1571. PEERDIR(ADDINCL $UNITTEST_DIR)
  1572. SRCDIR($UNITTEST_DIR)
  1573. }
  1574. ### @usage: _LIBRARY # internal
  1575. ###
  1576. ### Base module definition for all libraries.
  1577. ### Contains basic logic like module properties, default variable values etc.
  1578. ### All libraries similar to C++-libraries should be inherited from it.
  1579. module _LIBRARY: _BASE_UNIT {
  1580. .CMD=LINK_LIB
  1581. .NODE_TYPE=Library
  1582. .PEERDIR_POLICY=as_include
  1583. .EXTS=.o .obj .a .mf .supp .tidyjson .ld .lib
  1584. .ALLOWED=GRPC USE_SKIFF EXTRALIBS OBJADDE_GLOBAL RESOURCE_FILES
  1585. .GLOBAL=USER_CFLAGS USER_CXXFLAGS USER_CONLYFLAGS LDFLAGS SRCS _WHOLE_ARCHIVE_LIBS_VALUE RPATH OBJADDE_LIB
  1586. .RESTRICTED=ALLOCATOR SIZE TAG DATA TEST_DATA DEPENDS FORK_TESTS FORK_SUBTESTS SPLIT_FACTOR TEST_CWD RUN TIMEOUT SPLIT_DWARF
  1587. .ALIASES=EXTRALIBS=PY_EXTRALIBS
  1588. .FINAL_TARGET=no
  1589. .GLOBAL_CMD=GLOBAL_LINK_LIB
  1590. .GLOBAL_EXTS=.o .obj .tidyjson
  1591. GLOBAL_SUFFIX=.global$MODULE_SUFFIX
  1592. #TODO: Remove this hack (really we do not need add fake src at all)
  1593. ENABLE(NEED_ADD_FAKE_SRC)
  1594. CHECK_CONTRIB_CREDITS(contrib/clickhouse contrib/libs contrib/deprecated EXCEPT contrib/deprecated/python)
  1595. when ($USE_MKL == "yes") {
  1596. NOPLATFORM=yes
  1597. }
  1598. when ($MSVC == "yes" || $CYGWIN == "yes") {
  1599. MODULE_PREFIX=
  1600. MODULE_SUFFIX=.lib
  1601. }
  1602. elsewhen ($TIDY_ENABLED == "yes") {
  1603. MODULE_PREFIX=
  1604. MODULE_SUFFIX=.tidyjson
  1605. }
  1606. otherwise {
  1607. MODULE_PREFIX=lib
  1608. MODULE_SUFFIX=.a
  1609. }
  1610. when ($WERROR != "no") {
  1611. when ($WERROR_MODE == "all" || ($WERROR_MODE == "compiler_specific" && $WERROR == "yes")) {
  1612. C_WARNING_OPTS += $WERROR_FLAG
  1613. }
  1614. }
  1615. when ($WITH_VALGRIND == "yes") {
  1616. PEERDIR+=contrib/libs/valgrind
  1617. # https://st.yandex-team.ru/DTCC-1227
  1618. CFLAGS+=-fdebug-default-version=4
  1619. }
  1620. }
  1621. CPP_LIBRARY_INDUCED_SEM_PROPERTY=consumer_link_library
  1622. CPP_LIBRARY_INDUCED_LINKS=link-publics
  1623. CPP_LIBRARY_SEM=add_library ${MODDIR} $CMAKE_TARGET_NAME ${hide:TARGET} ${hide:AUTO_INPUT} $CMAKE_TARGET_ARTEFACT_RENAME_RULES \
  1624. && library_fake_marker FAKE_MODULE ${FAKE_MODULE} \
  1625. && is_fake_module ${FAKE_MODULE} \
  1626. && ${CPP_LIBRARY_INDUCED_SEM_PROPERTY} PUBLIC $CMAKE_LINK_TARGET \
  1627. && ${CPP_LIBRARY_INDUCED_LINKS} $CMAKE_LINK_TARGET \
  1628. && target_include_directories PUBLIC $_C__INCLUDE_GLOBAL \
  1629. && target_options-publics-ITEM && target_options-publics-option target_include_directories && target_options-publics-args $_C__INCLUDE_GLOBAL \
  1630. && target_include_directories PRIVATE $_C__INCLUDE_OWNED \
  1631. && target_options-privates-ITEM && target_options-privates-option target_include_directories && target_options-privates-args $_C__INCLUDE_OWNED \
  1632. && target_compile_options PRIVATE $USER_CFLAGS $USER_CXXFLAGS $_SEM_EXTRA_CXX_FLAGS \
  1633. && target_options-privates-ITEM && target_options-privates-option target_compile_options && target_options-privates-args $USER_CFLAGS $USER_CXXFLAGS $_SEM_EXTRA_CXX_FLAGS \
  1634. && target_compile_options PUBLIC $USER_CFLAGS_GLOBAL_RAW $USER_CXXFLAGS_GLOBAL_RAW \
  1635. && target_options-publics-ITEM && target_options-publics-option target_compile_options && target_options-publics-args $USER_CFLAGS_GLOBAL_RAW $USER_CXXFLAGS_GLOBAL_RAW \
  1636. && target_link_options INTERFACE $LDFLAGS_GLOBAL_RAW \
  1637. && target_options-interfaces-ITEM && target_options-interfaces-option target_link_options && target_options-interfaces-args $LDFLAGS_GLOBAL_RAW \
  1638. && add_language C && add_language CXX \
  1639. && project_languages C && project_languages CXX \
  1640. && target_sources PRIVATE ${MODULE_EXPLICIT_HEADERS} \
  1641. && target_options-privates-ITEM && target_options-privates-option target_sources && target_options-privates-args ${MODULE_EXPLICIT_HEADERS}
  1642. CPP_OBJ_LIBRARY_SEM=add_global_library_for ${MODDIR} ${suf=.global:CMAKE_TARGET_NAME} $CMAKE_TARGET_NAME ${hide:GLOBAL_TARGET} ${hide:AUTO_INPUT} \
  1643. && target_include_directories PUBLIC $_C__INCLUDE_GLOBAL \
  1644. && target_options-publics-ITEM && target_options-publics-option target_include_directories && target_options-publics-args $_C__INCLUDE_GLOBAL \
  1645. && target_include_directories PRIVATE $_C__INCLUDE_OWNED \
  1646. && target_options-privates-ITEM && target_options-privates-option target_include_directories && target_options-privates-args $_C__INCLUDE_OWNED \
  1647. && target_compile_options PRIVATE $USER_CFLAGS $USER_CXXFLAGS $_SEM_EXTRA_CXX_FLAGS \
  1648. && target_options-privates-ITEM && target_options-privates-option target_compile_options && target_options-privates-args $USER_CFLAGS $USER_CXXFLAGS $_SEM_EXTRA_CXX_FLAGS \
  1649. && target_compile_options PUBLIC $USER_CFLAGS_GLOBAL_RAW $USER_CXXFLAGS_GLOBAL_RAW \
  1650. && target_options-publics-ITEM && target_options-publics-option target_compile_options && target_options-publics-args $USER_CFLAGS_GLOBAL_RAW $USER_CXXFLAGS_GLOBAL_RAW
  1651. CMAKE_FIND_PKG=
  1652. CMAKE_LINK_TARGET=$REALPRJNAME
  1653. CMAKE_FIND_PKG_COMP=
  1654. CONAN_REQUIRE=
  1655. CONAN_OPTS_SEM=
  1656. ### @usage: LIBRARY()
  1657. ###
  1658. ### The regular static library module.
  1659. ###
  1660. ### The LIBRARY() is intermediate module, so when built directly it won't build its dependencies.
  1661. ### It transitively provides its PEERDIRs to ultimate final target, where all LIBRARY() modules are built and linked together.
  1662. ###
  1663. ### This is C++ library, and it selects peers from multimodules accordingly.
  1664. ###
  1665. ### It makes little sense to mention LIBRARY in DEPENDS or BUNDLE, package and deploy it since it is not a standalone entity.
  1666. ### In order to use library in tests PEERDIR it to link into tests.
  1667. ### If you think you need to distribute static library please contact devtools@ for assistance.
  1668. module LIBRARY: _LIBRARY {
  1669. .GLOBAL=_AARS _PROGUARD_RULES
  1670. .SEM=CPP_LIBRARY_SEM
  1671. .ALIASES=EXTRALIBS=PY_EXTRALIBS
  1672. .GLOBAL_SEM=CPP_OBJ_LIBRARY_SEM
  1673. .DEFAULT_NAME_GENERATOR=ThreeDirNames
  1674. .ARGS_PARSER=Base
  1675. when ($CMAKE_PACKAGE_COMPONENT != "") {
  1676. CMAKE_FIND_PKG_COMP=COMPONENTS $CMAKE_PACKAGE_COMPONENT && packages-components $CMAKE_PACKAGE_COMPONENT && mpackages-components $CMAKE_PACKAGE_COMPONENT
  1677. }
  1678. when ($CMAKE_PACKAGE != "") {
  1679. CMAKE_FIND_PKG=packages-ITEM && packages-name $CMAKE_PACKAGE && mpackages-ITEM && mpackages-name $CMAKE_PACKAGE && find_package $CMAKE_PACKAGE $CMAKE_FIND_PKG_COMP
  1680. CPP_LIBRARY_SEM=$CMAKE_FIND_PKG && ${CPP_LIBRARY_INDUCED_SEM_PROPERTY} PUBLIC $CMAKE_LINK_TARGET && ${CPP_LIBRARY_INDUCED_LINKS} $CMAKE_LINK_TARGET $CONAN_REQUIRE $CONAN_OPTS_SEM && IGNORED
  1681. }
  1682. when ($CONAN_REFERENCE != "") {
  1683. CONAN_REQUIRE=&& conan_require $CONAN_REFERENCE
  1684. CPP_LIBRARY_SEM=$CMAKE_FIND_PKG && ${CPP_LIBRARY_INDUCED_SEM_PROPERTY} PUBLIC $CMAKE_LINK_TARGET && ${CPP_LIBRARY_INDUCED_LINKS} $CMAKE_LINK_TARGET $CONAN_REQUIRE $CONAN_OPTS_SEM && IGNORED
  1685. }
  1686. when ($CONAN_PKG_OPTS != "") {
  1687. CONAN_OPTS_SEM=&& conan_options $CONAN_PKG_OPTS && conan-options $CONAN_PKG_OPTS
  1688. }
  1689. when ($OPENSOURCE_EXPORT == "no") {
  1690. CPP_LIBRARY_SEM=IGNORED
  1691. }
  1692. when ($HAS_CPP_PROTOBUF_PEERS == "yes") {
  1693. PEERDIR+=$CPP_PROTOBUF_PEERS
  1694. }
  1695. SET(MODULE_TYPE LIBRARY)
  1696. SET(MODULE_LANG CPP)
  1697. ADD_CLANG_TIDY()
  1698. when ($TIDY_ENABLED == "yes") {
  1699. _MAKEFILE_INCLUDE_LIKE_DEPS+=${ARCADIA_ROOT}/build/yandex_specific/config/clang_tidy/tidy_project_map.json
  1700. _MAKEFILE_INCLUDE_LIKE_DEPS+=${ARCADIA_ROOT}/build/yandex_specific/config/clang_tidy/tidy_default_map.json
  1701. }
  1702. }
  1703. # tag:internal
  1704. ### @usage: _BARE_MODULE() # internal
  1705. ###
  1706. ### Remove unwanted dependencies for "empty" library module
  1707. macro _BARE_MODULE() {
  1708. SET(NEED_PLATFORM_PEERDIRS no)
  1709. SET(PEERDIR_TEST_TOOL no)
  1710. DISABLE(WITH_VALGRIND)
  1711. NO_CODENAVIGATION()
  1712. NO_PLATFORM()
  1713. NO_RUNTIME()
  1714. NO_UTIL()
  1715. NO_CLANG_TIDY()
  1716. }
  1717. # tag:internal
  1718. ### @usage: _BARE_LINK_MODULE() # internal
  1719. ###
  1720. ### Remove unwanted dependencies for "empty" link module
  1721. macro _BARE_LINK_MODULE() {
  1722. _BARE_MODULE()
  1723. DISABLE(COMMON_LINK_SETTINGS)
  1724. ALLOCATOR(FAKE)
  1725. }
  1726. # tag:internal
  1727. ### @usage: _CONDITIONAL_SRCS([USE_CONDITIONAL_SRCS] Files...) # internal
  1728. ###
  1729. ### Adds Files... to SRCS if first word is `USE_CONDITIONAL_SRCS`
  1730. ### To be used with some variable which is set to `USE_CONDITIONAL_SRCS` under condition
  1731. macro _CONDITIONAL_SRCS(USE_CONDITIONAL_SRCS[], DYMMY...) {
  1732. SRCS($USE_CONDITIONAL_SRCS)
  1733. }
  1734. # XXX: dirty hack for correct LDFLAGS passing
  1735. RESOURCES_LIBRARY_LINK=$TOUCH_UNIT
  1736. RESOURCES_LIBRARY_SEM=IGNORED
  1737. ### @usage: RESOURCES_LIBRARY()
  1738. ###
  1739. ### Definition of a module that brings its content from external source (Sandbox) via DECLARE_EXTERNAL_RESOURCE macro.
  1740. ### This can participate in PEERDIRs of others as library but it cannot have own sources and PEERDIRs.
  1741. ###
  1742. ### @see: [DECLARE_EXTERNAL_RESOURCE()](#macro_DECLARE_EXTERNAL_RESOURCE)
  1743. module RESOURCES_LIBRARY: _BARE_UNIT {
  1744. .CMD=RESOURCES_LIBRARY_LINK
  1745. .SEM=RESOURCES_LIBRARY_SEM
  1746. .ALLOWED=DECLARE_EXTERNAL_RESOURCE EXTRALIBS OBJADDE_GLOBAL
  1747. .RESTRICTED=ALLOCATOR SIZE TAG DATA TEST_DATA DEPENDS FORK_TESTS FORK_SUBTESTS SPLIT_FACTOR TEST_CWD RUN TIMEOUT SRC SRCS SPLIT_DWARF
  1748. .ALIASES=EXTRALIBS=PY_EXTRALIBS
  1749. .NODE_TYPE=Library
  1750. .PEERDIR_POLICY=as_include
  1751. .EXTS=.o .obj .a .mf .supp .tidyjson .ld .lib
  1752. .GLOBAL=USER_CFLAGS USER_CXXFLAGS USER_CONLYFLAGS LDFLAGS _WHOLE_ARCHIVE_LIBS_VALUE RPATH OBJADDE_LIB
  1753. SET(MODULE_TAG RESOURCE_LIB)
  1754. SET(PEERDIR_TAGS RESOURCE_LIB)
  1755. when ($CMAKE_PACKAGE_COMPONENT != "") {
  1756. CMAKE_FIND_PKG_COMP=COMPONENTS $CMAKE_PACKAGE_COMPONENT && packages-components $CMAKE_PACKAGE_COMPONENT && mpackages-components $CMAKE_PACKAGE_COMPONENT
  1757. }
  1758. when ($CMAKE_PACKAGE != "") {
  1759. CMAKE_FIND_PKG=packages-ITEM && packages-name $CMAKE_PACKAGE && mpackages-ITEM && mpackages-name $CMAKE_PACKAGE && find_package $CMAKE_PACKAGE $CMAKE_FIND_PKG_COMP
  1760. RESOURCES_LIBRARY_SEM=$CMAKE_FIND_PKG && ${CPP_LIBRARY_INDUCED_SEM_PROPERTY} PUBLIC $CMAKE_LINK_TARGET && ${CPP_LIBRARY_INDUCED_LINKS} $CMAKE_LINK_TARGET $CONAN_REQUIRE $CONAN_OPTS_SEM && IGNORED
  1761. }
  1762. when ($CONAN_REFERENCE != "") {
  1763. CONAN_REQUIRE=&& conan_require $CONAN_REFERENCE
  1764. RESOURCES_LIBRARY_SEM=$CMAKE_FIND_PKG && ${CPP_LIBRARY_INDUCED_SEM_PROPERTY} PUBLIC $CMAKE_LINK_TARGET && ${CPP_LIBRARY_INDUCED_LINKS} $CMAKE_LINK_TARGET $CONAN_REQUIRE $CONAN_OPTS_SEM && IGNORED
  1765. }
  1766. when ($CONAN_PKG_OPTS != "") {
  1767. CONAN_OPTS_SEM=&& conan_options $CONAN_PKG_OPTS && conan-options $CONAN_PKG_OPTS
  1768. }
  1769. MODULE_SUFFIX=.pkg.fake
  1770. ENABLE(NEED_ADD_FAKE_SRC)
  1771. WITHOUT_LICENSE_TEXTS()
  1772. }
  1773. FAT_OBJECT_SEM=add_fat_object ${MODDIR} ${CMAKE_TARGET_NAME} ${hide:TARGET} ${hide:AUTO_INPUT} ${CMAKE_TARGET_ARTEFACT_RENAME_RULES} \
  1774. && target_include_directories PRIVATE $_C__INCLUDE_OWNED \
  1775. && target_options-privates-ITEM && target_options-privates-option target_include_directories && target_options-privates-args $_C__INCLUDE_OWNED \
  1776. && target_compile_options PRIVATE $USER_CFLAGS $USER_CXXFLAGS $_SEM_EXTRA_CXX_FLAGS \
  1777. && target_options-privates-ITEM && target_options-privates-option target_compile_options && target_options-privates-args $USER_CFLAGS $USER_CXXFLAGS $_SEM_EXTRA_CXX_FLAGS \
  1778. && set_global_flags FAT_OBJECT_PREFIX ${MODULE_PREFIX} \
  1779. && set_global_flags FAT_OBJECT_SUFFIX ${MODULE_SUFFIX} \
  1780. && platform_vars-FAT_OBJECT_PREFIX ${quo:MODULE_PREFIX} \
  1781. && platform_vars-FAT_OBJECT_SUFFIX ${quo:MODULE_SUFFIX}
  1782. ### Do not turn visibility=hidden symbos into static symbos of partially linked object file
  1783. ###
  1784. ### Note: This variable do not have any effect on platforms other than MacOS and iOS.
  1785. KEEP_FAT_OBJECT_SYMBOLS=no
  1786. ### @usage: FAT_OBJECT()
  1787. ###
  1788. ### The "fat" object module. It will contain all its transitive dependencies reachable by PEERDIRs:
  1789. ### static libraries, local (from own SRCS) and global (from peers') object files.
  1790. ###
  1791. ### Designed for use in XCode projects for iOS.
  1792. module FAT_OBJECT: LIBRARY {
  1793. .ALLOWED=PACK_GLOBALS_IN_LIBRARY
  1794. .CMD=LINK_FAT_OBJECT
  1795. .SEM=FAT_OBJECT_SEM
  1796. .PEERDIR_POLICY=as_build_from
  1797. when ($MSVC == "yes" || $CYGWIN == "yes") {
  1798. MODULE_SUFFIX=.lib
  1799. }
  1800. otherwise {
  1801. MODULE_SUFFIX=.a
  1802. }
  1803. when (($OS_DARWIN == "yes" || $OS_IOS == "yes") && $KEEP_FAT_OBJECT_SYMBOLS == "yes") {
  1804. LDFLAGS_GLOBAL += -keep_private_externs
  1805. }
  1806. when ($OS_IOS == "yes" || $OS_ANDROID == "yes" || $MAPSMOBI_BUILD_TARGET == "yes") {
  1807. MODULE_LICENSES_RESTRICTION_TYPES = ALLOW_ONLY
  1808. MODULE_LICENSES_RESTRICTIONS = SERVICE REQUIRE_CITATION
  1809. }
  1810. # FIXME: This is weird legacy
  1811. when ($OS_ANDROID == "yes") {
  1812. MODULE_PREFIX=lib
  1813. }
  1814. otherwise {
  1815. MODULE_PREFIX=
  1816. }
  1817. _USE_LINKER()
  1818. # This module requires at least one .o which is not subject to removal so just add _fake_src.cpp as SRCS
  1819. # ymake's handling of NEED_ADD_FAKE_SRC may insert arbitrary command, not necessarily compilation
  1820. DISABLE(NEED_ADD_FAKE_SRC)
  1821. SRCS(build/scripts/_fake_src.cpp)
  1822. }
  1823. RECURSIVE_LIBRARY_SEM=add_recursive_library ${MODDIR} ${CMAKE_TARGET_NAME} ${hide:TARGET} ${hide:AUTO_INPUT} ${CMAKE_TARGET_ARTEFACT_RENAME_RULES} \
  1824. && target_include_directories PUBLIC $_C__INCLUDE_GLOBAL \
  1825. && target_options-publics-ITEM && target_options-publics-option target_include_directories && target_options-publics-args $_C__INCLUDE_GLOBAL \
  1826. && target_include_directories PRIVATE $_C__INCLUDE_OWNED \
  1827. && target_options-privates-ITEM && target_options-privates-option target_include_directories && target_options-privates-args $_C__INCLUDE_OWNED \
  1828. && target_compile_options PRIVATE $USER_CFLAGS $USER_CXXFLAGS $_SEM_EXTRA_CXX_FLAGS \
  1829. && target_options-privates-ITEM && target_options-privates-option target_compile_options && target_options-privates-args $USER_CFLAGS $USER_CXXFLAGS $_SEM_EXTRA_CXX_FLAGS \
  1830. && target_compile_options PUBLIC $USER_CFLAGS_GLOBAL_RAW $USER_CXXFLAGS_GLOBAL_RAW \
  1831. && target_options-publics-ITEM && target_options-publics-option target_compile_options && target_options-publics-args $USER_CFLAGS_GLOBAL_RAW $USER_CXXFLAGS_GLOBAL_RAW \
  1832. && target_link_options INTERFACE $LDFLAGS_GLOBAL_RAW \
  1833. && target_options-interfaces-ITEM && target_options-interfaces-option target_link_options && target_options-interfaces-args $LDFLAGS_GLOBAL_RAW
  1834. ### @usage: RECURSIVE_LIBRARY()
  1835. ###
  1836. ### The recursive ("fat") library module. It will contain all its transitive dependencies reachable by PEERDIRs:
  1837. ### from static libraries, local (from own SRCS) and global (from peers') object files.
  1838. ###
  1839. ### Designed for use in XCode projects for iOS.
  1840. module RECURSIVE_LIBRARY: LIBRARY {
  1841. .CMD=LINK_RECURSIVE_LIBRARY
  1842. .SEM=RECURSIVE_LIBRARY_SEM
  1843. .PEERDIR_POLICY=as_build_from
  1844. # This module requires at least one .o which is not subject to removal so just add _fake_src.cpp as SRCS
  1845. # ymake's handling of NEED_ADD_FAKE_SRC may insert arbitrary command, not necessarily compilation
  1846. DISABLE(NEED_ADD_FAKE_SRC)
  1847. SRCS(build/scripts/_fake_src.cpp)
  1848. }
  1849. _SONAME=
  1850. _EXPORT_SCRIPT_SEM=
  1851. _CLEAN_TEXTREL=
  1852. macro _ADD_DYNLYB_SEM(Libname) {
  1853. .SEM=add_shared_library ${MODDIR} ${Libname} ${hide:TARGET} ${hide:AUTO_INPUT} && target_include_directories PUBLIC $_C__INCLUDE_GLOBAL && target_options-publics-ITEM && target_options-publics-option target_include_directories && target_options-publics-args $_C__INCLUDE_GLOBAL && target_include_directories PRIVATE $_C__INCLUDE_OWNED && target_options-privates-ITEM && target_options-privates-option target_include_directories && target_options-privates-args $_C__INCLUDE_OWNED && target_compile_options PRIVATE $USER_CFLAGS $USER_CXXFLAGS $_SEM_EXTRA_CXX_FLAGS && target_options-privates-ITEM && target_options-privates-option target_compile_options && target_options-privates-args $USER_CFLAGS $USER_CXXFLAGS $_SEM_EXTRA_CXX_FLAGS && target_compile_options PUBLIC $USER_CFLAGS_GLOBAL_RAW $USER_CXXFLAGS_GLOBAL_RAW && target_options-publics-ITEM && target_options-publics-option target_compile_options && target_options-publics-args $USER_CFLAGS_GLOBAL_RAW $USER_CXXFLAGS_GLOBAL_RAW && target_link_options PRIVATE $LDFLAGS_GLOBAL_RAW $LDFLAGS $OBJADDE_LIB $OBJADDE_LIB_GLOBAL $OBJADDE && target_options-privates-ITEM && target_options-privates-option target_link_options && target_options-privates-args $LDFLAGS_GLOBAL_RAW $LDFLAGS $OBJADDE_LIB $OBJADDE_LIB_GLOBAL $OBJADDE && ${VCS_INFO_SEM} $_EXPORT_SCRIPT_SEM
  1854. }
  1855. CPP_DYN_LIBRARY_SEM=$_ADD_DYNLYB_SEM($CMAKE_TARGET_NAME) $CMAKE_TARGET_ARTEFACT_RENAME_RULES
  1856. macro CLEAN_TEXTREL() {
  1857. SET(_CLEAN_TEXTREL yes)
  1858. }
  1859. ### @usage: DLL_UNIT # internal
  1860. ###
  1861. ### Base module for all dynamically linked libraries as final artifacts.
  1862. ### Contains all general logic for such kind of modules. Supports versioning and export files.
  1863. ### Cannot participate in linking to programs, intended to be used as final artifact (packaged and deployed).
  1864. module DLL_UNIT: _LINK_UNIT {
  1865. .CMD=LINK_DYN_LIB
  1866. .SEM=CPP_DYN_LIBRARY_SEM
  1867. .NODE_TYPE=Library
  1868. .SYMLINK_POLICY=SO
  1869. .GLOBAL=USER_CFLAGS USER_CXXFLAGS USER_CONLYFLAGS LDFLAGS _WHOLE_ARCHIVE_LIBS_VALUE RPATH OBJADDE_LIB
  1870. .ALLOWED=WHOLE_ARCHIVE
  1871. .ALIASES=EXTRALIBS=PY_EXTRALIBS
  1872. .DEFAULT_NAME_GENERATOR=TwoDirNames
  1873. .ARGS_PARSER=DLL
  1874. DYNAMIC_LINK=yes
  1875. ALLOCATOR(FAKE)
  1876. SET(MODULE_TYPE DLL)
  1877. SET(MODULE_TAG DLL)
  1878. SET(MODULE_LANG CPP)
  1879. when ($EXPORTS_FILE) {
  1880. _EXPORT_SCRIPT_SEM=&& use_export_script ${input:EXPORTS_FILE} && target_macroses-ITEM && target_macroses-macro use_export_script && target_macroses-args ${input:EXPORTS_FILE}
  1881. }
  1882. when ($MSVC == "yes" || $CYGWIN == "yes") {
  1883. MODULE_SUFFIX=.dll
  1884. }
  1885. elsewhen ($DARWIN == "yes" || $OS_IOS == "yes") {
  1886. MODULE_PREFIX=lib
  1887. MODULE_SUFFIX=.dylib
  1888. }
  1889. elsewhen ($TIDY_ENABLED != "yes") {
  1890. MODULE_PREFIX=lib
  1891. MODULE_SUFFIX=.so
  1892. }
  1893. # This by now replicates ymake's behavior. We'll get rid of SONAME setting in ymake and fix this code altogether
  1894. SONAME=${pre=$MODULE_PREFIX;suf=$MODULE_SUFFIX:REALPRJNAME}
  1895. when ($MODULE_VERSION) {
  1896. LINK_DYN_LIB_FLAGS=--soname ${output;pre=$MODULE_PREFIX;suf=$MODULE_SUFFIX$MODULE_VERSION:REALPRJNAME}
  1897. }
  1898. _SONAME=$SONAME$MODULE_VERSION
  1899. when ($LINUX == "yes") {
  1900. # '-z notext' is needed for linking mkl into shared libraries
  1901. when ($_CLEAN_TEXTREL != "yes") {
  1902. LDFLAGS += -Wl,-z,notext
  1903. }
  1904. }
  1905. when ($OS_LINUX == "yes" && $ARCH_X86_64 == "yes") {
  1906. when ($_NO_FIX_ELF != "yes") {
  1907. LINK_DYN_LIB_FLAGS+=--fix-elf ${tool:"tools/fix_elf"}
  1908. }
  1909. }
  1910. when ($DARWIN == "yes") {
  1911. LDFLAGS += -undefined dynamic_lookup
  1912. }
  1913. when ($CLANG_COVERAGE && $CLANG_COVERAGE != "no") {
  1914. PEERDIR+=library/cpp/testing/dump_clang_coverage
  1915. }
  1916. when ($IDE_MSVS == "yes") {
  1917. PEERDIR+=build/scripts/c_templates
  1918. }
  1919. when ($_CUSTOM_LINK_STEP_SCRIPT) {
  1920. LINK_DYN_LIB_FLAGS+=--python=$YMAKE_PYTHON --custom-step=${input:_CUSTOM_LINK_STEP_SCRIPT}
  1921. }
  1922. }
  1923. # tag:r-specific
  1924. ### @usage: R_MODULE(name major_ver [minor_ver] [EXPORTS symlist_file] [PREFIX prefix])
  1925. ###
  1926. ### The external module for R language.
  1927. ### 1. major_ver and minor_ver must be integers.
  1928. ### 2. The resulting .so will have the prefix "lib".
  1929. ### 3. Processing EXPORTS and PREFIX is the same as for DLL module
  1930. ### This is native DLL, so it will select C++ version from PROTO_LIBRARY.
  1931. module R_MODULE: DLL_UNIT {
  1932. .SEM=CPP_DYN_LIBRARY_SEM
  1933. when ($DARWIN == "yes") {
  1934. LDFLAGS+=-flat_namespace -dynamiclib
  1935. }
  1936. when ($MSVC == "yes" || $CYGWIN == "yes") {
  1937. MODULE_PREFIX=lib
  1938. MODULE_SUFFIX=.dll
  1939. }
  1940. ADDINCL(contrib/libs/r-lang)
  1941. }
  1942. ### @usage: DYNAMIC_LIBRARY_FROM(Paths)
  1943. ###
  1944. ### Use specified libraries as sources of DLL
  1945. macro DYNAMIC_LIBRARY_FROM(Path...) {
  1946. PEERDIR($Path)
  1947. WHOLE_ARCHIVE($Path)
  1948. }
  1949. ### @usage: DLL(name major_ver [minor_ver] [EXPORTS symlist_file] [PREFIX prefix])
  1950. ###
  1951. ### Dynamic library module definition.
  1952. ### 1. major_ver and minor_ver must be integers.
  1953. ### 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
  1954. ### 3. PREFIX allows you to change the prefix of the output file (default DLL has the prefix "lib").
  1955. ###
  1956. ### DLL cannot participate in linking to programs but can be used from Java or as final artifact (packaged and deployed).
  1957. module DLL: DLL_UNIT {
  1958. .SEM=CPP_DYN_LIBRARY_SEM
  1959. SET(MAKE_ONLY_SHARED_LIB yes)
  1960. when ($OS_WINDOWS) {
  1961. MODULE_SUFFIX=.dll
  1962. }
  1963. # TODO: Make it possible to use this syntax
  1964. # DEFAULT(DLL_FOR_DIR no)
  1965. ### FIXME: XXX
  1966. ###when ($DLL_FOR_DIR != "no") {
  1967. ### SRCDIR($DLL_FOR_DIR)
  1968. ### ADDINCL($DLL_FOR_DIR)
  1969. ###}
  1970. }
  1971. ### DLL_TOOL is a DLL that can be used as a LD_PRELOAD tool.
  1972. module DLL_TOOL: DLL {
  1973. .SEM=CPP_DYN_LIBRARY_SEM
  1974. # ymake resolves only program nodes as tools.
  1975. .NODE_TYPE=Program
  1976. }
  1977. ### @usage: SO_PROGRAM(name major_ver [minor_ver] [EXPORTS symlist_file] [PREFIX prefix])
  1978. ###
  1979. ### Executable dynamic library module definition.
  1980. ### 1. major_ver and minor_ver must be integers.
  1981. ### 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
  1982. ### 3. PREFIX allows you to change the prefix of the output file.
  1983. module SO_PROGRAM: DLL {
  1984. .CMD=LINK_EXEC_DYN_LIB
  1985. SET(MODULE_TYPE PROGRAM)
  1986. MODULE_PREFIX=
  1987. when ($MSVC == "yes" || $CYGWIN == "yes") {
  1988. MODULE_SUFFIX=.exe
  1989. }
  1990. otherwise {
  1991. MODULE_SUFFIX=
  1992. }
  1993. }
  1994. DLL_PROXY_CMD_MF=$GENERATE_MF && $COPY_CMD $AUTO_INPUT $TARGET
  1995. # tag:internal
  1996. ### @usage: DEV_DLL_PROXY() # internal
  1997. ###
  1998. ### The use of this module is strictly prohibited!!!
  1999. ### This is a temporary and project-specific solution.
  2000. module DEV_DLL_PROXY: _BARE_UNIT {
  2001. .NODE_TYPE=Library
  2002. .EXTS=.so .dll .dylib .mf
  2003. .CMD=DLL_PROXY_CMD_MF
  2004. DYNAMIC_LINK=yes
  2005. when ($OS_WINDOWS == "yes") {
  2006. MODULE_SUFFIX=.dll
  2007. }
  2008. elsewhen ($DARWIN == "yes" || $OS_IOS == "yes") {
  2009. MODULE_PREFIX=lib
  2010. MODULE_SUFFIX=.dylib$MODULE_VERSION
  2011. }
  2012. otherwise {
  2013. MODULE_PREFIX=lib
  2014. MODULE_SUFFIX=.so$MODULE_VERSION
  2015. }
  2016. }
  2017. # tag:internal
  2018. ### @usage: DYNAMIC_DEPS(Path...) # internal, temporary
  2019. ###
  2020. ### Enlist paths to all DYNAMIC_LIBRARY dependencies of the DYNAMIC_LIBRARY
  2021. ### This it needed to transfer their outputs through the library to PROGRAM
  2022. ### or dependent DLL/DYNAMIC_LIBRARY.
  2023. ###
  2024. ### Note: this is temporary solution until support of `super-global` variables come
  2025. ### which will enable transfer of some properties though final targets like DLLs.
  2026. macro DYNAMIC_DEPS(Path...) {
  2027. # PEERDIR as macro completely ignored in place where this macro applies
  2028. SET_APPEND(PEERDIR $Path)
  2029. }
  2030. # tag:internal
  2031. ### @usage: DYNAMIC_LIBRARY() # internal
  2032. ###
  2033. ### The use of this module is strictly prohibited except LGPL-related opensourcing
  2034. ### This provides linkable DLL module which brings its results to programs and tests
  2035. ### for seamless testing and packaging
  2036. multimodule DYNAMIC_LIBRARY {
  2037. module DLL_BIN: DLL {
  2038. .PROXY=yes
  2039. .IGNORED=PROVIDES
  2040. SET(MODULE_TAG DLL)
  2041. }
  2042. module DLL_LIB: _DLL_COMPATIBLE_LIBRARY {
  2043. .CMD=TOUCH_UNIT_MF
  2044. .PEERDIRSELF=DLL_BIN
  2045. .IGNORED=SRCS PEERDIR RUN_PROGRAM PYTHON DYNAMIC_LIBRARY_FROM GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER USE_PYTHON2 USE_PYTHON3
  2046. .ALLOWED=DYNAMIC_DEPS
  2047. SET(PEERDIR_TAGS DLL_LIB __EMPTY__ RESOURCE_LIB)
  2048. _BARE_MODULE()
  2049. DYNAMIC_LINK=yes
  2050. MODULE_SUFFIX=.pkg.fake
  2051. PEERDIR+=build/platform/local_so
  2052. # disable credits generation for static library
  2053. SET(CREDITS_FLAGS)
  2054. }
  2055. }
  2056. ### @usage: GLOBAL_SRCS(filenames...)
  2057. ###
  2058. ### Make all source files listed as GLOBAL.
  2059. ### Call to GLOBAL_SRCS macro is equivalent to call to SRCS macro when each source file is marked with GLOBAL keyword.
  2060. ### Arcadia root relative or project dir relative paths are supported for filenames arguments. GLOBAL keyword is not
  2061. ### recognized for GLOBAL_SRCS in contrast to SRCS macro.
  2062. ###
  2063. ### @example:
  2064. ### Consider the file to ya.make:
  2065. ###
  2066. ### LIBRARY()
  2067. ### GLOBAL_SRCS(foo.cpp bar.cpp)
  2068. ### END()
  2069. ###
  2070. ### @see: [SRCS()](#macro_SRCS)
  2071. macro GLOBAL_SRCS(Files...) {
  2072. SRCS(${pre=GLOBAL :Files})
  2073. }
  2074. ### @usage: ALL_SRCS([GLOBAL] filenames...)
  2075. ###
  2076. ### Make all source files listed as GLOBAL or not depending on the keyword GLOBAL
  2077. ### Call to ALL_SRCS macro is equivalent to call to GLOBAL_SRCS macro when GLOBAL keyword is specified
  2078. ### as the first argument and is equivalent to call to SRCS macro otherwise.
  2079. ###
  2080. ### @example:
  2081. ###
  2082. ### LIBRARY()
  2083. ### SET(MAKE_IT_GLOBAL GLOBAL)
  2084. ### ALL_SRCS(${MAKE_IT_GLOBAL} foo.cpp bar.cpp)
  2085. ### END()
  2086. ###
  2087. ### @see: [GLOBAL_SRCS()](#macro_GLOBAL_SRCS), [SRCS()](#macro_SRCS)
  2088. macro ALL_SRCS(GLOBAL?"GLOBAL":"", Files...) {
  2089. SRCS(${pre=$GLOBAL :Files})
  2090. }
  2091. ### @usage: _DLL_COMPATIBLE_LIBRARY # internal
  2092. ###
  2093. ### Base module to place DLLs into multimodules back to back with libraries.
  2094. ### In order to function properly all modules in multimodule shall have the
  2095. ### same set of arguments. So this module is just library that accepts but
  2096. ### ignores all DLL arguments.
  2097. module _DLL_COMPATIBLE_LIBRARY: LIBRARY {
  2098. .DEFAULT_NAME_GENERATOR=TwoDirNames
  2099. .ARGS_PARSER=DLL
  2100. }
  2101. # as SRCS in packages use macro BUNDLE_SRCS!
  2102. PACKED_PACKAGE_ARGS=
  2103. PACKED_PACKAGE_EXT=
  2104. ### @usage: PACK(archive_type)
  2105. ###
  2106. ### 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`
  2107. ###
  2108. ### Is not allowed other module types than PACKAGE().
  2109. ###
  2110. ### @see: [PACKAGE()](#module_PACKAGE)
  2111. macro PACK(Ext) {
  2112. SET(PACKED_PACKAGE_EXT $Ext)
  2113. }
  2114. PACKAGE_STRICT_VALUE=
  2115. macro PACKAGE_STRICT() {
  2116. SET(PACKAGE_STRICT_VALUE yes)
  2117. }
  2118. ### @usage: PACKAGE(name)
  2119. ###
  2120. ### Module collects what is described directly inside it, builds and collects all its transitively available PEERDIRs.
  2121. ### 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.
  2122. ### The data can be optionally packed if macro PACK() is used.
  2123. ###
  2124. ### Is only used together with the macros FILES(), PEERDIR(), COPY(), FROM_SANDBOX(), RUN_PROGRAM or BUNDLE(). Don't use SRCS inside a PACKAGE.
  2125. ###
  2126. ### Documentation: https://wiki.yandex-team.ru/yatool/large-data/
  2127. ###
  2128. ### @see: [PACK()](#macro_PACK)
  2129. multimodule PACKAGE {
  2130. module PACKAGE_FINAL: _BASE_UNIT {
  2131. .CMD=TOUCH_PACKAGE_MF
  2132. .ALIASES=SRCS=FILES
  2133. .ALLOWED=PACK
  2134. .PEERDIRSELF=PACKAGE_UNION
  2135. .USE_PEERS_LATE_OUTS=yes
  2136. .PEERDIR_POLICY=as_build_from
  2137. .FINAL_TARGET=yes
  2138. SET(PEERDIR_TAGS CPP_PROTO CPP_FBS PY2 PY3 PY2_NATIVE PY3_NATIVE YQL_UDF_SHARED __EMPTY__ RESOURCE_LIB DOCSBOOK JAR_RUNNABLE PY3_BIN PY3TEST_PROGRAM DLL GO_PROGRAM PACKAGE_UNION)
  2139. SET(MODULE_SUFFIX .final.pkg.fake)
  2140. SET(DONT_RESOLVE_INCLUDES yes)
  2141. NO_PLATFORM()
  2142. when ($PACKED_PACKAGE_EXT) {
  2143. PACKED_PACKAGE_ARGS+=--dest-arch ${output;pre=$MODULE_PREFIX;suf=.$PACKED_PACKAGE_EXT:REALPRJNAME}
  2144. }
  2145. SET(NEED_PLATFORM_PEERDIRS no)
  2146. SET(_COPY_FILE_CONTEXT TEXT)
  2147. }
  2148. module PACKAGE_UNION: UNION {
  2149. .CMD=UNION_CMD
  2150. .FINAL_TARGET=no
  2151. .ALLOWED=PACK
  2152. .IGNORED=VCS_INFO_FILE
  2153. SET(MODULE_SUFFIX .pkg.fake)
  2154. SET(PEERDIR_TAGS CPP_PROTO CPP_FBS PY2 PY3 PY2_NATIVE PY3_NATIVE YQL_UDF_SHARED __EMPTY__ RESOURCE_LIB DOCSBOOK JAR_RUNNABLE PY3_BIN PY3TEST_PROGRAM DLL GO_PROGRAM PACKAGE_UNION)
  2155. DISABLE(START_TARGET)
  2156. SET(_COPY_FILE_CONTEXT TEXT)
  2157. }
  2158. }
  2159. TOUCH_GROUP=$TOUCH_PACKAGE ${hide;kv:"p CI"}
  2160. ### @usage: CI_GROUP()
  2161. ###
  2162. ### Module collects what is described directly inside it transitively by PEERDIRs.
  2163. ### No particular layout of built artifacts is implied. This module is needed primarily for CI dependency analysis and may not trigger builds at all.
  2164. ###
  2165. ### Is only used together with the macro PEERDIR() and FILES(). Don't use SRCS inside CI_GROUP().
  2166. module CI_GROUP: _BARE_UNIT {
  2167. .CMD=TOUCH_GROUP
  2168. .PEERDIR_POLICY=as_build_from
  2169. .FINAL_TARGET=yes
  2170. .RESTRICTED=SRCS
  2171. .USE_PEERS_LATE_OUTS=yes
  2172. MODULE_SUFFIX=.ci.pkg.fake
  2173. PEERDIR_TAGS=CPP_PROTO PY3 PY3_NATIVE PY3_BIN PY3TEST_PROGRAM YQL_UDF_SHARED __EMPTY__ RESOURCE_LIB DOCSBOOK JAR_RUNNABLE DLL
  2174. }
  2175. # tag:generic tag:internal
  2176. TOUCH_UNIT_MF=$TOUCH_UNIT && $GENERATE_MF
  2177. ### @usage: UNION(name)
  2178. ###
  2179. ### Collection of PEERDIR dependencies, files and artifacts.
  2180. ### UNION doesn't build its peers, just provides those to modules depending on it.
  2181. ### 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).
  2182. ###
  2183. ### Is only used together with the macros like FILES(), PEERDIR(), COPY(), FROM_SANDBOX(), RUN_PROGRAM or BUNDLE(). Don't use SRCS inside a UNION.
  2184. ###
  2185. ### Documentation: https://wiki.yandex-team.ru/yatool/large-data/
  2186. module UNION: _BASE_UNIT {
  2187. .CMD=UNION_CMD_MF
  2188. .FINAL_TARGET=no
  2189. .ALIASES=SRCS=FILES
  2190. .ALLOWED=EXPLICIT_OUTPUTS
  2191. .IGNORED=VCS_INFO_FILE
  2192. NO_PLATFORM()
  2193. SET(MODULE_SUFFIX .pkg.fake)
  2194. SET(DONT_RESOLVE_INCLUDES yes)
  2195. SET(NEED_PLATFORM_PEERDIRS no)
  2196. PEERDIR_TAGS=CPP_PROTO CPP_FBS PY2 PY2_NATIVE PY3_NATIVE YQL_UDF_SHARED __EMPTY__ RESOURCE_LIB DOCSBOOK JAR_RUNNABLE PY3_BIN DLL PACKAGE_UNION
  2197. UNION_OUTS=${hide;late_out:AUTO_INPUT}
  2198. when ($_UNION_EXPLICIT_OUTPUTS) {
  2199. UNION_OUTS=$_EXPAND_INS_OUTS($_UNION_EXPLICIT_OUTPUTS)
  2200. }
  2201. SET(_COPY_FILE_CONTEXT TEXT)
  2202. }
  2203. # tag:internal
  2204. ### @usage: _ADD_HIDDEN_INPUTS(inputs...) # internal
  2205. macro _ADD_HIDDEN_INPUTS(Inputs...) {
  2206. .CMD=${hide;input:Inputs}
  2207. }
  2208. # tag:internal
  2209. ### @usage: _SET_FIRST_VALUE(name args...) # internal
  2210. ###
  2211. ### This macro sets the value of `name` variable to the value of next argument
  2212. macro _SET_FIRST_VALUE(NAME, VALUE, OTHER...) {
  2213. SET($NAME $VALUE)
  2214. }
  2215. # tag:internal
  2216. ### @usage: _SRCS_NO_GLOBAL(files...) # internal
  2217. ###
  2218. ### Proxy macro to SRCS macro which filters out GLOBAL keyword from the list of source files.
  2219. ### Useful for modules like EXTERNAL_JAVA_LIBRARY, where GLOBAL keyword cannot be applied properly.
  2220. ### Note: this macro changes order of source files.
  2221. macro _SRCS_NO_GLOBAL(GLOBAL[], FILES...) {
  2222. SRCS($GLOBAL $FILES)
  2223. }
  2224. @import "${CONF_ROOT}/conf/java.conf"
  2225. @import "${CONF_ROOT}/conf/python.conf"
  2226. TEST_CWD_VALUE=
  2227. ### @usage: TEST_CWD(path)
  2228. ###
  2229. ### Defines working directory for test runs. Often used in conjunction with DATA() macro.
  2230. ### Is only used inside of the TEST modules.
  2231. ###
  2232. ### Documentation: https://wiki.yandex-team.ru/yatool/test/
  2233. macro TEST_CWD(Arg) {
  2234. SET(TEST_CWD_VALUE $Arg)
  2235. }
  2236. # tag:allocator
  2237. ### @usage: ALLOCATOR(Alloc) # Default: LF
  2238. ###
  2239. ### Set memory allocator implementation for the PROGRAM()/DLL() module.
  2240. ### This may only be specified for programs and dlls, use in other modules leads to configuration errors.
  2241. ###
  2242. ### Available allocators are: "LF", "LF_YT", "LF_DBG", "YT", "J", "B", "BM", "C", "TCMALLOC", "GOOGLE", "LOCKLESS", "SYSTEM", "FAKE", "MIM", "MIM_SDC", "HU", "PROFILED_HU", "THREAD_PROFILED_HU".
  2243. ### - LF - lfalloc (https://a.yandex-team.ru/arc/trunk/arcadia/library/cpp/lfalloc)
  2244. ### - LF_YT - Allocator selection for YT (https://a.yandex-team.ru/arc/trunk/arcadia/library/cpp/lfalloc/yt/ya.make)
  2245. ### - LF_DBG - Debug allocator selection (https://a.yandex-team.ru/arc/trunk/arcadia/library/cpp/lfalloc/dbg/ya.make)
  2246. ### - YT - The YTAlloc allocator (https://a.yandex-team.ru/arc/trunk/arcadia/library/cpp/ytalloc/impl/ya.make)
  2247. ### - J - The JEMalloc allocator (https://a.yandex-team.ru/arc/trunk/arcadia/library/malloc/jemalloc)
  2248. ### - B - The balloc allocator named Pyotr Popov and Anton Samokhvalov
  2249. ### - Discussion: https://ironpeter.at.yandex-team.ru/replies.xml?item_no=126
  2250. ### - Code: https://a.yandex-team.ru/arc/trunk/arcadia/library/cpp/balloc
  2251. ### - BM - The balloc for market (agri@ commits from july 2018 till November 2018 saved)
  2252. ### - C - Like B, but can be disabled for each thread to LF or SYSTEM one (B can be disabled only to SYSTEM)
  2253. ### - MIM - Microsoft's mimalloc (actual version) (https://a.yandex-team.ru/arc/trunk/arcadia/library/malloc/mimalloc)
  2254. ### - MIM_SDC - Microsoft's mimalloc patched by SDC (https://a.yandex-team.ru/arc/trunk/arcadia/library/malloc/mimalloc_sdc)
  2255. ### - TCMALLOC - Google TCMalloc (actual version) (https://a.yandex-team.ru/arc/trunk/arcadia/library/malloc/tcmalloc)
  2256. ### - GOOGLE - Google TCMalloc (https://a.yandex-team.ru/arc/trunk/arcadia/library/malloc/galloc)
  2257. ### - LOCKLESS - Allocator based upon lockless queues (https://a.yandex-team.ru/arc/trunk/arcadia/library/malloc/lockless)
  2258. ### - SYSTEM - Use target system allocator
  2259. ### - FAKE - Don't link with any allocator
  2260. ### - HU - Huge page allocator by @gulin.
  2261. ### - PROFILED_HU - patched HU. It is a bit slower but has metrics of memory consumption.
  2262. ### - THREAD_PROFILED_HU - patched (special for market) HU. It is a bit slower but has metrics of memory consumption.
  2263. ###
  2264. ### More about allocators in Arcadia: https://wiki.yandex-team.ru/arcadia/allocators/
  2265. macro ALLOCATOR(Alloc) {
  2266. SET(ALLOCATOR $Alloc)
  2267. when ($ALLOCATOR in [ "LF", "LF_YT", "LF_DBG", "YT", "YT_TCMALLOC", "YT_TCMALLOC_256K", "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", "MIM_SDC", "HU", "PROFILED_HU", "THREAD_PROFILED_HU" ]) {
  2268. }
  2269. otherwise {
  2270. PEERDIR+=___configure_error___unknown_allocator_type___$ALLOCATOR
  2271. }
  2272. }
  2273. when ($MIC_ARCH == "yes") {
  2274. CFLAGS+=-mmic
  2275. LDFLAGS+=-mmic
  2276. }
  2277. when ($USE_OPENMP == "yes") {
  2278. PEERDIR+=contrib/libs/openmp
  2279. }
  2280. when ($STRIP == "yes" && $NO_STRIP != "yes") {
  2281. STRIP_FLAG=$LD_STRIP_FLAG
  2282. DWARF_COMMAND=
  2283. GO_LINK_FLAGS_VALUE+=-s
  2284. }
  2285. when ($NO_LINKER_DCE != "yes") {
  2286. DCE_FLAG=$LD_DCE_FLAG
  2287. }
  2288. when ($BT_MINSIZEREL == "yes" || $LINKER_ICF == "yes") {
  2289. ICF_FLAG=$LD_ICF_FLAG
  2290. }
  2291. OBJCOPY_TOOL=$OBJCOPY_TOOL_VENDOR
  2292. OBJDUMP_TOOL=$OBJDUMP_TOOL_VENDOR
  2293. STRIP_TOOL=$STRIP_TOOL_VENDOR
  2294. NEED_BINUTILS_PEERDIR=
  2295. BINUTILS_USED=
  2296. when (!$OBJCOPY_TOOL_VENDOR) {
  2297. OBJCOPY_TOOL=$BINUTILS_ROOT_RESOURCE_GLOBAL/bin/objcopy
  2298. NEED_BINUTILS_PEERDIR=yes
  2299. }
  2300. when (!$OBJDUMP_TOOL_VENDOR) {
  2301. OBJDUMP_TOOL=$BINUTILS_ROOT_RESOURCE_GLOBAL/bin/objdump
  2302. NEED_BINUTILS_PEERDIR=yes
  2303. }
  2304. when (!$STRIP_TOOL_VENDOR) {
  2305. STRIP_TOOL=$BINUTILS_ROOT_RESOURCE_GLOBAL/bin/strip
  2306. NEED_BINUTILS_PEERDIR=yes
  2307. }
  2308. SPLIT_DWARF_VALUE=no
  2309. NO_SPLIT_DWARF=no
  2310. when ($OS_DARWIN || $OS_IOS || $OS_IOSSIM) {
  2311. SPLIT_DWARF_VALUE=yes
  2312. }
  2313. when ($STRIP_DEBUG_INFO) {
  2314. SPLIT_DWARF_VALUE=yes
  2315. NO_SPLIT_DWARF=no
  2316. }
  2317. ### @usage: SPLIT_DWARF()
  2318. ###
  2319. ### Emit debug info for the PROGRAM/DLL as a separate file <module_name>.debug.
  2320. ### NB: It does not help you to save process RSS but can add problems (see e.g. BEGEMOT-2147).
  2321. macro SPLIT_DWARF() {
  2322. SET(SPLIT_DWARF_VALUE yes)
  2323. }
  2324. ### @usage: NO_SPLIT_DWARF()
  2325. ###
  2326. ### Do NOT emit debug info for the PROGRAM/DLL as a separate file.
  2327. ### On macOS this also means do NOT generate dSym files (faster linkage)
  2328. macro NO_SPLIT_DWARF() {
  2329. SET(SPLIT_DWARF_VALUE no)
  2330. }
  2331. SPLIT_DWARF_OUTPUT=${output;tobindir;pre=$MODULE_PREFIX;suf=$MODULE_SUFFIX.debug:REALPRJNAME}
  2332. when ($SPLIT_DWARF_VALUE == "yes" && $NO_SPLIT_DWARF != "yes" && $NO_DEBUGINFO != "yes" && $HOST_OS_LINUX == "yes" && $TARGET_PLATFORM == "LINUX") {
  2333. DWARF_COMMAND= \
  2334. $OBJCOPY_TOOL --only-keep-debug $TARGET $SPLIT_DWARF_OUTPUT && \
  2335. $STRIP_TOOL --strip-debug $TARGET && \
  2336. $OBJCOPY_TOOL --remove-section=.gnu_debuglink --add-gnu-debuglink $SPLIT_DWARF_OUTPUT $TARGET
  2337. BINUTILS_USED=yes
  2338. }
  2339. ### @usage: EXTRALIBS_STATIC(Libs...)
  2340. ###
  2341. ### Add the specified external static libraries to the program link
  2342. macro EXTRALIBS_STATIC(Args...) {
  2343. LDFLAGS(-Wl,-Bstatic ${Args} -Wl,-Bdynamic)
  2344. }
  2345. ### @usage ADD_COMPILABLE_TRANSLATE(Dict Name Options...)
  2346. ###
  2347. ### Generate translation dictionary code to transdict.LOWER(Name).cpp that will than be compiled into library
  2348. macro ADD_COMPILABLE_TRANSLATE(Dict, Name, MakeTransDictOptions...) {
  2349. __translatename_lower=${tolower:Name}
  2350. __translate_dict=${BINDIR}/transdict.${__translatename_lower}.cpp
  2351. RUN_PROGRAM(dict/tools/maketransdict -i ${Dict} ${MakeTransDictOptions} ${Name} STDOUT_NOAUTO ${__translate_dict} IN ${Dict})
  2352. }
  2353. ### @usage ADD_COMPILABLE_TRANSLIT(TranslitTable NGrams Name Options...)
  2354. ###
  2355. ### Generate transliteration dictionary code
  2356. ### This will emit both translit, untranslit and ngrams table codes those will be than further compiled into library
  2357. macro ADD_COMPILABLE_TRANSLIT(TranslitTable, NGrams, Name, Options...) {
  2358. __translitname_lower=${tolower:Name}
  2359. __translit_table=${BINDIR}/translit_trie_${__translitname_lower}.cpp
  2360. __untranslit_table=${BINDIR}/untranslit_trie_${__translitname_lower}.cpp
  2361. __ngrams_table=${BINDIR}/ngr_arr_${__translitname_lower}.cpp
  2362. __gentrie_dir=dict/tools/make_untranslit_trie
  2363. RUN_PROGRAM(${__gentrie_dir} -i ${TranslitTable} ${Options} ${__translitname_lower} IN ${TranslitTable} STDOUT ${__untranslit_table})
  2364. RUN_PROGRAM(${__gentrie_dir} -i ${TranslitTable} -n ${Options} ${__translitname_lower} IN ${TranslitTable} STDOUT ${__translit_table})
  2365. RUN_PROGRAM(dict/tools/make_ngrams -i ${NGrams} ${Options} ${__translitname_lower} IN ${NGrams} STDOUT ${__ngrams_table})
  2366. }
  2367. _COPY_FILE_CONTEXT=
  2368. macro _COPY_FILE_IMPL(TEXT[], AUTO_DST="", NOAUTO_DST="", OUTPUT_INCLUDES[], INDUCED_DEPS[], OUTPUT_INCLUDES_INP[], FILE...) {
  2369. .CMD=$COPY_CMD ${input:FILE} ${input;context=TEXT:TEXT} ${output:AUTO_DST} ${noauto;output:NOAUTO_DST} ${output_include;hide:OUTPUT_INCLUDES} ${output_include;from_input;hide:OUTPUT_INCLUDES_INP} $INDUCED_DEPS ${hide;kv:"p CP"} ${hide;kv:"pc light-cyan"}
  2370. .SEM=copy_file ${input:FILE} ${output:AUTO_DST} ${noauto;output:NOAUTO_DST} && target_commands-ITEM && target_commands-macro copy_file && target_commands-args ${input:FILE} ${output:AUTO_DST} ${noauto;output:NOAUTO_DST}
  2371. }
  2372. ### @usage: COPY_FILE(File Destination [AUTO] [OUTPUT_INCLUDES Deps...])
  2373. ###
  2374. ### Copy file to build root. It is possible to change both location and the name.
  2375. ###
  2376. ### Parameters:
  2377. ### - File - Source file name.
  2378. ### - Destination - Output file name.
  2379. ### - AUTO - Consider copied file for further processing automatically.
  2380. ### - OUTPUT_INCLUDES output_includes... - Output file dependencies.
  2381. ### - INDUCED_DEPS $VARs... - Dependencies for generated files. Unlike `OUTPUT_INCLUDES` these may target files further in processing chain.
  2382. ### In order to do so VAR should be filled by PREPARE_INDUCED_DEPS macro, stating target files (by type)
  2383. ### and set of dependencies
  2384. ###
  2385. ### The file will be just copied if AUTO boolean parameter is not specified. You should explicitly
  2386. ### mention it in SRCS under new name (or specify AUTO boolean parameter) for further processing.
  2387. macro COPY_FILE(File, Destination, AUTO?"AUTO_DST":"NOAUTO_DST", OUTPUT_INCLUDES[], INDUCED_DEPS[], TEXT?"TEXT":"$_COPY_FILE_CONTEXT") {
  2388. .CMD=$_COPY_FILE_IMPL($TEXT $File $AUTO $Destination OUTPUT_INCLUDES $OUTPUT_INCLUDES INDUCED_DEPS $INDUCED_DEPS)
  2389. .SEM=$_COPY_FILE_IMPL($File $AUTO $Destination)
  2390. }
  2391. ### @usage: COPY_FILE_WITH_CONTEXT(FILE DEST [AUTO] [OUTPUT_INCLUDES DEPS...])
  2392. ###
  2393. ### Copy file to build root the same way as it is done for COPY_FILE, but also
  2394. ### propagates the context of the source file.
  2395. macro COPY_FILE_WITH_CONTEXT(FILE, DEST, AUTO?"AUTO_DST":"NOAUTO_DST", OUTPUT_INCLUDES[], INDUCED_DEPS[]) {
  2396. .CMD=$_COPY_FILE_IMPL($FILE $AUTO $DEST OUTPUT_INCLUDES_INP $FILE OUTPUT_INCLUDES $OUTPUT_INCLUDES INDUCED_DEPS $INDUCED_DEPS)
  2397. }
  2398. ### This is to join $ALL_RES_ and $EXT
  2399. macro _ARF_HELPER(Args...) {
  2400. RESOURCE_FILES($Args)
  2401. }
  2402. ### @usage ALL_RESOURCE_FILES(Ext [PREFIX {prefix}] [STRIP {strip}] Dirs...)
  2403. ###
  2404. ### This macro collects all files with extension `Ext` and
  2405. ### Passes them to `RESOURCE_FILES` macro as relative to current directory
  2406. ###
  2407. ### `PREFIX` and `STRIP` have the same meaning as in `ROURCES_FILES`, both are applied over moddir-relative paths
  2408. ###
  2409. ### Note: This macro can be used multiple times per ya.make, but only once for each Ext value
  2410. ### Note: Wildcards are not allowed neither as Ext nor in Dirs
  2411. macro ALL_RESOURCE_FILES(EXT, PREFIX="", STRIP="", DIRS...) {
  2412. _GLOB(ALL_RES_$EXT ${suf=/*.$EXT:DIRS})
  2413. _ARF_HELPER(${pre=PREFIX :PREFIX} STRIP ${ARCADIA_ROOT}/${MODDIR}/${STRIP} ${pre=$ALL_RES_:EXT})
  2414. }
  2415. ### @usage ALL_RESOURCE_FILES_FROM_DIRS([PREFIX {prefix}] [STRIP {strip}] Dirs...)
  2416. ###
  2417. ### This macro collects all files non-recursively from listed Dirs and
  2418. ### Passes them to `RESOURCE_FILES` macro as relative to current directory
  2419. ### The macro is usefull if literally all files are needed because `ALL_RESOURCE_FILES` requires extension to be specified
  2420. ###
  2421. ### `PREFIX` and `STRIP` have the same meaning as in `ROURCES_FILES`, both are applied over moddir-relative paths
  2422. ###
  2423. ### Note: This macro can be used only once per ya.make
  2424. ### Note: Wildcards are not allowed neither as Ext nor in Dirs
  2425. macro ALL_RESOURCE_FILES_FROM_DIRS(PREFIX="", STRIP="", DIRS...) {
  2426. _GLOB(_ALL_RES_DIRS ${suf=/*:DIRS})
  2427. _ARF_HELPER(${pre=PREFIX :PREFIX} STRIP ${ARCADIA_ROOT}/${MODDIR}/${STRIP} ${_ALL_RES_DIRS})
  2428. }
  2429. macro _BUNDLE_TARGET(Target, Destination) {
  2430. .CMD=$MOVE_FILE ${result:Target} ${noauto;output:Destination} ${hide;kv:"p BN"} ${hide;kv:"pc light-cyan"} $VCS_INFO_DISABLE_CACHE__NO_UID__
  2431. }
  2432. ### @usage: TIMEOUT(TIMEOUT)
  2433. ###
  2434. ### Sets a timeout on test execution
  2435. ###
  2436. ### Documentation about the system test: https://wiki.yandex-team.ru/yatool/test/
  2437. macro TIMEOUT(Time) {
  2438. SET(TEST_TIMEOUT $Time)
  2439. }
  2440. SBR_UID_EXT=""
  2441. # tag:test
  2442. ### @usage: VALIDATE_DATA_RESTART(ext)
  2443. ###
  2444. ### Change uid for resource validation tests. May be useful when sandbox resource ttl is changed, but test status is cached in CI.
  2445. ### You can change ext to change test's uid. For example VALIDATE_DATA_RESTART(X), where is X is current revision.
  2446. macro VALIDATE_DATA_RESTART(Ext) {
  2447. SET(SBR_UID_EXT $Ext)
  2448. }
  2449. # tag:test
  2450. TEST_FORK_MODE=none
  2451. TEST_PARTITION=SEQUENTIAL
  2452. # tag:test
  2453. ### @usage: FORK_TESTS()
  2454. ###
  2455. ### Splits a test run on chunks by test classes.
  2456. ### The number of chunks can be overridden using the macro SPLIT_FACTOR.
  2457. ###
  2458. ### Allows to run tests in parallel. Supported in UNITTEST, JTEST/JUNIT5 and PY2TEST/PY3TEST modules.
  2459. ###
  2460. ### Documentation about the system test: https://wiki.yandex-team.ru/yatool/test/
  2461. macro FORK_TESTS(MODE...) {
  2462. SET(TEST_FORK_MODE tests)
  2463. SET(TEST_PARTITION $MODE)
  2464. }
  2465. # tag:test
  2466. ### @usage: FORK_SUBTESTS()
  2467. ###
  2468. ### Splits the test run in chunks on subtests.
  2469. ### The number of chunks can be overridden using the macro SPLIT_FACTOR.
  2470. ###
  2471. ### Allows to run tests in parallel. Supported in UNITTEST, JTEST/JUNIT5 and PY2TEST/PY3TEST modules.
  2472. ###
  2473. ### Documentation about the system test: https://wiki.yandex-team.ru/yatool/test/
  2474. macro FORK_SUBTESTS(MODE...) {
  2475. SET(TEST_FORK_MODE subtests)
  2476. SET(TEST_PARTITION $MODE)
  2477. }
  2478. # tag:test
  2479. ### @usage: SPLIT_FACTOR(x)
  2480. ###
  2481. ### Sets the number of chunks for parallel run tests when used in test module with FORK_TESTS() or FORK_SUBTESTS().
  2482. ### If none of those is specified this macro implies FORK_TESTS().
  2483. ###
  2484. ### Supports C++ ut and PyTest.
  2485. ###
  2486. ### Documentation about the system test: https://wiki.yandex-team.ru/yatool/test/
  2487. macro SPLIT_FACTOR(Factor) {
  2488. SET(TEST_SPLIT_FACTOR $Factor)
  2489. }
  2490. # tag:test
  2491. FORK_TEST_FILES_MODE=
  2492. ### @usage: FORK_TEST_FILES()
  2493. ###
  2494. ### Only for PY2TEST and PY3TEST: splits a file executable with the tests on chunks in the files listed in TEST_SRCS
  2495. ### Compatible with FORK_(SUB)TESTS.
  2496. ###
  2497. ### Documentation about the system test: https://wiki.yandex-team.ru/yatool/test/
  2498. macro FORK_TEST_FILES() {
  2499. SET(FORK_TEST_FILES_MODE on)
  2500. }
  2501. # tag:test
  2502. TEST_SIZE_NAME=SMALL
  2503. ### @usage: SIZE(SMALL/MEDIUM/LARGE)
  2504. ###
  2505. ### Set the 'size' for the test. Each 'size' has own set of resrtictions, SMALL bein the most restricted and LARGE being the list.
  2506. ### See documentation on test system for more details.
  2507. ###
  2508. ### Documentation about the system test: https://wiki.yandex-team.ru/yatool/test/
  2509. macro SIZE(Type) {
  2510. SET(TEST_SIZE_NAME $Type)
  2511. }
  2512. ### @usage: JOIN_SRCS(Out Src...)
  2513. ###
  2514. ### Join set of sources into single file named Out and send it for further processing.
  2515. ### This macro doesn't place all file into Out, it emits #include<Src>... Use the for C++ source files only.
  2516. ### You should specify file name with the extension as Out. Further processing will be done according this extension.
  2517. macro JOIN_SRCS(Out, Src...) {
  2518. .CMD=$YMAKE_PYTHON3 ${input:"build/scripts/gen_join_srcs.py"} ${hide;input:"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} ${hide;kv:"p JS"} ${hide;kv:"pc magenta"}
  2519. .SEM=target_joined_source $Out ${input:Src} ${hide;output;suf=.o:Out} ${hide;input:"build/scripts/gen_join_srcs.py"} ${hide;input:"build/scripts/process_command_files.py"} && target_macroses-ITEM && target_macroses-macro target_joined_source && target_macroses-args $Out ${input:Src} ${hide;output;suf=.o:Out} ${hide;input:"build/scripts/gen_join_srcs.py"} ${hide;input:"build/scripts/process_command_files.py"}
  2520. _CONDITIONAL_SRCS($TIDY_VALUE $Src)
  2521. }
  2522. ### @usage: JOIN_SRCS_GLOBAL(Out Src...)
  2523. ###
  2524. ### Join set of sources into single file named Out and send it for further processing as if it were listed as SRCS(GLOBAL Out).
  2525. ### This macro doesn't place all file into Out, it emits #include<Src>... Use the for C++ source files only.
  2526. ### You should specify file name with the extension as Out. Further processing will be done according to this extension.
  2527. macro JOIN_SRCS_GLOBAL(Out, Src...) {
  2528. .CMD=$YMAKE_PYTHON3 ${input:"build/scripts/gen_join_srcs.py"} ${hide;input:"build/scripts/process_command_files.py"} ${noauto;output:Out} --ya-start-command-file ${input;rootrel:Src} --ya-end-command-file ${output_include;from_input;hide:Src} ${hide;kv:"p JS"} ${hide;kv:"pc magenta"}
  2529. SRCS(GLOBAL $Out)
  2530. }
  2531. ### @usage: FLAT_JOIN_SRCS_GLOBAL(Out Src...)
  2532. ###
  2533. ### Join set of sources into single file named Out and send it for further processing as if it were listed as SRCS(GLOBAL Out).
  2534. ### This macro places all files into single file, so will work with any sources.
  2535. ### You should specify file name with the extension as Out. Further processing will be done according to this extension.
  2536. macro FLAT_JOIN_SRCS_GLOBAL(Out, Src...) {
  2537. .CMD=$FS_TOOLS cat ${noauto;output:Out} --ya-start-command-file ${input:Src} --ya-end-command-file ${output_include;from_input;hide:Src} ${hide;kv:"p JS"} ${hide;kv:"pc magenta"}
  2538. SRCS(GLOBAL $Out)
  2539. }
  2540. # tag:cpu
  2541. PIC_CFLAGS=
  2542. SSE2_CFLAGS=
  2543. SSE3_CFLAGS=
  2544. SSSE3_CFLAGS=
  2545. SSE41_CFLAGS=
  2546. SSE42_CFLAGS=
  2547. POPCNT_CFLAGS=
  2548. PCLMUL_CFLAGS=
  2549. CX16_FLAGS=
  2550. AVX_CFLAGS=
  2551. AVX2_CFLAGS=
  2552. AVX512_CFLAGS=
  2553. AMX_CFLAGS=
  2554. # tag:cpu
  2555. SSE_DEFINES=
  2556. SSE_CFLAGS=
  2557. SSE4_DEFINES=
  2558. SSE4_CFLAGS=
  2559. XOP_CFLAGS=
  2560. NO_LTO_CFLAGS=
  2561. # tag:cpu
  2562. when (($ARCH_X86_64 || $ARCH_I386) && $DISABLE_INSTRUCTION_SETS != "yes") {
  2563. when ($CLANG || $CLANG_CL || $GCC) {
  2564. PIC_CFLAGS=-fPIC
  2565. SSE2_CFLAGS=-msse2
  2566. SSE3_CFLAGS=-msse3
  2567. SSSE3_CFLAGS=-mssse3
  2568. SSE41_CFLAGS=-msse4.1
  2569. SSE42_CFLAGS=-msse4.2
  2570. XOP_CFLAGS=-mxop
  2571. POPCNT_CFLAGS=-mpopcnt
  2572. PCLMUL_CFLAGS=-mpclmul
  2573. AVX_CFLAGS=-mavx
  2574. # On Intel BMI1, BMI2 and FMA3 instruction sets come together with AVX-2 extension starting with Broadwell / Haswell.
  2575. # See:
  2576. # https://en.wikipedia.org/wiki/FMA_instruction_set
  2577. # https://en.wikipedia.org/wiki/X86_Bit_manipulation_instruction_set
  2578. #
  2579. # AMD implemented FMA3 in Piledriver architecture over AVX (that is, prior to AVX-2 which was introduced in Zen).
  2580. # BMI2 implementation was released by AMD along with AVX-2 support.
  2581. # See:
  2582. # https://en.wikipedia.org/wiki/Template:AMD_x86_CPU_features
  2583. #
  2584. # Due to the above, it looks safe to enable all three extensions whenever AVX-2 is enabled.
  2585. AVX2_CFLAGS=-mavx2 -mfma -mbmi -mbmi2
  2586. # All Intel CPUS with AVX-512 have these instructions except for the Knights Landing / Knights Mill
  2587. # (these are Xeon Phi)
  2588. # See:
  2589. # https://en.wikichip.org/wiki/x86/avx-512
  2590. AVX512_CFLAGS=-mavx512f -mavx512cd -mavx512bw -mavx512dq -mavx512vl
  2591. # AMX stands Advanced Matrix Extension supported by modern Intel architectures
  2592. # See:
  2593. # https://en.wikipedia.org/wiki/Advanced_Matrix_Extensions
  2594. # https://en.wikichip.org/wiki/x86/amx
  2595. AMX_CFLAGS=-mamx-tile -mamx-int8 ${AVX512_CFLAGS}
  2596. when ($ARCH_X86_64 && $OS_ANDROID != "yes") {
  2597. CX16_FLAGS=-mcx16
  2598. }
  2599. SSE_DEFINES=-DSSE_ENABLED=1 -DSSE3_ENABLED=1 -DSSSE3_ENABLED=1
  2600. SSE4_DEFINES=-DSSE41_ENABLED=1 -DSSE42_ENABLED=1 -DPOPCNT_ENABLED=1 -DCX16_ENABLED=1
  2601. }
  2602. elsewhen ($MSVC) {
  2603. SSE2_CFLAGS=/D__SSE2__=1
  2604. SSE3_CFLAGS=/D__SSE3__=1
  2605. SSSE3_CFLAGS=/D__SSSE3__=1
  2606. SSE41_CFLAGS=/D__SSE4_1__=1
  2607. SSE42_CFLAGS=/D__SSE4_2__=1
  2608. POPCNT_CFLAGS=/D__POPCNT__=1
  2609. PCLMUL_CFLAGS=/D__PCLMUL__=1
  2610. AVX_CFLAGS=/arch:AVX /DAVX_ENABLED=1
  2611. AVX2_CFLAGS=/arch:AVX2 /DAVX2_ENABLED=1
  2612. AVX512_CFLAGS=/arch:AVX512 /DAVX512_ENABLED=1
  2613. SSE_DEFINES=/DSSE_ENABLED=1 /DSSE3_ENABLED=1 /DSSSE3_ENABLED=1
  2614. SSE4_DEFINES=/DSSE41_ENABLED=1 /DSSE42_ENABLED=1 /DPOPCNT_ENABLED=1 /DCX16_ENABLED=1
  2615. }
  2616. SSE_CFLAGS=$SSE2_CFLAGS $SSE3_CFLAGS $SSSE3_CFLAGS
  2617. SSE4_CFLAGS=$SSE41_CFLAGS $SSE42_CFLAGS $POPCNT_CFLAGS $CX16_FLAGS
  2618. when ($ARCH_I386 && $OS_ANDROID == "yes") {
  2619. USE_SSE4=no
  2620. }
  2621. }
  2622. otherwise {
  2623. USE_SSE4=no
  2624. CPU_CHECK=no
  2625. }
  2626. # tag:cpu
  2627. when ($NOSSE == "yes") {
  2628. USE_SSE4=no
  2629. }
  2630. # tag:cpu
  2631. ### @usage: NO_SSE4()
  2632. ###
  2633. ### Compile module without SSE4
  2634. macro NO_SSE4() {
  2635. SET(USE_SSE4 no)
  2636. }
  2637. # tag:cpu
  2638. ### @usage: NO_CPU_CHECK()
  2639. ###
  2640. ### Compile module without startup CPU features check
  2641. macro NO_CPU_CHECK() {
  2642. SET(CPU_CHECK no)
  2643. }
  2644. ### @usage: ADDINCLSELF()
  2645. ###
  2646. ### The macro adds the -I<project source path> flag to the source compilation flags of the current project.
  2647. macro ADDINCLSELF(FOR="") {
  2648. when($FOR) {
  2649. ADDINCL+=FOR $FOR ${MODDIR}
  2650. }
  2651. otherwise {
  2652. ADDINCL+=${MODDIR}
  2653. }
  2654. }
  2655. COMPILE_OUT_SUFFIX=
  2656. _COMPILE_OUTPUTS=${output;suf=${COMPILE_OUT_SUFFIX}${OBJECT_SUF}:SRC}
  2657. _COMPILE_TIME_TRACE_OUTPUTS=${noauto;output;suf=${COMPILE_OUT_SUFFIX}${OBJECT_SUF}.time_trace.json:SRC}
  2658. macro SET_COMPILE_OUTPUTS_MODIFIERS(NOREL?";norel":"") {
  2659. SET(_COMPILE_OUTPUTS \${output;suf=\${OBJECT_SUF}$NOREL:SRC})
  2660. SET(_COMPILE_TIME_TRACE_OUTPUTS \${noauto;output;suf=\${OBJECT_SUF}.time_trace.json$NOREL:SRC})
  2661. }
  2662. # tag:internal
  2663. ### @usage: _ADD_EXTRA_FLAGS_IMPL([GENERATE] Args...) # internal
  2664. ### Generate prefix = " && set_property SOURCE ${input:SRC} APPEND PROPERTY COMPILE_OPTIONS " before $Args when GENERATE
  2665. ### is specified in the list of actual arguments
  2666. macro _ADD_EXTRA_FLAGS_IMPL(GENERATE?" && set_property SOURCE ${input:SRC} APPEND PROPERTY COMPILE_OPTIONS ":"", Args...) {
  2667. .SEM=$GENERATE $Args
  2668. }
  2669. ### @usage: _ADD_EXTRA_FLAGS_IMPL2([GENERATE] Args...) # internal
  2670. ### Generate prefix with specific semantics before $Args when GENERATE
  2671. ### is specified in the list of actual arguments
  2672. macro _ADD_EXTRA_FLAGS_IMPL2(GENERATE?" && target_commands-ITEM && target_commands-macro set_property && target_commands-args SOURCE ${input:SRC} APPEND PROPERTY COMPILE_OPTIONS ":"", Args...) {
  2673. .SEM=$GENERATE $Args
  2674. }
  2675. # tag:internal
  2676. ### @usage: _ADD_EXTRA_FLAGS([GENERATE] Args...) # internal
  2677. ### Generate prefix = " && set_property SOURCE ${input:SRC} APPEND PROPERTY COMPILE_OPTIONS " if Args is not empty
  2678. macro _ADD_EXTRA_FLAGS(COMPILE_OUT_SUFFIX="", Args...) {
  2679. .SEM=$_ADD_EXTRA_FLAGS_IMPL(${pre=GENERATE :Args}) $_ADD_EXTRA_FLAGS_IMPL2(${pre=GENERATE :Args})
  2680. }
  2681. _EMPTY_CMD=
  2682. # tag:src-processing
  2683. macro _SRC("swg", SRC, SRCFLAGS...) {
  2684. .CMD=${_SWIG_CMD}
  2685. .PEERDIR=${_SWIG_PEERDIR}
  2686. .SEM=conan_require_tool swig/4.0.2 && conan_import '"bin, *swig* -> ./bin"' && conan-tool_requires swig/4.0.2 && conan-imports 'bin, *swig* -> ./bin' ${hide;input:SRC} ${_SWIG_SEM_TO_MODULE_LINK}
  2687. }
  2688. RODATA_SYMBOL_PREFIX=
  2689. when ($DARWIN == "yes" || $IOS == "yes" || ($WINDOWS == "yes" && $ARCH_TYPE_32 == "yes")) {
  2690. RODATA_SYMBOL_PREFIX=_
  2691. }
  2692. RODATA_ELF_FLAGS=
  2693. when($LINUX == "yes" || $ANDROID == "yes") {
  2694. RODATA_ELF_FLAGS=--elf
  2695. }
  2696. 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})
  2697. when (($ARCH_AARCH64 || $ARCH_ARM || $ARCH_PPC64LE || $ARCH_RISCV32) == "yes") {
  2698. RODATA_COMPILE=$YMAKE_PYTHON3 ${input:"build/scripts/rodata2cpp.py"} ${noext;nopath:SRC} ${input:SRC} ${output;suf=.cpp:SRC}
  2699. }
  2700. # tag:src-processing
  2701. macro _SRC("rodata", SRC, SRCFLAGS...) {
  2702. .CMD=$RODATA_COMPILE ${hide;kv:"p RD"} ${hide;kv:"pc light-green"}
  2703. .SEM=target_rodata_sources PRIVATE ${input:SRC} ${hide;output;suf=${OBJ_SUF}.o:SRC} ${hide;input:"build/scripts/rodata2cpp.py"} && target_macroses-ITEM && target_macroses-macro target_rodata_sources && target_macroses-args PRIVATE ${input:SRC} ${hide;output;suf=${OBJ_SUF}.o:SRC} ${hide;input:"build/scripts/rodata2cpp.py"}
  2704. }
  2705. macro _SRS_S_ASM(SRC, SRCFLAGS...) {
  2706. .CMD=$C_COMPILER_OLD $C_FLAGS_PLATFORM $CFLAGS $SFLAGS $SRCFLAGS -c -o ${output:SRC.o} ${input:SRC} $TOOLCHAIN_ENV ${pre=-I:_C__INCLUDE}
  2707. .SEM=target_sources PRIVATE ${input:SRC} ${hide;output;suf=${OBJ_SUF}.o:SRC} $_ADD_EXTRA_FLAGS($SRCFLAGS) && target_options-privates-ITEM && target_options-privates-option target_sources && target_options-privates-args ${input:SRC} ${hide;output;suf=${OBJ_SUF}.o:SRC} && add_language ASM && project_languages ASM
  2708. }
  2709. # tag:src-processing
  2710. macro _SRC("S", SRC, SRCFLAGS...) {
  2711. .CMD=$_SRS_S_ASM($SRC, $SRCFLAGS)
  2712. .SEM=$_SRS_S_ASM($SRC, $SRCFLAGS)
  2713. }
  2714. # tag:src-processing
  2715. macro _SRC("s", SRC, SRCFLAGS...) {
  2716. .CMD=$_SRS_S_ASM($SRC, $SRCFLAGS)
  2717. .SEM=$_SRS_S_ASM($SRC, $SRCFLAGS)
  2718. }
  2719. # tag:src-processing
  2720. macro _SRC("s79", SRC, SRCFLAGS...) {
  2721. .CMD=$_SRC(S, $SRC $SRCFLAGS -x assembler-with-cpp)
  2722. }
  2723. # tag:src-processing
  2724. macro _SRC("mm", SRC, SRCFLAGS...) {
  2725. .CMD=$C_COMPILER_OLD $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} ${hide;kv:"p CC"} ${hide;kv:"pc light-green"} $TOOLCHAIN_ENV
  2726. }
  2727. # tag:src-processing
  2728. macro _SRC("sfdl", SRC, SRCFLAGS...) {
  2729. .CMD=$CXX_COMPILER_OLD $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} ${hide;kv:"p SF"} ${hide;kv:"pc yellow"} $TOOLCHAIN_ENV
  2730. }
  2731. macro _XS_SRCS(SRC, TYPEMAPS[], SRCFLAGS...) {
  2732. .CMD=$PERL_LD_LIBRARY_PATH $PERL $PERL_INCLUDE ${suf=/ExtUtils/xsubpp:PERL_PRIVLIB} -typemap ${suf=/ExtUtils/typemap:PERL_PRIVLIB} $PERLSUFFIX $XSUBPPFLAGS ${pre=-typemap :TYPEMAPS} ${hide;input:TYPEMAPS} ${SRCFLAGS} ${input:SRC} ${PERLOUTPUT} ${hide;kv:"p XS"} ${hide;kv:"pc yellow"}
  2733. }
  2734. # tag:src-processing
  2735. macro _SRC("xs", SRC, SRCFLAGS...) {
  2736. .CMD=$_XS_SRCS($SRC TYPEMAPS $_XSTYPEMAPS $SRCFLAGS)
  2737. }
  2738. # tag:src-processing
  2739. macro _SRC("gperf", SRC, SRCFLAGS...) {
  2740. .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} ${hide;kv:"p GP"} ${hide;kv:"pc yellow"}
  2741. }
  2742. # tag:src-processing
  2743. macro _SRC("rl", SRC, SRCFLAGS...) {
  2744. .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} ${hide;kv:"p R5"} ${hide;kv:"pc yellow"}
  2745. }
  2746. macro _SRC("xsyn", SRC, SRCFLAGS...) {
  2747. .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} ${hide;kv:"p XN"} ${hide;kv:"pc yellow"}
  2748. }
  2749. # tag:src-processing
  2750. macro _SRC("rl5", SRC, SRCFLAGS...) {
  2751. .CMD=$_SRC(rl $SRC $SRCFLAGS)
  2752. }
  2753. # tag:src-processing
  2754. macro _SRC("asp", SRC, SRCFLAGS...) {
  2755. .CMD=$RUN_NO_SANITIZE ${tool:"tools/html2cpp"} ${input:SRC} ${output:SRC.cpp} ${hide;kv:"p HT"} ${hide;kv:"pc yellow"}
  2756. }
  2757. # tag:src-processing
  2758. macro _SRC("rl6", SRC, SRCFLAGS...) {
  2759. .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} ${hide;kv:"p R6"} ${hide;kv:"pc yellow"}
  2760. .SEM=target_ragel_lexers PRIVATE ${input:SRC} ${hide;output;suf=${OBJ_SUF}.o:SRC} $RAGEL6_FLAGS ${SRCFLAGS} && target_macroses-ITEM && target_macroses-macro target_ragel_lexers && target_macroses-args PRIVATE ${input:SRC} ${hide;output;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"' && platform_vars-RAGEL_FLAGS "-L -I $S/" && conan-tool_requires ragel/6.10 && conan-imports 'bin, ragel* -> ./bin' ${hide;input:"build/scripts/run_tool.py"}
  2761. }
  2762. # tag:src-processing
  2763. macro _SRC("xsyn", SRC, SRCFLAGS...) {
  2764. .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} ${hide;kv:"p XN"} ${hide;kv:"pc yellow"}
  2765. }
  2766. # tag:src-processing
  2767. macro _SRC("ev", SRC, SRCFLAGS...) {
  2768. .CMD=$EVLOG_CMD($SRC)
  2769. .SEM=$EVLOG_CMD($SRC)
  2770. }
  2771. # tag:src-processing
  2772. macro _SRC("proto", SRC, SRCFLAGS...) {
  2773. .CMD=$PROTO_CMD($SRC)
  2774. .SEM=$PROTO_CMD($SRC)
  2775. }
  2776. # tag:src-processing
  2777. macro _SRC("gztproto", SRC, SRCFLAGS...) {
  2778. # _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.
  2779. # descriptor.proto must be resolved as google/protobuf/descriptor.proto
  2780. .CMD=${tool:"dict/gazetteer/converter"} -I$PROTOBUF_PATH ${pre="-I":_PROTO__INCLUDE} -I$ARCADIA_ROOT ${SRCFLAGS} ${input:SRC} ${output;nopath;noext;norel:SRC.proto} ${hide;kv:"p GZ"} ${hide;kv:"pc yellow"}
  2781. .PEERDIR=kernel/gazetteer/proto
  2782. }
  2783. # tag:src-processing
  2784. macro _SRC("cfgproto", SRC, SRCFLAGS...) {
  2785. .CMD=$_CPP_CFGPROTO_CMD($SRC)
  2786. }
  2787. # tag:src-processing
  2788. macro _SRC("pyx", SRC, SRCFLAGS...) {
  2789. # Copy-paste from BUILDWITH_CYTHON
  2790. .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} ${hide;kv:"p CY"} ${hide;kv:"pc yellow"}
  2791. .SEM=target_cython_sources PRIVATE ${input:Src} ${hide;output;tobindir:Src.fake.o} && target_options-privates-ITEM && target_options-privates-option target_cython_sources && target_options-privates-args ${input:Src} ${hide;output;tobindir:Src.fake.o} && target_cython_options $CYTHON_OPTIONS --cplus ${SRCFLAGS} ${CYTHON_CPP_OUTPUT_INCLUDES} && target_macroses-ITEM && target_macroses-macro target_cython_options && target_macroses-args $CYTHON_OPTIONS --cplus ${SRCFLAGS} ${CYTHON_CPP_OUTPUT_INCLUDES} && target_cython_include_directories $_CYTHON__INCLUDE && target_macroses-ITEM && target_macroses-macro target_cython_include_directories && target_macroses-args $_CYTHON__INCLUDE && set_python_type_for_cython $PYTHON_TYPE_FOR_CYTHON && target_macroses-ITEM && target_macroses-macro set_python_type_for_cython && target_macroses-args $PYTHON_TYPE_FOR_CYTHON
  2792. .ADDINCL=FOR cython contrib/tools/cython/Cython/Includes
  2793. }
  2794. # tag:src-processing
  2795. macro _SRC("in", SRC, SRCFLAGS...) {
  2796. .CMD=$CONFIGURE_FILE(${SRC} ${nopath;noext:SRC})
  2797. .SEM=$CONFIGURE_FILE(${SRC} ${nopath;noext:SRC})
  2798. }
  2799. macro MANUAL_GENERATION(Outs...) {
  2800. .SEM=IGNORED ${hide;noauto;output:Outs}
  2801. }
  2802. # tag:src-processing
  2803. macro _SRC("sc", SRC, SRCFLAGS...) {
  2804. .CMD=${tool:"tools/domschemec"} --in ${input:SRC} --out ${output;norel:SRC.h} ${output_include;hide:"library/cpp/domscheme/runtime.h"} ${SRCFLAGS} ${hide;kv:"p SC"} ${hide;kv:"pc yellow"}
  2805. .PEERDIR=library/cpp/domscheme
  2806. }
  2807. # tag:src-processing
  2808. macro _SRC("ssqls", SRC, SRCFLAGS...) {
  2809. .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} ${hide;kv:"p SS"} ${hide;kv:"pc yellow"}
  2810. }
  2811. # tag:src-processing
  2812. macro _SRC("f", SRC, SRCFLAGS...) {
  2813. .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"} ${hide;kv:"p FT"} ${hide;kv:"pc light-green"}
  2814. .PEERDIR=contrib/libs/libf2c
  2815. .ADDINCL=contrib/libs/libf2c
  2816. }
  2817. # tag:src-processing
  2818. macro _SRC("cpp", SRC, SRCFLAGS...) {
  2819. .CMD=$_SRC_CPP_CMD_NEW
  2820. .SEM=target_sources PRIVATE ${input:SRC} ${hide;output;suf=${OBJ_SUF}.o:SRC} && target_options-privates-ITEM && target_options-privates-option target_sources && target_options-privates-args ${input:SRC} ${hide;output;suf=${OBJ_SUF}.o:SRC} $_ADD_EXTRA_FLAGS($SRCFLAGS)
  2821. .STRUCT_CMD=yes
  2822. }
  2823. # tag:src-processing
  2824. macro _SRC("cxx", SRC, SRCFLAGS...) {
  2825. .CMD=$_SRC_CPP_CMD_NEW
  2826. .SEM=target_sources PRIVATE ${input:SRC} ${hide;output;suf=${OBJ_SUF}.o:SRC} && target_options-privates-ITEM && target_options-privates-option target_sources && target_options-privates-args ${input:SRC} ${hide;output;suf=${OBJ_SUF}.o:SRC} $_ADD_EXTRA_FLAGS($SRCFLAGS)
  2827. .STRUCT_CMD=yes
  2828. }
  2829. # tag:src-processing
  2830. macro _SRC("cc", SRC, SRCFLAGS...) {
  2831. .CMD=$_SRC_CPP_CMD_NEW
  2832. .SEM=target_sources PRIVATE ${input:SRC} ${hide;output;suf=${OBJ_SUF}.o:SRC} && target_options-privates-ITEM && target_options-privates-option target_sources && target_options-privates-args ${input:SRC} ${hide;output;suf=${OBJ_SUF}.o:SRC} $_ADD_EXTRA_FLAGS($SRCFLAGS)
  2833. .STRUCT_CMD=yes
  2834. }
  2835. # tag:src-processing
  2836. macro _SRC("auxcpp", SRC, SRCFLAGS...) {
  2837. .CMD=$_SRC_CPP_CMD_NEW_FORCED
  2838. .SEM=target_sources PRIVATE ${input:SRC} ${hide;output;suf=${OBJ_SUF}.o:SRC} && target_options-privates-ITEM && target_options-privates-option target_sources && target_options-privates-args ${input:SRC} ${hide;output;suf=${OBJ_SUF}.o:SRC} $_ADD_EXTRA_FLAGS($_FORCE_CPP_FLAGS $SRCFLAGS)
  2839. .STRUCT_CMD=yes
  2840. }
  2841. # tag:src-processing
  2842. macro _SRC("C", SRC, SRCFLAGS...) {
  2843. .CMD=$_SRC_CPP_CMD_NEW
  2844. .SEM=target_sources PRIVATE ${input:SRC} ${hide;output;suf=${OBJ_SUF}.o:SRC} && target_options-privates-ITEM && target_options-privates-option target_sources && target_options-privates-args ${input:SRC} ${hide;output;suf=${OBJ_SUF}.o:SRC} $_ADD_EXTRA_FLAGS($SRCFLAGS)
  2845. .STRUCT_CMD=yes
  2846. }
  2847. # tag:src-processing
  2848. macro _SRC("c", SRC, SRCFLAGS...) {
  2849. .CMD=$_SRC_C_CMD_NEW
  2850. .SEM=target_sources PRIVATE ${input:SRC} ${hide;output;suf=${OBJ_SUF}.o:SRC} && target_options-privates-ITEM && target_options-privates-option target_sources && target_options-privates-args ${input:SRC} ${hide;output;suf=${OBJ_SUF}.o:SRC} $_ADD_EXTRA_FLAGS($SRCFLAGS $USER_CONLYFLAGS $USER_CONLYFLAGS_GLOBAL)
  2851. .STRUCT_CMD=yes
  2852. }
  2853. # tag:src-processing
  2854. macro _SRC("m", SRC, SRCFLAGS...) {
  2855. .CMD=$_SRC(c $SRC $SRCFLAGS)
  2856. }
  2857. MASM_SEM=target_sources PRIVATE ${input:SRC} ${hide;output;suf=${OBJ_SUF}.o:SRC} \
  2858. && target_options-privates-ITEM && target_options-privates-option target_sources && target_options-privates-args ${input:SRC} ${hide;output;suf=${OBJ_SUF}.o:SRC} \
  2859. && curdir_masm_flags ${MASMFLAGS} \
  2860. && dir_macroses-ITEM && dir_macroses-macro curdir_masm_flags && dir_macroses-args ${MASMFLAGS}
  2861. YASM_SEM=target_yasm_source PRIVATE ${input:SRC} ${hide;output;suf=${OBJ_SUF}.o:SRC} $YASM_FLAGS ${pre=-I :_ASM__INCLUDE} $SRCFLAGS ${pre=-P :PREINCLUDES} ${hide;input:"build/scripts/run_tool.py"} \
  2862. && target_macroses-ITEM && target_macroses-macro target_yasm_source && target_macroses-args PRIVATE ${input:SRC} ${hide;output;suf=${OBJ_SUF}.o:SRC} $YASM_FLAGS ${pre=-I :_ASM__INCLUDE} $SRCFLAGS ${pre=-P :PREINCLUDES} ${hide;input:"build/scripts/run_tool.py"} \
  2863. && 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 \
  2864. && platform_vars-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" \
  2865. && add_language ASM && project_languages ASM \
  2866. && conan_require_tool yasm/1.3.0 && conan_import '"bin, *yasm* -> ./bin"' && conan_import '"bin, ytasm* -> ./bin"' \
  2867. && conan-tool_requires yasm/1.3.0 && conan-imports 'bin, *yasm* -> ./bin' && conan-imports 'bin, ytasm* -> ./bin'
  2868. ASM_SEM=target_yasm_source PRIVATE ${input:SRC} ${hide;output;suf=${OBJ_SUF}.o:SRC} $YASM_FLAGS ${pre=-I :_ASM__INCLUDE} $SRCFLAGS ${hide;input:"build/scripts/run_tool.py"} \
  2869. && target_macroses-ITEM && target_macroses-macro target_yasm_source && target_macroses-args PRIVATE ${input:SRC} ${hide;output;suf=${OBJ_SUF}.o:SRC} $YASM_FLAGS ${pre=-I :_ASM__INCLUDE} $SRCFLAGS ${hide;input:"build/scripts/run_tool.py"} \
  2870. && 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 \
  2871. && platform_vars-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" \
  2872. && add_language ASM && project_languages ASM \
  2873. && conan_require_tool yasm/1.3.0 && conan_import '"bin, *yasm* -> ./bin"' && conan_import '"bin, ytasm* -> ./bin"' \
  2874. && conan-tool_requires yasm/1.3.0 && conan-imports 'bin, *yasm* -> ./bin' && conan-imports 'bin, ytasm* -> ./bin'
  2875. # tag:src-processing
  2876. macro _SRC("masm", SRC, SRCFLAGS...) {
  2877. .CMD=$_SRC_masm($SRC $SRCFLAGS)
  2878. .SEM=$MASM_SEM
  2879. }
  2880. # tag:src-processing
  2881. macro _SRC("yasm", SRC, SRCFLAGS...) {
  2882. .CMD=$_SRC_yasm($SRC $SRCFLAGS PREINCLUDES $YASM_PREINCLUDES_VALUE)
  2883. .SEM=$YASM_SEM
  2884. }
  2885. # tag:src-processing
  2886. macro _SRC("asm", SRC, SRCFLAGS...) {
  2887. .CMD=$_SRC_ASM($SRC $SRCFLAGS PREINCLUDES $YASM_PREINCLUDES_VALUE)
  2888. .SEM=$ASM_SEM
  2889. }
  2890. # tag:src-processing
  2891. macro _SRC("lua", SRC, SRCFLAGS...) {
  2892. .CMD=${cwd:LUAJIT_PATH} ${tool:"contrib/libs/luajit/compiler"} -b -g ${input:SRC} ${SRCFLAGS} ${global;output;suf=.o:SRC} ${hide;kv:"p LJ"} ${hide;kv:"pc light-cyan"}
  2893. .PEERDIR=$LUAJIT_PATH
  2894. }
  2895. NVCC_CFLAGS=
  2896. when ($IDE_MSVS_CALL == "yes") {
  2897. # This is to avoid issues with .pdb from MSVC calling nvcc calling cl
  2898. NVCC_CFLAGS+=/Fd$(TEMP)
  2899. }
  2900. NVCC_STD_VER=17
  2901. when ($MSVC == "yes") {
  2902. NVCC_STD=/std:c++${NVCC_STD_VER}
  2903. }
  2904. otherwise {
  2905. NVCC_STD=-std=c++${NVCC_STD_VER}
  2906. }
  2907. # tag:src-processing
  2908. macro _SRC("cu", SRC, SRCFLAGS...) {
  2909. .CMD=$_SRC_CU_CMD
  2910. .SEM=target_cuda_sources PRIVATE ${input:SRC} ${hide;output;suf=${OBJ_SUF}.o:SRC} && target_options-privates-ITEM && target_options-privates-option target_cuda_sources && target_options-privates-args ${input:SRC} ${hide;output;suf=${OBJ_SUF}.o:SRC} && set_global_flags CMAKE_CUDA_STANDARD ${NVCC_STD_VER} && platform_vars-CMAKE_CUDA_STANDARD ${quo:NVCC_STD_VER} && target_cuda_flags $CUDA_NVCC_FLAGS && target_macroses-ITEM && target_macroses-macro target_cuda_flags && target_macroses-args $CUDA_NVCC_FLAGS && target_cuda_cflags $USER_CXXFLAGS $SRCFLAGS $_SEM_EXTRA_CXX_FLAGS && target_macroses-ITEM && target_macroses-macro target_cuda_cflags && target_macroses-args $USER_CXXFLAGS $SRCFLAGS $_SEM_EXTRA_CXX_FLAGS
  2911. .PEERDIR=$_SRC_CU_PEERDIR
  2912. }
  2913. # tag:src-processing
  2914. macro _SRC("fbs", SRC, SRCFLAGS...) {
  2915. .CMD=$FBS_CMD($SRC, $SRCFLAGS)
  2916. .SEM=$FBS_CMD($SRC, $SRCFLAGS)
  2917. }
  2918. # tag:src-processing
  2919. macro _SRC("fbs64", SRC, SRCFLAGS...) {
  2920. .CMD=$_CPP_FLATC64_CMD($SRC, $SRCFLAGS)
  2921. }
  2922. # tag:src-processing
  2923. macro _SRC("pysrc", SRC, SRCFLAGS...) {
  2924. .CMD=$_SRC_PYSRC($SRC, $SRCFLAGS)
  2925. }
  2926. # tag:src-processing
  2927. # This triggers configure error in attempt to add `ya.make` to SRCS macro or apply automatic processing by extension from codegen
  2928. macro _SRC("make", SRC, SRCFLAGS...) {
  2929. .CMD=
  2930. }
  2931. @import "${CONF_ROOT}/conf/bison_lex.conf"
  2932. # tag:src-processing
  2933. macro _SRC_py2src(SRC, SRCFLAGS...) {
  2934. .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"} ${hide;kv:"p P2"} ${hide;kv:"pc light-green"}
  2935. }
  2936. # tag:src-processing
  2937. macro _SRC_py3src(SRC, SRCFLAGS...) {
  2938. .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:"tools/py3cc"} ${hide;kv:"p P3"} ${hide;kv:"pc light-green"}
  2939. }
  2940. # tag:src-processing python-specific
  2941. when ($PYTHON3 == "yes") {
  2942. _SRC_PYSRC_CMDLINE=$_SRC_py3src($SRC $SRCFLAGS)
  2943. }
  2944. elsewhen ($PYTHON2 == "yes") {
  2945. _SRC_PYSRC_CMDLINE=$_SRC_py2src($SRC $SRCFLAGS)
  2946. }
  2947. otherwise {
  2948. _SRC_PYSRC_CMDLINE=
  2949. }
  2950. # tag:src-processing tag:python-specific
  2951. macro _SRC_PYSRC(SRC, SRCFLAGS...) {
  2952. .CMD=$_SRC_PYSRC_CMDLINE
  2953. }
  2954. # tag:src-processing
  2955. macro _SRC_c_nodeps(SRC, OUTFILE, INC...) {
  2956. .CMD=$_SRC_C_NODEPS_CMD
  2957. }
  2958. # Custom flags for generated cpp-files. To support another generator:
  2959. # - insert additional file extension before .cpp into generated cpp-file name
  2960. # - update _LANG_CFLAGS_FILTER variable. Don't forget to add ' SKIP ' after flag list
  2961. #
  2962. # ragel5 and ragel6 generated terrible code which makes use of goto's in switch statements.
  2963. # This triggers -Werror-implicit-fallthrough due to `unannotated fall-through between switch labels`.
  2964. #
  2965. # cython generated code also fails to pass this diagnostics due to `fallthrough annotation in unreachable code`.
  2966. # We use cython==0.29.26 at the time. This issue might be fixed in further versions.
  2967. #
  2968. # flags -fno-profile-instr-generate -fno-coverage-mapping needed to always disable coverage for .pyx, .rl5, .rl6
  2969. # generated sources
  2970. ## tag:src-processing
  2971. when ($CLANG == "yes") {
  2972. _LANG_CFLAGS_FILTER=\
  2973. ${pre=-Wno-implicit-fallthrough -fno-profile-instr-generate -fno-coverage-mapping SKIP ;ext=.rl5:SRC} \
  2974. ${pre=-Wno-implicit-fallthrough -fno-profile-instr-generate -fno-coverage-mapping SKIP ;ext=.rl6:SRC} \
  2975. ${pre=-Wno-implicit-fallthrough -fno-profile-instr-generate -fno-coverage-mapping SKIP ;ext=.pyx:SRC}
  2976. _LANG_CFLAGS_RL=-Wno-implicit-fallthrough -fno-profile-instr-generate -fno-coverage-mapping
  2977. _LANG_CFLAGS_SWG=-Wno-deprecated-declarations -fno-profile-instr-generate -fno-coverage-mapping
  2978. _LANG_CFLAGS_LEX=-Wno-unused-variable -fno-profile-instr-generate -fno-coverage-mapping
  2979. }
  2980. otherwise {
  2981. _LANG_CFLAGS_FILTER=\
  2982. ${pre=-Wno-implicit-fallthrough SKIP ;ext=.rl5:SRC} \
  2983. ${pre=-Wno-implicit-fallthrough SKIP ;ext=.rl6:SRC} \
  2984. ${pre=-Wno-implicit-fallthrough SKIP ;ext=.pyx:SRC}
  2985. _LANG_CFLAGS_RL=-Wno-implicit-fallthrough
  2986. _LANG_CFLAGS_SWG=-Wno-deprecated-declarations
  2987. _LANG_CFLAGS_LEX=-Wno-unused-variable
  2988. }
  2989. # tag:src-processing
  2990. # Magic macro for removing file name from result (file name is passed as unused SKIP parameter)
  2991. macro _FILTER_EXTS(SKIP="", FLAGS...) {
  2992. .CMD=$FLAGS
  2993. }
  2994. # tag:src-processing
  2995. macro _LANG_CFLAGS(SRC) {
  2996. .CMD=$_FILTER_EXTS($_LANG_CFLAGS_FILTER)
  2997. }
  2998. # tag:src-processing
  2999. # ymake bug workaround: variables followed a macros call in .CMD are not substituted and are placed in result as is
  3000. # Pack macro call into a variable and use it in _SRC_CPP_CMD instead of macro call
  3001. _LANG_CFLAGS_VALUE=
  3002. _LANG_CFLAGS_VALUE_NEW=
  3003. when ($CLANG == "yes" || $CLANG_CL == "yes" || $GCC == "yes") {
  3004. _LANG_CFLAGS_VALUE=$_LANG_CFLAGS(${noext:SRC})
  3005. _LANG_CFLAGS_VALUE_NEW=\
  3006. ${pre=$_LANG_CFLAGS_RL;clear;ext=.rl5;noext;input:SRC} \
  3007. ${pre=$_LANG_CFLAGS_RL;clear;ext=.rl6;noext;input:SRC} \
  3008. ${pre=$_LANG_CFLAGS_RL;clear;ext=.pyx;noext;input:SRC} \
  3009. ${pre=$_LANG_CFLAGS_SWG;clear;ext=.swg;noext;input:SRC} \
  3010. ${pre=$_LANG_CFLAGS_LEX;clear;ext=.l;noext;input:SRC}
  3011. }
  3012. # Allows to add single compilation unit name to the node's 'kv' section.
  3013. # This is used by the coverage machinery to instrument only the necessary sources
  3014. # when --coverage-prefix-filter <rootrelpath> is specified. For more info see DEVTOOLSSUPPORT-16891
  3015. SCU_NAME_KV=
  3016. SCU_NAME_KV_NEW=
  3017. SCU_NAME_KV_NEW_BODY=scu_name ${input:SRC}
  3018. when ($CLANG_COVERAGE && $CLANG_COVERAGE != "no" && $USE_SCU_VALUE == "yes") {
  3019. SCU_NAME_KV=${hide;kv:"scu_name $KV_VAL"}
  3020. SCU_NAME_KV_NEW=${hide;kv:SCU_NAME_KV_NEW_BODY}
  3021. }
  3022. macro _ADD_SCU_NAME(KV_VAL) {
  3023. .CMD=$SCU_NAME_KV
  3024. }
  3025. # tag:src-processing
  3026. macro _SRC_cpp(SRC, COMPILE_OUT_SUFFIX="", SRCFLAGS...) {
  3027. .CMD=$_SRC_CPP_CMD $_ADD_SCU_NAME(${input:SRC})
  3028. }
  3029. # tag:src-processing
  3030. macro _SRC_c(SRC, COMPILE_OUT_SUFFIX="", SRCFLAGS...) {
  3031. .CMD=$_SRC_C_CMD $_ADD_SCU_NAME(${input:SRC})
  3032. }
  3033. # tag:src-processing
  3034. macro _SRC_m(SRC, SRCFLAGS...) {
  3035. .CMD=$_SRC_M_CMD
  3036. }
  3037. # tag:src-processing
  3038. macro _SRC_masm(SRC, SRCFLAGS...) {
  3039. .CMD=$_SRC_MASM_CMD
  3040. }
  3041. # tag:lua-specific
  3042. ### @usage: COMPILE_LUA(Src, [NAME <import_name>])
  3043. ###
  3044. ### Compile LUA source file to object code using LUA 2.0
  3045. ### Optionally override import name which is by default reflects Src name
  3046. macro COMPILE_LUA(Src, NAME="") {
  3047. .CMD=$_SRC(lua, $Src, ${pre=-n :NAME})
  3048. }
  3049. # tag:lua-specific
  3050. ### @usage: _SRC_lua_21(SRC [SRCFLAGS...]) # internal
  3051. ###
  3052. ### Compile LUA source file to object code using LUA 2.1
  3053. macro _SRC_lua_21(SRC, SRCFLAGS...) {
  3054. .CMD=${cwd:LUAJIT_21_PATH} ${tool:"contrib/libs/luajit_21/compiler"} -b -g ${input:SRC} ${SRCFLAGS} ${global;output;suf=.o:SRC} ${hide;kv:"p LJ"} ${hide;kv:"pc light-cyan"}
  3055. .PEERDIR=$LUAJIT_21_PATH
  3056. }
  3057. # tag:lua-specific
  3058. ### @usage: COMPILE_LUA_21(Src, [NAME <import_name>])
  3059. ###
  3060. ### Compile LUA source file to object code using LUA 2.1
  3061. ### Optionally override import name which is by default reflects Src name
  3062. macro COMPILE_LUA_21(Src, NAME="") {
  3063. .CMD=$_SRC_lua_21($Src, ${pre=-n :NAME})
  3064. }
  3065. # tag:lua-specific
  3066. ### @usage: _SRC_lua_openresty(SRC [SRCFLAGS...]) # internal
  3067. ###
  3068. ### Compile LUA source file to object code using OpenResty LUA 2.1
  3069. macro _SRC_lua_openresty(SRC, SRCFLAGS...) {
  3070. .CMD=${cwd:LUAJIT_OPENRESTY_PATH} ${tool:"contrib/libs/luajit_openresty/compiler"} -b -g ${input:SRC} ${SRCFLAGS} ${global;output;suf=.o:SRC} ${hide;kv:"p LJ"} ${hide;kv:"pc light-cyan"}
  3071. .PEERDIR=$LUAJIT_OPENRESTY_PATH
  3072. }
  3073. # tag:lua-specific
  3074. ### @usage: COMPILE_LUA_OPENRESTY(Src, [NAME <import_name>])
  3075. ###
  3076. ### Compile LUA source file to object code using OpenResty LUA 2.1
  3077. ### Optionally override import name which is by default reflects Src name
  3078. macro COMPILE_LUA_OPENRESTY(Src, NAME="") {
  3079. .CMD=$_SRC_lua_openresty($Src, ${pre=-n :NAME})
  3080. }
  3081. GETTEXT_KEEP_PATH=no
  3082. _MO_OUTPUT=
  3083. when ($GETTEXT_KEEP_PATH == "yes") {
  3084. _MO_OUTPUT=${noauto;output;norel;noext:SRC.mo}
  3085. }
  3086. otherwise {
  3087. _MO_OUTPUT=${noauto;output;nopath;noext;tobindir:SRC.mo}
  3088. }
  3089. # tag:src-processing
  3090. macro _SRC("po", SRC, SRCFLAGS...) {
  3091. .CMD=$YMAKE_PYTHON ${input:"contrib/tools/python/src/Tools/i18n/msgfmt.py"} -o $_MO_OUTPUT ${input:SRC}
  3092. }
  3093. # tag:ydl-specific
  3094. YDL_FLAGS= --force-color -I ${ARCADIA_ROOT}
  3095. YDL_DESC_FLAGS=
  3096. # tag:src-processing tag:ydl-specific
  3097. macro _SRC("ydl", SRC, SRCFLAGS...) {
  3098. .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"} ${hide;kv:"p YDL"} ${hide;kv:"pc yellow"}
  3099. .PEERDIR+=statbox/ydl/runtime/cpp
  3100. }
  3101. # tag:ydl-specific
  3102. ### @usage BUILD_YDL_DESC(Input Symbol Output)
  3103. ###
  3104. ### Generate a descriptor for a Symbol located in a ydl module Input, and put it to the file Output.
  3105. ###
  3106. ### @example:
  3107. ###
  3108. ### PACKAGE()
  3109. ### BUILD_YDL_DESC(../types.ydl Event Event.ydld)
  3110. ### END()
  3111. ###
  3112. ### 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.
  3113. macro BUILD_YDL_DESC(Input, Symbol, Output) {
  3114. .CMD=${tool:"statbox/ydl/compiler/tooling/ydl/bin"} ti $YDL_FLAGS $YDL_DESC_FLAGS -o ${noauto;output:Output} ${input:Input} ${Symbol} ${hide;kv:"p YDL"} ${hide;kv:"pc yellow"}
  3115. }
  3116. # tag:ydl-specific
  3117. ### @usage: YDL_DESC_USE_BINARY()
  3118. ###
  3119. ### Used in conjunction with BUILD_YDL_DESC. When enabled, all generated descriptors are binary.
  3120. ###
  3121. ### @example:
  3122. ###
  3123. ### PACKAGE()
  3124. ### YDL_DESC_USE_BINARY()
  3125. ### BUILD_YDL_DESC(../types.ydl Event Event.ydld)
  3126. ### END()
  3127. ###
  3128. ### This will generate descriptor Event.ydld in a binary format.
  3129. macro YDL_DESC_USE_BINARY() {
  3130. YDL_DESC_FLAGS_BINARY= --binary
  3131. SET_APPEND(YDL_DESC_FLAGS $YDL_DESC_FLAGS_BINARY)
  3132. }
  3133. ### @usage SRC(File Flags...)
  3134. ###
  3135. ### Compile single file with extra Flags.
  3136. ### Compilation is driven by the last extension of the File and Flags are specific to corresponding compilation command
  3137. macro SRC(FILE, FLAGS...) {
  3138. _SRC(${lastext:FILE} $FILE $FLAGS)
  3139. }
  3140. ### @usage: SRCS(<[GLOBAL] File> ...)
  3141. ###
  3142. ### 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.
  3143. ### Arcadia Paths from the root and is relative to the project's LIST are supported
  3144. ###
  3145. ### 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.
  3146. ### 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)
  3147. ###
  3148. ### @example:
  3149. ###
  3150. ### LIBRARY(test_global)
  3151. ### SRCS(GLOBAL foo.cpp)
  3152. ### END()
  3153. ###
  3154. ### 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.
  3155. macro SRCS(FILES...) {
  3156. foreach (FILE : $FILES) {
  3157. _SRC(${lastext:FILE} $FILE)
  3158. }
  3159. }
  3160. # tag:c-specific
  3161. macro _SRC_C_CUSTOM_FLAGS(SRC, COMPILE_OUT_SUFFIX, CUSTOM_FLAGS...) {
  3162. .CMD=$_SRC_c($SRC COMPILE_OUT_SUFFIX ${COMPILE_OUT_SUFFIX} ${CUSTOM_FLAGS})
  3163. .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 && target_macroses-ITEM && target_macroses-macro target_sources_custom && target_macroses-args $COMPILE_OUT_SUFFIX SRCS ${input:SRC} ${hide;output;suf=${COMPILE_OUT_SUFFIX}.o:SRC} CUSTOM_FLAGS $CUSTOM_FLAGS $USER_CONLYFLAGS $USER_CONLYFLAGS_GLOBAL
  3164. }
  3165. macro _SRC_CPP_CUSTOM_FLAGS(SRC, COMPILE_OUT_SUFFIX, CUSTOM_FLAGS...) {
  3166. .CMD=$_SRC_cpp($SRC COMPILE_OUT_SUFFIX ${COMPILE_OUT_SUFFIX} ${CUSTOM_FLAGS})
  3167. .SEM=target_sources_custom $COMPILE_OUT_SUFFIX SRCS ${input:SRC} ${hide;output;suf=${COMPILE_OUT_SUFFIX}.o:SRC} CUSTOM_FLAGS $CUSTOM_FLAGS && target_macroses-ITEM && target_macroses-macro target_sources_custom && target_macroses-args $COMPILE_OUT_SUFFIX SRCS ${input:SRC} ${hide;output;suf=${COMPILE_OUT_SUFFIX}.o:SRC} CUSTOM_FLAGS $CUSTOM_FLAGS
  3168. }
  3169. # tag:src-specific tag:cpp-specific
  3170. ### @usage: _SRC_CUSTOM_C_CPP(Ext MacroName File Flags...) # internal
  3171. ###
  3172. ### Defenition of generic macro. Report an error that the File with Ext is not
  3173. ### supported by macro MacroName if no appropriate macro specialization is found.
  3174. macro _SRC_CUSTOM_C_CPP(EXT, MACRO_NAME, FILE, COMPILE_OUT_SUFFIX, FLAGS...) {
  3175. MESSAGE(FATAL_ERROR macro [[alt1]]$MACRO_NAME[[rst]] does not support files with [[imp]].$EXT[[rst]] extension)
  3176. }
  3177. # tag:src-specific tag:cpp-specific
  3178. ### @usage: _SRC_CUSTOM_C_CPP(Ext MacroName File Flags...) # internal
  3179. ###
  3180. ### Specialization of genreric macro _SRC_CUSTOM_C_CPP which compiles a single C file (with .c extension)
  3181. macro _SRC_CUSTOM_C_CPP("c", MACRO_NAME, FILE, COMPILE_OUT_SUFFIX, FLAGS...) {
  3182. _SRC_C_CUSTOM_FLAGS($FILE $COMPILE_OUT_SUFFIX $FLAGS)
  3183. }
  3184. # tag:src-specific tag:cpp-specific
  3185. ### @usage: _SRC_CUSTOM_C_CPP(Ext MacroName File Flags...) # internal
  3186. ###
  3187. ### Specialization of genreric macro _SRC_CUSTOM_C_CPP which compiles a single Cpp file (with .cpp extension)
  3188. macro _SRC_CUSTOM_C_CPP("cpp", MACRO_NAME, FILE, COMPILE_OUT_SUFFIX, FLAGS...) {
  3189. _SRC_CPP_CUSTOM_FLAGS($FILE $COMPILE_OUT_SUFFIX $FLAGS)
  3190. }
  3191. # tag:src-specific tag:cpp-specific
  3192. ### @usage: _SRC_CUSTOM_C_CPP(Ext MacroName File Flags...) # internal
  3193. ###
  3194. ### Specialization of genreric macro _SRC_CUSTOM_C_CPP which compiles a single Cpp file (with .cxx extension)
  3195. macro _SRC_CUSTOM_C_CPP("cxx", MACRO_NAME, FILE, COMPILE_OUT_SUFFIX, FLAGS...) {
  3196. _SRC_CPP_CUSTOM_FLAGS($FILE $COMPILE_OUT_SUFFIX $FLAGS)
  3197. }
  3198. # tag:src-specific tag:cpp-specific
  3199. ### @usage: _SRC_CUSTOM_C_CPP(Ext MacroName File Flags...) # internal
  3200. ###
  3201. ### Specialization of genreric macro _SRC_CUSTOM_C_CPP which compiles a single Cpp file (with .cc extension)
  3202. macro _SRC_CUSTOM_C_CPP("cc", MACRO_NAME, FILE, COMPILE_OUT_SUFFIX, FLAGS...) {
  3203. _SRC_CPP_CUSTOM_FLAGS($FILE $COMPILE_OUT_SUFFIX $FLAGS)
  3204. }
  3205. # tag:src-specific tag:cpp-specific
  3206. ### @usage: _SRC_CUSTOM_C_CPP(Ext MacroName File Flags...) # internal
  3207. ###
  3208. ### Specialization of genreric macro _SRC_CUSTOM_C_CPP which compiles a single Cpp file (with .C extension)
  3209. macro _SRC_CUSTOM_C_CPP("C", MACRO_NAME, FILE, COMPILE_OUT_SUFFIX, FLAGS...) {
  3210. _SRC_CPP_CUSTOM_FLAGS($FILE $COMPILE_OUT_SUFFIX $FLAGS)
  3211. }
  3212. # tag:src-specific tag:cpp-specific tag:cpu
  3213. ### @uasge SRC_C_SSE2(File Flags...)
  3214. ###
  3215. ### Compile a single C/C++ file with SSE2 and additional Flags
  3216. macro SRC_C_SSE2(FILE, FLAGS...) {
  3217. _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_SSE2 $FILE .sse2 $SSE2_CFLAGS $FLAGS)
  3218. }
  3219. # tag:src-specific tag:cpp-specific tag:cpu
  3220. ### @uasge SRC_C_SSE3(File Flags...)
  3221. ###
  3222. ### Compile a single C/C++ file with SSE3 and additional Flags
  3223. macro SRC_C_SSE3(FILE, FLAGS...) {
  3224. _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_SSE3 $FILE .sse3 $SSE3_CFLAGS $FLAGS)
  3225. }
  3226. # tag:src-specific tag:cpp-specific tag:cpu
  3227. ### @uasge SRC_C_SSSE3(File Flags...)
  3228. ###
  3229. ### Compile a single C/C++ file with SSSE3 and additional Flags
  3230. macro SRC_C_SSSE3(FILE, FLAGS...) {
  3231. _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_SSSE3 $FILE .ssse3 $SSSE3_CFLAGS $FLAGS)
  3232. }
  3233. # tag:src-specific tag:cpp-specific tag:cpu
  3234. ### @uasge SRC_C_SSE4(File Flags...)
  3235. ###
  3236. ### Compile a single C/C++ file with SSE4 and additional Flags
  3237. macro SRC_C_SSE4(FILE, FLAGS...) {
  3238. _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_SSE4 $FILE .sse4 $SSE4_CFLAGS $FLAGS)
  3239. }
  3240. # tag:src-specific tag:cpp-specific tag:cpu
  3241. ### @uasge SRC_C_SSE41(File Flags...)
  3242. ###
  3243. ### Compile a single C/C++ file with SSE4.1 and additional Flags
  3244. macro SRC_C_SSE41(FILE, FLAGS...) {
  3245. _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_SSE41 $FILE .sse41 $SSE41_CFLAGS $FLAGS)
  3246. }
  3247. # tag:src-specific tag:cpp-specific tag:cpu
  3248. ### @uasge SRC_C_AVX(File Flags...)
  3249. ###
  3250. ### Compile a single C/C++ file with AVX and additional Flags
  3251. macro SRC_C_AVX(FILE, FLAGS...) {
  3252. _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_AVX $FILE .avx $AVX_CFLAGS $FLAGS)
  3253. }
  3254. # tag:src-specific tag:cpp-specific tag:cpu
  3255. ### @uasge SRC_C_AVX2(File Flags...)
  3256. ###
  3257. ### Compile a single C/C++ file with AVX2 and additional Flags
  3258. macro SRC_C_AVX2(FILE, FLAGS...) {
  3259. _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_AVX2 $FILE .avx2 $AVX2_CFLAGS $FLAGS)
  3260. }
  3261. # tag:src-specific tag:cpp-specific tag:cpu
  3262. ### @uasge SRC_C_AVX512(File Flags...)
  3263. ###
  3264. ### Compile a single C/C++ file with AVX512 and additional Flags
  3265. macro SRC_C_AVX512(FILE, FLAGS...) {
  3266. _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_AVX512 $FILE .avx512 $AVX512_CFLAGS $FLAGS)
  3267. }
  3268. # tag:src-specific tag:cpp-specific tag:cpu
  3269. ### @uasge SRC_C_AVX512(File Flags...)
  3270. ###
  3271. ### Compile a single C/C++ file with AVX512 and additional Flags
  3272. macro SRC_C_AMX(FILE, FLAGS...) {
  3273. _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_AMX $FILE .amx $AMX_CFLAGS $FLAGS)
  3274. }
  3275. # tag:src-specific tag:cpp-specific tag:cpu
  3276. ### @uasge SRC_C_XOP(File Flags...)
  3277. ###
  3278. ### Compile a single C/C++ file with (an AMD-specific instruction set,
  3279. ### see https://en.wikipedia.org/wiki/XOP_instruction_set) and additional Flags
  3280. macro SRC_C_XOP(FILE, FLAGS...) {
  3281. _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_XOP $FILE .xop $XOP_CFLAGS $FLAGS)
  3282. }
  3283. # tag:src-specific tag:cpp-specific tag:cpu
  3284. ### @uasge SRC_C_PCLMUL(File Flags...)
  3285. ###
  3286. ### Compile a single C/C++ file with PCLMUL and additional Flags
  3287. macro SRC_C_PCLMUL(FILE, FLAGS...) {
  3288. _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_PCLMUL $FILE .pclmul $PCLMUL_CFLAGS $FLAGS )
  3289. }
  3290. # tag:src-specific tag:cpp-specific
  3291. ### @usage: _SRC_STRICT_C_CPP(Ext MacroName File Flags...) # internal
  3292. ###
  3293. ### Defenition of generic macro. Report an error that the File with Ext is not
  3294. ### supported by macro MacroName if no appropriate macro specialization is found.
  3295. macro _SRC_STRICT_C_CPP(EXT, MACRO_NAME, FILE, FLAGS...) {
  3296. MESSAGE(FATAL_ERROR macro [[alt1]]$MACRO_NAME[[rst]] does not support files with [[imp]].$EXT[[rst]] extension)
  3297. }
  3298. # tag:src-specific tag:cpp-specific
  3299. ### @usage: _SRC_STRICT_C_CPP(Ext MacroName File Flags...) # internal
  3300. ###
  3301. ### Specialization of genreric macro _SRC_STRICT_C_CPP which compiles a single C file (with .c extension)
  3302. macro _SRC_STRICT_C_CPP("c", MACRO_NAME, FILE, FLAGS...) {
  3303. _SRC(c $FILE $FLAGS)
  3304. }
  3305. # tag:src-specific tag:cpp-specific
  3306. ### @usage: _SRC_STRICT_C_CPP(Ext MacroName File Flags...) # internal
  3307. ###
  3308. ### Specialization of genreric macro _SRC_STRICT_C_CPP which compiles a single Cpp file (with .cpp extension)
  3309. macro _SRC_STRICT_C_CPP("cpp", MACRO_NAME, FILE, FLAGS...) {
  3310. _SRC(cpp $FILE $FLAGS)
  3311. }
  3312. # tag:src-specific tag:cpp-specific
  3313. ### @usage: _SRC_STRICT_C_CPP(Ext MacroName File Flags...) # internal
  3314. ###
  3315. ### Specialization of genreric macro _SRC_STRICT_C_CPP which compiles a single Cpp file (with .cxx extension)
  3316. macro _SRC_STRICT_C_CPP("cxx", MACRO_NAME, FILE, FLAGS...) {
  3317. _SRC(cpp $FILE $FLAGS)
  3318. }
  3319. # tag:src-specific tag:cpp-specific
  3320. ### @usage: _SRC_STRICT_C_CPP(Ext MacroName File Flags...) # internal
  3321. ###
  3322. ### Specialization of genreric macro _SRC_STRICT_C_CPP which compiles a single Cpp file (with .cc extension)
  3323. macro _SRC_STRICT_C_CPP("cc", MACRO_NAME, FILE, FLAGS...) {
  3324. _SRC(cpp $FILE $FLAGS)
  3325. }
  3326. # tag:src-specific tag:cpp-specific
  3327. ### @usage: _SRC_STRICT_C_CPP(Ext MacroName File Flags...) # internal
  3328. ###
  3329. ### Specialization of genreric macro _SRC_STRICT_C_CPP which compiles a single Cpp file (with .C extension)
  3330. macro _SRC_STRICT_C_CPP("C", MACRO_NAME, FILE, FLAGS...) {
  3331. _SRC(cpp $FILE $FLAGS)
  3332. }
  3333. # tag:src-specific tag:cpp-specific
  3334. ### @uasge SRC_C_PIC(File Flags...)
  3335. ###
  3336. ### Compile a single C/C++ file with -fPIC and additional Flags
  3337. macro SRC_C_PIC(FILE, FLAGS...) {
  3338. _SRC_STRICT_C_CPP(${lastext:FILE} SRC_C_PIC $FILE $PIC_CFLAGS $FLAGS)
  3339. }
  3340. # tag:src-specific tag:cpp-specific
  3341. ### @uasge SRC_C_NO_LTO(File Flags...)
  3342. ###
  3343. ### Compile a single C/C++ file with link-time-optimization disabling and additional Flags
  3344. macro SRC_C_NO_LTO(FILE, FLAGS...) {
  3345. _SRC_STRICT_C_CPP(${lastext:FILE} SRC_C_NO_LTO $FILE $NO_LTO_CFLAGS $FLAGS)
  3346. }
  3347. # tag:python-processing tag:cython
  3348. # TODO: use it in [.pyx] cmd
  3349. ### @usage: BUILDWITH_CYTHON_CPP(Src Options...)
  3350. ###
  3351. ### Generates .cpp file from .pyx.
  3352. macro BUILDWITH_CYTHON_CPP(Src, Options...) {
  3353. .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 ${hide;kv:"p CY"} ${hide;kv:"pc yellow"}
  3354. .SEM=target_cython_sources PRIVATE ${input:Src} ${hide;output;tobindir:Src.fake.o} && target_options-privates-ITEM && target_options-privates-option target_cython_sources && target_options-privates-args ${input:Src} ${hide;output;tobindir:Src.fake.o} && target_cython_options $CYTHON_OPTIONS ${Options} --cplus ${CYTHON_CPP_OUTPUT_INCLUDES} && target_macroses-ITEM && target_macroses-macro target_cython_options && target_macroses-args $CYTHON_OPTIONS ${Options} --cplus ${CYTHON_CPP_OUTPUT_INCLUDES} && target_cython_include_directories $_CYTHON__INCLUDE && target_macroses-ITEM && target_macroses-macro target_cython_include_directories && target_macroses-args $_CYTHON__INCLUDE && set_python_type_for_cython $PYTHON_TYPE_FOR_CYTHON && target_macroses-ITEM && target_macroses-macro set_python_type_for_cython && target_macroses-args $PYTHON_TYPE_FOR_CYTHON
  3355. ADDINCL(FOR cython contrib/tools/cython/Cython/Includes)
  3356. }
  3357. # tag:python-processing tag:cython tag:internal
  3358. ### @usage: _BUILDWITH_CYTHON_CPP_DEP(Src Dep Options...) # internal
  3359. ###
  3360. ### Generates .cpp file from .pyx and attach extra input Dep.
  3361. ### If Dep changes the .cpp file will be re-generated.
  3362. macro _BUILDWITH_CYTHON_CPP_DEP(Src, Dep, Options...) {
  3363. .CMD=$RUN_CYTHON_SCRIPT $CYTHON_OPTIONS ${Options} --cplus ${CYTHON_CPP_OUTPUT_INCLUDES} ${pre=-I:_CYTHON__INCLUDE} ${input:Src} ${hide;input:Dep} -o ${output;tobindir;suf=${OBJ_SUF}.cpp:Src} $CYTHON_OUTPUT_INCLUDES ${hide;kv:"p CY"} ${hide;kv:"pc yellow"}
  3364. .SEM=target_cython_sources PRIVATE ${input:Src} ${hide;input:Dep} ${hide;output;tobindir:Src.fake.o} && target_options-privates-ITEM && target_options-privates-option target_cython_sources && target_options-privates-args ${input:Src} ${hide;input:Dep} ${hide;output;tobindir:Src.fake.o} && target_cython_options $CYTHON_OPTIONS ${Options} --cplus ${CYTHON_CPP_OUTPUT_INCLUDES} && target_macroses-ITEM && target_macroses-macro target_cython_options && target_macroses-args $CYTHON_OPTIONS ${Options} --cplus ${CYTHON_CPP_OUTPUT_INCLUDES} && target_cython_include_directories $_CYTHON__INCLUDE && target_macroses-ITEM && target_macroses-macro target_cython_include_directories && target_macroses-args $_CYTHON__INCLUDE && set_python_type_for_cython $PYTHON_TYPE_FOR_CYTHON && target_macroses-ITEM && target_macroses-macro set_python_type_for_cython && target_macroses-args $PYTHON_TYPE_FOR_CYTHON
  3365. ADDINCL(FOR cython contrib/tools/cython/Cython/Includes)
  3366. }
  3367. # tag:python-processing tag:cython tag:internal
  3368. ### @usage: _BUILDWITH_CYTHON_CPP_H(Src Dep Options...) # internal
  3369. ###
  3370. ### BUILDWITH_CYTHON_CPP without .pyx infix and with cdef public .h file.
  3371. macro _BUILDWITH_CYTHON_CPP_H(Src, Dep, Options...) {
  3372. .CMD=$RUN_CYTHON_SCRIPT_H $CYTHON_OPTIONS ${Options} --cplus ${CYTHON_CPP_OUTPUT_INCLUDES} ${pre=-I:_CYTHON__INCLUDE} ${input:Src} ${hide;input:Dep} -o ${output;noext;tobindir:Src.cpp} ${hide;output;addincl;noext;tobindir:Src.h} ${hide;kv:"p CY"} ${hide;kv:"pc yellow"}
  3373. ADDINCL(FOR cython contrib/tools/cython/Cython/Includes)
  3374. }
  3375. # tag:python-processing tag:cython
  3376. ### @usage: BUILDWITH_CYTHON_C(Src Options...)
  3377. ###
  3378. ### Generates .c file from .pyx.
  3379. macro BUILDWITH_CYTHON_C(Src, Options...) {
  3380. .CMD=$RUN_CYTHON_SCRIPT $CYTHON_OPTIONS ${Options} ${pre=-I:_CYTHON__INCLUDE} ${input:Src} -o ${output;tobindir;suf=${OBJ_SUF}.c:Src} $CYTHON_OUTPUT_INCLUDES ${hide;kv:"p CY"} ${hide;kv:"pc yellow"}
  3381. .SEM=target_cython_sources PRIVATE ${input:Src} ${hide;output;tobindir:Src.fake.o} && target_options-privates-ITEM && target_options-privates-option target_cython_sources && target_options-privates-args ${input:Src} ${hide;output;tobindir:Src.fake.o} && target_cython_options $CYTHON_OPTIONS ${Options} ${CYTHON_OUTPUT_INCLUDES} && target_macroses-ITEM && target_macroses-macro target_cython_options && target_macroses-args $CYTHON_OPTIONS ${Options} ${CYTHON_OUTPUT_INCLUDES} && target_cython_include_directories $_CYTHON__INCLUDE && target_macroses-ITEM && target_macroses-macro target_cython_include_directories && target_macroses-args $_CYTHON__INCLUDE && set_python_type_for_cython $PYTHON_TYPE_FOR_CYTHON && target_macroses-ITEM && target_macroses-macro set_python_type_for_cython && target_macroses-args $PYTHON_TYPE_FOR_CYTHON
  3382. ADDINCL(FOR cython contrib/tools/cython/Cython/Includes)
  3383. }
  3384. # tag:python-processing tag:cython tag:internal
  3385. ### @usage: _BUILDWITH_CYTHON_C_DEP(Src Dep Options...) # internal
  3386. ###
  3387. ### Generates .c file from .pyx and attach extra input Dep.
  3388. ### If Dep changes the .c file will be re-generated.
  3389. macro _BUILDWITH_CYTHON_C_DEP(Src, Dep, Options...) {
  3390. .CMD=$RUN_CYTHON_SCRIPT $CYTHON_OPTIONS ${Options} ${pre=-I:_CYTHON__INCLUDE} ${input:Src} ${hide;input:Dep} -o ${output;tobindir;suf=${OBJ_SUF}.c:Src} $CYTHON_OUTPUT_INCLUDES ${hide;kv:"p CY"} ${hide;kv:"pc yellow"}
  3391. .SEM=target_cython_sources PRIVATE ${input:Src} ${hide;input:Dep} ${hide;output;tobindir:Src.fake.o} && target_options-privates-ITEM && target_options-privates-option target_cython_sources && target_options-privates-args ${input:Src} ${hide;input:Dep} ${hide;output;tobindir:Src.fake.o} && target_cython_options $CYTHON_OPTIONS ${Options} ${CYTHON_OUTPUT_INCLUDES} && target_macroses-ITEM && target_macroses-macro target_cython_options && target_macroses-args $CYTHON_OPTIONS ${Options} ${CYTHON_OUTPUT_INCLUDES} && target_cython_include_directories $_CYTHON__INCLUDE && target_macroses-ITEM && target_macroses-macro target_cython_include_directories && target_macroses-args $_CYTHON__INCLUDE && set_python_type_for_cython $PYTHON_TYPE_FOR_CYTHON && target_macroses-ITEM && target_macroses-macro set_python_type_for_cython && target_macroses-args $PYTHON_TYPE_FOR_CYTHON
  3392. ADDINCL(FOR cython contrib/tools/cython/Cython/Includes)
  3393. }
  3394. # tag:python-processing tag:cython tag:internal
  3395. ### @usage: _BUILDWITH_CYTHON_C_H(Src Dep Options...) # internal
  3396. ###
  3397. ### BUILDWITH_CYTHON_C without .pyx infix and with cdef public .h file.
  3398. macro _BUILDWITH_CYTHON_C_H(Src, Dep, Options...) {
  3399. .CMD=$RUN_CYTHON_SCRIPT_H $CYTHON_OPTIONS ${Options} ${pre=-I:_CYTHON__INCLUDE} ${input:Src} ${hide;input:Dep} -o ${output;noext;tobindir:Src.c} ${hide;output;addincl;noext;tobindir:Src.h} $CYTHON_OUTPUT_INCLUDES ${hide;kv:"p CY"} ${hide;kv:"pc yellow"}
  3400. ADDINCL(FOR cython contrib/tools/cython/Cython/Includes)
  3401. }
  3402. # tag:python-processing tag:cython tag:internal
  3403. ### @usage: _BUILDWITH_CYTHON_C_API_H(Src Dep Options...) # internal
  3404. ###
  3405. ### BUILDWITH_CYTHON_C_H with cdef api _api.h file.
  3406. macro _BUILDWITH_CYTHON_C_API_H(Src, Dep, Options...) {
  3407. .CMD=$RUN_CYTHON_SCRIPT_H $CYTHON_OPTIONS ${Options} ${pre=-I:_CYTHON__INCLUDE} ${input:Src} ${hide;input:Dep} -o ${output;noext;tobindir:Src.c} ${hide;output;addincl;noext;tobindir:Src.h} ${hide;output;addincl;noext;defext=_api.h;tobindir:Src} $CYTHON_OUTPUT_INCLUDES ${hide;kv:"p CY"} ${hide;kv:"pc yellow"}
  3408. ADDINCL(FOR cython contrib/tools/cython/Cython/Includes)
  3409. }
  3410. ### @usage: BUILDWITH_RAGEL6(Src Options...)
  3411. ###
  3412. ### Compile .rl file using Ragel6.
  3413. macro BUILDWITH_RAGEL6(Src, Options...) {
  3414. .CMD=$RUN_NO_SANITIZE ${tool:"contrib/tools/ragel6"} $RAGEL6_FLAGS ${Options} -I${ARCADIA_ROOT} -o ${output;nopath;noext;defext=.rl6.cpp:Src} ${input:Src} ${hide;kv:"p R6"} ${hide;kv:"pc yellow"}
  3415. }
  3416. # tag:python-processing tag:internal
  3417. # TODO: use it in [.pyx] cmd
  3418. ### @usage: _PY_REGISTER() # internal
  3419. ###
  3420. ### Register Python 2.x module in internal resource file system. Arcadia Python 2.x importer will be retrieve these on import directive.
  3421. ###
  3422. ### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/pysrcs/#makrospyregister
  3423. macro _PY_REGISTER(Func) {
  3424. .CMD=$YMAKE_PYTHON ${input:"build/scripts/gen_py_reg.py"} $Func ${noauto;output:Func.reg.cpp} ${hide;kv:"p PY"} ${hide;kv:"pc yellow"}
  3425. SRCS(GLOBAL $Func.reg.cpp)
  3426. }
  3427. # tag:python-processing tag:internal
  3428. ### @usage: _PY3_REGISTER() # internal
  3429. ###
  3430. ### Register Python 3.x module in internal resource file system. Arcadia Python 3.x importer will be retrieve these on import directive
  3431. ###
  3432. ### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/pysrcs/#makrospyregister
  3433. macro _PY3_REGISTER(Func) {
  3434. .CMD=$YMAKE_PYTHON ${input:"build/scripts/gen_py3_reg.py"} $Func ${noauto;output:Func.reg3.cpp} ${hide;kv:"p PY"} ${hide;kv:"pc yellow"}
  3435. SRCS(GLOBAL $Func.reg3.cpp)
  3436. }
  3437. # tag:python-processing tag:internal
  3438. ### @usage: _PY_COMPILE_BYTECODE(SrcX Src) # internal
  3439. ###
  3440. ### Compile Python 2.x .py source file into Arcadia binary form suitable for PY2_PROGRAM
  3441. ###
  3442. ### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/pysrcs/#makrospyregister
  3443. macro _PY_COMPILE_BYTECODE(SrcX, Src, Dst) {
  3444. .CMD=$YMAKE_PYTHON ${input:"build/scripts/py_compile.py"} $SrcX ${input:Src} ${noauto;output:Dst.yapyc} ${hide;kv:"p PY"} ${hide;kv:"pc yellow"}
  3445. }
  3446. # tag:python-processing tag:internal
  3447. ### @usage: _PY3_COMPILE_BYTECODE(SrcX Src) # internal
  3448. ###
  3449. ### Compile Python 3.x .py source file into Arcadia binary form suitable for PY3_PROGRAM
  3450. ###
  3451. ### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/pysrcs/#makrospyregister
  3452. macro _PY3_COMPILE_BYTECODE(SrcX, Src, Dst) {
  3453. .CMD=${env:"PYTHONHASHSEED=0"} ${tool:"tools/py3cc"} $SrcX ${input:Src} ${noauto;output:Dst.yapyc3} ${hide;kv:"p PY"} ${hide;kv:"pc yellow"}
  3454. }
  3455. macro _ARCHIVE_SEM_HELPER(FLAGS[], OUT, Files...) {
  3456. .SEM=add_custom_command OUTPUT ${OUT} DEPENDS $ARCH_TOOL ${join= :Files} COMMAND $ARCH_TOOL $FLAGS ${join=\: :Files}: -o ${OUT} && target_commands-ITEM && target_commands-macro add_custom_command && target_commands-args OUTPUT ${OUT} DEPENDS $ARCH_TOOL ${join= :Files} COMMAND $ARCH_TOOL $FLAGS ${join=\: :Files}: -o ${OUT}
  3457. }
  3458. ### @usage: ARCHIVE_ASM(NAME archive_name files...)
  3459. ###
  3460. ### Similar to the macro ARCHIVE, but:
  3461. ### 1. works faster and it is better to use for large files.
  3462. ### 2. Different syntax (see examples in codesearch or users/pg/tests/archive_test)
  3463. macro ARCHIVE_ASM(NAME="", DONTCOMPRESS?"-p":"", Files...) {
  3464. .CMD=$ARCH_TOOL -q $DONTCOMPRESS ${input;join=\: :Files}: -o ${output;suf=$OBJ_SUF.rodata:NAME} ${hide;kv:"p AR"} ${hide;kv:"pc light-cyan"}
  3465. .SEM=$_ARCHIVE_SEM_HELPER(${output;suf=$OBJ_SUF.rodata:NAME} ${input:Files} FLAGS -q $DONTCOMPRESS)
  3466. }
  3467. # tag:yweb-specific
  3468. macro PIRE_INLINE_CMD(SRC) {
  3469. .CMD=${tool:"library/cpp/regex/pire/inline"} -o ${output:SRC} ${input:SRC} ${output_include;hide:SRC} ${hide;kv:"p PI"} ${hide;kv:"pc yellow"}
  3470. }
  3471. # tag:yweb-specific
  3472. macro PIRE_INLINE(FILES...) {
  3473. foreach (FILE : $FILES) {
  3474. PIRE_INLINE_CMD($FILE)
  3475. }
  3476. }
  3477. ### @usage: ARCHIVE(archive_name [DONT_COMPRESS] files...)
  3478. ###
  3479. ### Add arbitrary data to a modules. Unlike RESOURCE macro the result should be futher processed by othet macros in the module.
  3480. ###
  3481. ### Example: https://wiki.yandex-team.ru/yatool/howtowriteyamakefiles/#a1ispolzujjtekomanduarchive
  3482. macro ARCHIVE(NAME="", DONTCOMPRESS?"-p":"", Files...) {
  3483. .CMD=$ARCH_TOOL -q -x $DONTCOMPRESS ${input;join=\: :Files}: -o ${output;addincl;noauto:NAME} ${hide;kv:"p AR"} ${hide;kv:"pc light-red"}
  3484. .SEM=$_ARCHIVE_SEM_HELPER(${output;addincl;noauto:NAME} ${input:Files} FLAGS -q -x $DONTCOMPRESS) && target_sources PRIVATE $BINDIR/$NAME && target_options-privates-ITEM && target_options-privates-option target_sources && target_options-privates-args $BINDIR/$NAME
  3485. }
  3486. ### @usage: ARCHIVE_BY_KEYS(archive_name key [DONT_COMPRESS] files...)
  3487. ###
  3488. ### Add arbitrary data to a module be accessible by specified key.
  3489. ### Unlike RESOURCE macro the result should be futher processed by othet macros in the module.
  3490. ###
  3491. ### Example: https://wiki.yandex-team.ru/yatool/howtowriteyamakefiles/#a1ispolzujjtekomanduarchive
  3492. macro ARCHIVE_BY_KEYS(NAME="", KEYS="", DONTCOMPRESS?"-p":"", Files...) {
  3493. .CMD=$ARCH_TOOL -q -x $DONTCOMPRESS ${input:Files} -k $KEYS -o ${output;addincl;noauto:NAME} ${hide;kv:"p AR"} ${hide;kv:"pc light-red"}
  3494. }
  3495. #scripts
  3496. #special commands
  3497. BUILDVERSION_SCRIPT=build/scripts/build_info_gen.py
  3498. SVNVERSION_JAVA_MARKER=output-java-class
  3499. SVNVERSION_GO_MARKER=output-go
  3500. VCS_C_OBJ=$BINDIR/__vcs_version__.c$OBJECT_SUF
  3501. VCS_C_OBJ_RR=$MODDIR/__vcs_version__.c$OBJECT_SUF
  3502. VCS_C=$BINDIR/__vcs_version__.c
  3503. VCS_GO=$BINDIR/__vcs_version__.go
  3504. VCS_JAVA=$BINDIR/__vcs_version__.mf
  3505. VCS_INFO_DISABLE_CACHE__NO_UID__=
  3506. YASM_DEBUG_INFO_DISABLE_CACHE__NO_UID__=
  3507. CL_DEBUG_INFO_DISABLE_CACHE__NO_UID__=
  3508. CL_MACRO_INFO_DISABLE_CACHE__NO_UID__=
  3509. YASM_DEBUG_INFO=
  3510. CL_DEBUG_INFO=
  3511. CL_MACRO_INFO=
  3512. when ($FORCE_VCS_INFO_UPDATE == "yes") {
  3513. VCS_INFO_DISABLE_CACHE__NO_UID__=${hide;kv:"disable_cache"}
  3514. }
  3515. ### Works for pyton too.
  3516. 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))
  3517. GENERATE_VCS_GO_INFO_NODEP=$YMAKE_PYTHON3 ${input:"build/scripts/vcs_info.py"} output-go $(VCS)/vcs.json $VCS_GO $GO_ARCADIA_PROJECT_PREFIX $VCS_INFO_DISABLE_CACHE__NO_UID__
  3518. 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__
  3519. macro UPDATE_VCS_JAVA_INFO_NODEP(Jar) {
  3520. .CMD=$YMAKE_PYTHON3 ${input:"build/scripts/vcs_info.py"} output-java $(VCS)/vcs.json $VCS_JAVA $Jar $VCS_INFO_DISABLE_CACHE__NO_UID__
  3521. }
  3522. VCS_INFO_FILE=
  3523. ### @usage VCS_INFO_FILE([FILE out_file])
  3524. ###
  3525. ### Enable saving vcs info as a json-file into PACKAGE
  3526. ###
  3527. ### Info is saved to 'vcs_info.json' by default.
  3528. ### Use FILE parameter if you want another name.
  3529. ###
  3530. ### Note: macro can be used only once per module
  3531. macro VCS_INFO_FILE(FILE="vcs_info.json") {
  3532. SET(VCS_INFO_FILE $FILE)
  3533. }
  3534. ADD_VCS_INFO_FILE_CMD=
  3535. when ($VCS_INFO_FILE) {
  3536. 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__
  3537. }
  3538. ### @usage: CREATE_BUILDINFO_FOR(GenHdr)
  3539. ###
  3540. ### Creates header file to access some information about build specified via configuration variables.
  3541. ### Unlike CREATE_SVNVERSION_FOR() it doesn't take revion information from VCS, it uses revision and SandboxTaskId passed via -D options to ya make
  3542. macro CREATE_BUILDINFO_FOR(GenHdr) {
  3543. .CMD=$YIELD $CXX_COMPILER_OLD && $YIELD $CXXFLAGS && $XARGS $YMAKE_PYTHON3 ${input:BUILDVERSION_SCRIPT} ${output:GenHdr} ${hide;kv:"p BI"} ${hide;kv:"pc yellow"} ${hide;kv:"show_out"} $SVN_DEPENDS_CACHE__NO_UID__
  3544. .SEM=$RUN_PYTHON3($BUILDVERSION_SCRIPT $GenHdr \\\"${CMAKE_CXX_COMPILER}\\\" \\\"${CMAKE_CXX_FLAGS}\\\" OUT $GenHdr)
  3545. }
  3546. DECIMAL_MD5_SCRIPT=build/scripts/decimal_md5.py
  3547. DECIMAL_MD5_FIXED=
  3548. ### @usage: DECIMAL_MD5_LOWER_32_BITS(<fileName> [FUNCNAME funcName] [inputs...])
  3549. ###
  3550. ### Generates .cpp file <fileName> with one defined function 'const char* <funcName>() { return "<calculated_md5_hash>"; }'.
  3551. ### <calculated_md5_hash> will be md5 hash for all inputs passed to this macro.
  3552. macro DECIMAL_MD5_LOWER_32_BITS(File, FUNCNAME="", Opts...) {
  3553. .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} ${hide;kv:"p SV"} ${hide;kv:"pc yellow"} ${hide;kv:"show_out"}
  3554. }
  3555. # tag:internal
  3556. ### @usage $CFG_VARS # internal
  3557. ###
  3558. ### Mark commands that embed Configuration variables into files
  3559. macro CFG_VARS() {
  3560. .GEN_FROM_FILE=yes
  3561. }
  3562. ### @usage: CONFIGURE_FILE(from to)
  3563. ###
  3564. ### Copy file with the replacement of configuration variables in form of @ANY_CONF_VAR@ with their values.
  3565. ### The values are collected during configure stage, while replacement itself happens during build stage.
  3566. ### Used implicitly for .in-files processing.
  3567. macro CONFIGURE_FILE(Src, Dst) {
  3568. .CMD=$YMAKE_PYTHON ${input:"build/scripts/configure_file.py"} ${input:Src} ${output;addincl:Dst} $CFG_VARS ${hide;kv:"p CF"} ${hide;kv:"pc yellow"}
  3569. .SEM=set_vars ${CFG_VARS} && dir_macroses-ITEM && dir_macroses-macro set_vars && dir_macroses-args ${CFG_VARS} && configure_file $S/${input;rootrel:Src} $B/${output;addincl;rootrel:Dst} && target_commands-ITEM && target_commands-macro configure_file && target_commands-args $S/${input;rootrel:Src} $B/${output;addincl;rootrel:Dst}
  3570. }
  3571. # tag:flags
  3572. ### @usage: LDFLAGS(LinkerFlags...)
  3573. ###
  3574. ### Add flags to the link command line of executable or shared library/dll.
  3575. ### Note: LDFLAGS are always global. When set in the LIBRARY module they will affect all programs/dlls/tests the library is linked into.
  3576. ### Note: remember about the incompatibility of flags for gcc and cl.
  3577. macro LDFLAGS(Flags...) {
  3578. SET_APPEND(LDFLAGS_GLOBAL $Flags)
  3579. }
  3580. # tag:flags
  3581. ### @usage: CFLAGS([GLOBAL compiler_flag]* compiler_flags)
  3582. ###
  3583. ### Add the specified flags to the compilation command of C and C++ files.
  3584. ### @params: GLOBAL - Propagates these flags to dependent projects
  3585. ### Note: remember about the incompatibility flags for clang and cl (to set flags specifically for cl.exe use MSVC_FLAGS).
  3586. macro CFLAGS(Flags...) {
  3587. SET_APPEND_WITH_GLOBAL(USER_CFLAGS $Flags)
  3588. }
  3589. # tag:flags
  3590. ### @usage: GLOBAL_CFLAGS(compiler_flags)
  3591. ###
  3592. ### Add the specified flags to the compilation command of C and C++ files and propagate these flags to dependent projects
  3593. macro GLOBAL_CFLAGS(Flags...) {
  3594. SET_APPEND_WITH_GLOBAL(USER_CFLAGS ${pre=GLOBAL :Flags})
  3595. }
  3596. # tag:flags
  3597. ### @usage: MASMFLAGS(compiler flags)
  3598. ### Add the specified flags to the compilation command of .masm files.
  3599. macro MASMFLAGS(Flags...) {
  3600. SET_APPEND(MASMFLAGS $Flags)
  3601. }
  3602. # tag:flags
  3603. ### @usage: CONLYFLAGS([GLOBAL compiler_flag]* compiler_flags)
  3604. ### Add the specified flags to the compilation command of .c (but not .cpp) files.
  3605. ### @params: GLOBAL - Distributes these flags on dependent projects
  3606. macro CONLYFLAGS(Flags...) {
  3607. SET_APPEND_WITH_GLOBAL(USER_CONLYFLAGS $Flags)
  3608. }
  3609. # tag:flags
  3610. ### @usage: CXXFLAGS(compiler_flags)
  3611. ### Add the specified flags to the compilation command of .cpp (but not .c) files.
  3612. macro CXXFLAGS(Flags...) {
  3613. SET_APPEND_WITH_GLOBAL(USER_CXXFLAGS $Flags)
  3614. }
  3615. # tag:flags
  3616. ### @usage: CUDA_NVCC_FLAGS(compiler flags)
  3617. ### Add the specified flags to the compile line .cu-files.
  3618. macro CUDA_NVCC_FLAGS(Flags...) {
  3619. SET_APPEND(CUDA_NVCC_FLAGS $Flags)
  3620. }
  3621. # tag:flags
  3622. ### @usage: NVCC_DEVICE_LINK(file.cu...)
  3623. ### Run nvcc --device-link on objects compiled from srcs with --device-c.
  3624. ### This generates a stub object devlink.o that supplies missing pieces for the
  3625. ### host linker to link relocatable device objects into the final executable.
  3626. macro NVCC_DEVICE_LINK(Srcs...) {
  3627. .CMD=$NVCC_OLD $NVCC_FLAGS -o ${output;suf=${OBJ_SUF}${NVCC_OBJ_EXT}:"devlink"} -dlink ${input;suf=${OBJ_SUF}${NVCC_OBJ_EXT}:Srcs} -I$CUDA_TARGET_ROOT/include --compiler-options ${quo:C_FLAGS_PLATFORM} $NVCC_ENV ${hide;kv:"p DL"} ${hide;kv:"pc light-blue"}
  3628. .PEERDIR=build/platform/cuda
  3629. }
  3630. # tag:flags
  3631. ### @usage: CYTHON_FLAGS(compiler_flags)
  3632. ### Add the specified flags to the compilation command of .pyx files.
  3633. macro CYTHON_FLAGS(Flags...) {
  3634. SET_APPEND(CYTHON_OPTIONS $Flags)
  3635. }
  3636. ### @usage: STRIP()
  3637. ### Strip debug info from a PROGRAM, DLL or TEST.
  3638. ### This macro doesn't work in LIBRARY's, UNION's and PACKAGE's.
  3639. macro STRIP() {
  3640. ENABLE(STRIP)
  3641. }
  3642. ### @usage: NO_OPTIMIZE()
  3643. ### Build code without any optimizations (-O0 mode).
  3644. macro NO_OPTIMIZE() {
  3645. ENABLE(NO_OPTIMIZE)
  3646. }
  3647. #TODO(YMAKE-91) read proper compile flags instead of sending explicit flags to semgraph directly
  3648. _SEM_EXTRA_CXX_FLAGS=
  3649. ### @usage: NO_COMPILER_WARNINGS()
  3650. ### Disable all compiler warnings in the module.
  3651. ### Priorities: NO_COMPILER_WARNINGS > NO_WERROR > WERROR_MODE > WERROR.
  3652. macro NO_COMPILER_WARNINGS() {
  3653. ENABLE(NO_COMPILER_WARNINGS)
  3654. SET(_SEM_EXTRA_CXX_FLAGS "$<IF:$<CXX_COMPILER_ID:MSVC>,,-Wno-everything>")
  3655. }
  3656. ### @usage: WERROR()
  3657. ### Consider warnings as errors in the current module.
  3658. ### In the bright future will be removed, since WERROR is the default.
  3659. ### Priorities: NO_COMPILER_WARNINGS > NO_WERROR > WERROR_MODE > WERROR.
  3660. macro WERROR() {
  3661. ENABLE(WERROR)
  3662. }
  3663. ### @usage: NO_WERROR()
  3664. ### Override WERROR() behavior
  3665. ### Priorities: NO_COMPILER_WARNINGS > NO_WERROR > WERROR_MODE > WERROR.
  3666. macro NO_WERROR() {
  3667. DISABLE(WERROR)
  3668. }
  3669. ### @usage: NO_WSHADOW()
  3670. ### Disable C++ shadowing warnings.
  3671. macro NO_WSHADOW() {
  3672. ENABLE(NO_WSHADOW)
  3673. }
  3674. # tag:internal
  3675. ### @usage: NO_PLATFORM_RESOURCES() # internal
  3676. ### Exclude dependency on platform resources libraries.
  3677. ### Most probably you'll never need this. If you think you need, please contact devtools@ for assistance.
  3678. macro NO_PLATFORM_RESOURCES() {
  3679. ENABLE(NOPLATFORM_RESOURCES)
  3680. }
  3681. # tag:internal tag:codenav
  3682. ### @usage: NO_CODENAVIGATION() # internal
  3683. ### Disable codenaviagtion for a module. Needed to avoid PEERDIR loops in codenavigation support.
  3684. ### Most probably you'll never need this. If you think you need, please contact devtools@ for assistance.
  3685. macro NO_CODENAVIGATION() {
  3686. ENABLE(NOCODENAVIGATION)
  3687. }
  3688. ### @usage: NO_UTIL()
  3689. ### Build module without dependency on util.
  3690. ### Note: use this with care. Util most likely will be linked into executable anyway,
  3691. ### so using util headers/functions/classes may not be detected at build time and may lead to unpredictable behavors at configure time.
  3692. macro NO_UTIL() {
  3693. ENABLE(NOUTIL)
  3694. }
  3695. ### @usage: NO_RUNTIME()
  3696. ###
  3697. ### This macro:
  3698. ### 1. Sets the ENABLE(NOUTIL) + DISABLE(USE_INTERNAL_STL);
  3699. ### 2. If the project that contains the macro NO_RUNTIME(), peerdir-it project does not contain NO_RUNTIME() => Warning.
  3700. ### Note: use this with care. Arcadia STL most likely will be linked into executable anyway, so using STL headers/functions/classes
  3701. ### may not be detected at build time and may lead to unpredictable behavors at configure time.
  3702. macro NO_RUNTIME() {
  3703. SET(USE_ARCADIA_LIBM no)
  3704. NO_UTIL()
  3705. ENABLE(NORUNTIME)
  3706. }
  3707. ### @usage: NO_LIBC()
  3708. ###
  3709. ### Exclude dependencies on C++ and C runtimes (including util, musl and libeatmydata).
  3710. ### Note: use this with care. libc most likely will be linked into executable anyway,
  3711. ### so using libc headers/functions may not be detected at build time and may lead to unpredictable behavors at configure time.
  3712. macro NO_LIBC() {
  3713. NO_RUNTIME()
  3714. DISABLE(MUSL)
  3715. ENABLE(NOLIBC)
  3716. }
  3717. ### @usage: NO_PLATFORM()
  3718. ###
  3719. ### Exclude dependencies on C++ and C runtimes (including util, musl and libeatmydata) and set NO_PLATFORM variable for special processing.
  3720. ### Note: use this with care. libc most likely will be linked into executable anyway,
  3721. ### so using libc headers/functions may not be detected at build time and may lead to unpredictable behavors at configure time.
  3722. macro NO_PLATFORM() {
  3723. NO_LIBC()
  3724. ENABLE(NOPLATFORM)
  3725. }
  3726. # tag:cpp-specific
  3727. ### @usage: USE_CXX()
  3728. ###
  3729. ### Add dependency on C++ runtime
  3730. ### Note: This macro is inteneded for use in _GO_BASE_UNIT like module when the module is built without C++ runtime by default
  3731. macro USE_CXX() {
  3732. DISABLE(NORUNTIME)
  3733. }
  3734. ### @usage: USE_UTIL()
  3735. ###
  3736. ### Add dependency on util and C++ runtime
  3737. ### Note: This macro is intended for use in _GO_BASE_UNIT like module when the module is build without util by default
  3738. macro USE_UTIL() {
  3739. USE_CXX()
  3740. DISABLE(NOUTIL)
  3741. }
  3742. ### @usage: USE_NASM()
  3743. ###
  3744. ### Build only .asm files with nasm toolchain instead of yasm
  3745. ### Add to ya.make file ADDINCL(asm ...) with all folders where .asm files include smth
  3746. macro USE_NASM() {
  3747. ENABLE(USE_NASM_ASSEMBLER)
  3748. PEERDIR(build/external_resources/nasm)
  3749. }
  3750. # tag:deprecated
  3751. ### @usage: NO_JOIN_SRC() # deprecated, does-nothing
  3752. ### This macro currently does nothing. This is default behavior which cannot be overridden at module level.
  3753. macro NO_JOIN_SRC() {
  3754. ENABLE(UNUSED_MACRO)
  3755. }
  3756. # tag:sanitize
  3757. ### @usage: NO_SANITIZE()
  3758. ###
  3759. ### Disable all sanitizers for the module.
  3760. macro NO_SANITIZE() {
  3761. DISABLE(SANITIZER_TYPE)
  3762. }
  3763. # tag:coverage tag:sanitize
  3764. ### @usage: NO_SANITIZE_COVERAGE()
  3765. ###
  3766. ### Disable lightweight coverage (-fsanitize-coverage) for the module.
  3767. ### Sanitize coverage is commonly used with fuzzing.
  3768. ### It might be useful to disable it for libraries that should never
  3769. ### be the main targets for fuzzing, like libfuzzer library itself.
  3770. ### Sanitize coverage instrumentation is enabled by the --sanitize-coverage option.
  3771. macro NO_SANITIZE_COVERAGE() {
  3772. DISABLE(SANITIZE_COVERAGE)
  3773. }
  3774. # tag:coverage
  3775. ### @usage: NO_CLANG_COVERAGE()
  3776. ###
  3777. ### Disable heavyweight clang coverage for the module. Clang coverage instrumentation is enabled by the --clang-coverage option.
  3778. macro NO_CLANG_COVERAGE() {
  3779. DISABLE(CLANG_COVERAGE)
  3780. }
  3781. # tag:coverage
  3782. ### @usage: NO_PROFILE_RUNTIME()
  3783. ###
  3784. ### Never link this target with profile runtime. Only should be used for very basic build tools
  3785. macro NO_PROFILE_RUNTIME() {
  3786. DISABLE(NEED_PROFILE_RUNTIME)
  3787. }
  3788. macro NO_CLANG_TIDY() {
  3789. DISABLE(TIDY_ENABLED)
  3790. }
  3791. # tag:lua-specific
  3792. LUAJIT_PATH=${ARCADIA_ROOT}/contrib/libs/luajit
  3793. macro _LUAJIT_OBJDUMP(Src, OUT="") {
  3794. .CMD=${cwd:LUAJIT_PATH} ${tool:"contrib/libs/luajit/compiler"} -b -g ${input:Src} ${noauto;output:OUT} ${hide;kv:"p LJ"} ${hide;kv:"pc light-cyan"}
  3795. }
  3796. # tag:lua-specific
  3797. LUAJIT_21_PATH=${ARCADIA_ROOT}/contrib/libs/luajit_21
  3798. macro _LUAJIT_21_OBJDUMP(Src, OUT="") {
  3799. .CMD=${cwd:LUAJIT_21_PATH} ${tool:"contrib/libs/luajit_21/compiler"} -b -g ${input:Src} ${noauto;output:OUT} ${hide;kv:"p LJ"} ${hide;kv:"pc light-cyan"}
  3800. }
  3801. # tag:lua-specific
  3802. LUAJIT_OPENRESTY_PATH=${ARCADIA_ROOT}/contrib/libs/luajit_openresty
  3803. macro _LUAJIT_OPENRESTY_OBJDUMP(Src, OUT="") {
  3804. .CMD=${cwd:LUAJIT_OPENRESTY_PATH} ${tool:"contrib/libs/luajit_openresty/compiler"} -b -g ${input:Src} ${noauto;output:OUT} ${hide;kv:"p LJ"} ${hide;kv:"pc light-cyan"}
  3805. }
  3806. ### @usage: GENERATE_ENUM_SERIALIZATION(File.h)
  3807. ###
  3808. ### Create serialization support for enumeration members defined in the header (String <-> Enum conversions) and compile it into the module.
  3809. ###
  3810. ### Documentation: https://wiki.yandex-team.ru/yatool/HowToWriteYaMakeFiles/
  3811. macro GENERATE_ENUM_SERIALIZATION(File) {
  3812. .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"} ${hide;kv:"p EN"} ${hide;kv:"pc yellow"}
  3813. .SEM=generate_enum_serilization ${input:File} ${hide;output;suf=_serialized.o:File} INCLUDE_HEADERS ${input;rootrel:File} ${hide;tool:"tools/enum_parser/enum_parser"} && target_macroses-ITEM && target_macroses-macro generate_enum_serilization && target_macroses-args ${input:File} ${hide;output;suf=_serialized.o:File} INCLUDE_HEADERS ${input;rootrel:File} ${hide;tool:"tools/enum_parser/enum_parser"}
  3814. PEERDIR(tools/enum_parser/enum_serialization_runtime)
  3815. }
  3816. ### @usage: GENERATE_ENUM_SERIALIZATION_WITH_HEADER(File.h)
  3817. ###
  3818. ### Create serialization support for enumeration members defined in the header (String <-> Enum conversions) and compile it into the module
  3819. ### Provide access to serialization functions via generated header File_serialized.h
  3820. ###
  3821. ### Documentation: https://wiki.yandex-team.ru/yatool/HowToWriteYaMakeFiles/
  3822. macro GENERATE_ENUM_SERIALIZATION_WITH_HEADER(File) {
  3823. .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} ${hide;kv:"p EN"} ${hide;kv:"pc yellow"}
  3824. .SEM=generate_enum_serilization ${input:File} ${hide;output;suf=_serialized.o:File} GEN_HEADER ${output;suf=_serialized.h:File} INCLUDE_HEADERS ${input;rootrel:File} ${hide;tool:"tools/enum_parser/enum_parser"} && target_macroses-ITEM && target_macroses-macro generate_enum_serilization && target_macroses-args ${input:File} ${hide;output;suf=_serialized.o:File} GEN_HEADER ${output;suf=_serialized.h:File} INCLUDE_HEADERS ${input;rootrel:File} ${hide;tool:"tools/enum_parser/enum_parser"}
  3825. PEERDIR(tools/enum_parser/enum_serialization_runtime)
  3826. }
  3827. ### @usage: DEB_VERSION(File)
  3828. ###
  3829. ### Creates a header file DebianVersion.h define the DEBIAN_VERSION taken from the File.
  3830. macro DEB_VERSION(File) {
  3831. .CMD=$YMAKE_PYTHON ${input:"build/scripts/mkver.py"} ${input:File} ${output;stdout:"DebianVersion.h"} ${hide;kv:"p CL"} ${hide;kv:"pc yellow"}
  3832. }
  3833. ### @usage: NEED_CHECK()
  3834. ###
  3835. ### Commits to the project marked with this macro will be blocked by pre-commit check and then will be
  3836. ### automatically merged to trunk only if there is no new broken build targets in check results.
  3837. ### The use of this macro is disabled by default.
  3838. macro NEED_CHECK(Flags...) {
  3839. # TODO: FIXME
  3840. ENABLE(UNUSED_MACRO)
  3841. }
  3842. ### @usage: NO_NEED_CHECK()
  3843. ###
  3844. ### Commits to the project marked with this macro will not be affected by higher-level NEED_CHECK macro.
  3845. macro NO_NEED_CHECK(Flags...) {
  3846. ENABLE(UNUSED_MACRO)
  3847. }
  3848. # tag:deprecated
  3849. ### @usage: NEED_REVIEW() # deprecated
  3850. ###
  3851. ### Mark the project as needing review.
  3852. ### Reviewers are listed in the macro OWNER. The use of this macro is disabled by default.
  3853. ### Details can be found here: https://clubs.at.yandex-team.ru/arcadia/6104
  3854. macro NEED_REVIEW(Flags...) {
  3855. # TODO: FIXME
  3856. ENABLE(UNUSED_MACRO)
  3857. }
  3858. MODVER=unknown
  3859. ### @usage: VERSION(Args...)
  3860. ###
  3861. ### Specify version of a module. Currently unused by build system, only informative.
  3862. macro VERSION(Flags...) {
  3863. SET(MODVER ${Flags})
  3864. }
  3865. DATAWORK_SCHEEME_EXPORT_FLAGS=
  3866. when ($UNIX == "yes") {
  3867. SCHEEME2_CFLAGS= -E -x c++
  3868. }
  3869. when ($WIN32 == "yes") {
  3870. SCHEEME2_CFLAGS= /E /TP
  3871. }
  3872. SCHEEME2_STRUCT_INFO_FLAGS=-f "const static ui32 RecordSig" -u "RecordSig" --gcc44_no_typename --no_complex_overloaded_func_export
  3873. ### @usage: GEN_SCHEEME2(scheeme_name from_file dependent_files...)
  3874. ###
  3875. ### Generates a C++ description for structure(contains the field RecordSig) in the specified file (and connected).
  3876. ###
  3877. ### 1. ${scheeme_name}.inc - the name of the generated file.
  3878. ### 2. Use an environment variable - DATAWORK_SCHEEME_EXPORT_FLAGS that allows to specify flags to tools/structparser
  3879. ###
  3880. ### @example:
  3881. ###
  3882. ### SET(DATAWORK_SCHEEME_EXPORT_FLAGS --final_only -m "::")
  3883. ###
  3884. ### 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)
  3885. ### sets in extra option
  3886. ###
  3887. ### @example:
  3888. ###
  3889. ### SET(EXTRACT_STRUCT_INFO_FLAGS -f \"const static ui32 RecordSig\"
  3890. ### -u \"RecordSig\" -n${scheeme_name}SchemeInfo ----gcc44_no_typename no_complex_overloaded_func_export
  3891. ### ${DATAWORK_SCHEEME_EXPORT_FLAGS})
  3892. ###
  3893. ### for compatibility with C++ compiler and the external environment.
  3894. ### See tools/structparser for more details.
  3895. macro GEN_SCHEEME2(ScheemeName, FromFile) {
  3896. .CMD=$CXX_COMPILER_OLD $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} ${hide;kv:"p SH"} ${hide;kv:"pc yellow"}
  3897. }
  3898. ### @usage: SYMLINK(from to)
  3899. ### Add symlink
  3900. macro SYMLINK(From, To) {
  3901. .CMD=$YMAKE_PYTHON ${input:"build/scripts/symlink.py"} ${input;dirallowed:From} ${noauto;output:To} ${hide;kv:"p LN"} ${hide;kv:"pc light-cyan"}
  3902. }
  3903. # tag:internal
  3904. ### @usage: _TARGET_SOURCES_FOR_HEADERS_IMPL([GENERATE] Args...) # internal
  3905. ### Generate prefix " && target_sources PRIVATE " before $Args when GENERATE is specified in the list of actual arguments
  3906. macro _TARGET_SOURCES_FOR_HEADERS_IMPL(GENERATE?" && target_sources PRIVATE ":"", Args...) {
  3907. .SEM=$GENERATE ${output;ext=.h:Args} ${output;ext=.hh:Args} ${output;ext=.hpp:Args} ${output;ext=.inc:Args} ${output;ext=.i:Args}
  3908. }
  3909. # tag:internal
  3910. ### @usage: _TARGET_SOURCES_FOR_HEADERS(Args...) # internal
  3911. ### Generate prefix " && target_sources PRIVATE " before $Args if Args is not empty
  3912. macro _TARGET_SOURCES_FOR_HEADERS(Args...) {
  3913. .SEM=$_TARGET_SOURCES_FOR_HEADERS_IMPL(${pre=GENERATE :Args})
  3914. }
  3915. # tag:internal
  3916. ### @usage: _TARGET_SOURCES_FOR_HEADERS_IMPL([GENERATE] Args...) # internal
  3917. ### Generate prefix " ${CMAKE_COMMAND} -E env " before $Args when GENERATE is specified in the list of actual arguments
  3918. macro _SET_ENV_FOR_CUSTOM_COMMAND_IMPL(GENERATE?" ${CMAKE_COMMAND} -E env ":"", Args...) {
  3919. .SEM=$GENERATE ${pre= :Args}
  3920. }
  3921. # tag:internal
  3922. ### @usage: _SET_ENV_FOR_CUSTOM_COMMAND(Args...) # internal
  3923. ### Generate prefix " ${CMAKE_COMMAND} -E env " before $Args if Args is not empty
  3924. macro _SET_ENV_FOR_CUSTOM_COMMAND(Args...) {
  3925. .SEM=$_SET_ENV_FOR_CUSTOM_COMMAND_IMPL(${pre=GENERATE :Args})
  3926. }
  3927. macro _FMT_INDUCED_DEPS(For, Deps...) {
  3928. .CMD=${induced_deps=$For;hide:Deps}
  3929. }
  3930. ### @usage: PREPARE_INDUCED_DEPS(VAR Type Files...)
  3931. ###
  3932. ### Format value for `INDUCED_DEPS` param in certain macros and assign to `VAR`
  3933. ### This tells that files of Type resulted from code generation macros (not neccessarily directly,
  3934. ### but in processing chain of generated files) should have extra dependencies from list of Files...
  3935. ###
  3936. ### Prominent example here is Cython: one can generate .pyx file that may depend on .pxd and have cimpot from
  3937. ### certain .h. The former is dependency for .pyx itself, while the latter is dependency for .pyx.cpp
  3938. ### resulted from Cython-processing of generated pyx. The code ganeration will look like:
  3939. ### ```
  3940. ### PREPARE_INDUCED_DEPS(PYX_DEPS pyx imported.pxd)
  3941. ### PREPARE_INDUCED_DEPS(CPP_DEPS cpp cdefed.h)
  3942. ### RUN_PYTHON3(generate_pyx.py genereted.pyx OUT generated.pyx INDUCED_DEPS $PYX_DEPS $CPP_DEPS)
  3943. ### ```
  3944. ###
  3945. ### The VAR will basically contain pair of `Type:[Files...]` in a form suitable for passing
  3946. ### as an element of array parameter. This is needed because language of ya.make doesn't support
  3947. ### Dict params right now and so it is impossible to directly pass something
  3948. ### like `{Type1:[Files2...], Type2:[Files2...]}`
  3949. ###
  3950. macro PREPARE_INDUCED_DEPS(VAR, For, Deps...) {
  3951. SET($VAR \$_FMT_INDUCED_DEPS($For $Deps))
  3952. }
  3953. ### Helper macro for DECLARE_IN_DIRS to add proper '/' to non-empty SRCDIR and form proper EXCLUDES
  3954. macro _DECL_IN_DIR_GLOB(var_prefix, pattern, rec_part, SRCDIR="", EXCLBASE="", EXCLUDES[], DIRS[], DUMMY[]) {
  3955. _PATTERN=${pre=${SRCDIR};suf=/${rec_part}${pattern}:DIRS}
  3956. _EXCLUDES=${EXCLBASE}**/ya.make ${EXCLBASE}**/a.yaml ${pre=${EXCLBASE}:EXCLUDES}
  3957. _LATE_GLOB(_${var_prefix}_FILES ${_PATTERN} EXCLUDE ${_EXCLUDES})
  3958. SET(${var_prefix}_PATTERN ${_PATTERN})
  3959. SET(${var_prefix}_EXCLUDES ${_EXCLUDES})
  3960. }
  3961. ### @usage: DECLARE_IN_DIR(var_prefix files_mask DIRS dirs [RECURSIVE] [EXCLUDES excludes] [SRCDIR srcdir])
  3962. ###
  3963. ### This macro allow passing content of directories to macros like `RUN_PROGRAM` and `RUN_PYTHON3` as IN parameter.
  3964. ###
  3965. ### The content is matched by following rules:
  3966. ### - The files are looked in <srcdir>. The srcdir is relative to module directory and defaulted to module directory.
  3967. ### - Inside <srcdir> files are looked in all <dirs>, recursively or not depending on RECURSIVE parameter.
  3968. ### - Files are matched by file_mask which may contain * or ?.
  3969. ### - <excludes> are then applied over matched files. Excludes are regular globs including recursive parts support.
  3970. ###
  3971. ### Taking `var_prefix` macro declared 4 variables:
  3972. ### - <var_prefix>_FILES - the file list matched by the macro using rules above. This variable can be passed to `IN` parameter of `RUN_PROGRAM` and alikes.
  3973. ### Also it may be passed escaped as argument to tool/script. See example below.
  3974. ### - <var_prefix>_PATTERNS - the glob patterns used for match.
  3975. ### - <var_prefix>_EXCLUDES - exclude patterns from EXCLUDES argument and ones to exclude ya.make and a.yaml
  3976. ### - <var_prefix>_SRCDIR - value of SRCDIR argument
  3977. ###
  3978. ### Parameters:
  3979. ### - var_prefix - Mandatory prefix of variables the macro declares
  3980. ### - file_mask - Mandatory glob-like mask for files
  3981. ### file_mask should not conatain '**'
  3982. ### - DIRS dirs - Mandatory list of dirs relative to srcdir or current one in which files should be looked
  3983. ### Dirs cannot contain ${ARCADIA_ROOT} (and other similar vars), '..', '*' or '?'.
  3984. ### - RECURSIVE - Optional request to lookup dirs recursively. Default is non-recursive lookup
  3985. ### - EXCLUDES excludes - Optional list of globs to exclude from match.
  3986. ### - SRCDIR srcdir - Optional directory (relative to current one) to apply globs. Default is the current dir.
  3987. ### We strongly discourage this, but srcdir may contain '..' or start from ${ARCADIA_ROOT} for root-relative addressing.
  3988. ### scrdir cannot contain any of '*' or '?'
  3989. ###
  3990. ### Examples:
  3991. ### ```
  3992. ### DECLARE_IN_DIRS(TXT *.txt DIRS . EXCLUDE .*.txt **/.*.txt)
  3993. ### # file list requires escaping as argument
  3994. ### RUN_PYTHON3(concat.py \${TXT_FILES} IN ${TXT_FILES} STDOUT concatenated.txt)
  3995. ### ```
  3996. ###
  3997. ### ```
  3998. ### DECLARE_IN_DIRS(ALL_TXT *.txt SRCDIR txt RECURSIVE DIRS design rules EXCLUDE all.txt)
  3999. ### RUN_PYTHON3(concat_all.py --dirs ${MODDIR}/${ALL_TXT_SRCDIR} --pattern ${ALL_TXT_PATTERNS} --exclude ${ALL_TXT_EXCLUDES} IN ${ALL_TXT_FILES} STDOUT concatenated.txt)
  4000. ### ```
  4001. ###
  4002. ### ```
  4003. ### DECLARE_IN_DIRS(D_TXT *.txt SRCDIR txt/design EXCLUDE all.txt DIRS .)
  4004. ### DECLARE_IN_DIRS(R_TXT *.txt SRCDIR txt/rules DIRS .)
  4005. ### RUN_PYTHON3(concat_all.py --dirs ${MODDIR}/${D_TXT_SRCDIR} ${MODDIR}/${R_TXT_SRCDIR} --patterns ${D_TXT_PATTERNS} ${R_TXT_PATTERNS} --exclude ${D_TXT_EXCLUDES} IN ${D_TXT_FILES} ${R_TXT_FILES} STDOUT concatenated.txt)
  4006. ### ```
  4007. ###
  4008. ### Notes:
  4009. ### 1. All 'ya.make' and 'a.yaml' files are excluded from match.
  4010. ### 2. Matched files are never parsed for dependencies even though they shall be passed to IN, not to IN_NOPARSE.
  4011. ### 3. The list of files expanded late and will not work in macros like SRCS. This macro only meant for use with generating macros like RUN_PROGRAM processing entire matching list with one command.
  4012. ### 4. We support extended file mask syntax for multiple masks like "(*.cpp|*.h)". However, this will be preserved in <var_prefix>_PATTERNS variable and so tool/script either should support such syntax or
  4013. ### or should not rely on value of the variable for actual matching.
  4014. ### 5. There is known issue with empty match and escaped substitution like `concat.py \${TXT_FILES}`. It may result in weird errors and can be workarounded by extra argument like `concat.py - \${TXT_FILES}`
  4015. ### 6. EXCLUDES work differently with SRCDIR is specified. Use discriminating tail of SRCDIR in order to match exact files non-recursively.
  4016. ### E.g. if SRCDIR is a/b/zz and EXCLUDE is *.x the exclude will work recursively on all matches including zz's child dierctories. To limit match to zz's level use EXCLUDE zz/*.x instead.
  4017. ### 6. Parameters of macro are somewhat validated and we may add extra checks in the fulture including protection over too broad match.
  4018. ###
  4019. macro DECLARE_IN_DIRS(var_prefix, PATTERN, SRCDIR="", RECURSIVE?"**/":"", EXCLUDES[], DIRS[]) {
  4020. _DECL_IN_DIR_GLOB($var_prefix $PATTERN $RECURSIVE ${pre=SRCDIR ;suf=/:SRCDIR} ${pre=EXCLBASE ${ARCADIA_ROOT}/**/ DUMMY :SRCDIR} EXCLUDES ${EXCLUDES} DIRS ${DIRS})
  4021. SET(${var_prefix}_FILES \$_${var_prefix}_FILES)
  4022. SET(${var_prefix}_SRCDIR $SRCDIR)
  4023. VALIDATE_IN_DIRS(${var_prefix}_FILES $PATTERN $SRCDIR -- $DIRS)
  4024. }
  4025. ### @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...])
  4026. ###
  4027. ### Run a program from arcadia.
  4028. ### These macros are similar: RUN_PROGRAM, RUN_LUA, PYTHON.
  4029. ###
  4030. ### Parameters:
  4031. ### - tool_path - Path to the directory of the tool.
  4032. ### - args... - Program arguments. Relative paths listed in TOOL, IN, OUT, STDOUT become absolute.
  4033. ### - CWD dir - Absolute path of the working directory.
  4034. ### - ENV key=value... - Environment variables.
  4035. ### - TOOL tools... - Auxiliary tool directories.
  4036. ### - IN[_NOPARSE] inputs... - Input files. NOPARSE inputs are treated as textual and not parsed for dependencies regardless of file extensions.
  4037. ### - OUT[_NOAUTO] outputs... - Output files. NOAUTO outputs are not automatically added to the build process.
  4038. ### - STDOUT[_NOAUTO] output - Redirect the standard output to the output file.
  4039. ### - OUTPUT_INCLUDES output_includes... - Includes of the output files that are needed to build them.
  4040. ### - INDUCED_DEPS $VARs... - Dependencies for generated files. Unlike `OUTPUT_INCLUDES` these may target files further in processing chain.
  4041. ### In order to do so VAR should be filled by PREPARE_INDUCED_DEPS macro, stating target files (by type) and set of dependencies
  4042. ###
  4043. ### For absolute paths use ${ARCADIA_ROOT} and ${ARCADIA_BUILD_ROOT}, or
  4044. ### ${CURDIR} and ${BINDIR} which are expanded where the outputs are used.
  4045. ### 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).
  4046. 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...) {
  4047. .CMD=${cwd:CWD} ${env:ENV} ${tool:Tool} $Args ${hide;input:IN} ${input;context=TEXT;hide:IN_NOPARSE} ${hide;input:IN_DEPS} ${output_include;hide:OUTPUT_INCLUDES} $INDUCED_DEPS ${hide;tool:TOOL} ${hide;output:OUT} ${hide;noauto;output:OUT_NOAUTO} ${output;stdout:STDOUT} ${output;stdout;noauto:STDOUT_NOAUTO} ${hide;kv:"p PR"} ${hide;kv:"pc yellow"} ${hide;kv:"show_out"}
  4048. .SEM=add_custom_command $_SET_ENV_FOR_CUSTOM_COMMAND($ENV) OUTPUT ${output:OUT} ${noauto;output:OUT_NOAUTO} ${output:STDOUT} ${noauto;output: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) && target_commands-ITEM && target_commands-macro add_custom_command && target_commands-args $_SET_ENV_FOR_CUSTOM_COMMAND($ENV) OUTPUT ${output:OUT} ${noauto;output:OUT_NOAUTO} ${output:STDOUT} ${noauto;output: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)
  4049. }
  4050. # tag:lua-specific
  4051. ### @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...])
  4052. ###
  4053. ### Run a lua script.
  4054. ### These macros are similar: RUN_PROGRAM, RUN_LUA, PYTHON.
  4055. ###
  4056. ### Parameters:
  4057. ### - script_path - Path to the script.3
  4058. ### - args... - Program arguments. Relative paths listed in TOOL, IN, OUT, STDOUT become absolute.
  4059. ### - CWD dir - Absolute path of the working directory.
  4060. ### - ENV key=value... - Environment variables.
  4061. ### - TOOL tools... - Auxiliary tool directories.
  4062. ### - IN[_NOPARSE] inputs... - Input files. NOPARSE inputs are treated as textual and not parsed for dependencies regardless of file extensions.
  4063. ### - OUT[_NOAUTO] outputs... - Output files. NOAUTO outputs are not automatically added to the build process.
  4064. ### - STDOUT[_NOAUTO] output - Redirect the standard output to the output file.
  4065. ### - OUTPUT_INCLUDES output_includes... - Includes of the output files that are needed to build them.
  4066. ### - INDUCED_DEPS $VARs... - Dependencies for generated files. Unlike `OUTPUT_INCLUDES` these may target files further in processing chain.
  4067. ### In order to do so VAR should be filled by PREPARE_INDUCED_DEPS macro, stating target files (by type) and set of dependencies
  4068. ###
  4069. ### For absolute paths use ${ARCADIA_ROOT} and ${ARCADIA_BUILD_ROOT}, or
  4070. ### ${CURDIR} and ${BINDIR} which are expanded where the outputs are used.
  4071. 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...) {
  4072. .CMD=${cwd:CWD} ${env:ENV} $LUA_TOOL ${input:ScriptPath} $Args ${hide;input:IN} ${input;context=TEXT;hide:IN_NOPARSE} ${output_include;hide:OUTPUT_INCLUDES} $INDUCED_DEPS ${hide;tool:TOOL} ${hide;output:OUT} ${hide;noauto;output:OUT_NOAUTO} ${output;stdout:STDOUT} ${output;stdout;noauto:STDOUT_NOAUTO} ${hide;kv:"p LU"} ${hide;kv:"pc yellow"} ${hide;kv:"show_out"}
  4073. }
  4074. # tag:python-specific
  4075. ### @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...])
  4076. ###
  4077. ### Run a python script with prebuilt python3 interpretor built from devtools/huge_python3.
  4078. ### These macros are similar: RUN_PROGRAM, RUN_LUA, PYTHON.
  4079. ###
  4080. ### Parameters:
  4081. ### - script_path - Path to the script.
  4082. ### - args... - Program arguments. Relative paths listed in TOOL, IN, OUT, STDOUT become absolute.
  4083. ### - CWD dir - Absolute path of the working directory.
  4084. ### - ENV key=value... - Environment variables.
  4085. ### - TOOL tools... - Auxiliary tool directories.
  4086. ### - IN[_NOPARSE] inputs... - Input files. NOPARSE inputs are treated as textual and not parsed for dependencies regardless of file extensions.
  4087. ### - OUT[_NOAUTO] outputs... - Output files. NOAUTO outputs are not automatically added to the build process.
  4088. ### - STDOUT[_NOAUTO] output - Redirect the standard output to the output file.
  4089. ### - OUTPUT_INCLUDES output_includes... - Includes of the output files that are needed to build them.
  4090. ### - INDUCED_DEPS $VARs... - Dependencies for generated files. Unlike `OUTPUT_INCLUDES` these may target files further in processing chain.
  4091. ### In order to do so VAR should be filled by PREPARE_INDUCED_DEPS macro, stating target files (by type) and set of dependencies
  4092. ###
  4093. ### For absolute paths use ${ARCADIA_ROOT} and ${ARCADIA_BUILD_ROOT}, or
  4094. ### ${CURDIR} and ${BINDIR} which are expanded where the outputs are used.
  4095. 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...) {
  4096. .CMD=${cwd:CWD} ${env:ENV} $YMAKE_PYTHON3 ${input:ScriptPath} $Args ${hide;input:IN} ${input;context=TEXT;hide:IN_NOPARSE} ${output_include;hide:OUTPUT_INCLUDES} $INDUCED_DEPS ${hide;tool:TOOL} ${hide;output:OUT} ${hide;noauto;output:OUT_NOAUTO} ${output;stdout:STDOUT} ${output;stdout;noauto:STDOUT_NOAUTO} ${hide;kv:"p PY"} ${hide;kv:"pc yellow"} ${hide;kv:"show_out"}
  4097. .SEM=find_package Python3 && packages-ITEM && packages-name Python3 && mpackages-ITEM && mpackages-name Python3 && add_custom_command $_SET_ENV_FOR_CUSTOM_COMMAND($ENV) OUTPUT ${output:OUT} ${noauto;output:OUT_NOAUTO} ${output:STDOUT} ${noauto;output: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) && target_commands-ITEM && target_commands-macro add_custom_command && target_commands-args $_SET_ENV_FOR_CUSTOM_COMMAND($ENV) OUTPUT ${output:OUT} ${noauto;output:OUT_NOAUTO} ${output:STDOUT} ${noauto;output: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)
  4098. }
  4099. # tag:java-specific
  4100. 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...) {
  4101. PEERDIR(build/platform/java/jdk $JDK_RESOURCE_PEERDIR)
  4102. .CMD=${cwd:CWD} ${env:ENV} $YMAKE_PYTHON ${input;pre=build/scripts/:HIDE_OUTPUT.py} $JDK_RESOURCE/bin/java $Args ${hide;tool:TOOL} ${hide;input:IN} ${input;context=TEXT;hide:IN_NOPARSE} ${output_include;hide:OUTPUT_INCLUDES} $INDUCED_DEPS ${hide;output:OUT} ${hide;noauto;output:OUT_NOAUTO} ${output;stdout:STDOUT} ${output;stdout;noauto:STDOUT_NOAUTO} ${hide;kv:"p JV"} ${hide;kv:"pc light-blue"} ${hide;kv:"show_out"}
  4103. }
  4104. ### @usage: FROM_SANDBOX([FILE] resource_id [AUTOUPDATED script] [RENAME <resource files>] OUT_[NOAUTO] <output files> [EXECUTABLE] [OUTPUT_INCLUDES <include files>] [INDUCED_DEPS $VARs...])
  4105. ###
  4106. ### Download the resource from the Sandbox, unpack (if not explicitly specified word FILE) and add OUT files to the build. EXECUTABLE makes them executable.
  4107. ### 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.
  4108. ### If there is no default processing for OUT files or you need process them specially use OUT_NOAUTO instead of OUT.
  4109. ###
  4110. ### It is disallowed to specify directory as OUT/OUT_NOAUTO since all outputs of commands shall be known to build system.
  4111. ###
  4112. ### RENAME renames files to the corresponding OUT and OUT_NOAUTO outputs:
  4113. ### FROM_SANDBOX(resource_id RENAME in_file1 in_file2 OUT out_file1 out_file2 out_file3)
  4114. ### FROM_SANDBOX(resource_id RENAME in_file1 OUT out_file1 RENAME in_file2 OUT out_file2)
  4115. ### FROM_SANDBOX(FILE resource_id RENAME resource_file OUT out_name)
  4116. ###
  4117. ### RENAME RESOURCE allows to rename the resource without specifying its file name.
  4118. ###
  4119. ### OUTPUT_INCLUDES output_includes... - Includes of the output files that are needed to build them.
  4120. ### INDUCED_DEPS $VARs... - Dependencies for generated files. Unlike `OUTPUT_INCLUDES` these may target files further in processing chain.
  4121. ### In order to do so VAR should be filled by PREPARE_INDUCED_DEPS macro, stating target files (by type) and set of dependencies
  4122. ###
  4123. ### If AUTOUPDATED is specified than macro will be regularly updated according to autoupdate script. The dedicated Sandbox task scans the arcadia and
  4124. ### changes resource_ids in such macros if newer resource of specified type is available. Note that the task seeks AUTOUPDATED in specific position,
  4125. ### so you shall place it immediately after resource_id.
  4126. 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:") {
  4127. .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 ${hide;input:"build/scripts/fetch_from.py"} ${output_include;hide:OUTPUT_INCLUDES} $INDUCED_DEPS ${hide;output:OUT} ${hide;noauto;output:OUT_NOAUTO} ${requirements;hide:"network:full"} ${hide;kv:"p SB"} ${hide;kv:"pc yellow"} ${hide;kv:"show_out"}
  4128. ADD_CHECK(check.resource $Id)
  4129. }
  4130. ### @usage: FROM_MDS([FILE] key [RENAME <resource files>] OUT_[NOAUTO] <output files> [EXECUTABLE] [OUTPUT_INCLUDES <include files>] [INDUCED_DEPS $VARs...])
  4131. ###
  4132. ### Download resource from MDS with the specified key and process like [FROM_SANDBOX()](#macro_FROM_SANDBOX).
  4133. macro FROM_MDS(Key, OUT{output}[], OUT_NOAUTO{output}[], OUTPUT_INCLUDES[], INDUCED_DEPS[], FILE?"--copy-to-dir":"--untar-to", PREFIX=".", RENAME[], EXECUTABLE?"--executable":"") {
  4134. .CMD=${cwd:BINDIR} $YMAKE_PYTHON ${input:"build/scripts/fetch_from_mds.py"} --key $Key $FILE $PREFIX ${pre=--rename :RENAME} $EXECUTABLE -- $OUT $OUT_NOAUTO ${hide;input:"build/scripts/fetch_from.py"} ${output_include;hide:OUTPUT_INCLUDES} $INDUCED_DEPS ${hide;output:OUT} ${hide;noauto;output:OUT_NOAUTO} ${requirements;hide:"network:full"} ${hide;kv:"p MD"} ${hide;kv:"pc yellow"} ${hide;kv:"show_out"}
  4135. ADD_CHECK(check.mds $Key)
  4136. }
  4137. ### @usage LARGE_FILES([AUTOUPDATED] Files...)
  4138. ###
  4139. ### Use large file ether from working copy or from remote storage via placeholder <File>.external
  4140. ### If <File> is present locally (and not a symlink!) it will be copied to build directory.
  4141. ### Otherwise macro will try to locate <File>.external, parse it retrieve ot during build phase.
  4142. macro LARGE_FILES(AUTOUPDATED?, Files...) {
  4143. # This is needed to correctly switch between remote and local modes
  4144. _GLOB($LF $Files)
  4145. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS ${suf=.external:Files})
  4146. }
  4147. ### @usage: FROM_ARCHIVE(Src [RENAME <resource files>] OUT_[NOAUTO] <output files> [EXECUTABLE] [OUTPUT_INCLUDES <include files>] [INDUCED_DEPS $VARs...])
  4148. ###
  4149. ### Process file archive as [FROM_SANDBOX()](#macro_FROM_SANDBOX).
  4150. macro FROM_ARCHIVE(Src, OUT{output}[], OUT_NOAUTO{output}[], OUTPUT_INCLUDES[], INDUCED_DEPS[], PREFIX=".", RENAME[], EXECUTABLE?"--executable":"") {
  4151. .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 ${hide;input:"build/scripts/fetch_from.py"} ${output_include;hide:OUTPUT_INCLUDES} $INDUCED_DEPS ${hide;output:OUT} ${hide;noauto;output:OUT_NOAUTO} ${hide;kv:"p FA"} ${hide;kv:"pc yellow"} ${hide;kv:"show_out"}
  4152. }
  4153. when ($MSVC == "yes") {
  4154. C_AS_CXX_FLAGS=/TP /std:c++17
  4155. }
  4156. otherwise {
  4157. C_AS_CXX_FLAGS=-x c++ -std=c++17
  4158. }
  4159. # tag:cpp-specific
  4160. ### @usage: COMPILE_C_AS_CXX()
  4161. ###
  4162. ### Compile .c files as .cpp ones within a module.
  4163. macro COMPILE_C_AS_CXX() {
  4164. SET(EXTRA_C_FLAGS $C_AS_CXX_FLAGS)
  4165. }
  4166. ### @usage: NO_DEBUG_INFO()
  4167. ###
  4168. ### Compile files without debug info collection.
  4169. macro NO_DEBUG_INFO() {
  4170. SET(NO_DEBUGINFO yes)
  4171. }
  4172. ### @usage: CTEMPLATE_VARNAMES(File)
  4173. ###
  4174. ### Generate File.varnames.h using contrib/libs/ctemplate/make_tpl_varnames_h
  4175. ###
  4176. ### Documentation: https://a.yandex-team.ru/arc/trunk/arcadia/contrib/libs/ctemplate/README.md
  4177. macro CTEMPLATE_VARNAMES(File) {
  4178. .CMD=${tool:"contrib/libs/ctemplate/make_tpl_varnames_h"} -f ${output;addincl;nopath;noallext:File.varnames.h} ${input:File}
  4179. }
  4180. LLVM_OPTS=
  4181. CLANG_BC_ROOT=
  4182. macro USE_LLVM_BC14() {
  4183. SET(CLANG_BC_ROOT ${CLANG14_RESOURCE_GLOBAL})
  4184. SET(LLVM_LLC_TOOL contrib/libs/llvm14/tools/llc)
  4185. }
  4186. macro USE_LLVM_BC16() {
  4187. SET(CLANG_BC_ROOT ${CLANG16_RESOURCE_GLOBAL})
  4188. SET(LLVM_LLC_TOOL contrib/libs/llvm16/tools/llc)
  4189. }
  4190. ### @usage: CLANG_EMIT_AST_CXX(Input Output Opts...)
  4191. ###
  4192. ### Emit Clang AST from .cpp file. CXXFLAGS and LLVM_OPTS are passed in, while CFLAGS and C_FLAGS_PLATFORM are not.
  4193. ### Note: Output name is used as is, no extension added.
  4194. macro CLANG_EMIT_AST_CXX(Input, Output, Opts...) {
  4195. .CMD=$YMAKE_PYTHON ${input:"build/scripts/clang_wrapper.py"} $WINDOWS ${CLANG_RESOURCE_GLOBAL}/bin/clang++ ${pre=-I:_C__INCLUDE} $CXXFLAGS $C_FLAGS_PLATFORM $LLVM_OPTS -emit-ast -c ${input:Input} -o ${noauto;output:Output} $Opts ${hide;kv:"p ST"} ${hide;kv:"pc light-green"}
  4196. PEERDIR(build/platform/clang)
  4197. }
  4198. ### @usage: LLVM_COMPILE_CXX(Input Output Opts...)
  4199. ###
  4200. ### Emit LLVM bytecode from .cpp file. BC_CXXFLAGS, LLVM_OPTS and C_FLAGS_PLATFORM are passed in, while CFLAGS are not.
  4201. ### Note: Output name is used as is, no extension added.
  4202. macro LLVM_COMPILE_CXX(Input, Output, Opts...) {
  4203. .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 ${noauto;output:Output} $Opts ${hide;kv:"p BC"} ${hide;kv:"pc light-green"}
  4204. .SEM=llvm_compile_cxx ${input:Input} ${noauto;output:Output} ${"${CLANGPLUSPLUS}"} -Wno-unknown-warning-option $LLVM_OPTS ${NO_LTO_CFLAGS} -emit-llvm ${Opts} && target_macroses-ITEM && target_macroses-macro llvm_compile_cxx && target_macroses-args ${input:Input} ${noauto;output:Output} ${"${CLANGPLUSPLUS}"} -Wno-unknown-warning-option $LLVM_OPTS ${NO_LTO_CFLAGS} -emit-llvm ${Opts}
  4205. when ($CLANG_BC_ROOT == "") {
  4206. _OK = no
  4207. }
  4208. ASSERT(_OK "Invoke USE_LLVM_BC() with specific version first")
  4209. PEERDIR(build/platform/clang)
  4210. }
  4211. ### @usage: LLVM_COMPILE_C(Input Output Opts...)
  4212. ###
  4213. ### Emit LLVM bytecode from .c file. BC_CFLAGS, LLVM_OPTS and C_FLAGS_PLATFORM are passed in, while CFLAGS are not.
  4214. ### Note: Output name is used as is, no extension added.
  4215. macro LLVM_COMPILE_C(Input, Output, Opts...) {
  4216. .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 ${noauto;output:Output} $Opts ${hide;kv:"p BC"} ${hide;kv:"pc light-green"}
  4217. .SEM=llvm_compile_c ${input:Input} ${noauto;output:Output} ${"${CLANGC}"} -Wno-unknown-warning-option $LLVM_OPTS ${NO_LTO_CFLAGS} -emit-llvm ${Opts} && target_macroses-ITEM && target_macroses-macro llvm_compile_c && target_macroses-args ${input:Input} ${noauto;output:Output} ${"${CLANGC}"} -Wno-unknown-warning-option $LLVM_OPTS ${NO_LTO_CFLAGS} -emit-llvm ${Opts}
  4218. when ($CLANG_BC_ROOT == "") {
  4219. _OK = no
  4220. }
  4221. ASSERT(CLANG_BC_ROOT "Invoke USE_LLVM_BC() with specific version first")
  4222. PEERDIR(build/platform/clang)
  4223. }
  4224. ### @usage: BPF(Input Output Opts...)
  4225. ###
  4226. ### Emit eBPF bytecode from .c file.
  4227. ### Note: Output name is used as is, no extension added.
  4228. macro BPF(Input, Output, Opts...) {
  4229. .CMD=$YMAKE_PYTHON ${input:"build/scripts/clang_wrapper.py"} $WINDOWS ${CLANG_RESOURCE_GLOBAL}/bin/clang ${pre=-I:_C__INCLUDE} $C_FLAGS_PLATFORM -target bpf -c ${input:Input} -o ${noauto;output:Output} $Opts ${hide;kv:"p BP"} ${hide;kv:"pc light-green"}
  4230. PEERDIR(build/platform/clang)
  4231. }
  4232. LD_BINARY_NAME=ld
  4233. when($OS_LINUX) {
  4234. LD_BINARY_NAME=ld.lld
  4235. }
  4236. ### @usage: BPF_STATIC(Input Output Opts...)
  4237. ###
  4238. ### Emit eBPF bytecode from .c file.
  4239. ### Note: Output name is used as is, no extension added.
  4240. macro BPF_STATIC(Input, Output, Opts...) {
  4241. .CMD=$YMAKE_PYTHON ${input:"build/scripts/clang_wrapper.py"} $WINDOWS ${CLANG_RESOURCE_GLOBAL}/bin/clang ${pre=-I:_C__INCLUDE} $C_FLAGS_PLATFORM -target bpf -c ${input:Input} -o ${noauto;output:Output} $Opts ${hide;kv:"p BP"} ${hide;kv:"pc light-green"} && ${cwd:BINDIR} $LLD_ROOT_RESOURCE_GLOBAL/$LD_BINARY_NAME -r -b binary -m elf_x86_64 -o ${noauto;output;suf=.bpf.o:Input} ${noauto;nopath:Output}
  4242. PEERDIR(build/platform/clang build/platform/lld)
  4243. }
  4244. ### @usage: LLVM_COMPILE_LL(Input Output Opts...)
  4245. ###
  4246. ### Compile LLVM bytecode to object representation.
  4247. ### Note: Output name is used as is, no extension added.
  4248. macro LLVM_COMPILE_LL(Input, Output, Opts...) {
  4249. .CMD=${CLANG_BC_ROOT}/bin/llvm-as ${input:Input} -o ${noauto;output:Output} ${hide;kv:"p BC"} ${hide;kv:"pc light-green"}
  4250. .SEM=add_custom_command OUTPUT ${noauto;output:Output} DEPENDS ${input:Input} COMMAND ${LLVMAS} ${input:Input} -o ${noauto;output:Output} && target_commands-ITEM && target_commands-macro add_custom_command && target_commands-args OUTPUT ${noauto;output:Output} DEPENDS ${input:Input} COMMAND ${LLVMAS} ${input:Input} -o ${noauto;output:Output}
  4251. PEERDIR(build/platform/clang)
  4252. }
  4253. ### @usage: LLVM_LINK(Output Inputs...)
  4254. ###
  4255. ### Call llvm-link on set of Inputs to produce Output.
  4256. ### Note: Unlike many other macros output argument goes first. Output name is used as is, no extension added.
  4257. macro LLVM_LINK(Output, Inputs...) {
  4258. .CMD=${CLANG_BC_ROOT}/bin/llvm-link ${input:Inputs} -o ${noauto;output:Output} ${hide;kv:"p LD"} ${hide;kv:"pc light-red"}
  4259. .SEM=add_custom_command OUTPUT ${noauto;output:Output} DEPENDS ${input:Inputs} COMMAND ${LLVMLINK} ${input:Inputs} -o ${noauto;output:Output} && target_commands-ITEM && target_commands-macro add_custom_command && target_commands-args OUTPUT ${noauto;output:Output} DEPENDS ${input:Inputs} COMMAND ${LLVMLINK} ${input:Inputs} -o ${noauto;output:Output}
  4260. PEERDIR(build/platform/clang)
  4261. }
  4262. ### @usage: LLVM_OPT(Input Output Opts...)
  4263. ###
  4264. ### Call llvm-opt with set of Opts on Input to produce Output.
  4265. ### Note: Output name is used as is, no extension added.
  4266. macro LLVM_OPT(Input, Output, Opts...) {
  4267. .CMD=$YMAKE_PYTHON ${input:"build/scripts/llvm_opt_wrapper.py"} ${CLANG_BC_ROOT}/bin/opt ${input:Input} -o ${noauto;output:Output} $Opts ${hide;kv:"p OP"} ${hide;kv:"pc yellow"}
  4268. .SEM=add_custom_command OUTPUT ${noauto;output:Output} DEPENDS ${input:Input} COMMAND ${LLVMOPT} ${input:Input} -o ${noauto;output:Output} $Opts && target_commands-ITEM && target_commands-macro add_custom_command && target_commands-args OUTPUT ${noauto;output:Output} DEPENDS ${input:Input} COMMAND ${LLVMOPT} ${input:Input} -o ${noauto;output:Output} $Opts
  4269. PEERDIR(build/platform/clang)
  4270. }
  4271. ### @usage: LLVM_LLC(Src Opts...)
  4272. ###
  4273. ### Call llvm-llc with set of Opts on Src to produce object file.
  4274. ###
  4275. ### Note: Output name is calculated as concatenation of Src name and platform specific object file extension.
  4276. macro LLVM_LLC(Src, Opts...) {
  4277. .CMD=${tool:LLVM_LLC_TOOL} ${input:Src} --filetype obj -o ${output;suf=$OBJECT_SUF;noauto:Src} $Opts ${hide;kv:"p LC"} ${hide;kv:"pc yellow"}
  4278. .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 && target_commands-ITEM && target_commands-macro add_custom_command && target_commands-args OUTPUT ${output;suf=$OBJECT_SUF;noauto:Src} DEPENDS ${input:Src} COMMAND ${LLVMLLC} --filetype obj ${input:Src} -o ${output;suf=$OBJECT_SUF;noauto:Src} $Opts
  4279. PEERDIR(build/platform/clang)
  4280. }
  4281. when ($NO_DEBUGINFO == "yes") {
  4282. DEBUG_INFO_FLAGS=
  4283. }
  4284. when ($CLANG && $DEBUGINFO_LINES_ONLY == "yes" && $NO_DEBUGINFO != "yes") {
  4285. DEBUG_INFO_FLAGS=-gline-tables-only
  4286. }
  4287. # TODO: configurable tar and touch
  4288. PACK_TGZ=${cwd:ARCADIA_BUILD_ROOT} tar -czf ${rootrel:OUTPUT} ${rootrel:INPUT} ${hide;kv:"p AR"} ${hide;kv:"pc light-red"}
  4289. # tag:internal
  4290. ### @usage TOUCH(Outputs...) # internal
  4291. ### Just introduce outputs
  4292. macro TOUCH(Outputs...) {
  4293. .CMD=$YMAKE_PYTHON ${input:"build/scripts/touch.py"} ${output:Outputs}
  4294. }
  4295. TOUCH_UNIT=$YMAKE_PYTHON ${input:"build/scripts/touch.py"} ${hide;kv:"p UN"} ${hide;kv:"pc light-cyan"} $TARGET
  4296. FAKE_PACKAGE_CMD=$YMAKE_PYTHON ${input:"build/scripts/touch.py"} ${hide;kv:"pc light-red"} $TARGET
  4297. 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} ${hide;kv:"package PACKAGE"}
  4298. TOUCH_PACKAGE=$FAKE_PACKAGE_CMD $VCS_INFO_DISABLE_CACHE__NO_UID__ && $COPY_PACKAGE_CMD
  4299. _P_PK=${hide;kv:"p PK"}
  4300. TOUCH_PACKAGE_MF=$GENERATE_MF && $TOUCH_PACKAGE $_P_PK && $ADD_VCS_INFO_FILE_CMD
  4301. # Note: we don't use touch.py in the command below to avoid introduction of undesired input
  4302. UNION_CMD=$YMAKE_PYTHON -c open(\'$TARGET\',\'w\').close() ${hide;kv:"p UN"} ${hide;kv:"package UNION"} ${hide;kv:"pc light-cyan"} $UNION_OUTS $VCS_INFO_DISABLE_CACHE__NO_UID__
  4303. UNION_CMD_MF=$UNION_CMD && $GENERATE_MF
  4304. macro _EXPAND_INS_OUTS(FILES{input}[]) {
  4305. .CMD=${hide;input:FILES} ${late_out;hide:INPUT}
  4306. }
  4307. _UNION_EXPLICIT_OUTPUTS=
  4308. ### @usage: EXPLICIT_OUTPUTS(Files...)
  4309. ###
  4310. ### Let UNION has only explicitly specified outputs listed in this macro
  4311. ### The list of files shall contain results of commands in this UNION.
  4312. ### Only these files will be outputs of the UNION. This allows to eliminate
  4313. ### intermediate files being result of the UNION
  4314. macro EXPLICIT_OUTPUTS(Files...) {
  4315. SET_APPEND(_UNION_EXPLICIT_OUTPUTS ${Files})
  4316. }
  4317. NO_CHECK_IMPORTS_FOR_VALUE=None
  4318. ### @usage: NO_CHECK_IMPORTS([patterns])
  4319. ###
  4320. ### Do not run checks on imports of Python modules.
  4321. ### Optional parameter mask patterns describes the names of the modules that do not need to check.
  4322. macro NO_CHECK_IMPORTS(Masks...) {
  4323. SET(NO_CHECK_IMPORTS_FOR_VALUE $Masks)
  4324. }
  4325. # tag:yasm-specific
  4326. _YASM_FMT_VALUE=
  4327. _YASM_PLATFORM_FLAGS_VALUE=
  4328. _YASM_PREDEFINED_FLAGS_VALUE=
  4329. when ($OS_DARWIN || $OS_IOS) {
  4330. _YASM_FMT_VALUE=macho
  4331. _YASM_PLATFORM_FLAGS_VALUE=-D DARWIN -D UNIX
  4332. }
  4333. elsewhen ($OS_WINDOWS && $ARCH_X86_64) {
  4334. _YASM_FMT_VALUE=win
  4335. _YASM_PLATFORM_FLAGS_VALUE=-D WIN64
  4336. }
  4337. elsewhen ($OS_WINDOWS && $ARCH_I386) {
  4338. _YASM_FMT_VALUE=win
  4339. _YASM_PLATFORM_FLAGS_VALUE=-D WIN32
  4340. }
  4341. otherwise {
  4342. _YASM_FMT_VALUE=elf
  4343. _YASM_PLATFORM_FLAGS_VALUE=-D UNIX
  4344. _YASM_PREDEFINED_FLAGS_VALUE=-g dwarf2
  4345. }
  4346. when ($ASM_PREFIX) {
  4347. ASM_PREFIX_VALUE=--prefix=$ASM_PREFIX
  4348. }
  4349. otherwise {
  4350. ASM_PREFIX_VALUE=
  4351. }
  4352. # tag:yasm-specific
  4353. YASM_FLAGS=
  4354. YASM_PREINCLUDES_VALUE=
  4355. # tag:yasm-specific
  4356. macro _SRC_yasm_helper(SRC, PREINCLUDES[], SRCFLAGS...) {
  4357. .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} ${hide;input:PREINCLUDES} ${SRC} ${hide;kv:"p AS"} ${hide;kv:"pc light-green"}
  4358. }
  4359. # tag:yasm-specific
  4360. macro _SRC_yasm(SRC, PREINCLUDES[], SRCFLAGS...) {
  4361. .CMD=$_SRC_yasm_helper(${input:SRC}, $SRCFLAGS, PREINCLUDES $PREINCLUDES)
  4362. }
  4363. # tag:nasm-specific
  4364. NASM_FLAGS=
  4365. # tag:nasm-specific
  4366. macro _SRC_nasm_helper(SRC, SRCFLAGS...) {
  4367. .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}
  4368. }
  4369. # tag:nasm-specific
  4370. macro _SRC_nasm(SRC, PREINCLUDES[], SRCFLAGS...) {
  4371. .CMD=$_SRC_nasm_helper(${input:SRC}, $SRCFLAGS)
  4372. }
  4373. # tag:src-processing
  4374. when ($USE_NASM_ASSEMBLER == "yes") {
  4375. _SRC_ASM_CMDLINE=$_SRC_nasm($SRC $SRCFLAGS)
  4376. }
  4377. elsewhen ($USE_YASM_ASSEMBLER == "yes") {
  4378. _SRC_ASM_CMDLINE=$_SRC_yasm($SRC $SRCFLAGS)
  4379. }
  4380. otherwise {
  4381. _SRC_ASM_CMDLINE=
  4382. }
  4383. # tag:src-processing
  4384. macro _SRC_ASM(SRC, SRCFLAGS...) {
  4385. .CMD=$_SRC_ASM_CMDLINE
  4386. }
  4387. ### @usage: ASM_PREINCLUDE(AsmFiles...)
  4388. ###
  4389. ### Supply additional .asm files to all assembler calls within a module
  4390. macro ASM_PREINCLUDE(PREINCLUDES...) {
  4391. SET_APPEND(YASM_PREINCLUDES_VALUE $PREINCLUDES)
  4392. }
  4393. ### @usage: RUN_ANTLR(Args...)
  4394. ###
  4395. ### Macro to invoke ANTLR3 generator (general case)
  4396. macro RUN_ANTLR(IN[], IN_NOPARSE[], OUT[], OUT_NOAUTO[], OUTPUT_INCLUDES[], INDUCED_DEPS[], CWD="", Args...) {
  4397. _RUN_JAVA(-jar ${input:"contrib/java/antlr/antlr3/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})
  4398. .SEM=run_antlr OUTPUT ${output:OUT} ${noauto;output:OUT_NOAUTO} DEPENDS ${input:IN} ${pre=WORKING_DIRECTORY :CWD} ANTLER_ARGS $Args && target_commands-ITEM && target_commands-macro run_antlr && target_commands-args OUTPUT ${output:OUT} ${noauto;output:OUT_NOAUTO} DEPENDS ${input:IN} ${pre=WORKING_DIRECTORY :CWD} ANTLER_ARGS $Args
  4399. }
  4400. ### @usage: RUN_ANTLR4(Args...)
  4401. ###
  4402. ### Macro to invoke ANTLR4 generator (general case)
  4403. macro RUN_ANTLR4(IN[], IN_NOPARSE[], OUT[], OUT_NOAUTO[], OUTPUT_INCLUDES[], INDUCED_DEPS[], CWD="", Args...) {
  4404. _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})
  4405. }
  4406. _ANTLR4_LISTENER_GRAMMAR=-listener
  4407. _ANTLR4_LISTENER_PARSER=-listener
  4408. _ANTLR4_LISTENER__ANTLR4_EMPTY=-no-listener
  4409. _ANTLR4_VISITOR_GRAMMAR=-visitor
  4410. _ANTLR4_VISITOR_PARSER=-visitor
  4411. _ANTLR4_VISITOR__ANTLR4_EMPTY=-no-visitor
  4412. ### @usage: RUN_ANTLR4_CPP_SPLIT(LEXER, PARSER, OUTPUT_INCLUDES, LISTENER, VISITOR, Args...)
  4413. ###
  4414. ### Macro to invoke ANTLR4 generator for separate lexer and parser grammars (Cpp)
  4415. macro RUN_ANTLR4_CPP_SPLIT(LEXER, PARSER, OUTPUT_INCLUDES[], LISTENER?"PARSER":"_ANTLR4_EMPTY", VISITOR?"PARSER":"_ANTLR4_EMPTY", _ANTLR4_EMPTY="", Args...) {
  4416. RUN_ANTLR4(${LEXER} ${PARSER} -Dlanguage=Cpp -o ${BINDIR} ${_ANTLR4_VISITOR_$VISITOR} ${_ANTLR4_LISTENER_$LISTENER} ${Args} CWD ${BINDIR} IN ${LEXER} ${PARSER} OUT ${noext;suf=.cpp:LEXER} ${noext;suf=.h:LEXER} ${noext;suf=.cpp:PARSER} ${noext;suf=.h:PARSER} ${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})
  4417. PEERDIR(contrib/libs/antlr4_cpp_runtime)
  4418. }
  4419. ### @usage: RUN_ANTLR4_CPP(GRAMMAR, OUTPUT_INCLUDES, LISTENER, VISITOR, Args...)
  4420. ###
  4421. ### Macro to invoke ANTLR4 generator for combined lexer+parser grammars (Cpp)
  4422. macro RUN_ANTLR4_CPP(GRAMMAR, OUTPUT_INCLUDES[], LISTENER?"GRAMMAR":"_ANTLR4_EMPTY", VISITOR?"GRAMMAR":"_ANTLR4_EMPTY", _ANTLR4_EMPTY="", Args...) {
  4423. 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})
  4424. PEERDIR(contrib/libs/antlr4_cpp_runtime)
  4425. }
  4426. ### @usage: RUN_ANTLR4_GO(GRAMMAR, DEPS <extra_go_deps>, LISTENER, VISITOR, Args...)
  4427. ###
  4428. ### Macro to invoke ANTLR4 generator (Go)
  4429. macro RUN_ANTLR4_GO(GRAMMAR, DEPS[], LISTENER?"GRAMMAR":"_ANTLR4_EMPTY", VISITOR?"GRAMMAR":"_ANTLR4_EMPTY", _ANTLR4_EMPTY="", Args...) {
  4430. 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})
  4431. PEERDIR(${GOSTD}/fmt ${GOSTD}/reflect ${GOSTD}/strconv ${GOSTD}/sync ${GOSTD}/unicode vendor/github.com/antlr/antlr4/runtime/Go/antlr/v4 $DEPS)
  4432. }
  4433. ### @usage: RUN_ANTLR4_PYTHON(Grammar [LISTENER] [VISITOR] [SUBDIR] [EXTRA_OUTS Outs...] Args...)
  4434. ###
  4435. ### `LISTENER` - emit grammar listener
  4436. ### `VISITOR` - emit grammar visitor
  4437. ### `SUBDIR` - place generated files to specified subdirectory of BINDIR
  4438. ### `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.
  4439. ###
  4440. ### 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.
  4441. macro RUN_ANTLR4_PYTHON(GRAMMAR, LISTENER?"GRAMMAR":"_ANTLR4_EMPTY", VISITOR?"GRAMMAR":"_ANTLR4_EMPTY", SUBDIR=".", EXTRA_OUTS[], _ANTLR4_EMPTY="", Args...) {
  4442. 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})
  4443. PEERDIR(contrib/python/antlr4)
  4444. }
  4445. # tag:cpp-specific
  4446. macro CPP_ADDINCL(Dirs...) {
  4447. ADDINCL($Dirs)
  4448. }
  4449. # tag:internal
  4450. _WHOLE_ARCHIVE_PEERS_VALUE=
  4451. ### @usage: WHOLE_ARCHIVE(dirnames...) # internal
  4452. macro WHOLE_ARCHIVE(PEERS...) {
  4453. SET_APPEND(_WHOLE_ARCHIVE_PEERS_VALUE ${PEERS})
  4454. REQUIRES(${PEERS})
  4455. }
  4456. ANDROID_SDK_ROOT=${ANDROID_SDK_RESOURCE_GLOBAL}/android_sdk
  4457. macro TASKLET() {
  4458. PEERDIR(tasklet/v1/api)
  4459. # CPP
  4460. CPP_PROTO_PLUGIN(tasklet_cpp tasklet/v1/gen/cpp .tasklet.h)
  4461. # Python
  4462. PY_PROTO_PLUGIN2(tasklet_py _tasklet.py _sbtask.py tasklet/v1/gen/python DEPS tasklet/v1/domain/sandbox tasklet/v1/runtime sandbox/sdk2)
  4463. }
  4464. TASKLET_REG_INCLUDES= \
  4465. ${output_include;hide:"tasklet/v1/runtime/lib/cpp_wrapper.h"} \
  4466. ${output_include;hide:"tasklet/v1/runtime/lib/go_wrapper.h"} \
  4467. ${output_include;hide:"tasklet/v1/runtime/lib/py_wrapper.h"} \
  4468. ${output_include;hide:"tasklet/v1/runtime/lib/js_wrapper.h"} \
  4469. ${output_include;hide:"tasklet/v1/runtime/lib/registry.h"}
  4470. macro TASKLET_REG(Name, Lang, Impl, Includes...) {
  4471. PEERDIR(tasklet/v1/domain sandbox/bin sandbox/taskbox/worker)
  4472. when($Lang == "js") {
  4473. # JS runtime links the Node.js from contrib as a library, which is a bit heavy,
  4474. # so we do it, only if any JS tasklets are linked into the target
  4475. PEERDIR+=tasklet/v1/runtime/js
  4476. }
  4477. .CMD=$YMAKE_PYTHON ${input:"build/scripts/gen_tasklet_reg.py"} $Name -l $Lang -i $Impl ${noauto;output:Name.task.cpp} $Includes ${output_include;hide:Includes} $TASKLET_REG_INCLUDES ${hide;kv:"p TT"} ${hide;kv:"pc yellow"}
  4478. SRCS(GLOBAL $Name.task.cpp)
  4479. }
  4480. # TEMPORARY METHOD FOR EXTENDED REGISTRY SETUP
  4481. # NOT COMPLETE
  4482. macro TASKLET_REG_EXT(Name, Lang, Impl, Wrapper, Includes...) {
  4483. PEERDIR(tasklet/v1/domain sandbox/bin sandbox/taskbox/worker)
  4484. .CMD=$YMAKE_PYTHON ${input:"build/scripts/gen_tasklet_reg.py"} $Name -l $Lang -i $Impl -w $Wrapper ${noauto;output:Name.task.cpp} $Includes ${output_include;hide:Includes} $TASKLET_REG_INCLUDES ${hide;kv:"p TT"} ${hide;kv:"pc yellow"}
  4485. SRCS(GLOBAL $Name.task.cpp)
  4486. }
  4487. # tag:cpp-specific
  4488. _CPP_PROTO_MODULE_PREFIX=
  4489. _CPP_PROTO_MODULE_SUFFIX=
  4490. when ($MSVC == "yes" || $CYGWIN == "yes") {
  4491. _CPP_PROTO_MODULE_PREFIX=
  4492. _CPP_PROTO_MODULE_SUFFIX=.lib
  4493. }
  4494. otherwise {
  4495. _CPP_PROTO_MODULE_PREFIX=lib
  4496. _CPP_PROTO_MODULE_SUFFIX=.a
  4497. }
  4498. ### @usage: _EXPOSE(OutputsToExport...)
  4499. ###
  4500. ### Allows to mark outputs of macro command as unused in the current module but intended
  4501. ### to be used in modules consuming current via PEERDIR.
  4502. ###
  4503. ### TODO(DEVTOOLS-9000) proper implementation needed
  4504. macro _EXPOSE(Args...) {
  4505. .CMD=$YMAKE_PYTHON ${input:"build/scripts/touch.py"} ${output;suf=$_HASH_HELPER($Args).ya_exposed:"empty_"} ${hide;input:Args}
  4506. }
  4507. # tag:internal
  4508. ### @usage: _PROXY_LIBRARY() # internal
  4509. ###
  4510. ### The use of this module is strictly prohibited!!!
  4511. module _PROXY_LIBRARY: LIBRARY {
  4512. .EXTS=.a .lib
  4513. .PEERDIR_POLICY=as_build_from
  4514. .PROXY=yes
  4515. .FINAL_TARGET=yes
  4516. DISABLE(NEED_ADD_FAKE_SRC)
  4517. NO_UTIL()
  4518. NO_RUNTIME()
  4519. }
  4520. @import "${CONF_ROOT}/conf/project_specific/yql_udf.conf"
  4521. _PRIMARY_OUTPUT_VALUE=
  4522. # tag:internal
  4523. ### @usage: PRIMARY_OUTPUT_VALUE(Output) # internal
  4524. ###
  4525. ### The use of this module is strictly prohibited!!!
  4526. macro PRIMARY_OUTPUT(OUTPUT) {
  4527. SET(_PRIMARY_OUTPUT_VALUE $OUTPUT)
  4528. }
  4529. _DLL_PROXY_LIBRARY_CMD=$GENERATE_MF && $COPY_CMD $_PRIMARY_OUTPUT_VALUE ${hide;input:_PRIMARY_OUTPUT_VALUE} ${TARGET}
  4530. # tag:internal
  4531. ### @usage: DLL_PROXY_LIBRARY() # internal
  4532. ###
  4533. ### The use of this module is strictly prohibited!!!
  4534. module DLL_PROXY_LIBRARY: _PROXY_LIBRARY {
  4535. .ALLOWED=PRIMARY_OUTPUT
  4536. .CMD=_DLL_PROXY_LIBRARY_CMD
  4537. }
  4538. _PREBUILT_PROGRAM_CMD=$GENERATE_MF && $COPY_CMD $_PRIMARY_OUTPUT_VALUE ${TARGET} ${hide;kv:"p ld"} ${hide;kv:"pc light-blue"} ${hide;kv:"show_out"}
  4539. # tag:internal
  4540. ### @usage: PREBUILT_PROGRAM([programname]) # internal
  4541. ###
  4542. ### Program module which uses a prebuilt prgram as its output.
  4543. module PREBUILT_PROGRAM: _LINK_UNIT {
  4544. .CMD=_PREBUILT_PROGRAM_CMD
  4545. .SYMLINK_POLICY=EXE
  4546. .ALLOWED=INDUCED_DEPS PRIMARY_OUTPUT
  4547. .RESTRICTED=SRCS
  4548. _BARE_LINK_MODULE()
  4549. SET(MODULE_TYPE PROGRAM)
  4550. _DONT_REQUIRE_LICENSE()
  4551. when ($WIN32 == "yes" || $OS_CYGWIN == "yes") {
  4552. MODULE_SUFFIX=.exe
  4553. }
  4554. }
  4555. ### @usage COLLECT_JINJA_TEMPLATES(varname path)
  4556. ###
  4557. ### This macro collects all jinja and yaml files in the directory specified by second argument and
  4558. ### stores result in the variable with mane specified by first parameter.
  4559. macro COLLECT_JINJA_TEMPLATES(VAR, DIR) {
  4560. _GLOB($VAR ${DIR}/**/*.jinja ${DIR}/**/*.yaml)
  4561. }
  4562. @import "${CONF_ROOT}/conf/go.conf"
  4563. # Conflict between protobuf-java and protobuf-javalite ¯\_(ツ)_/¯
  4564. # both libraries are required by grpc
  4565. JAVA_IGNORE_CLASSPATH_CLASH_DEFAULE_VALUE=\
  4566. com.google.protobuf.AbstractMessageLite \
  4567. com.google.protobuf.AbstractMessageLite$Builder \
  4568. com.google.protobuf.AbstractMessageLite$Builder$LimitedInputStream \
  4569. com.google.protobuf.AbstractMessageLite$InternalOneOfEnum \
  4570. com.google.protobuf.AbstractParser \
  4571. com.google.protobuf.AbstractProtobufList \
  4572. com.google.protobuf.AllocatedBuffer \
  4573. com.google.protobuf.AllocatedBuffer$1 \
  4574. com.google.protobuf.AllocatedBuffer$2 \
  4575. com.google.protobuf.Android \
  4576. com.google.protobuf.Any \
  4577. com.google.protobuf.Any$1 \
  4578. com.google.protobuf.Any$Builder \
  4579. com.google.protobuf.AnyOrBuilder \
  4580. com.google.protobuf.AnyProto \
  4581. com.google.protobuf.Api \
  4582. com.google.protobuf.Api$1 \
  4583. com.google.protobuf.Api$Builder \
  4584. com.google.protobuf.ApiOrBuilder \
  4585. com.google.protobuf.ApiProto \
  4586. com.google.protobuf.ArrayDecoders \
  4587. com.google.protobuf.ArrayDecoders$1 \
  4588. com.google.protobuf.ArrayDecoders$Registers \
  4589. com.google.protobuf.BinaryReader \
  4590. com.google.protobuf.BinaryReader$1 \
  4591. com.google.protobuf.BinaryReader$SafeHeapReader \
  4592. com.google.protobuf.BinaryWriter \
  4593. com.google.protobuf.BinaryWriter$1 \
  4594. com.google.protobuf.BinaryWriter$SafeDirectWriter \
  4595. com.google.protobuf.BinaryWriter$SafeHeapWriter \
  4596. com.google.protobuf.BinaryWriter$UnsafeDirectWriter \
  4597. com.google.protobuf.BinaryWriter$UnsafeHeapWriter \
  4598. com.google.protobuf.BooleanArrayList \
  4599. com.google.protobuf.BoolValue \
  4600. com.google.protobuf.BoolValue$1 \
  4601. com.google.protobuf.BoolValue$Builder \
  4602. com.google.protobuf.BoolValueOrBuilder \
  4603. com.google.protobuf.BufferAllocator \
  4604. com.google.protobuf.BufferAllocator$1 \
  4605. com.google.protobuf.ByteBufferWriter \
  4606. com.google.protobuf.ByteOutput \
  4607. com.google.protobuf.ByteString \
  4608. com.google.protobuf.ByteString$1 \
  4609. com.google.protobuf.ByteString$2 \
  4610. com.google.protobuf.ByteString$AbstractByteIterator \
  4611. com.google.protobuf.ByteString$ArraysByteArrayCopier \
  4612. com.google.protobuf.ByteString$BoundedByteString \
  4613. com.google.protobuf.ByteString$ByteArrayCopier \
  4614. com.google.protobuf.ByteString$ByteIterator \
  4615. com.google.protobuf.ByteString$CodedBuilder \
  4616. com.google.protobuf.ByteString$LeafByteString \
  4617. com.google.protobuf.ByteString$LiteralByteString \
  4618. com.google.protobuf.ByteString$Output \
  4619. com.google.protobuf.ByteString$SystemByteArrayCopier \
  4620. com.google.protobuf.BytesValue \
  4621. com.google.protobuf.BytesValue$1 \
  4622. com.google.protobuf.BytesValue$Builder \
  4623. com.google.protobuf.BytesValueOrBuilder \
  4624. com.google.protobuf.CanIgnoreReturnValue \
  4625. com.google.protobuf.CheckReturnValue \
  4626. com.google.protobuf.CodedInputStream \
  4627. com.google.protobuf.CodedInputStream$1 \
  4628. com.google.protobuf.CodedInputStream$ArrayDecoder \
  4629. com.google.protobuf.CodedInputStream$IterableDirectByteBufferDecoder \
  4630. com.google.protobuf.CodedInputStream$StreamDecoder \
  4631. com.google.protobuf.CodedInputStream$StreamDecoder$RefillCallback \
  4632. com.google.protobuf.CodedInputStream$StreamDecoder$SkippedDataSink \
  4633. com.google.protobuf.CodedInputStream$UnsafeDirectNioDecoder \
  4634. com.google.protobuf.CodedInputStreamReader \
  4635. com.google.protobuf.CodedInputStreamReader$1 \
  4636. com.google.protobuf.CodedOutputStream \
  4637. com.google.protobuf.CodedOutputStream$1 \
  4638. com.google.protobuf.CodedOutputStream$AbstractBufferedEncoder \
  4639. com.google.protobuf.CodedOutputStream$ArrayEncoder \
  4640. com.google.protobuf.CodedOutputStream$ByteOutputEncoder \
  4641. com.google.protobuf.CodedOutputStream$HeapNioEncoder \
  4642. com.google.protobuf.CodedOutputStream$OutOfSpaceException \
  4643. com.google.protobuf.CodedOutputStream$OutputStreamEncoder \
  4644. com.google.protobuf.CodedOutputStream$SafeDirectNioEncoder \
  4645. com.google.protobuf.CodedOutputStream$UnsafeDirectNioEncoder \
  4646. com.google.protobuf.CodedOutputStreamWriter \
  4647. com.google.protobuf.CodedOutputStreamWriter$1 \
  4648. com.google.protobuf.DoubleArrayList \
  4649. com.google.protobuf.DoubleValue \
  4650. com.google.protobuf.DoubleValue$1 \
  4651. com.google.protobuf.DoubleValue$Builder \
  4652. com.google.protobuf.DoubleValueOrBuilder \
  4653. com.google.protobuf.Duration \
  4654. com.google.protobuf.Duration$1 \
  4655. com.google.protobuf.Duration$Builder \
  4656. com.google.protobuf.DurationOrBuilder \
  4657. com.google.protobuf.DurationProto \
  4658. com.google.protobuf.Empty \
  4659. com.google.protobuf.Empty$1 \
  4660. com.google.protobuf.Empty$Builder \
  4661. com.google.protobuf.EmptyOrBuilder \
  4662. com.google.protobuf.EmptyProto \
  4663. com.google.protobuf.Enum \
  4664. com.google.protobuf.Enum$1 \
  4665. com.google.protobuf.Enum$Builder \
  4666. com.google.protobuf.EnumOrBuilder \
  4667. com.google.protobuf.EnumValue \
  4668. com.google.protobuf.EnumValue$1 \
  4669. com.google.protobuf.EnumValue$Builder \
  4670. com.google.protobuf.EnumValueOrBuilder \
  4671. com.google.protobuf.ExperimentalApi \
  4672. com.google.protobuf.ExtensionLite \
  4673. com.google.protobuf.ExtensionRegistryFactory \
  4674. com.google.protobuf.ExtensionRegistryLite \
  4675. com.google.protobuf.ExtensionRegistryLite$ExtensionClassHolder \
  4676. com.google.protobuf.ExtensionRegistryLite$ObjectIntPair \
  4677. com.google.protobuf.ExtensionSchema \
  4678. com.google.protobuf.ExtensionSchemaLite \
  4679. com.google.protobuf.ExtensionSchemaLite$1 \
  4680. com.google.protobuf.ExtensionSchemas \
  4681. com.google.protobuf.Field \
  4682. com.google.protobuf.Field$1 \
  4683. com.google.protobuf.Field$Builder \
  4684. com.google.protobuf.Field$Cardinality \
  4685. com.google.protobuf.Field$Cardinality$1 \
  4686. com.google.protobuf.Field$Kind \
  4687. com.google.protobuf.Field$Kind$1 \
  4688. com.google.protobuf.FieldInfo \
  4689. com.google.protobuf.FieldInfo$1 \
  4690. com.google.protobuf.FieldInfo$Builder \
  4691. com.google.protobuf.FieldMask \
  4692. com.google.protobuf.FieldMask$1 \
  4693. com.google.protobuf.FieldMask$Builder \
  4694. com.google.protobuf.FieldMaskOrBuilder \
  4695. com.google.protobuf.FieldMaskProto \
  4696. com.google.protobuf.FieldOrBuilder \
  4697. com.google.protobuf.FieldSet \
  4698. com.google.protobuf.FieldSet$1 \
  4699. com.google.protobuf.FieldSet$Builder \
  4700. com.google.protobuf.FieldSet$FieldDescriptorLite \
  4701. com.google.protobuf.FieldType \
  4702. com.google.protobuf.FieldType$1 \
  4703. com.google.protobuf.FieldType$Collection \
  4704. com.google.protobuf.FloatArrayList \
  4705. com.google.protobuf.FloatValue \
  4706. com.google.protobuf.FloatValue$1 \
  4707. com.google.protobuf.FloatValue$Builder \
  4708. com.google.protobuf.FloatValueOrBuilder \
  4709. com.google.protobuf.GeneratedMessageInfoFactory \
  4710. com.google.protobuf.GeneratedMessageLite \
  4711. com.google.protobuf.GeneratedMessageLite$1 \
  4712. com.google.protobuf.GeneratedMessageLite$Builder \
  4713. com.google.protobuf.GeneratedMessageLite$DefaultInstanceBasedParser \
  4714. com.google.protobuf.GeneratedMessageLite$ExtendableBuilder \
  4715. com.google.protobuf.GeneratedMessageLite$ExtendableMessage \
  4716. com.google.protobuf.GeneratedMessageLite$ExtendableMessage$ExtensionWriter \
  4717. com.google.protobuf.GeneratedMessageLite$ExtendableMessageOrBuilder \
  4718. com.google.protobuf.GeneratedMessageLite$ExtensionDescriptor \
  4719. com.google.protobuf.GeneratedMessageLite$GeneratedExtension \
  4720. com.google.protobuf.GeneratedMessageLite$MethodToInvoke \
  4721. com.google.protobuf.GeneratedMessageLite$SerializedForm \
  4722. com.google.protobuf.Int32Value \
  4723. com.google.protobuf.Int32Value$1 \
  4724. com.google.protobuf.Int32Value$Builder \
  4725. com.google.protobuf.Int32ValueOrBuilder \
  4726. com.google.protobuf.Int64Value \
  4727. com.google.protobuf.Int64Value$1 \
  4728. com.google.protobuf.Int64Value$Builder \
  4729. com.google.protobuf.Int64ValueOrBuilder \
  4730. com.google.protobuf.IntArrayList \
  4731. com.google.protobuf.Internal \
  4732. com.google.protobuf.Internal$BooleanList \
  4733. com.google.protobuf.Internal$DoubleList \
  4734. com.google.protobuf.Internal$EnumLite \
  4735. com.google.protobuf.Internal$EnumLiteMap \
  4736. com.google.protobuf.Internal$EnumVerifier \
  4737. com.google.protobuf.Internal$FloatList \
  4738. com.google.protobuf.Internal$IntList \
  4739. com.google.protobuf.Internal$ListAdapter \
  4740. com.google.protobuf.Internal$ListAdapter$Converter \
  4741. com.google.protobuf.Internal$LongList \
  4742. com.google.protobuf.Internal$MapAdapter \
  4743. com.google.protobuf.Internal$MapAdapter$1 \
  4744. com.google.protobuf.Internal$MapAdapter$Converter \
  4745. com.google.protobuf.Internal$MapAdapter$EntryAdapter \
  4746. com.google.protobuf.Internal$MapAdapter$IteratorAdapter \
  4747. com.google.protobuf.Internal$MapAdapter$SetAdapter \
  4748. com.google.protobuf.Internal$ProtobufList \
  4749. com.google.protobuf.InvalidProtocolBufferException \
  4750. com.google.protobuf.InvalidProtocolBufferException$InvalidWireTypeException \
  4751. com.google.protobuf.IterableByteBufferInputStream \
  4752. com.google.protobuf.JavaType \
  4753. com.google.protobuf.LazyField \
  4754. com.google.protobuf.LazyField$1 \
  4755. com.google.protobuf.LazyField$LazyEntry \
  4756. com.google.protobuf.LazyField$LazyIterator \
  4757. com.google.protobuf.LazyFieldLite \
  4758. com.google.protobuf.LazyStringArrayList \
  4759. com.google.protobuf.LazyStringArrayList$ByteArrayListView \
  4760. com.google.protobuf.LazyStringArrayList$ByteStringListView \
  4761. com.google.protobuf.LazyStringList \
  4762. com.google.protobuf.ListFieldSchema \
  4763. com.google.protobuf.ListFieldSchema$1 \
  4764. com.google.protobuf.ListFieldSchema$ListFieldSchemaFull \
  4765. com.google.protobuf.ListFieldSchema$ListFieldSchemaLite \
  4766. com.google.protobuf.ListValue \
  4767. com.google.protobuf.ListValue$1 \
  4768. com.google.protobuf.ListValue$Builder \
  4769. com.google.protobuf.ListValueOrBuilder \
  4770. com.google.protobuf.LongArrayList \
  4771. com.google.protobuf.ManifestSchemaFactory \
  4772. com.google.protobuf.ManifestSchemaFactory$1 \
  4773. com.google.protobuf.ManifestSchemaFactory$CompositeMessageInfoFactory \
  4774. com.google.protobuf.MapEntryLite \
  4775. com.google.protobuf.MapEntryLite$1 \
  4776. com.google.protobuf.MapEntryLite$Metadata \
  4777. com.google.protobuf.MapFieldLite \
  4778. com.google.protobuf.MapFieldSchema \
  4779. com.google.protobuf.MapFieldSchemaLite \
  4780. com.google.protobuf.MapFieldSchemas \
  4781. com.google.protobuf.MessageInfo \
  4782. com.google.protobuf.MessageInfoFactory \
  4783. com.google.protobuf.MessageLite \
  4784. com.google.protobuf.MessageLite$Builder \
  4785. com.google.protobuf.MessageLiteOrBuilder \
  4786. com.google.protobuf.MessageLiteToString \
  4787. com.google.protobuf.MessageSchema \
  4788. com.google.protobuf.MessageSchema$1 \
  4789. com.google.protobuf.MessageSetSchema \
  4790. com.google.protobuf.Method \
  4791. com.google.protobuf.Method$1 \
  4792. com.google.protobuf.Method$Builder \
  4793. com.google.protobuf.MethodOrBuilder \
  4794. com.google.protobuf.Mixin \
  4795. com.google.protobuf.Mixin$1 \
  4796. com.google.protobuf.Mixin$Builder \
  4797. com.google.protobuf.MixinOrBuilder \
  4798. com.google.protobuf.MutabilityOracle \
  4799. com.google.protobuf.MutabilityOracle$1 \
  4800. com.google.protobuf.NewInstanceSchema \
  4801. com.google.protobuf.NewInstanceSchemaLite \
  4802. com.google.protobuf.NewInstanceSchemas \
  4803. com.google.protobuf.NioByteString \
  4804. com.google.protobuf.NioByteString$1 \
  4805. com.google.protobuf.NullValue \
  4806. com.google.protobuf.NullValue$1 \
  4807. com.google.protobuf.OneofInfo \
  4808. com.google.protobuf.Option \
  4809. com.google.protobuf.Option$1 \
  4810. com.google.protobuf.Option$Builder \
  4811. com.google.protobuf.OptionOrBuilder \
  4812. com.google.protobuf.Parser \
  4813. com.google.protobuf.PrimitiveNonBoxingCollection \
  4814. com.google.protobuf.Protobuf \
  4815. com.google.protobuf.ProtobufArrayList \
  4816. com.google.protobuf.ProtobufLists \
  4817. com.google.protobuf.ProtocolStringList \
  4818. com.google.protobuf.ProtoSyntax \
  4819. com.google.protobuf.RawMessageInfo \
  4820. com.google.protobuf.Reader \
  4821. com.google.protobuf.RopeByteString \
  4822. com.google.protobuf.RopeByteString$1 \
  4823. com.google.protobuf.RopeByteString$Balancer \
  4824. com.google.protobuf.RopeByteString$PieceIterator \
  4825. com.google.protobuf.RopeByteString$RopeInputStream \
  4826. com.google.protobuf.Schema \
  4827. com.google.protobuf.SchemaFactory \
  4828. com.google.protobuf.SchemaUtil \
  4829. com.google.protobuf.SmallSortedMap \
  4830. com.google.protobuf.SmallSortedMap$1 \
  4831. com.google.protobuf.SmallSortedMap$DescendingEntryIterator \
  4832. com.google.protobuf.SmallSortedMap$DescendingEntrySet \
  4833. com.google.protobuf.SmallSortedMap$EmptySet \
  4834. com.google.protobuf.SmallSortedMap$EmptySet$1 \
  4835. com.google.protobuf.SmallSortedMap$EmptySet$2 \
  4836. com.google.protobuf.SmallSortedMap$Entry \
  4837. com.google.protobuf.SmallSortedMap$EntryIterator \
  4838. com.google.protobuf.SmallSortedMap$EntrySet \
  4839. com.google.protobuf.SourceContext \
  4840. com.google.protobuf.SourceContext$1 \
  4841. com.google.protobuf.SourceContext$Builder \
  4842. com.google.protobuf.SourceContextOrBuilder \
  4843. com.google.protobuf.SourceContextProto \
  4844. com.google.protobuf.StringValue \
  4845. com.google.protobuf.StringValue$1 \
  4846. com.google.protobuf.StringValue$Builder \
  4847. com.google.protobuf.StringValueOrBuilder \
  4848. com.google.protobuf.Struct \
  4849. com.google.protobuf.Struct$1 \
  4850. com.google.protobuf.Struct$Builder \
  4851. com.google.protobuf.Struct$FieldsDefaultEntryHolder \
  4852. com.google.protobuf.StructOrBuilder \
  4853. com.google.protobuf.StructProto \
  4854. com.google.protobuf.StructuralMessageInfo \
  4855. com.google.protobuf.StructuralMessageInfo$Builder \
  4856. com.google.protobuf.Syntax \
  4857. com.google.protobuf.Syntax$1 \
  4858. com.google.protobuf.TextFormatEscaper \
  4859. com.google.protobuf.TextFormatEscaper$1 \
  4860. com.google.protobuf.TextFormatEscaper$2 \
  4861. com.google.protobuf.TextFormatEscaper$ByteSequence \
  4862. com.google.protobuf.Timestamp \
  4863. com.google.protobuf.Timestamp$1 \
  4864. com.google.protobuf.Timestamp$Builder \
  4865. com.google.protobuf.TimestampOrBuilder \
  4866. com.google.protobuf.TimestampProto \
  4867. com.google.protobuf.Type \
  4868. com.google.protobuf.Type$1 \
  4869. com.google.protobuf.Type$Builder \
  4870. com.google.protobuf.TypeOrBuilder \
  4871. com.google.protobuf.TypeProto \
  4872. com.google.protobuf.UInt32Value \
  4873. com.google.protobuf.UInt32Value$1 \
  4874. com.google.protobuf.UInt32Value$Builder \
  4875. com.google.protobuf.UInt32ValueOrBuilder \
  4876. com.google.protobuf.UInt64Value \
  4877. com.google.protobuf.UInt64Value$1 \
  4878. com.google.protobuf.UInt64Value$Builder \
  4879. com.google.protobuf.UInt64ValueOrBuilder \
  4880. com.google.protobuf.UninitializedMessageException \
  4881. com.google.protobuf.UnknownFieldSchema \
  4882. com.google.protobuf.UnknownFieldSetLite \
  4883. com.google.protobuf.UnknownFieldSetLiteSchema \
  4884. com.google.protobuf.UnmodifiableLazyStringList \
  4885. com.google.protobuf.UnmodifiableLazyStringList$1 \
  4886. com.google.protobuf.UnmodifiableLazyStringList$2 \
  4887. com.google.protobuf.UnsafeByteOperations \
  4888. com.google.protobuf.UnsafeUtil \
  4889. com.google.protobuf.UnsafeUtil$1 \
  4890. com.google.protobuf.UnsafeUtil$Android32MemoryAccessor \
  4891. com.google.protobuf.UnsafeUtil$Android64MemoryAccessor \
  4892. com.google.protobuf.UnsafeUtil$JvmMemoryAccessor \
  4893. com.google.protobuf.UnsafeUtil$MemoryAccessor \
  4894. com.google.protobuf.Utf8 \
  4895. com.google.protobuf.Utf8$DecodeUtil \
  4896. com.google.protobuf.Utf8$Processor \
  4897. com.google.protobuf.Utf8$SafeProcessor \
  4898. com.google.protobuf.Utf8$UnpairedSurrogateException \
  4899. com.google.protobuf.Utf8$UnsafeProcessor \
  4900. com.google.protobuf.Value \
  4901. com.google.protobuf.Value$1 \
  4902. com.google.protobuf.Value$Builder \
  4903. com.google.protobuf.Value$KindCase \
  4904. com.google.protobuf.ValueOrBuilder \
  4905. com.google.protobuf.WireFormat \
  4906. com.google.protobuf.WireFormat$1 \
  4907. com.google.protobuf.WireFormat$FieldType \
  4908. com.google.protobuf.WireFormat$FieldType$1 \
  4909. com.google.protobuf.WireFormat$FieldType$2 \
  4910. com.google.protobuf.WireFormat$FieldType$3 \
  4911. com.google.protobuf.WireFormat$FieldType$4 \
  4912. com.google.protobuf.WireFormat$JavaType \
  4913. com.google.protobuf.WireFormat$Utf8Validation \
  4914. com.google.protobuf.WireFormat$Utf8Validation$1 \
  4915. com.google.protobuf.WireFormat$Utf8Validation$2 \
  4916. com.google.protobuf.WireFormat$Utf8Validation$3 \
  4917. com.google.protobuf.WrappersProto \
  4918. com.google.protobuf.Writer \
  4919. com.google.protobuf.Writer$FieldOrder
  4920. # tag:java-specific
  4921. JAVA_IGNORE_CLASSPATH_CLASH_VALUE=$JAVA_IGNORE_CLASSPATH_CLASH_DEFAULE_VALUE
  4922. ### @usage: JAVA_IGNORE_CLASSPATH_CLASH_FOR([classes])
  4923. ### Ignore classpath clash test fails for classes
  4924. macro JAVA_IGNORE_CLASSPATH_CLASH_FOR(Args...) {
  4925. SET_APPEND(JAVA_IGNORE_CLASSPATH_CLASH_VALUE $Args $JAVA_IGNORE_CLASSPATH_CLASH_DEFAULE_VALUE)
  4926. }
  4927. IBTOOL_PATH=$XCODE_TOOLS_ROOT_RESOURCE_GLOBAL/Xcode/Contents/Developer/usr/bin/ibtool
  4928. # tag:src-processing
  4929. STORYBOARD_FLAGS=--errors --warnings --notices --auto-activate-custom-fonts --output-format human-readable-text
  4930. macro _SRC("storyboard", SRC, SRCFLAGS...) {
  4931. .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}
  4932. }
  4933. # tag:src-processing
  4934. macro _SRC("xib", SRC, SRCFLAGS...) {
  4935. .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}
  4936. }
  4937. # tag:src-processing
  4938. macro _SRC("msg", SRC, SRCFLAGS...) {
  4939. .CMD=$ROS_CMD($SRC)
  4940. }
  4941. ACTOOL_PATH=$XCODE_TOOLS_ROOT_RESOURCE_GLOBAL/Xcode/Contents/Developer/usr/bin/ibtool
  4942. # tag:ios-specific
  4943. ASSETS_FLAGS=--output-format human-readable-text --notices --warnings
  4944. macro _IOS_ASSETS(AssetsDir, Content...) {
  4945. .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 ${hide;input:Content} && ${cwd:BINDIR} $YMAKE_PYTHON ${input:"build/scripts/tar_directory.py"} ${output;suf=_assetes.resource_tar:REALPRJNAME} $REALPRJNAME $REALPRJNAME
  4946. }
  4947. # tag:ios-specific
  4948. macro IOS_APP_COMMON_FLAGS(Flags...) {
  4949. SET_APPEND(STORYBOARD_FLAGS $Flags)
  4950. SET_APPEND(ASSETS_FLAGS $Flags)
  4951. }
  4952. # tag:ios-specific
  4953. macro IOS_APP_ASSETS_FLAGS(Flags...) {
  4954. SET_APPEND(ASSETS_FLAGS $Flags)
  4955. }
  4956. macro DARWIN_STRINGS_RESOURCE(Resource, Relpath) {
  4957. .CMD=$COPY_CMD ${input:Resource} $BINDIR/$Relpath && $YMAKE_PYTHON ${input:"build/scripts/tar_directory.py"} ${output;tobindir;suf=.strings_tar:Relpath} $BINDIR/$Relpath $BINDIR
  4958. }
  4959. macro DARWIN_SIGNED_RESOURCE(Resource, Relpath) {
  4960. .CMD=$COPY_CMD $Resource $BINDIR/$Relpath && $YMAKE_PYTHON ${input:"build/scripts/tar_directory.py"} ${output;tobindir;suf=.signed_resource_tar:Relpath} $BINDIR/$Relpath $BINDIR
  4961. }
  4962. # tag:ios-specific
  4963. DELIM=__DELIM__
  4964. 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
  4965. ### @usage: IOS_INTERFACE()
  4966. ### iOS GUI module definition
  4967. module IOS_INTERFACE: _BARE_UNIT {
  4968. .CMD=PACK_IOS_ARCHIVE
  4969. .EXTS=.compiled_storyboard_tar .partial_plist .plist .xcent .nib .resource_tar .signed_resource_tar .strings_tar .plist_json
  4970. .NODE_TYPE=Library
  4971. .FINAL_TARGET=no
  4972. SET(MODULE_SUFFIX .ios.interface)
  4973. PEERDIR+=build/platform/xcode/tools
  4974. }
  4975. # tag:ios-specific
  4976. module DEFAULT_IOS_INTERFACE: IOS_INTERFACE {
  4977. SET(MODULE_SUFFIX .default.ios.interface)
  4978. }
  4979. DEFAULT_IOS_TYPE=
  4980. IOS_TYPE=
  4981. when(!$IOS_TYPE) {
  4982. when($DEFAULT_IOS_TYPE) {
  4983. IOS_TYPE=$DEFAULT_IOS_TYPE
  4984. }
  4985. otherwise {
  4986. IOS_TYPE=com.apple.CoreSimulator.SimDeviceType.iPhone-X
  4987. }
  4988. }
  4989. DEFAULT_IOS_RUNTIME=
  4990. IOS_RUNTIME=
  4991. when(!$IOS_RUNTIME) {
  4992. when($DEFAULT_IOS_RUNTIME) {
  4993. IOS_RUNTIME=$DEFAULT_IOS_RUNTIME
  4994. }
  4995. otherwise {
  4996. IOS_RUNTIME=com.apple.CoreSimulator.SimRuntime.iOS-12-1
  4997. }
  4998. }
  4999. when ($ARCH_I386) {
  5000. TEST_IOS_DEVICE_TYPE_VALUE=com.apple.CoreSimulator.SimDeviceType.iPhone-5
  5001. TEST_IOS_RUNTIME_TYPE_VALUE=com.apple.CoreSimulator.SimRuntime.iOS-10-3
  5002. }
  5003. otherwise {
  5004. TEST_IOS_DEVICE_TYPE_VALUE=$IOS_TYPE
  5005. TEST_IOS_RUNTIME_TYPE_VALUE=$IOS_RUNTIME
  5006. }
  5007. # tag:frontend-specific
  5008. ### @usage: COLLECT_FRONTEND_FILES(Varname, Dir)
  5009. ###
  5010. ### Recursively collect files with typical frontend extensions from Dir and save the result into variable Varname
  5011. macro COLLECT_FRONTEND_FILES(Varname, Dir) {
  5012. _GLOB($Varname $Dir/**/*.(css|ejs|jpg|js|jsx|png|styl|svg|ts|tsx|json|html))
  5013. }
  5014. # tag:swift-specific
  5015. CPP_XCODE_TOOLCHAIN_VERSION=9.2
  5016. SWIFT_XCODE_TOOLCHAIN_VERSION=9.2
  5017. XCODE_TOOLS_VERSION=10.1
  5018. macro COMPILE_SWIFT_MODULE(SRCS{input}[], BRIDGE_HEADER{input}="", Flags...) {
  5019. when ($BRIDGE_HEADER != "") {
  5020. SWIFT_BRIDGE_HEADER=-import-objc-header ${input:BRIDGE_HEADER}
  5021. }
  5022. otherwise {
  5023. SWIFT_BRIDGE_HEADER=
  5024. }
  5025. .PEERDIR+=build/platform/xcode/swift
  5026. # swift core libraries
  5027. LDFLAGS($SWIFT_LD_FLAGS)
  5028. .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 ${hide;output;suf=.o:SRCS}
  5029. }
  5030. TEST_TOOL_HOST_LOCAL=
  5031. TEST_TOOL_TARGET_LOCAL=
  5032. when ($MOST_USED_CUDA) {
  5033. CUDA11=yes
  5034. }
  5035. CUDA_VERSION=0
  5036. when ($CUDA11) {
  5037. CUDA_VERSION=11.4
  5038. CUDNN_VERSION=8.0.5
  5039. TENSORRT_VERSION=7
  5040. }
  5041. when ($CUDA12) {
  5042. CUDA_VERSION=12.2
  5043. CUDNN_VERSION=8.6.0
  5044. TENSORRT_VERSION=8
  5045. }
  5046. when ($TENSORFLOW_WITH_CUDA) {
  5047. CUDA_REQUIRED=yes
  5048. }
  5049. when (!$TENSORRT_VERSION) {
  5050. TENSORRT_VERSION=5
  5051. }
  5052. ANDROID_APK_TEST_ACTIVITY_VALUE=com.yandex.test.unittests/.RunTestsActivity
  5053. # tag:windows-specific
  5054. WINDOWS_MANIFEST=
  5055. macro WINDOWS_MANIFEST(Manifest) {
  5056. SET(WINDOWS_MANIFEST $Manifest)
  5057. }
  5058. # https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation#enable-long-paths-in-windows-10-version-1607-and-later
  5059. macro WINDOWS_LONG_PATH_MANIFEST() {
  5060. SET(WINDOWS_MANIFEST build/long-path.manifest)
  5061. }
  5062. # tag:windows-specific
  5063. when ($MSVC == "yes" && $WINDOWS_MANIFEST) {
  5064. LDFLAGS+=/MANIFEST:EMBED /MANIFESTINPUT:${input:WINDOWS_MANIFEST}
  5065. }
  5066. # tag:cpp-specific
  5067. _VISIBILITY_LEVEL=
  5068. ### @usage: VISIBILITY(level)
  5069. ###
  5070. ### This macro sets visibility level for symbols compiled for the current module. 'level'
  5071. ### may take only one of the following values: DEFAULT, HIDDEN.
  5072. macro VISIBILITY(LEVEL) {
  5073. SET(_VISIBILITY_LEVEL ${LEVEL})
  5074. select ($LEVEL) {
  5075. "DEFAULT" | "HIDDEN" ? {
  5076. }
  5077. default ? {
  5078. _OK = no
  5079. }
  5080. }
  5081. ASSERT(_OK Unsupported value [$LEVEL] passed to VISIBILITY macro, expected values are DEFAULT, HIDDEN.)
  5082. }
  5083. # tag:cpp-specific
  5084. _CFLAGS_VISIBILITY=
  5085. when ($_VISIBILITY_LEVEL != "" && $IGNORE_VISIBILITY != "yes") {
  5086. when ($CLANG == "yes" || $GCC == "yes") {
  5087. _CFLAGS_VISIBILITY=-fvisibility=${tolower:_VISIBILITY_LEVEL}
  5088. }
  5089. }
  5090. CFLAGS+=$_CFLAGS_VISIBILITY
  5091. # tag:cpp-specific
  5092. macro SDBUS_CPP_ADAPTOR(File) {
  5093. .CMD=${tool:"contrib/libs/sdbus-cpp/tools/xml2cpp-codegen"} --adaptor=${output;nopath;noext:File.adaptor.h} ${input:File}
  5094. .PEERDIR=contrib/libs/sdbus-cpp
  5095. }
  5096. # tag:cpp-specific
  5097. macro SDBUS_CPP_PROXY(File) {
  5098. .CMD=${tool:"contrib/libs/sdbus-cpp/tools/xml2cpp-codegen"} --proxy=${output;nopath;noext:File.proxy.h} ${input:File}
  5099. .PEERDIR=contrib/libs/sdbus-cpp
  5100. }
  5101. # tag:python-specific
  5102. macro _PY_ENUM_SERIALIZATION_TO_JSON(File) {
  5103. .CMD=$ENUM_PARSER_TOOL ${input:File} --output ${output;noext;suf=.generated.h:File} --json-output ${output;noext:File.json} ${hide;kv:"p EN"} ${hide;kv:"pc yellow"}
  5104. }
  5105. # tag:python-specific
  5106. macro _PY_ENUM_SERIALIZATION_TO_PY(File) {
  5107. .CMD=${tool:"metrika/core/tools/python_enum_generator"} ${input;noext:File.json} -D ${MODDIR} --output ${output;noext:File.py} ${hide;kv:"p EN"} ${hide;kv:"pc yellow"}
  5108. }
  5109. macro NGINX_MODULES(Modules...) {
  5110. PEERDIR(${Modules})
  5111. 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)
  5112. }
  5113. ### @usage: ORIGINAL_SOURCE(Source)
  5114. ###
  5115. ### This macro specifies the source repository for contrib
  5116. ### Does nothing now (just a placeholder for future functionality)
  5117. ### See https://st.yandex-team.ru/DTCC-316
  5118. macro ORIGINAL_SOURCE(Source) {
  5119. ENABLE(UNUSED_MACRO)
  5120. }
  5121. # tag:licence
  5122. CREDITS_FILE_EXTRA_EXT=
  5123. CREDITS_FLAGS=
  5124. CREDITS_TEXTS_FILE=
  5125. NO_CREDITS_TEXTS_FILE=
  5126. WITH_CREDITS=
  5127. ### @usage: LICENSE_TEXTS(File)
  5128. ###
  5129. ### This macro specifies the filename with all library licenses texts
  5130. macro LICENSE_TEXTS(Source) {
  5131. SET(CREDITS_TEXTS_FILE $Source)
  5132. }
  5133. # tag:licence
  5134. ### @usage: WITHOUT_LICENSE_TEXTS()
  5135. ###
  5136. ### This macro indicates that the module has no license text
  5137. macro WITHOUT_LICENSE_TEXTS() {
  5138. ENABLE(NO_CREDITS_TEXTS_FILE)
  5139. }
  5140. # tag:licence
  5141. when ($WITH_CREDITS) {
  5142. CREDITS_FLAGS+=--credits-output ${output;pre=${MODULE_PREFIX};suf=${MODULE_SUFFIX}${CREDITS_FILE_EXTRA_EXT}.CREDITS.txt:REALPRJNAME}
  5143. }
  5144. GENERATE_MF=
  5145. when ($WITH_CREDITS) {
  5146. GENERATE_MF=$GENERATE_MF_CMD
  5147. }
  5148. # tag:flags tag:internal tag:windows-specific
  5149. ### @usage: _MSVC_FLAGS_WINDOWS_IMPL(target_platform compiler_flags) # internal
  5150. ###
  5151. ### Add CFLAGS when the firts argument is WINDOWS
  5152. macro _MSVC_FLAGS_WINDOWS_IMPL(WINDOWS[], FLAGS...) {
  5153. CFLAGS($WINDOWS)
  5154. }
  5155. # tag:flags tag:windows-specific tag:cpp-specific
  5156. ### @usage: MSVC_FLAGS([GLOBAL compiler_flag]* compiler_flags)
  5157. ###
  5158. ### Add the specified flags to the compilation line of C/C++files.
  5159. ### Flags apply only if the compiler used is MSVC (cl.exe)
  5160. macro MSVC_FLAGS(FLAGS...) {
  5161. _MSVC_FLAGS_WINDOWS_IMPL($TARGET_PLATFORM $FLAGS)
  5162. }
  5163. # tag:internal
  5164. ### Add passed ya.conf.json and all bottle's formula external files to resources
  5165. ### File MUST be arcadia root relative path (without "${ARCADIA_ROOT}/" prefix).
  5166. ### NOTE:
  5167. ### An external formula file referenced from ya.conf.json must be passed as an arcadia root relative path and
  5168. ### should be located in any subdirectory of the ya.conf.json location ("build/" if we consider a production).
  5169. ### The later restriction prevents problems in selectively checkouted arcadia.
  5170. macro YA_CONF_JSON(File) {
  5171. _YA_CONF_JSON($File)
  5172. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS ${ARCADIA_ROOT}/$File)
  5173. }
  5174. # tag:internal
  5175. # Don't use directly - wrap with custom macros
  5176. macro ADD_LINTER_CHECK(CheckName, Linter, DEPENDS[], EXCLUDE[], FILES[], CONFIGS[]) {
  5177. SET(_FILES_VAR uniq_${hash:VAR_SALT})
  5178. _GLOB($_FILES_VAR $FILES EXCLUDE $EXCLUDE)
  5179. _ADD_LINTER_CHECK($CheckName $Linter ${pre=DEPENDS :DEPENDS} FILES $$_FILES_VAR CONFIGS $CONFIGS)
  5180. }
  5181. # tag:internal
  5182. # Draft. Don't use.
  5183. macro _CPP_STYLE(EXCLUDE[], Files...) {
  5184. ADD_LINTER_CHECK(cpp_style tools/cpp_style_checker/cpp_style_checker DEPENDS contrib/libs/clang16/tools/clang-format EXCLUDE $EXCLUDE FILES $Files CONFIGS devtools/ya/handlers/style/style_config)
  5185. }
  5186. #tag:test
  5187. ### @usage STYLE_CPP()
  5188. ###
  5189. ### Run clang-format test on all cpp sources of current module
  5190. macro STYLE_CPP() {
  5191. SET(USE_ALL_SRCS yes)
  5192. HEADERS(.)
  5193. _ADD_LINTER_CHECK(cpp_style tools/cpp_style_checker/cpp_style_checker DEPENDS contrib/libs/clang16/tools/clang-format CONFIGS build/config/tests/cpp_style/config.clang-format)
  5194. }
  5195. ### @usage: HEADERS([Dir1 Dir2 ...])
  5196. ###
  5197. ### Add all C/C++ header files (h|H|hh|hpp|hxx|ipp) in given directories to SRCS
  5198. macro HEADERS(Dirs...) {
  5199. _GLOB(_HEADERS ${suf=/*.(h|H|hh|hpp|hxx|ipp):Dirs})
  5200. SRCS($_HEADERS)
  5201. }
  5202. ### @usage: CLANG_EMIT_AST_CXX_RUN_TOOL(Tool Args... [SOURCES ...] [OPTS ...] [IN ...] [IN_NOPARSE ...] [TOOL ...] [OUTPUT_INCLUDES ...] [INDUCED_DEPS ...] [IN_DEPS ...] [STDOUT out-file-name] [STDOUT_NOAUTO out-file-name] [CWD cwd])
  5203. ###
  5204. ### Emit Clang ASTs from .cpp files listed in SOURCES parameter (CXXFLAGS and LLVM_OPTS are passed in, while CFLAGS and C_FLAGS_PLATFORM are not) and run tool Tool with Args... .
  5205. ### OPTS[] parameter is used to pass additional flags to clang. Parameters other than OPTS[] and SOURCES[] are used for runnig a generator (Tool):
  5206. ### - Tool - path to the directory of the tool
  5207. ### - Args... - Tool's arguments
  5208. ### - IN[] - input files required for running the Tool
  5209. ### - IN_NOPARSE[] - input files required for running the Tool, but these files are not parsed for dependencies
  5210. ### - TOOL[] - list of directories of axiliary tools used by Tool
  5211. ### - OUTPUT_INCLUDES[] - includes of the output files which are needed to "build" them
  5212. ### - STDOUT - redirect stdout of the Tool to the output file
  5213. ### - STDOUT_NOAUTO - redirect stdout of the Tool to the output file, but do not chain this file automatically to the processing queue
  5214. ### - CWD - path to the working directory of the Tool
  5215. ### Note: Generated AST files generated into BINDIR according to corresponding .cpp file names listed in SOURCES parameter.
  5216. macro CLANG_EMIT_AST_CXX_RUN_TOOL(SOURCES[], OPTS[], 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...) {
  5217. .CMD=${cwd:BINDIR} $YMAKE_PYTHON ${input:"build/scripts/clang_wrapper.py"} $WINDOWS ${CLANG_RESOURCE_GLOBAL}/bin/clang++ ${pre=-I:_C__INCLUDE} $CXXFLAGS $C_FLAGS_PLATFORM $LLVM_OPTS -emit-ast -c ${input:SOURCES} ${hide;tmp;noext;nopath:SOURCES.ast} $OPTS ${hide;kv:"p ST"} ${hide;kv:"pc light-green"} && ${cwd:CWD} ${env:ENV} ${tool:Tool} $Args ${hide;input:IN} ${input;context=TEXT;hide:IN_NOPARSE} ${hide;input:IN_DEPS} ${output_include;hide:OUTPUT_INCLUDES} $INDUCED_DEPS ${hide;tool:TOOL} ${hide;output:OUT} ${hide;noauto;output:OUT_NOAUTO} ${output;stdout:STDOUT} ${output;stdout;noauto:STDOUT_NOAUTO} ${hide;kv:"p PR"} ${hide;kv:"pc yellow"} ${hide;kv:"show_out"}
  5218. PEERDIR(build/platform/clang)
  5219. }