node_modules.conf 4.5 KB

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