ts.conf 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. NODEJS_ROOT=$NODEJS_RESOURCE_GLOBAL
  2. NODEJS_BIN=$NODEJS_ROOT/node
  3. PNPM_ROOT=$PNPM_RESOURCE_GLOBAL
  4. PNPM_SCRIPT=$PNPM_ROOT/pnpm.js
  5. TSC_ROOT=$TS_COMPILER_RESOURCE_GLOBAL/typescript
  6. TSC_SCRIPT=$TSC_ROOT/lib/tsc.js
  7. WEBPACK_ROOT=$WEBPACK_RESOURCE_GLOBAL/node_modules
  8. WEBPACK_SCRIPT=$WEBPACK_ROOT/.bin/webpack
  9. NOTS_TOOL=${tool:"tools/nots"}
  10. NOTS_TOOL_BASE_ARGS=--build-root $ARCADIA_BUILD_ROOT --bindir $BINDIR --curdir $CURDIR --nodejs-bin $NODEJS_BIN
  11. NPM_CONTRIBS_PATH=devtools/dummy_arcadia/ts/contribs
  12. ### @usage: NPM_CONTRIBS() # internal
  13. ###
  14. ### Defines special module that provides contrib tarballs from internal npm registry.
  15. ### Should be used only with `NODE_MODULES` macro.
  16. ###
  17. ### @see [FROM_NPM_LOCKFILES()](#macro_FROM_NPM_LOCKFILES)
  18. ### @see [NODE_MODULES()](#macro_NODE_MODULES)
  19. module NPM_CONTRIBS: _BASE_UNIT {
  20. .CMD=TOUCH_UNIT
  21. .PEERDIR_POLICY=as_build_from
  22. .FINAL_TARGET=no
  23. .ALLOWED=FROM_NPM_LOCKFILES
  24. .RESTRICTED=PEERDIR
  25. SET(MODULE_TAG NPM_CONTRIBS)
  26. MODULE_SUFFIX=.fake
  27. _BARE_MODULE()
  28. }
  29. ### @usage: FROM_NPM_LOCKFILES(LOCKFILES...) # internal
  30. ###
  31. ### Defines lockfile list for `NPM_CONTRIBS` module.
  32. ###
  33. ### @see [NPM_CONTRIBS()](#module_NPM_CONTRIBS)
  34. macro FROM_NPM_LOCKFILES(LOCKFILES...) {
  35. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS $LOCKFILES)
  36. # See implementation in build/plugins/nots.py
  37. _FROM_NPM_LOCKFILES($LOCKFILES)
  38. }
  39. ### @usage: FROM_NPM(NAME VERSION SKY_ID INTEGRITY INTEGRITY_ALGO TARBALL_PATH)
  40. macro FROM_NPM(NAME, VERSION, SKY_ID, INTEGRITY, INTEGRITY_ALGO, TARBALL_PATH) {
  41. .CMD=${cwd:BINDIR} $YMAKE_PYTHON ${input:"build/scripts/fetch_from_npm.py"} ${input;hide:"build/scripts/fetch_from.py"} ${input;hide:"build/scripts/sky.py"} --name $NAME --version $VERSION --sky-id $SKY_ID --integrity $INTEGRITY --integrity-algorithm $INTEGRITY_ALGO --copy-to ${output:TARBALL_PATH} ${requirements;hide:"network:full"} ${kv;hide:"p NP"} ${kv;hide:"pc yellow"}
  42. }
  43. ### @usage: NODE_MODULES()
  44. ###
  45. ### Materializes `node_modules.tar` bundle according to the module's lockfile.
  46. ###
  47. ### @see [NPM_CONTRIBS()](#module_NPM_CONTRIBS)
  48. macro NODE_MODULES() {
  49. # See implementation in build/plugins/nots.py
  50. }
  51. _NODE_MODULES_INPUTS=
  52. macro _NODE_MODULES(IN{input}[], OUT{output}[]) {
  53. PEERDIR($NPM_CONTRIBS_PATH)
  54. SET(_NODE_MODULES_INPUTS \${input;hide:node_modules.tar})
  55. .CMD=${cwd:BINDIR} $NOTS_TOOL create-node-modules $NOTS_TOOL_BASE_ARGS --pnpm-script $PNPM_SCRIPT --contribs $NPM_CONTRIBS_PATH ${input;hide:IN} ${output;global;hide:OUT} ${kv;hide:"p NM"} ${kv;hide:"pc yellow"}
  56. }
  57. module _TS_BASE_UNIT: _BASE_UNIT {
  58. SET(MODULE_TAG TS)
  59. SET(PEERDIR_TAGS TS NPM_CONTRIBS)
  60. PEERDIR(build/platform/nodejs)
  61. PEERDIR(build/external_resources/pnpm)
  62. PEERDIR(build/external_resources/typescript)
  63. MODULE_SUFFIX=.fake
  64. _BARE_MODULE()
  65. }
  66. TS_CONFIG_PATH=tsconfig.json
  67. TS_COMPILE=${cwd:BINDIR} $NOTS_TOOL compile-ts $NOTS_TOOL_BASE_ARGS --tsc-script $TSC_SCRIPT --config ${input:TS_CONFIG_PATH} ${hide:PEERS} $_NODE_MODULES_INPUTS ${output;hide:"package.json"} ${kv;hide:"p FE"} ${kv;hide:"pc yellow"} && $TOUCH_UNIT
  68. ### @usage: TS_LIBRARY([name])
  69. ###
  70. ### The TypeScript/JavaScript library module, compiles TypeScript sources to JavaScript.
  71. ### Build results are JavaScript files, typings and source mappings (depending on local tsconfig.json settings).
  72. ###
  73. ### @see [NODE_MODULES()](#macro_NODE_MODULES)
  74. ### @example
  75. ###
  76. ### TS_LIBRARY()
  77. ### SRCS(src/index.ts)
  78. ### NODE_MODULES()
  79. ### END()
  80. ###
  81. module TS_LIBRARY : _TS_BASE_UNIT {
  82. .CMD=TS_COMPILE
  83. .FINAL_TARGET=yes
  84. .PEERDIR_POLICY=as_build_from
  85. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS ${CURDIR}/${TS_CONFIG_PATH} ${CURDIR}/package.json)
  86. SET(TS_CONFIG_DEDUCE_OUT yes)
  87. _TS_CONFIGURE($TS_CONFIG_PATH)
  88. }
  89. WEBPACK_CONFIG_PATH=webpack.config.js
  90. TS_BUNDLE_WEBPACK=${cwd:BINDIR} $NOTS_TOOL bundle-webpack $NOTS_TOOL_BASE_ARGS --webpack-root $WEBPACK_ROOT --webpack-script $WEBPACK_SCRIPT --config ${input:WEBPACK_CONFIG_PATH} ${hide:PEERS} $_NODE_MODULES_INPUTS ${output;hide:"bundle.tar"} ${kv;hide:"p FE"} ${kv;hide:"pc yellow"} && $TOUCH_UNIT
  91. ### @usage: TS_BUNDLE([name])
  92. ###
  93. ### The Webpack bundle, bundles JavaScript code.
  94. ### Build results are bundle.tar, typings and source mappings (depending on local tsconfig.json settings).
  95. ###
  96. ### @see [NODE_MODULES()](#macro_NODE_MODULES)
  97. ### @example
  98. ###
  99. ### TS_BUNDLE()
  100. ### SRCS(src/index.ts)
  101. ### NODE_MODULES()
  102. ### END()
  103. ###
  104. module TS_BUNDLE : _TS_BASE_UNIT {
  105. .CMD=TS_BUNDLE_WEBPACK
  106. .FINAL_TARGET=yes
  107. .PEERDIR_POLICY=as_build_from
  108. DECLARE_EXTERNAL_RESOURCE(WEBPACK sbr:2815569512)
  109. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS ${CURDIR}/${WEBPACK_CONFIG_PATH} ${CURDIR}/package.json)
  110. SET(TS_CONFIG_DEDUCE_OUT no)
  111. _TS_CONFIGURE($TS_CONFIG_PATH)
  112. }