ymake.core.conf 227 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740
  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=2023-12-06
  12. GO_FAKEID=11100371
  13. ANDROID_FAKEID=2023-05-17
  14. CLANG_TIDY_FAKEID=2023-06-06
  15. CYTHON_FAKE_ID=10784829
  16. JAVA_FAKEID=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/project_specific/other.conf"
  60. @import "${CONF_ROOT}/conf/project_specific/yt.conf"
  61. SO_OUTPUTS=no
  62. USE_GLOBAL_CMD=no
  63. when ($OS_WINDOWS != "yes") {
  64. USE_GLOBAL_CMD=yes
  65. }
  66. when ($USE_PYTHON) {
  67. C_DEFINES+= -DUSE_PYTHON
  68. }
  69. __COMMA__=${comma:""}
  70. ARCADIA_TEST_ROOT=../arcadia_tests_data/
  71. DEFAULT_REQUIREMENTS=network:restricted cpu:1 ram:32
  72. FAIL_PY2=no
  73. _PREBUILT_TOOLS_ROOT=build/prebuilt
  74. _TOOL_PROTOC_GEN_GO=vendor/github.com/golang/protobuf/protoc-gen-go
  75. _TOOL_PROTOC_GEN_GO_V2=vendor/google.golang.org/protobuf/cmd/protoc-gen-go
  76. _TOOL_PROTOC_GEN_GO_GRPC_V2=vendor/google.golang.org/grpc/cmd/protoc-gen-go-grpc
  77. _TOOL_RESCOMPILER=tools/rescompiler
  78. _TOOL_RESCOMPRESSOR=tools/rescompressor
  79. _TOOL_RORESCOMPILER=tools/rorescompiler
  80. when ($DISABLE_SEPARATE_AUX_CPP != "yes") {
  81. SEPARATE_AUX_CPP=yes
  82. }
  83. _HOST_SUPPORTS_PREBUILT_PROTOC_GEN_GO=no
  84. _TARGET_SUPPORTS_PREBUILT_PROTOC_GEN_GO=no
  85. when ($USE_PREBUILT_TOOLS == "yes") {
  86. when ($HOST_ARCH_X86_64 == "yes" && ($HOST_OS_LINUX == "yes" || $HOST_OS_WINDOWS == "yes" || $HOST_OS_DARWIN == "yes")) {
  87. _HOST_SUPPORTS_PREBUILT_PROTOC_GEN_GO=yes
  88. }
  89. when ($HOST_ARCH_ARM64 == "yes" && $HOST_OS_DARWIN == "yes") {
  90. _HOST_SUPPORTS_PREBUILT_PROTOC_GEN_GO=yes
  91. }
  92. when ($ARCH_X86_64 == "yes" && ($OS_LINUX == "yes" || $OS_WINDOWS == "yes" || $OS_DARWIN == "yes")) {
  93. _TARGET_SUPPORTS_PREBUILT_PROTOC_GEN_GO=yes
  94. }
  95. when ($ARCH_ARM64 == "yes" && $OS_DARWIN == "yes") {
  96. _TARGET_SUPPORTS_PREBUILT_PROTOC_GEN_GO=yes
  97. }
  98. when ($_HOST_SUPPORTS_PREBUILT_PROTOC_GEN_GO == "yes" && $_TARGET_SUPPORTS_PREBUILT_PROTOC_GEN_GO == "yes") {
  99. _TOOL_PROTOC_GEN_GO=${_PREBUILT_TOOLS_ROOT}/vendor/github.com/golang/protobuf/protoc-gen-go
  100. }
  101. }
  102. ### @usage: SELECT_CLANG_SA_CONFIG(static_analyzer.yaml)
  103. ###
  104. ### Select config file for clang static analyzer.
  105. ### The file should be called static_analyzer.yaml.
  106. macro SELECT_CLANG_SA_CONFIG(config) {
  107. SET(_CLANG_SA_CONFIG ${input:config})
  108. }
  109. ### @usage: USE_SA_PLUGINS(FROM path/to/external/module1 NAME VAR_NAME1 FROM path/to/external/module2 NAME VAR_NAME2 ...)
  110. ###
  111. ### Select additional plugins for clang static analyzer, each path/to/external/module should declare target RESOURCES_LIBRARY.
  112. ### VAR_NAME should be the same value that was passed into DECLARE_EXTERNAL_HOST_RESOURCES_BUNDLE as first argument.
  113. ### See example in market/report/csa_checks/static_analyzer_ymake.inc
  114. macro USE_SA_PLUGINS(FROM[], NAME[]) {
  115. PEERDIR($FROM)
  116. SET_APPEND(CLANG_SA_PLUGINS ${suf=_RESOURCE_GLOBAL/plugin.so;pre=$:NAME})
  117. }
  118. # Helper macro for unwrapping sequence of files
  119. macro _CLANG_SA_UNWRAP_PLUGINS(Plugins{input}[]) {
  120. .CMD=${Plugins}
  121. }
  122. CLANG_SA_PLUGINS=
  123. CLANG_CSA_ROOT=${CLANG_CSA16_RESOURCE_GLOBAL}
  124. CLANG_CSA_BIN=${CLANG_CSA16_RESOURCE_GLOBAL}/bin/clang
  125. when ($CLANG_SA_ENABLE == "yes" && $_CLANG_SA_CONFIG && $CLANG_CSA_ROOT) {
  126. PEERDIR+=build/platform/clang/clang-static-analyzer
  127. CLANG_STATIC_ANALYZER_OPTIONS=$YMAKE_PYTHON3 ${input:"build/scripts/clang_static_analyzer.py"} \
  128. "--testing-src" ${input:SRC} \
  129. "--clang-bin" $CLANG_CSA_BIN \
  130. "--source-root" $(SOURCE_ROOT) \
  131. "--config-file" ${input:_CLANG_SA_CONFIG} \
  132. "--plugins-begin" "dummy_param" $_CLANG_SA_UNWRAP_PLUGINS($CLANG_SA_PLUGINS) "--plugins-end" \
  133. $GCC_COMPILE_FLAGS $CXXFLAGS $SRCFLAGS
  134. }
  135. otherwise {
  136. CLANG_STATIC_ANALYZER_OPTIONS=
  137. }
  138. FAIL_MODULE_CMD=$YMAKE_PYTHON3 ${input:"build/scripts/fail_module_cmd.py"} $TARGET ${kv;hide:"p ER"} ${kv;hide:"pc red"}
  139. DEFAULT_TIDY_CONFIG=build/config/tests/clang_tidy/config.yaml
  140. PROJECT_TIDY_CONFIG=build/config/tests/clang_tidy/config.yaml
  141. TIDY=
  142. TIDY_ENABLED=
  143. when($TIDY == "yes") {
  144. TIDY_ENABLED=yes
  145. }
  146. CLANG_TIDY_BIN=${CLANG_TIDY_RESOURCE_GLOBAL}/bin/clang-tidy
  147. when ($TIDY_ENABLED == "yes") {
  148. when ($TIDY_EXPORT_FIXES=="") {
  149. TIDY_EXPORT_FIXES="no"
  150. }
  151. 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
  152. CLANG_TIDY_ARGS+="--default-config-file" ${input:DEFAULT_TIDY_CONFIG}
  153. CLANG_TIDY_ARGS+="--project-config-file" ${input:PROJECT_TIDY_CONFIG}
  154. when ($TIDY_CHECKS) {
  155. CLANG_TIDY_ARGS+="--checks=$TIDY_CHECKS"
  156. }
  157. when ($TIDY_HEADER_FILTER) {
  158. CLANG_TIDY_ARGS+="--header-filter=$TIDY_HEADER_FILTER"
  159. }
  160. TIDY_VALUE=USE_CONDITIONAL_SRCS
  161. }
  162. otherwise {
  163. CLANG_TIDY_ARGS=
  164. TIDY_VALUE=
  165. }
  166. # tag:profile
  167. NEED_PROFILE_RUNTIME=no
  168. when ($BUILD_TYPE == "PROFILE" || $BUILD_TYPE == "COVERAGE" || ($CLANG_COVERAGE && $CLANG_COVERAGE != "no") || $GCOV_COVERAGE == "yes" || $PGO_ADD == "yes") {
  169. when($CLANG && ($TARGET_PLATFORM == "LINUX" || $TARGET_PLATFORM == "DARWIN")) {
  170. NEED_PROFILE_RUNTIME=yes
  171. }
  172. }
  173. otherwise {
  174. NEED_PROFILE_RUNTIME=no
  175. }
  176. when ($NEED_PROFILE_RUNTIME == "yes") {
  177. COPY_PROFILE_RUNTIME=\
  178. $YMAKE_PYTHON3 ${input:"build/scripts/copy_clang_profile_rt.py"} \
  179. --arch $TARGET_PLATFORM \
  180. --build-root $ARCADIA_BUILD_ROOT --
  181. COPY_PROFILE_RUNTIME+=\
  182. ${rootrel:PEERS} \
  183. $LDFLAGS
  184. }
  185. otherwise {
  186. COPY_PROFILE_RUNTIME=
  187. }
  188. # tag:codenav
  189. when ($CODENAVIGATION && $NOCODENAVIGATION != "yes") {
  190. PY_PROGRAM_LINK_EXE=$LINK_EXE ${kv;hide:"pyndex $TARGET"}
  191. YNDEXER_ARGS=$YMAKE_PYTHON ${input:"build/scripts/yndexer.py"} $CPPYNDEXER_RESOURCE_GLOBAL/yndexer 1500 $(SOURCE_ROOT) $ARCADIA_BUILD_ROOT ${input:SRC}
  192. YNDEXER_OUTPUT=${output;noauto;suf=${OBJ_CROSS_SUF}${COMPILE_OUT_SUFFIX}.ydx.pb2:SRC}
  193. }
  194. otherwise {
  195. PY_PROGRAM_LINK_EXE=$LINK_EXE
  196. YNDEXER_ARGS=
  197. YNDEXER_OUTPUT=
  198. }
  199. when ($RETRY == "yes") {
  200. RETRY_ARGS=$YMAKE_PYTHON ${input:"build/scripts/wrapcc.py"}
  201. }
  202. otherwise {
  203. RETRY_ARGS=
  204. }
  205. COVERAGE_FLAGS=
  206. EXTRA_OUTPUT=
  207. when ($CLANG == "yes" || $GCC == "yes") {
  208. when ($BUILD_TYPE == "COVERAGE" || $GCOV_COVERAGE) {
  209. COVERAGE_FLAGS=-fprofile-arcs -ftest-coverage
  210. EXTRA_OUTPUT=${output;noauto;hide;suf=${COMPILE_OUT_SUFFIX}${OBJ_SUF}${_CROSS_SUFFIX}.gcno:SRC}
  211. }
  212. }
  213. when ($OS_CYGWIN == "yes") {
  214. CFLAGS+=-D_LDBL_EQ_DBL=1 -U__STRICT_ANSI__
  215. USE_ASMLIB=no
  216. FSTACK=
  217. }
  218. when ($OS_IOS == "yes" || $OS_ANDROID == "yes") {
  219. USE_ASMLIB=no
  220. }
  221. CFLAGS+=$COVERAGE_FLAGS
  222. LDFLAGS+=$COVERAGE_FLAGS
  223. CHECKFLAG=
  224. NO_MAPREDUCE=
  225. when ($NO_MAPREDUCE == "yes") {
  226. C_DEFINES+=-DNO_MAPREDUCE
  227. }
  228. when ($OS_ANDROID == "yes") {
  229. PIE=yes
  230. }
  231. when ($CLANG && $OS_DARWIN && $SANITIZER_TYPE && $SANITIZER_TYPE != "no") {
  232. SO_OUTPUTS=yes
  233. }
  234. when ($OS_NONE == "yes" || $MAPSMOBI_BUILD_TARGET == "yes" && $OS_LINUX != "yes") {
  235. USE_STL_SYSTEM=yes
  236. }
  237. # USE_INTERNAL_STL is an internal flag (set on by default) but may be used externally to
  238. # select system standard C++ library when USE_INTERNAL_STL=no is set.
  239. #
  240. # USE_STL_SYSTEM=yes is a regular way to select system standard C++ library.
  241. #
  242. when ($USE_STL_SYSTEM == "yes") {
  243. USE_INTERNAL_STL=no
  244. }
  245. when ($USE_INTERNAL_STL == "no") {
  246. USE_STL_SYSTEM=yes
  247. }
  248. otherwise {
  249. USE_INTERNAL_STL=yes
  250. # TODO: Extract to conf/sysincl.conf
  251. # This trigger doesn't work for module level since SYSINCL is processed at
  252. # configuration stage (This means that NO_RUNTIME() macro called in ya.make
  253. # won't affect SYSINCL and the only way to make this trigger work correctly
  254. # is to define configuration variable NORUNTIME (-DNORUNTIME) on the command
  255. # line when `ya make ...` is invoked.
  256. when ($NORUNTIME != "yes") {
  257. SYSINCL+=build/sysincl/stl-to-libcxx.yml
  258. when ($MSVC == "yes" && $CLANG_CL != "yes") {
  259. SYSINCL+=build/sysincl/stl-to-libcxxmsvc.yml
  260. }
  261. when ($MUSL == "yes") {
  262. SYSINCL+=build/sysincl/libc-musl-libcxx.yml
  263. }
  264. }
  265. }
  266. # tag:linux-specific
  267. when ($OS_LINUX && $OS_SDK == "ubuntu-14" && $MUSL != "yes") {
  268. USE_UBUNTU_COMPATIBILITY=yes
  269. }
  270. USE_ARCADIA_PYTHON=yes
  271. USE_ARCADIA_LIBM=no
  272. USE_EAT_MY_DATA=no
  273. HAVE_MKL=
  274. when ($HAVE_MKL == "") {
  275. when ($OS_LINUX && $ARCH_X86_64 && !$SANITIZER_TYPE) {
  276. HAVE_MKL=yes
  277. }
  278. otherwise {
  279. HAVE_MKL=no
  280. }
  281. }
  282. SFDL_TMP_OUT= ${output;tmp:SRC.tmp}
  283. # tag:tool-specific
  284. ARCH_TOOL=${tool:"tools/archiver"}
  285. # tag:tool-specific
  286. LUA_TOOL=${tool:"tools/lua"}
  287. ENUM_PARSER_TOOL=${tool:"tools/enum_parser/enum_parser"}
  288. FATAL_ERROR_MODULE=no
  289. FATAL_ERROR_MESSAGE=
  290. ANTLR_PYTHON=Python2
  291. ### @usage: NO_LTO()
  292. ###
  293. ### Disable any lto (link-time optimizations) for the module.
  294. ### This will compile module source files as usual (without LTO) but will not prevent lto-enabled
  295. ### linking of entire program if global settings say so.
  296. macro NO_LTO() {
  297. DISABLE(USE_LTO)
  298. DISABLE(USE_THINLTO)
  299. }
  300. # tag:allocator
  301. DEFAULT_ALLOCATOR=LF
  302. # tag:allocator
  303. when ($OS_ANDROID == "yes" || $MSVC == "yes" || $ARCH_TYPE_32 == "yes" || $ARCH_AARCH64 == "yes") {
  304. DEFAULT_ALLOCATOR=J
  305. }
  306. # tag:allocator
  307. when ($OS_CYGWIN == "yes" || $ARCH_PPC64LE == "yes") {
  308. DEFAULT_ALLOCATOR=SYSTEM
  309. }
  310. # tag:allocator
  311. when ($OS_DARWIN == "yes") {
  312. DEFAULT_ALLOCATOR=SYSTEM
  313. }
  314. # tag:allocator
  315. when ($OS_LINUX == "yes") {
  316. when ($GCC) {
  317. # tcmalloc broken build
  318. }
  319. elsewhen ($SANDBOXING) {
  320. # broken
  321. }
  322. elsewhen ($ARCH_X86_64) {
  323. DEFAULT_ALLOCATOR=TCMALLOC_TC
  324. }
  325. }
  326. # tag:allocator
  327. when ($SANITIZER_TYPE) {
  328. when ($SANITIZER_TYPE != "no") {
  329. DEFAULT_ALLOCATOR=SYSTEM
  330. }
  331. }
  332. # tag:allocator
  333. when ($ARCH_XTENSA == "yes") {
  334. DEFAULT_ALLOCATOR=FAKE
  335. }
  336. # tag:internal
  337. ### @usage: CHECK_CONFIG_H(<conf_header>) # internal
  338. ###
  339. ### This internal macro adds checking code for configuration header in external (contrib) library.
  340. ### The check is needed to avoid conflicts on certain types and functions available in arcadia.
  341. ###
  342. ### @see https://a.yandex-team.ru/arc/trunk/arcadia/build/scripts/check_config_h.py for exact details
  343. macro CHECK_CONFIG_H(Conf) {
  344. .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"}
  345. OUTPUT_INCLUDES=$Conf
  346. }
  347. REQUIRED_TRANSITIVE_PEERS=
  348. ### @usage REQUIRES(dirs...)
  349. ###
  350. ### Specify list of dirs which this module must depend on indirectly.
  351. ###
  352. ### This macro can be used if module depends on the directories specified but they can't be listed
  353. ### as direct PEERDIR dependencies (due to public include order or link order issues).
  354. macro REQUIRES(DIRS[]) {
  355. SET_APPEND(REQUIRED_TRANSITIVE_PEERS $DIRS)
  356. }
  357. CHECK_DEPENDENT_DIRS_TYPES=
  358. CHECK_DEPENDENT_DIRS_RESTRICTIONS=
  359. ### @usage CHECK_DEPENDENT_DIRS(DENY|ALLOW_ONLY ([ALL|PEERDIRS|GLOB] dir)...)
  360. ###
  361. ### Specify project transitive dependencies constraints.
  362. ###
  363. ### @params:
  364. ### 1. DENY: current module can not depend on module from any specified directory neither directly nor transitively.
  365. ### 2. ALLOW_ONLY: current module can not depend on module from a dir not specified in the directory list neither directly nor transitively.
  366. ### 3. ALL: directory constraints following after this modifier are applied to both transitive PEERDIR dependencies and tool dependencies.
  367. ### 4. PEERDIRS: directory constraints following after this modifier are applied to transitive PEERDIR dependencies only.
  368. ### 5. GLOB: next directory constraint is an ANT glob pattern.
  369. ### 6. EXCEPT: next constraint is an exception for the rest of other rules.
  370. ###
  371. ### Directory constraints added before either ALL or PEERDIRS modifier is used are treated as ALL directory constraints.
  372. ###
  373. ### Note: Can be used multiple times on the same module all specified constraints will be checked.
  374. ### All macro invocation for the same module must use same constraints type (DENY or ALLOW_ONLY)
  375. macro CHECK_DEPENDENT_DIRS(TYPE, ALL?"UNUSED":"", PEERDIRS?"PEERDIRS":"ALL", RESTRICTIONS...) {
  376. SET_APPEND(CHECK_DEPENDENT_DIRS_RESTRICTIONS $PEERDIRS $RESTRICTIONS)
  377. SET_APPEND(CHECK_DEPENDENT_DIRS_TYPES $TYPE)
  378. }
  379. macro _RESOURCE_SEM(INPUTS[], KEYS[]) {
  380. SET(RESOURCE_OUTPUT ${hash:INPUTS}.cpp)
  381. .SEM=resources ${output;global:RESOURCE_OUTPUT} INPUTS ${input:INPUTS} KEYS $KEYS ${tool;hide:"tools/rescompiler/bin"}
  382. }
  383. # tag:built-in
  384. ### @usage: RESOURCE([FORCE_TEXT ][Src Key]* [- Key=Value]*) # built-in
  385. ### Add data (resources, random files, strings) to the program)
  386. ### 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.
  387. ### Alternative syntax with '- Key=Value' allows placing Value string as resource data into binary and make it accessible by Key.
  388. ###
  389. ### This is a simpler but less flexible option than ARCHIVE(), because in the case of ARCHIVE(), you have to use the data explicitly,
  390. ### and in the case of RESOURCE(), the data will fall through SRCS() or SRCS(GLOBAL) to binary linking.
  391. ###
  392. ### Use the FORCE_TEXT parameter to explicitly mark all Src files as text files: they will not be parsed unless used elsewhere.
  393. ###
  394. ### @example: https://wiki.yandex-team.ru/yatool/howtowriteyamakefiles/#a2ispolzujjtekomanduresource
  395. ###
  396. ### @example:
  397. ###
  398. ### LIBRARY()
  399. ### OWNER(user1)
  400. ###
  401. ### RESOURCE(
  402. ### path/to/file1 /key/in/program/1
  403. ### path/to/file2 /key2
  404. ### )
  405. ### END()
  406. ###
  407. macro RESOURCE(Args...) {
  408. PEERDIR(library/cpp/resource)
  409. }
  410. # tag:sanitize
  411. RUN_NO_SANITIZE=$YMAKE_PYTHON ${input:"build/scripts/run_tool.py"} --
  412. # tag:sanitize
  413. when ($IS_CROSS_SANITIZE) {
  414. RUN_NO_SANITIZE=
  415. }
  416. YIELD=$YMAKE_PYTHON ${input:"build/scripts/yield_line.py"} -- ${BINDIR}/__args
  417. XARGS=$YMAKE_PYTHON ${input:"build/scripts/xargs.py"} -- ${BINDIR}/__args
  418. WRITER_PY=$YMAKE_PYTHON ${input:"build/scripts/writer.py"} ${input;hide:"build/scripts/process_command_files.py"}
  419. FS_TOOLS=$YMAKE_PYTHON3 ${input:"build/scripts/fs_tools.py"} ${input;hide:"build/scripts/process_command_files.py"}
  420. FIX_MSVC_OUTPUT=${YMAKE_PYTHON} ${input:"build/scripts/fix_msvc_output.py"} ${input;hide:"build/scripts/process_command_files.py"}
  421. _PROCESS_WHOLE_ARCHIVE_SCRIPT=${input;hide:"build/scripts/process_command_files.py"} ${input;hide:"build/scripts/process_whole_archive_option.py"}
  422. COPY_CMD=$FS_TOOLS copy
  423. LINK_OR_COPY_CMD=$FS_TOOLS link_or_copy
  424. REMOVE_FILE=$FS_TOOLS remove
  425. MOVE_FILE=$FS_TOOLS rename
  426. # tag:allocator tag:windows-specific
  427. MSVC_DYNAMICBASE=/DYNAMICBASE
  428. when ($ALLOCATOR == "LF") {
  429. MSVC_DYNAMICBASE=/DYNAMICBASE:NO
  430. }
  431. # tag:sanitize
  432. SANITIZER_CFLAGS=
  433. # variables must be defined for all module types to make generate_mf.py work
  434. NEED_PLATFORM_PEERDIRS=yes
  435. PEERDIR_TEST_TOOL=yes
  436. ### @usage: _BARE_UNIT # internal
  437. ###
  438. ### The base of all modules describing default bare minimum for all modules.
  439. ### To avoid surprises, all buildable modules are better to be inherited from it or its descendants.
  440. module _BARE_UNIT {
  441. .EXTS=.*
  442. .CMD=TOUCH_UNIT
  443. .IGNORED=GO_PROTO_PLUGIN
  444. .NODE_TYPE=Bundle
  445. .PEERDIR_POLICY=as_include
  446. .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
  447. .FINAL_TARGET=no
  448. PEERDIR_TAGS=__EMPTY__
  449. PEERDIR+=$YMAKE_PYTHON3_PEERDIR
  450. when ($FATAL_ERROR_MESSAGE && $FATAL_ERROR_MODULE != "yes") {
  451. PEERDIR+=build/conf_fatal_error
  452. }
  453. DEFAULT(MODULE_VERSION)
  454. DEFAULT(MODULE_PREFIX)
  455. DEFAULT(MODULE_SUFFIX)
  456. }
  457. ### @usage: GEN_LIBRARY()
  458. ###
  459. ### Definition of a module that brings generated artefacts. This module can PEERDIRed
  460. ### from any module. The resulted module is empty and cleaned up during construction
  461. ### of the build graph.
  462. ###
  463. ### NOTE! SRCS macro is not supported for this library.
  464. module GEN_LIBRARY: _BARE_UNIT {
  465. .PROXY=yes
  466. .RESTRICTED=SRCS SRC
  467. .SEM=IGNORED
  468. # ENABLE(_FAKE_MODULE)
  469. SET(MODULE_SUFFIX .pkg.fake)
  470. }
  471. ### @usage: _BASE_UNIT # internal
  472. ###
  473. ### The base of all LIBRARY/PROGRAM modules describing common logic for all modules.
  474. ### To avoid surprises, all buildable modules are better to be inherited from it or its descendants.
  475. module _BASE_UNIT: _BARE_UNIT {
  476. .GLOBAL=_FBS_NAMESPACE_MAP
  477. PEERDIR_TAGS=CPP_PROTO CPP_FBS H_IDL PY2 PY2_NATIVE YQL_UDF_STATIC __EMPTY__ DLL_LIB
  478. 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}
  479. CPP_PROTO_OUTS+=${output;hide;norel;nopath;noext:File.pb.cc} ${output;main;hide;norel;nopath;noext:File.pb.h}
  480. CPP_PROTO_OUTS_SEM+=${output;main;hide;norel;nopath;noext:File.pb.h}
  481. CPP_EV_OUTS+=${output;hide;norel:File.pb.cc} ${output;hide;norel:File.pb.h}
  482. CPP_EV_OUTS_SEM+=${output;hide;norel:File.pb.h}
  483. when ($SWIG_LANG == "perl") {
  484. _SWIG_CMD=$_SWIG_PERL_CMD
  485. _SWIG_PEERDIR=contrib/tools/swig/Lib/perl5 build/platform/perl
  486. }
  487. elsewhen ($SWIG_LANG == "python") {
  488. _SWIG_CMD=$_SWIG_PYTHON_CMD
  489. _SWIG_PEERDIR=contrib/tools/swig/Lib/python
  490. }
  491. elsewhen ($SWIG_LANG == "jni_cpp") {
  492. _SWIG_CMD=$_SWIG_JNI_CPP_CMD
  493. _SWIG_PEERDIR=contrib/tools/swig/Lib/java $_SWIG_JNI_PEERDIR
  494. }
  495. elsewhen ($SWIG_LANG == "java") {
  496. _SWIG_CMD=$_SWIG_JNI_CMD
  497. _SWIG_PEERDIR=contrib/tools/swig/Lib/java $_SWIG_JNI_PEERDIR
  498. }
  499. when ($PY_PROTOS_FOR == "yes") {
  500. _EVLOG_CMDLINE=$_PY_EVLOG_CMDLINE
  501. _PROTO_CMDLINE=$_PY_PROTO_CMDLINE
  502. }
  503. otherwise {
  504. _EVLOG_CMDLINE=$_CPP_EVLOG_CMDLINE
  505. _FBS_CMDLINE=$_CPP_FLATC_CMDLINE
  506. when ($BUILD_PROTO_AS_EVLOG == "yes") {
  507. _PROTO_CMDLINE=$_CPP_PROTO_EVLOG_CMDLINE
  508. }
  509. otherwise {
  510. _PROTO_CMDLINE=$_CPP_PROTO_CMDLINE
  511. }
  512. when ($USE_VANILLA_PROTOC == "yes") {
  513. PROTOC=${tool:"contrib/tools/protoc_std"}
  514. PROTOC_STYLEGUIDE_OUT=
  515. PROTOC_PLUGIN_STYLEGUIDE=
  516. PROTOBUF_PATH=${ARCADIA_ROOT}/contrib/libs/protobuf_std
  517. _PROTO_CMDLINE=$_CPP_VANILLA_PROTO_CMDLINE
  518. }
  519. when ($PROTOC_TRANSITIVE_HEADERS == "no") {
  520. CPP_PROTO_PLUGINS=transitive_pb_h=false:${CPP_PROTO_PLUGINS}
  521. }
  522. }
  523. SANITIZER_DEFINED=no
  524. when ($SANITIZER_TYPE && $SANITIZER_TYPE != "no") {
  525. CFLAGS+=-fsanitize=$SANITIZER_TYPE -D${SANITIZER_TYPE}_sanitizer_enabled $SANITIZER_CFLAGS -fno-omit-frame-pointer
  526. LDFLAGS+=-fsanitize=$SANITIZER_TYPE
  527. SANITIZER_DEFINED=yes
  528. when ($CLANG) {
  529. CFLAGS+=-fsanitize-blacklist=${input:"build/sanitize-blacklist.txt"} -fno-sanitize-link-runtime
  530. LDFLAGS+=-fsanitize-blacklist=${input:"build/sanitize-blacklist.txt"} -fno-sanitize-link-runtime
  531. }
  532. }
  533. when ($SANITIZER_TYPE && $SANITIZER_TYPE == "memory") {
  534. CFLAGS+=-fno-sanitize-memory-use-after-dtor -Wno-unused-command-line-argument
  535. }
  536. when ($SANITIZE_COVERAGE && $SANITIZE_COVERAGE != "no") {
  537. CFLAGS+=-fsanitize-coverage=$SANITIZE_COVERAGE
  538. LDFLAGS+=-fsanitize-coverage=$SANITIZE_COVERAGE
  539. }
  540. POPULATE_CPP_COVERAGE_FLAGS()
  541. when ($NLG_COVERAGE && $NLG_COVERAGE != "no") {
  542. CFLAGS+=-DNLG_COVERAGE
  543. }
  544. when ($GCC) {
  545. select ($SANITIZER_TYPE) {
  546. "address" ? {
  547. LDFLAGS+=-static-libasan
  548. }
  549. "undefined" ? {
  550. LDFLAGS+=-static-libubsan
  551. }
  552. "thread" ? {
  553. PIE=yes
  554. LDFLAGS+=-static-libtsan
  555. }
  556. }
  557. }
  558. when ($HARDENING == "yes") {
  559. when ($CLANG) {
  560. CFLAGS+=-fstack-protector-all -D_hardening_enabled_
  561. LDFLAGS+=-z relro -z now -z noexecstack
  562. PIE=yes
  563. }
  564. }
  565. when ($USE_LTO == "yes") {
  566. when ($GCC) {
  567. CFLAGS+=-flto -fno-fat-lto-objects
  568. LDFLAGS+=-flto
  569. NO_LTO_CFLAGS=-fno-lto
  570. }
  571. when ($CLANG) {
  572. CFLAGS+=-flto
  573. LDFLAGS+=-flto
  574. NO_LTO_CFLAGS=-fno-lto
  575. }
  576. }
  577. when ($USE_THINLTO == "yes") {
  578. when ($GCC) {
  579. CFLAGS+=-flto=thin
  580. LDFLAGS+=-flto=thin
  581. NO_LTO_CFLAGS=-fno-lto
  582. }
  583. when ($CLANG) {
  584. CFLAGS+=-flto=thin
  585. LDFLAGS+=-flto=thin
  586. NO_LTO_CFLAGS=-fno-lto
  587. }
  588. }
  589. when ($CLANG) {
  590. when ($PGO_ADD == "yes") {
  591. CFLAGS+=-fprofile-instr-generate
  592. LDFLAGS+=-fprofile-instr-generate
  593. }
  594. when ($PGO_PATH) {
  595. CFLAGS+=-fprofile-instr-use=$PGO_PATH -Wno-profile-instr-unprofiled -Wno-profile-instr-out-of-date
  596. LDFLAGS+=-fprofile-instr-use=$PGO_PATH
  597. }
  598. }
  599. when ($COMPILER_PLATFORM && $NEED_PLATFORM_PEERDIRS == "yes") {
  600. PEERDIR+=$COMPILER_PLATFORM
  601. }
  602. when ($OS_LINUX && $NEED_PLATFORM_PEERDIRS == "yes") {
  603. PEERDIR+=contrib/libs/linux-headers
  604. }
  605. # Adding PEERDIR from trigger doesn't always work. In this case it
  606. # cause troubles in contrib/libs/libc_compat/ubuntu_14 under musl
  607. # Workaround this issue by setting variable with PEERDIR in trigger
  608. # and then adding PEERDIR to it's value unconditionally.
  609. when ($USE_UBUNTU_COMPATIBILITY == "yes" && $NEED_PLATFORM_PEERDIRS == "yes") {
  610. _UBUNTU_COMPAT_PEERDIR=contrib/libs/libc_compat/ubuntu_14
  611. }
  612. otherwise {
  613. _UBUNTU_COMPAT_PEERDIR=
  614. }
  615. PEERDIR+=$_UBUNTU_COMPAT_PEERDIR
  616. when ($NORUNTIME != "yes") {
  617. PEERDIR+=contrib/libs/cxxsupp
  618. when ($MAPSMOBI_BUILD_TARGET == "yes") {
  619. PEERDIR+=build/platform/mapkit
  620. }
  621. }
  622. when ($NOUTIL != "yes") {
  623. PEERDIR+=util
  624. }
  625. when ($MUSL == "yes") {
  626. CFLAGS += -D_musl_
  627. LINK_DYN_LIB_FLAGS += --musl
  628. LINK_SCRIPT_EXE_FLAGS += --musl
  629. PEERDIR+=contrib/libs/musl/include
  630. }
  631. # g++ has proxy C-headers which are incompatible with libc++ proxy C-headers.
  632. # The same problem exists for clang toolchain. On the other hand, the problem
  633. # doesn't affect cl since it has united C/C++ library and doesn't need
  634. # proxy C-headers.
  635. # Disable all C++ headers including proxy C-headers when we use libc++.
  636. when ($USE_INTERNAL_STL == "yes" && $MSVC != "yes") {
  637. CXXFLAGS += -nostdinc++
  638. }
  639. otherwise {
  640. CFLAGS += -DUSE_STL_SYSTEM
  641. }
  642. when ($CODENAVIGATION && $NOCODENAVIGATION != "yes") {
  643. PEERDIR += build/external_resources/codenavigation
  644. }
  645. when ($CYTHON_COVERAGE && $CYTHON_COVERAGE == "yes") {
  646. CFLAGS+=-DCYTHON_TRACE=1 -DCYTHON_TRACE_NOGIL=1
  647. }
  648. DEFAULT(USE_SSE4 yes)
  649. when ($NOSSE != "yes") {
  650. CFLAGS+=$SSE_CFLAGS
  651. C_DEFINES+=$SSE_DEFINES
  652. when ($USE_SSE4 == "yes") {
  653. CFLAGS+=$SSE4_CFLAGS
  654. C_DEFINES+=$SSE4_DEFINES
  655. }
  656. }
  657. elsewhen ($MSVC != "yes") {
  658. CFLAGS += -mno-sse
  659. }
  660. POPULATE_CPP_COVERAGE_FLAGS()
  661. _REGISTER_NO_CHECK_IMPORTS()
  662. DEFAULT(PACKAGE_PREFIX_ARGS)
  663. DEFAULT(SWIG_LANG python)
  664. DEFAULT(GP_FLAGS -CtTLANSI-C -Dk* -c)
  665. when ($NEED_BINUTILS_PEERDIR && $BINUTILS_USED && $NEED_PLATFORM_PEERDIRS == "yes") {
  666. PEERDIR+=build/platform/binutils
  667. }
  668. when ($TIDY_ENABLED == "yes") {
  669. PEERDIR+=build/platform/clang/clang-tidy
  670. }
  671. ENABLE(USE_YASM_ASSEMBLER)
  672. }
  673. _LINKER_ID=
  674. # GCC does not support -fuse-ld with an executable path,
  675. # only -fuse-ld=gold or -fuse-ld=lld.
  676. when ($_LINKER_ID != "" && $_DEFAULT_LINKER_ID != "" && $CLANG == "yes" && $NEED_PLATFORM_PEERDIRS == "yes") {
  677. when ($_LINKER_ID in [ "gold", "lld" ]) {
  678. PEERDIR+=build/platform/${_LINKER_ID}
  679. }
  680. }
  681. macro _USE_LINKER_IMPL(LINKER_ID...) {
  682. SET(_LINKER_ID $LINKER_ID)
  683. }
  684. macro _USE_LINKER() {
  685. _USE_LINKER_IMPL($_DEFAULT_LINKER_ID)
  686. }
  687. ### @usage: USE_LINKER_GOLD()
  688. ### Use gold linker for a program. This doesn't work in libraries
  689. macro USE_LINKER_GOLD() {
  690. _USE_LINKER_IMPL(gold)
  691. }
  692. COMMON_LINK_SETTINGS=
  693. LINK_ADDITIONAL_SECTIONS=
  694. LINK_ADDITIONAL_SECTIONS_COMMAND=
  695. when ($COMMON_LINK_SETTINGS == "yes") {
  696. when ($_LINKER_ID == "lld" && ($OS_LINUX == "yes" || $OS_ANDROID == "yes")) {
  697. LDFLAGS += -Wl,--gdb-index
  698. }
  699. when ($EMBED_LINKER_CREF == "yes") {
  700. LDFLAGS+=-Wl,--cref ${tmp;stdout;pre=$MODULE_PREFIX;suf=.ldcref:REALPRJNAME} -Wl,--no-demangle
  701. LINK_ADDITIONAL_SECTIONS+=--add-section=.ya.linker_cref=${tmp;pre=$MODULE_PREFIX;suf=.ldcref:REALPRJNAME}
  702. }
  703. elsewhen ($DUMP_LINKER_CREF == "yes") {
  704. LDFLAGS+=-Wl,--cref ${output;stdout;pre=$MODULE_PREFIX;suf=.ldcref:REALPRJNAME} -Wl,--no-demangle
  705. }
  706. when ($EMBED_LINKER_MAP == "yes") {
  707. LDFLAGS+=-Wl,-Map=${tmp;pre=$MODULE_PREFIX;suf=.map.$_LINKER_ID:REALPRJNAME}
  708. LINK_ADDITIONAL_SECTIONS+=--add-section=.ya.linker_map.${_LINKER_ID}=${tmp;pre=$MODULE_PREFIX;suf=.map.$_LINKER_ID:REALPRJNAME}
  709. }
  710. elsewhen ($DUMP_LINKER_MAP == "yes") {
  711. LDFLAGS+=-Wl,-Map=${output;rootrel;pre=$MODULE_PREFIX;suf=.map.$_LINKER_ID:REALPRJNAME}
  712. }
  713. when ($USE_MKL == "yes") {
  714. NOPLATFORM=yes
  715. }
  716. when ($AUTOCHECK == "yes" && $OS_LINUX == "yes") {
  717. PEERDIR+=contrib/libs/libeatmydata
  718. # We can not use LICENSE_RESTRICTION_EXCEPTIONS() macro inside a trigger.
  719. # Duplicate its implementation here
  720. MODULE_LICENSES_RESTRICTION_EXCEPTIONS+=contrib/libs/libeatmydata
  721. }
  722. when ($USE_ARCADIA_LIBM == "yes") {
  723. PEERDIR+=contrib/libs/libm
  724. }
  725. when ($USE_ARCADIA_LIBM == "no") {
  726. C_SYSTEM_LIBRARIES+=-lm
  727. }
  728. when (($MUSL != "yes" && $WITH_VALGRIND == "yes") || $SANITIZER_DEFINED == "yes") {
  729. 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" ]) {
  730. PEERDIR+=library/cpp/malloc/system
  731. }
  732. }
  733. otherwise {
  734. select ($ALLOCATOR) {
  735. "MIM" ? {
  736. PEERDIR+=library/cpp/malloc/mimalloc
  737. }
  738. "HU" ? {
  739. PEERDIR+=library/cpp/malloc/hu
  740. }
  741. "PROFILED_HU" ? {
  742. PEERDIR+=library/cpp/malloc/profiled_hu
  743. }
  744. "THREAD_PROFILED_HU" ? {
  745. PEERDIR+=library/cpp/malloc/thread_profiled_hu
  746. }
  747. "TCMALLOC_256K" ? {
  748. PEERDIR+=library/cpp/malloc/tcmalloc
  749. PEERDIR+=contrib/libs/tcmalloc
  750. }
  751. "TCMALLOC_SMALL_BUT_SLOW" ? {
  752. PEERDIR+=library/cpp/malloc/tcmalloc
  753. PEERDIR+=contrib/libs/tcmalloc/small_but_slow
  754. }
  755. "TCMALLOC_NUMA_256K" ? {
  756. PEERDIR+=library/cpp/malloc/tcmalloc
  757. PEERDIR+=contrib/libs/tcmalloc/numa_256k
  758. }
  759. "TCMALLOC_NUMA_LARGE_PAGES" ? {
  760. PEERDIR+=library/cpp/malloc/tcmalloc
  761. PEERDIR+=contrib/libs/tcmalloc/numa_large_pages
  762. }
  763. "TCMALLOC" ? {
  764. PEERDIR+=library/cpp/malloc/tcmalloc
  765. PEERDIR+=contrib/libs/tcmalloc/default
  766. }
  767. "TCMALLOC_TC" ? {
  768. PEERDIR+=library/cpp/malloc/tcmalloc
  769. PEERDIR+=contrib/libs/tcmalloc/no_percpu_cache
  770. }
  771. "GOOGLE" ? {
  772. PEERDIR+=library/cpp/malloc/galloc
  773. }
  774. "J" ? {
  775. when ($WIN32 == "yes") {
  776. PEERDIR+=library/cpp/malloc/system
  777. }
  778. otherwise {
  779. PEERDIR+=library/cpp/malloc/jemalloc
  780. }
  781. }
  782. "LF" ? {
  783. PEERDIR+=library/cpp/lfalloc
  784. }
  785. "LF_YT" ? {
  786. PEERDIR+=library/cpp/lfalloc/yt
  787. }
  788. "LF_DBG" ? {
  789. PEERDIR+=library/cpp/lfalloc/dbg
  790. }
  791. "B" ? {
  792. PEERDIR+=library/cpp/balloc
  793. }
  794. "BM" ? {
  795. PEERDIR+=library/cpp/balloc_market
  796. }
  797. "C" ? {
  798. PEERDIR+=library/cpp/malloc/calloc
  799. }
  800. "LOCKLESS" ? {
  801. PEERDIR+=library/cpp/malloc/lockless
  802. }
  803. "YT" ? {
  804. PEERDIR+=library/cpp/ytalloc/impl
  805. }
  806. "YT_TCMALLOC" ? {
  807. PEERDIR+=library/cpp/malloc/tcmalloc
  808. PEERDIR+=contrib/libs/yt_tcmalloc/default
  809. }
  810. "YT_TCMALLOC_256K" ? {
  811. PEERDIR+=library/cpp/malloc/tcmalloc
  812. PEERDIR+=contrib/libs/yt_tcmalloc
  813. }
  814. }
  815. }
  816. when ($ALLOCATOR == "SYSTEM") {
  817. PEERDIR+=library/cpp/malloc/system
  818. }
  819. when ($WERROR != "no") {
  820. when ($WERROR_MODE == "all" || ($WERROR_MODE == "compiler_specific" && $WERROR == "yes")) {
  821. C_WARNING_OPTS += $WERROR_FLAG
  822. }
  823. }
  824. when ($ICC == "yes") {
  825. PEERDIR+=contrib/libs/intel/core
  826. }
  827. when ($WITH_VALGRIND == "yes") {
  828. PEERDIR+=contrib/libs/valgrind
  829. # https://st.yandex-team.ru/DTCC-122
  830. CFLAGS+=-fdebug-default-version=4
  831. }
  832. }
  833. when ($EMBED_LINKER_MAP == "yes" || $EMBED_LINKER_CREF == "yes") {
  834. LINK_ADDITIONAL_SECTIONS_COMMAND+= \
  835. $OBJCOPY_TOOL $LINK_ADDITIONAL_SECTIONS $TARGET
  836. }
  837. _SO_EXT_FILTER=${ext=.so:PEERS} ${hide;late_out;nopath;ext=.so;pre=$BINDIR/:PEERS}
  838. when ($OS_WINDOWS == "yes") {
  839. _SO_EXT_FILTER=${ext=.dll:PEERS} ${hide;late_out;nopath;ext=.dll;pre=$BINDIR/:PEERS}
  840. }
  841. elsewhen ($OS_DARWIN == "yes" || $OS_IOS == "yes") {
  842. _SO_EXT_FILTER=${ext=.dylib:PEERS} ${hide;late_out;nopath;ext=.dylib;pre=$BINDIR/:PEERS}
  843. }
  844. LINK_OR_COPY_SO_CMD=
  845. RPATH_GLOBAL=
  846. when ($SO_OUTPUTS == "yes") {
  847. LINK_OR_COPY_SO_CMD=$FS_TOOLS link_or_copy_to_dir --no-check $_SO_EXT_FILTER ${BINDIR}
  848. LDFLAGS+=$RPATH_GLOBAL
  849. }
  850. # tag:restricted tag:DLL
  851. ### $usage: WITH_DYNAMIC_LIBS() # restricted
  852. ###
  853. ### Include dynamic libraries as extra PROGRAM/DLL outputs
  854. macro WITH_DYNAMIC_LIBS() {
  855. ENABLE(SO_OUTPUTS)
  856. }
  857. # tag:internal
  858. ### $usage: REAL_LINK_EXE_IMPL(peers...) # internal
  859. macro REAL_LINK_EXE_IMPL(WHOLE_ARCHIVE_PEERS...) {
  860. .CMD=$REAL_LINK_EXE_CMDLINE && $LINK_OR_COPY_SO_CMD
  861. }
  862. # tag:internal
  863. ### $usage: REAL_LINK_EXEC_DYN_LIB_IMPL(peers...) # internal
  864. macro REAL_LINK_EXEC_DYN_LIB_IMPL(WHOLE_ARCHIVE_PEERS...) {
  865. .CMD=$REAL_LINK_EXEC_DYN_LIB_CMDLINE
  866. }
  867. # tag:internal
  868. ### $usage: REAL_LINK_DYN_LIB_IMPL(peers...) # internal
  869. macro REAL_LINK_DYN_LIB_IMPL(WHOLE_ARCHIVE_PEERS...) {
  870. .CMD=$REAL_LINK_DYN_LIB_CMDLINE && $LINK_OR_COPY_SO_CMD
  871. }
  872. # tag:internal
  873. ### $usage: LINK_EXE_IMPL(peers...) # internal
  874. macro LINK_EXE_IMPL(WHOLE_ARCHIVE_PEERS...) {
  875. .CMD=$LINK_EXE_CMDLINE && $LINK_OR_COPY_SO_CMD
  876. }
  877. # tag:internal
  878. ### $usage: LINK_EXEC_DYN_LIB_IMPL(peers...) # internal
  879. macro LINK_EXEC_DYN_LIB_IMPL(WHOLE_ARCHIVE_PEERS...) {
  880. .CMD=$LINK_EXEC_DYN_LIB_CMDLINE
  881. }
  882. # tag:internal
  883. ### @usage: _LINK_UNIT # internal
  884. ###
  885. ### The base of all linkable modules: programs, DLLs etc. Describes common linking logic.
  886. module _LINK_UNIT: _BASE_UNIT {
  887. .EXTS=.o .obj .supp .tidyjson .ld
  888. .CMD=LINK_EXE
  889. .ALLOWED=EXTRALIBS OBJADDE_GLOBAL RESOURCE_FILES
  890. .NODE_TYPE=Program
  891. .PEERDIR_POLICY=as_build_from
  892. .FINAL_TARGET=yes
  893. .DEFAULT_NAME_GENERATOR=DirName
  894. .ARGS_PARSER=Base
  895. DEFAULT(ALLOCATOR $DEFAULT_ALLOCATOR)
  896. _USE_LINKER()
  897. #link with libunwind manually
  898. when ($DARWIN == "yes" && $NOPLATFORM != "yes") {
  899. PEERDIR += contrib/libs/cxxsupp
  900. }
  901. when ($NEED_PROFILE_RUNTIME == "yes") {
  902. LDFLAGS+=-resource-dir=contrib/libs/clang-rt
  903. PEERDIR+=contrib/libs/clang${CLANG_VER}-rt/lib/profile
  904. }
  905. when ($USE_LIBCXXRT == "yes") {
  906. PEERDIR += contrib/libs/cxxsupp/libcxxrt
  907. }
  908. when ($USE_DYNAMIC_CUDA == "yes") {
  909. LINK_DYN_LIB_FLAGS += --dynamic-cuda
  910. LINK_SCRIPT_EXE_FLAGS += --dynamic-cuda
  911. }
  912. when ($OPENSOURCE == "yes" && $AUTOCHECK == "yes") {
  913. # FIXME: Replace AUTOCHECK == yes with _not a host platform_ check after YMAKE-218
  914. MODULE_LICENSES_RESTRICTION_TYPES = ALLOW_ONLY
  915. MODULE_LICENSES_RESTRICTIONS = SERVICE REQUIRE_CITATION REQUIRE_MODIFICATIONS_DISCLOSURE
  916. }
  917. when ($OS_IOS == "yes" || $OS_ANDROID == "yes" || $MAPSMOBI_BUILD_TARGET == "yes") {
  918. MODULE_LICENSES_RESTRICTION_TYPES = ALLOW_ONLY
  919. MODULE_LICENSES_RESTRICTIONS = SERVICE REQUIRE_CITATION
  920. }
  921. ENABLE(COMMON_LINK_SETTINGS)
  922. CHECK_PROVIDES()
  923. }
  924. MODULE_TYPE=UNKNOWN
  925. macro ADD_CLANG_TIDY() {
  926. ADD_YTEST($MODULE_PREFIX$REALPRJNAME clang_tidy)
  927. when ($TIDY_ENABLED == "yes") {
  928. _MAKEFILE_INCLUDE_LIKE_DEPS+=${ARCADIA_ROOT}/build/yandex_specific/config/clang_tidy/tidy_project_map.json
  929. _MAKEFILE_INCLUDE_LIKE_DEPS+=${ARCADIA_ROOT}/build/yandex_specific/config/clang_tidy/tidy_default_map.json
  930. }
  931. }
  932. # tag:internal
  933. ### @usage: _BASE_PROGRAM # internal
  934. ###
  935. ### The base of all programs. It adds dependencies to make final artefact complete and runnable.
  936. module _BASE_PROGRAM: _LINK_UNIT {
  937. .SYMLINK_POLICY=EXE
  938. .ALLOWED=INDUCED_DEPS WHOLE_ARCHIVE
  939. .GLOBAL=LDFLAGS _WHOLE_ARCHIVE_LIBS_VALUE RPATH OBJADDE_LIB
  940. SET(MODULE_TYPE PROGRAM)
  941. SET(MODULE_LANG CPP)
  942. FORCE_COVERAGE_ENABLED=yes
  943. when ($OS_IOS == "yes") {
  944. EXTS+=.ios.interface
  945. }
  946. when ($WIN32 == "yes" || $OS_CYGWIN == "yes") {
  947. MODULE_SUFFIX=.exe
  948. }
  949. when ($TIDY_ENABLED == "yes") {
  950. MODULE_SUFFIX=.tidyjson
  951. }
  952. when ($MSVC != "yes" && $NOPLATFORM != "yes" && $WITH_VALGRIND != "yes" && $USE_ASMLIB != "no" && $MIC_ARCH != "yes" && $PIC != "yes" && $PIE != "yes") {
  953. when ($OS_LINUX == "yes" && $ARCH_X86_64 == "yes" && $MUSL != "yes" && $SANITIZER_DEFINED != "yes" && $USE_THINLTO != "yes") {
  954. PEERDIR+=contrib/libs/glibcasm
  955. }
  956. otherwise {
  957. PEERDIR+=contrib/libs/asmlib
  958. }
  959. }
  960. when ($MUSL == "yes") {
  961. when ($MUSL_LITE == "yes") {
  962. PEERDIR += contrib/libs/musl
  963. }
  964. otherwise {
  965. PEERDIR += contrib/libs/musl/full
  966. }
  967. }
  968. DEFAULT(CPU_CHECK yes)
  969. when ($USE_SSE4 != "yes" || $NOUTIL == "yes" || $ALLOCATOR == "FAKE") {
  970. CPU_CHECK = no
  971. }
  972. when ($CPU_CHECK == "yes") {
  973. PEERDIR += library/cpp/cpuid_check
  974. }
  975. when ($USE_ARC_PROFILE == "yes" && $NOUTIL != "yes") {
  976. PEERDIR += library/cpp/execprofile/autostart
  977. }
  978. when ($SANITIZER_TYPE && $SANITIZER_TYPE != "no") {
  979. PEERDIR += contrib/libs/cxxsupp/libsan
  980. when ($CLANG) {
  981. select ($TARGET_PLATFORM) {
  982. "LINUX" ? {
  983. PEERDIR += library/cpp/sanitizer/${SANITIZER_TYPE}/static
  984. }
  985. "DARWIN" ? {
  986. # Memory sanitizer is not supported for darwin platform.
  987. # https://clang.llvm.org/docs/MemorySanitizer.html#supported-platforms
  988. when ($SANITIZER_TYPE != "memory") {
  989. PEERDIR += library/cpp/sanitizer/${SANITIZER_TYPE}/dynamic
  990. }
  991. }
  992. default ? {
  993. FATAL_ERROR_MESSAGE+=Unsupported platform for sanitizer
  994. }
  995. }
  996. }
  997. }
  998. when ($CLANG_COVERAGE && $CLANG_COVERAGE != "no") {
  999. PEERDIR+=library/cpp/testing/dump_clang_coverage
  1000. }
  1001. when ($IDE_MSVS == "yes") {
  1002. PEERDIR+=build/scripts/c_templates
  1003. }
  1004. when ($_CUSTOM_LINK_STEP_SCRIPT) {
  1005. LINK_SCRIPT_EXE_FLAGS+=--python=$YMAKE_PYTHON --custom-step=${input:_CUSTOM_LINK_STEP_SCRIPT}
  1006. }
  1007. }
  1008. 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"}
  1009. CPP_PROGRAM_SEM=add_executable $MODDIR $CMAKE_TARGET_NAME ${hide:TARGET} ${hide:AUTO_INPUT} $CMAKE_TARGET_ARTEFACT_RENAME_RULES \
  1010. && ${VCS_INFO_SEM} \
  1011. && target_link_options PRIVATE $LDFLAGS_GLOBAL_RAW $LDFLAGS $OBJADDE_LIB $OBJADDE_LIB_GLOBAL $OBJADDE \
  1012. && target_include_directories PRIVATE $_C__INCLUDE_OWNED \
  1013. && target_compile_options PRIVATE $USER_CFLAGS $USER_CXXFLAGS $_SEM_EXTRA_CXX_FLAGS \
  1014. && target_compile_options PRIVATE $USER_CFLAGS_GLOBAL_RAW $USER_CXXFLAGS_GLOBAL_RAW
  1015. ### @usage: PROGRAM([progname])
  1016. ###
  1017. ### Regular program module.
  1018. ### If name is not specified it will be generated from the name of the containing project directory.
  1019. module PROGRAM: _BASE_PROGRAM {
  1020. .SEM=CPP_PROGRAM_SEM
  1021. .ALIASES=EXTRALIBS=PY_EXTRALIBS
  1022. ADD_YTEST($MODULE_PREFIX$REALPRJNAME coverage.extractor)
  1023. ADD_CLANG_TIDY()
  1024. _DONT_REQUIRE_LICENSE()
  1025. }
  1026. ### @usage: EXPORTS_SCRIPT(exports_file)
  1027. ###
  1028. ### Specify exports script within PROGRAM, DLL and DLL-derived modules.
  1029. ### This accepts 2 kind of files: .exports with <lang symbol> pairs and JSON-line .symlist files.
  1030. ### The other option use EXPORTS parameter of the DLL module itself.
  1031. ###
  1032. ### @see: [DLL](#module_DLL)
  1033. macro EXPORTS_SCRIPT(Arg) {
  1034. SET(EXPORTS_FILE $Arg)
  1035. }
  1036. ### @usage: NO_EXPORT_DYNAMIC_SYMBOLS()
  1037. ###
  1038. ### Disable exporting all non-hidden symbols as dynamic when linking a PROGRAM.
  1039. macro NO_EXPORT_DYNAMIC_SYMBOLS() {
  1040. ENABLE(NO_EXPORT_DYNAMIC_SYMBOLS)
  1041. }
  1042. ### @usage: EXPORT_ALL_DYNAMIC_SYMBOLS()
  1043. ###
  1044. ### Export all non-hidden symbols as dynamic when linking a PROGRAM.
  1045. macro EXPORT_ALL_DYNAMIC_SYMBOLS() {
  1046. # Dummy: default behaviour
  1047. ENABLE(EXPORT_ALL_DYNAMIC_SYMBOLS)
  1048. }
  1049. ### @usage: USE_DYNAMIC_CUDA()
  1050. ###
  1051. ### Enable linking of PROGRAM with dynamic CUDA. By default CUDA uses static linking
  1052. macro USE_DYNAMIC_CUDA() {
  1053. LDFLAGS(-Wl,-rpath,$ORIGIN)
  1054. ENABLE(USE_DYNAMIC_CUDA)
  1055. }
  1056. ### @usage: CUSTOM_LINK_STEP_SCRIPT(name)
  1057. ###
  1058. ### Specifies name of a script for custom link step. The scripts
  1059. ### should be placed in the build/scripts directory and are subject to
  1060. ### review by devtools@.
  1061. macro CUSTOM_LINK_STEP_SCRIPT(Name) {
  1062. SET(_CUSTOM_LINK_STEP_SCRIPT build/scripts/$Name)
  1063. }
  1064. ### @usage: _BASE_UNITTEST # internal
  1065. ###
  1066. ### Module with base logic for all unit-test modules: it makes code runnable as unit-test by Arcadia testing machinery.
  1067. module _BASE_UNITTEST: _BASE_PROGRAM {
  1068. .FINAL_TARGET=no
  1069. .NODE_TYPE=Program
  1070. .ALLOWED=YT_SPEC
  1071. when ($UT_SKIP_EXCEPTIONS == "yes") {
  1072. C_DEFINES+=-DUT_SKIP_EXCEPTIONS
  1073. }
  1074. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS canondata/result.json)
  1075. # Assume that no code may depend on unit test output and thus
  1076. # do not mandate license markup in such modules.
  1077. _DONT_REQUIRE_LICENSE()
  1078. }
  1079. _TEST_SPLIT_FACTOR_SEM=1
  1080. _TEST_TIMEOUT_SEM=
  1081. _TEST_PARTITION_SEM=
  1082. UNITTEST_SEM=$CPP_PROGRAM_SEM \
  1083. && set_property TARGET $REALPRJNAME PROPERTY SPLIT_FACTOR $_TEST_SPLIT_FACTOR_SEM \
  1084. $_TEST_PARTITION_SEM \
  1085. && add_yunittest NAME $REALPRJNAME TEST_TARGET $REALPRJNAME TEST_ARG --print-before-suite --print-before-test --fork-tests --print-times --show-fails \
  1086. && set_yunittest_property TEST $REALPRJNAME PROPERTY LABELS $TEST_SIZE_NAME $FILTER_ONLY_TEST_TAGS \
  1087. && add_ytest_requirements $REALPRJNAME $DEFAULT_REQUIREMENTS $TEST_REQUIREMENTS_VALUE \
  1088. $_TEST_TIMEOUT_SEM
  1089. # tag:test
  1090. ### @usage: UNITTEST([name])
  1091. ###
  1092. ### Unit test module based on library/cpp/testing/unittest.
  1093. ### It is recommended not to specify the name.
  1094. ###
  1095. ### Documentation: https://wiki.yandex-team.ru/yatool/test/#opisanievya.make1
  1096. module UNITTEST: _BASE_UNITTEST {
  1097. .SEM=UNITTEST_SEM
  1098. .DEFAULT_NAME_GENERATOR=FullPath
  1099. .ARGS_PARSER=Base
  1100. PEERDIR(library/cpp/testing/unittest_main)
  1101. ADD_YTEST($MODULE_PREFIX$REALPRJNAME unittest.py)
  1102. when ($TEST_FORK_MODE != "none") {
  1103. when ($TEST_SPLIT_FACTOR) {
  1104. _TEST_SPLIT_FACTOR_SEM=$TEST_SPLIT_FACTOR
  1105. }
  1106. otherwise {
  1107. _TEST_SPLIT_FACTOR_SEM=10
  1108. }
  1109. when ($TEST_PARTITION == "MODULO") {
  1110. _TEST_PARTITION_SEM=&& set_property TARGET $REALPRJNAME PROPERTY SPLIT_TYPE $TEST_PARTITION \
  1111. }
  1112. }
  1113. when ($TEST_TIMEOUT) {
  1114. _TEST_TIMEOUT_SEM=&& set_yunittest_property TEST $REALPRJNAME PROPERTY TIMEOUT $TEST_TIMEOUT
  1115. }
  1116. }
  1117. # tag:yt-specific tag:test
  1118. ### @usage: YT_UNITTEST([name])
  1119. ###
  1120. ### YT Unit test module based on library/cpp/testing/unittest with NYT::Initialize hook
  1121. module YT_UNITTEST: _BASE_UNITTEST {
  1122. PEERDIR(library/cpp/testing/unittest_main mapreduce/yt/tests/yt_initialize_hook)
  1123. ADD_YTEST($MODULE_PREFIX$REALPRJNAME unittest.py)
  1124. }
  1125. # tag:test
  1126. ### @usage: UNITTEST_WITH_CUSTOM_ENTRY_POINT([name])
  1127. ###
  1128. ### Generic unit test module.
  1129. module UNITTEST_WITH_CUSTOM_ENTRY_POINT: _BASE_UNITTEST {
  1130. ADD_YTEST($MODULE_PREFIX$REALPRJNAME unittest.py)
  1131. }
  1132. GTEST_SEM=$CPP_PROGRAM_SEM \
  1133. && add_test NAME $REALPRJNAME COMMAND $REALPRJNAME \
  1134. && set_property TEST $REALPRJNAME PROPERTY LABELS $TEST_SIZE_NAME $FILTER_ONLY_TEST_TAGS \
  1135. && add_test_requirements $REALPRJNAME $DEFAULT_REQUIREMENTS $TEST_REQUIREMENTS_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/cpp_test
  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. when ($USE_ARCADIA_LIBM == "yes") {
  1555. PEERDIR+=contrib/libs/libm
  1556. }
  1557. }
  1558. CPP_LIBRARY_INDUCED_SEM_PROPERTY=consumer_link_library
  1559. CPP_LIBRARY_SEM=add_library ${MODDIR} $CMAKE_TARGET_NAME ${hide:TARGET} ${hide:AUTO_INPUT} $CMAKE_TARGET_ARTEFACT_RENAME_RULES \
  1560. && library_fake_marker FAKE_MODULE ${FAKE_MODULE} \
  1561. && ${CPP_LIBRARY_INDUCED_SEM_PROPERTY} PUBLIC $CMAKE_LINK_TARGET \
  1562. && target_include_directories PUBLIC $_C__INCLUDE_GLOBAL \
  1563. && target_include_directories PRIVATE $_C__INCLUDE_OWNED \
  1564. && target_compile_options PRIVATE $USER_CFLAGS $USER_CXXFLAGS $_SEM_EXTRA_CXX_FLAGS \
  1565. && target_compile_options PUBLIC $USER_CFLAGS_GLOBAL_RAW $USER_CXXFLAGS_GLOBAL_RAW \
  1566. && target_link_options INTERFACE $LDFLAGS_GLOBAL_RAW \
  1567. && add_language C && add_language CXX
  1568. CPP_OBJ_LIBRARY_SEM=add_global_library_for ${MODDIR} ${suf=.global:CMAKE_TARGET_NAME} $CMAKE_TARGET_NAME ${hide:GLOBAL_TARGET} ${hide:AUTO_INPUT} \
  1569. && target_include_directories PUBLIC $_C__INCLUDE_GLOBAL \
  1570. && target_include_directories PRIVATE $_C__INCLUDE_OWNED \
  1571. && target_compile_options PRIVATE $USER_CFLAGS $USER_CXXFLAGS $_SEM_EXTRA_CXX_FLAGS \
  1572. && target_compile_options PUBLIC $USER_CFLAGS_GLOBAL_RAW $USER_CXXFLAGS_GLOBAL_RAW
  1573. CMAKE_FIND_PKG=
  1574. CMAKE_LINK_TARGET=$REALPRJNAME
  1575. CMAKE_FIND_PKG_COMP=
  1576. CONAN_REQUIRE=
  1577. CONAN_OPTS_SEM=
  1578. ### @usage: LIBRARY()
  1579. ###
  1580. ### The regular static library module.
  1581. ###
  1582. ### The LIBRARY() is intermediate module, so when built directly it won't build its dependencies.
  1583. ### It transitively provides its PEERDIRs to ultimate final target, where all LIBRARY() modules are built and linked together.
  1584. ###
  1585. ### This is C++ library, and it selects peers from multimodules accordingly.
  1586. ###
  1587. ### It makes little sense to mention LIBRARY in DEPENDS or BUNDLE, package and deploy it since it is not a standalone entity.
  1588. ### In order to use library in tests PEERDIR it to link into tests.
  1589. ### If you think you need to distribute static library please contact devtools@ for assistance.
  1590. module LIBRARY: _LIBRARY {
  1591. .GLOBAL=_AARS _PROGUARD_RULES
  1592. .SEM=CPP_LIBRARY_SEM
  1593. .ALIASES=EXTRALIBS=PY_EXTRALIBS
  1594. .GLOBAL_SEM=CPP_OBJ_LIBRARY_SEM
  1595. .DEFAULT_NAME_GENERATOR=ThreeDirNames
  1596. .ARGS_PARSER=Base
  1597. when ($CMAKE_PACKAGE_COMPONENT != "") {
  1598. CMAKE_FIND_PKG_COMP=COMPONENTS $CMAKE_PACKAGE_COMPONENT
  1599. }
  1600. when ($CMAKE_PACKAGE != "") {
  1601. CMAKE_FIND_PKG=find_package $CMAKE_PACKAGE $CMAKE_FIND_PKG_COMP
  1602. CPP_LIBRARY_SEM=$CMAKE_FIND_PKG && ${CPP_LIBRARY_INDUCED_SEM_PROPERTY} PUBLIC $CMAKE_LINK_TARGET $CONAN_REQUIRE $CONAN_OPTS_SEM && IGNORED
  1603. }
  1604. when ($CONAN_REFERENCE != "") {
  1605. CONAN_REQUIRE=&& conan_require $CONAN_REFERENCE
  1606. CPP_LIBRARY_SEM=$CMAKE_FIND_PKG && ${CPP_LIBRARY_INDUCED_SEM_PROPERTY} PUBLIC $CMAKE_LINK_TARGET $CONAN_REQUIRE $CONAN_OPTS_SEM && IGNORED
  1607. }
  1608. when ($CONAN_PKG_OPTS != "") {
  1609. CONAN_OPTS_SEM=&& conan_options $CONAN_PKG_OPTS
  1610. }
  1611. when ($OPENSOURCE_EXPORT == "no") {
  1612. CPP_LIBRARY_SEM=IGNORED
  1613. }
  1614. when ($HAS_CPP_PROTOBUF_PEERS == "yes") {
  1615. PEERDIR+=$CPP_PROTOBUF_PEERS
  1616. }
  1617. SET(MODULE_TYPE LIBRARY)
  1618. SET(MODULE_LANG CPP)
  1619. ADD_CLANG_TIDY()
  1620. }
  1621. # tag:internal
  1622. ### @usage: _BARE_MODULE() # internal
  1623. ###
  1624. ### Remove unwanted dependencies for "empty" library module
  1625. macro _BARE_MODULE() {
  1626. SET(NEED_PLATFORM_PEERDIRS no)
  1627. SET(PEERDIR_TEST_TOOL no)
  1628. DISABLE(WITH_VALGRIND)
  1629. NO_CODENAVIGATION()
  1630. NO_PLATFORM()
  1631. NO_RUNTIME()
  1632. NO_UTIL()
  1633. NO_CLANG_TIDY()
  1634. }
  1635. # tag:internal
  1636. ### @usage: _BARE_LINK_MODULE() # internal
  1637. ###
  1638. ### Remove unwanted dependencies for "empty" link module
  1639. macro _BARE_LINK_MODULE() {
  1640. _BARE_MODULE()
  1641. DISABLE(COMMON_LINK_SETTINGS)
  1642. ALLOCATOR(FAKE)
  1643. }
  1644. # tag:internal
  1645. ### @usage: _CONDITIONAL_SRCS([USE_CONDITIONAL_SRCS] Files...) # internal
  1646. ###
  1647. ### Adds Files... to SRCS if first word is `USE_CONDITIONAL_SRCS`
  1648. ### To be used with some variable which is set to `USE_CONDITIONAL_SRCS` under condition
  1649. macro _CONDITIONAL_SRCS(USE_CONDITIONAL_SRCS[], DYMMY...) {
  1650. SRCS($USE_CONDITIONAL_SRCS)
  1651. }
  1652. # XXX: dirty hack for correct LDFLAGS passing
  1653. RESOURCES_LIBRARY_LINK=$TOUCH_UNIT
  1654. RESOURCES_LIBRARY_SEM=IGNORED
  1655. ### @usage: RESOURCES_LIBRARY()
  1656. ###
  1657. ### Definition of a module that brings its content from external source (Sandbox) via DECLARE_EXTERNAL_RESOURCE macro.
  1658. ### This can participate in PEERDIRs of others as library but it cannot have own sources and PEERDIRs.
  1659. ###
  1660. ### @see: [DECLARE_EXTERNAL_RESOURCE()](#macro_DECLARE_EXTERNAL_RESOURCE)
  1661. module RESOURCES_LIBRARY: _BARE_UNIT {
  1662. .CMD=RESOURCES_LIBRARY_LINK
  1663. .SEM=RESOURCES_LIBRARY_SEM
  1664. .ALLOWED=DECLARE_EXTERNAL_RESOURCE EXTRALIBS OBJADDE_GLOBAL
  1665. .RESTRICTED=ALLOCATOR SIZE TAG DATA TEST_DATA DEPENDS FORK_TESTS FORK_SUBTESTS SPLIT_FACTOR TEST_CWD RUN TIMEOUT SRC SRCS PEERDIR SPLIT_DWARF
  1666. .ALIASES=EXTRALIBS=PY_EXTRALIBS
  1667. .NODE_TYPE=Library
  1668. .PEERDIR_POLICY=as_include
  1669. .EXTS=.o .obj .a .mf .supp .tidyjson .ld .lib
  1670. .GLOBAL=USER_CFLAGS USER_CXXFLAGS USER_CONLYFLAGS LDFLAGS _WHOLE_ARCHIVE_LIBS_VALUE RPATH OBJADDE_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__)
  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__ 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__ 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__ 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__ 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:"util/generic/strbuf.h"} ${output_include;hide:"array"} ${output_include;hide:"util/generic/string.h"} ${output_include;hide:"util/generic/vector.h"} ${output_include;hide:"util/string/cast.h"} ${SRCFLAGS} ${kv;hide:"p SC"} ${kv;hide:"pc yellow"}
  2720. }
  2721. # tag:src-processing
  2722. macro _SRC("ssqls", SRC, SRCFLAGS...) {
  2723. .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"}
  2724. }
  2725. # tag:src-processing
  2726. macro _SRC("f", SRC, SRCFLAGS...) {
  2727. .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"}
  2728. .PEERDIR=contrib/libs/libf2c
  2729. .ADDINCL=contrib/libs/libf2c
  2730. }
  2731. # tag:src-processing
  2732. macro _SRC("cpp", SRC, SRCFLAGS...) {
  2733. .CMD=$_SRC_cpp($SRC $SRCFLAGS)
  2734. .SEM=target_sources PRIVATE ${input:SRC} ${output;hide;suf=${OBJ_SUF}.o:SRC} $_ADD_EXTRA_FLAGS($SRCFLAGS)
  2735. }
  2736. # tag:src-processing
  2737. macro _SRC("cxx", SRC, SRCFLAGS...) {
  2738. .CMD=$_SRC(cpp $SRC $SRCFLAGS)
  2739. }
  2740. # tag:src-processing
  2741. macro _SRC("cc", SRC, SRCFLAGS...) {
  2742. .CMD=$_SRC(cpp $SRC $SRCFLAGS)
  2743. .SEM=target_sources PRIVATE ${input:SRC} ${output;hide;suf=${OBJ_SUF}.o:SRC} $_ADD_EXTRA_FLAGS($SRCFLAGS)
  2744. }
  2745. # tag:src-processing
  2746. macro _SRC("auxcpp", SRC, SRCFLAGS...) {
  2747. .CMD=$_SRC_cpp($SRC $_FORCE_CPP_FLAGS $SRCFLAGS)
  2748. .SEM=target_sources PRIVATE ${input:SRC} ${output;hide;suf=${OBJ_SUF}.o:SRC} $_ADD_EXTRA_FLAGS($_FORCE_CPP_FLAGS $SRCFLAGS)
  2749. }
  2750. # tag:src-processing
  2751. macro _SRC("C", SRC, SRCFLAGS...) {
  2752. .CMD=$_SRC(cpp $SRC $SRCFLAGS)
  2753. }
  2754. # tag:src-processing
  2755. macro _SRC("c", SRC, SRCFLAGS...) {
  2756. .CMD=$_SRC_c($SRC $SRCFLAGS)
  2757. .SEM=target_sources PRIVATE ${input:SRC} ${output;hide;suf=${OBJ_SUF}.o:SRC} $_ADD_EXTRA_FLAGS($SRCFLAGS $USER_CONLYFLAGS $USER_CONLYFLAGS_GLOBAL)
  2758. }
  2759. # tag:src-processing
  2760. macro _SRC("m", SRC, SRCFLAGS...) {
  2761. .CMD=$_SRC(c $SRC $SRCFLAGS)
  2762. }
  2763. MASM_SEM=target_sources PRIVATE ${input:SRC} ${output;hide;suf=${OBJ_SUF}.o:SRC} \
  2764. && curdir_masm_flags ${MASMFLAGS}
  2765. 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"} \
  2766. && 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 \
  2767. && add_language ASM \
  2768. && conan_require_tool yasm/1.3.0 && conan_import '"bin, *yasm* -> ./bin"' && conan_import '"bin, ytasm* -> ./bin"'
  2769. 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"} \
  2770. && 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 \
  2771. && add_language ASM \
  2772. && conan_require_tool yasm/1.3.0 && conan_import '"bin, *yasm* -> ./bin"' && conan_import '"bin, ytasm* -> ./bin"'
  2773. # tag:src-processing
  2774. macro _SRC("masm", SRC, SRCFLAGS...) {
  2775. .CMD=$_SRC_masm($SRC $SRCFLAGS)
  2776. .SEM=$MASM_SEM
  2777. }
  2778. # tag:src-processing
  2779. macro _SRC("yasm", SRC, SRCFLAGS...) {
  2780. .CMD=$_SRC_yasm($SRC $SRCFLAGS PREINCLUDES $YASM_PREINCLUDES_VALUE)
  2781. .SEM=$YASM_SEM
  2782. }
  2783. # tag:src-processing
  2784. macro _SRC("asm", SRC, SRCFLAGS...) {
  2785. .CMD=$_SRC_ASM($SRC $SRCFLAGS PREINCLUDES $YASM_PREINCLUDES_VALUE)
  2786. .SEM=$ASM_SEM
  2787. }
  2788. # tag:src-processing
  2789. macro _SRC("lua", SRC, SRCFLAGS...) {
  2790. .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"}
  2791. .PEERDIR=$LUAJIT_PATH
  2792. }
  2793. NVCC_CFLAGS=
  2794. when ($IDE_MSVS_CALL == "yes") {
  2795. # This is to avoid issues with .pdb from MSVC calling nvcc calling cl
  2796. NVCC_CFLAGS+=/Fd$(TEMP)
  2797. }
  2798. NVCC_STD_VER=14
  2799. when ($MSVC == "yes") {
  2800. NVCC_STD=/std:c++${NVCC_STD_VER}
  2801. }
  2802. otherwise {
  2803. NVCC_STD=-std=c++${NVCC_STD_VER}
  2804. }
  2805. # tag:src-processing
  2806. macro _SRC("cu", SRC, SRCFLAGS...) {
  2807. .CMD=$_SRC_CU_CMD
  2808. .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
  2809. .PEERDIR=$_SRC_CU_PEERDIR
  2810. }
  2811. # tag:src-processing
  2812. macro _SRC("fbs", SRC, SRCFLAGS...) {
  2813. .CMD=$FBS_CMD($SRC, $SRCFLAGS)
  2814. .SEM=$FBS_CMD($SRC, $SRCFLAGS)
  2815. }
  2816. # tag:src-processing
  2817. macro _SRC("fbs64", SRC, SRCFLAGS...) {
  2818. .CMD=$_CPP_FLATC64_CMD($SRC, $SRCFLAGS)
  2819. }
  2820. # tag:src-processing
  2821. macro _SRC("pysrc", SRC, SRCFLAGS...) {
  2822. .CMD=$_SRC_PYSRC($SRC, $SRCFLAGS)
  2823. }
  2824. # tag:src-processing
  2825. # This triggers configure error in attempt to add `ya.make` to SRCS macro or apply automatic processing by extension from codegen
  2826. macro _SRC("make", SRC, SRCFLAGS...) {
  2827. .CMD=
  2828. }
  2829. @import "${CONF_ROOT}/conf/bison_lex.conf"
  2830. # tag:src-processing
  2831. macro _SRC_py2src(SRC, SRCFLAGS...) {
  2832. .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"}
  2833. }
  2834. # tag:src-processing
  2835. macro _SRC_py3src(SRC, SRCFLAGS...) {
  2836. .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"}
  2837. }
  2838. # tag:src-processing python-specific
  2839. when ($PYTHON3 == "yes") {
  2840. _SRC_PYSRC_CMDLINE=$_SRC_py3src($SRC $SRCFLAGS)
  2841. }
  2842. elsewhen ($PYTHON2 == "yes") {
  2843. _SRC_PYSRC_CMDLINE=$_SRC_py2src($SRC $SRCFLAGS)
  2844. }
  2845. otherwise {
  2846. _SRC_PYSRC_CMDLINE=
  2847. }
  2848. # tag:src-processing tag:python-specific
  2849. macro _SRC_PYSRC(SRC, SRCFLAGS...) {
  2850. .CMD=$_SRC_PYSRC_CMDLINE
  2851. }
  2852. # tag:src-processing
  2853. macro _SRC_c_nodeps(SRC, OUTFILE, INC...) {
  2854. .CMD=$_SRC_C_NODEPS_CMD
  2855. }
  2856. # Custom flags for generated cpp-files. To support another generator:
  2857. # - insert additional file extension before .cpp into generated cpp-file name
  2858. # - update _LANG_CFLAGS_FILTER variable. Don't forget to add ' SKIP ' after flag list
  2859. #
  2860. # ragel5 and ragel6 generated terrible code which makes use of goto's in switch statements.
  2861. # This triggers -Werror-implicit-fallthrough due to `unannotated fall-through between switch labels`.
  2862. #
  2863. # cython generated code also fails to pass this diagnostics due to `fallthrough annotation in unreachable code`.
  2864. # We use cython==0.29.26 at the time. This issue might be fixed in further versions.
  2865. #
  2866. # flags -fno-profile-instr-generate -fno-coverage-mapping needed to always disable coverage for .pyx, .rl5, .rl6
  2867. # generated sources
  2868. ## tag:src-processing
  2869. when ($CLANG == "yes") {
  2870. _LANG_CFLAGS_FILTER=\
  2871. ${pre=-Wno-implicit-fallthrough -fno-profile-instr-generate -fno-coverage-mapping SKIP ;ext=.rl5:SRC} \
  2872. ${pre=-Wno-implicit-fallthrough -fno-profile-instr-generate -fno-coverage-mapping SKIP ;ext=.rl6:SRC} \
  2873. ${pre=-Wno-implicit-fallthrough -fno-profile-instr-generate -fno-coverage-mapping SKIP ;ext=.pyx:SRC}
  2874. }
  2875. otherwise {
  2876. _LANG_CFLAGS_FILTER=\
  2877. ${pre=-Wno-implicit-fallthrough SKIP ;ext=.rl5:SRC} \
  2878. ${pre=-Wno-implicit-fallthrough SKIP ;ext=.rl6:SRC} \
  2879. ${pre=-Wno-implicit-fallthrough SKIP ;ext=.pyx:SRC}
  2880. }
  2881. # tag:src-processing
  2882. # Magic macro for removing file name from result (file name is passed as unused SKIP parameter)
  2883. macro _FILTER_EXTS(SKIP="", FLAGS...) {
  2884. .CMD=$FLAGS
  2885. }
  2886. # tag:src-processing
  2887. macro _LANG_CFLAGS(SRC) {
  2888. .CMD=$_FILTER_EXTS($_LANG_CFLAGS_FILTER)
  2889. }
  2890. # tag:src-processing
  2891. # ymake bug workaround: variables followed a macros call in .CMD are not substituted and are placed in result as is
  2892. # Pack macro call into a variable and use it in _SRC_CPP_CMD instead of macro call
  2893. _LANG_CFLAGS_VALUE=
  2894. when ($CLANG == "yes" || $CLANG_CL == "yes" || $GCC == "yes") {
  2895. _LANG_CFLAGS_VALUE=$_LANG_CFLAGS(${noext:SRC})
  2896. }
  2897. # Allows to add single compilation unit name to the node's 'kv' section.
  2898. # This is used by the coverage machinery to instrument only the necessary sources
  2899. # when --coverage-prefix-filter <rootrelpath> is specified. For more info see DEVTOOLSSUPPORT-16891
  2900. SCU_NAME_KV=
  2901. when ($CLANG_COVERAGE && $CLANG_COVERAGE != "no" && $USE_SCU_VALUE == "yes") {
  2902. SCU_NAME_KV=${hide;kv:"scu_name $KV_VAL"}
  2903. }
  2904. macro _ADD_SCU_NAME(KV_VAL) {
  2905. .CMD=$SCU_NAME_KV
  2906. }
  2907. # tag:src-processing
  2908. macro _SRC_cpp(SRC, COMPILE_OUT_SUFFIX="", SRCFLAGS...) {
  2909. .CMD=$_SRC_CPP_CMD $_ADD_SCU_NAME(${input:SRC})
  2910. }
  2911. # tag:src-processing
  2912. macro _SRC_c(SRC, COMPILE_OUT_SUFFIX="", SRCFLAGS...) {
  2913. .CMD=$_SRC_C_CMD $_ADD_SCU_NAME(${input:SRC})
  2914. }
  2915. # tag:src-processing
  2916. macro _SRC_m(SRC, SRCFLAGS...) {
  2917. .CMD=$_SRC_M_CMD
  2918. }
  2919. # tag:src-processing
  2920. macro _SRC_masm(SRC, SRCFLAGS...) {
  2921. .CMD=$_SRC_MASM_CMD
  2922. }
  2923. # tag:lua-specific
  2924. ### @usage: COMPILE_LUA(Src, [NAME <import_name>])
  2925. ###
  2926. ### Compile LUA source file to object code using LUA 2.0
  2927. ### Optionally override import name which is by default reflects Src name
  2928. macro COMPILE_LUA(Src, NAME="") {
  2929. .CMD=$_SRC(lua, $Src, ${pre=-n :NAME})
  2930. }
  2931. # tag:lua-specific
  2932. ### @usage: _SRC_lua_21(SRC [SRCFLAGS...]) # internal
  2933. ###
  2934. ### Compile LUA source file to object code using LUA 2.1
  2935. macro _SRC_lua_21(SRC, SRCFLAGS...) {
  2936. .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"}
  2937. .PEERDIR=$LUAJIT_21_PATH
  2938. }
  2939. # tag:lua-specific
  2940. ### @usage: COMPILE_LUA_21(Src, [NAME <import_name>])
  2941. ###
  2942. ### Compile LUA source file to object code using LUA 2.1
  2943. ### Optionally override import name which is by default reflects Src name
  2944. macro COMPILE_LUA_21(Src, NAME="") {
  2945. .CMD=$_SRC_lua_21($Src, ${pre=-n :NAME})
  2946. }
  2947. # tag:lua-specific
  2948. ### @usage: _SRC_lua_openresty(SRC [SRCFLAGS...]) # internal
  2949. ###
  2950. ### Compile LUA source file to object code using OpenResty LUA 2.1
  2951. macro _SRC_lua_openresty(SRC, SRCFLAGS...) {
  2952. .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"}
  2953. .PEERDIR=$LUAJIT_OPENRESTY_PATH
  2954. }
  2955. # tag:lua-specific
  2956. ### @usage: COMPILE_LUA_OPENRESTY(Src, [NAME <import_name>])
  2957. ###
  2958. ### Compile LUA source file to object code using OpenResty LUA 2.1
  2959. ### Optionally override import name which is by default reflects Src name
  2960. macro COMPILE_LUA_OPENRESTY(Src, NAME="") {
  2961. .CMD=$_SRC_lua_openresty($Src, ${pre=-n :NAME})
  2962. }
  2963. GETTEXT_KEEP_PATH=no
  2964. _MO_OUTPUT=
  2965. when ($GETTEXT_KEEP_PATH == "yes") {
  2966. _MO_OUTPUT=${output;noauto;norel;noext:SRC.mo}
  2967. }
  2968. otherwise {
  2969. _MO_OUTPUT=${output;noauto;nopath;noext;tobindir:SRC.mo}
  2970. }
  2971. # tag:src-processing
  2972. macro _SRC("po", SRC, SRCFLAGS...) {
  2973. .CMD=$YMAKE_PYTHON ${input:"contrib/tools/python/src/Tools/i18n/msgfmt.py"} -o $_MO_OUTPUT ${input:SRC}
  2974. }
  2975. # tag:ydl-specific
  2976. YDL_FLAGS= --force-color -I ${ARCADIA_ROOT}
  2977. YDL_DESC_FLAGS=
  2978. # tag:src-processing tag:ydl-specific
  2979. macro _SRC("ydl", SRC, SRCFLAGS...) {
  2980. .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"}
  2981. .PEERDIR+=statbox/ydl/runtime/cpp
  2982. }
  2983. # tag:ydl-specific
  2984. ### @usage BUILD_YDL_DESC(Input Symbol Output)
  2985. ###
  2986. ### Generate a descriptor for a Symbol located in a ydl module Input, and put it to the file Output.
  2987. ###
  2988. ### @example:
  2989. ###
  2990. ### PACKAGE()
  2991. ### BUILD_YDL_DESC(../types.ydl Event Event.ydld)
  2992. ### END()
  2993. ###
  2994. ### 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.
  2995. macro BUILD_YDL_DESC(Input, Symbol, Output) {
  2996. .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"}
  2997. }
  2998. # tag:ydl-specific
  2999. ### @usage: YDL_DESC_USE_BINARY()
  3000. ###
  3001. ### Used in conjunction with BUILD_YDL_DESC. When enabled, all generated descriptors are binary.
  3002. ###
  3003. ### @example:
  3004. ###
  3005. ### PACKAGE()
  3006. ### YDL_DESC_USE_BINARY()
  3007. ### BUILD_YDL_DESC(../types.ydl Event Event.ydld)
  3008. ### END()
  3009. ###
  3010. ### This will generate descriptor Event.ydld in a binary format.
  3011. macro YDL_DESC_USE_BINARY() {
  3012. YDL_DESC_FLAGS_BINARY= --binary
  3013. SET_APPEND(YDL_DESC_FLAGS $YDL_DESC_FLAGS_BINARY)
  3014. }
  3015. ### @usage SRC(File Flags...)
  3016. ###
  3017. ### Compile single file with extra Flags.
  3018. ### Compilation is driven by the last extension of the File and Flags are specific to corresponding compilation command
  3019. macro SRC(FILE, FLAGS...) {
  3020. _SRC(${lastext:FILE} $FILE $FLAGS)
  3021. }
  3022. ### @usage: SRCS(<[GLOBAL] File> ...)
  3023. ###
  3024. ### 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.
  3025. ### Arcadia Paths from the root and is relative to the project's LIST are supported
  3026. ###
  3027. ### 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.
  3028. ### 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)
  3029. ###
  3030. ### @example:
  3031. ###
  3032. ### LIBRARY(test_global)
  3033. ### SRCS(GLOBAL foo.cpp)
  3034. ### END()
  3035. ###
  3036. ### 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.
  3037. macro SRCS(FILES...) {
  3038. foreach (FILE : $FILES) {
  3039. _SRC(${lastext:FILE} $FILE)
  3040. }
  3041. }
  3042. # tag:c-specific
  3043. macro _SRC_C_CUSTOM_FLAGS(SRC, COMPILE_OUT_SUFFIX, CUSTOM_FLAGS...) {
  3044. .CMD=$_SRC_c($SRC COMPILE_OUT_SUFFIX ${COMPILE_OUT_SUFFIX} ${CUSTOM_FLAGS})
  3045. .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
  3046. }
  3047. macro _SRC_CPP_CUSTOM_FLAGS(SRC, COMPILE_OUT_SUFFIX, CUSTOM_FLAGS...) {
  3048. .CMD=$_SRC_cpp($SRC COMPILE_OUT_SUFFIX ${COMPILE_OUT_SUFFIX} ${CUSTOM_FLAGS})
  3049. .SEM=target_sources_custom $COMPILE_OUT_SUFFIX SRCS ${input:SRC} ${hide;output;suf=${COMPILE_OUT_SUFFIX}.o:SRC} CUSTOM_FLAGS $CUSTOM_FLAGS
  3050. }
  3051. # tag:src-specific tag:cpp-specific
  3052. ### @usage: _SRC_CUSTOM_C_CPP(Ext MacroName File Flags...) # internal
  3053. ###
  3054. ### Defenition of generic macro. Report an error that the File with Ext is not
  3055. ### supported by macro MacroName if no appropriate macro specialization is found.
  3056. macro _SRC_CUSTOM_C_CPP(EXT, MACRO_NAME, FILE, COMPILE_OUT_SUFFIX, FLAGS...) {
  3057. MESSAGE(FATAL_ERROR macro [[alt1]]$MACRO_NAME[[rst]] does not support files with [[imp]].$EXT[[rst]] extension)
  3058. }
  3059. # tag:src-specific tag:cpp-specific
  3060. ### @usage: _SRC_CUSTOM_C_CPP(Ext MacroName File Flags...) # internal
  3061. ###
  3062. ### Specialization of genreric macro _SRC_CUSTOM_C_CPP which compiles a single C file (with .c extension)
  3063. macro _SRC_CUSTOM_C_CPP("c", MACRO_NAME, FILE, COMPILE_OUT_SUFFIX, FLAGS...) {
  3064. _SRC_C_CUSTOM_FLAGS($FILE $COMPILE_OUT_SUFFIX $FLAGS)
  3065. }
  3066. # tag:src-specific tag:cpp-specific
  3067. ### @usage: _SRC_CUSTOM_C_CPP(Ext MacroName File Flags...) # internal
  3068. ###
  3069. ### Specialization of genreric macro _SRC_CUSTOM_C_CPP which compiles a single Cpp file (with .cpp extension)
  3070. macro _SRC_CUSTOM_C_CPP("cpp", MACRO_NAME, FILE, COMPILE_OUT_SUFFIX, FLAGS...) {
  3071. _SRC_CPP_CUSTOM_FLAGS($FILE $COMPILE_OUT_SUFFIX $FLAGS)
  3072. }
  3073. # tag:src-specific tag:cpp-specific
  3074. ### @usage: _SRC_CUSTOM_C_CPP(Ext MacroName File Flags...) # internal
  3075. ###
  3076. ### Specialization of genreric macro _SRC_CUSTOM_C_CPP which compiles a single Cpp file (with .cxx extension)
  3077. macro _SRC_CUSTOM_C_CPP("cxx", MACRO_NAME, FILE, COMPILE_OUT_SUFFIX, FLAGS...) {
  3078. _SRC_CPP_CUSTOM_FLAGS($FILE $COMPILE_OUT_SUFFIX $FLAGS)
  3079. }
  3080. # tag:src-specific tag:cpp-specific
  3081. ### @usage: _SRC_CUSTOM_C_CPP(Ext MacroName File Flags...) # internal
  3082. ###
  3083. ### Specialization of genreric macro _SRC_CUSTOM_C_CPP which compiles a single Cpp file (with .cc extension)
  3084. macro _SRC_CUSTOM_C_CPP("cc", MACRO_NAME, FILE, COMPILE_OUT_SUFFIX, FLAGS...) {
  3085. _SRC_CPP_CUSTOM_FLAGS($FILE $COMPILE_OUT_SUFFIX $FLAGS)
  3086. }
  3087. # tag:src-specific tag:cpp-specific
  3088. ### @usage: _SRC_CUSTOM_C_CPP(Ext MacroName File Flags...) # internal
  3089. ###
  3090. ### Specialization of genreric macro _SRC_CUSTOM_C_CPP which compiles a single Cpp file (with .C extension)
  3091. macro _SRC_CUSTOM_C_CPP("C", MACRO_NAME, FILE, COMPILE_OUT_SUFFIX, FLAGS...) {
  3092. _SRC_CPP_CUSTOM_FLAGS($FILE $COMPILE_OUT_SUFFIX $FLAGS)
  3093. }
  3094. # tag:src-specific tag:cpp-specific tag:cpu
  3095. ### @uasge SRC_C_SSE2(File Flags...)
  3096. ###
  3097. ### Compile a single C/C++ file with SSE2 and additional Flags
  3098. macro SRC_C_SSE2(FILE, FLAGS...) {
  3099. _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_SSE2 $FILE .sse2 $SSE2_CFLAGS $FLAGS)
  3100. }
  3101. # tag:src-specific tag:cpp-specific tag:cpu
  3102. ### @uasge SRC_C_SSE3(File Flags...)
  3103. ###
  3104. ### Compile a single C/C++ file with SSE3 and additional Flags
  3105. macro SRC_C_SSE3(FILE, FLAGS...) {
  3106. _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_SSE3 $FILE .sse3 $SSE3_CFLAGS $FLAGS)
  3107. }
  3108. # tag:src-specific tag:cpp-specific tag:cpu
  3109. ### @uasge SRC_C_SSSE3(File Flags...)
  3110. ###
  3111. ### Compile a single C/C++ file with SSSE3 and additional Flags
  3112. macro SRC_C_SSSE3(FILE, FLAGS...) {
  3113. _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_SSSE3 $FILE .ssse3 $SSSE3_CFLAGS $FLAGS)
  3114. }
  3115. # tag:src-specific tag:cpp-specific tag:cpu
  3116. ### @uasge SRC_C_SSE4(File Flags...)
  3117. ###
  3118. ### Compile a single C/C++ file with SSE4 and additional Flags
  3119. macro SRC_C_SSE4(FILE, FLAGS...) {
  3120. _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_SSE4 $FILE .sse4 $SSE4_CFLAGS $FLAGS)
  3121. }
  3122. # tag:src-specific tag:cpp-specific tag:cpu
  3123. ### @uasge SRC_C_SSE41(File Flags...)
  3124. ###
  3125. ### Compile a single C/C++ file with SSE4.1 and additional Flags
  3126. macro SRC_C_SSE41(FILE, FLAGS...) {
  3127. _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_SSE41 $FILE .sse41 $SSE41_CFLAGS $FLAGS)
  3128. }
  3129. # tag:src-specific tag:cpp-specific tag:cpu
  3130. ### @uasge SRC_C_AVX(File Flags...)
  3131. ###
  3132. ### Compile a single C/C++ file with AVX and additional Flags
  3133. macro SRC_C_AVX(FILE, FLAGS...) {
  3134. _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_AVX $FILE .avx $AVX_CFLAGS $FLAGS)
  3135. }
  3136. # tag:src-specific tag:cpp-specific tag:cpu
  3137. ### @uasge SRC_C_AVX2(File Flags...)
  3138. ###
  3139. ### Compile a single C/C++ file with AVX2 and additional Flags
  3140. macro SRC_C_AVX2(FILE, FLAGS...) {
  3141. _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_AVX2 $FILE .avx2 $AVX2_CFLAGS $FLAGS)
  3142. }
  3143. # tag:src-specific tag:cpp-specific tag:cpu
  3144. ### @uasge SRC_C_AVX512(File Flags...)
  3145. ###
  3146. ### Compile a single C/C++ file with AVX512 and additional Flags
  3147. macro SRC_C_AVX512(FILE, FLAGS...) {
  3148. _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_AVX512 $FILE .avx512 $AVX512_CFLAGS $FLAGS)
  3149. }
  3150. # tag:src-specific tag:cpp-specific tag:cpu
  3151. ### @uasge SRC_C_AVX512(File Flags...)
  3152. ###
  3153. ### Compile a single C/C++ file with AVX512 and additional Flags
  3154. macro SRC_C_AMX(FILE, FLAGS...) {
  3155. _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_AMX $FILE .amx $AMX_CFLAGS $FLAGS)
  3156. }
  3157. # tag:src-specific tag:cpp-specific tag:cpu
  3158. ### @uasge SRC_C_XOP(File Flags...)
  3159. ###
  3160. ### Compile a single C/C++ file with (an AMD-specific instruction set,
  3161. ### see https://en.wikipedia.org/wiki/XOP_instruction_set) and additional Flags
  3162. macro SRC_C_XOP(FILE, FLAGS...) {
  3163. _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_XOP $FILE .xop $XOP_CFLAGS $FLAGS)
  3164. }
  3165. # tag:src-specific tag:cpp-specific tag:cpu
  3166. ### @uasge SRC_C_PCLMUL(File Flags...)
  3167. ###
  3168. ### Compile a single C/C++ file with PCLMUL and additional Flags
  3169. macro SRC_C_PCLMUL(FILE, FLAGS...) {
  3170. _SRC_CUSTOM_C_CPP(${lastext:FILE} SRC_C_PCLMUL $FILE .pclmul $PCLMUL_CFLAGS $FLAGS )
  3171. }
  3172. # tag:src-specific tag:cpp-specific
  3173. ### @usage: _SRC_STRICT_C_CPP(Ext MacroName File Flags...) # internal
  3174. ###
  3175. ### Defenition of generic macro. Report an error that the File with Ext is not
  3176. ### supported by macro MacroName if no appropriate macro specialization is found.
  3177. macro _SRC_STRICT_C_CPP(EXT, MACRO_NAME, FILE, FLAGS...) {
  3178. MESSAGE(FATAL_ERROR macro [[alt1]]$MACRO_NAME[[rst]] does not support files with [[imp]].$EXT[[rst]] extension)
  3179. }
  3180. # tag:src-specific tag:cpp-specific
  3181. ### @usage: _SRC_STRICT_C_CPP(Ext MacroName File Flags...) # internal
  3182. ###
  3183. ### Specialization of genreric macro _SRC_STRICT_C_CPP which compiles a single C file (with .c extension)
  3184. macro _SRC_STRICT_C_CPP("c", MACRO_NAME, FILE, FLAGS...) {
  3185. _SRC(c $FILE $FLAGS)
  3186. }
  3187. # tag:src-specific tag:cpp-specific
  3188. ### @usage: _SRC_STRICT_C_CPP(Ext MacroName File Flags...) # internal
  3189. ###
  3190. ### Specialization of genreric macro _SRC_STRICT_C_CPP which compiles a single Cpp file (with .cpp extension)
  3191. macro _SRC_STRICT_C_CPP("cpp", MACRO_NAME, FILE, FLAGS...) {
  3192. _SRC(cpp $FILE $FLAGS)
  3193. }
  3194. # tag:src-specific tag:cpp-specific
  3195. ### @usage: _SRC_STRICT_C_CPP(Ext MacroName File Flags...) # internal
  3196. ###
  3197. ### Specialization of genreric macro _SRC_STRICT_C_CPP which compiles a single Cpp file (with .cxx extension)
  3198. macro _SRC_STRICT_C_CPP("cxx", MACRO_NAME, FILE, FLAGS...) {
  3199. _SRC(cpp $FILE $FLAGS)
  3200. }
  3201. # tag:src-specific tag:cpp-specific
  3202. ### @usage: _SRC_STRICT_C_CPP(Ext MacroName File Flags...) # internal
  3203. ###
  3204. ### Specialization of genreric macro _SRC_STRICT_C_CPP which compiles a single Cpp file (with .cc extension)
  3205. macro _SRC_STRICT_C_CPP("cc", MACRO_NAME, FILE, FLAGS...) {
  3206. _SRC(cpp $FILE $FLAGS)
  3207. }
  3208. # tag:src-specific tag:cpp-specific
  3209. ### @usage: _SRC_STRICT_C_CPP(Ext MacroName File Flags...) # internal
  3210. ###
  3211. ### Specialization of genreric macro _SRC_STRICT_C_CPP which compiles a single Cpp file (with .C extension)
  3212. macro _SRC_STRICT_C_CPP("C", MACRO_NAME, FILE, FLAGS...) {
  3213. _SRC(cpp $FILE $FLAGS)
  3214. }
  3215. # tag:src-specific tag:cpp-specific
  3216. ### @uasge SRC_C_PIC(File Flags...)
  3217. ###
  3218. ### Compile a single C/C++ file with -fPIC and additional Flags
  3219. macro SRC_C_PIC(FILE, FLAGS...) {
  3220. _SRC_STRICT_C_CPP(${lastext:FILE} SRC_C_PIC $FILE $PIC_CFLAGS $FLAGS)
  3221. }
  3222. # tag:src-specific tag:cpp-specific
  3223. ### @uasge SRC_C_NO_LTO(File Flags...)
  3224. ###
  3225. ### Compile a single C/C++ file with link-time-optimization disabling and additional Flags
  3226. macro SRC_C_NO_LTO(FILE, FLAGS...) {
  3227. _SRC_STRICT_C_CPP(${lastext:FILE} SRC_C_NO_LTO $FILE $NO_LTO_CFLAGS $FLAGS)
  3228. }
  3229. # tag:python-processing tag:cython
  3230. # TODO: use it in [.pyx] cmd
  3231. ### @usage: BUILDWITH_CYTHON_CPP(Src Options...)
  3232. ###
  3233. ### Generates .cpp file from .pyx.
  3234. macro BUILDWITH_CYTHON_CPP(Src, Options...) {
  3235. .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"}
  3236. .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
  3237. ADDINCL(FOR cython contrib/tools/cython/Cython/Includes)
  3238. }
  3239. # tag:python-processing tag:cython tag:internal
  3240. ### @usage: _BUILDWITH_CYTHON_CPP_DEP(Src Dep Options...) # internal
  3241. ###
  3242. ### Generates .cpp file from .pyx and attach extra input Dep.
  3243. ### If Dep changes the .cpp file will be re-generated.
  3244. macro _BUILDWITH_CYTHON_CPP_DEP(Src, Dep, Options...) {
  3245. .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"}
  3246. .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
  3247. ADDINCL(FOR cython contrib/tools/cython/Cython/Includes)
  3248. }
  3249. # tag:python-processing tag:cython tag:internal
  3250. ### @usage: _BUILDWITH_CYTHON_CPP_H(Src Dep Options...) # internal
  3251. ###
  3252. ### BUILDWITH_CYTHON_CPP without .pyx infix and with cdef public .h file.
  3253. macro _BUILDWITH_CYTHON_CPP_H(Src, Dep, Options...) {
  3254. .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"}
  3255. ADDINCL(FOR cython contrib/tools/cython/Cython/Includes)
  3256. }
  3257. # tag:python-processing tag:cython
  3258. ### @usage: BUILDWITH_CYTHON_C(Src Options...)
  3259. ###
  3260. ### Generates .c file from .pyx.
  3261. macro BUILDWITH_CYTHON_C(Src, Options...) {
  3262. .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"}
  3263. .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
  3264. ADDINCL(FOR cython contrib/tools/cython/Cython/Includes)
  3265. }
  3266. # tag:python-processing tag:cython tag:internal
  3267. ### @usage: _BUILDWITH_CYTHON_C_DEP(Src Dep Options...) # internal
  3268. ###
  3269. ### Generates .c file from .pyx and attach extra input Dep.
  3270. ### If Dep changes the .c file will be re-generated.
  3271. macro _BUILDWITH_CYTHON_C_DEP(Src, Dep, Options...) {
  3272. .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"}
  3273. .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
  3274. ADDINCL(FOR cython contrib/tools/cython/Cython/Includes)
  3275. }
  3276. # tag:python-processing tag:cython tag:internal
  3277. ### @usage: _BUILDWITH_CYTHON_C_H(Src Dep Options...) # internal
  3278. ###
  3279. ### BUILDWITH_CYTHON_C without .pyx infix and with cdef public .h file.
  3280. macro _BUILDWITH_CYTHON_C_H(Src, Dep, Options...) {
  3281. .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"}
  3282. ADDINCL(FOR cython contrib/tools/cython/Cython/Includes)
  3283. }
  3284. # tag:python-processing tag:cython tag:internal
  3285. ### @usage: _BUILDWITH_CYTHON_C_API_H(Src Dep Options...) # internal
  3286. ###
  3287. ### BUILDWITH_CYTHON_C_H with cdef api _api.h file.
  3288. macro _BUILDWITH_CYTHON_C_API_H(Src, Dep, Options...) {
  3289. .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"}
  3290. ADDINCL(FOR cython contrib/tools/cython/Cython/Includes)
  3291. }
  3292. ### @usage: BUILDWITH_RAGEL6(Src Options...)
  3293. ###
  3294. ### Compile .rl file using Ragel6.
  3295. macro BUILDWITH_RAGEL6(Src, Options...) {
  3296. .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"}
  3297. }
  3298. # tag:python-processing tag:internal
  3299. # TODO: use it in [.pyx] cmd
  3300. ### @usage: _PY_REGISTER() # internal
  3301. ###
  3302. ### Register Python 2.x module in internal resource file system. Arcadia Python 2.x importer will be retrieve these on import directive.
  3303. ###
  3304. ### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/pysrcs/#makrospyregister
  3305. macro _PY_REGISTER(Func) {
  3306. .CMD=$YMAKE_PYTHON ${input:"build/scripts/gen_py_reg.py"} $Func ${output;noauto:Func.reg.cpp} ${kv;hide:"p PY"} ${kv;hide:"pc yellow"}
  3307. SRCS(GLOBAL $Func.reg.cpp)
  3308. }
  3309. # tag:python-processing tag:internal
  3310. ### @usage: _PY3_REGISTER() # internal
  3311. ###
  3312. ### Register Python 3.x module in internal resource file system. Arcadia Python 3.x importer will be retrieve these on import directive
  3313. ###
  3314. ### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/pysrcs/#makrospyregister
  3315. macro _PY3_REGISTER(Func) {
  3316. .CMD=$YMAKE_PYTHON ${input:"build/scripts/gen_py3_reg.py"} $Func ${output;noauto:Func.reg3.cpp} ${kv;hide:"p PY"} ${kv;hide:"pc yellow"}
  3317. SRCS(GLOBAL $Func.reg3.cpp)
  3318. }
  3319. # tag:python-processing tag:internal
  3320. ### @usage: _PY_COMPILE_BYTECODE(SrcX Src) # internal
  3321. ###
  3322. ### Compile Python 2.x .py source file into Arcadia binary form suitable for PY2_PROGRAM
  3323. ###
  3324. ### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/pysrcs/#makrospyregister
  3325. macro _PY_COMPILE_BYTECODE(SrcX, Src, Dst) {
  3326. .CMD=$YMAKE_PYTHON ${input:"build/scripts/py_compile.py"} $SrcX ${input:Src} ${output;noauto:Dst.yapyc} ${kv;hide:"p PY"} ${kv;hide:"pc yellow"}
  3327. }
  3328. # tag:python-processing tag:internal
  3329. ### @usage: _PY3_COMPILE_BYTECODE(SrcX Src) # internal
  3330. ###
  3331. ### Compile Python 3.x .py source file into Arcadia binary form suitable for PY3_PROGRAM
  3332. ###
  3333. ### Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/pysrcs/#makrospyregister
  3334. macro _PY3_COMPILE_BYTECODE(SrcX, Src, Dst) {
  3335. .CMD=${env:"PYTHONHASHSEED=0"} ${tool:"tools/py3cc"} $SrcX ${input:Src} ${output;noauto:Dst.yapyc3} ${kv;hide:"p PY"} ${kv;hide:"pc yellow"}
  3336. }
  3337. macro _ARCHIVE_SEM_HELPER(FLAGS[], OUT, Files...) {
  3338. .SEM=add_custom_command OUTPUT ${OUT} DEPENDS $ARCH_TOOL ${join= :Files} COMMAND $ARCH_TOOL $FLAGS ${join=\: :Files}: -o ${OUT}
  3339. }
  3340. ### @usage: ARCHIVE_ASM(NAME archive_name files...)
  3341. ###
  3342. ### Similar to the macro ARCHIVE, but:
  3343. ### 1. works faster and it is better to use for large files.
  3344. ### 2. Different syntax (see examples in codesearch or users/pg/tests/archive_test)
  3345. macro ARCHIVE_ASM(NAME="", DONTCOMPRESS?"-p":"", Files...) {
  3346. .CMD=$ARCH_TOOL -q $DONTCOMPRESS ${input;join=\: :Files}: -o ${output;suf=$OBJ_SUF.rodata:NAME} ${kv;hide:"p AR"} ${kv;hide:"pc light-cyan"}
  3347. .SEM=$_ARCHIVE_SEM_HELPER(${output;suf=$OBJ_SUF.rodata:NAME} ${input:Files} FLAGS -q $DONTCOMPRESS)
  3348. }
  3349. # tag:yweb-specific
  3350. macro PIRE_INLINE_CMD(SRC) {
  3351. .CMD=${tool:"library/cpp/regex/pire/inline"} -o ${output:SRC} ${input:SRC} ${output_include;hide:SRC} ${kv;hide:"p PI"} ${kv;hide:"pc yellow"}
  3352. }
  3353. # tag:yweb-specific
  3354. macro PIRE_INLINE(FILES...) {
  3355. foreach (FILE : $FILES) {
  3356. PIRE_INLINE_CMD($FILE)
  3357. }
  3358. }
  3359. ### @usage: ARCHIVE(archive_name [DONT_COMPRESS] files...)
  3360. ###
  3361. ### Add arbitrary data to a modules. Unlike RESOURCE macro the result should be futher processed by othet macros in the module.
  3362. ###
  3363. ### Example: https://wiki.yandex-team.ru/yatool/howtowriteyamakefiles/#a1ispolzujjtekomanduarchive
  3364. macro ARCHIVE(NAME="", DONTCOMPRESS?"-p":"", Files...) {
  3365. .CMD=$ARCH_TOOL -q -x $DONTCOMPRESS ${input;join=\: :Files}: -o ${output;addincl;noauto:NAME} ${kv;hide:"p AR"} ${kv;hide:"pc light-red"}
  3366. .SEM=$_ARCHIVE_SEM_HELPER(${output;addincl;noauto:NAME} ${input:Files} FLAGS -q -x $DONTCOMPRESS) && target_sources PRIVATE $BINDIR/$NAME
  3367. }
  3368. ### @usage: ARCHIVE_BY_KEYS(archive_name key [DONT_COMPRESS] files...)
  3369. ###
  3370. ### Add arbitrary data to a module be accessible by specified key.
  3371. ### Unlike RESOURCE macro the result should be futher processed by othet macros in the module.
  3372. ###
  3373. ### Example: https://wiki.yandex-team.ru/yatool/howtowriteyamakefiles/#a1ispolzujjtekomanduarchive
  3374. macro ARCHIVE_BY_KEYS(NAME="", KEYS="", DONTCOMPRESS?"-p":"", Files...) {
  3375. .CMD=$ARCH_TOOL -q -x $DONTCOMPRESS ${input:Files} -k $KEYS -o ${output;addincl;noauto:NAME} ${kv;hide:"p AR"} ${kv;hide:"pc light-red"}
  3376. }
  3377. #scripts
  3378. #special commands
  3379. BUILDVERSION_SCRIPT=build/scripts/build_info_gen.py
  3380. SVNVERSION_JAVA_MARKER=output-java-class
  3381. SVNVERSION_GO_MARKER=output-go
  3382. VCS_C_OBJ=$BINDIR/__vcs_version__.c$OBJECT_SUF
  3383. VCS_C_OBJ_RR=$MODDIR/__vcs_version__.c$OBJECT_SUF
  3384. VCS_C=$BINDIR/__vcs_version__.c
  3385. VCS_GO=$BINDIR/__vcs_version__.go
  3386. VCS_JAVA=$BINDIR/__vcs_version__.mf
  3387. VCS_INFO_DISABLE_CACHE__NO_UID__=
  3388. YASM_DEBUG_INFO_DISABLE_CACHE__NO_UID__=
  3389. CL_DEBUG_INFO_DISABLE_CACHE__NO_UID__=
  3390. CL_MACRO_INFO_DISABLE_CACHE__NO_UID__=
  3391. YASM_DEBUG_INFO=
  3392. CL_DEBUG_INFO=
  3393. CL_MACRO_INFO=
  3394. when ($FORCE_VCS_INFO_UPDATE == "yes") {
  3395. VCS_INFO_DISABLE_CACHE__NO_UID__=${hide;kv:"disable_cache"}
  3396. }
  3397. ### Works for pyton too.
  3398. 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))
  3399. 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__
  3400. 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__
  3401. macro UPDATE_VCS_JAVA_INFO_NODEP(Jar) {
  3402. .CMD=$YMAKE_PYTHON3 ${input:"build/scripts/vcs_info.py"} output-java $(VCS)/vcs.json $VCS_JAVA $Jar $VCS_INFO_DISABLE_CACHE__NO_UID__
  3403. }
  3404. VCS_INFO_FILE=
  3405. ### @usage VCS_INFO_FILE([FILE out_file])
  3406. ###
  3407. ### Enable saving vcs info as a json-file into PACKAGE
  3408. ###
  3409. ### Info is saved to 'vcs_info.json' by default.
  3410. ### Use FILE parameter if you want another name.
  3411. ###
  3412. ### Note: macro can be used only once per module
  3413. macro VCS_INFO_FILE(FILE="vcs_info.json") {
  3414. SET(VCS_INFO_FILE $FILE)
  3415. }
  3416. ADD_VCS_INFO_FILE_CMD=
  3417. when ($VCS_INFO_FILE) {
  3418. 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__
  3419. }
  3420. ### @usage: CREATE_BUILDINFO_FOR(GenHdr)
  3421. ###
  3422. ### Creates header file to access some information about build specified via configuration variables.
  3423. ### Unlike CREATE_SVNVERSION_FOR() it doesn't take revion information from VCS, it uses revision and SandboxTaskId passed via -D options to ya make
  3424. macro CREATE_BUILDINFO_FOR(GenHdr) {
  3425. .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__
  3426. .SEM=$RUN_PYTHON3($BUILDVERSION_SCRIPT $GenHdr \\\"${CMAKE_CXX_COMPILER}\\\" \\\"${CMAKE_CXX_FLAGS}\\\" OUT $GenHdr)
  3427. }
  3428. DECIMAL_MD5_SCRIPT=build/scripts/decimal_md5.py
  3429. DECIMAL_MD5_FIXED=
  3430. ### @usage: DECIMAL_MD5_LOWER_32_BITS(<fileName> [FUNCNAME funcName] [inputs...])
  3431. ###
  3432. ### Generates .cpp file <fileName> with one defined function 'const char* <funcName>() { return "<calculated_md5_hash>"; }'.
  3433. ### <calculated_md5_hash> will be md5 hash for all inputs passed to this macro.
  3434. macro DECIMAL_MD5_LOWER_32_BITS(File, FUNCNAME="", Opts...) {
  3435. .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"}
  3436. }
  3437. # tag:internal
  3438. ### @usage $CFG_VARS # internal
  3439. ###
  3440. ### Mark commands that embed Configuration variables into files
  3441. macro CFG_VARS() {
  3442. .GEN_FROM_FILE=yes
  3443. }
  3444. ### @usage: CONFIGURE_FILE(from to)
  3445. ###
  3446. ### Copy file with the replacement of configuration variables in form of @ANY_CONF_VAR@ with their values.
  3447. ### The values are collected during configure stage, while replacement itself happens during build stage.
  3448. ### Used implicitly for .in-files processing.
  3449. macro CONFIGURE_FILE(Src, Dst) {
  3450. .CMD=$YMAKE_PYTHON ${input:"build/scripts/configure_file.py"} ${input:Src} ${output;addincl:Dst} $CFG_VARS ${kv;hide:"p CF"} ${kv;hide:"pc yellow"}
  3451. .SEM=set_vars ${CFG_VARS} && configure_file $S/${input;rootrel:Src} $B/${output;addincl;rootrel:Dst}
  3452. }
  3453. # tag:flags
  3454. ### @usage: LDFLAGS(LinkerFlags...)
  3455. ###
  3456. ### Add flags to the link command line of executable or shared library/dll.
  3457. ### Note: LDFLAGS are always global. When set in the LIBRARY module they will affect all programs/dlls/tests the library is linked into.
  3458. ### Note: remember about the incompatibility of flags for gcc and cl.
  3459. macro LDFLAGS(Flags...) {
  3460. SET_APPEND(LDFLAGS_GLOBAL $Flags)
  3461. }
  3462. # tag:flags
  3463. ### @usage: CFLAGS([GLOBAL compiler_flag]* compiler_flags)
  3464. ###
  3465. ### Add the specified flags to the compilation command of C and C++ files.
  3466. ### @params: GLOBAL - Propagates these flags to dependent projects
  3467. ### Note: remember about the incompatibility flags for clang and cl (to set flags specifically for cl.exe use MSVC_FLAGS).
  3468. macro CFLAGS(Flags...) {
  3469. SET_APPEND_WITH_GLOBAL(USER_CFLAGS $Flags)
  3470. }
  3471. # tag:flags
  3472. ### @usage: GLOBAL_CFLAGS(compiler_flags)
  3473. ###
  3474. ### Add the specified flags to the compilation command of C and C++ files and propagate these flags to dependent projects
  3475. macro GLOBAL_CFLAGS(Flags...) {
  3476. SET_APPEND_WITH_GLOBAL(USER_CFLAGS ${pre=GLOBAL :Flags})
  3477. }
  3478. # tag:flags
  3479. ### @usage: MASMFLAGS(compiler flags)
  3480. ### Add the specified flags to the compilation command of .masm files.
  3481. macro MASMFLAGS(Flags...) {
  3482. SET_APPEND(MASMFLAGS $Flags)
  3483. }
  3484. # tag:flags
  3485. ### @usage: CONLYFLAGS([GLOBAL compiler_flag]* compiler_flags)
  3486. ### Add the specified flags to the compilation command of .c (but not .cpp) files.
  3487. ### @params: GLOBAL - Distributes these flags on dependent projects
  3488. macro CONLYFLAGS(Flags...) {
  3489. SET_APPEND_WITH_GLOBAL(USER_CONLYFLAGS $Flags)
  3490. }
  3491. # tag:flags
  3492. ### @usage: CXXFLAGS(compiler_flags)
  3493. ### Add the specified flags to the compilation command of .cpp (but not .c) files.
  3494. macro CXXFLAGS(Flags...) {
  3495. SET_APPEND_WITH_GLOBAL(USER_CXXFLAGS $Flags)
  3496. }
  3497. # tag:flags
  3498. ### @usage: CUDA_NVCC_FLAGS(compiler flags)
  3499. ### Add the specified flags to the compile line .cu-files.
  3500. macro CUDA_NVCC_FLAGS(Flags...) {
  3501. SET_APPEND(CUDA_NVCC_FLAGS $Flags)
  3502. }
  3503. # tag:flags
  3504. ### @usage: NVCC_DEVICE_LINK(file.cu...)
  3505. ### Run nvcc --device-link on objects compiled from srcs with --device-c.
  3506. ### This generates a stub object devlink.o that supplies missing pieces for the
  3507. ### host linker to link relocatable device objects into the final executable.
  3508. macro NVCC_DEVICE_LINK(Srcs...) {
  3509. .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"}
  3510. }
  3511. # tag:flags
  3512. ### @usage: CYTHON_FLAGS(compiler_flags)
  3513. ### Add the specified flags to the compilation command of .pyx files.
  3514. macro CYTHON_FLAGS(Flags...) {
  3515. SET_APPEND(CYTHON_OPTIONS $Flags)
  3516. }
  3517. ### @usage: STRIP()
  3518. ### Strip debug info from a PROGRAM, DLL or TEST.
  3519. ### This macro doesn't work in LIBRARY's, UNION's and PACKAGE's.
  3520. macro STRIP() {
  3521. ENABLE(STRIP)
  3522. }
  3523. ### @usage: NO_OPTIMIZE()
  3524. ### Build code without any optimizations (-O0 mode).
  3525. macro NO_OPTIMIZE() {
  3526. ENABLE(NO_OPTIMIZE)
  3527. }
  3528. #TODO(YMAKE-91) read proper compile flags instead of sending explicit flags to semgraph directly
  3529. _SEM_EXTRA_CXX_FLAGS=
  3530. ### @usage: NO_COMPILER_WARNINGS()
  3531. ### Disable all compiler warnings in the module.
  3532. ### Priorities: NO_COMPILER_WARNINGS > NO_WERROR > WERROR_MODE > WERROR.
  3533. macro NO_COMPILER_WARNINGS() {
  3534. ENABLE(NO_COMPILER_WARNINGS)
  3535. SET(_SEM_EXTRA_CXX_FLAGS "$<IF:$<CXX_COMPILER_ID:MSVC>,,-Wno-everything>")
  3536. }
  3537. ### @usage: WERROR()
  3538. ### Consider warnings as errors in the current module.
  3539. ### In the bright future will be removed, since WERROR is the default.
  3540. ### Priorities: NO_COMPILER_WARNINGS > NO_WERROR > WERROR_MODE > WERROR.
  3541. macro WERROR() {
  3542. ENABLE(WERROR)
  3543. }
  3544. ### @usage: NO_WERROR()
  3545. ### Override WERROR() behavior
  3546. ### Priorities: NO_COMPILER_WARNINGS > NO_WERROR > WERROR_MODE > WERROR.
  3547. macro NO_WERROR() {
  3548. DISABLE(WERROR)
  3549. }
  3550. ### @usage: NO_WSHADOW()
  3551. ### Disable C++ shadowing warnings.
  3552. macro NO_WSHADOW() {
  3553. ENABLE(NO_WSHADOW)
  3554. }
  3555. # tag:internal
  3556. ### @usage: NO_PLATFORM_RESOURCES() # internal
  3557. ### Exclude dependency on platform resources libraries.
  3558. ### Most probably you'll never need this. If you think you need, please contact devtools@ for assistance.
  3559. macro NO_PLATFORM_RESOURCES() {
  3560. ENABLE(NOPLATFORM_RESOURCES)
  3561. }
  3562. # tag:internal tag:codenav
  3563. ### @usage: NO_CODENAVIGATION() # internal
  3564. ### Disable codenaviagtion for a module. Needed to avoid PEERDIR loops in codenavigation support.
  3565. ### Most probably you'll never need this. If you think you need, please contact devtools@ for assistance.
  3566. macro NO_CODENAVIGATION() {
  3567. ENABLE(NOCODENAVIGATION)
  3568. }
  3569. ### @usage: NO_UTIL()
  3570. ### Build module without dependency on util.
  3571. ### Note: use this with care. Util most likely will be linked into executable anyway,
  3572. ### so using util headers/functions/classes may not be detected at build time and may lead to unpredictable behavors at configure time.
  3573. macro NO_UTIL() {
  3574. ENABLE(NOUTIL)
  3575. }
  3576. ### @usage: NO_RUNTIME()
  3577. ###
  3578. ### This macro:
  3579. ### 1. Sets the ENABLE(NOUTIL) + DISABLE(USE_INTERNAL_STL);
  3580. ### 2. If the project that contains the macro NO_RUNTIME(), peerdir-it project does not contain NO_RUNTIME() => Warning.
  3581. ### Note: use this with care. Arcadia STL most likely will be linked into executable anyway, so using STL headers/functions/classes
  3582. ### may not be detected at build time and may lead to unpredictable behavors at configure time.
  3583. macro NO_RUNTIME() {
  3584. SET(USE_ARCADIA_LIBM no)
  3585. NO_UTIL()
  3586. ENABLE(NORUNTIME)
  3587. }
  3588. ### @usage: NO_LIBC()
  3589. ###
  3590. ### Exclude dependencies on C++ and C runtimes (including util, musl and libeatmydata).
  3591. ### Note: use this with care. libc most likely will be linked into executable anyway,
  3592. ### so using libc headers/functions may not be detected at build time and may lead to unpredictable behavors at configure time.
  3593. macro NO_LIBC() {
  3594. NO_RUNTIME()
  3595. DISABLE(MUSL)
  3596. }
  3597. ### @usage: NO_PLATFORM()
  3598. ###
  3599. ### Exclude dependencies on C++ and C runtimes (including util, musl and libeatmydata) and set NO_PLATFORM variable for special processing.
  3600. ### Note: use this with care. libc most likely will be linked into executable anyway,
  3601. ### so using libc headers/functions may not be detected at build time and may lead to unpredictable behavors at configure time.
  3602. macro NO_PLATFORM() {
  3603. NO_LIBC()
  3604. ENABLE(NOPLATFORM)
  3605. }
  3606. # tag:cpp-specific
  3607. ### @usage: USE_CXX()
  3608. ###
  3609. ### Add dependency on C++ runtime
  3610. ### Note: This macro is inteneded for use in _GO_BASE_UNIT like module when the module is built without C++ runtime by default
  3611. macro USE_CXX() {
  3612. DISABLE(NORUNTIME)
  3613. }
  3614. ### @usage: USE_UTIL()
  3615. ###
  3616. ### Add dependency on util and C++ runtime
  3617. ### Note: This macro is intended for use in _GO_BASE_UNIT like module when the module is build without util by default
  3618. macro USE_UTIL() {
  3619. USE_CXX()
  3620. DISABLE(NOUTIL)
  3621. }
  3622. ### @usage: USE_NASM()
  3623. ###
  3624. ### Build only .asm files with nasm toolchain instead of yasm
  3625. ### Add to ya.make file ADDINCL(asm ...) with all folders where .asm files include smth
  3626. macro USE_NASM() {
  3627. ENABLE(USE_NASM_ASSEMBLER)
  3628. PEERDIR(build/external_resources/nasm)
  3629. }
  3630. # tag:deprecated
  3631. ### @usage: NO_JOIN_SRC() # deprecated, does-nothing
  3632. ### This macro currently does nothing. This is default behavior which cannot be overridden at module level.
  3633. macro NO_JOIN_SRC() {
  3634. ENABLE(UNUSED_MACRO)
  3635. }
  3636. # tag:sanitize
  3637. ### @usage: NO_SANITIZE()
  3638. ###
  3639. ### Disable all sanitizers for the module.
  3640. macro NO_SANITIZE() {
  3641. DISABLE(SANITIZER_TYPE)
  3642. }
  3643. # tag:coverage tag:sanitize
  3644. ### @usage: NO_SANITIZE_COVERAGE()
  3645. ###
  3646. ### Disable lightweight coverage (-fsanitize-coverage) for the module.
  3647. ### Sanitize coverage is commonly used with fuzzing.
  3648. ### It might be useful to disable it for libraries that should never
  3649. ### be the main targets for fuzzing, like libfuzzer library itself.
  3650. ### Sanitize coverage instrumentation is enabled by the --sanitize-coverage option.
  3651. macro NO_SANITIZE_COVERAGE() {
  3652. DISABLE(SANITIZE_COVERAGE)
  3653. }
  3654. # tag:coverage
  3655. ### @usage: NO_CLANG_COVERAGE()
  3656. ###
  3657. ### Disable heavyweight clang coverage for the module. Clang coverage instrumentation is enabled by the --clang-coverage option.
  3658. macro NO_CLANG_COVERAGE() {
  3659. DISABLE(CLANG_COVERAGE)
  3660. }
  3661. # tag:coverage
  3662. ### @usage: NO_PROFILE_RUNTIME()
  3663. ###
  3664. ### Never link this target with profile runtime. Only should be used for very basic build tools
  3665. macro NO_PROFILE_RUNTIME() {
  3666. DISABLE(NEED_PROFILE_RUNTIME)
  3667. }
  3668. macro NO_CLANG_TIDY() {
  3669. DISABLE(TIDY_ENABLED)
  3670. }
  3671. # tag:lua-specific
  3672. LUAJIT_PATH=${ARCADIA_ROOT}/contrib/libs/luajit
  3673. macro _LUAJIT_OBJDUMP(Src, OUT="") {
  3674. .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"}
  3675. }
  3676. # tag:lua-specific
  3677. LUAJIT_21_PATH=${ARCADIA_ROOT}/contrib/libs/luajit_21
  3678. macro _LUAJIT_21_OBJDUMP(Src, OUT="") {
  3679. .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"}
  3680. }
  3681. # tag:lua-specific
  3682. LUAJIT_OPENRESTY_PATH=${ARCADIA_ROOT}/contrib/libs/luajit_openresty
  3683. macro _LUAJIT_OPENRESTY_OBJDUMP(Src, OUT="") {
  3684. .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"}
  3685. }
  3686. ### @usage: GENERATE_ENUM_SERIALIZATION(File.h)
  3687. ###
  3688. ### Create serialization support for enumeration members defined in the header (String <-> Enum conversions) and compile it into the module.
  3689. ###
  3690. ### Documentation: https://wiki.yandex-team.ru/yatool/HowToWriteYaMakeFiles/
  3691. macro GENERATE_ENUM_SERIALIZATION(File) {
  3692. .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"}
  3693. .SEM=generate_enum_serilization ${input:File} ${output;hide;suf=_serialized.o:File} INCLUDE_HEADERS ${input;rootrel:File} ${tool;hide:"tools/enum_parser/enum_parser"}
  3694. PEERDIR(tools/enum_parser/enum_serialization_runtime)
  3695. }
  3696. ### @usage: GENERATE_ENUM_SERIALIZATION_WITH_HEADER(File.h)
  3697. ###
  3698. ### Create serialization support for enumeration members defined in the header (String <-> Enum conversions) and compile it into the module
  3699. ### Provide access to serialization functions via generated header File_serialized.h
  3700. ###
  3701. ### Documentation: https://wiki.yandex-team.ru/yatool/HowToWriteYaMakeFiles/
  3702. macro GENERATE_ENUM_SERIALIZATION_WITH_HEADER(File) {
  3703. .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"}
  3704. .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"}
  3705. PEERDIR(tools/enum_parser/enum_serialization_runtime)
  3706. }
  3707. ### @usage: DEB_VERSION(File)
  3708. ###
  3709. ### Creates a header file DebianVersion.h define the DEBIAN_VERSION taken from the File.
  3710. macro DEB_VERSION(File) {
  3711. .CMD=$YMAKE_PYTHON ${input:"build/scripts/mkver.py"} ${input:File} ${output;stdout:"DebianVersion.h"} ${kv;hide:"p CL"} ${kv;hide:"pc yellow"}
  3712. }
  3713. ### @usage: NEED_CHECK()
  3714. ###
  3715. ### Commits to the project marked with this macro will be blocked by pre-commit check and then will be
  3716. ### automatically merged to trunk only if there is no new broken build targets in check results.
  3717. ### The use of this macro is disabled by default.
  3718. macro NEED_CHECK(Flags...) {
  3719. # TODO: FIXME
  3720. ENABLE(UNUSED_MACRO)
  3721. }
  3722. ### @usage: NO_NEED_CHECK()
  3723. ###
  3724. ### Commits to the project marked with this macro will not be affected by higher-level NEED_CHECK macro.
  3725. macro NO_NEED_CHECK(Flags...) {
  3726. ENABLE(UNUSED_MACRO)
  3727. }
  3728. # tag:deprecated
  3729. ### @usage: NEED_REVIEW() # deprecated
  3730. ###
  3731. ### Mark the project as needing review.
  3732. ### Reviewers are listed in the macro OWNER. The use of this macro is disabled by default.
  3733. ### Details can be found here: https://clubs.at.yandex-team.ru/arcadia/6104
  3734. macro NEED_REVIEW(Flags...) {
  3735. # TODO: FIXME
  3736. ENABLE(UNUSED_MACRO)
  3737. }
  3738. ### @usage: VERSION(Args...)
  3739. ###
  3740. ### Specify version of a module. Currently unused by build system, only informative.
  3741. macro VERSION(Flags...) {
  3742. ENABLE(UNUSED_MACRO)
  3743. }
  3744. DATAWORK_SCHEEME_EXPORT_FLAGS=
  3745. when ($UNIX == "yes") {
  3746. SCHEEME2_CFLAGS= -E -x c++
  3747. }
  3748. when ($WIN32 == "yes") {
  3749. SCHEEME2_CFLAGS= /E /TP
  3750. }
  3751. SCHEEME2_STRUCT_INFO_FLAGS=-f "const static ui32 RecordSig" -u "RecordSig" --gcc44_no_typename --no_complex_overloaded_func_export
  3752. ### @usage: GEN_SCHEEME2(scheeme_name from_file dependent_files...)
  3753. ###
  3754. ### Generates a C++ description for structure(contains the field RecordSig) in the specified file (and connected).
  3755. ###
  3756. ### 1. ${scheeme_name}.inc - the name of the generated file.
  3757. ### 2. Use an environment variable - DATAWORK_SCHEEME_EXPORT_FLAGS that allows to specify flags to tools/structparser
  3758. ###
  3759. ### @example:
  3760. ###
  3761. ### SET(DATAWORK_SCHEEME_EXPORT_FLAGS --final_only -m "::")
  3762. ###
  3763. ### 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)
  3764. ### sets in extra option
  3765. ###
  3766. ### @example:
  3767. ###
  3768. ### SET(EXTRACT_STRUCT_INFO_FLAGS -f \"const static ui32 RecordSig\"
  3769. ### -u \"RecordSig\" -n${scheeme_name}SchemeInfo ----gcc44_no_typename no_complex_overloaded_func_export
  3770. ### ${DATAWORK_SCHEEME_EXPORT_FLAGS})
  3771. ###
  3772. ### for compatibility with C++ compiler and the external environment.
  3773. ### See tools/structparser for more details.
  3774. macro GEN_SCHEEME2(ScheemeName, FromFile) {
  3775. .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"}
  3776. }
  3777. ### @usage: SYMLINK(from to)
  3778. ### Add symlink
  3779. macro SYMLINK(From, To) {
  3780. .CMD=$YMAKE_PYTHON ${input:"build/scripts/symlink.py"} ${input;dirallowed:From} ${output;noauto:To} ${kv;hide:"p LN"} ${kv;hide:"pc light-cyan"}
  3781. }
  3782. # tag:internal
  3783. ### @usage: _TARGET_SOURCES_FOR_HEADERS_IMPL([GENERATE] Args...) # internal
  3784. ### Generate prefix " && target_sources PRIVATE " before $Args when GENERATE is specified in the list of actual arguments
  3785. macro _TARGET_SOURCES_FOR_HEADERS_IMPL(GENERATE?" && target_sources PRIVATE ":"", Args...) {
  3786. .SEM=$GENERATE ${output;ext=.h:Args} ${output;ext=.hh:Args} ${output;ext=.hpp:Args} ${output;ext=.inc:Args} ${output;ext=.i:Args}
  3787. }
  3788. # tag:internal
  3789. ### @usage: _TARGET_SOURCES_FOR_HEADERS(Args...) # internal
  3790. ### Generate prefix " && target_sources PRIVATE " before $Args if Args is not empty
  3791. macro _TARGET_SOURCES_FOR_HEADERS(Args...) {
  3792. .SEM=$_TARGET_SOURCES_FOR_HEADERS_IMPL(${pre=GENERATE :Args})
  3793. }
  3794. # tag:internal
  3795. ### @usage: _TARGET_SOURCES_FOR_HEADERS_IMPL([GENERATE] Args...) # internal
  3796. ### Generate prefix " ${CMAKE_COMMAND} -E env " before $Args when GENERATE is specified in the list of actual arguments
  3797. macro _SET_ENV_FOR_CUSTOM_COMMAND_IMPL(GENERATE?" ${CMAKE_COMMAND} -E env ":"", Args...) {
  3798. .SEM=$GENERATE ${pre= :Args}
  3799. }
  3800. # tag:internal
  3801. ### @usage: _SET_ENV_FOR_CUSTOM_COMMAND(Args...) # internal
  3802. ### Generate prefix " ${CMAKE_COMMAND} -E env " before $Args if Args is not empty
  3803. macro _SET_ENV_FOR_CUSTOM_COMMAND(Args...) {
  3804. .SEM=$_SET_ENV_FOR_CUSTOM_COMMAND_IMPL(${pre=GENERATE :Args})
  3805. }
  3806. macro _FMT_INDUCED_DEPS(For, Deps...) {
  3807. .CMD=${induced_deps=$For;hide:Deps}
  3808. }
  3809. ### @usage: PREPARE_INDUCED_DEPS(VAR Type Files...)
  3810. ###
  3811. ### Format value for `INDUCED_DEPS` param in certain macros and assign to `VAR`
  3812. ### This tells that files of Type resulted from code generation macros (not neccessarily directly,
  3813. ### but in processing chain of generated files) should have extra dependencies from list of Files...
  3814. ###
  3815. ### Prominent example here is Cython: one can generate .pyx file that may depend on .pxd and have cimpot from
  3816. ### certain .h. The former is dependency for .pyx itself, while the latter is dependency for .pyx.cpp
  3817. ### resulted from Cython-processing of generated pyx. The code ganeration will look like:
  3818. ### ```
  3819. ### PREPARE_INDUCED_DEPS(PYX_DEPS pyx imported.pxd)
  3820. ### PREPARE_INDUCED_DEPS(CPP_DEPS cpp cdefed.h)
  3821. ### RUN_PYTHON3(generate_pyx.py genereted.pyx OUT generated.pyx INDUCED_DEPS $PYX_DEPS $CPP_DEPS)
  3822. ### ```
  3823. ###
  3824. ### The VAR will basically contain pair of `Type:[Files...]` in a form suitable for passing
  3825. ### as an element of array parameter. This is needed because language of ya.make doesn't support
  3826. ### Dict params right now and so it is impossible to directly pass something
  3827. ### like `{Type1:[Files2...], Type2:[Files2...]}`
  3828. ###
  3829. macro PREPARE_INDUCED_DEPS(VAR, For, Deps...) {
  3830. SET($VAR \$_FMT_INDUCED_DEPS($For $Deps))
  3831. }
  3832. ### @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...])
  3833. ###
  3834. ### Run a program from arcadia.
  3835. ### These macros are similar: RUN_PROGRAM, RUN_LUA, PYTHON.
  3836. ###
  3837. ### Parameters:
  3838. ### - tool_path - Path to the directory of the tool.
  3839. ### - args... - Program arguments. Relative paths listed in TOOL, IN, OUT, STDOUT become absolute.
  3840. ### - CWD dir - Absolute path of the working directory.
  3841. ### - ENV key=value... - Environment variables.
  3842. ### - TOOL tools... - Auxiliary tool directories.
  3843. ### - IN[_NOPARSE] inputs... - Input files. NOPARSE inputs are treated as textual and not parsed for dependencies regardless of file extensions.
  3844. ### - OUT[_NOAUTO] outputs... - Output files. NOAUTO outputs are not automatically added to the build process.
  3845. ### - STDOUT[_NOAUTO] output - Redirect the standard output to the output file.
  3846. ### - OUTPUT_INCLUDES output_includes... - Includes of the output files that are needed to build them.
  3847. ### - INDUCED_DEPS $VARs... - Dependencies for generated files. Unlike `OUTPUT_INCLUDES` these may target files further in processing chain.
  3848. ### In order to do so VAR should be filled by PREPARE_INDUCED_DEPS macro, stating target files (by type) and set of dependencies
  3849. ###
  3850. ### For absolute paths use ${ARCADIA_ROOT} and ${ARCADIA_BUILD_ROOT}, or
  3851. ### ${CURDIR} and ${BINDIR} which are expanded where the outputs are used.
  3852. ### 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).
  3853. 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...) {
  3854. .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"}
  3855. .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)
  3856. }
  3857. # tag:lua-specific
  3858. ### @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...])
  3859. ###
  3860. ### Run a lua script.
  3861. ### These macros are similar: RUN_PROGRAM, RUN_LUA, PYTHON.
  3862. ###
  3863. ### Parameters:
  3864. ### - script_path - Path to the script.3
  3865. ### - args... - Program arguments. Relative paths listed in TOOL, IN, OUT, STDOUT become absolute.
  3866. ### - CWD dir - Absolute path of the working directory.
  3867. ### - ENV key=value... - Environment variables.
  3868. ### - TOOL tools... - Auxiliary tool directories.
  3869. ### - IN[_NOPARSE] inputs... - Input files. NOPARSE inputs are treated as textual and not parsed for dependencies regardless of file extensions.
  3870. ### - OUT[_NOAUTO] outputs... - Output files. NOAUTO outputs are not automatically added to the build process.
  3871. ### - STDOUT[_NOAUTO] output - Redirect the standard output to the output file.
  3872. ### - OUTPUT_INCLUDES output_includes... - Includes of the output files that are needed to build them.
  3873. ### - INDUCED_DEPS $VARs... - Dependencies for generated files. Unlike `OUTPUT_INCLUDES` these may target files further in processing chain.
  3874. ### In order to do so VAR should be filled by PREPARE_INDUCED_DEPS macro, stating target files (by type) and set of dependencies
  3875. ###
  3876. ### For absolute paths use ${ARCADIA_ROOT} and ${ARCADIA_BUILD_ROOT}, or
  3877. ### ${CURDIR} and ${BINDIR} which are expanded where the outputs are used.
  3878. 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...) {
  3879. .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"}
  3880. }
  3881. # tag:python-specific
  3882. ### @usage: PYTHON(script_path args... [CWD dir] [ENV key=value...] [TOOL tools...] [IN[_NOPARSE] inputs...] [OUT[_NOAUTO] outputs...] [STDOUT[_NOAUTO] output] [OUTPUT_INCLUDES output_includes...] [INDUCED_DEPS $VARs...])
  3883. ###
  3884. ### Run a python script with $(PYTHON)/python built from devtools/huge_python.
  3885. ### These macros are similar: RUN_PROGRAM, RUN_LUA, PYTHON.
  3886. ###
  3887. ### Parameters:
  3888. ### - script_path - Path to the script.
  3889. ### - args... - Program arguments. Relative paths listed in TOOL, IN, OUT, STDOUT become absolute.
  3890. ### - CWD dir - Absolute path of the working directory.
  3891. ### - ENV key=value... - Environment variables.
  3892. ### - TOOL tools... - Auxiliary tool directories.
  3893. ### - IN[_NOPARSE] inputs... - Input files. NOPARSE inputs are treated as textual and not parsed for dependencies regardless of file extensions.
  3894. ### - OUT[_NOAUTO] outputs... - Output files. NOAUTO outputs are not automatically added to the build process.
  3895. ### - STDOUT[_NOAUTO] output - Redirect the standard output to the output file.
  3896. ### - OUTPUT_INCLUDES output_includes... - Includes of the output files that are needed to build them.
  3897. ### - INDUCED_DEPS $VARs... - Dependencies for generated files. Unlike `OUTPUT_INCLUDES` these may target files further in processing chain.
  3898. ### In order to do so VAR should be filled by PREPARE_INDUCED_DEPS macro, stating target files (by type) and set of dependencies
  3899. ###
  3900. ### For absolute paths use ${ARCADIA_ROOT} and ${ARCADIA_BUILD_ROOT}, or
  3901. ### ${CURDIR} and ${BINDIR} which are expanded where the outputs are used.
  3902. macro PYTHON(ScriptPath, IN{input}[], IN_NOPARSE{input}[], OUT{output}[], OUT_NOAUTO{output}[], TOOL{tool}[], OUTPUT_INCLUDES[], INDUCED_DEPS[], STDOUT="", STDOUT_NOAUTO="", CWD="", ENV[], Args...) {
  3903. .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"}
  3904. .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)
  3905. }
  3906. # tag:python-specific
  3907. ### @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...])
  3908. ###
  3909. ### Run a python script with prebuilt python3 interpretor built from devtools/huge_python3.
  3910. ### These macros are similar: RUN_PROGRAM, RUN_LUA, PYTHON.
  3911. ###
  3912. ### Parameters:
  3913. ### - script_path - Path to the script.
  3914. ### - args... - Program arguments. Relative paths listed in TOOL, IN, OUT, STDOUT become absolute.
  3915. ### - CWD dir - Absolute path of the working directory.
  3916. ### - ENV key=value... - Environment variables.
  3917. ### - TOOL tools... - Auxiliary tool directories.
  3918. ### - IN[_NOPARSE] inputs... - Input files. NOPARSE inputs are treated as textual and not parsed for dependencies regardless of file extensions.
  3919. ### - OUT[_NOAUTO] outputs... - Output files. NOAUTO outputs are not automatically added to the build process.
  3920. ### - STDOUT[_NOAUTO] output - Redirect the standard output to the output file.
  3921. ### - OUTPUT_INCLUDES output_includes... - Includes of the output files that are needed to build them.
  3922. ### - INDUCED_DEPS $VARs... - Dependencies for generated files. Unlike `OUTPUT_INCLUDES` these may target files further in processing chain.
  3923. ### In order to do so VAR should be filled by PREPARE_INDUCED_DEPS macro, stating target files (by type) and set of dependencies
  3924. ###
  3925. ### For absolute paths use ${ARCADIA_ROOT} and ${ARCADIA_BUILD_ROOT}, or
  3926. ### ${CURDIR} and ${BINDIR} which are expanded where the outputs are used.
  3927. 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...) {
  3928. .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"}
  3929. .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)
  3930. }
  3931. # tag:java-specific
  3932. 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...) {
  3933. PEERDIR(build/platform/java/jdk $JDK_RESOURCE_PEERDIR)
  3934. .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"}
  3935. }
  3936. ### @usage: FROM_SANDBOX([FILE] resource_id [AUTOUPDATED script] [RENAME <resource files>] OUT_[NOAUTO] <output files> [EXECUTABLE] [OUTPUT_INCLUDES <include files>] [INDUCED_DEPS $VARs...])
  3937. ###
  3938. ### Download the resource from the Sandbox, unpack (if not explicitly specified word FILE) and add OUT files to the build. EXECUTABLE makes them executable.
  3939. ### 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.
  3940. ### If there is no default processing for OUT files or you need process them specially use OUT_NOAUTO instead of OUT.
  3941. ###
  3942. ### It is disallowed to specify directory as OUT/OUT_NOAUTO since all outputs of commands shall be known to build system.
  3943. ###
  3944. ### RENAME renames files to the corresponding OUT and OUT_NOAUTO outputs:
  3945. ### FROM_SANDBOX(resource_id RENAME in_file1 in_file2 OUT out_file1 out_file2 out_file3)
  3946. ### FROM_SANDBOX(resource_id RENAME in_file1 OUT out_file1 RENAME in_file2 OUT out_file2)
  3947. ### FROM_SANDBOX(FILE resource_id RENAME resource_file OUT out_name)
  3948. ###
  3949. ### RENAME RESOURCE allows to rename the resource without specifying its file name.
  3950. ###
  3951. ### OUTPUT_INCLUDES output_includes... - Includes of the output files that are needed to build them.
  3952. ### INDUCED_DEPS $VARs... - Dependencies for generated files. Unlike `OUTPUT_INCLUDES` these may target files further in processing chain.
  3953. ### In order to do so VAR should be filled by PREPARE_INDUCED_DEPS macro, stating target files (by type) and set of dependencies
  3954. ###
  3955. ### If AUTOUPDATED is specified than macro will be regularly updated according to autoupdate script. The dedicated Sandbox task scans the arcadia and
  3956. ### changes resource_ids in such macros if newer resource of specified type is available. Note that the task seeks AUTOUPDATED in specific position,
  3957. ### so you shall place it immediately after resource_id.
  3958. 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="") {
  3959. .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"}
  3960. ADD_CHECK(check.resource $Id)
  3961. ADD_CHECK(check.external $EXTERNAL_FILE)
  3962. }
  3963. ### @usage: FROM_MDS([FILE] key [RENAME <resource files>] OUT_[NOAUTO] <output files> [EXECUTABLE] [OUTPUT_INCLUDES <include files>] [INDUCED_DEPS $VARs...])
  3964. ###
  3965. ### Download resource from MDS with the specified key and process like [FROM_SANDBOX()](#macro_FROM_SANDBOX).
  3966. 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="") {
  3967. .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"}
  3968. ADD_CHECK(check.mds $Key)
  3969. ADD_CHECK(check.external $EXTERNAL_FILE)
  3970. }
  3971. ### @usage LARGE_FILES([AUTOUPDATED] Files...)
  3972. ###
  3973. ### Use large file ether from working copy or from remote storage via placeholder <File>.external
  3974. ### If <File> is present locally (and not a symlink!) it will be copied to build directory.
  3975. ### Otherwise macro will try to locate <File>.external, parse it retrieve ot during build phase.
  3976. macro LARGE_FILES(AUTOUPDATED?, Files...) {
  3977. # This is needed to correctly switch between remote and local modes
  3978. _GLOB($LF $Files)
  3979. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS ${suf=.external:Files})
  3980. }
  3981. ### @usage: FROM_ARCHIVE(Src [RENAME <resource files>] OUT_[NOAUTO] <output files> [EXECUTABLE] [OUTPUT_INCLUDES <include files>] [INDUCED_DEPS $VARs...])
  3982. ###
  3983. ### Process file archive as [FROM_SANDBOX()](#macro_FROM_SANDBOX).
  3984. macro FROM_ARCHIVE(Src, OUT{output}[], OUT_NOAUTO{output}[], OUTPUT_INCLUDES[], INDUCED_DEPS[], PREFIX=".", RENAME[], EXECUTABLE?"--executable":"") {
  3985. .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"}
  3986. }
  3987. when ($MSVC == "yes") {
  3988. C_AS_CXX_FLAGS=/TP /std:c++17
  3989. }
  3990. otherwise {
  3991. C_AS_CXX_FLAGS=-x c++ -std=c++17
  3992. }
  3993. # tag:cpp-specific
  3994. ### @usage: COMPILE_C_AS_CXX()
  3995. ###
  3996. ### Compile .c files as .cpp ones within a module.
  3997. macro COMPILE_C_AS_CXX() {
  3998. SET(EXTRA_C_FLAGS $C_AS_CXX_FLAGS)
  3999. }
  4000. ### @usage: NO_DEBUG_INFO()
  4001. ###
  4002. ### Compile files without debug info collection.
  4003. macro NO_DEBUG_INFO() {
  4004. SET(NO_DEBUGINFO yes)
  4005. }
  4006. ### @usage: CTEMPLATE_VARNAMES(File)
  4007. ###
  4008. ### Generate File.varnames.h using contrib/libs/ctemplate/make_tpl_varnames_h
  4009. ###
  4010. ### Documentation: https://a.yandex-team.ru/arc/trunk/arcadia/contrib/libs/ctemplate/README.md
  4011. macro CTEMPLATE_VARNAMES(File) {
  4012. .CMD=${tool:"contrib/libs/ctemplate/make_tpl_varnames_h"} -f ${output;addincl;nopath;noallext:File.varnames.h} ${input:File}
  4013. }
  4014. LLVM_OPTS=
  4015. CLANG_BC_ROOT=${CLANG11_RESOURCE_GLOBAL}
  4016. macro USE_LLVM_BC12() {
  4017. SET(CLANG_BC_ROOT ${CLANG12_RESOURCE_GLOBAL})
  4018. }
  4019. macro USE_LLVM_BC14() {
  4020. SET(CLANG_BC_ROOT ${CLANG14_RESOURCE_GLOBAL})
  4021. }
  4022. macro USE_LLVM_BC16() {
  4023. SET(CLANG_BC_ROOT ${CLANG16_RESOURCE_GLOBAL})
  4024. }
  4025. CLANG_DEFAULT_ROOT=${CLANG_RESOURCE_GLOBAL}
  4026. CLANG_C_COMPILER_BIN=${CLANG_RESOURCE_GLOBAL}/bin/clang
  4027. CLANG_CPP_COMPILER_BIN=${CLANG_RESOURCE_GLOBAL}/bin/clang++
  4028. CLANG_EMIT_EXTRA_OPTS=
  4029. when ($OS_WINDOWS == "yes") {
  4030. # we can't use c++latest for clang14 now
  4031. # so we set c++20 for it
  4032. # for clang11 (actual clang for CLANG_EMIT_AST_CXX and LLVM_COMPILE_* macroses) /std:c++20 provokes "unused-command-line-argument" error
  4033. # !do not forget to change this flag when updating build/platform/clang
  4034. CLANG_EMIT_EXTRA_OPTS+=/std:c++latest
  4035. }
  4036. when ($OS_ANDROID == "yes") {
  4037. # We use clang shipped with android-ndk which has different layout
  4038. CLANG_DEFAULT_ROOT=$CLANG_ANDROID_RESOURCE_GLOBAL
  4039. when ($HOST_OS_DARWIN) {
  4040. CLANG_C_COMPILER_BIN=${CLANG_ANDROID_RESOURCE_GLOBAL}/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang
  4041. CLANG_CPP_COMPILER_BIN=${CLANG_ANDROID_RESOURCE_GLOBAL}/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++
  4042. }
  4043. otherwise {
  4044. CLANG_C_COMPILER_BIN=${CLANG_ANDROID_RESOURCE_GLOBAL}/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
  4045. CLANG_CPP_COMPILER_BIN=${CLANG_ANDROID_RESOURCE_GLOBAL}/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++
  4046. }
  4047. }
  4048. ### @usage: CLANG_EMIT_AST_CXX(Input Output Opts...)
  4049. ###
  4050. ### Emit Clang AST from .cpp file. CXXFLAGS and LLVM_OPTS are passed in, while CFLAGS and C_FLAGS_PLATFORM are not.
  4051. ### Note: Output name is used as is, no extension added.
  4052. macro CLANG_EMIT_AST_CXX(Input, Output, Opts...) {
  4053. .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"}
  4054. PEERDIR(build/platform/clang)
  4055. }
  4056. ### @usage: LLVM_COMPILE_CXX(Input Output Opts...)
  4057. ###
  4058. ### Emit LLVM bytecode from .cpp file. BC_CXXFLAGS, LLVM_OPTS and C_FLAGS_PLATFORM are passed in, while CFLAGS are not.
  4059. ### Note: Output name is used as is, no extension added.
  4060. macro LLVM_COMPILE_CXX(Input, Output, Opts...) {
  4061. .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"}
  4062. .SEM=llvm_compile_cxx ${input:Input} ${output;noauto:Output} ${"${CLANGPLUSPLUS}"} -Wno-unknown-warning-option $LLVM_OPTS ${NO_LTO_CFLAGS} -emit-llvm ${Opts}
  4063. PEERDIR(build/platform/clang)
  4064. }
  4065. ### @usage: LLVM_COMPILE_C(Input Output Opts...)
  4066. ###
  4067. ### Emit LLVM bytecode from .c file. BC_CFLAGS, LLVM_OPTS and C_FLAGS_PLATFORM are passed in, while CFLAGS are not.
  4068. ### Note: Output name is used as is, no extension added.
  4069. macro LLVM_COMPILE_C(Input, Output, Opts...) {
  4070. .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"}
  4071. .SEM=llvm_compile_c ${input:Input} ${output;noauto:Output} ${"${CLANGC}"} -Wno-unknown-warning-option $LLVM_OPTS ${NO_LTO_CFLAGS} -emit-llvm ${Opts}
  4072. PEERDIR(build/platform/clang)
  4073. }
  4074. ### @usage: BPF(Input Output Opts...)
  4075. ###
  4076. ### Emit eBPF bytecode from .c file.
  4077. ### Note: Output name is used as is, no extension added.
  4078. macro BPF(Input, Output, Opts...) {
  4079. .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"}
  4080. PEERDIR(build/platform/clang)
  4081. }
  4082. LD_BINARY_NAME=ld
  4083. when($OS_LINUX) {
  4084. LD_BINARY_NAME=ld.lld
  4085. }
  4086. ### @usage: BPF_STATIC(Input Output Opts...)
  4087. ###
  4088. ### Emit eBPF bytecode from .c file.
  4089. ### Note: Output name is used as is, no extension added.
  4090. macro BPF_STATIC(Input, Output, Opts...) {
  4091. .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}
  4092. PEERDIR(build/platform/clang build/platform/lld)
  4093. }
  4094. ### @usage: LLVM_COMPILE_LL(Input Output Opts...)
  4095. ###
  4096. ### Compile LLVM bytecode to object representation.
  4097. ### Note: Output name is used as is, no extension added.
  4098. macro LLVM_COMPILE_LL(Input, Output, Opts...) {
  4099. .CMD=${CLANG_BC_ROOT}/bin/llvm-as ${input:Input} -o ${output;noauto:Output} ${kv;hide:"p BC"} ${kv;hide:"pc light-green"}
  4100. .SEM=add_custom_command OUTPUT ${output;noauto:Output} DEPENDS ${input:Input} COMMAND ${LLVMAS} ${input:Input} -o ${output;noauto:Output}
  4101. PEERDIR(build/platform/clang)
  4102. }
  4103. ### @usage: LLVM_LINK(Output Inputs...)
  4104. ###
  4105. ### Call llvm-link on set of Inputs to produce Output.
  4106. ### Note: Unlike many other macros output argument goes first. Output name is used as is, no extension added.
  4107. macro LLVM_LINK(Output, Inputs...) {
  4108. .CMD=${CLANG_BC_ROOT}/bin/llvm-link ${input:Inputs} -o ${output;noauto:Output} ${kv;hide:"p LD"} ${kv;hide:"pc light-red"}
  4109. .SEM=add_custom_command OUTPUT ${output;noauto:Output} DEPENDS ${input:Inputs} COMMAND ${LLVMLINK} ${input:Inputs} -o ${output;noauto:Output}
  4110. PEERDIR(build/platform/clang)
  4111. }
  4112. ### @usage: LLVM_OPT(Input Output Opts...)
  4113. ###
  4114. ### Call llvm-opt with set of Opts on Input to produce Output.
  4115. ### Note: Output name is used as is, no extension added.
  4116. macro LLVM_OPT(Input, Output, Opts...) {
  4117. .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"}
  4118. .SEM=add_custom_command OUTPUT ${output;noauto:Output} DEPENDS ${input:Input} COMMAND ${LLVMOPT} ${input:Input} -o ${output;noauto:Output} $Opts
  4119. PEERDIR(build/platform/clang)
  4120. }
  4121. ### @usage: LLVM_LLC(Src Opts...)
  4122. ###
  4123. ### Call llvm-llc with set of Opts on Src to produce object file.
  4124. ###
  4125. ### Note: Output name is calculated as concatenation of Src name and platform specific object file extension.
  4126. macro LLVM_LLC(Src, Opts...) {
  4127. .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"}
  4128. .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
  4129. PEERDIR(build/platform/clang)
  4130. }
  4131. when ($NO_DEBUGINFO == "yes") {
  4132. DEBUG_INFO_FLAGS=
  4133. }
  4134. when ($CLANG && $DEBUGINFO_LINES_ONLY == "yes" && $NO_DEBUGINFO != "yes") {
  4135. DEBUG_INFO_FLAGS=-gline-tables-only
  4136. }
  4137. # TODO: configurable tar and touch
  4138. PACK_TGZ=${cwd:ARCADIA_BUILD_ROOT} tar -czf ${rootrel:OUTPUT} ${rootrel:INPUT} ${kv;hide:"p AR"} ${kv;hide:"pc light-red"}
  4139. # tag:internal
  4140. ### @usage TOUCH(Outputs...) # internal
  4141. ### Just introduce outputs
  4142. macro TOUCH(Outputs...) {
  4143. .CMD=$YMAKE_PYTHON ${input:"build/scripts/touch.py"} ${output:Outputs}
  4144. }
  4145. TOUCH_UNIT=$YMAKE_PYTHON ${input:"build/scripts/touch.py"} ${kv;hide:"p UN"} ${kv;hide:"pc light-cyan"} $TARGET
  4146. FAKE_PACKAGE_CMD=$YMAKE_PYTHON ${input:"build/scripts/touch.py"} ${kv;hide:"pc light-red"} $TARGET
  4147. 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"}
  4148. TOUCH_PACKAGE=$FAKE_PACKAGE_CMD $VCS_INFO_DISABLE_CACHE__NO_UID__ && $COPY_PACKAGE_CMD
  4149. _P_PK=${kv;hide:"p PK"}
  4150. TOUCH_PACKAGE_MF=$GENERATE_MF && $TOUCH_PACKAGE $_P_PK && $ADD_VCS_INFO_FILE_CMD
  4151. # Note: we don't use touch.py in the command below to avoid introduction of undesired input
  4152. 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__
  4153. UNION_CMD_MF=$UNION_CMD && $GENERATE_MF
  4154. macro _EXPAND_INS_OUTS(FILES{input}[]) {
  4155. .CMD=${input;hide:FILES} ${late_out;hide:INPUT}
  4156. }
  4157. _UNION_EXPLICIT_OUTPUTS=
  4158. ### @usage: EXPLICIT_OUTPUTS(Files...)
  4159. ###
  4160. ### Let UNION has only explicitly specified outputs listed in this macro
  4161. ### The list of files shall contain results of commands in this UNION.
  4162. ### Only these files will be outputs of the UNION. This allows to eliminate
  4163. ### intermediate files being result of the UNION
  4164. macro EXPLICIT_OUTPUTS(Files...) {
  4165. SET_APPEND(_UNION_EXPLICIT_OUTPUTS ${Files})
  4166. }
  4167. NO_CHECK_IMPORTS_FOR_VALUE=None
  4168. ### @usage: NO_CHECK_IMPORTS([patterns])
  4169. ###
  4170. ### Do not run checks on imports of Python modules.
  4171. ### Optional parameter mask patterns describes the names of the modules that do not need to check.
  4172. macro NO_CHECK_IMPORTS(Masks...) {
  4173. SET(NO_CHECK_IMPORTS_FOR_VALUE $Masks)
  4174. }
  4175. # tag:yasm-specific
  4176. _YASM_FMT_VALUE=
  4177. _YASM_PLATFORM_FLAGS_VALUE=
  4178. _YASM_PREDEFINED_FLAGS_VALUE=
  4179. when ($OS_DARWIN || $OS_IOS) {
  4180. _YASM_FMT_VALUE=macho
  4181. _YASM_PLATFORM_FLAGS_VALUE=-D DARWIN -D UNIX
  4182. }
  4183. elsewhen ($OS_WINDOWS && $ARCH_X86_64) {
  4184. _YASM_FMT_VALUE=win
  4185. _YASM_PLATFORM_FLAGS_VALUE=-D WIN64
  4186. }
  4187. elsewhen ($OS_WINDOWS && $ARCH_I386) {
  4188. _YASM_FMT_VALUE=win
  4189. _YASM_PLATFORM_FLAGS_VALUE=-D WIN32
  4190. }
  4191. otherwise {
  4192. _YASM_FMT_VALUE=elf
  4193. _YASM_PLATFORM_FLAGS_VALUE=-D UNIX
  4194. _YASM_PREDEFINED_FLAGS_VALUE=-g dwarf2
  4195. }
  4196. when ($ASM_PREFIX) {
  4197. ASM_PREFIX_VALUE=--prefix=$ASM_PREFIX
  4198. }
  4199. otherwise {
  4200. ASM_PREFIX_VALUE=
  4201. }
  4202. # tag:yasm-specific
  4203. YASM_FLAGS=
  4204. YASM_PREINCLUDES_VALUE=
  4205. # tag:yasm-specific
  4206. macro _SRC_yasm_helper(SRC, PREINCLUDES[], SRCFLAGS...) {
  4207. .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"}
  4208. }
  4209. # tag:yasm-specific
  4210. macro _SRC_yasm(SRC, PREINCLUDES[], SRCFLAGS...) {
  4211. .CMD=$_SRC_yasm_helper(${input:SRC}, $SRCFLAGS, PREINCLUDES $PREINCLUDES)
  4212. }
  4213. # tag:nasm-specific
  4214. NASM_FLAGS=
  4215. # tag:nasm-specific
  4216. macro _SRC_nasm_helper(SRC, SRCFLAGS...) {
  4217. .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}
  4218. }
  4219. # tag:nasm-specific
  4220. macro _SRC_nasm(SRC, PREINCLUDES[], SRCFLAGS...) {
  4221. .CMD=$_SRC_nasm_helper(${input:SRC}, $SRCFLAGS)
  4222. }
  4223. # tag:src-processing
  4224. when ($USE_NASM_ASSEMBLER == "yes") {
  4225. _SRC_ASM_CMDLINE=$_SRC_nasm($SRC $SRCFLAGS)
  4226. }
  4227. elsewhen ($USE_YASM_ASSEMBLER == "yes") {
  4228. _SRC_ASM_CMDLINE=$_SRC_yasm($SRC $SRCFLAGS)
  4229. }
  4230. otherwise {
  4231. _SRC_ASM_CMDLINE=
  4232. }
  4233. # tag:src-processing
  4234. macro _SRC_ASM(SRC, SRCFLAGS...) {
  4235. .CMD=$_SRC_ASM_CMDLINE
  4236. }
  4237. ### @usage: ASM_PREINCLUDE(AsmFiles...)
  4238. ###
  4239. ### Supply additional .asm files to all assembler calls within a module
  4240. macro ASM_PREINCLUDE(PREINCLUDES...) {
  4241. SET_APPEND(YASM_PREINCLUDES_VALUE $PREINCLUDES)
  4242. }
  4243. ### @usage: RUN_ANTLR(Args...)
  4244. ###
  4245. ### Macro to invoke ANTLR3 generator (general case)
  4246. macro RUN_ANTLR(IN[], IN_NOPARSE[], OUT[], OUT_NOAUTO[], OUTPUT_INCLUDES[], INDUCED_DEPS[], CWD="", Args...) {
  4247. _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})
  4248. .SEM=run_antlr OUTPUT ${output:OUT} ${output;noauto:OUT_NOAUTO} DEPENDS ${input:IN} ${pre=WORKING_DIRECTORY :CWD} ANTLER_ARGS $Args
  4249. }
  4250. ### @usage: RUN_ANTLR4(Args...)
  4251. ###
  4252. ### Macro to invoke ANTLR4 generator (general case)
  4253. macro RUN_ANTLR4(IN[], IN_NOPARSE[], OUT[], OUT_NOAUTO[], OUTPUT_INCLUDES[], INDUCED_DEPS[], CWD="", Args...) {
  4254. _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})
  4255. }
  4256. _ANTLR4_LISTENER_GRAMMAR=-listener
  4257. _ANTLR4_LISTENER_PARSER=-listener
  4258. _ANTLR4_LISTENER__ANTLR4_EMPTY=-no-listener
  4259. _ANTLR4_VISITOR_GRAMMAR=-visitor
  4260. _ANTLR4_VISITOR_PARSER=-visitor
  4261. _ANTLR4_VISITOR__ANTLR4_EMPTY=-no-visitor
  4262. ### @usage: RUN_ANTLR4_CPP_SPLIT(LEXER, PARSER, OUTPUT_INCLUDES, LISTENER, VISITOR, Args...)
  4263. ###
  4264. ### Macro to invoke ANTLR4 generator for separate lexer and parser grammars (Cpp)
  4265. macro RUN_ANTLR4_CPP_SPLIT(LEXER, PARSER, OUTPUT_INCLUDES[], LISTENER?"PARSER":"_ANTLR4_EMPTY", VISITOR?"PARSER":"_ANTLR4_EMPTY", _ANTLR4_EMPTY="", Args...) {
  4266. 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})
  4267. PEERDIR(contrib/libs/antlr4_cpp_runtime)
  4268. }
  4269. ### @usage: RUN_ANTLR4_CPP(GRAMMAR, OUTPUT_INCLUDES, LISTENER, VISITOR, Args...)
  4270. ###
  4271. ### Macro to invoke ANTLR4 generator for combined lexer+parser grammars (Cpp)
  4272. macro RUN_ANTLR4_CPP(GRAMMAR, OUTPUT_INCLUDES[], LISTENER?"GRAMMAR":"_ANTLR4_EMPTY", VISITOR?"GRAMMAR":"_ANTLR4_EMPTY", _ANTLR4_EMPTY="", Args...) {
  4273. 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})
  4274. PEERDIR(contrib/libs/antlr4_cpp_runtime)
  4275. }
  4276. ### @usage: RUN_ANTLR4_GO(GRAMMAR, DEPS <extra_go_deps>, LISTENER, VISITOR, Args...)
  4277. ###
  4278. ### Macro to invoke ANTLR4 generator (Go)
  4279. macro RUN_ANTLR4_GO(GRAMMAR, DEPS[], LISTENER?"GRAMMAR":"_ANTLR4_EMPTY", VISITOR?"GRAMMAR":"_ANTLR4_EMPTY", _ANTLR4_EMPTY="", Args...) {
  4280. 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})
  4281. PEERDIR(${GOSTD}/fmt ${GOSTD}/reflect ${GOSTD}/strconv ${GOSTD}/sync ${GOSTD}/unicode vendor/github.com/antlr/antlr4/runtime/Go/antlr/v4 $DEPS)
  4282. }
  4283. ### @usage: RUN_ANTLR4_PYTHON(Grammar [LISTENER] [VISITOR] [SUBDIR] [EXTRA_OUTS Outs...] Args...)
  4284. ###
  4285. ### `LISTENER` - emit grammar listener
  4286. ### `VISITOR` - emit grammar visitor
  4287. ### `SUBDIR` - place generated files to specified subdirectory of BINDIR
  4288. ### `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.
  4289. ###
  4290. ### 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.
  4291. macro RUN_ANTLR4_PYTHON(GRAMMAR, LISTENER?"GRAMMAR":"_ANTLR4_EMPTY", VISITOR?"GRAMMAR":"_ANTLR4_EMPTY", SUBDIR=".", EXTRA_OUTS[], _ANTLR4_EMPTY="", Args...) {
  4292. 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})
  4293. PEERDIR(contrib/python/antlr4)
  4294. }
  4295. # tag:cpp-specific
  4296. macro CPP_ADDINCL(Dirs...) {
  4297. ADDINCL($Dirs)
  4298. }
  4299. # tag:internal
  4300. _WHOLE_ARCHIVE_PEERS_VALUE=
  4301. ### @usage: WHOLE_ARCHIVE(dirnames...) # internal
  4302. macro WHOLE_ARCHIVE(PEERS...) {
  4303. SET_APPEND(_WHOLE_ARCHIVE_PEERS_VALUE ${PEERS})
  4304. REQUIRES(${PEERS})
  4305. }
  4306. ANDROID_SDK_ROOT=${ANDROID_SDK_RESOURCE_GLOBAL}/android_sdk
  4307. macro TASKLET() {
  4308. PEERDIR(tasklet/api)
  4309. # CPP
  4310. CPP_PROTO_PLUGIN(tasklet_cpp tasklet/v1/gen/cpp .tasklet.h)
  4311. # Python
  4312. PY_PROTO_PLUGIN2(tasklet_py _tasklet.py _sbtask.py tasklet/v1/gen/python DEPS tasklet/v1/domain/sandbox tasklet/v1/runtime sandbox/sdk2)
  4313. }
  4314. TASKLET_REG_INCLUDES= \
  4315. ${output_include;hide:"tasklet/v1/runtime/lib/cpp_wrapper.h"} \
  4316. ${output_include;hide:"tasklet/v1/runtime/lib/go_wrapper.h"} \
  4317. ${output_include;hide:"tasklet/v1/runtime/lib/py_wrapper.h"} \
  4318. ${output_include;hide:"tasklet/v1/runtime/lib/js_wrapper.h"} \
  4319. ${output_include;hide:"tasklet/v1/runtime/lib/registry.h"}
  4320. macro TASKLET_REG(Name, Lang, Impl, Includes...) {
  4321. PEERDIR(tasklet/v1/domain sandbox/bin sandbox/taskbox/worker)
  4322. when($Lang == "js") {
  4323. # JS runtime links the Node.js from contrib as a library, which is a bit heavy,
  4324. # so we do it, only if any JS tasklets are linked into the target
  4325. PEERDIR+=tasklet/v1/runtime/js
  4326. }
  4327. .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"}
  4328. SRCS(GLOBAL $Name.task.cpp)
  4329. }
  4330. # TEMPORARY METHOD FOR EXTENDED REGISTRY SETUP
  4331. # NOT COMPLETE
  4332. macro TASKLET_REG_EXT(Name, Lang, Impl, Wrapper, Includes...) {
  4333. PEERDIR(tasklet/v1/domain sandbox/bin sandbox/taskbox/worker)
  4334. .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"}
  4335. SRCS(GLOBAL $Name.task.cpp)
  4336. }
  4337. # tag:cpp-specific
  4338. _CPP_PROTO_MODULE_PREFIX=
  4339. _CPP_PROTO_MODULE_SUFFIX=
  4340. when ($MSVC == "yes" || $CYGWIN == "yes") {
  4341. _CPP_PROTO_MODULE_PREFIX=
  4342. _CPP_PROTO_MODULE_SUFFIX=.lib
  4343. }
  4344. otherwise {
  4345. _CPP_PROTO_MODULE_PREFIX=lib
  4346. _CPP_PROTO_MODULE_SUFFIX=.a
  4347. }
  4348. ### @usage: _EXPOSE(OutputsToExport...)
  4349. ###
  4350. ### Allows to mark outputs of macro command as unused in the current module but intended
  4351. ### to be used in modules consuming current via PEERDIR.
  4352. ###
  4353. ### TODO(DEVTOOLS-9000) proper implementation needed
  4354. macro _EXPOSE(Args...) {
  4355. .CMD=$YMAKE_PYTHON ${input:"build/scripts/touch.py"} ${output;suf=$_HASH_HELPER($Args).ya_exposed:"empty_"} ${input;hide:Args}
  4356. }
  4357. # tag:internal
  4358. ### @usage: _PROXY_LIBRARY() # internal
  4359. ###
  4360. ### The use of this module is strictly prohibited!!!
  4361. module _PROXY_LIBRARY: LIBRARY {
  4362. .EXTS=.a .lib
  4363. .PEERDIR_POLICY=as_build_from
  4364. .PROXY=yes
  4365. .FINAL_TARGET=yes
  4366. DISABLE(NEED_ADD_FAKE_SRC)
  4367. NO_UTIL()
  4368. NO_RUNTIME()
  4369. }
  4370. @import "${CONF_ROOT}/conf/project_specific/yql_udf.conf"
  4371. _PRIMARY_OUTPUT_VALUE=
  4372. # tag:internal
  4373. ### @usage: PRIMARY_OUTPUT_VALUE(Output) # internal
  4374. ###
  4375. ### The use of this module is strictly prohibited!!!
  4376. macro PRIMARY_OUTPUT(OUTPUT) {
  4377. SET(_PRIMARY_OUTPUT_VALUE $OUTPUT)
  4378. }
  4379. _DLL_PROXY_LIBRARY_CMD=$GENERATE_MF && $COPY_CMD $_PRIMARY_OUTPUT_VALUE ${input;hide:_PRIMARY_OUTPUT_VALUE} ${TARGET}
  4380. # tag:internal
  4381. ### @usage: DLL_PROXY_LIBRARY() # internal
  4382. ###
  4383. ### The use of this module is strictly prohibited!!!
  4384. module DLL_PROXY_LIBRARY: _PROXY_LIBRARY {
  4385. .ALLOWED=PRIMARY_OUTPUT
  4386. .CMD=_DLL_PROXY_LIBRARY_CMD
  4387. }
  4388. _PREBUILT_PROGRAM_CMD=$GENERATE_MF && $COPY_CMD $_PRIMARY_OUTPUT_VALUE ${TARGET} ${kv;hide:"p ld"} ${kv;hide:"pc light-blue"} ${kv;hide:"show_out"}
  4389. # tag:internal
  4390. ### @usage: PREBUILT_PROGRAM([programname]) # internal
  4391. ###
  4392. ### Program module which uses a prebuilt prgram as its output.
  4393. module PREBUILT_PROGRAM: _LINK_UNIT {
  4394. .CMD=_PREBUILT_PROGRAM_CMD
  4395. .SYMLINK_POLICY=EXE
  4396. .ALLOWED=INDUCED_DEPS PRIMARY_OUTPUT
  4397. .RESTRICTED=SRCS
  4398. _BARE_LINK_MODULE()
  4399. SET(MODULE_TYPE PROGRAM)
  4400. _DONT_REQUIRE_LICENSE()
  4401. when ($WIN32 == "yes" || $OS_CYGWIN == "yes") {
  4402. MODULE_SUFFIX=.exe
  4403. }
  4404. }
  4405. ### @usage COLLECT_JINJA_TEMPLATES(varname path)
  4406. ###
  4407. ### This macro collects all jinja and yaml files in the directory specified by second argument and
  4408. ### stores result in the variable with mane specified by first parameter.
  4409. macro COLLECT_JINJA_TEMPLATES(VAR, DIR) {
  4410. _GLOB($VAR ${DIR}/**/*.jinja ${DIR}/**/*.yaml)
  4411. }
  4412. @import "${CONF_ROOT}/conf/go.conf"
  4413. # Conflict between protobuf-java and protobuf-javalite ¯\_(ツ)_/¯
  4414. # both libraries are required by grpc
  4415. JAVA_IGNORE_CLASSPATH_CLASH_DEFAULE_VALUE=\
  4416. com.google.protobuf.AbstractMessageLite \
  4417. com.google.protobuf.AbstractMessageLite$Builder \
  4418. com.google.protobuf.AbstractMessageLite$Builder$LimitedInputStream \
  4419. com.google.protobuf.AbstractMessageLite$InternalOneOfEnum \
  4420. com.google.protobuf.AbstractParser \
  4421. com.google.protobuf.AbstractProtobufList \
  4422. com.google.protobuf.AllocatedBuffer \
  4423. com.google.protobuf.AllocatedBuffer$1 \
  4424. com.google.protobuf.AllocatedBuffer$2 \
  4425. com.google.protobuf.Android \
  4426. com.google.protobuf.Any \
  4427. com.google.protobuf.Any$1 \
  4428. com.google.protobuf.Any$Builder \
  4429. com.google.protobuf.AnyOrBuilder \
  4430. com.google.protobuf.AnyProto \
  4431. com.google.protobuf.Api \
  4432. com.google.protobuf.Api$1 \
  4433. com.google.protobuf.Api$Builder \
  4434. com.google.protobuf.ApiOrBuilder \
  4435. com.google.protobuf.ApiProto \
  4436. com.google.protobuf.ArrayDecoders \
  4437. com.google.protobuf.ArrayDecoders$1 \
  4438. com.google.protobuf.ArrayDecoders$Registers \
  4439. com.google.protobuf.BinaryReader \
  4440. com.google.protobuf.BinaryReader$1 \
  4441. com.google.protobuf.BinaryReader$SafeHeapReader \
  4442. com.google.protobuf.BinaryWriter \
  4443. com.google.protobuf.BinaryWriter$1 \
  4444. com.google.protobuf.BinaryWriter$SafeDirectWriter \
  4445. com.google.protobuf.BinaryWriter$SafeHeapWriter \
  4446. com.google.protobuf.BinaryWriter$UnsafeDirectWriter \
  4447. com.google.protobuf.BinaryWriter$UnsafeHeapWriter \
  4448. com.google.protobuf.BooleanArrayList \
  4449. com.google.protobuf.BoolValue \
  4450. com.google.protobuf.BoolValue$1 \
  4451. com.google.protobuf.BoolValue$Builder \
  4452. com.google.protobuf.BoolValueOrBuilder \
  4453. com.google.protobuf.BufferAllocator \
  4454. com.google.protobuf.BufferAllocator$1 \
  4455. com.google.protobuf.ByteBufferWriter \
  4456. com.google.protobuf.ByteOutput \
  4457. com.google.protobuf.ByteString \
  4458. com.google.protobuf.ByteString$1 \
  4459. com.google.protobuf.ByteString$2 \
  4460. com.google.protobuf.ByteString$AbstractByteIterator \
  4461. com.google.protobuf.ByteString$ArraysByteArrayCopier \
  4462. com.google.protobuf.ByteString$BoundedByteString \
  4463. com.google.protobuf.ByteString$ByteArrayCopier \
  4464. com.google.protobuf.ByteString$ByteIterator \
  4465. com.google.protobuf.ByteString$CodedBuilder \
  4466. com.google.protobuf.ByteString$LeafByteString \
  4467. com.google.protobuf.ByteString$LiteralByteString \
  4468. com.google.protobuf.ByteString$Output \
  4469. com.google.protobuf.ByteString$SystemByteArrayCopier \
  4470. com.google.protobuf.BytesValue \
  4471. com.google.protobuf.BytesValue$1 \
  4472. com.google.protobuf.BytesValue$Builder \
  4473. com.google.protobuf.BytesValueOrBuilder \
  4474. com.google.protobuf.CanIgnoreReturnValue \
  4475. com.google.protobuf.CheckReturnValue \
  4476. com.google.protobuf.CodedInputStream \
  4477. com.google.protobuf.CodedInputStream$1 \
  4478. com.google.protobuf.CodedInputStream$ArrayDecoder \
  4479. com.google.protobuf.CodedInputStream$IterableDirectByteBufferDecoder \
  4480. com.google.protobuf.CodedInputStream$StreamDecoder \
  4481. com.google.protobuf.CodedInputStream$StreamDecoder$RefillCallback \
  4482. com.google.protobuf.CodedInputStream$StreamDecoder$SkippedDataSink \
  4483. com.google.protobuf.CodedInputStream$UnsafeDirectNioDecoder \
  4484. com.google.protobuf.CodedInputStreamReader \
  4485. com.google.protobuf.CodedInputStreamReader$1 \
  4486. com.google.protobuf.CodedOutputStream \
  4487. com.google.protobuf.CodedOutputStream$1 \
  4488. com.google.protobuf.CodedOutputStream$AbstractBufferedEncoder \
  4489. com.google.protobuf.CodedOutputStream$ArrayEncoder \
  4490. com.google.protobuf.CodedOutputStream$ByteOutputEncoder \
  4491. com.google.protobuf.CodedOutputStream$HeapNioEncoder \
  4492. com.google.protobuf.CodedOutputStream$OutOfSpaceException \
  4493. com.google.protobuf.CodedOutputStream$OutputStreamEncoder \
  4494. com.google.protobuf.CodedOutputStream$SafeDirectNioEncoder \
  4495. com.google.protobuf.CodedOutputStream$UnsafeDirectNioEncoder \
  4496. com.google.protobuf.CodedOutputStreamWriter \
  4497. com.google.protobuf.CodedOutputStreamWriter$1 \
  4498. com.google.protobuf.DoubleArrayList \
  4499. com.google.protobuf.DoubleValue \
  4500. com.google.protobuf.DoubleValue$1 \
  4501. com.google.protobuf.DoubleValue$Builder \
  4502. com.google.protobuf.DoubleValueOrBuilder \
  4503. com.google.protobuf.Duration \
  4504. com.google.protobuf.Duration$1 \
  4505. com.google.protobuf.Duration$Builder \
  4506. com.google.protobuf.DurationOrBuilder \
  4507. com.google.protobuf.DurationProto \
  4508. com.google.protobuf.Empty \
  4509. com.google.protobuf.Empty$1 \
  4510. com.google.protobuf.Empty$Builder \
  4511. com.google.protobuf.EmptyOrBuilder \
  4512. com.google.protobuf.EmptyProto \
  4513. com.google.protobuf.Enum \
  4514. com.google.protobuf.Enum$1 \
  4515. com.google.protobuf.Enum$Builder \
  4516. com.google.protobuf.EnumOrBuilder \
  4517. com.google.protobuf.EnumValue \
  4518. com.google.protobuf.EnumValue$1 \
  4519. com.google.protobuf.EnumValue$Builder \
  4520. com.google.protobuf.EnumValueOrBuilder \
  4521. com.google.protobuf.ExperimentalApi \
  4522. com.google.protobuf.ExtensionLite \
  4523. com.google.protobuf.ExtensionRegistryFactory \
  4524. com.google.protobuf.ExtensionRegistryLite \
  4525. com.google.protobuf.ExtensionRegistryLite$ExtensionClassHolder \
  4526. com.google.protobuf.ExtensionRegistryLite$ObjectIntPair \
  4527. com.google.protobuf.ExtensionSchema \
  4528. com.google.protobuf.ExtensionSchemaLite \
  4529. com.google.protobuf.ExtensionSchemaLite$1 \
  4530. com.google.protobuf.ExtensionSchemas \
  4531. com.google.protobuf.Field \
  4532. com.google.protobuf.Field$1 \
  4533. com.google.protobuf.Field$Builder \
  4534. com.google.protobuf.Field$Cardinality \
  4535. com.google.protobuf.Field$Cardinality$1 \
  4536. com.google.protobuf.Field$Kind \
  4537. com.google.protobuf.Field$Kind$1 \
  4538. com.google.protobuf.FieldInfo \
  4539. com.google.protobuf.FieldInfo$1 \
  4540. com.google.protobuf.FieldInfo$Builder \
  4541. com.google.protobuf.FieldMask \
  4542. com.google.protobuf.FieldMask$1 \
  4543. com.google.protobuf.FieldMask$Builder \
  4544. com.google.protobuf.FieldMaskOrBuilder \
  4545. com.google.protobuf.FieldMaskProto \
  4546. com.google.protobuf.FieldOrBuilder \
  4547. com.google.protobuf.FieldSet \
  4548. com.google.protobuf.FieldSet$1 \
  4549. com.google.protobuf.FieldSet$Builder \
  4550. com.google.protobuf.FieldSet$FieldDescriptorLite \
  4551. com.google.protobuf.FieldType \
  4552. com.google.protobuf.FieldType$1 \
  4553. com.google.protobuf.FieldType$Collection \
  4554. com.google.protobuf.FloatArrayList \
  4555. com.google.protobuf.FloatValue \
  4556. com.google.protobuf.FloatValue$1 \
  4557. com.google.protobuf.FloatValue$Builder \
  4558. com.google.protobuf.FloatValueOrBuilder \
  4559. com.google.protobuf.GeneratedMessageInfoFactory \
  4560. com.google.protobuf.GeneratedMessageLite \
  4561. com.google.protobuf.GeneratedMessageLite$1 \
  4562. com.google.protobuf.GeneratedMessageLite$Builder \
  4563. com.google.protobuf.GeneratedMessageLite$DefaultInstanceBasedParser \
  4564. com.google.protobuf.GeneratedMessageLite$ExtendableBuilder \
  4565. com.google.protobuf.GeneratedMessageLite$ExtendableMessage \
  4566. com.google.protobuf.GeneratedMessageLite$ExtendableMessage$ExtensionWriter \
  4567. com.google.protobuf.GeneratedMessageLite$ExtendableMessageOrBuilder \
  4568. com.google.protobuf.GeneratedMessageLite$ExtensionDescriptor \
  4569. com.google.protobuf.GeneratedMessageLite$GeneratedExtension \
  4570. com.google.protobuf.GeneratedMessageLite$MethodToInvoke \
  4571. com.google.protobuf.GeneratedMessageLite$SerializedForm \
  4572. com.google.protobuf.Int32Value \
  4573. com.google.protobuf.Int32Value$1 \
  4574. com.google.protobuf.Int32Value$Builder \
  4575. com.google.protobuf.Int32ValueOrBuilder \
  4576. com.google.protobuf.Int64Value \
  4577. com.google.protobuf.Int64Value$1 \
  4578. com.google.protobuf.Int64Value$Builder \
  4579. com.google.protobuf.Int64ValueOrBuilder \
  4580. com.google.protobuf.IntArrayList \
  4581. com.google.protobuf.Internal \
  4582. com.google.protobuf.Internal$BooleanList \
  4583. com.google.protobuf.Internal$DoubleList \
  4584. com.google.protobuf.Internal$EnumLite \
  4585. com.google.protobuf.Internal$EnumLiteMap \
  4586. com.google.protobuf.Internal$EnumVerifier \
  4587. com.google.protobuf.Internal$FloatList \
  4588. com.google.protobuf.Internal$IntList \
  4589. com.google.protobuf.Internal$ListAdapter \
  4590. com.google.protobuf.Internal$ListAdapter$Converter \
  4591. com.google.protobuf.Internal$LongList \
  4592. com.google.protobuf.Internal$MapAdapter \
  4593. com.google.protobuf.Internal$MapAdapter$1 \
  4594. com.google.protobuf.Internal$MapAdapter$Converter \
  4595. com.google.protobuf.Internal$MapAdapter$EntryAdapter \
  4596. com.google.protobuf.Internal$MapAdapter$IteratorAdapter \
  4597. com.google.protobuf.Internal$MapAdapter$SetAdapter \
  4598. com.google.protobuf.Internal$ProtobufList \
  4599. com.google.protobuf.InvalidProtocolBufferException \
  4600. com.google.protobuf.InvalidProtocolBufferException$InvalidWireTypeException \
  4601. com.google.protobuf.IterableByteBufferInputStream \
  4602. com.google.protobuf.JavaType \
  4603. com.google.protobuf.LazyField \
  4604. com.google.protobuf.LazyField$1 \
  4605. com.google.protobuf.LazyField$LazyEntry \
  4606. com.google.protobuf.LazyField$LazyIterator \
  4607. com.google.protobuf.LazyFieldLite \
  4608. com.google.protobuf.LazyStringArrayList \
  4609. com.google.protobuf.LazyStringArrayList$ByteArrayListView \
  4610. com.google.protobuf.LazyStringArrayList$ByteStringListView \
  4611. com.google.protobuf.LazyStringList \
  4612. com.google.protobuf.ListFieldSchema \
  4613. com.google.protobuf.ListFieldSchema$1 \
  4614. com.google.protobuf.ListFieldSchema$ListFieldSchemaFull \
  4615. com.google.protobuf.ListFieldSchema$ListFieldSchemaLite \
  4616. com.google.protobuf.ListValue \
  4617. com.google.protobuf.ListValue$1 \
  4618. com.google.protobuf.ListValue$Builder \
  4619. com.google.protobuf.ListValueOrBuilder \
  4620. com.google.protobuf.LongArrayList \
  4621. com.google.protobuf.ManifestSchemaFactory \
  4622. com.google.protobuf.ManifestSchemaFactory$1 \
  4623. com.google.protobuf.ManifestSchemaFactory$CompositeMessageInfoFactory \
  4624. com.google.protobuf.MapEntryLite \
  4625. com.google.protobuf.MapEntryLite$1 \
  4626. com.google.protobuf.MapEntryLite$Metadata \
  4627. com.google.protobuf.MapFieldLite \
  4628. com.google.protobuf.MapFieldSchema \
  4629. com.google.protobuf.MapFieldSchemaLite \
  4630. com.google.protobuf.MapFieldSchemas \
  4631. com.google.protobuf.MessageInfo \
  4632. com.google.protobuf.MessageInfoFactory \
  4633. com.google.protobuf.MessageLite \
  4634. com.google.protobuf.MessageLite$Builder \
  4635. com.google.protobuf.MessageLiteOrBuilder \
  4636. com.google.protobuf.MessageLiteToString \
  4637. com.google.protobuf.MessageSchema \
  4638. com.google.protobuf.MessageSchema$1 \
  4639. com.google.protobuf.MessageSetSchema \
  4640. com.google.protobuf.Method \
  4641. com.google.protobuf.Method$1 \
  4642. com.google.protobuf.Method$Builder \
  4643. com.google.protobuf.MethodOrBuilder \
  4644. com.google.protobuf.Mixin \
  4645. com.google.protobuf.Mixin$1 \
  4646. com.google.protobuf.Mixin$Builder \
  4647. com.google.protobuf.MixinOrBuilder \
  4648. com.google.protobuf.MutabilityOracle \
  4649. com.google.protobuf.MutabilityOracle$1 \
  4650. com.google.protobuf.NewInstanceSchema \
  4651. com.google.protobuf.NewInstanceSchemaLite \
  4652. com.google.protobuf.NewInstanceSchemas \
  4653. com.google.protobuf.NioByteString \
  4654. com.google.protobuf.NioByteString$1 \
  4655. com.google.protobuf.NullValue \
  4656. com.google.protobuf.NullValue$1 \
  4657. com.google.protobuf.OneofInfo \
  4658. com.google.protobuf.Option \
  4659. com.google.protobuf.Option$1 \
  4660. com.google.protobuf.Option$Builder \
  4661. com.google.protobuf.OptionOrBuilder \
  4662. com.google.protobuf.Parser \
  4663. com.google.protobuf.PrimitiveNonBoxingCollection \
  4664. com.google.protobuf.Protobuf \
  4665. com.google.protobuf.ProtobufArrayList \
  4666. com.google.protobuf.ProtobufLists \
  4667. com.google.protobuf.ProtocolStringList \
  4668. com.google.protobuf.ProtoSyntax \
  4669. com.google.protobuf.RawMessageInfo \
  4670. com.google.protobuf.Reader \
  4671. com.google.protobuf.RopeByteString \
  4672. com.google.protobuf.RopeByteString$1 \
  4673. com.google.protobuf.RopeByteString$Balancer \
  4674. com.google.protobuf.RopeByteString$PieceIterator \
  4675. com.google.protobuf.RopeByteString$RopeInputStream \
  4676. com.google.protobuf.Schema \
  4677. com.google.protobuf.SchemaFactory \
  4678. com.google.protobuf.SchemaUtil \
  4679. com.google.protobuf.SmallSortedMap \
  4680. com.google.protobuf.SmallSortedMap$1 \
  4681. com.google.protobuf.SmallSortedMap$DescendingEntryIterator \
  4682. com.google.protobuf.SmallSortedMap$DescendingEntrySet \
  4683. com.google.protobuf.SmallSortedMap$EmptySet \
  4684. com.google.protobuf.SmallSortedMap$EmptySet$1 \
  4685. com.google.protobuf.SmallSortedMap$EmptySet$2 \
  4686. com.google.protobuf.SmallSortedMap$Entry \
  4687. com.google.protobuf.SmallSortedMap$EntryIterator \
  4688. com.google.protobuf.SmallSortedMap$EntrySet \
  4689. com.google.protobuf.SourceContext \
  4690. com.google.protobuf.SourceContext$1 \
  4691. com.google.protobuf.SourceContext$Builder \
  4692. com.google.protobuf.SourceContextOrBuilder \
  4693. com.google.protobuf.SourceContextProto \
  4694. com.google.protobuf.StringValue \
  4695. com.google.protobuf.StringValue$1 \
  4696. com.google.protobuf.StringValue$Builder \
  4697. com.google.protobuf.StringValueOrBuilder \
  4698. com.google.protobuf.Struct \
  4699. com.google.protobuf.Struct$1 \
  4700. com.google.protobuf.Struct$Builder \
  4701. com.google.protobuf.Struct$FieldsDefaultEntryHolder \
  4702. com.google.protobuf.StructOrBuilder \
  4703. com.google.protobuf.StructProto \
  4704. com.google.protobuf.StructuralMessageInfo \
  4705. com.google.protobuf.StructuralMessageInfo$Builder \
  4706. com.google.protobuf.Syntax \
  4707. com.google.protobuf.Syntax$1 \
  4708. com.google.protobuf.TextFormatEscaper \
  4709. com.google.protobuf.TextFormatEscaper$1 \
  4710. com.google.protobuf.TextFormatEscaper$2 \
  4711. com.google.protobuf.TextFormatEscaper$ByteSequence \
  4712. com.google.protobuf.Timestamp \
  4713. com.google.protobuf.Timestamp$1 \
  4714. com.google.protobuf.Timestamp$Builder \
  4715. com.google.protobuf.TimestampOrBuilder \
  4716. com.google.protobuf.TimestampProto \
  4717. com.google.protobuf.Type \
  4718. com.google.protobuf.Type$1 \
  4719. com.google.protobuf.Type$Builder \
  4720. com.google.protobuf.TypeOrBuilder \
  4721. com.google.protobuf.TypeProto \
  4722. com.google.protobuf.UInt32Value \
  4723. com.google.protobuf.UInt32Value$1 \
  4724. com.google.protobuf.UInt32Value$Builder \
  4725. com.google.protobuf.UInt32ValueOrBuilder \
  4726. com.google.protobuf.UInt64Value \
  4727. com.google.protobuf.UInt64Value$1 \
  4728. com.google.protobuf.UInt64Value$Builder \
  4729. com.google.protobuf.UInt64ValueOrBuilder \
  4730. com.google.protobuf.UninitializedMessageException \
  4731. com.google.protobuf.UnknownFieldSchema \
  4732. com.google.protobuf.UnknownFieldSetLite \
  4733. com.google.protobuf.UnknownFieldSetLiteSchema \
  4734. com.google.protobuf.UnmodifiableLazyStringList \
  4735. com.google.protobuf.UnmodifiableLazyStringList$1 \
  4736. com.google.protobuf.UnmodifiableLazyStringList$2 \
  4737. com.google.protobuf.UnsafeByteOperations \
  4738. com.google.protobuf.UnsafeUtil \
  4739. com.google.protobuf.UnsafeUtil$1 \
  4740. com.google.protobuf.UnsafeUtil$Android32MemoryAccessor \
  4741. com.google.protobuf.UnsafeUtil$Android64MemoryAccessor \
  4742. com.google.protobuf.UnsafeUtil$JvmMemoryAccessor \
  4743. com.google.protobuf.UnsafeUtil$MemoryAccessor \
  4744. com.google.protobuf.Utf8 \
  4745. com.google.protobuf.Utf8$DecodeUtil \
  4746. com.google.protobuf.Utf8$Processor \
  4747. com.google.protobuf.Utf8$SafeProcessor \
  4748. com.google.protobuf.Utf8$UnpairedSurrogateException \
  4749. com.google.protobuf.Utf8$UnsafeProcessor \
  4750. com.google.protobuf.Value \
  4751. com.google.protobuf.Value$1 \
  4752. com.google.protobuf.Value$Builder \
  4753. com.google.protobuf.Value$KindCase \
  4754. com.google.protobuf.ValueOrBuilder \
  4755. com.google.protobuf.WireFormat \
  4756. com.google.protobuf.WireFormat$1 \
  4757. com.google.protobuf.WireFormat$FieldType \
  4758. com.google.protobuf.WireFormat$FieldType$1 \
  4759. com.google.protobuf.WireFormat$FieldType$2 \
  4760. com.google.protobuf.WireFormat$FieldType$3 \
  4761. com.google.protobuf.WireFormat$FieldType$4 \
  4762. com.google.protobuf.WireFormat$JavaType \
  4763. com.google.protobuf.WireFormat$Utf8Validation \
  4764. com.google.protobuf.WireFormat$Utf8Validation$1 \
  4765. com.google.protobuf.WireFormat$Utf8Validation$2 \
  4766. com.google.protobuf.WireFormat$Utf8Validation$3 \
  4767. com.google.protobuf.WrappersProto \
  4768. com.google.protobuf.Writer \
  4769. com.google.protobuf.Writer$FieldOrder
  4770. # tag:java-specific
  4771. JAVA_IGNORE_CLASSPATH_CLASH_VALUE=$JAVA_IGNORE_CLASSPATH_CLASH_DEFAULE_VALUE
  4772. ### @usage: JAVA_IGNORE_CLASSPATH_CLASH_FOR([classes])
  4773. ### Ignore classpath clash test fails for classes
  4774. macro JAVA_IGNORE_CLASSPATH_CLASH_FOR(Args...) {
  4775. SET_APPEND(JAVA_IGNORE_CLASSPATH_CLASH_VALUE $Args $JAVA_IGNORE_CLASSPATH_CLASH_DEFAULE_VALUE)
  4776. }
  4777. IBTOOL_PATH=$XCODE_TOOLS_ROOT_RESOURCE_GLOBAL/Xcode/Contents/Developer/usr/bin/ibtool
  4778. # tag:src-processing
  4779. STORYBOARD_FLAGS=--errors --warnings --notices --auto-activate-custom-fonts --output-format human-readable-text
  4780. macro _SRC("storyboard", SRC, SRCFLAGS...) {
  4781. .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}
  4782. }
  4783. # tag:src-processing
  4784. macro _SRC("xib", SRC, SRCFLAGS...) {
  4785. .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}
  4786. }
  4787. ACTOOL_PATH=$XCODE_TOOLS_ROOT_RESOURCE_GLOBAL/Xcode/Contents/Developer/usr/bin/ibtool
  4788. # tag:ios-specific
  4789. ASSETS_FLAGS=--output-format human-readable-text --notices --warnings
  4790. macro _IOS_ASSETS(AssetsDir, Content...) {
  4791. .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
  4792. }
  4793. # tag:ios-specific
  4794. macro IOS_APP_COMMON_FLAGS(Flags...) {
  4795. SET_APPEND(STORYBOARD_FLAGS $Flags)
  4796. SET_APPEND(ASSETS_FLAGS $Flags)
  4797. }
  4798. # tag:ios-specific
  4799. macro IOS_APP_ASSETS_FLAGS(Flags...) {
  4800. SET_APPEND(ASSETS_FLAGS $Flags)
  4801. }
  4802. macro DARWIN_STRINGS_RESOURCE(Resource, Relpath) {
  4803. .CMD=$COPY_CMD ${input:Resource} $BINDIR/$Relpath && $YMAKE_PYTHON ${input:"build/scripts/tar_directory.py"} ${output;tobindir;suf=.strings_tar:Relpath} $BINDIR/$Relpath $BINDIR
  4804. }
  4805. macro DARWIN_SIGNED_RESOURCE(Resource, Relpath) {
  4806. .CMD=$COPY_CMD $Resource $BINDIR/$Relpath && $YMAKE_PYTHON ${input:"build/scripts/tar_directory.py"} ${output;tobindir;suf=.signed_resource_tar:Relpath} $BINDIR/$Relpath $BINDIR
  4807. }
  4808. # tag:ios-specific
  4809. DELIM=__DELIM__
  4810. 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
  4811. ### @usage: IOS_INTERFACE()
  4812. ### iOS GUI module definition
  4813. module IOS_INTERFACE: _BARE_UNIT {
  4814. .CMD=PACK_IOS_ARCHIVE
  4815. .EXTS=.compiled_storyboard_tar .partial_plist .plist .xcent .nib .resource_tar .signed_resource_tar .strings_tar .plist_json
  4816. .NODE_TYPE=Library
  4817. .FINAL_TARGET=no
  4818. SET(MODULE_SUFFIX .ios.interface)
  4819. PEERDIR+=build/platform/xcode/tools
  4820. }
  4821. # tag:ios-specific
  4822. module DEFAULT_IOS_INTERFACE: IOS_INTERFACE {
  4823. SET(MODULE_SUFFIX .default.ios.interface)
  4824. }
  4825. DEFAULT_IOS_TYPE=
  4826. IOS_TYPE=
  4827. when(!$IOS_TYPE) {
  4828. when($DEFAULT_IOS_TYPE) {
  4829. IOS_TYPE=$DEFAULT_IOS_TYPE
  4830. }
  4831. otherwise {
  4832. IOS_TYPE=com.apple.CoreSimulator.SimDeviceType.iPhone-X
  4833. }
  4834. }
  4835. DEFAULT_IOS_RUNTIME=
  4836. IOS_RUNTIME=
  4837. when(!$IOS_RUNTIME) {
  4838. when($DEFAULT_IOS_RUNTIME) {
  4839. IOS_RUNTIME=$DEFAULT_IOS_RUNTIME
  4840. }
  4841. otherwise {
  4842. IOS_RUNTIME=com.apple.CoreSimulator.SimRuntime.iOS-12-1
  4843. }
  4844. }
  4845. when ($ARCH_I386) {
  4846. TEST_IOS_DEVICE_TYPE_VALUE=com.apple.CoreSimulator.SimDeviceType.iPhone-5
  4847. TEST_IOS_RUNTIME_TYPE_VALUE=com.apple.CoreSimulator.SimRuntime.iOS-10-3
  4848. }
  4849. otherwise {
  4850. TEST_IOS_DEVICE_TYPE_VALUE=$IOS_TYPE
  4851. TEST_IOS_RUNTIME_TYPE_VALUE=$IOS_RUNTIME
  4852. }
  4853. # tag:frontend-specific
  4854. ### @usage: COLLECT_FRONTEND_FILES(Varname, Dir)
  4855. ###
  4856. ### Recursively collect files with typical frontend extensions from Dir and save the result into variable Varname
  4857. macro COLLECT_FRONTEND_FILES(Varname, Dir) {
  4858. _GLOB($Varname $Dir/**/*.(css|ejs|jpg|js|jsx|png|styl|svg|ts|tsx|json|html))
  4859. }
  4860. # tag:swift-specific
  4861. CPP_XCODE_TOOLCHAIN_VERSION=9.2
  4862. SWIFT_XCODE_TOOLCHAIN_VERSION=9.2
  4863. XCODE_TOOLS_VERSION=10.1
  4864. macro COMPILE_SWIFT_MODULE(SRCS{input}[], BRIDGE_HEADER{input}="", Flags...) {
  4865. when ($BRIDGE_HEADER != "") {
  4866. SWIFT_BRIDGE_HEADER=-import-objc-header ${input:BRIDGE_HEADER}
  4867. }
  4868. otherwise {
  4869. SWIFT_BRIDGE_HEADER=
  4870. }
  4871. .PEERDIR+=build/platform/xcode/swift
  4872. # swift core libraries
  4873. LDFLAGS($SWIFT_LD_FLAGS)
  4874. .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}
  4875. }
  4876. TEST_TOOL_HOST_LOCAL=
  4877. TEST_TOOL_TARGET_LOCAL=
  4878. when ($MOST_USED_CUDA) {
  4879. CUDA11=yes
  4880. }
  4881. when ($CUDA11) {
  4882. CUDA_VERSION=11.4
  4883. CUDNN_VERSION=8.0.5
  4884. TENSORRT_VERSION=7
  4885. }
  4886. when ($CUDA12) {
  4887. CUDA_VERSION=12.1
  4888. CUDNN_VERSION=8.6.0
  4889. TENSORRT_VERSION=8
  4890. }
  4891. when ($TENSORFLOW_WITH_CUDA) {
  4892. CUDA_REQUIRED=yes
  4893. }
  4894. when (!$TENSORRT_VERSION) {
  4895. TENSORRT_VERSION=5
  4896. }
  4897. ANDROID_APK_TEST_ACTIVITY_VALUE=com.yandex.test.unittests/.RunTestsActivity
  4898. # tag:windows-specific
  4899. WINDOWS_MANIFEST=
  4900. macro WINDOWS_MANIFEST(Manifest) {
  4901. SET(WINDOWS_MANIFEST $Manifest)
  4902. }
  4903. # https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation#enable-long-paths-in-windows-10-version-1607-and-later
  4904. macro WINDOWS_LONG_PATH_MANIFEST() {
  4905. SET(WINDOWS_MANIFEST build/long-path.manifest)
  4906. }
  4907. # tag:windows-specific
  4908. when ($MSVC == "yes" && $WINDOWS_MANIFEST) {
  4909. LDFLAGS+=/MANIFEST:EMBED /MANIFESTINPUT:${input:WINDOWS_MANIFEST}
  4910. }
  4911. # tag:cpp-specific
  4912. _VISIBILITY_LEVEL=
  4913. ### @usage: VISIBILITY(level)
  4914. ###
  4915. ### This macro sets visibility level for symbols compiled for the current module. 'level'
  4916. ### may take only one of the following values: DEFAULT, HIDDEN.
  4917. macro VISIBILITY(LEVEL) {
  4918. SET(_VISIBILITY_LEVEL ${LEVEL})
  4919. select ($LEVEL) {
  4920. "DEFAULT" | "HIDDEN" ? {
  4921. }
  4922. default ? {
  4923. _OK = no
  4924. }
  4925. }
  4926. ASSERT(_OK Unsupported value [$LEVEL] passed to VISIBILITY macro, expected values are DEFAULT, HIDDEN.)
  4927. }
  4928. # tag:cpp-specific
  4929. _CFLAGS_VISIBILITY=
  4930. when ($_VISIBILITY_LEVEL != "" && $IGNORE_VISIBILITY != "yes") {
  4931. when ($CLANG == "yes" || $GCC == "yes") {
  4932. _CFLAGS_VISIBILITY=-fvisibility=${tolower:_VISIBILITY_LEVEL}
  4933. }
  4934. }
  4935. CFLAGS+=$_CFLAGS_VISIBILITY
  4936. # tag:cpp-specific
  4937. macro SDBUS_CPP_ADAPTOR(File) {
  4938. .CMD=${tool:"contrib/libs/sdbus-cpp/tools/xml2cpp-codegen"} --adaptor=${output;nopath;noext:File.adaptor.h} ${input:File}
  4939. .PEERDIR=contrib/libs/sdbus-cpp
  4940. }
  4941. # tag:cpp-specific
  4942. macro SDBUS_CPP_PROXY(File) {
  4943. .CMD=${tool:"contrib/libs/sdbus-cpp/tools/xml2cpp-codegen"} --proxy=${output;nopath;noext:File.proxy.h} ${input:File}
  4944. .PEERDIR=contrib/libs/sdbus-cpp
  4945. }
  4946. # tag:python-specific
  4947. macro _PY_ENUM_SERIALIZATION_TO_JSON(File) {
  4948. .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"}
  4949. }
  4950. # tag:python-specific
  4951. macro _PY_ENUM_SERIALIZATION_TO_PY(File) {
  4952. .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"}
  4953. }
  4954. macro NGINX_MODULES(Modules...) {
  4955. PEERDIR(${Modules})
  4956. 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)
  4957. }
  4958. ### @usage: ORIGINAL_SOURCE(Source)
  4959. ###
  4960. ### This macro specifies the source repository for contrib
  4961. ### Does nothing now (just a placeholder for future functionality)
  4962. ### See https://st.yandex-team.ru/DTCC-316
  4963. macro ORIGINAL_SOURCE(Source) {
  4964. ENABLE(UNUSED_MACRO)
  4965. }
  4966. # tag:licence
  4967. CREDITS_FILE_EXTRA_EXT=
  4968. CREDITS_FLAGS=
  4969. CREDITS_TEXTS_FILE=
  4970. NO_CREDITS_TEXTS_FILE=
  4971. WITH_CREDITS=
  4972. ### @usage: LICENSE_TEXTS(File)
  4973. ###
  4974. ### This macro specifies the filename with all library licenses texts
  4975. macro LICENSE_TEXTS(Source) {
  4976. SET(CREDITS_TEXTS_FILE $Source)
  4977. }
  4978. # tag:licence
  4979. ### @usage: WITHOUT_LICENSE_TEXTS()
  4980. ###
  4981. ### This macro indicates that the module has no license text
  4982. macro WITHOUT_LICENSE_TEXTS() {
  4983. ENABLE(NO_CREDITS_TEXTS_FILE)
  4984. }
  4985. # tag:licence
  4986. when ($WITH_CREDITS) {
  4987. CREDITS_FLAGS+=--credits-output ${output;suf=${CREDITS_FILE_EXTRA_EXT}".CREDITS.txt":REALPRJNAME}
  4988. }
  4989. GENERATE_MF=
  4990. when ($WITH_CREDITS) {
  4991. GENERATE_MF=$GENERATE_MF_CMD
  4992. }
  4993. macro _MCU_CONVERT(Bin) {
  4994. .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}
  4995. }
  4996. MCU_LINK_EXE=$LINK_EXE && $_MCU_CONVERT($MODULE_PREFIX$REALPRJNAME)
  4997. ### @usage: MCU_PROGRAM([progname])
  4998. ###
  4999. ### Program module for microcontrollers. Converts ELF to Intel HEX, Motorola S-record and raw binary file formats.
  5000. ### If name is not specified it will be generated from the name of the containing project directory.
  5001. module MCU_PROGRAM: PROGRAM {
  5002. .CMD=MCU_LINK_EXE
  5003. }
  5004. # tag:flags tag:internal tag:windows-specific
  5005. ### @usage: _MSVC_FLAGS_WINDOWS_IMPL(target_platform compiler_flags) # internal
  5006. ###
  5007. ### Add CFLAGS when the firts argument is WINDOWS
  5008. macro _MSVC_FLAGS_WINDOWS_IMPL(WINDOWS[], FLAGS...) {
  5009. CFLAGS($WINDOWS)
  5010. }
  5011. # tag:flags tag:windows-specific tag:cpp-specific
  5012. ### @usage: MSVC_FLAGS([GLOBAL compiler_flag]* compiler_flags)
  5013. ###
  5014. ### Add the specified flags to the compilation line of C/C++files.
  5015. ### Flags apply only if the compiler used is MSVC (cl.exe)
  5016. macro MSVC_FLAGS(FLAGS...) {
  5017. _MSVC_FLAGS_WINDOWS_IMPL($TARGET_PLATFORM $FLAGS)
  5018. }
  5019. # tag:internal
  5020. ### Add passed ya.conf.json and all bottle's formula external files to resources
  5021. ### File MUST be arcadia root relative path (without "${ARCADIA_ROOT}/" prefix).
  5022. ### NOTE:
  5023. ### An external formula file referenced from ya.conf.json must be passed as an arcadia root relative path and
  5024. ### should be located in any subdirectory of the ya.conf.json location ("build/" if we consider a production).
  5025. ### The later restriction prevents problems in selectively checkouted arcadia.
  5026. macro YA_CONF_JSON(File) {
  5027. _YA_CONF_JSON($File)
  5028. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS ${ARCADIA_ROOT}/$File)
  5029. }
  5030. # tag:internal
  5031. # Don't use directly - wrap with custom macros
  5032. macro ADD_LINTER_CHECK(CheckName, Linter, DEPENDS[], EXCLUDE[], FILES[], CONFIGS[]) {
  5033. SET(_FILES_VAR uniq_${hash:VAR_SALT})
  5034. _GLOB($_FILES_VAR $FILES EXCLUDE $EXCLUDE)
  5035. _ADD_LINTER_CHECK($CheckName $Linter ${pre=DEPENDS :DEPENDS} FILES $$_FILES_VAR CONFIGS $CONFIGS)
  5036. }
  5037. # tag:internal
  5038. # Draft. Don't use.
  5039. macro _CPP_STYLE(EXCLUDE[], Files...) {
  5040. 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)
  5041. }
  5042. # tag:proto
  5043. macro ALICE_CAPABILITY() {
  5044. CPP_PROTO_PLUGIN(alice_capability_cpp yandex_io/tools/capability_gen .cap.h DEPS yandex_io/libs/protobuf_utils)
  5045. 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)
  5046. }
  5047. ### @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])
  5048. ###
  5049. ### 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... .
  5050. ### OPTS[] parameter is used to pass additional flags to clang. Parameters other than OPTS[] and SOURCES[] are used for runnig a generator (Tool):
  5051. ### - Tool - path to the directory of the tool
  5052. ### - Args... - Tool's arguments
  5053. ### - IN[] - input files required for running the Tool
  5054. ### - IN_NOPARSE[] - input files required for running the Tool, but these files are not parsed for dependencies
  5055. ### - TOOL[] - list of directories of axiliary tools used by Tool
  5056. ### - OUTPUT_INCLUDES[] - includes of the output files which are needed to "build" them
  5057. ### - STDOUT - redirect stdout of the Tool to the output file
  5058. ### - STDOUT_NOAUTO - redirect stdout of the Tool to the output file, but do not chain this file automatically to the processing queue
  5059. ### - CWD - path to the working directory of the Tool
  5060. ### Note: Generated AST files generated into BINDIR according to corresponding .cpp file names listed in SOURCES parameter.
  5061. 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...) {
  5062. .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"}
  5063. PEERDIR(build/platform/clang)
  5064. }