Switch ts_library to RSP files. (#31800)

This commit is contained in:
Aleksei Khoroshilov
2025-10-14 09:49:11 -04:00
committed by GitHub
parent 528acfea5f
commit ac2cab0758
3 changed files with 41 additions and 22 deletions
+25 -20
View File
@@ -11,8 +11,8 @@ load("@builtin//struct.star", "module", "struct")
__HOST_OS_IS_LINUX = runtime.os == "linux"
__HOST_OS_IS_WINDOWS = runtime.os == "windows"
# Rules to disable remote execution.
__RULES_TO_DISABLE_REMOTE = [
# Rules to remove from handling.
__RULES_TO_REMOVE = [
# We have chromium_src mangling which requires additional inputs/outputs
# handling. This is not trivial and require careful configuration. Can be
# revisited when SISO becomes first class citizen in Brave.
@@ -60,10 +60,33 @@ __debug = False
# Main configuration function that sets up SISO for Brave-specific build
# requirements by adjusting step configurations and registering custom handlers.
def __configure(ctx, step_config, handlers):
__remove_rules(step_config)
__adjust_handlers(ctx, step_config, handlers)
__remove_labels_from_platforms(step_config)
# Disable any handling for rules that deviate from upstream.
def __remove_rules(step_config):
def should_remove(rule_name):
# Remove rules that are not supported by Brave.
if rule_name in __RULES_TO_REMOVE:
return True
# Disable remote execution for rust rules on non-Linux platforms. Linux
# rust toolchain does not include cross-toolchains, so we can't use it
# the same way we use Linux clang toolchain for cross-compilation.
if not __HOST_OS_IS_LINUX and rule_name.startswith("rust"):
return True
return False
step_config["rules"] = [
rule for rule in step_config["rules"]
if not should_remove(rule["name"])
]
# Configures handlers to handle chromium_src overrides and disable remote
# execution for specific rules that require local processing.
def __adjust_handlers(ctx, step_config, handlers):
@@ -75,18 +98,6 @@ def __adjust_handlers(ctx, step_config, handlers):
for rule in step_config["rules"]:
rule_name = rule["name"]
# Disable remote execution for rules that need local processing.
if rule_name in __RULES_TO_DISABLE_REMOTE:
__disable_remote_execution(rule)
continue
# Disable remote execution for rust rules on non-Linux platforms. Linux
# rust toolchain does not include cross-toolchains, so we can't use it
# the same way we use Linux clang toolchain for cross-compilation.
if not __HOST_OS_IS_LINUX and rule_name.startswith("rust"):
__disable_remote_execution(rule)
continue
if rule_name == "blink/generate_bindings":
# This step requires increased timeouts to work.
rule["timeout"] = "10m"
@@ -301,12 +312,6 @@ def __chromium_src_inputs_handler(ctx, cmd, fixed_inputs):
return __evolve_struct(cmd, inputs=new_inputs)
# Disables remote execution for a rule.
def __disable_remote_execution(rule):
rule["remote"] = False
rule.pop("reproxy_config", None)
# Ensures a list field exists in a dict and returns it.
def __ensure_list(d, field_name):
val = d.get(field_name)
@@ -7,6 +7,7 @@ import argparse
import json
import os
import re
import shlex
import override_utils
@@ -30,6 +31,15 @@ def _write_tsconfig_json(original_function, gen_dir, tsconfig, tsconfig_file):
@override_utils.override_function(globals())
def main(original_function, argv):
rsp_parser = argparse.ArgumentParser()
rsp_parser.add_argument('--rsp', required=False)
rsp_args, _ = rsp_parser.parse_known_args(argv)
if rsp_args.rsp:
with open(rsp_args.rsp, 'r') as f:
# Do not prepend argv[0], because original script strips it.
argv = shlex.split(f.read())
# Parse only the arguments used by this override
parser = argparse.ArgumentParser()
parser.add_argument('--root_dir', required=True)
@@ -1,8 +1,8 @@
diff --git a/tools/typescript/ts_library.gni b/tools/typescript/ts_library.gni
index 9f8d59cdf04620ea6df5965b03a176043937d9d6..72374b8a4e77f9bc838e9d4c1dc2f5c734268fe8 100644
index 9f8d59cdf04620ea6df5965b03a176043937d9d6..424d09870894a62ed5af31c3f5cbd40514b9b9e9 100644
--- a/tools/typescript/ts_library.gni
+++ b/tools/typescript/ts_library.gni
@@ -169,6 +169,7 @@ template("ts_library") {
@@ -169,9 +169,11 @@ template("ts_library") {
]
}
@@ -10,3 +10,7 @@ index 9f8d59cdf04620ea6df5965b03a176043937d9d6..72374b8a4e77f9bc838e9d4c1dc2f5c7
args += [ "--path_mappings" ] + path_mappings
if (defined(invoker.path_mappings)) {
args += invoker.path_mappings
}
+ response_file_contents = args args = [] args = ["--rsp", "{{response_file_name}}"]
}
}