Browse Source

feat(TS_PROTO): macro TS_PROTO_OPT
commit_hash:85e6695c5b8e188ef7d4204d15af4cb7f399e46c

zaverden 5 months ago
parent
commit
24b53856b5
2 changed files with 22 additions and 2 deletions
  1. 1 1
      build/conf/proto.conf
  2. 21 1
      build/conf/ts/ts_proto.conf

+ 1 - 1
build/conf/proto.conf

@@ -796,7 +796,7 @@ multimodule PROTO_LIBRARY {
 
     module TS_PROTO: _TS_PROTO_IMPL {
         # opt-in. We don't want to have TS_PROTO by default
-        # To include TS_PROTO user have to set INCLUDE_TAGS(TS_PROTO) in ya.make
+        # To include TS_PROTO user have to set INCLUDE_TAGS(TS_PROTO TS_PREPARE_DEPS) in ya.make
         .INCLUDE_TAG=no
         .EPILOGUE=_TS_CONFIG_EPILOGUE
         .PEERDIRSELF=TS_PREPARE_DEPS

+ 21 - 1
build/conf/ts/ts_proto.conf

@@ -1,7 +1,8 @@
-_TS_PROTO_SRCS_FILES=
+_TS_PROTO_OPT=
 _TS_PROTO_IMPL_CMD=$TOUCH_UNIT \
     && $_TS_FILES_COPY_CMD \
     && $NOTS_TOOL $NOTS_TOOL_BASE_ARGS build-ts-proto $NOTS_TOOL_COMMON_BUILDER_ARGS \
+        ${_TS_PROTO_OPT} \
         --protoc-bin $PROTOC \
         --proto-srcs $_TS_PROTO_SRCS_FILES \
         --proto-paths ./$PROTO_NAMESPACE $ARCADIA_ROOT/$PROTO_NAMESPACE $_PROTO__INCLUDE $ARCADIA_BUILD_ROOT $PROTOBUF_INCLUDE_PATH \
@@ -45,3 +46,22 @@ module _TS_PROTO_IMPL: _TS_BASE_UNIT {
 macro _TS_PROTO_SRCS(FILES...) {
     _SET_APPEND_WITH_DIRECTIVE(_TS_PROTO_SRCS_FILES input $FILES)
 }
+
+### @usage: TS_PROTO_OPT(key1=value1 key2=value2)
+###
+### Overrides default options for `--ts_proto_opt`
+### ([supported options](https://github.com/stephenh/ts-proto?tab=readme-ov-file#supported-options)).
+###
+### Documentation: https://docs.yandex-team.ru/frontend-in-arcadia/references/PROTO_LIBRARY#ts_proto_opt
+###
+### @example
+###
+###     TS_PROTO_OPT(env=browser)
+###     TS_PROTO_OPT(
+###         useJsonName=true
+###         useJsonWireFormat=true
+###     )
+###
+macro TS_PROTO_OPT(OPTS...) {
+    SET_APPEND(_TS_PROTO_OPT ${pre=--ts-proto-opt :OPTS})
+}