ymake.core.conf 227 KB

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