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