node_modules.conf 3.9 KB

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