proto.conf 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883
  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=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. }
  162. # tag:proto tag:java-specific
  163. ### @usage: JAVA_PROTO_PLUGIN(Name Tool DEPS <Dependencies>)
  164. ###
  165. ### Define protoc plugin for Java with given Name that emits extra outputs
  166. ### using Tool. Extra dependencies are passed via DEPS
  167. macro JAVA_PROTO_PLUGIN(NAME, TOOL, DEPS[]) {
  168. SET_APPEND(JAVA_PROTO_ARGS $_JAVA_PROTO_PLUGIN_ARGS_BASE($NAME $TOOL))
  169. # XXX fix variable expansion in plugins
  170. SET(JAVA_PROTOBUF_PEERS $JAVA_PROTOBUF_PEERS $DEPS)
  171. }
  172. macro _ADD_SEM_PROP_IF_NON_EMPTY(Prop, Args...) {
  173. .SEM=${pre=&& target_properties-ITEM && target_properties-name $Prop && target_properties-value :Args}
  174. }
  175. # tag:proto tag:java-specific
  176. _WITH_KOTLIN_GRPC_SEM=
  177. macro WITH_KOTLIN_GRPC() {
  178. ENABLE(KOTLIN_PROTO)
  179. PEERDIR(build/platform/java/kotlin_grpc)
  180. 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)
  181. SET(JAVA_PROTOBUF_PEERS $JAVA_PROTOBUF_PEERS contrib/java/io/grpc/grpc-kotlin-stub/$KOTLIN_GRPC_VERSION)
  182. SET(JAVA_PROTOBUF_PEERS $JAVA_PROTOBUF_PEERS contrib/java/com/google/protobuf/protobuf-kotlin/${JAVA_PROTO_RUNTIME_VERSION})
  183. SET(_WITH_KOTLIN_GRPC_SEM && proto_kotlin_grpc && proto_kotlin_grpc_version ${KOTLIN_GRPC_VERSION})
  184. }
  185. # tag:proto tag:cpp-specific
  186. macro _ADD_CPP_PROTO_OUT(Suf) {
  187. SET_APPEND(CPP_PROTO_OUTS \${output;norel;nopath;noext;suf=$Suf:File})
  188. 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))
  189. # XXX fix variable expansion in plugins
  190. SET(CPP_PROTO_SUFFIXES $CPP_PROTO_SUFFIXES $Suf)
  191. }
  192. # tag:proto tag:cpp-specific
  193. HAS_CPP_PROTOBUF_PEERS=no
  194. CPP_PROTOBUF_PEERS=
  195. # tag:proto tag:cpp-specific
  196. ### @usage: CPP_PROTO_PLUGIN0(Name Tool [DEPS <Dependencies>] [EXTRA_OUT_FLAG <ExtraOutFlag>])
  197. ###
  198. ### Define protoc plugin for C++ with given Name that emits code into regular outputs
  199. ### using Tool. Extra dependencies are passed via DEPS.
  200. macro CPP_PROTO_PLUGIN0(NAME, TOOL, DEPS[], EXTRA_OUT_FLAG="") {
  201. .SEM=target_macroses-ITEM && target_macroses-macro target_proto_plugin && target_macroses-args $NAME ${tool;rootrel:TOOL} ${hide;output;suf=.fake.o:NAME}
  202. SET_APPEND(CPP_PROTO_OPTS $_PROTO_PLUGIN_ARGS_BASE($NAME $TOOL $EXTRA_OUT_FLAG))
  203. # XXX fix variable expansion in plugins
  204. ENABLE(HAS_CPP_PROTOBUF_PEERS)
  205. SET(CPP_PROTOBUF_PEERS $CPP_PROTOBUF_PEERS $DEPS)
  206. }
  207. # tag:proto tag:cpp-specific
  208. ### @usage: CPP_PROTO_PLUGIN(Name Tool Suf [DEPS <Dependencies>] [EXTRA_OUT_FLAG <ExtraOutFlag>])
  209. ###
  210. ### Define protoc plugin for C++ with given Name that emits code into 1 extra output
  211. ### using Tool. Extra dependencies are passed via DEPS.
  212. macro CPP_PROTO_PLUGIN(NAME, TOOL, SUF, DEPS[], EXTRA_OUT_FLAG="") {
  213. CPP_PROTO_PLUGIN0($NAME $TOOL DEPS $DEPS ${pre=EXTRA_OUT_FLAG :EXTRA_OUT_FLAG})
  214. _ADD_CPP_PROTO_OUT($SUF)
  215. }
  216. # tag:proto tag:cpp-specific
  217. ### @usage: CPP_PROTO_PLUGIN2(Name Tool Suf1 Suf2 [DEPS <Dependencies>] [EXTRA_OUT_FLAG <ExtraOutFlag>])
  218. ###
  219. ### Define protoc plugin for C++ with given Name that emits code into 2 extra outputs
  220. ### using Tool. Extra dependencies are passed via DEPS.
  221. macro CPP_PROTO_PLUGIN2(NAME, TOOL, SUF1, SUF2, DEPS[], EXTRA_OUT_FLAG="") {
  222. CPP_PROTO_PLUGIN($NAME $TOOL $SUF1 DEPS $DEPS ${pre=EXTRA_OUT_FLAG :EXTRA_OUT_FLAG})
  223. _ADD_CPP_PROTO_OUT($SUF2)
  224. SET_APPEND(CPP_PROTO_OUTS_SEM \${hide;output;norel;nopath;noext;suf=$SUF2:File})
  225. }
  226. # tag:proto
  227. ### @usage: USE_SKIFF() #wip, do not use
  228. ###
  229. ### Use mapreduce/yt/skiff_proto/plugin for C++
  230. macro USE_SKIFF() {
  231. # Move extra includes to INDUCED_DEPS macro in mapreduce/yt/skiff_proto/plugin/ya.make
  232. CPP_PROTO_PLUGIN0(skiff mapreduce/yt/skiff_proto/plugin DEPS mapreduce/yt/skiff_proto/lib)
  233. }
  234. # tag:go-specific
  235. _GO_COMMON_GOOGLE_APIS = \
  236. vendor/google.golang.org/genproto/googleapis/api/annotations \
  237. vendor/google.golang.org/genproto/googleapis/api/configchange \
  238. vendor/google.golang.org/genproto/googleapis/api/distribution \
  239. vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1 \
  240. vendor/google.golang.org/genproto/googleapis/api/expr/v1beta1 \
  241. vendor/google.golang.org/genproto/googleapis/api/httpbody \
  242. vendor/google.golang.org/genproto/googleapis/api/label \
  243. vendor/google.golang.org/genproto/googleapis/api/metric \
  244. vendor/google.golang.org/genproto/googleapis/api/monitoredres \
  245. vendor/google.golang.org/genproto/googleapis/api/serviceconfig \
  246. vendor/cloud.google.com/go/servicecontrol/apiv1/servicecontrolpb \
  247. vendor/cloud.google.com/go/servicemanagement/apiv1/servicemanagementpb \
  248. vendor/google.golang.org/genproto/googleapis/iam/admin/v1 \
  249. vendor/google.golang.org/genproto/googleapis/iam/credentials/v1 \
  250. vendor/google.golang.org/genproto/googleapis/iam/v1 \
  251. vendor/google.golang.org/genproto/googleapis/iam/v1/logging \
  252. vendor/google.golang.org/genproto/googleapis/logging/type \
  253. vendor/google.golang.org/genproto/googleapis/logging/v2 \
  254. vendor/google.golang.org/genproto/googleapis/rpc/code \
  255. vendor/google.golang.org/genproto/googleapis/rpc/errdetails \
  256. vendor/google.golang.org/genproto/googleapis/rpc/status \
  257. vendor/google.golang.org/genproto/googleapis/type/calendarperiod \
  258. vendor/google.golang.org/genproto/googleapis/type/color \
  259. vendor/google.golang.org/genproto/googleapis/type/date \
  260. vendor/google.golang.org/genproto/googleapis/type/dayofweek \
  261. vendor/google.golang.org/genproto/googleapis/type/expr \
  262. vendor/google.golang.org/genproto/googleapis/type/fraction \
  263. vendor/google.golang.org/genproto/googleapis/type/latlng \
  264. vendor/google.golang.org/genproto/googleapis/type/money \
  265. vendor/google.golang.org/genproto/googleapis/type/postaladdress \
  266. vendor/google.golang.org/genproto/googleapis/type/quaternion \
  267. vendor/google.golang.org/genproto/googleapis/type/timeofday
  268. # tag:go-specific
  269. _COMMON_GOOGLE_APIS=None
  270. # tag:go-specific
  271. ### @usage: USE_COMMON_GOOGLE_APIS([apis...])
  272. ###
  273. ### Use common-google-apis library set. Pass optional apis list to be used or use them all.
  274. ### This macro is properly handled for all languages including Go, where apis come in
  275. ## pregenerated form. In other languages apis are generated from sources in Arcadia.
  276. macro USE_COMMON_GOOGLE_APIS(APIS...) {
  277. SET(_COMMON_GOOGLE_APIS ${pre=vendor/google.golang.org/genproto/googleapis/:APIS})
  278. }
  279. # tag:go-specific tag:proto
  280. GO_PROTO_GEN_PLUGINS=
  281. GO_PROTO_OPTS=
  282. GO_PROTO_OUTS=
  283. GO_PROTO_GRPC_OPTS=
  284. GO_PROTO_GRPC_OUTS=
  285. GO_PROTO_V2=no
  286. _GO_PROTO_CHECK_OUTPUT=
  287. # tag:go-specific tag:proto
  288. GO_PROTOBUF_IMPORTS=\
  289. ${GOSTD}/sync \
  290. ${GOSTD}/reflect \
  291. ${GOSTD}/fmt \
  292. ${GOSTD}/math \
  293. vendor/github.com/golang/protobuf/proto \
  294. vendor/google.golang.org/protobuf/types/descriptorpb \
  295. vendor/google.golang.org/protobuf/runtime/protoimpl \
  296. vendor/google.golang.org/protobuf/runtime/protoiface \
  297. vendor/google.golang.org/protobuf/reflect/protoreflect
  298. # tag:go-specific tag:proto
  299. GO_PROTOBUF_WELLKNOWN_TYPES=\
  300. vendor/google.golang.org/protobuf/types/known/anypb \
  301. vendor/google.golang.org/protobuf/types/known/apipb \
  302. vendor/google.golang.org/protobuf/types/known/durationpb \
  303. vendor/google.golang.org/protobuf/types/known/emptypb \
  304. vendor/google.golang.org/protobuf/types/known/fieldmaskpb \
  305. vendor/google.golang.org/protobuf/types/known/sourcecontextpb \
  306. vendor/google.golang.org/protobuf/types/known/structpb \
  307. vendor/google.golang.org/protobuf/types/known/timestamppb \
  308. vendor/google.golang.org/protobuf/types/known/typepb \
  309. vendor/google.golang.org/protobuf/types/known/wrapperspb
  310. # tag:go-specific tag:proto
  311. ### @usage: GO_PROTO_PLUGIN(Name Ext Tool [DEPS dependencies...])
  312. ###
  313. ### Define protoc plugin for GO with given Name that emits extra output with provided extension
  314. ### Ext using Tool. Extra dependencies are passed via DEPS.
  315. macro GO_PROTO_PLUGIN(NAME, EXT, TOOL, DEPS[]) {
  316. SET_APPEND(GO_PROTO_OPTS $_PROTO_PLUGIN_ARGS_BASE($NAME $TOOL))
  317. SET_APPEND(GO_PROTO_OUTS \${hide;noauto;output;norel;nopath;noext;suf=$EXT:File})
  318. PEERDIR(${DEPS})
  319. }
  320. # tag:go-specific tag:proto
  321. 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}
  322. # tag:go-specific tag:proto
  323. macro _GO_PROTO_CMD_IMPL(File, OPTS...) {
  324. .CMD=$GO_PROTO_CMDLINE $OPTS ${hide;kv:"p PB"} ${hide;kv:"pc yellow"}
  325. .PEERDIR=${GO_PROTOBUF_IMPORTS} ${GO_PROTOBUF_WELLKNOWN_TYPES}
  326. .ADDINCL=FOR proto ${PROTOBUF_INCLUDE_PATH}
  327. }
  328. # tag:go-specific tag:proto
  329. macro _GO_PROTO_CMD(File) {
  330. .CMD=$_GO_PROTO_CMD_IMPL($File $GO_PROTO_OPTS $GO_PROTO_OUTS)
  331. }
  332. # tag:proto
  333. ### @usage: YT_ORM_PROTO_YSON(Files... OUT_OPTS Opts...)
  334. ###
  335. ### Generate .yson.go from .proto using yt/yt/orm/go/codegen/yson/internal/proto-yson-gen/cmd/proto-yson-gen
  336. macro YT_ORM_PROTO_YSON(OUT_OPTS[], Files...) {
  337. .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}
  338. .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}
  339. .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
  340. }
  341. _SEM_CPP_PROTO_CMD=target_options-privates-ITEM && target_options-privates-option target_proto_messages && target_options-privates-args ${input:File} \
  342. $CPP_PROTO_OUTS_SEM ${hide;output;suf=${OBJ_SUF}.pb.o:File} $DEFAULT_PROTOC_TOOLS \
  343. $PROTOC_EXTRA_OUTS_SEM \
  344. && platform_vars-COMMON_PROTOC_FLAGS "" \
  345. && target_macroses-ITEM && target_macroses-macro target_proto_outs && target_macroses-args --cpp_out=$ARCADIA_BUILD_ROOT/$PROTO_NAMESPACE $PROTOC_STYLEGUIDE_OUT \
  346. && 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
  347. # tag:proto
  348. macro _CPP_PROTO_CMD(File) {
  349. .CMD=$CPP_PROTO_CMDLINE $CPP_PROTO_OPTS ${hide;kv:"p PB"} ${hide;kv:"pc yellow"}
  350. .SEM=$_SEM_CPP_PROTO_CMD
  351. .PEERDIR=contrib/libs/protobuf
  352. }
  353. # tag:proto
  354. macro _CPP_VANILLA_PROTO_CMD(File) {
  355. .CMD=$CPP_PROTO_CMDLINE $CPP_PROTO_OPTS ${hide;kv:"p PB"} ${hide;kv:"pc yellow"}
  356. .PEERDIR=contrib/libs/protobuf_std
  357. }
  358. _SEM_CPP_EV_CMD=target_options-privates-ITEM && target_options-privates-option target_ev_messages && target_options-privates-args ${input:File} \
  359. $CPP_EV_OUTS_SEM ${hide;output;suf=${OBJ_SUF}.pb.o:File} ${hide;tool:"tools/event2cpp/bin"} $DEFAULT_PROTOC_TOOLS \
  360. && platform_vars-COMMON_PROTOC_FLAGS "" \
  361. && 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 \
  362. && 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
  363. # tag:proto
  364. macro _CPP_EVLOG_CMD(File) {
  365. .CMD=$CPP_EV_CMDLINE $CPP_EV_OPTS ${hide;kv:"p EV"} ${hide;kv:"pc yellow"}
  366. .SEM=$_SEM_CPP_EV_CMD
  367. .PEERDIR=library/cpp/eventlog contrib/libs/protobuf
  368. }
  369. # tag:proto
  370. macro _CPP_PROTO_EVLOG_CMD(File) {
  371. # process .proto as .ev
  372. .CMD=$CPP_PROTO_CMDLINE $CPP_EV_OPTS ${hide;kv:"p PB"} ${hide;kv:"pc yellow"}
  373. .PEERDIR=library/cpp/eventlog contrib/libs/protobuf
  374. }
  375. # tag:proto
  376. macro _CPP_CFGPROTO_CMD(File) {
  377. # keep extension in output just as in EV: this is hard-coded behaviour of protoc for non-.proto extensions
  378. .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"}
  379. .PEERDIR=library/cpp/proto_config/codegen library/cpp/proto_config/protos contrib/libs/protobuf
  380. }
  381. # tag:proto
  382. PY_PROTO_MYPY_ENABLED=yes
  383. 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
  384. # tag:proto tag:python-specific
  385. PY_PROTO_MYPY_SUFFIX=
  386. PY_PROTO_MYPY_PLUGIN=
  387. PY_PROTO_MYPY_PLUGIN_INTERNAL=
  388. # tag:proto tag:python-specific
  389. macro NO_MYPY() {
  390. DISABLE(PY_PROTO_MYPY_ENABLED)
  391. }
  392. # tag:proto tag:python-specific
  393. macro _PY_PROTO_CMD_BASE(File, Suf, Args...) {
  394. .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}
  395. }
  396. # tag:proto tag:python-specific
  397. macro _PY_PROTO_CMD(File) {
  398. .CMD=${cwd;rootdir;input:File} $_PY_PROTO_CMD_BASE($File _pb2.py $PY_PROTO_OPTS $PY_PROTO_OUTS $PY_PROTO_MYPY_PLUGIN)
  399. }
  400. # tag:proto tag:python-specific
  401. macro _PY_PROTO_CMD_INTERNAL(File) {
  402. .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)
  403. }
  404. # tag:proto tag:java-specific
  405. JAVA_PROTO_RUNTIME=
  406. # tag:proto tag:java-specific
  407. ### @usage: USE_JAVALITE()
  408. ### Use protobuf-javalite for Java
  409. macro USE_JAVALITE() {
  410. SET(JAVA_PROTO_RUNTIME javalite)
  411. }
  412. # tag:proto tag:java-specific
  413. JAVA_PROTO_COMPILER_VERSION = 3.25.3
  414. JAVA_PROTO_RUNTIME_VERSION = 3.25.3
  415. JAVA_PROTO_COMMON_VERSION = 2.9.0
  416. JAVA_GRPC_VERSION = 1.51.0
  417. KOTLIN_GRPC_VERSION = 1.3.1
  418. JAVA_NETTY_NETTY_VERSION = 4.1.79.Final
  419. KOTLIN_PROTO=no
  420. KOTLIN_PROTO_PEERS=
  421. when ($JAVA_PROTO_RUNTIME == "javalite") {
  422. _JAVA_PROTO_LITE_ARG=lite:
  423. JAVA_PROTOBUF_PEERS=contrib/java/com/google/protobuf/protobuf-javalite/${JAVA_PROTO_RUNTIME_VERSION} ${KOTLIN_PROTO_PEERS}
  424. JAVA_GRPC_STUB=contrib/java/io/grpc/grpc-stub/${JAVA_GRPC_VERSION}
  425. JAVA_GRPC_PROTOBUF=contrib/java/io/grpc/grpc-protobuf/${JAVA_GRPC_VERSION}
  426. }
  427. otherwise {
  428. _JAVA_PROTO_LITE_ARG=
  429. JAVA_PROTOBUF_PEERS=contrib/java/com/google/protobuf/protobuf-java/${JAVA_PROTO_RUNTIME_VERSION} ${KOTLIN_PROTO_PEERS}
  430. JAVA_GRPC_STUB=contrib/java/io/grpc/grpc-stub/${JAVA_GRPC_VERSION}
  431. JAVA_GRPC_PROTOBUF=contrib/java/io/grpc/grpc-protobuf/${JAVA_GRPC_VERSION}
  432. }
  433. KOTLIN_PROTO_FLAGS=
  434. # tag:proto tag:java-specific
  435. macro _JAVA_PROTO_CMD(File) {
  436. .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}
  437. .SEM=proto_files ${input;rootrel:File} ${hide;output:File.jsrc}
  438. }
  439. # tag:proto tag:perl-specific tag:deprecated
  440. ### @usage: XS_PROTO(InputProto Dir Outputs...) # deprecated
  441. ###
  442. ### Generate Perl code from protobuf.
  443. ### In order to use this macro one should predict all outputs protoc will emit from input_proto file and enlist those as outputs.
  444. macro XS_PROTO(File, Dir, Outputs...) {
  445. .CMD=${PROTOC_OLD} -I=${ARCADIA_ROOT}/${Dir} ${pre=-I=:_PROTO__INCLUDE} -I=${ARCADIA_ROOT} -I=${PROTOBUF_OLD_PATH} --perlxs_out=${BINDIR} $_PROTOC_FLAGS ${input:File} ${hide;output:Outputs} ${induced_deps=h+cpp;hide;nopath;noext;suf=.pb.h:File} ${hide:PROTO_FAKEID}
  446. PEERDIR(${Dir})
  447. ADDINCL(${ARCADIA_BUILD_ROOT}/${Dir})
  448. }
  449. # tag:proto tag:python-specific
  450. when ($PY_PROTOS_FOR == "yes") {
  451. PEERDIR+=contrib/libs/protobuf/python
  452. }
  453. # tag:python-specific
  454. macro _PY_EVLOG_CMD_BASE(File, Suf, Args...) {
  455. .CMD=$_PY_PROTO_CMD_BASE($File $Suf $Args)
  456. .PEERDIR=library/cpp/eventlog/proto
  457. }
  458. # tag:python-specific tag:proto
  459. macro _PY_EVLOG_CMD(File) {
  460. .CMD=${cwd;rootdir;input:File} $_PY_EVLOG_CMD_BASE($File _ev_pb2.py)
  461. }
  462. # tag:python-specific tag:proto
  463. macro _PY_EVLOG_CMD_INTERNAL(File) {
  464. .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}"})
  465. }
  466. # tag:java-specific tag:proto
  467. macro _JAVA_EVLOG_CMD(File) {
  468. .CMD=$COPY_CMD ${input:File} ${output;nopath;noext;norel;suf=_ev.proto:File} ${hide;kv:"p EV"} ${hide;kv:"pc yellow"}
  469. .PEERDIR=library/cpp/eventlog/proto
  470. }
  471. # tag:proto tag:grpc
  472. _GRPC_ENABLED=no
  473. _GRPC_SUF_CC=.grpc.pb.cc
  474. _GRPC_SUF_H=.grpc.pb.h
  475. # tag:proto tag:grpc
  476. ### @usage: GRPC()
  477. ###
  478. ### Emit GRPC code for all .proto files in a PROTO_LIBRARY.
  479. ### This works for all available PROTO_LIBRARY versions (C++, Python 2.x, Python 3.x, Java and Go).
  480. macro GRPC() {
  481. ENABLE(_GRPC_ENABLED)
  482. # C++
  483. CPP_PROTO_PLUGIN2(grpc_cpp contrib/tools/protoc/plugins/grpc_cpp $_GRPC_SUF_CC $_GRPC_SUF_H DEPS contrib/libs/grpc $_GRPC_GMOCK_OUTFLAG)
  484. # Python
  485. PY_PROTO_PLUGIN(grpc_py _pb2_grpc.py contrib/tools/protoc/plugins/grpc_python DEPS contrib/python/grpcio)
  486. # Java
  487. JAVA_PROTO_PLUGIN(grpc_java build/platform/java/grpc DEPS $JAVA_GRPC_STUB $JAVA_GRPC_PROTOBUF)
  488. SET_APPEND(JAVA_PROTOBUF_PEERS contrib/java/javax/annotation/javax.annotation-api/1.3.1)
  489. }
  490. # tag:proto tag:grpc
  491. _GRPC_GMOCK_OUTFLAG=
  492. # tag:proto tag:grpc
  493. ### @usage: WITH_GMOCK()
  494. ###
  495. ### Enable generating *_mock.grpc.pb.cc/h files
  496. macro GRPC_WITH_GMOCK() {
  497. SET(_GRPC_GMOCK_OUTFLAG EXTRA_OUT_FLAG generate_mock_code=true)
  498. GRPC()
  499. _ADD_CPP_PROTO_OUT(_mock$_GRPC_SUF_H)
  500. SET_APPEND(CPP_PROTO_OUTS_SEM ${hide;output;norel;nopath;noext;suf=_mock$_GRPC_SUF_H:File})
  501. }
  502. macro GO_PROTO_USE_V2() {
  503. ENABLE(GO_PROTO_V2)
  504. }
  505. # tag:proto
  506. ### @usage: RESOLVE_PROTO()
  507. ###
  508. ### Enable include resolving within UNIONs and let system .proto being resolved
  509. ### among .proto/.gztproto imports
  510. ###
  511. ### Note: it is currently impossible to enable resolving only for .proto, so resolving is enabled for all supported files
  512. ### also we only add ADDINCL for stock protobuf. So use this macro with care: it may cause resolving problems those are
  513. ### to be addressed by either ADDINCLs or marking them as TEXT. Please contact devtools for details.
  514. macro RESOLVE_PROTO() {
  515. SET(DONT_RESOLVE_INCLUDES no)
  516. ADDINCL(FOR proto $PROTOBUF_INCLUDE_PATH)
  517. }
  518. # tag:python-specific tag:proto tag:deprecated
  519. ### @usage GENERATE_PY_PROTOS(ProtoFiles...) # deprecated
  520. ###
  521. ### Generate python bindings for protobuf files.
  522. ### Macro is obsolete and not recommended for use!
  523. macro GENERATE_PY_PROTOS(FILES...) {
  524. foreach (FILE : $FILES) {
  525. _PY_PROTO_CMD($FILE)
  526. }
  527. }
  528. # tag:python-specific tag:proto
  529. macro _GENERATE_PY_PROTOS_INTERNAL(FILES...) {
  530. foreach (FILE : $FILES) {
  531. _PY_PROTO_CMD_INTERNAL($FILE)
  532. }
  533. }
  534. # tag:python-specific
  535. macro _GENERATE_PY_EVS_INTERNAL(FILES...) {
  536. foreach (FILE : $FILES) {
  537. _PY_EVLOG_CMD_INTERNAL($FILE)
  538. }
  539. }
  540. ### @usage: LIST_PROTO([TO list.proto] Files...) # deprecated
  541. ###
  542. ### Create list of .proto files in a list-file (should be .proto, files.proto by default)
  543. ### with original .proto-files as list's dependencies.
  544. ###
  545. ### This allows to process files listed, passing list as an argument to the processor
  546. ###
  547. ### TODO: proper implementation needed
  548. macro LIST_PROTO(TO="files.proto", Files...) {
  549. .CMD=$YMAKE_PYTHON3 ${input:"build/scripts/list.py"} ${Files} ${hide;input:Files} ${stdout;noauto;output:TO} ${output_include;from_input;hide:Files}
  550. _COMPILE_LIST_PROTO(${TO})
  551. _EXPOSE(${TO})
  552. }
  553. macro _COMPILE_LIST_PROTO(SRC) {
  554. .CMD=$YMAKE_PYTHON ${input:"build/scripts/touch.py"} ${hide;input:SRC} ${output;noext;suf=.pb.h:SRC}
  555. }
  556. # tag:proto
  557. macro _PROTO_DESC_RAWPROTO_CMD(File) {
  558. .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}
  559. }
  560. _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}
  561. _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}
  562. NEED_GOOGLE_PROTO_PEERDIRS=yes
  563. CPP_PROTO_LIBRARY_SEM=$CPP_LIBRARY_SEM
  564. JAVA_PROTO_LIBRARY_SEM=$BUILD_PROTO_JAR_SEM $_GRADLE_EXPORT_PUBLISHING_SEM
  565. # tag:proto
  566. ### @usage: PROTO_LIBRARY()
  567. ###
  568. ### Build some varian of protocol buffers library.
  569. ###
  570. ### The particular variant is selected based on where PEERDIR to PROTO_LIBRARY comes from.
  571. ###
  572. ### Now supported 5 variants: C++, Java, Python 2.x, Python 3.x and Go.
  573. ### When PEERDIR comes from module for particular language appropriate variant is selected.
  574. ### PROTO_LIBRARY also supports emission of GRPC code if GRPC() macro is specified.
  575. ### Notes:
  576. ### - Python versions emit C++ code in addition to Python as optimization.
  577. ### - In some PROTO_LIBRARY-es Java or Python versions are excluded via EXCLUDE_TAGS macros due to incompatibilities.
  578. ### - Use from DEPENDS or BUNDLE is not allowed
  579. ###
  580. ### Documentation: https://wiki.yandex-team.ru/yatool/proto_library/
  581. ###
  582. ### See: [GRPC()](#macro_GRPC), [OPTIMIZE_PY_PROTOS()](#macro_OPTIMIZE_PY_PROTOS), [INCLUDE_TAGS()](#macro_INCLUDE_TAGS), [EXCLUDE_TAGS()](#macro_EXCLUDE_TAGS)
  583. multimodule PROTO_LIBRARY {
  584. module CPP_PROTO : LIBRARY {
  585. .ALLOWED=_EXPOSE LIST_PROTO
  586. # TODO(svidyuk): think about marker which forces semantics inheritance
  587. .SEM=CPP_PROTO_LIBRARY_SEM
  588. FORCE_COVERAGE_DISABLED=yes
  589. ENABLE(CPP_PROTO)
  590. ENABLE(GEN_PROTO)
  591. NO_CLANG_TIDY()
  592. CPP_PROTOLIBS_DEBUG_INFO()
  593. SET(PEERDIR_TAGS CPP_PROTO)
  594. when ($BUILD_PROTO_AS_EVLOG == "yes" && $USE_VANILLA_PROTOC == "yes") {
  595. _OK=no
  596. }
  597. ASSERT(_OK BUILD_PROTO_AS_EVLOG and USE_VANILLA_PROTOC are incompatible yet)
  598. MODULE_SUFFIX=$_CPP_PROTO_MODULE_SUFFIX
  599. MODULE_PREFIX=$_CPP_PROTO_MODULE_PREFIX
  600. when ($_COMMON_GOOGLE_APIS != "None") {
  601. PEERDIR += contrib/libs/googleapis-common-protos
  602. }
  603. }
  604. module JAVA_PROTO: EXTERNAL_JAVA_LIBRARY {
  605. .EXTS=.jsrc
  606. .ALLOWED=GRPC
  607. .SEM=JAVA_PROTO_LIBRARY_SEM
  608. SET(PEERDIR_TAGS JAVA JAVA_PROTO)
  609. ENABLE(JAVA_PROTO)
  610. DISABLE(_NEED_SBOM_INFO)
  611. PEERDIR+=$JAVA_PROTOBUF_PEERS
  612. when ($KOTLIN_PROTO == "yes") {
  613. KOTLIN_PROTO_PEERS=contrib/java/com/google/protobuf/protobuf-kotlin/${JAVA_PROTO_RUNTIME_VERSION}
  614. KOTLIN_PROTO_FLAGS=--kotlin_out=$ARCADIA_BUILD_ROOT/java_out
  615. }
  616. when ($GRADLE_EXPORT_PUBLISHING == "yes") {
  617. _GRADLE_EXPORT_PUBLISHING_SEM=$_DO_GRADLE_EXPORT_PUBLISHING_SEM
  618. }
  619. .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER USE_SKIFF CPP_PROTO_PLUGIN2 PY_PROTO_PLUGIN YMAPS_SPROTO RESOURCE
  620. ADDINCL(FOR proto $PROTOBUF_INCLUDE_PATH)
  621. when ($_COMMON_GOOGLE_APIS != "None") {
  622. PEERDIR += contrib/java/com/google/api/grpc/proto-google-common-protos/${JAVA_PROTO_COMMON_VERSION}
  623. ADDINCL += GLOBAL FOR proto ${ARCADIA_ROOT}/contrib/libs/googleapis-common-protos
  624. }
  625. }
  626. module PY_PROTO: PY2_LIBRARY {
  627. .ALIASES=SRCS=PY_SRCS
  628. .ALLOWED=OPTIMIZE_PY_PROTOS NO_OPTIMIZE_PY_PROTOS
  629. .PEERDIRSELF=CPP_PROTO
  630. .SEM=IGNORED
  631. SET(PEERDIR_TAGS PY2 PY_PROTO)
  632. ENABLE(PY_PROTO)
  633. DISABLE(_NEED_SBOM_INFO)
  634. OPTIMIZE_PY_PROTOS()
  635. OBJ_SUF=.py2
  636. # Can not use NO_LINT(), because is not allowed outside of contrib directory
  637. SET(_NO_LINT_VALUE none_internal)
  638. when ($_COMMON_GOOGLE_APIS != "None") {
  639. PEERDIR += contrib/libs/googleapis-common-protos
  640. }
  641. _IGNORE_SELF_PEERS=
  642. _CPP_PROTO_LIBRARY=${MODDIR}/$_CPP_PROTO_MODULE_PREFIX$REALPRJNAME$_CPP_PROTO_MODULE_SUFFIX
  643. when ($OPTIMIZE_PY_PROTOS_FLAG == "no") {
  644. _IGNORE_PEERDIRSELF=CPP_PROTO
  645. }
  646. SET_APPEND(_WHOLE_ARCHIVE_LIBS_VALUE_GLOBAL $_CPP_PROTO_LIBRARY)
  647. }
  648. module PY3_PROTO: PY3_LIBRARY {
  649. .ALIASES=SRCS=PY_SRCS
  650. .ALLOWED=OPTIMIZE_PY_PROTOS NO_OPTIMIZE_PY_PROTOS
  651. .PEERDIRSELF=CPP_PROTO
  652. .SEM=IGNORED
  653. SET(PEERDIR_TAGS PY3 PY3_PROTO)
  654. ENABLE(PY3_PROTO)
  655. DISABLE(_NEED_SBOM_INFO)
  656. OPTIMIZE_PY_PROTOS()
  657. OBJ_SUF=.py3
  658. # Can not use NO_LINT(), because is not allowed outside of contrib directory
  659. SET(_NO_LINT_VALUE none_internal)
  660. when ($_COMMON_GOOGLE_APIS != "None") {
  661. PEERDIR += contrib/libs/googleapis-common-protos
  662. }
  663. _IGNORE_SELF_PEERS=
  664. _CPP_PROTO_LIBRARY=${MODDIR}/$_CPP_PROTO_MODULE_PREFIX$REALPRJNAME$_CPP_PROTO_MODULE_SUFFIX
  665. when ($OPTIMIZE_PY_PROTOS_FLAG == "no") {
  666. _IGNORE_PEERDIRSELF=CPP_PROTO
  667. }
  668. SET_APPEND(_WHOLE_ARCHIVE_LIBS_VALUE_GLOBAL $_CPP_PROTO_LIBRARY)
  669. }
  670. module GO_PROTO: GO_LIBRARY {
  671. .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER YMAPS_SPROTO
  672. .SEM=IGNORED
  673. SET(PEERDIR_TAGS GO GO_PROTO)
  674. ENABLE(GO_PROTO)
  675. when ($_COMMON_GOOGLE_APIS == "None") {
  676. }
  677. elsewhen ($_COMMON_GOOGLE_APIS == "") {
  678. PEERDIR += $_GO_COMMON_GOOGLE_APIS
  679. ADDINCL += GLOBAL FOR proto ${ARCADIA_ROOT}/contrib/libs/googleapis-common-protos
  680. }
  681. otherwise {
  682. PEERDIR += $_COMMON_GOOGLE_APIS
  683. ADDINCL += GLOBAL FOR proto ${ARCADIA_ROOT}/contrib/libs/googleapis-common-protos
  684. }
  685. }
  686. module TS_PROTO: _TS_PROTO_IMPL {
  687. # opt-in. We don't want to have TS_PROTO by default
  688. # To include TS_PROTO user have to set INCLUDE_TAGS(TS_PROTO TS_PREPARE_DEPS) in ya.make
  689. .INCLUDE_TAG=no
  690. .EPILOGUE=_TS_CONFIG_EPILOGUE
  691. .PEERDIRSELF=TS_PREPARE_DEPS
  692. DISABLE(_NEED_SBOM_INFO)
  693. when ($_COMMON_GOOGLE_APIS != "None") {
  694. PEERDIR += contrib/libs/googleapis-common-protos
  695. }
  696. }
  697. module TS_PREPARE_DEPS: _PREPARE_DEPS_BASE {
  698. .INCLUDE_TAG=no
  699. .IGNORED=PEERDIR SRCS GENERATE_ENUM_SERIALIZATION
  700. DISABLE(_NEED_SBOM_INFO)
  701. }
  702. module DESC_PROTO: _BARE_UNIT {
  703. .CMD=_PROTO_DESC_MERGE_CMD
  704. .SEM=IGNORED
  705. .EXTS=.desc .rawproto
  706. .NODE_TYPE=Library
  707. .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER YMAPS_SPROTO RESOURCE GO_PROTO_PLUGIN GRPC
  708. .ALIASES=SRCS=_SRCS_NO_GLOBAL
  709. SET(PEERDIR_TAGS DESC_PROTO)
  710. ENABLE(DESC_PROTO)
  711. DISABLE(_NEED_SBOM_INFO)
  712. MODULE_SUFFIX=.self.protodesc
  713. SET(MODULE_TYPE LIBRARY)
  714. SET(_MODDIR_HASH ${hash:MODDIR})
  715. _EVLOG_CMDLINE=$_PROTO_DESC_CMDLINE
  716. _PROTO_CMDLINE=$_PROTO_DESC_CMDLINE
  717. when ($_COMMON_GOOGLE_APIS != "None") {
  718. PEERDIR += contrib/libs/googleapis-common-protos
  719. }
  720. when ($NEED_GOOGLE_PROTO_PEERDIRS == "yes") {
  721. when ($USE_VANILLA_PROTOC == "yes") {
  722. PEERDIR += contrib/libs/protobuf_std/builtin_proto/protos_from_protobuf
  723. }
  724. otherwise {
  725. PEERDIR += contrib/libs/protobuf/builtin_proto/protos_from_protoc
  726. }
  727. }
  728. }
  729. }
  730. module PROTO_DESCRIPTIONS: _BARE_UNIT {
  731. .CMD=_PROTO_DESC_MERGE_PEERS_CMD
  732. .PEERDIR_POLICY=as_build_from
  733. .NODE_TYPE=Library
  734. .RESTRICTED=SRCS
  735. .FINAL_TARGET=yes
  736. SET(MODULE_TAG PROTO_DESCRIPTIONS)
  737. SET(PEERDIR_TAGS DESC_PROTO)
  738. SET(MODULE_SUFFIX .protodesc)
  739. SET(MODULE_TYPE PROTO_DESCRIPTIONS)
  740. }
  741. module PROTO_REGISTRY: PROTO_DESCRIPTIONS {
  742. SET(MODULE_TAG PROTO_REGISTRY)
  743. SET(MODULE_TYPE PROTO_REGISTRY)
  744. }
  745. macro EVLOG_CMD(SRC) {
  746. .CMD=$_EVLOG_CMDLINE
  747. .SEM=$_EVLOG_CMDLINE
  748. }
  749. macro PROTO_CMD(SRC) {
  750. .CMD=$_PROTO_CMDLINE
  751. .SEM=$_PROTO_CMDLINE
  752. }
  753. _CPP_EVLOG_CMDLINE=$_CPP_EVLOG_CMD($SRC)
  754. _CPP_PROTO_CMDLINE=$_CPP_PROTO_CMD($SRC)
  755. _CPP_PROTO_EVLOG_CMDLINE=$_CPP_PROTO_EVLOG_CMD($SRC)
  756. _CPP_VANILLA_PROTO_CMDLINE=$_CPP_VANILLA_PROTO_CMD($SRC)
  757. _JAVA_EVLOG_CMDLINE=$_JAVA_EVLOG_CMD($SRC)
  758. _JAVA_PROTO_CMDLINE=$_JAVA_PROTO_CMD($SRC)
  759. _PROTO_DESC_CMDLINE=$_PROTO_DESC_RAWPROTO_CMD($SRC)
  760. _PY_EVLOG_CMDLINE=$_PY_EVLOG_CMD($SRC)
  761. _PY_PROTO_CMDLINE=$_PY_PROTO_CMD($SRC)