fbs.conf 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. # tag:fbs
  2. FLATC_FLAGS_VALUE=
  3. ### @usage: FLATC_FLAGS(flags...)
  4. ###
  5. ### Add flags to flatc command line
  6. macro FLATC_FLAGS(FLAGS...) {
  7. SET_APPEND(FLATC_FLAGS_VALUE $FLAGS)
  8. }
  9. # tag:fbs
  10. _PY_FBS_DEPS=contrib/python/flatbuffers
  11. # tag:fbs tag:internal
  12. ### @usage: FBS_TO_PYSRC(output_base_name fbs_files...) # internal
  13. ###
  14. ### Create a tar archive of .py files generated by flatc for Python. Output tar
  15. ### archive will have .fbs.pysrc extension. This .fbs.pysrc extension is specially
  16. ### processed when --add-flatbuf-result flag is specified on the command line
  17. ### for 'ya make ...' (tar archive is extracted to output directory).
  18. macro FBS_TO_PYSRC(OUT_NAME, IN_FBS_FILES...) {
  19. .CMD=${cwd:ARCADIA_BUILD_ROOT} ${tool:"contrib/tools/flatc"} --python --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}
  20. }
  21. macro FBS_TO_PY2SRC(OUT_NAME, IN_FBS_FILES...) {
  22. .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}
  23. }
  24. # tag:fbs tag:go-specific
  25. # Implicit dependencies of generated code for Go
  26. _GO_FLATC_IMPORTS=\
  27. ${GOSTD}/bytes \
  28. ${GOSTD}/strconv \
  29. vendor/github.com/google/flatbuffers/go
  30. # tag:fbs tag:cpp-specific
  31. macro _CPP_FLATC_CMD(SRC, SRCFLAGS...) {
  32. .CMD=${cwd:ARCADIA_BUILD_ROOT} $YMAKE_PYTHON3 ${input:"build/scripts/cpp_flatc_wrapper.py"} ${tool:"contrib/tools/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}
  33. .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:"contrib/tools/flatc/bin"} && set_global_flags 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"}
  34. .PEERDIR=contrib/libs/flatbuffers
  35. }
  36. # tag:fbs tag:cpp-specific
  37. macro _CPP_FLATC64_CMD(SRC, SRCFLAGS...) {
  38. .CMD=${cwd:ARCADIA_BUILD_ROOT} $YMAKE_PYTHON3 ${input:"build/scripts/cpp_flatc_wrapper.py"} ${tool:"contrib/tools/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}
  39. .PEERDIR=contrib/libs/flatbuffers64
  40. }
  41. # tag:fbs tag:go-specific tag:internal
  42. ### @usage: _GO_FLATC_CMD(fbs_file flags...) # internal
  43. ###
  44. ### Create a tar archive of .go files generated by flatc for Go. Output tar archive
  45. ### will have .fbs.gosrc extension. This .fbs.gosrc is specially processed when
  46. ### --add-protobuf-result flag is specified on the command line for 'ya make ...'
  47. ### (tar archive is extracted to output directory).
  48. macro _GO_FLATC_CMD(SRC, PACKAGE_NAME) {
  49. .CMD=${cwd:ARCADIA_BUILD_ROOT} ${tool:"contrib/tools/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}
  50. .PEERDIR=${_GO_FLATC_IMPORTS}
  51. }
  52. # tag:fbs tag:java-specific tag:internal
  53. ### @usage: _JAVA_FLATC_CMD(fbs_file) # internal
  54. ###
  55. ### Create a tar archive of .java files generated by flatc for Java. Output tar
  56. ### acrchive will have .fbs.jsrc extension. Files with .fbs.jsrc extension will
  57. ### be added to results when --add-flatbuf-result flag is specified on the command
  58. ### line for 'ya make ...'
  59. macro _JAVA_FLATC_CMD(SRC, SRCFLAGS...) {
  60. .CMD=${cwd:ARCADIA_BUILD_ROOT} ${tool:"contrib/tools/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}
  61. .PEERDIR=contrib/java/com/google/flatbuffers/flatbuffers-java/${JAVA_FLATBUFFERS_VERSION}
  62. }
  63. # tag:fbs
  64. _FBS_NAMESPACE_MAP_GLOBAL=
  65. # tag:fbs
  66. macro _FBS_NAMESPACE_IMPL(NAMESPACE, PATH, DUMMY...) {
  67. SET_APPEND(_FBS_NAMESPACE_MAP_GLOBAL ${NAMESPACE}=${PATH})
  68. }
  69. # tag:fbs
  70. macro FBS_NAMESPACE(NAMESPACE, PATH...) {
  71. _FBS_NAMESPACE_IMPL($NAMESPACE $PATH $MODDIR)
  72. }
  73. # tag:fbs
  74. ### @usage: FBS_LIBRARY()
  75. ###
  76. ### Build some variant of Flatbuffers library.
  77. ###
  78. ### The particular variant is selected based on where PEERDIR to FBS_LIBRARY
  79. ### comes from.
  80. ###
  81. ### Now supported 5 variants: C++, Java, Python 2.x, Python 3.x and Go.
  82. ### When PEERDIR comes from module for particular language appropriate variant
  83. ### is selected.
  84. ###
  85. ### Notes: FBS_NAMESPACE must be specified in all dependent FBS_LIBRARY modules
  86. ### if build of Go code is requested.
  87. multimodule FBS_LIBRARY {
  88. module CPP_FBS: LIBRARY {
  89. ENABLE(CPP_FBS)
  90. ENABLE(GEN_FBS)
  91. SET(PEERDIR_TAGS CPP_FBS)
  92. }
  93. module GO_FBS: GO_LIBRARY {
  94. .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER
  95. ENABLE(GO_FBS)
  96. SET(PEERDIR_TAGS GO GO_FBS)
  97. }
  98. module JAVA_FBS: EXTERNAL_JAVA_LIBRARY {
  99. .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER
  100. ENABLE(JAVA_FBS)
  101. SET(PEERDIR_TAGS JAVA_FBS)
  102. }
  103. module PY2_FBS: PY2_LIBRARY {
  104. .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER
  105. .ALIASES=SRCS=PY_SRCS
  106. ENABLE(PY2_FBS)
  107. SET(PEERDIR_TAGS PY2 PY2_FBS)
  108. # Can not use NO_LINT(), because is not allowed outside of contrib directory
  109. SET(_NO_LINT_VALUE none_internal)
  110. }
  111. module PY3_FBS: PY3_LIBRARY {
  112. .IGNORED=GENERATE_ENUM_SERIALIZATION GENERATE_ENUM_SERIALIZATION_WITH_HEADER
  113. .ALIASES=SRCS=PY_SRCS
  114. ENABLE(PY3_FBS)
  115. SET(PEERDIR_TAGS PY3 PY3_FBS)
  116. # Can not use NO_LINT(), because is not allowed outside of contrib directory
  117. SET(_NO_LINT_VALUE none_internal)
  118. OBJ_SUF=.py3
  119. }
  120. }
  121. macro FBS_CMD(SRC, SRCFLAGS...) {
  122. .CMD=$_FBS_CMDLINE
  123. .SEM=$_FBS_CMDLINE
  124. }
  125. _CPP_FLATC_CMDLINE=$_CPP_FLATC_CMD($SRC $SRCFLAGS)
  126. _CPP_FLATC64_CMDLINE=$_CPP_FLATC64_CMD($SRC $SRCFLAGS)
  127. _JAVA_FLATC_CMDLINE=$_JAVA_FLATC_CMD($SRC $SRCFLAGS)