From ac2cab07587f3f96895ca12e415205cc4ce1b51a Mon Sep 17 00:00:00 2001 From: Aleksei Khoroshilov <5928869+goodov@users.noreply.github.com> Date: Tue, 14 Oct 2025 20:49:11 +0700 Subject: [PATCH] Switch ts_library to RSP files. (#31800) --- build/config/siso/brave_siso_config.star | 45 ++++++++++--------- chromium_src/tools/typescript/ts_library.py | 10 +++++ patches/tools-typescript-ts_library.gni.patch | 8 +++- 3 files changed, 41 insertions(+), 22 deletions(-) diff --git a/build/config/siso/brave_siso_config.star b/build/config/siso/brave_siso_config.star index 48bf1d9d822..30feeedd735 100644 --- a/build/config/siso/brave_siso_config.star +++ b/build/config/siso/brave_siso_config.star @@ -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) diff --git a/chromium_src/tools/typescript/ts_library.py b/chromium_src/tools/typescript/ts_library.py index 8229b1cd217..8faa8f80605 100644 --- a/chromium_src/tools/typescript/ts_library.py +++ b/chromium_src/tools/typescript/ts_library.py @@ -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) diff --git a/patches/tools-typescript-ts_library.gni.patch b/patches/tools-typescript-ts_library.gni.patch index ea9feae2b9b..94e32c0a94e 100644 --- a/patches/tools-typescript-ts_library.gni.patch +++ b/patches/tools-typescript-ts_library.gni.patch @@ -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}}"] + } + }