proto.conf 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994
  1. # tag:tool-specific tag:proto
  2. PROTOC=${tool:"contrib/tools/protoc"}
  3. PROTOC_OLD=${tool:"contrib/tools/protoc_old"}
  4. PY_PROTOC=${tool:"contrib/tools/protoc"}
  5. when ($PYTHON2 == "yes") {
  6. PY_PROTOC=${PROTOC_OLD}
  7. }
  8. JAVA_PROTOC=${tool:"build/platform/java/protoc"}
  9. when ($OPENSOURCE_REPLACE_PROTOBUF) {
  10. PROTOC_STYLEGUIDE_OUT=
  11. PROTOC_PLUGIN_STYLEGUIDE=
  12. PROTOBUF_INCLUDE_PATH="${protobuf_INCLUDE_DIRS}"
  13. DEFAULT_PROTOC_TOOLS=
  14. }
  15. otherwise {
  16. PROTOC_STYLEGUIDE_OUT=--cpp_styleguide_out=$ARCADIA_BUILD_ROOT/$PROTO_NAMESPACE
  17. PROTOC_PLUGIN_STYLEGUIDE=--plugin=protoc-gen-cpp_styleguide=${tool:"contrib/tools/protoc/plugins/cpp_styleguide"}
  18. PROTOBUF_INCLUDE_PATH=${ARCADIA_ROOT}/contrib/libs/protobuf/src
  19. PROTOBUF_OLD_PATH=${ARCADIA_ROOT}/contrib/libs/protobuf_old/src
  20. DEFAULT_PROTOC_TOOLS=${hide;tool:"contrib/tools/protoc/bin"} ${hide;tool:"contrib/tools/protoc/plugins/cpp_styleguide"}
  21. }
  22. USE_VANILLA_PROTOC=no
  23. PROTOC_TRANSITIVE_HEADERS=yes
  24. _PROTOC_FLAGS=
  25. # tag:proto
  26. PY_PROTOS_FOR=no
  27. BUILD_PROTO_AS_EVLOG=no
  28. # tag:proto
  29. PROTO_NAMESPACE=
  30. # tag:proto tag:python-specific
  31. GEN_PY_PROTOS=$YMAKE_PYTHON ${input:"build/scripts/gen_py_protos.py"} --py_ver ${_PYTHON_VER}
  32. # tag:proto tag:cpp-specific
  33. PROTO_HEADER_EXTS=.pb.h
  34. CPP_PROTO_CMDLINE=
  35. CPP_PROTO_OPTS=
  36. CPP_PROTO_OUTS=
  37. CPP_PROTO_OUTS_SEM=
  38. CPP_PROTO_SUFFIXES=.pb.h .pb.cc
  39. CPP_PROTO_PLUGINS=
  40. CPP_PROTO_NO_DBGINFO=no
  41. PROTOC_EXTRA_OUTS_SEM=
  42. # tag:proto tag:cpp-specific
  43. CPP_EV_OPTS=--plugin=protoc-gen-event2cpp=${tool:"tools/event2cpp"} --event2cpp_out=$ARCADIA_BUILD_ROOT -I=$ARCADIA_ROOT/library/cpp/eventlog
  44. CPP_EV_OUTS=
  45. CPP_EV_OUTS_SEM=
  46. # tag:proto tag:python-specific
  47. PY_PROTO_OPTS=
  48. PY_PROTO_OUTS=
  49. PY_PROTO_OUTS_INTERNAL=
  50. PY_PROTO_DEPS=
  51. PY_PROTO_SUFFIXES=_pb2.py
  52. PY_EVLOG_SUFFIXES=_ev_pb2.py
  53. # tag:proto tag:java-specific
  54. JAVA_PROTO_ARGS=
  55. # tag:proto tag:python-specific
  56. OPTIMIZE_PY_PROTOS_FLAG=no
  57. # tag:proto
  58. ### @usage: CPP_PROTOLIBS_DEBUG_INFO()
  59. ###
  60. ### Eqvivalent to NO_DEBUG_INFO() macro if the flag CPP_PROTO_NO_DBGINFO=yes
  61. macro CPP_PROTOLIBS_DEBUG_INFO() {
  62. SET(NO_DEBUGINFO $CPP_PROTO_NO_DBGINFO)
  63. }
  64. # tag:internal
  65. ### @usage: _ORDER_ADDINCL([BUILD ...] [SOURCE ...] Args...) # internal
  66. ###
  67. ### Order and filter ADDINCLs (Args - is intentionally omitted in ADDINCL macro)
  68. macro _ORDER_ADDINCL(BUILD[], SOURCE[], ARGS...) {
  69. ADDINCL($BUILD $SOURCE)
  70. }
  71. # tag:proto
  72. ### @usage: PROTO_ADDINCL([GLOBAL] [WITH_GEN] Path)
  73. ###
  74. ### This macro introduces proper ADDINCLs for .proto-files found in sources and
  75. ### .cpp/.h generated files, supplying them to appropriate commands and allowing
  76. ### proper dependency resolution at configure-time.
  77. ###
  78. ### Note: you normally shouldn't use this macro. ADDINCLs should be sent to user
  79. ### from dependency via PROTO_NAMESPACE macro
  80. macro PROTO_ADDINCL(GLOBAL?"GLOBAL":"", Path, WITH_GEN?"BUILD":"") {
  81. _ORDER_ADDINCL($WITH_GEN $GLOBAL FOR proto ${ARCADIA_BUILD_ROOT}/$Path SOURCE $GLOBAL FOR proto ${ARCADIA_ROOT}/$Path)
  82. ADDINCL($GLOBAL ${ARCADIA_BUILD_ROOT}/$Path)
  83. }
  84. # tag:proto
  85. ### @usage: PROTO_NAMESPACE([WITH_GEN] Namespace)
  86. ###
  87. ### Defines protobuf namespace (import/export path prefix) which should be used for imports and
  88. ### which defines output path for .proto generation.
  89. ###
  90. ### For proper importing and configure-time dependency management it sets ADDINCLs
  91. ### for both .cpp headers includes and .proto imports. If .proto expected to be used outside of the
  92. ### processing module use GLOBAL to send proper ADDINCLs to all (transitive) users. PEERDIR to
  93. ### PROTO_LIBRARY with PROTO_NAMESPACE() is enough at user side to correctly use the library.
  94. ### If generated .proto files are going to be used for building a module than use of WITH_GEN
  95. ### parameter will add appropriate dir from the build root for .proto files search.
  96. macro PROTO_NAMESPACE(GLOBAL?"GLOBAL":"", WITH_GEN?"WITH_GEN":"", Namespace) {
  97. SET(PROTO_NAMESPACE $Namespace)
  98. PROTO_ADDINCL(GLOBAL $WITH_GEN $Namespace)
  99. }
  100. # tag:proto
  101. ### @usage PROTOC_FATAL_WARNINGS()
  102. ###
  103. ### Treat protoc warnings as fatal errors that break the build, for example, unused imports
  104. ### Adds `--fatal_warnings` argument to protoc
  105. macro PROTOC_FATAL_WARNINGS() {
  106. SET_APPEND(_PROTOC_FLAGS --fatal_warnings)
  107. }
  108. # tag:proto tag:internal tag:python-specific
  109. ### @usage: OPTIMIZE_PY_PROTOS() # internal
  110. ###
  111. ### Enable Python proto optimization by embedding corresponding C++ code into binary.
  112. ### Python protobuf runtime will use C++ implementation instead of Python one if former is available.
  113. ### This is default mode for most PROTO_LIBRARY's and PY2_LIBRARY's, some system ones being exceptions.
  114. macro OPTIMIZE_PY_PROTOS() {
  115. SET(OPTIMIZE_PY_PROTOS_FLAG yes)
  116. }
  117. # tag:proto tag:python-specific
  118. ### @usage: NO_OPTIMIZE_PY_PROTOS()
  119. ###
  120. ### Disable Python proto optimization using embedding corresponding C++ code into binary.
  121. ### Python protobuf runtime will use C++ implementation instead of Python one if former is available.
  122. ### This is default mode only for some system libraries.
  123. macro NO_OPTIMIZE_PY_PROTOS() {
  124. SET(OPTIMIZE_PY_PROTOS_FLAG no)
  125. }
  126. # tag:proto tag:python-specific
  127. macro _PROTO_PLUGIN_ARGS_BASE(Name, Tool, OutParm...) {
  128. .CMD=--plugin=protoc-gen-${Name}=\${tool:"$Tool"} --${Name}_out=$ARCADIA_BUILD_ROOT/\$PROTO_NAMESPACE ${pre=--${Name}_opt=:OutParm}
  129. .SEM=$_SEM_IGNORED
  130. }
  131. # tag:proto tag:python-specific
  132. macro _ADD_PY_PROTO_OUT(Suf) {
  133. SET_APPEND(PY_PROTO_OUTS \${hide;noauto;output;norel;nopath;noext;suf=$Suf:File})
  134. SET_APPEND(PY_PROTO_OUTS_INTERNAL \${hide;noauto;output;norel;nopath;noext;suf=__int${_PYTHON_VER}__$Suf:File} \${hide;kv:"ext_out_name_for_\${nopath;noext;suf=__int${_PYTHON_VER}__$Suf:File} \${nopath;noext;suf=$Suf:File}"})
  135. # XXX fix variable expansion in plugins
  136. SET(PY_PROTO_SUFFIXES $PY_PROTO_SUFFIXES $Suf)
  137. }
  138. # tag:proto tag:python-specific
  139. ### @usage: PY_PROTO_PLUGIN(Name Ext Tool DEPS <Dependencies>)
  140. ###
  141. ### Define protoc plugin for python with given Name that emits extra output with provided Extension
  142. ### using Tool. Extra dependencies are passed via DEPS
  143. macro PY_PROTO_PLUGIN(NAME, EXT, TOOL, DEPS[]) {
  144. SET_APPEND(PY_PROTO_OPTS $_PROTO_PLUGIN_ARGS_BASE($NAME $TOOL))
  145. _ADD_PY_PROTO_OUT($EXT)
  146. # XXX fix variable expansion in plugins
  147. SET(PY_PROTO_DEPS $PY_PROTO_DEPS $DEPS)
  148. }
  149. # tag:proto tag:python-specific
  150. ### @usage: PY_PROTO_PLUGIN2(Name Ext1 Ext2 Tool DEPS <Dependencies>)
  151. ###
  152. ### Define protoc plugin for python with given Name that emits 2 extra outputs with provided Extensions
  153. ### using Tool. Extra dependencies are passed via DEPS
  154. macro PY_PROTO_PLUGIN2(NAME, EXT1, EXT2, TOOL, DEPS[]) {
  155. PY_PROTO_PLUGIN($NAME $EXT1 $TOOL DEPS $DEPS)
  156. _ADD_PY_PROTO_OUT($EXT2)
  157. }
  158. # tag:proto tag:java-specific
  159. macro _JAVA_PROTO_PLUGIN_ARGS_BASE(Name, Tool, OutParm...) {
  160. .CMD=--plugin=protoc-gen-${Name}=\${tool:"$Tool"} --${Name}_out=$ARCADIA_BUILD_ROOT/java_out
  161. .SEM=$_SEM_IGNORED
  162. }
  163. # tag:proto tag:java-specific
  164. ### @usage: JAVA_PROTO_PLUGIN(Name Tool DEPS <Dependencies>)
  165. ###
  166. ### Define protoc plugin for Java with given Name that emits extra outputs
  167. ### using Tool. Extra dependencies are passed via DEPS
  168. macro JAVA_PROTO_PLUGIN(NAME, TOOL, DEPS[]) {
  169. SET_APPEND(JAVA_PROTO_ARGS $_JAVA_PROTO_PLUGIN_ARGS_BASE($NAME $TOOL))
  170. # XXX fix variable expansion in plugins
  171. SET(JAVA_PROTOBUF_PEERS $JAVA_PROTOBUF_PEERS $DEPS)
  172. }
  173. macro _ADD_SEM_PROP_IF_NON_EMPTY(Prop, Args...) {
  174. .SEM=${pre=&& target_properties-ITEM && target_properties-name $Prop && target_properties-value :Args}
  175. }
  176. # tag:proto tag:java-specific
  177. _WITH_KOTLIN_GRPC_SEM=
  178. macro WITH_KOTLIN_GRPC() {
  179. ENABLE(KOTLIN_PROTO)
  180. PEERDIR(build/platform/java/kotlin_grpc)
  181. SET_APPEND(JAVA_PROTO_ARGS ${env:"JAVA_HOME=${JDK_RESOURCE}"} ${env:"KOTLIN_GRPC_JAR=${KOTLIN_GRPC_RESOURCE_GLOBAL}/grpc_kotlin/protoc-gen-grpc-kotlin-${KOTLIN_GRPC_VERSION}.jar"} --plugin=protoc-gen-kotlin_grpc=${KOTLIN_GRPC_RESOURCE_GLOBAL}/grpc_kotlin/grpc_kotlin --kotlin_grpc_out=$ARCADIA_BUILD_ROOT/java_out)
  182. SET(JAVA_PROTOBUF_PEERS $JAVA_PROTOBUF_PEERS contrib/java/io/grpc/grpc-kotlin-stub/$KOTLIN_GRPC_VERSION)
  183. SET(JAVA_PROTOBUF_PEERS $JAVA_PROTOBUF_PEERS contrib/java/com/google/protobuf/protobuf-kotlin/${JAVA_PROTO_RUNTIME_VERSION})
  184. SET(_WITH_KOTLIN_GRPC_SEM && proto_kotlin_grpc && proto_kotlin_grpc_version ${KOTLIN_GRPC_VERSION})
  185. }
  186. # tag:proto tag:cpp-specific
  187. macro _ADD_CPP_PROTO_OUT(Suf) {
  188. SET_APPEND(CPP_PROTO_OUTS \${output;norel;nopath;noext;suf=$Suf:File})
  189. SET_APPEND(PROTOC_EXTRA_OUTS_SEM && protoc_extra_outs $Suf \${hide;output;suf=.o:Suf} \$_ADD_SEM_PROP_IF_NON_EMPTY(PROTO_NAMESPACE $PROTO_NAMESPACE))
  190. # XXX fix variable expansion in plugins
  191. SET(CPP_PROTO_SUFFIXES $CPP_PROTO_SUFFIXES $Suf)
  192. }
  193. # tag:proto tag:cpp-specific
  194. HAS_CPP_PROTOBUF_PEERS=no
  195. CPP_PROTOBUF_PEERS=
  196. # tag:proto tag:cpp-specific
  197. ### @usage: CPP_PROTO_PLUGIN0(Name Tool [DEPS <Dependencies>] [EXTRA_OUT_FLAG <ExtraOutFlag>])
  198. ###
  199. ### Define protoc plugin for C++ with given Name that emits code into regular outputs
  200. ### using Tool. Extra dependencies are passed via DEPS.
  201. macro CPP_PROTO_PLUGIN0(NAME, TOOL, DEPS[], EXTRA_OUT_FLAG="") {
  202. .SEM=target_macroses-ITEM && target_macroses-macro target_proto_plugin && target_macroses-args $NAME ${tool;rootrel:TOOL} ${hide;output;suf=.fake.o:NAME}
  203. SET_APPEND(CPP_PROTO_OPTS $_PROTO_PLUGIN_ARGS_BASE($NAME $TOOL $EXTRA_OUT_FLAG))
  204. # XXX fix variable expansion in plugins
  205. ENABLE(HAS_CPP_PROTOBUF_PEERS)
  206. SET(CPP_PROTOBUF_PEERS $CPP_PROTOBUF_PEERS $DEPS)
  207. }
  208. # tag:proto tag:cpp-specific
  209. ### @usage: CPP_PROTO_PLUGIN(Name Tool Suf [DEPS <Dependencies>] [EXTRA_OUT_FLAG <ExtraOutFlag>])
  210. ###
  211. ### Define protoc plugin for C++ with given Name that emits code into 1 extra output
  212. ### using Tool. Extra dependencies are passed via DEPS.
  213. macro CPP_PROTO_PLUGIN(NAME, TOOL, SUF, DEPS[], EXTRA_OUT_FLAG="") {
  214. CPP_PROTO_PLUGIN0($NAME $TOOL DEPS $DEPS ${pre=EXTRA_OUT_FLAG :EXTRA_OUT_FLAG})
  215. _ADD_CPP_PROTO_OUT($SUF)
  216. }
  217. # tag:proto tag:cpp-specific
  218. ### @usage: CPP_PROTO_PLUGIN2(Name Tool Suf1 Suf2 [DEPS <Dependencies>] [EXTRA_OUT_FLAG <ExtraOutFlag>])
  219. ###
  220. ### Define protoc plugin for C++ with given Name that emits code into 2 extra outputs
  221. ### using Tool. Extra dependencies are passed via DEPS.
  222. macro CPP_PROTO_PLUGIN2(NAME, TOOL, SUF1, SUF2, DEPS[], EXTRA_OUT_FLAG="") {
  223. CPP_PROTO_PLUGIN($NAME $TOOL $SUF1 DEPS $DEPS ${pre=EXTRA_OUT_FLAG :EXTRA_OUT_FLAG})
  224. _ADD_CPP_PROTO_OUT($SUF2)
  225. SET_APPEND(CPP_PROTO_OUTS_SEM \${hide;output;norel;nopath;noext;suf=$SUF2:File})
  226. }
  227. # tag:proto
  228. ### @usage: USE_SKIFF() #wip, do not use
  229. ###
  230. ### Use mapreduce/yt/skiff_proto/plugin for C++
  231. macro USE_SKIFF() {
  232. # Move extra includes to INDUCED_DEPS macro in mapreduce/yt/skiff_proto/plugin/ya.make
  233. CPP_PROTO_PLUGIN0(skiff mapreduce/yt/skiff_proto/plugin DEPS mapreduce/yt/skiff_proto/lib)
  234. }
  235. # tag:go-specific
  236. _GO_COMMON_GOOGLE_APIS = \
  237. vendor/google.golang.org/genproto/googleapis/api/annotations \
  238. vendor/google.golang.org/genproto/googleapis/api/configchange \
  239. vendor/google.golang.org/genproto/googleapis/api/distribution \
  240. vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1 \
  241. vendor/google.golang.org/genproto/googleapis/api/expr/v1beta1 \
  242. vendor/google.golang.org/genproto/googleapis/api/httpbody \
  243. vendor/google.golang.org/genproto/googleapis/api/label \
  244. vendor/google.golang.org/genproto/googleapis/api/metric \
  245. vendor/google.golang.org/genproto/googleapis/api/monitoredres \
  246. vendor/google.golang.org/genproto/googleapis/api/serviceconfig \
  247. vendor/cloud.google.com/go/servicecontrol/apiv1/servicecontrolpb \
  248. vendor/cloud.google.com/go/servicemanagement/apiv1/servicemanagementpb \
  249. vendor/google.golang.org/genproto/googleapis/iam/admin/v1 \
  250. vendor/google.golang.org/genproto/googleapis/iam/credentials/v1 \
  251. vendor/google.golang.org/genproto/googleapis/iam/v1 \
  252. vendor/google.golang.org/genproto/googleapis/iam/v1/logging \
  253. vendor/google.golang.org/genproto/googleapis/logging/type \
  254. vendor/google.golang.org/genproto/googleapis/logging/v2 \
  255. vendor/google.golang.org/genproto/googleapis/rpc/code \
  256. vendor/google.golang.org/genproto/googleapis/rpc/errdetails \
  257. vendor/google.golang.org/genproto/googleapis/rpc/status \
  258. vendor/google.golang.org/genproto/googleapis/type/calendarperiod \
  259. vendor/google.golang.org/genproto/googleapis/type/color \
  260. vendor/google.golang.org/genproto/googleapis/type/date \
  261. vendor/google.golang.org/genproto/googleapis/type/date_range \
  262. vendor/google.golang.org/genproto/googleapis/type/datetime \
  263. vendor/google.golang.org/genproto/googleapis/type/date_time_range \
  264. vendor/google.golang.org/genproto/googleapis/type/dayofweek \
  265. vendor/google.golang.org/genproto/googleapis/type/decimal \
  266. vendor/google.golang.org/genproto/googleapis/type/expr \
  267. vendor/google.golang.org/genproto/googleapis/type/fraction \
  268. vendor/google.golang.org/genproto/googleapis/type/interval \
  269. vendor/google.golang.org/genproto/googleapis/type/latlng \
  270. vendor/google.golang.org/genproto/googleapis/type/localized_text \
  271. vendor/google.golang.org/genproto/googleapis/type/money \
  272. vendor/google.golang.org/genproto/googleapis/type/month \
  273. vendor/google.golang.org/genproto/googleapis/type/phone_number \
  274. vendor/google.golang.org/genproto/googleapis/type/postaladdress \
  275. vendor/google.golang.org/genproto/googleapis/type/quaternion \
  276. vendor/google.golang.org/genproto/googleapis/type/timeofday
  277. # tag:go-specific
  278. _COMMON_GOOGLE_APIS=None
  279. # tag:go-specific
  280. ### @usage: USE_COMMON_GOOGLE_APIS([apis...])
  281. ###
  282. ### Use common-google-apis library set. Pass optional apis list to be used or use them all.
  283. ### This macro is properly handled for all languages including Go, where apis come in
  284. ## pregenerated form. In other languages apis are generated from sources in Arcadia.
  285. macro USE_COMMON_GOOGLE_APIS(APIS...) {
  286. SET(_COMMON_GOOGLE_APIS ${pre=vendor/google.golang.org/genproto/googleapis/:APIS})
  287. }
  288. # tag:go-specific tag:proto
  289. GO_PROTO_GEN_PLUGINS=
  290. GO_PROTO_OPTS=
  291. GO_PROTO_OUTS=
  292. GO_PROTO_GRPC_OPTS=
  293. GO_PROTO_GRPC_OUTS=
  294. GO_PROTO_V2=no
  295. _GO_PROTO_CHECK_OUTPUT=
  296. # tag:go-specific tag:proto
  297. GO_PROTOBUF_IMPORTS=\
  298. ${GOSTD}/sync \
  299. ${GOSTD}/reflect \
  300. ${GOSTD}/fmt \
  301. ${GOSTD}/math \
  302. vendor/github.com/golang/protobuf/proto \
  303. vendor/google.golang.org/protobuf/types/descriptorpb \
  304. vendor/google.golang.org/protobuf/runtime/protoimpl \
  305. vendor/google.golang.org/protobuf/runtime/protoiface \
  306. vendor/google.golang.org/protobuf/reflect/protoreflect
  307. # tag:go-specific tag:proto
  308. GO_PROTOBUF_WELLKNOWN_TYPES=\
  309. vendor/google.golang.org/protobuf/types/known/anypb \
  310. vendor/google.golang.org/protobuf/types/known/apipb \
  311. vendor/google.golang.org/protobuf/types/known/durationpb \
  312. vendor/google.golang.org/protobuf/types/known/emptypb \
  313. vendor/google.golang.org/protobuf/types/known/fieldmaskpb \
  314. vendor/google.golang.org/protobuf/types/known/sourcecontextpb \
  315. vendor/google.golang.org/protobuf/types/known/structpb \
  316. vendor/google.golang.org/protobuf/types/known/timestamppb \
  317. vendor/google.golang.org/protobuf/types/known/typepb \
  318. vendor/google.golang.org/protobuf/types/known/wrapperspb
  319. # tag:go-specific tag:proto
  320. ### @usage: GO_PROTO_PLUGIN(Name Ext Tool [DEPS dependencies...])
  321. ###
  322. ### Define protoc plugin for GO with given Name that emits extra output with provided extension
  323. ### Ext using Tool. Extra dependencies are passed via DEPS.
  324. macro GO_PROTO_PLUGIN(NAME, EXT, TOOL, DEPS[]) {
  325. SET_APPEND(GO_PROTO_OPTS $_PROTO_PLUGIN_ARGS_BASE($NAME $TOOL))
  326. SET_APPEND(GO_PROTO_OUTS \${hide;noauto;output;norel;nopath;noext;suf=$EXT:File})
  327. PEERDIR(${DEPS})
  328. }
  329. # tag:go-specific tag:proto
  330. GO_PROTO_CMDLINE=${cwd;rootdir;input:File} $YMAKE_PYTHON3 ${input:"build/scripts/go_proto_wrapper.py"} --arcadia-prefix $GO_ARCADIA_PROJECT_PREFIX --contrib-prefix $GO_CONTRIB_PROJECT_PREFIX --namespace ./$PROTO_NAMESPACE $_GO_PROTO_CHECK_OUTPUT --proto ${input;rootrel:File} -- $PROTOC -I=./$PROTO_NAMESPACE -I=$ARCADIA_ROOT/$PROTO_NAMESPACE ${pre=-I=:_PROTO__INCLUDE} -I=$ARCADIA_BUILD_ROOT -I=$PROTOBUF_INCLUDE_PATH $_PROTOC_FLAGS ${hide:PROTO_FAKEID}
  331. # tag:go-specific tag:proto
  332. macro _GO_PROTO_CMD_IMPL(File, OPTS...) {
  333. .CMD=$GO_PROTO_CMDLINE $OPTS ${hide;kv:"p PB"} ${hide;kv:"pc yellow"}
  334. .PEERDIR=${GO_PROTOBUF_IMPORTS} ${GO_PROTOBUF_WELLKNOWN_TYPES}
  335. .ADDINCL=FOR proto ${PROTOBUF_INCLUDE_PATH}
  336. }
  337. # tag:go-specific tag:proto
  338. macro _GO_PROTO_CMD(File) {
  339. .CMD=$_GO_PROTO_CMD_IMPL($File $GO_PROTO_OPTS $GO_PROTO_OUTS)
  340. }
  341. # tag:proto
  342. ### @usage: YT_ORM_PROTO_YSON(Files... OUT_OPTS Opts...)
  343. ###
  344. ### Generate .yson.go from .proto using yt/yt/orm/go/codegen/yson/internal/proto-yson-gen/cmd/proto-yson-gen
  345. macro YT_ORM_PROTO_YSON(OUT_OPTS[], Files...) {
  346. .CMD=${cwd:BINDIR} $PROTOC --plugin=protoc-gen-custom=${tool:"yt/yt/orm/go/codegen/yson/internal/proto-yson-gen/cmd/proto-yson-gen"} -I=${ARCADIA_ROOT}/${PROTO_NAMESPACE} ${pre=-I=:_PROTO__INCLUDE} -I=${ARCADIA_ROOT} --custom_out="$OUT_OPTS paths=base_name:." --custom_opt="goroot=${GO_TOOLS_ROOT}" $_PROTOC_FLAGS ${input:Files} ${hide;noauto;output;nopath;noext;suf=.yson.go:Files} ${hide:PROTO_FAKEID}
  347. .ADDINCL=FOR proto ${ARCADIA_ROOT}/${MODDIR} FOR proto ${ARCADIA_ROOT}/${GO_TEST_IMPORT_PATH} FOR proto yt ${ARCADIA_BUILD_ROOT}/yt FOR proto ${PROTOBUF_INCLUDE_PATH}
  348. .PEERDIR=$GOSTD/strings $GOSTD/fmt $GOSTD/errors $GOSTD/encoding/json library/go/core/xerrors yt/go/yson yt/go/yterrors yt/yt/orm/go/codegen/yson/ytypes contrib/libs/protobuf
  349. }
  350. _SEM_CPP_PROTO_CMD=target_options-privates-ITEM && target_options-privates-option target_proto_messages && target_options-privates-args ${input:File} \
  351. $CPP_PROTO_OUTS_SEM ${hide;output;suf=${OBJ_SUF}.pb.o:File} $DEFAULT_PROTOC_TOOLS \
  352. $PROTOC_EXTRA_OUTS_SEM \
  353. && platform_vars-COMMON_PROTOC_FLAGS "" \
  354. && target_macroses-ITEM && target_macroses-macro target_proto_outs && target_macroses-args --cpp_out=$ARCADIA_BUILD_ROOT/$PROTO_NAMESPACE $PROTOC_STYLEGUIDE_OUT \
  355. && target_macroses-ITEM && target_macroses-macro target_proto_addincls && target_macroses-args ./$PROTO_NAMESPACE $ARCADIA_ROOT/$PROTO_NAMESPACE ${_PROTO__INCLUDE} $ARCADIA_BUILD_ROOT $PROTOBUF_INCLUDE_PATH
  356. # tag:proto
  357. macro _CPP_PROTO_CMD(File) {
  358. .CMD=$CPP_PROTO_CMDLINE $CPP_PROTO_OPTS ${hide;kv:"p PB"} ${hide;kv:"pc yellow"}
  359. .SEM=$_SEM_CPP_PROTO_CMD
  360. .PEERDIR=contrib/libs/protobuf
  361. }
  362. # tag:proto
  363. macro _CPP_VANILLA_PROTO_CMD(File) {
  364. .CMD=$CPP_PROTO_CMDLINE $CPP_PROTO_OPTS ${hide;kv:"p PB"} ${hide;kv:"pc yellow"}
  365. .PEERDIR=contrib/libs/protobuf_std
  366. }
  367. _SEM_CPP_EV_CMD=target_options-privates-ITEM && target_options-privates-option target_ev_messages && target_options-privates-args ${input:File} \
  368. $CPP_EV_OUTS_SEM ${hide;output;suf=${OBJ_SUF}.pb.o:File} ${hide;tool:"tools/event2cpp/bin"} $DEFAULT_PROTOC_TOOLS \
  369. && platform_vars-COMMON_PROTOC_FLAGS "" \
  370. && target_macroses-ITEM && target_macroses-macro target_proto_outs && target_macroses-args --cpp_out=$ARCADIA_BUILD_ROOT/$PROTO_NAMESPACE $PROTOC_STYLEGUIDE_OUT --event2cpp_out=$ARCADIA_BUILD_ROOT/$PROTO_NAMESPACE \
  371. && target_macroses-ITEM && target_macroses-macro target_proto_addincls && target_macroses-args ./$PROTO_NAMESPACE $ARCADIA_ROOT/$PROTO_NAMESPACE ${_PROTO__INCLUDE} $ARCADIA_BUILD_ROOT $PROTOBUF_INCLUDE_PATH $ARCADIA_ROOT/library/cpp/eventlog
  372. # tag:proto
  373. macro _CPP_EVLOG_CMD(File) {
  374. .CMD=$CPP_EV_CMDLINE $CPP_EV_OPTS ${hide;kv:"p EV"} ${hide;kv:"pc yellow"}
  375. .SEM=$_SEM_CPP_EV_CMD
  376. .PEERDIR=library/cpp/eventlog contrib/libs/protobuf
  377. }
  378. # tag:proto
  379. macro _CPP_PROTO_EVLOG_CMD(File) {
  380. # process .proto as .ev
  381. .CMD=$CPP_PROTO_CMDLINE $CPP_EV_OPTS ${hide;kv:"p PB"} ${hide;kv:"pc yellow"}
  382. .PEERDIR=library/cpp/eventlog contrib/libs/protobuf
  383. }
  384. # tag:proto
  385. macro _CPP_CFGPROTO_CMD(File) {
  386. # keep extension in output just as in EV: this is hard-coded behaviour of protoc for non-.proto extensions
  387. .CMD=$CPP_EV_CMDLINE --plugin=protoc-gen-config=${tool:"library/cpp/proto_config/plugin"} --config_out=$ARCADIA_BUILD_ROOT/$PROTO_NAMESPACE ${hide;kv:"p PB"} ${hide;kv:"pc yellow"}
  388. .PEERDIR=library/cpp/proto_config/codegen library/cpp/proto_config/protos contrib/libs/protobuf
  389. }
  390. # tag:proto
  391. PY_PROTO_MYPY_ENABLED=yes
  392. PY_PROTO_MYPY_PLUGIN_BASE=--plugin=protoc-gen-mypy=${tool:"contrib/python/mypy-protobuf/bin/protoc-gen-mypy"} --mypy_out=$ARCADIA_BUILD_ROOT/$PROTO_NAMESPACE
  393. # tag:proto tag:python-specific
  394. PY_PROTO_MYPY_SUFFIX=
  395. PY_PROTO_MYPY_PLUGIN=
  396. PY_PROTO_MYPY_PLUGIN_INTERNAL=
  397. # tag:proto tag:python-specific
  398. macro NO_MYPY() {
  399. DISABLE(PY_PROTO_MYPY_ENABLED)
  400. }
  401. # tag:proto tag:python-specific
  402. macro _PY_PROTO_CMD_BASE(File, Suf, Args...) {
  403. .CMD=$PY_PROTOC -I=./$PROTO_NAMESPACE -I=$ARCADIA_ROOT/$PROTO_NAMESPACE ${pre=-I=:_PROTO__INCLUDE} -I=$ARCADIA_BUILD_ROOT -I=$PROTOBUF_INCLUDE_PATH --python_out=$ARCADIA_BUILD_ROOT/$PROTO_NAMESPACE $_PROTOC_FLAGS ${input;rootrel:File} ${output;main;hide;noauto;norel;nopath;noext;suf=$Suf:File} ${hide;kv:"p PB"} ${hide;kv:"pc yellow"} $Args ${hide:PROTO_FAKEID}
  404. }
  405. # tag:proto tag:python-specific
  406. macro _PY_PROTO_CMD(File) {
  407. .CMD=${cwd;rootdir;input:File} $_PY_PROTO_CMD_BASE($File _pb2.py $PY_PROTO_OPTS $PY_PROTO_OUTS $PY_PROTO_MYPY_PLUGIN)
  408. }
  409. # tag:proto tag:python-specific
  410. macro _PY_PROTO_CMD_INTERNAL(File) {
  411. .CMD=${cwd;rootdir;input:File} $GEN_PY_PROTOS --suffixes $PY_PROTO_SUFFIXES $PY_PROTO_MYPY_SUFFIX --input ${input;rootrel:File} --ns /$PROTO_NAMESPACE -- $_PY_PROTO_CMD_BASE($File __int${_PYTHON_VER}___pb2.py $PY_PROTO_OPTS $PY_PROTO_OUTS_INTERNAL ${hide;kv:"ext_out_name_for_${nopath;noext;suf=__int${_PYTHON_VER}___pb2.py:File} ${nopath;noext;suf=_pb2.py:File}"} $PY_PROTO_MYPY_PLUGIN_INTERNAL)
  412. }
  413. # tag:proto tag:java-specific
  414. JAVA_PROTO_RUNTIME=
  415. # tag:proto tag:java-specific
  416. ### @usage: USE_JAVALITE()
  417. ### Use protobuf-javalite for Java
  418. macro USE_JAVALITE() {
  419. SET(JAVA_PROTO_RUNTIME javalite)
  420. }
  421. # tag:proto tag:java-specific
  422. JAVA_PROTO_COMPILER_VERSION = 3.25.5
  423. JAVA_PROTO_RUNTIME_VERSION = 3.25.5
  424. JAVA_PROTO_COMMON_VERSION = 2.9.0
  425. JAVA_GRPC_VERSION = 1.51.0
  426. KOTLIN_GRPC_VERSION = 1.3.1
  427. JAVA_NETTY_NETTY_VERSION = 4.1.79.Final
  428. KOTLIN_PROTO=no
  429. KOTLIN_PROTO_PEERS=
  430. when ($JAVA_PROTO_RUNTIME == "javalite") {
  431. _JAVA_PROTO_LITE_ARG=lite:
  432. JAVA_PROTOBUF_PEERS=contrib/java/com/google/protobuf/protobuf-javalite/${JAVA_PROTO_RUNTIME_VERSION} ${KOTLIN_PROTO_PEERS}
  433. JAVA_GRPC_STUB=contrib/java/io/grpc/grpc-stub/${JAVA_GRPC_VERSION}
  434. JAVA_GRPC_PROTOBUF=contrib/java/io/grpc/grpc-protobuf/${JAVA_GRPC_VERSION}
  435. }
  436. otherwise {
  437. _JAVA_PROTO_LITE_ARG=
  438. JAVA_PROTOBUF_PEERS=contrib/java/com/google/protobuf/protobuf-java/${JAVA_PROTO_RUNTIME_VERSION} ${KOTLIN_PROTO_PEERS}
  439. JAVA_GRPC_STUB=contrib/java/io/grpc/grpc-stub/${JAVA_GRPC_VERSION}
  440. JAVA_GRPC_PROTOBUF=contrib/java/io/grpc/grpc-protobuf/${JAVA_GRPC_VERSION}
  441. }
  442. KOTLIN_PROTO_FLAGS=
  443. # tag:proto tag:java-specific
  444. macro _JAVA_PROTO_CMD(File) {
  445. .CMD=${cwd;rootdir;input:File} $YMAKE_PYTHON ${input:"build/scripts/tared_protoc.py"} --tar-output ${output;norel;nopath;noext;suf=.jsrc:File} --protoc-out-dir $ARCADIA_BUILD_ROOT/java_out $JAVA_PROTOC -I=./$PROTO_NAMESPACE ${pre=-I=:_PROTO__INCLUDE} -I=$ARCADIA_ROOT --java_out=${_JAVA_PROTO_LITE_ARG}$ARCADIA_BUILD_ROOT/java_out ${KOTLIN_PROTO_FLAGS} $_PROTOC_FLAGS ${input;rootrel:File} ${hide;kv:"p PB"} ${hide;kv:"pc yellow"} $JAVA_PROTO_ARGS ${hide:PROTO_FAKEID}
  446. .SEM=proto_files ${input;rootrel:File} ${hide;output:File.jsrc}
  447. }
  448. # tag:proto tag:python-specific
  449. when ($PY_PROTOS_FOR == "yes") {
  450. PEERDIR+=contrib/libs/protobuf/python
  451. }
  452. # tag:python-specific
  453. macro _PY_EVLOG_CMD_BASE(File, Suf, Args...) {
  454. .CMD=$_PY_PROTO_CMD_BASE($File $Suf $Args)
  455. .PEERDIR=library/cpp/eventlog/proto
  456. }
  457. # tag:python-specific tag:proto
  458. macro _PY_EVLOG_CMD(File) {
  459. .CMD=${cwd;rootdir;input:File} $_PY_EVLOG_CMD_BASE($File _ev_pb2.py)
  460. }
  461. # tag:python-specific tag:proto
  462. macro _PY_EVLOG_CMD_INTERNAL(File) {
  463. .CMD=${cwd;rootdir;input:File} $GEN_PY_PROTOS --suffixes $PY_EVLOG_SUFFIXES --input ${input;rootrel:File} --ns /$PROTO_NAMESPACE -- $_PY_EVLOG_CMD_BASE($File __int${_PYTHON_VER}___ev_pb2.py ${hide;kv:"ext_out_name_for_${nopath;noext;suf=__int${_PYTHON_VER}___ev_pb2.py:File} ${nopath;noext;suf=_ev_pb2.py:File}"})
  464. }
  465. # tag:java-specific tag:proto
  466. macro _JAVA_EVLOG_CMD(File) {
  467. .CMD=$COPY_CMD ${input:File} ${output;nopath;noext;norel;suf=_ev.proto:File} ${hide;kv:"p EV"} ${hide;kv:"pc yellow"}
  468. .PEERDIR=library/cpp/eventlog/proto
  469. }
  470. # tag:proto tag:grpc
  471. _GRPC_ENABLED=no
  472. _GRPC_SUF_CC=.grpc.pb.cc
  473. _GRPC_SUF_H=.grpc.pb.h
  474. # tag:proto tag:grpc
  475. ### @usage: GRPC()
  476. ###
  477. ### Emit GRPC code for all .proto files in a PROTO_LIBRARY.
  478. ### This works for all available PROTO_LIBRARY versions (C++, Python 2.x, Python 3.x, Java and Go).
  479. macro GRPC() {
  480. ENABLE(_GRPC_ENABLED)
  481. # C++
  482. CPP_PROTO_PLUGIN2(grpc_cpp contrib/tools/protoc/plugins/grpc_cpp $_GRPC_SUF_CC $_GRPC_SUF_H DEPS contrib/libs/grpc $_GRPC_GMOCK_OUTFLAG)
  483. # Python
  484. PY_PROTO_PLUGIN(grpc_py _pb2_grpc.py contrib/tools/protoc/plugins/grpc_python DEPS contrib/python/grpcio)
  485. # Java
  486. JAVA_PROTO_PLUGIN(grpc_java build/platform/java/grpc DEPS $JAVA_GRPC_STUB $JAVA_GRPC_PROTOBUF)
  487. SET_APPEND(JAVA_PROTOBUF_PEERS contrib/java/javax/annotation/javax.annotation-api/1.3.1)
  488. }
  489. # tag:proto tag:grpc
  490. _GRPC_GMOCK_OUTFLAG=
  491. # tag:proto tag:grpc
  492. ### @usage: GRPC_WITH_GMOCK()
  493. ###
  494. ### Enable generating *_mock.grpc.pb.cc/h files
  495. macro GRPC_WITH_GMOCK() {
  496. SET(_GRPC_GMOCK_OUTFLAG EXTRA_OUT_FLAG generate_mock_code=true)
  497. GRPC()
  498. _ADD_CPP_PROTO_OUT(_mock$_GRPC_SUF_H)
  499. SET_APPEND(CPP_PROTO_OUTS_SEM ${hide;output;norel;nopath;noext;suf=_mock$_GRPC_SUF_H:File})
  500. }
  501. macro GO_PROTO_USE_V2() {
  502. ENABLE(GO_PROTO_V2)
  503. }
  504. # tag:proto
  505. ### @usage: RESOLVE_PROTO()
  506. ###
  507. ### Enable include resolving within UNIONs and let system .proto being resolved
  508. ### among .proto/.gztproto imports
  509. ###
  510. ### Note: it is currently impossible to enable resolving only for .proto, so resolving is enabled for all supported files
  511. ### also we only add ADDINCL for stock protobuf. So use this macro with care: it may cause resolving problems those are
  512. ### to be addressed by either ADDINCLs or marking them as TEXT. Please contact devtools for details.
  513. macro RESOLVE_PROTO() {
  514. SET(DONT_RESOLVE_INCLUDES no)
  515. ADDINCL(FOR proto $PROTOBUF_INCLUDE_PATH)
  516. }
  517. # tag:python-specific tag:proto tag:deprecated
  518. ### @usage GENERATE_PY_PROTOS(ProtoFiles...) # deprecated
  519. ###
  520. ### Generate python bindings for protobuf files.
  521. ### Macro is obsolete and not recommended for use!
  522. macro GENERATE_PY_PROTOS(FILES...) {
  523. foreach (FILE : $FILES) {
  524. _PY_PROTO_CMD($FILE)
  525. }
  526. }
  527. # tag:python-specific tag:proto
  528. macro _GENERATE_PY_PROTOS_INTERNAL(FILES...) {
  529. foreach (FILE : $FILES) {
  530. _PY_PROTO_CMD_INTERNAL($FILE)
  531. }
  532. }
  533. # tag:python-specific
  534. macro _GENERATE_PY_EVS_INTERNAL(FILES...) {
  535. foreach (FILE : $FILES) {
  536. _PY_EVLOG_CMD_INTERNAL($FILE)
  537. }
  538. }
  539. ### @usage: LIST_PROTO([TO list.proto] Files...) # deprecated
  540. ###
  541. ### Create list of .proto files in a list-file (should be .proto, files.proto by default)
  542. ### with original .proto-files as list's dependencies.
  543. ###
  544. ### This allows to process files listed, passing list as an argument to the processor
  545. ###
  546. ### TODO: proper implementation needed
  547. macro LIST_PROTO(TO="files.proto", Files...) {
  548. .CMD=$YMAKE_PYTHON3 ${input:"build/scripts/list.py"} ${Files} ${hide;input:Files} ${stdout;noauto;output:TO} ${output_include;from_input;hide:Files}
  549. _COMPILE_LIST_PROTO(${TO})
  550. _EXPOSE(${TO})
  551. }
  552. macro _COMPILE_LIST_PROTO(SRC) {
  553. .CMD=$YMAKE_PYTHON ${input:"build/scripts/touch.py"} ${hide;input:SRC} ${output;noext;suf=.pb.h:SRC}
  554. }
  555. # tag:proto
  556. macro _PROTO_DESC_RAWPROTO_CMD(File) {
  557. .CMD=${cwd;rootdir;input:File} $YMAKE_PYTHON3 ${input:"build/scripts/desc_rawproto_wrapper.py"} --desc-output ${output;suf=.desc:File} --rawproto-output ${output;norel;suf=.${_MODDIR_HASH}.rawproto:File} --proto-file ${input;rootrel:File} -- $PROTOC -I=./$PROTO_NAMESPACE -I=$ARCADIA_ROOT/$PROTO_NAMESPACE ${pre=-I=:_PROTO__INCLUDE} -I=$ARCADIA_BUILD_ROOT -I=$PROTOBUF_INCLUDE_PATH --include_source_info $_PROTOC_FLAGS ${hide:PROTO_FAKEID}
  558. }
  559. _PROTO_DESC_MERGE_CMD=$YMAKE_PYTHON3 ${input:"build/scripts/merge_files.py"} $TARGET ${ext=.desc:AUTO_INPUT} ${hide;kv:"p PD"} ${hide;kv:"pc light-cyan"} && ${cwd:ARCADIA_BUILD_ROOT} $YMAKE_PYTHON3 ${input:"build/scripts/collect_rawproto.py"} --output ${output;suf=.protosrc:REALPRJNAME} ${rootrel;ext=.rawproto:AUTO_INPUT}
  560. _PROTO_DESC_MERGE_PEERS_CMD=$YMAKE_PYTHON3 ${input:"build/scripts/merge_files.py"} $TARGET $PEERS ${ext=.protodesc:SRCS_GLOBAL} ${hide;kv:"p PD"} ${hide;kv:"pc light-cyan"} && ${cwd:ARCADIA_BUILD_ROOT} $YMAKE_PYTHON3 ${input:"build/scripts/merge_protosrc.py"} --output ${output;suf=.tar:REALPRJNAME} ${rootrel:PEERS}
  561. NEED_GOOGLE_PROTO_PEERDIRS=yes
  562. _CPP_PROTO_LIBRARY_SEM=$_CPP_LIBRARY_SEM
  563. _JAVA_PROTO_LIBRARY_SEM=$_BUILD_PROTO_JAR_SEM $_GRADLE_EXPORT_PUBLISHING_SEM
  564. module _CPP_PROTO : LIBRARY {
  565. .ALLOWED=_EXPOSE LIST_PROTO
  566. FORCE_COVERAGE_DISABLED=yes
  567. ENABLE(CPP_PROTO)
  568. ENABLE(GEN_PROTO)
  569. NO_CLANG_TIDY()
  570. CPP_PROTOLIBS_DEBUG_INFO()
  571. SET(PEERDIR_TAGS)
  572. when ($BUILD_PROTO_AS_EVLOG == "yes" && $USE_VANILLA_PROTOC == "yes") {
  573. _OK=no
  574. }
  575. ASSERT(_OK BUILD_PROTO_AS_EVLOG and USE_VANILLA_PROTOC are incompatible yet)
  576. MODULE_SUFFIX=$_CPP_PROTO_MODULE_SUFFIX
  577. MODULE_PREFIX=$_CPP_PROTO_MODULE_PREFIX
  578. when ($_COMMON_GOOGLE_APIS != "None") {
  579. PEERDIR += contrib/libs/googleapis-common-protos
  580. }
  581. }
  582. _WITH_KOTLIN_PROTO_SEM=
  583. _DO_WITH_KOTLIN_PROTO_SEM=&& with_kotlin && kotlin_version ${_KOTLIN_VERSION} && proto_kotlin
  584. module _JAVA_PROTO: EXTERNAL_JAVA_LIBRARY {
  585. .EXTS=.jsrc
  586. .ALLOWED=GRPC
  587. SET(PEERDIR_TAGS JAVA)
  588. ENABLE(JAVA_PROTO)
  589. DISABLE(_NEED_SBOM_INFO)
  590. PEERDIR+=$JAVA_PROTOBUF_PEERS
  591. when ($KOTLIN_PROTO == "yes") {
  592. KOTLIN_PROTO_PEERS=contrib/java/com/google/protobuf/protobuf-kotlin/${JAVA_PROTO_RUNTIME_VERSION}
  593. KOTLIN_PROTO_FLAGS=--kotlin_out=$ARCADIA_BUILD_ROOT/java_out
  594. _WITH_KOTLIN_PROTO_SEM=$_DO_WITH_KOTLIN_PROTO_SEM
  595. }
  596. when ($GRADLE_EXPORT_PUBLISHING == "yes") {
  597. _GRADLE_EXPORT_PUBLISHING_SEM=$_DO_GRADLE_EXPORT_PUBLISHING_SEM
  598. }
  599. .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER USE_SKIFF CPP_PROTO_PLUGIN2 PY_PROTO_PLUGIN YMAPS_SPROTO RESOURCE
  600. ADDINCL(FOR proto $PROTOBUF_INCLUDE_PATH)
  601. when ($_COMMON_GOOGLE_APIS != "None") {
  602. PEERDIR += contrib/java/com/google/api/grpc/proto-google-common-protos/${JAVA_PROTO_COMMON_VERSION}
  603. ADDINCL += GLOBAL FOR proto ${ARCADIA_ROOT}/contrib/libs/googleapis-common-protos
  604. }
  605. }
  606. module _PY_PROTO: PY2_LIBRARY {
  607. .ALIASES=SRCS=PY_SRCS
  608. .ALLOWED=OPTIMIZE_PY_PROTOS NO_OPTIMIZE_PY_PROTOS
  609. SET(PEERDIR_TAGS PY2)
  610. ENABLE(PY_PROTO)
  611. DISABLE(_NEED_SBOM_INFO)
  612. OPTIMIZE_PY_PROTOS()
  613. OBJ_SUF=.py2
  614. # Can not use NO_LINT(), because is not allowed outside of contrib directory
  615. SET(_NO_LINT_VALUE none_internal)
  616. when ($_COMMON_GOOGLE_APIS != "None") {
  617. PEERDIR += contrib/libs/googleapis-common-protos
  618. }
  619. _IGNORE_SELF_PEERS=
  620. _CPP_PROTO_LIBRARY=${MODDIR}/$_CPP_PROTO_MODULE_PREFIX$REALPRJNAME$_CPP_PROTO_MODULE_SUFFIX
  621. when ($OPTIMIZE_PY_PROTOS_FLAG == "no") {
  622. _IGNORE_PEERDIRSELF=CPP_PROTO
  623. }
  624. SET_APPEND(_WHOLE_ARCHIVE_LIBS_VALUE_GLOBAL $_CPP_PROTO_LIBRARY)
  625. }
  626. module _PY3_PROTO: PY3_LIBRARY {
  627. .ALIASES=SRCS=PY_SRCS
  628. .ALLOWED=OPTIMIZE_PY_PROTOS NO_OPTIMIZE_PY_PROTOS
  629. SET(PEERDIR_TAGS PY3)
  630. ENABLE(PY3_PROTO)
  631. DISABLE(_NEED_SBOM_INFO)
  632. OPTIMIZE_PY_PROTOS()
  633. OBJ_SUF=.py3
  634. # Can not use NO_LINT(), because is not allowed outside of contrib directory
  635. SET(_NO_LINT_VALUE none_internal)
  636. when ($_COMMON_GOOGLE_APIS != "None") {
  637. PEERDIR += contrib/libs/googleapis-common-protos
  638. }
  639. _IGNORE_SELF_PEERS=
  640. _CPP_PROTO_LIBRARY=${MODDIR}/$_CPP_PROTO_MODULE_PREFIX$REALPRJNAME$_CPP_PROTO_MODULE_SUFFIX
  641. when ($OPTIMIZE_PY_PROTOS_FLAG == "no") {
  642. _IGNORE_PEERDIRSELF=CPP_PROTO
  643. }
  644. SET_APPEND(_WHOLE_ARCHIVE_LIBS_VALUE_GLOBAL $_CPP_PROTO_LIBRARY)
  645. }
  646. module _GO_PROTO: GO_LIBRARY {
  647. .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER YMAPS_SPROTO
  648. SET(PEERDIR_TAGS GO)
  649. ENABLE(GO_PROTO)
  650. when ($_COMMON_GOOGLE_APIS == "None") {
  651. }
  652. elsewhen ($_COMMON_GOOGLE_APIS == "") {
  653. PEERDIR += $_GO_COMMON_GOOGLE_APIS
  654. ADDINCL += GLOBAL FOR proto ${ARCADIA_ROOT}/contrib/libs/googleapis-common-protos
  655. }
  656. otherwise {
  657. PEERDIR += $_COMMON_GOOGLE_APIS
  658. ADDINCL += GLOBAL FOR proto ${ARCADIA_ROOT}/contrib/libs/googleapis-common-protos
  659. }
  660. }
  661. module _TS_PROTO: _TS_PROTO_IMPL {
  662. DISABLE(_NEED_SBOM_INFO)
  663. }
  664. module _TS_PREPARE_DEPS: _PREPARE_DEPS_BASE {
  665. .IGNORED=PEERDIR
  666. DISABLE(_NEED_SBOM_INFO)
  667. }
  668. module _DESC_PROTO: _BARE_UNIT {
  669. .CMD=_PROTO_DESC_MERGE_CMD
  670. .EXTS=.desc .rawproto
  671. .NODE_TYPE=Library
  672. .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER YMAPS_SPROTO RESOURCE GO_PROTO_PLUGIN GRPC
  673. .ALIASES=SRCS=_SRCS_NO_GLOBAL
  674. ENABLE(DESC_PROTO)
  675. DISABLE(_NEED_SBOM_INFO)
  676. MODULE_SUFFIX=.self.protodesc
  677. SET(MODULE_TYPE LIBRARY)
  678. SET(_MODDIR_HASH ${hash:MODDIR})
  679. _EVLOG_CMDLINE=$_PROTO_DESC_CMDLINE
  680. _PROTO_CMDLINE=$_PROTO_DESC_CMDLINE
  681. when ($_COMMON_GOOGLE_APIS != "None") {
  682. PEERDIR += contrib/libs/googleapis-common-protos
  683. }
  684. when ($NEED_GOOGLE_PROTO_PEERDIRS == "yes") {
  685. when ($USE_VANILLA_PROTOC == "yes") {
  686. PEERDIR += contrib/libs/protobuf_std/builtin_proto/protos_from_protobuf
  687. }
  688. otherwise {
  689. PEERDIR += contrib/libs/protobuf/builtin_proto/protos_from_protoc
  690. }
  691. }
  692. }
  693. # tag:proto
  694. ### @usage: PROTO_LIBRARY()
  695. ###
  696. ### Build some varian of protocol buffers library.
  697. ###
  698. ### The particular variant is selected based on where PEERDIR to PROTO_LIBRARY comes from.
  699. ###
  700. ### Now supported 5 variants: C++, Java, Python 2.x, Python 3.x and Go.
  701. ### When PEERDIR comes from module for particular language appropriate variant is selected.
  702. ### PROTO_LIBRARY also supports emission of GRPC code if GRPC() macro is specified.
  703. ### Notes:
  704. ### - Python versions emit C++ code in addition to Python as optimization.
  705. ### - In some PROTO_LIBRARY-es Java or Python versions are excluded via EXCLUDE_TAGS macros due to incompatibilities.
  706. ### - Use from DEPENDS or BUNDLE is not allowed
  707. ###
  708. ### Documentation: https://wiki.yandex-team.ru/yatool/proto_library/
  709. ###
  710. ### See: [GRPC()](#macro_GRPC), [OPTIMIZE_PY_PROTOS()](#macro_OPTIMIZE_PY_PROTOS), [INCLUDE_TAGS()](#macro_INCLUDE_TAGS), [EXCLUDE_TAGS()](#macro_EXCLUDE_TAGS)
  711. multimodule PROTO_LIBRARY {
  712. module CPP_PROTO: _CPP_PROTO {
  713. # TODO(svidyuk): think about marker which forces semantics inheritance
  714. .SEM=_CPP_PROTO_LIBRARY_SEM
  715. .GLOBAL_SEM=_CPP_PROTO_LIBRARY_SEM
  716. SET_APPEND(PEERDIR_TAGS CPP_PROTO)
  717. }
  718. module JAVA_PROTO: _JAVA_PROTO {
  719. .SEM=_JAVA_PROTO_LIBRARY_SEM
  720. .GLOBAL_SEM=_JAVA_PROTO_LIBRARY_SEM
  721. SET_APPEND(PEERDIR_TAGS JAVA_PROTO)
  722. }
  723. module PY_PROTO: _PY_PROTO {
  724. .SEM=_SEM_IGNORED
  725. SET_APPEND(PEERDIR_TAGS PY_PROTO)
  726. .PEERDIRSELF=CPP_PROTO
  727. DISABLE(START_TARGET)
  728. }
  729. module PY3_PROTO: _PY3_PROTO {
  730. .SEM=_SEM_IGNORED
  731. SET_APPEND(PEERDIR_TAGS PY3_PROTO)
  732. .PEERDIRSELF=CPP_PROTO
  733. }
  734. module GO_PROTO: _GO_PROTO {
  735. .SEM=_SEM_IGNORED
  736. SET_APPEND(PEERDIR_TAGS GO_PROTO)
  737. }
  738. module TS_PROTO: _TS_PROTO {
  739. .SEM=_SEM_IGNORED
  740. # opt-in. We don't want to have TS_PROTO by default
  741. # To include TS_PROTO user have to set INCLUDE_TAGS(TS_PROTO TS_PREPARE_DEPS) in ya.make
  742. .INCLUDE_TAG=no
  743. .PEERDIRSELF=TS_PREPARE_DEPS
  744. .EPILOGUE=_TS_CONFIG_EPILOGUE
  745. SET_APPEND(PEERDIR_TAGS TS_PROTO)
  746. }
  747. module TS_PREPARE_DEPS: _TS_PREPARE_DEPS {
  748. .SEM=_SEM_IGNORED
  749. .INCLUDE_TAG=no
  750. SET_APPEND(PEERDIR_TAGS TS_PREPARE_DEPS)
  751. }
  752. module DESC_PROTO: _DESC_PROTO {
  753. .SEM=_SEM_IGNORED
  754. SET_APPEND(PEERDIR_TAGS DESC_PROTO)
  755. }
  756. }
  757. module PROTO_DESCRIPTIONS: _BARE_UNIT {
  758. .CMD=_PROTO_DESC_MERGE_PEERS_CMD
  759. .PEERDIR_POLICY=as_build_from
  760. .NODE_TYPE=Library
  761. .RESTRICTED=SRCS
  762. .FINAL_TARGET=yes
  763. SET(MODULE_TAG PROTO_DESCRIPTIONS)
  764. SET(PEERDIR_TAGS DESC_PROTO DESC_PROTO_FROM_SCHEMA)
  765. SET(MODULE_SUFFIX .protodesc)
  766. SET(MODULE_TYPE PROTO_DESCRIPTIONS)
  767. }
  768. module PROTO_REGISTRY: PROTO_DESCRIPTIONS {
  769. SET(MODULE_TAG PROTO_REGISTRY)
  770. SET(MODULE_TYPE PROTO_REGISTRY)
  771. }
  772. # tag:proto
  773. ### @usage: PROTO_SCHEMA()
  774. ###
  775. ### Build some variant of protocol buffers library or proto descriptions.
  776. ###
  777. ### When used as a PEERDIR from a language module like GO_PROGRAM it behaves like PROTO_LIBRARY.
  778. ### When built directly it produces proto descriptions. When required by RECURSE it produces
  779. ### both proto descriptions and language libraries.
  780. ### PROTO_SCHEMA can depend on PROTO_LIBRARY, but PROTO_LIBRARY cannot depend on PROTO_SCHEMA.
  781. ###
  782. ### See: [PROTO_LIBRARY()](#module_PROTO_LIBRARY)
  783. multimodule PROTO_SCHEMA {
  784. module CPP_PROTO_FROM_SCHEMA: _CPP_PROTO {
  785. # TODO(svidyuk): think about marker which forces semantics inheritance
  786. .SEM=_CPP_PROTO_LIBRARY_SEM
  787. .GLOBAL_SEM=_CPP_PROTO_LIBRARY_SEM
  788. DISABLE(START_TARGET)
  789. SET_APPEND(PEERDIR_TAGS CPP_PROTO CPP_PROTO_FROM_SCHEMA)
  790. }
  791. module JAVA_PROTO_FROM_SCHEMA: _JAVA_PROTO {
  792. .SEM=_JAVA_PROTO_LIBRARY_SEM
  793. .GLOBAL_SEM=_JAVA_PROTO_LIBRARY_SEM
  794. DISABLE(START_TARGET)
  795. SET_APPEND(PEERDIR_TAGS JAVA_PROTO JAVA_PROTO_FROM_SCHEMA)
  796. }
  797. module PY_PROTO_FROM_SCHEMA: _PY_PROTO {
  798. .SEM=_SEM_IGNORED
  799. .PEERDIRSELF=CPP_PROTO_FROM_SCHEMA
  800. DISABLE(START_TARGET)
  801. SET_APPEND(PEERDIR_TAGS PY_PROTO PY_PROTO_FROM_SCHEMA)
  802. }
  803. module PY3_PROTO_FROM_SCHEMA: _PY3_PROTO {
  804. .SEM=_SEM_IGNORED
  805. .PEERDIRSELF=CPP_PROTO_FROM_SCHEMA
  806. DISABLE(START_TARGET)
  807. SET_APPEND(PEERDIR_TAGS PY3_PROTO PY3_PROTO_FROM_SCHEMA)
  808. }
  809. module GO_PROTO_FROM_SCHEMA: _GO_PROTO {
  810. .SEM=_SEM_IGNORED
  811. DISABLE(START_TARGET)
  812. SET_APPEND(PEERDIR_TAGS GO_PROTO GO_PROTO_FROM_SCHEMA)
  813. }
  814. module TS_PROTO_FROM_SCHEMA: _TS_PROTO {
  815. .SEM=_SEM_IGNORED
  816. # opt-in. We don't want to have TS_PROTO by default
  817. # To include TS_PROTO user have to set INCLUDE_TAGS(TS_PROTO TS_PREPARE_DEPS) in ya.make
  818. .INCLUDE_TAG=no
  819. .PEERDIRSELF=TS_PREPARE_DEPS_FROM_SCHEMA
  820. .EPILOGUE=_TS_CONFIG_EPILOGUE
  821. DISABLE(START_TARGET)
  822. SET_APPEND(PEERDIR_TAGS TS_PROTO TS_PROTO_FROM_SCHEMA)
  823. }
  824. module TS_PREPARE_DEPS_FROM_SCHEMA: _TS_PREPARE_DEPS {
  825. .SEM=_SEM_IGNORED
  826. .INCLUDE_TAG=no
  827. DISABLE(START_TARGET)
  828. SET_APPEND(PEERDIR_TAGS TS_PREPARE_DEPS TS_PREPARE_DEPS_FROM_SCHEMA)
  829. }
  830. module DESC_PROTO_FROM_SCHEMA: _DESC_PROTO {
  831. .SEM=_SEM_IGNORED
  832. DISABLE(START_TARGET)
  833. SET_APPEND(PEERDIR_TAGS DESC_PROTO DESC_PROTO_FROM_SCHEMA)
  834. }
  835. module PROTO_DESCRIPTIONS_: PROTO_DESCRIPTIONS {
  836. .SEM=_SEM_IGNORED
  837. .PEERDIRSELF=DESC_PROTO_FROM_SCHEMA
  838. .FINAL_TARGET=yes
  839. SET_APPEND(PEERDIR_TAGS DESC_PROTO_FROM_SCHEMA)
  840. }
  841. }
  842. macro EVLOG_CMD(SRC) {
  843. .CMD=$_EVLOG_CMDLINE
  844. .SEM=$_EVLOG_CMDLINE
  845. }
  846. macro PROTO_CMD(SRC) {
  847. .CMD=$_PROTO_CMDLINE
  848. .SEM=$_PROTO_CMDLINE
  849. }
  850. _CPP_EVLOG_CMDLINE=$_CPP_EVLOG_CMD($SRC)
  851. _CPP_PROTO_CMDLINE=$_CPP_PROTO_CMD($SRC)
  852. _CPP_PROTO_EVLOG_CMDLINE=$_CPP_PROTO_EVLOG_CMD($SRC)
  853. _CPP_VANILLA_PROTO_CMDLINE=$_CPP_VANILLA_PROTO_CMD($SRC)
  854. _JAVA_EVLOG_CMDLINE=$_JAVA_EVLOG_CMD($SRC)
  855. _JAVA_PROTO_CMDLINE=$_JAVA_PROTO_CMD($SRC)
  856. _PROTO_DESC_CMDLINE=$_PROTO_DESC_RAWPROTO_CMD($SRC)
  857. _PY_EVLOG_CMDLINE=$_PY_EVLOG_CMD($SRC)
  858. _PY_PROTO_CMDLINE=$_PY_PROTO_CMD($SRC)