node_modules.conf 3.6 KB

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