yql_udf.conf 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. when ($SANITIZER_TYPE || $USE_ARCADIA_PYTHON == "no" || $UDF_NO_PROBE == "yes" || $MUSL == "yes" || $TIDY == "yes") {
  2. YQL_UDF_LINK_CMD=$LINK_DYN_LIB
  3. YQL_UDF_LINK_PRG_CMD=$LINK_EXEC_DYN_LIB
  4. }
  5. otherwise {
  6. YQL_UDF_LINK_CMD=$LINK_DYN_LIB && ${tool:"contrib/ydb/library/yql/tools/udf_probe"} $TARGET ${hide;kv:"p UD"}
  7. YQL_UDF_LINK_PRG_CMD=$LINK_EXEC_DYN_LIB && ${tool:"contrib/ydb/library/yql/tools/udf_probe"} $TARGET ${hide;kv:"p UD"}
  8. }
  9. ### @usage: UDF_BASE(name [EXPORTS symlist_file] [PREFIX prefix]) #internal
  10. ###
  11. ### The base logic of all UDF extension modules (User-Defined Functions).
  12. ### Processing EXPORTS and PREFIX is the same as for DLL.
  13. ###
  14. ### https://wiki.yandex-team.ru/robot/manual/kiwi/userguide/#polzovatelskiefunkciiudftriggerykwcalc
  15. module UDF_BASE: DLL_UNIT {
  16. when ($MSVC != "yes" && $DARWIN != "yes") {
  17. LDFLAGS+= -Wl,-Bsymbolic
  18. }
  19. }
  20. UDF_NO_PROBE="no"
  21. ### @usage: UDF_NO_PROBE()
  22. ###
  23. ### Disable UDF import check at build stage
  24. macro UDF_NO_PROBE() {
  25. ENABLE(UDF_NO_PROBE)
  26. }
  27. ### @usage: YQL_UDF_TEST([name])
  28. ###
  29. ### The module to test YQL C++ UDF.
  30. ###
  31. ### Documentation: https://yql.yandex-team.ru/docs/yt/libraries/testing/
  32. ### Documentation about the Arcadia test system: https://wiki.yandex-team.ru/yatool/test/
  33. module YQL_UDF_TEST: PY3TEST_BIN {
  34. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS canondata/result.json)
  35. PEERDIR(contrib/ydb/library/yql/tests/common/udf_test)
  36. DEPENDS(contrib/ydb/library/yql/tools/astdiff)
  37. DEPENDS(contrib/ydb/library/yql/tools/yqlrun)
  38. DEPENDS(contrib/ydb/library/yql/tools/udf_resolver)
  39. DATA(arcadia/contrib/ydb/library/yql/mount)
  40. DATA(arcadia/contrib/ydb/library/yql/cfg/udf_test)
  41. ENV(YQL_ASTDIFF_PATH="contrib/ydb/library/yql/tools/astdiff/astdiff")
  42. ENV(YQL_CONFIG_DIR="contrib/ydb/library/yql/cfg/udf_test")
  43. ENV(YQL_YQLRUN_PATH="contrib/ydb/library/yql/tools/yqlrun/yqlrun")
  44. ENV(YQL_SQL2YQL_PATH="contrib/ydb/library/yql/tools/sql2yql/sql2yql")
  45. ENV(YQL_UDFRESOLVER_PATH="contrib/ydb/library/yql/tools/udf_resolver/udf_resolver")
  46. }
  47. module YQL_UDF_YDB_TEST: PY3TEST_BIN {
  48. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS canondata/result.json)
  49. PEERDIR(ydb/library/yql/tests/common/udf_test)
  50. DEPENDS(ydb/library/yql/tools/astdiff)
  51. DEPENDS(ydb/library/yql/tools/yqlrun)
  52. DEPENDS(ydb/library/yql/tools/udf_resolver)
  53. DATA(arcadia/ydb/library/yql/mount)
  54. DATA(arcadia/ydb/library/yql/cfg/udf_test)
  55. }
  56. module YQL_UDF_TEST_CONTRIB: PY3TEST_BIN {
  57. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS canondata/result.json)
  58. PEERDIR(contrib/ydb/library/yql/tests/common/udf_test)
  59. DEPENDS(contrib/ydb/library/yql/tools/astdiff)
  60. DEPENDS(contrib/ydb/library/yql/tools/yqlrun)
  61. DEPENDS(contrib/ydb/library/yql/tools/udf_resolver)
  62. DATA(arcadia/contrib/ydb/library/yql/mount)
  63. DATA(arcadia/contrib/ydb/library/yql/cfg/udf_test)
  64. ENV(YQL_ASTDIFF_PATH="contrib/ydb/library/yql/tools/astdiff/astdiff")
  65. ENV(YQL_CONFIG_DIR="contrib/ydb/library/yql/cfg/udf_test")
  66. ENV(YQL_YQLRUN_PATH="contrib/ydb/library/yql/tools/yqlrun/yqlrun")
  67. ENV(YQL_SQL2YQL_PATH="contrib/ydb/library/yql/tools/sql2yql/sql2yql")
  68. ENV(YQL_UDFRESOLVER_PATH="contrib/ydb/library/yql/tools/udf_resolver/udf_resolver")
  69. }
  70. ### @usage: _ADD_YQL_UDF_DEPS()
  71. ###
  72. ### Add all needed PEERDIRs to a YQL_UDF.
  73. ###
  74. ### https://yql.yandex-team.ru/docs/yt/udf/cpp/
  75. macro _ADD_YQL_UDF_DEPS() {
  76. PEERDIR(${YQL_BASE_DIR}/public/udf)
  77. PEERDIR(${YQL_BASE_DIR}/public/udf/support)
  78. }
  79. macro _ADD_YQL_UDF_YDB_DEPS() {
  80. PEERDIR(ydb/library/yql/public/udf)
  81. PEERDIR(ydb/library/yql/public/udf/support)
  82. }
  83. macro _ADD_YQL_UDF_DEPS_CONTRIB() {
  84. PEERDIR(contrib/ydb/library/yql/public/udf)
  85. PEERDIR(contrib/ydb/library/yql/public/udf/support)
  86. }
  87. ### @usage: _MAKE_YQL_UDF()
  88. ###
  89. ### Make module definition an YQL UDF: add all needed dependencies, properties and flags
  90. ###
  91. ### https://yql.yandex-team.ru/docs/yt/udf/cpp/
  92. macro _MAKE_YQL_UDF() {
  93. _ADD_YQL_UDF_DEPS()
  94. SET_APPEND(USER_CXXFLAGS -DBUILD_UDF)
  95. # For Windows using declspecs
  96. DEFAULT(YQL_UDF_EXPORT ${ARCADIA_ROOT}/${YQL_BASE_DIR}/public/udf/udfs_exports.exports)
  97. when ($WINDOWS == "yes") {
  98. YQL_UDF_EXPORT=
  99. }
  100. SET(EXPORTS_FILE $YQL_UDF_EXPORT)
  101. }
  102. macro _MAKE_YQL_UDF_YDB() {
  103. _ADD_YQL_UDF_YDB_DEPS()
  104. SET_APPEND(USER_CXXFLAGS -DBUILD_UDF)
  105. # For Windows using declspecs
  106. DEFAULT(YQL_UDF_EXPORT ${ARCADIA_ROOT}/ydb/library/yql/public/udf/udfs_exports.exports)
  107. when ($WINDOWS == "yes") {
  108. YQL_UDF_EXPORT=
  109. }
  110. SET(EXPORTS_FILE $YQL_UDF_EXPORT)
  111. }
  112. macro _MAKE_YQL_UDF_CONTRIB() {
  113. _ADD_YQL_UDF_DEPS_CONTRIB()
  114. SET_APPEND(USER_CXXFLAGS -DBUILD_UDF)
  115. # For Windows using declspecs
  116. DEFAULT(YQL_UDF_EXPORT ${ARCADIA_ROOT}/contrib/ydb/library/yql/public/udf/udfs_exports.exports)
  117. when ($WINDOWS == "yes") {
  118. YQL_UDF_EXPORT=
  119. }
  120. SET(EXPORTS_FILE $YQL_UDF_EXPORT)
  121. }
  122. ### @usage: YQL_UDF_MODULE(name)
  123. ###
  124. ### The extension module for YQL with C++ UDF (User Defined Function YQL)
  125. ###
  126. ### https://yql.yandex-team.ru/docs/yt/udf/cpp/
  127. module YQL_UDF_MODULE: UDF_BASE {
  128. .CMD=$YQL_UDF_LINK_CMD
  129. _MAKE_YQL_UDF()
  130. PROVIDES(YqlServicePolicy)
  131. }
  132. module YQL_UDF_YDB_MODULE: UDF_BASE {
  133. .CMD=$YQL_UDF_LINK_CMD
  134. _MAKE_YQL_UDF_YDB()
  135. PROVIDES(YqlServicePolicy)
  136. }
  137. module YQL_UDF_MODULE_CONTRIB: UDF_BASE {
  138. .CMD=$YQL_UDF_LINK_CMD
  139. _MAKE_YQL_UDF_CONTRIB()
  140. PROVIDES(YqlServicePolicy)
  141. }
  142. module _YQL_UDF_PROGRAM_BASE: SO_PROGRAM {
  143. .CMD=$YQL_UDF_LINK_PRG_CMD
  144. _MAKE_YQL_UDF()
  145. }
  146. UDF_SHARED_SEM=$CPP_DYN_LIBRARY_SEM
  147. ### @usage: YQL_UDF(name)
  148. ###
  149. ### User-defined function for YQL
  150. ###
  151. ### Multimodule which is YQL_UDF_MODULE when built directly or referred by BUNDLE and DEPENDS macros.
  152. ### If used by PEERDIRs it is usual static LIBRARY with default YQL dependencies, allowing code reuse between UDFs.
  153. ###
  154. ### @see: [YQL_UDF_MODULE()](#module_YQL_UDF_MODULE)
  155. multimodule YQL_UDF {
  156. module YQL_UDF_SHARED: YQL_UDF_MODULE {
  157. .SEM=UDF_SHARED_SEM
  158. CMAKE_TARGET_NAME=${REALPRJNAME}.dyn
  159. CMAKE_TARGET_ARTEFACT_RENAME_RULES=&& set_target_property OUTPUT_NAME $REALPRJNAME && target_properties-ITEM && target_properties-name OUTPUT_NAME && target_properties-value $REALPRJNAME
  160. NO_CLANG_TIDY()
  161. }
  162. module YQL_UDF_STATIC: _DLL_COMPATIBLE_LIBRARY {
  163. .ALIASES=SRCS=GLOBAL_SRCS
  164. .SEM=CPP_LIBRARY_SEM
  165. .GLOBAL_SEM=CPP_OBJ_LIBRARY_SEM
  166. OBJ_SUF=.udfs
  167. _ADD_YQL_UDF_DEPS()
  168. # disable credits generation for static library
  169. SET(CREDITS_FLAGS)
  170. when ($MSVC == "yes" || $CYGWIN == "yes") {
  171. MODULE_SUFFIX=.static.lib
  172. }
  173. }
  174. }
  175. multimodule YQL_UDF_YDB {
  176. module YQL_UDF_SHARED: YQL_UDF_YDB_MODULE {
  177. .SEM=UDF_SHARED_SEM
  178. CMAKE_TARGET_NAME=${REALPRJNAME}.dyn
  179. CMAKE_TARGET_ARTEFACT_RENAME_RULES=&& set_target_property OUTPUT_NAME $REALPRJNAME && target_properties-ITEM && target_properties-name OUTPUT_NAME && target_properties-value $REALPRJNAME
  180. NO_CLANG_TIDY()
  181. }
  182. module YQL_UDF_STATIC: _DLL_COMPATIBLE_LIBRARY {
  183. .ALIASES=SRCS=GLOBAL_SRCS
  184. .SEM=CPP_LIBRARY_SEM
  185. .GLOBAL_SEM=CPP_OBJ_LIBRARY_SEM
  186. OBJ_SUF=.udfs
  187. _ADD_YQL_UDF_YDB_DEPS()
  188. # disable credits generation for static library
  189. SET(CREDITS_FLAGS)
  190. when ($MSVC == "yes" || $CYGWIN == "yes") {
  191. MODULE_SUFFIX=.static.lib
  192. }
  193. }
  194. }
  195. multimodule YQL_UDF_CONTRIB {
  196. module YQL_UDF_SHARED: YQL_UDF_MODULE_CONTRIB {
  197. .SEM=UDF_SHARED_SEM
  198. NO_CLANG_TIDY()
  199. }
  200. module YQL_UDF_STATIC: _DLL_COMPATIBLE_LIBRARY {
  201. .ALIASES=SRCS=GLOBAL_SRCS
  202. .SEM=CPP_LIBRARY_SEM
  203. .GLOBAL_SEM=CPP_OBJ_LIBRARY_SEM
  204. OBJ_SUF=.udfs
  205. _ADD_YQL_UDF_DEPS_CONTRIB()
  206. # disable credits generation for static library
  207. SET(CREDITS_FLAGS)
  208. when ($MSVC == "yes" || $CYGWIN == "yes") {
  209. MODULE_SUFFIX=.static.lib
  210. }
  211. }
  212. }
  213. ### @usage: YQL_ABI_VERSION(major minor release))
  214. ###
  215. ### Specifying the supported ABI for YQL_UDF.
  216. ###
  217. ### @see: [YQL_UDF()](#multimodule_YQL_UDF)
  218. macro YQL_ABI_VERSION(Major, Minor, Patch) {
  219. YQL_ABI_FLAGS=-DUDF_ABI_VERSION_MAJOR=$Major -DUDF_ABI_VERSION_MINOR=$Minor -DUDF_ABI_VERSION_PATCH=$Patch
  220. SET_APPEND(USER_CXXFLAGS $YQL_ABI_FLAGS)
  221. }
  222. ### @usage: YQL_LAST_ABI_VERSION()
  223. ###
  224. ### Use the last ABI for YQL_UDF
  225. ###
  226. macro YQL_LAST_ABI_VERSION() {
  227. YQL_ABI_FLAGS=-DUSE_CURRENT_UDF_ABI_VERSION
  228. SET_APPEND(USER_CXXFLAGS $YQL_ABI_FLAGS)
  229. }
  230. ### @usage: YQL_PYTHON_UDF(name)
  231. ###
  232. ### Definition of the extension module for YQL with Python 2.x UDF (User Defined Function for YQL).
  233. ### Unlike YQL_UDF this is plain DLL module, so PEERDIRs to it are not allowed.
  234. ###
  235. ### https://yql.yandex-team.ru/docs/yt/udf/python/
  236. module YQL_PYTHON_UDF: YQL_UDF_MODULE {
  237. .IGNORED=USE_PYTHON2
  238. .RESTRICTED=PYTHON3_ADDINCL USE_PYTHON3 PYTHON2_ADDINCL
  239. USE_PYTHON2()
  240. _ARCADIA_PYTHON_ADDINCL()
  241. PEERDIR(build/platform/python/ldflags)
  242. PEERDIR(library/python/type_info)
  243. DEFAULT(YQL_PYTHON_UDF_EXPORT ${ARCADIA_ROOT}/${YQL_BASE_DIR}/udfs/common/python/python_udf/python_udfs_exports.exports)
  244. when ($WINDOWS == "yes") {
  245. YQL_PYTHON_UDF_EXPORT=
  246. }
  247. ### FIXME: XXX the statement below uncoditionally set EXPORTS_FILE (due to incorrect behaviour of old ConfReader
  248. ###when ($USE_ARCADIA_PYTHON == "yes") SET(EXPORTS_FILE $YQL_PYTHON_UDF_EXPORT)
  249. SET(EXPORTS_FILE $YQL_PYTHON_UDF_EXPORT)
  250. SET(MODULE_LANG PY2)
  251. }
  252. ### @usage: YQL_PYTHON_UDF_PROGRAM(name)
  253. ###
  254. ### Definition of the extension module for YQL with Python 2.x UDF (User Defined Function for YQL).
  255. ### Unlike YQL_UDF this is plain DLL module, so PEERDIRs to it are not allowed.
  256. ###
  257. ### https://yql.yandex-team.ru/docs/yt/udf/python/
  258. module YQL_PYTHON_UDF_PROGRAM: _YQL_UDF_PROGRAM_BASE {
  259. .IGNORED=USE_PYTHON2
  260. .RESTRICTED=PYTHON3_ADDINCL USE_PYTHON3 PYTHON2_ADDINCL
  261. USE_PYTHON2()
  262. _ARCADIA_PYTHON_ADDINCL()
  263. PEERDIR(build/platform/python/ldflags)
  264. PEERDIR(library/python/type_info)
  265. DEFAULT(YQL_PYTHON_UDF_EXPORT ${ARCADIA_ROOT}/${YQL_BASE_DIR}/udfs/common/python/python_udf/python_udfs_exports.exports)
  266. when ($WINDOWS == "yes") {
  267. YQL_PYTHON_UDF_EXPORT=
  268. }
  269. ### FIXME: XXX the statement below uncoditionally set EXPORTS_FILE (due to incorrect behaviour of old ConfReader
  270. ###when ($USE_ARCADIA_PYTHON == "yes") SET(EXPORTS_FILE $YQL_PYTHON_UDF_EXPORT)
  271. SET(EXPORTS_FILE $YQL_PYTHON_UDF_EXPORT)
  272. SET(MODULE_LANG PY2)
  273. }
  274. ### @usage: YQL_PYTHON3_UDF(name)
  275. ###
  276. ### The extension module for YQL with Python 3.x UDF (User Defined Function for YQL).
  277. ### Unlike YQL_UDF this is plain DLL module, so PEERDIRs to it are not allowed.
  278. ###
  279. ### Documentation: https://yql.yandex-team.ru/docs/yt/udf/python/
  280. module YQL_PYTHON3_UDF: YQL_UDF_MODULE {
  281. .RESTRICTED=PYTHON2_ADDINCL PYTHON3_ADDINCL USE_PYTHON2 USE_PYTHON3
  282. _ARCADIA_PYTHON3_ADDINCL()
  283. PEERDIR(build/platform/python/ldflags)
  284. PEERDIR(library/python/type_info)
  285. DEFAULT(YQL_PYTHON_UDF_EXPORT ${ARCADIA_ROOT}/${YQL_BASE_DIR}/udfs/common/python/python_udf/python_udfs_exports.exports)
  286. when ($WINDOWS == "yes") {
  287. YQL_PYTHON_UDF_EXPORT=
  288. }
  289. ### FIXME: XXX the statement below uncoditionally set EXPORTS_FILE (due to incorrect behaviour of old ConfReader
  290. ###when ($USE_ARCADIA_PYTHON == "yes") SET(EXPORTS_FILE $YQL_PYTHON_UDF_EXPORT)
  291. SET(EXPORTS_FILE $YQL_PYTHON_UDF_EXPORT)
  292. SET(MODULE_LANG PY3)
  293. }
  294. macro _MAKE_YQL_PYTHON_UDF_TEST() {
  295. PEERDIR(library/python/pytest)
  296. DEPENDS(yql/tools/run_python_udf)
  297. SETUP_PYTEST_BIN(RUNNER_BIN $(BUILD_ROOT)/yql/tools/run_python_udf/run_python_udf)
  298. }
  299. ### @usage: YQL_PYTHON_UDF_TEST(name)
  300. ###
  301. ### The Python test for Python YQL UDF (Python User Defined Function for YQL). The code should be a proper YQL_PYTHON_UDF.
  302. ###
  303. ### This module will basically build itself as UDF and run as test using yql/tools/run_python_udf/run_python_udf tool.
  304. ###
  305. ### Documentation: https://yql.yandex-team.ru/docs/yt/udf/python/
  306. ###
  307. ### @example: https://a.yandex-team.ru/arc/trunk/arcadia/yql/udfs/test/simple/ya.make
  308. ###
  309. ### @see: [YQL_PYTHON_UDF()](#module_YQL_PYTHON_UDF)
  310. module YQL_PYTHON_UDF_TEST: YQL_PYTHON_UDF {
  311. _MAKE_YQL_PYTHON_UDF_TEST()
  312. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS canondata/result.json)
  313. }
  314. ### @usage: YQL_PYTHON3_UDF_TEST(name)
  315. ###
  316. ### The Python test for Python 3.x YQL UDF (User Defined Function for YQL). The code should be a proper YQL_PYTHON3_UDF.
  317. ###
  318. ### This module will basically build itself as UDF and run as test using yql/tools/run_python_udf/run_python_udf tool.
  319. ###
  320. ### Documentation: https://yql.yandex-team.ru/docs/yt/udf/python/
  321. ###
  322. ### @see: [YQL_PYTHON3_UDF()](#module_YQL_PYTHON3_UDF)
  323. module YQL_PYTHON3_UDF_TEST: YQL_PYTHON3_UDF {
  324. _MAKE_YQL_PYTHON_UDF_TEST()
  325. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS canondata/result.json)
  326. }