node_modules.conf 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. PNPM_ROOT=
  2. PNPM_SCRIPT=$PNPM_ROOT/node_modules/pnpm/dist/pnpm.cjs
  3. NPM_CONTRIBS_PATH=contrib/typescript
  4. NODE_MODULES_BUNDLE_AS_OUTPUT=
  5. _NODE_MODULES_INS=
  6. _NODE_MODULES_OUTS=
  7. # TOUCH_UNIT is required to create module identity file.
  8. # we can "call" macro as `$_NODE_MODULES(...)`. in this case we will get .CMD from it.
  9. # this is the only way to process a variable data as an array.
  10. # ${output;hide:_NODE_MODULES_OUTS} does not produce list of paths, but a single value (space-separeted paths)
  11. _NODE_MODULES_CMD=$TOUCH_UNIT && $_NODE_MODULES(IN $_NODE_MODULES_INS OUT $_NODE_MODULES_OUTS)
  12. module _NODE_MODULES_BASE: _BARE_UNIT {
  13. .CMD=_NODE_MODULES_CMD
  14. # ignore SRCS macro
  15. .ALIASES=SRCS=_NOOP_MACRO
  16. # Propagates peers to related modules
  17. .PEERDIR_POLICY=as_build_from
  18. .NODE_TYPE=Bundle
  19. # we have several modules in the same dir (.PEERDIRSELF=NODE_MODULES in BUILD)
  20. # we need different names for module identity file
  21. # .fake tells builder to not materialize it in results
  22. SET(MODULE_SUFFIX .n_m.fake)
  23. # .NODE_TYPE=Bundle is required for peers propagation, but it also affects
  24. # how merging of pic/nopic graphs. Here we can override this merging behaviour
  25. SET(MODULE_TYPE LIBRARY)
  26. # define own tag
  27. SET(MODULE_TAG NODE_MODULES)
  28. # what modules it can PEERDIR to
  29. SET(PEERDIR_TAGS TS NPM_CONTRIBS)
  30. # do not include it into "results" of graph
  31. DISABLE(START_TARGET)
  32. # we read package.json and erm-packages.json during configuration
  33. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS ${CURDIR}/package.json ${ARCADIA_ROOT}/$ERM_PACKAGES_PATH)
  34. PEERDIR($NPM_CONTRIBS_PATH)
  35. # PEERDIR to the right version of nodejs and pnpm
  36. _PEERDIR_TS_RESOURCE(nodejs pnpm)
  37. # run py logic
  38. _NODE_MODULES_CONFIGURE()
  39. }
  40. # called in on_node_modules_configure
  41. macro _SET_NODE_MODULES_INS_OUTS(IN{input}[], OUT{output}[]) {
  42. SET(_NODE_MODULES_INS $IN)
  43. SET(_NODE_MODULES_OUTS $OUT)
  44. }
  45. macro _NODE_MODULES(IN{input}[], OUT{output}[]) {
  46. .CMD=${cwd:BINDIR} $NOTS_TOOL create-node-modules $NOTS_TOOL_BASE_ARGS --pnpm-script $PNPM_SCRIPT --contribs $NPM_CONTRIBS_PATH ${input;hide:IN} ${output;hide:OUT} ${kv;hide:"p NOMO"} ${kv;hide:"pc magenta"}
  47. }
  48. ### @usage: NPM_CONTRIBS() # internal
  49. ###
  50. ### Defines special module that provides contrib tarballs from internal npm registry.
  51. ###
  52. ### @see [FROM_NPM_LOCKFILES()](#macro_FROM_NPM_LOCKFILES)
  53. module NPM_CONTRIBS: _BARE_UNIT {
  54. .CMD=TOUCH_UNIT
  55. .PEERDIR_POLICY=as_build_from
  56. .FINAL_TARGET=no
  57. .ALLOWED=FROM_NPM_LOCKFILES
  58. .RESTRICTED=PEERDIR
  59. .EXTS=_ # Ignore all files, so module is not affected by FROM_NPM output (.EXTS=* is inherited from _BARE_UNIT)
  60. SET(MODULE_TAG NPM_CONTRIBS)
  61. # .fake tells builder to not materialize it in results
  62. SET(MODULE_SUFFIX .fake)
  63. }
  64. ### @usage: FROM_NPM_LOCKFILES(LOCKFILES...) # internal
  65. ###
  66. ### Defines lockfile list for `NPM_CONTRIBS` module.
  67. ###
  68. ### @see [NPM_CONTRIBS()](#module_NPM_CONTRIBS)
  69. macro FROM_NPM_LOCKFILES(LOCKFILES...) {
  70. SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS $LOCKFILES)
  71. # See implementation in build/plugins/nots.py
  72. _FROM_NPM_LOCKFILES($LOCKFILES)
  73. }
  74. FROM_NPM_CWD=$ARCADIA_BUILD_ROOT/$NPM_CONTRIBS_PATH
  75. macro _FROM_NPM(NAME, VERSION, SKY_ID, INTEGRITY, INTEGRITY_ALGO, TARBALL_PATH) {
  76. .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"} --name $NAME --version $VERSION --sky-id $SKY_ID --integrity $INTEGRITY --integrity-algorithm $INTEGRITY_ALGO --copy-to ${output;noauto:TARBALL_PATH} ${requirements;hide:"network:full"} ${kv;hide:"p NPM"} ${kv;hide:"pc magenta"}
  77. # we want output to be available for other modules without affecting NPM_CONTRIBS
  78. # we need to expose it (some details in https://st.yandex-team.ru/YMAKE-34)
  79. _EXPOSE($TARBALL_PATH)
  80. }
  81. macro NODE_MODULES() {
  82. MESSAGE(Remove NODE_MODULES())
  83. }