node_modules.conf 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. PNPM_ROOT=
  2. PNPM_SCRIPT=$PNPM_ROOT/node_modules/pnpm/dist/pnpm.cjs
  3. NPM_ROOT=
  4. NPM_SCRIPT=$NPM_ROOT/node_modules/npm/bin/npm-cli.js
  5. PM_SCRIPT=
  6. PM_TYPE=
  7. NPM_CONTRIBS_PATH=contrib/typescript
  8. # combined input/outputs records as list of directives ${input;hide:<path>} ${output;hide:<path>}, used in builders
  9. _NODE_MODULES_INOUTS=
  10. _YATOOL_PREBUILDER_ARG=
  11. macro CUSTOM_CONTRIB_TYPESCRIPT(P) {
  12. SET(NPM_CONTRIBS_PATH $P)
  13. }
  14. macro NO_CONTRIB_TYPESCRIPT() {
  15. SET(NPM_CONTRIBS_PATH -)
  16. }
  17. ### @usage: NPM_CONTRIBS() # internal
  18. ###
  19. ### Defines special module that provides contrib tarballs from internal npm registry.
  20. ###
  21. ### @see [FROM_NPM_LOCKFILES()](#macro_FROM_NPM_LOCKFILES)
  22. module NPM_CONTRIBS: _BARE_UNIT {
  23. .CMD=TOUCH_UNIT
  24. .PEERDIR_POLICY=as_build_from
  25. .FINAL_TARGET=no
  26. .ALLOWED=FROM_NPM_LOCKFILES
  27. .RESTRICTED=PEERDIR
  28. .EXTS=_ # Ignore all files, so module is not affected by FROM_NPM output (.EXTS=* is inherited from _BARE_UNIT)
  29. SET(MODULE_TAG NPM_CONTRIBS)
  30. SET(MODULE_LANG TS)
  31. # .fake tells builder to not materialize it in results
  32. SET(MODULE_SUFFIX .fake)
  33. }
  34. ### @usage: FROM_NPM_LOCKFILES(LOCKFILES...) # internal
  35. ###
  36. ### Defines lockfile list for `NPM_CONTRIBS` module.
  37. ###
  38. ### @see [NPM_CONTRIBS()](#module_NPM_CONTRIBS)
  39. macro FROM_NPM_LOCKFILES(LOCKFILES...) {
  40. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS $LOCKFILES)
  41. # See implementation in build/plugins/nots.py
  42. _FROM_NPM_LOCKFILES($LOCKFILES)
  43. }
  44. FROM_NPM_CWD=$ARCADIA_BUILD_ROOT/$NPM_CONTRIBS_PATH
  45. macro _FROM_NPM(TARBALL_URL, SKY_ID, INTEGRITY, INTEGRITY_ALGO, TARBALL_PATH) {
  46. .CMD=${cwd:FROM_NPM_CWD} $YMAKE_PYTHON ${input:"build/scripts/fetch_from_npm.py"} ${input;hide:"build/scripts/fetch_from.py"} ${input;hide:"build/scripts/sky.py"} --tarball-url $TARBALL_URL --sky-id $SKY_ID --integrity $INTEGRITY --integrity-algorithm $INTEGRITY_ALGO --copy-to ${output;noauto:TARBALL_PATH} ${requirements;hide:"network:full"} ${kv;hide:"p TS_FNPM"} ${kv;hide:"pc magenta"}
  47. # we want output to be available for other modules without affecting NPM_CONTRIBS
  48. # we need to expose it (some details in https://st.yandex-team.ru/YMAKE-34)
  49. _EXPOSE($TARBALL_PATH)
  50. }
  51. macro _TS_ADD_NODE_MODULES_FOR_BUILDER() {
  52. # Calculate inputs and outputs of node_modules, fill `_NODE_MODULES_INOUTS` variable
  53. _NODE_MODULES_CONFIGURE()
  54. }
  55. _TARBALLS_STORE=__tarballs__
  56. _PREPARE_DEPS_INOUTS=
  57. _PREPARE_DEPS_RESOURCES=
  58. _PREPARE_DEPS_USE_RESOURCES_FLAG=
  59. _PREPARE_DEPS_CMD=$TOUCH_UNIT \
  60. && $NOTS_TOOL $NOTS_TOOL_BASE_ARGS prepare-deps \
  61. --tarballs-store $_TARBALLS_STORE \
  62. $_PREPARE_DEPS_INOUTS \
  63. $_PREPARE_DEPS_RESOURCES \
  64. $_PREPARE_DEPS_USE_RESOURCES_FLAG \
  65. ${kv;hide:"pc magenta"} ${kv;hide:"p TS_DEP"}
  66. # In case of no deps we need to create empty outputs for graph connectivity
  67. _PREPARE_NO_DEPS_CMD=$TOUCH_UNIT \
  68. && $YMAKE_PYTHON ${input:"build/scripts/touch.py"} \
  69. $_PREPARE_DEPS_INOUTS \
  70. ${kv;hide:"pc magenta"} ${kv;hide:"p TS_NODEP"}
  71. module _PREPARE_DEPS_BASE: _BARE_UNIT {
  72. .CMD=_PREPARE_DEPS_CMD
  73. .IGNORED=SRCS FILES TS_FILES COPY_FILE
  74. # Propagates peers to related modules
  75. .PEERDIR_POLICY=as_build_from
  76. .NODE_TYPE=Bundle
  77. .INCLUDE_TAG=no
  78. # we have several modules in the same dir (.PEERDIRSELF=TS_PREPARE_DEPS in BUILD)
  79. # we need different names for module identity file
  80. # .fake tells builder to not materialize it in results
  81. SET(MODULE_SUFFIX .prepare_deps.fake)
  82. # .NODE_TYPE=Bundle is required for peers propagation, but it also affects
  83. # how merging of pic/nopic graphs. Here we can override this merging behaviour
  84. SET(MODULE_TYPE LIBRARY)
  85. # define own tag
  86. SET(MODULE_TAG TS_PREPARE_DEPS)
  87. SET(MODULE_LANG TS)
  88. # what modules it can PEERDIR to
  89. SET(PEERDIR_TAGS TS_PREPARE_DEPS)
  90. # do not include it into "results" of graph
  91. DISABLE(START_TARGET)
  92. # we read pnpm-lock.yaml and package.json during configuration
  93. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS ${CURDIR}/pnpm-lock.yaml ${CURDIR}/package-lock.json ${CURDIR}/package.json)
  94. _SET_PACKAGE_MANAGER()
  95. _PREPARE_DEPS_CONFIGURE()
  96. }