fbs.conf 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. FLATC=contrib/libs/flatbuffers/flatc
  2. FLATC64=contrib/libs/flatbuffers64/flatc
  3. # tag:fbs
  4. FLATC_FLAGS_VALUE=
  5. ### @usage: FLATC_FLAGS(flags...)
  6. ###
  7. ### Add flags to flatc command line
  8. macro FLATC_FLAGS(FLAGS...) {
  9. SET_APPEND(FLATC_FLAGS_VALUE $FLAGS)
  10. }
  11. # tag:fbs
  12. _PY_FBS_DEPS=contrib/python/flatbuffers
  13. # tag:fbs tag:internal
  14. ### @usage: FBS_TO_PYSRC(output_base_name fbs_files...) # internal
  15. ###
  16. ### Create a tar archive of .py files generated by flatc for Python. Output tar
  17. ### archive will have .fbs.pysrc extension. This .fbs.pysrc extension is specially
  18. ### processed when --add-flatbuf-result flag is specified on the command line
  19. ### for 'ya make ...' (tar archive is extracted to output directory).
  20. macro FBS_TO_PYSRC(OUT_NAME, IN_FBS_FILES...) {
  21. .CMD=${cwd:ARCADIA_BUILD_ROOT} ${tool:FLATC} --python --no-warnings --python-typing --gen-mutable ${FLATC_FLAGS_VALUE} ${pre=-I :_FLATC__INCLUDE} -o ${BINDIR} ${input:IN_FBS_FILES} && $YMAKE_PYTHON3 ${input:"build/scripts/tar_sources.py"} --exts .py --input $BINDIR --output ${output;noauto;tared:OUT_NAME.py3.fbs.pysrc} ${kv;hide:"p FP"} ${kv;hide:"pc light-green"} ${kv;hide:"tared_kind nodir"} ${hide:FBS_FAKEID}
  22. }
  23. macro FBS_TO_PY2SRC(OUT_NAME, IN_FBS_FILES...) {
  24. .CMD=${cwd:ARCADIA_BUILD_ROOT} ${tool:"contrib/deprecated/flatc"} --python --gen-mutable ${FLATC_FLAGS_VALUE} ${pre=-I :_FLATC__INCLUDE} -o ${BINDIR} ${input:IN_FBS_FILES} && $YMAKE_PYTHON3 ${input:"build/scripts/tar_sources.py"} --exts .py --input $BINDIR --output ${output;noauto;tared:OUT_NAME.py2.fbs.pysrc} ${kv;hide:"p FP"} ${kv;hide:"pc light-green"} ${kv;hide:"tared_kind nodir"} ${hide:FBS_FAKEID}
  25. }
  26. # tag:fbs tag:go-specific
  27. # Implicit dependencies of generated code for Go
  28. _GO_FLATC_IMPORTS=\
  29. ${GOSTD}/bytes \
  30. ${GOSTD}/strconv \
  31. vendor/github.com/google/flatbuffers/go
  32. # tag:fbs tag:cpp-specific
  33. macro _CPP_FLATC_CMD(SRC, SRCFLAGS...) {
  34. .CMD=${cwd:ARCADIA_BUILD_ROOT} $YMAKE_PYTHON3 ${input:"build/scripts/cpp_flatc_wrapper.py"} ${tool:FLATC} --no-warnings --cpp --keep-prefix --gen-mutable --schema -b --yandex-maps-iter --gen-object-api --filename-suffix .fbs ${FLATC_FLAGS_VALUE} ${pre=-I :_FLATC__INCLUDE} -o ${output;main;norel:SRC.h} ${output;hide;norel:SRC.cpp} ${input:SRC} ${output;hide;noext;norel:SRC.iter.fbs.h} ${output;noauto;hide;noext;norel:SRC.bfbs} ${kv;hide:"p FL"} ${kv;hide:"pc light-green"} ${hide:FBS_FAKEID}
  35. .SEM=target_fbs_source PRIVATE ${input:SRC} ${FLATC_FLAGS_VALUE} ${pre=-I :_FLATC__INCLUDE} ${output;hide;norel:SRC.h} ${output;hide;norel:SRC.cpp} ${output;hide;noext;norel:SRC.iter.fbs.h} ${output;noauto;hide;noext;norel:SRC.bfbs} ${hide;tool:FLATC} && target_macroses-ITEM && target_macroses-macro target_fbs_source && target_macroses-args PRIVATE ${input:SRC} ${FLATC_FLAGS_VALUE} ${pre=-I :_FLATC__INCLUDE} ${output;hide;norel:SRC.h} ${output;hide;norel:SRC.cpp} ${output;hide;noext;norel:SRC.iter.fbs.h} ${output;noauto;hide;noext;norel:SRC.bfbs} ${hide;tool:FLATC} && set_global_flags FBS_CPP_FLAGS --no-warnings --cpp --keep-prefix --gen-mutable --schema -b --yandex-maps-iter --gen-object-api --filename-suffix .fbs && platform_vars-FBS_CPP_FLAGS "--no-warnings --cpp --keep-prefix --gen-mutable --schema -b --yandex-maps-iter --gen-object-api --filename-suffix .fbs" ${input;hide:"build/scripts/cpp_flatc_wrapper.py"}
  36. .PEERDIR=contrib/libs/flatbuffers
  37. }
  38. # tag:fbs tag:cpp-specific
  39. macro _CPP_FLATC64_CMD(SRC, SRCFLAGS...) {
  40. .CMD=${cwd:ARCADIA_BUILD_ROOT} $YMAKE_PYTHON3 ${input:"build/scripts/cpp_flatc_wrapper.py"} ${tool:FLATC64} --no-warnings --cpp --keep-prefix --gen-mutable --schema -b --filename-suffix .fbs64 ${FLATC_FLAGS_VALUE} -I ${ARCADIA_ROOT} -I ${ARCADIA_BUILD_ROOT} -o ${output;main;norel:SRC.h} ${output;hide;norel:SRC.cpp} ${input:SRC} ${output;noauto;hide;noext;norel:SRC.bfbs64} ${kv;hide:"p FL64"} ${kv;hide:"pc light-green"} ${hide:FBS_FAKEID}
  41. .PEERDIR=contrib/libs/flatbuffers64
  42. }
  43. # tag:fbs tag:go-specific tag:internal
  44. ### @usage: _GO_FLATC_CMD(fbs_file flags...) # internal
  45. ###
  46. ### Create a tar archive of .go files generated by flatc for Go. Output tar archive
  47. ### will have .fbs.gosrc extension. This .fbs.gosrc is specially processed when
  48. ### --add-protobuf-result flag is specified on the command line for 'ya make ...'
  49. ### (tar archive is extracted to output directory).
  50. macro _GO_FLATC_CMD(SRC, PACKAGE_NAME) {
  51. .CMD=${cwd:ARCADIA_BUILD_ROOT} ${tool:FLATC} --go --gen-mutable --go-namespace ${PACKAGE_NAME} ${FLATC_FLAGS_VALUE} ${pre=-I :_FLATC__INCLUDE} -o ${BINDIR}/_generated ${input:SRC} && $YMAKE_PYTHON3 ${input:"build/scripts/postprocess_go_fbs.py"} --arcadia-prefix ${GO_ARCADIA_PROJECT_PREFIX} --input-dir ${BINDIR} --map $_FBS_NAMESPACE_MAP_GLOBAL && $YMAKE_PYTHON3 ${input:"build/scripts/tar_sources.py"} --flat --input ${BINDIR}/_generated --output ${output;noext;tared:SRC.fbs.gosrc} --exts .go ${kv;hide:"p FG"} ${kv;hide:"pc light-green"} ${kv;hide:"tared_kind nodir"} ${hide:FBS_FAKEID}
  52. .PEERDIR=${_GO_FLATC_IMPORTS}
  53. }
  54. # tag:fbs tag:java-specific tag:internal
  55. ### @usage: _JAVA_FLATC_CMD(fbs_file) # internal
  56. ###
  57. ### Create a tar archive of .java files generated by flatc for Java. Output tar
  58. ### acrchive will have .fbs.jsrc extension. Files with .fbs.jsrc extension will
  59. ### be added to results when --add-flatbuf-result flag is specified on the command
  60. ### line for 'ya make ...'
  61. macro _JAVA_FLATC_CMD(SRC, SRCFLAGS...) {
  62. .CMD=${cwd:ARCADIA_BUILD_ROOT} ${tool:FLATC} --java --gen-mutable ${FLATC_FLAGS_VALUE} ${pre=-I :_FLATC__INCLUDE} -o ${BINDIR} ${input:SRC} && $YMAKE_PYTHON3 ${input:"build/scripts/tar_sources.py"} --input $BINDIR --output ${output;nopath;noext:SRC.fbs.jsrc} --exts .java ${kv;hide:"p FJ"} ${kv;hide:"pc light-green"} ${hide:FBS_FAKEID}
  63. .PEERDIR=contrib/java/com/google/flatbuffers/flatbuffers-java/${JAVA_FLATBUFFERS_VERSION}
  64. }
  65. # tag:fbs
  66. _FBS_NAMESPACE_MAP_GLOBAL=
  67. # tag:fbs
  68. macro _FBS_NAMESPACE_IMPL(NAMESPACE, PATH, DUMMY...) {
  69. SET_APPEND(_FBS_NAMESPACE_MAP_GLOBAL ${NAMESPACE}=${PATH})
  70. }
  71. # tag:fbs
  72. macro FBS_NAMESPACE(NAMESPACE, PATH...) {
  73. _FBS_NAMESPACE_IMPL($NAMESPACE $PATH $MODDIR)
  74. }
  75. # tag:fbs
  76. ### @usage: FBS_LIBRARY()
  77. ###
  78. ### Build some variant of Flatbuffers library.
  79. ###
  80. ### The particular variant is selected based on where PEERDIR to FBS_LIBRARY
  81. ### comes from.
  82. ###
  83. ### Now supported 5 variants: C++, Java, Python 2.x, Python 3.x and Go.
  84. ### When PEERDIR comes from module for particular language appropriate variant
  85. ### is selected.
  86. ###
  87. ### Notes: FBS_NAMESPACE must be specified in all dependent FBS_LIBRARY modules
  88. ### if build of Go code is requested.
  89. multimodule FBS_LIBRARY {
  90. module CPP_FBS: LIBRARY {
  91. ENABLE(CPP_FBS)
  92. ENABLE(GEN_FBS)
  93. SET(PEERDIR_TAGS CPP_FBS)
  94. }
  95. module GO_FBS: GO_LIBRARY {
  96. .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER
  97. ENABLE(GO_FBS)
  98. SET(PEERDIR_TAGS GO GO_FBS)
  99. }
  100. module JAVA_FBS: EXTERNAL_JAVA_LIBRARY {
  101. .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER
  102. ENABLE(JAVA_FBS)
  103. SET(PEERDIR_TAGS JAVA_FBS)
  104. }
  105. module PY2_FBS: PY2_LIBRARY {
  106. .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER
  107. .ALIASES=SRCS=PY_SRCS
  108. ENABLE(PY2_FBS)
  109. SET(PEERDIR_TAGS PY2 PY2_FBS)
  110. # Can not use NO_LINT(), because is not allowed outside of contrib directory
  111. SET(_NO_LINT_VALUE none_internal)
  112. }
  113. module PY3_FBS: PY3_LIBRARY {
  114. .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER
  115. .ALIASES=SRCS=PY_SRCS
  116. ENABLE(PY3_FBS)
  117. SET(PEERDIR_TAGS PY3 PY3_FBS)
  118. # Can not use NO_LINT(), because is not allowed outside of contrib directory
  119. SET(_NO_LINT_VALUE none_internal)
  120. OBJ_SUF=.py3
  121. }
  122. }
  123. macro FBS_CMD(SRC, SRCFLAGS...) {
  124. .CMD=$_FBS_CMDLINE
  125. .SEM=$_FBS_CMDLINE
  126. }
  127. # tag:proto tag:fbs
  128. ### @usage: PROTO2FBS(InputProto)
  129. ###
  130. ### Produce flatbuf schema out of protobuf description.
  131. macro PROTO2FBS(File) {
  132. .CMD=${cwd:BINDIR} ${tool:FLATC} -I . -I ${ARCADIA_ROOT} --proto ${input:File} ${output;hide;norel;noext:File.fbs} ${kv;hide:"p FBS"} ${kv;hide:"pc yellow"} && $MOVE_FILE ${BINDIR}/${nopath;noext:File.fbs} ${output;norel;noext:File.fbs}
  133. }
  134. _CPP_FLATC_CMDLINE=$_CPP_FLATC_CMD($SRC $SRCFLAGS)
  135. _CPP_FLATC64_CMDLINE=$_CPP_FLATC64_CMD($SRC $SRCFLAGS)
  136. _JAVA_FLATC_CMDLINE=$_JAVA_FLATC_CMD($SRC $SRCFLAGS)