aboutsummaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorkhoden <khoden@yandex-team.com>2023-09-15 18:14:22 +0300
committerkhoden <khoden@yandex-team.com>2023-09-15 18:48:38 +0300
commita4cc6e01c8ca4271c8c9596c519f8317fb68dd67 (patch)
treeaa48b3dfbd3e8a62c52d001a6d8b9c5aa1b62743 /build
parent6409303f9bc7336744e42afa15a8c4c5d6e091a7 (diff)
downloadydb-a4cc6e01c8ca4271c8c9596c519f8317fb68dd67.tar.gz
TS_LIBRARY: запускать несколько сборок с разными ts-конфигами
Diffstat (limited to 'build')
-rw-r--r--build/conf/ts/ts.conf10
-rw-r--r--build/conf/ts/ts_bundle.conf2
-rw-r--r--build/conf/ts/ts_library.conf4
-rw-r--r--build/conf/ts/ts_next.conf2
-rw-r--r--build/conf/ts/ts_vite_bundle.conf2
-rw-r--r--build/plugins/nots.py75
6 files changed, 64 insertions, 31 deletions
diff --git a/build/conf/ts/ts.conf b/build/conf/ts/ts.conf
index 942b21c274..dd2e06ef6c 100644
--- a/build/conf/ts/ts.conf
+++ b/build/conf/ts/ts.conf
@@ -46,9 +46,10 @@ macro _TS_CONFIG_EPILOGUE() {
_SETUP_EXTRACT_NODE_MODULES_RECIPE(${MODDIR})
}
+# Used as inputs in TS_COMPILE through `$_AS_HIDDEN_INPUTS(IN $TS_INPUT_FILES)`
+TS_INPUT_FILES=
-# List of the inputs, filled in _TS_GLOB. Will be reduced in _TS_CONFIGURE macro.
-# Used as inputs in TS_COMPILE through `$_TS_GLOB_AS_INPUTS(IN $TS_GLOB_FILES)`
+# List of the files, filled in _TS_GLOB. Will be reduced in _TS_CONFIGURE macro to TS_INPUT_FILES.
TS_GLOB_FILES=
# Hardcoded "include" list (all other files will be ignored)
@@ -73,8 +74,9 @@ macro _TS_GLOB() {
}
# Ugly hack for using inputs from the variable
-macro _TS_GLOB_AS_INPUTS(IN{input}[]) {
- .CMD=${input;hide:IN}
+macro _AS_HIDDEN_INPUTS(IN{input}[]) {
+ # "context=TEXT" exclude file from the "include processing"
+ .CMD=${input;hide;context=TEXT:IN}
}
diff --git a/build/conf/ts/ts_bundle.conf b/build/conf/ts/ts_bundle.conf
index 0c455cff20..ae16f09dd6 100644
--- a/build/conf/ts/ts_bundle.conf
+++ b/build/conf/ts/ts_bundle.conf
@@ -14,7 +14,7 @@ TS_BUNDLE_WEBPACK=$TOUCH_UNIT \
--webpack-config ${input:WEBPACK_CONFIG_PATH} \
--vcs-info "${VCS_INFO_FILE}" \
--output-dir ${WEBPACK_OUTPUT_DIR} \
- ${input;hide:"package.json"} ${TS_CONFIG_FILES} $_TS_GLOB_AS_INPUTS(IN $TS_GLOB_FILES) \
+ ${input;hide:"package.json"} ${TS_CONFIG_FILES} $_AS_HIDDEN_INPUTS(IN $TS_INPUT_FILES) \
${output;hide:"package.json"} ${output;hide:"output.tar"} \
${kv;hide:"p TSWP"} ${kv;hide:"pc magenta"}
diff --git a/build/conf/ts/ts_library.conf b/build/conf/ts/ts_library.conf
index ed3a59fe96..078c933f01 100644
--- a/build/conf/ts/ts_library.conf
+++ b/build/conf/ts/ts_library.conf
@@ -5,10 +5,10 @@ TS_COMPILE=$TOUCH_UNIT \
&& $_TS_FILES_COPY_CMD \
&& ${cwd:BINDIR} $NOTS_TOOL compile-ts $NOTS_TOOL_BASE_ARGS \
--moddir $MODDIR \
- --ts-config ${input:TS_CONFIG_PATH} \
+ --ts-configs $TS_CONFIG_PATH \
--node-modules-bundle $NOTS_TOOL_NODE_MODULES_BUNDLE $NODE_MODULES_BUNDLE_AS_OUTPUT ${hide:PEERS} \
--tsc-resource $TYPESCRIPT_ROOT \
- ${input;hide:"package.json"} ${TS_CONFIG_FILES} $_TS_GLOB_AS_INPUTS(IN $TS_GLOB_FILES) \
+ ${input;hide:"package.json"} ${TS_CONFIG_FILES} $_AS_HIDDEN_INPUTS(IN $TS_INPUT_FILES) \
${output;hide:"package.json"} ${output;hide:"output.tar"} \
${kv;hide:"p TSC"} ${kv;hide:"pc magenta"}
diff --git a/build/conf/ts/ts_next.conf b/build/conf/ts/ts_next.conf
index bc66e176dc..d88c76e9a9 100644
--- a/build/conf/ts/ts_next.conf
+++ b/build/conf/ts/ts_next.conf
@@ -14,7 +14,7 @@ TS_NEXT_CMD=$TOUCH_UNIT \
--nextjs-config ${input:TS_NEXT_CONFIG_PATH} \
--vcs-info "${VCS_INFO_FILE}" \
--output-dir ${TS_NEXT_OUTPUT_DIR} \
- ${input;hide:"package.json"} ${TS_CONFIG_FILES} $_TS_GLOB_AS_INPUTS(IN $TS_GLOB_FILES) \
+ ${input;hide:"package.json"} ${TS_CONFIG_FILES} $_AS_HIDDEN_INPUTS(IN $TS_INPUT_FILES) \
${output;hide:"output.tar"} ${output;hide:"package.json"} \
${kv;hide:"p TSNEXT"} ${kv;hide:"pc magenta"}
diff --git a/build/conf/ts/ts_vite_bundle.conf b/build/conf/ts/ts_vite_bundle.conf
index 4c6590b687..8b6a610492 100644
--- a/build/conf/ts/ts_vite_bundle.conf
+++ b/build/conf/ts/ts_vite_bundle.conf
@@ -14,7 +14,7 @@ TS_BUNDLE_VITE=$TOUCH_UNIT \
--vite-config ${input:VITE_CONFIG_PATH} \
--vcs-info "${VCS_INFO_FILE}" \
--output-dir ${VITE_OUTPUT_DIR} \
- ${input;hide:"package.json"} ${TS_CONFIG_FILES} $_TS_GLOB_AS_INPUTS(IN $TS_GLOB_FILES) \
+ ${input;hide:"package.json"} ${TS_CONFIG_FILES} $_AS_HIDDEN_INPUTS(IN $TS_INPUT_FILES) \
${output;hide:"package.json"} ${output;hide:"output.tar"} \
${kv;hide:"p TSVB"} ${kv;hide:"pc magenta"}
diff --git a/build/plugins/nots.py b/build/plugins/nots.py
index 385e82783f..1421903a37 100644
--- a/build/plugins/nots.py
+++ b/build/plugins/nots.py
@@ -80,9 +80,17 @@ def _canonize_resource_name(name):
return re.sub(r"\W+", "_", name).strip("_").upper()
-def _build_cmd_input_paths(paths, hide=False):
- # type: (list[str], bool) -> str
- return " ".join(["${{input{}:\"{}\"}}".format(";hide" if hide else "", p) for p in paths])
+def _build_cmd_input_paths(paths, hide=False, disable_include_processor=False):
+ # type: (list[str]|tuple[str], bool) -> str
+ input_part = "input"
+ hide_part = "hide" if hide else ""
+ disable_ip_part = "context=TEXT" if disable_include_processor else ""
+
+ parts = [p for p in [input_part, hide_part, disable_ip_part] if p]
+
+ input_expressions = ["${{{parts}:\"{path}\"}}".format(parts=";".join(parts), path=path) for path in paths]
+
+ return " ".join(input_expressions)
def _create_pm(unit):
@@ -191,35 +199,58 @@ def on_peerdir_ts_resource(unit, *resources):
@_with_report_configure_error
-def on_ts_configure(unit, tsconfig_path):
+def on_ts_configure(unit, *tsconfig_paths):
+ # type: (Unit, *str) -> None
from lib.nots.package_manager.base import PackageJson
from lib.nots.package_manager.base.utils import build_pj_path
from lib.nots.typescript import TsConfig
- abs_tsconfig_path = unit.resolve(unit.resolve_arc_path(tsconfig_path))
- if not abs_tsconfig_path:
- raise Exception("tsconfig not found: {}".format(tsconfig_path))
+ __set_append(unit, "TS_CONFIG_FILES", _build_cmd_input_paths(tsconfig_paths, hide=True, disable_include_processor=True))
- tsconfig = TsConfig.load(abs_tsconfig_path)
- cur_dir = unit.get("TS_TEST_FOR_PATH") if unit.get("TS_TEST_FOR") else unit.get("MODDIR")
+ mod_dir = unit.get("MODDIR")
+ cur_dir = unit.get("TS_TEST_FOR_PATH") if unit.get("TS_TEST_FOR") else mod_dir
pj_path = build_pj_path(unit.resolve(unit.resolve_arc_path(cur_dir)))
dep_paths = PackageJson.load(pj_path).get_dep_paths_by_names()
- config_files = tsconfig.inline_extend(dep_paths)
- mod_dir = unit.get("MODDIR")
- config_files = _resolve_module_files(unit, mod_dir, config_files)
- tsconfig.validate()
+ # reversed for using the first tsconfig as the config for include processor (legacy)
+ for tsconfig_path in reversed(tsconfig_paths):
+ abs_tsconfig_path = unit.resolve(unit.resolve_arc_path(tsconfig_path))
+ if not abs_tsconfig_path:
+ raise Exception("tsconfig not found: {}".format(tsconfig_path))
+
+ tsconfig = TsConfig.load(abs_tsconfig_path)
+ config_files = tsconfig.inline_extend(dep_paths)
+ config_files = _resolve_module_files(unit, mod_dir, config_files)
+ tsconfig.validate()
+
+ # for use in CMD as inputs
+ __set_append(unit, "TS_CONFIG_FILES", _build_cmd_input_paths(config_files, hide=True, disable_include_processor=True))
- unit.set(["TS_CONFIG_FILES", _build_cmd_input_paths(config_files, hide=True)])
- unit.set(["TS_CONFIG_ROOT_DIR", tsconfig.compiler_option("rootDir")])
- unit.set(["TS_CONFIG_OUT_DIR", tsconfig.compiler_option("outDir")])
- unit.set(["TS_CONFIG_SOURCE_MAP", to_yesno(tsconfig.compiler_option("sourceMap"))])
- unit.set(["TS_CONFIG_DECLARATION", to_yesno(tsconfig.compiler_option("declaration"))])
- unit.set(["TS_CONFIG_DECLARATION_MAP", to_yesno(tsconfig.compiler_option("declarationMap"))])
- unit.set(["TS_CONFIG_PRESERVE_JSX", to_yesno(tsconfig.compiler_option("jsx") == "preserve")])
+ # region include processor
+ unit.set(["TS_CONFIG_ROOT_DIR", tsconfig.compiler_option("rootDir")]) # also for hermione
+ unit.set(["TS_CONFIG_OUT_DIR", tsconfig.compiler_option("outDir")]) # also for hermione
+
+ unit.set(["TS_CONFIG_SOURCE_MAP", to_yesno(tsconfig.compiler_option("sourceMap"))])
+ unit.set(["TS_CONFIG_DECLARATION", to_yesno(tsconfig.compiler_option("declaration"))])
+ unit.set(["TS_CONFIG_DECLARATION_MAP", to_yesno(tsconfig.compiler_option("declarationMap"))])
+ unit.set(["TS_CONFIG_PRESERVE_JSX", to_yesno(tsconfig.compiler_option("jsx") == "preserve")])
+ # endregion
+
+ _filter_inputs_by_rules_from_tsconfig(unit, tsconfig)
_setup_eslint(unit)
- _filter_inputs_by_rules_from_tsconfig(unit, tsconfig)
+
+
+def __set_append(unit, var_name, value):
+ # type: (Unit, str, str|list[str]|tuple[str]) -> None
+ """
+ SET_APPEND() python naive implementation - append value/values to the list of values
+ """
+ previous_value = unit.get(var_name) or ""
+ value_in_str = " ".join(value) if isinstance(value, list) or isinstance(value, tuple) else value
+ new_value = previous_value + " " + value_in_str
+
+ unit.set([var_name, new_value])
def __strip_prefix(prefix, line):
@@ -241,7 +272,7 @@ def _filter_inputs_by_rules_from_tsconfig(unit, tsconfig):
all_files = [__strip_prefix(target_path, f) for f in unit.get("TS_GLOB_FILES").split(" ")]
filtered_files = tsconfig.filter_files(all_files)
- unit.set(["TS_GLOB_FILES", ' '.join([target_path + f for f in filtered_files])])
+ __set_append(unit, "TS_INPUT_FILES", [target_path + f for f in filtered_files])
def _get_ts_test_data_dirs(unit):