From 5e9f8975c430dee7cab0d48ef20859cb59a541d6 Mon Sep 17 00:00:00 2001 From: marif-nexthop Date: Thu, 23 Apr 2026 00:08:10 +0000 Subject: [PATCH 1/5] fix pre-existing ruff lint issues --- fboss/lib/oss/run-helper.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/fboss/lib/oss/run-helper.py b/fboss/lib/oss/run-helper.py index d271185e3752a..bdf8cb4de0c0d 100644 --- a/fboss/lib/oss/run-helper.py +++ b/fboss/lib/oss/run-helper.py @@ -17,10 +17,9 @@ import subprocess import sys from pathlib import Path -from typing import List, Tuple -def get_command_line_args() -> Tuple[str, List[str]]: +def get_command_line_args() -> tuple[str, list[str]]: parser = argparse.ArgumentParser( description="OSS FBOSS build and run helper script." ) @@ -40,14 +39,14 @@ def main() -> None: "Please run the script from the root of the FBOSS repository", file=sys.stderr, ) - exit(1) + sys.exit(1) expected_path = parents[3].absolute().as_posix() if run_path != expected_path: error_string = f"""Please executed the script from the root of the FBOSS repository Expected run path: {expected_path} Current run path: {run_path}""" print(error_string, file=sys.stderr) - exit(1) + sys.exit(1) get_deps_paths = [ expected_path + "/opensource/fbcode_builder/getdeps.py", @@ -60,7 +59,7 @@ def main() -> None: get_deps_path = maybe_path if get_deps_path is None: print("Could not find getdeps.py", file=sys.stderr) - exit(1) + sys.exit(1) else: print(get_deps_path) @@ -75,6 +74,7 @@ def main() -> None: f"""{get_deps_path} build """ + '--allow-system-packages --num-jobs 32 --extra-cmake-defines=\'{"CMAKE_BUILD_TYPE": "MinSizeRel", "CMAKE_CXX_STANDARD": "20"}\' --cmake-target' + f" {target} fboss", + check=False, shell=True, ) @@ -82,6 +82,7 @@ def main() -> None: show_build_dir_proc = subprocess.run( f"""{get_deps_path} show-build-dir fboss""", + check=False, shell=True, capture_output=True, text=True, @@ -96,15 +97,16 @@ def main() -> None: result = subprocess.run( fboss_oss_target, + check=False, shell=True, ) if result.returncode != 0: print(f"Failed to run target {target}", file=sys.stderr) - exit(1) + sys.exit(1) print("Configs have been written to specified output directory") - exit(0) + sys.exit(0) if __name__ == "__main__": From 7c4bb8dac41a2448105b0218b46412abd231b165 Mon Sep 17 00:00:00 2001 From: marif-nexthop Date: Thu, 23 Apr 2026 00:08:20 +0000 Subject: [PATCH 2/5] handle TYPE dir python executables add_fb_thrift_python_executable (and any add_fb_python_executable call with TYPE dir) produces a directory whose cmake target name is suffixed with .GEN_PY_EXE. Strip that suffix when computing the on-disk output path, and invoke directory outputs via python3 so __main__.py runs. Non-python targets (e.g. fboss-bspmapping-gen) continue to exec directly. --- fboss/lib/oss/run-helper.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/fboss/lib/oss/run-helper.py b/fboss/lib/oss/run-helper.py index bdf8cb4de0c0d..3ceeffeabbb26 100644 --- a/fboss/lib/oss/run-helper.py +++ b/fboss/lib/oss/run-helper.py @@ -88,12 +88,13 @@ def main() -> None: text=True, ) - fboss_oss_target = ( - show_build_dir_proc.stdout.rstrip() - + f"/{target}" - + " " - + " ".join(command_line_args) - ) + build_dir = show_build_dir_proc.stdout.rstrip() + target_basename = target.removesuffix(".GEN_PY_EXE") + output_path = f"{build_dir}/{target_basename}" + + # Thrift python output is a directory; everything else is a native executable + python_prefix = "python3 " if os.path.isdir(output_path) else "" + fboss_oss_target = f"{python_prefix}{output_path} {' '.join(command_line_args)}" result = subprocess.run( fboss_oss_target, From 72edd89ede602af95b4fcde3185f5e794b4a28ea Mon Sep 17 00:00:00 2001 From: marif-nexthop Date: Thu, 23 Apr 2026 00:08:27 +0000 Subject: [PATCH 3/5] pass .GEN_PY_EXE target to run-helper cmake/AsicConfigV2ConfigCli.cmake uses add_fb_thrift_python_executable, which registers the cmake target with a .GEN_PY_EXE suffix. Pass the suffixed name so build can find it; run-helper.py strips the suffix when locating the on-disk output. --- fboss/lib/asic_config_v2/run-helper.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fboss/lib/asic_config_v2/run-helper.sh b/fboss/lib/asic_config_v2/run-helper.sh index 80ba38234ea30..c3b3a53e09780 100755 --- a/fboss/lib/asic_config_v2/run-helper.sh +++ b/fboss/lib/asic_config_v2/run-helper.sh @@ -1,2 +1,2 @@ #!/bin/bash -python3 fboss/lib/oss/run-helper.py --target fboss-asic-config-gen "$@" +python3 fboss/lib/oss/run-helper.py --target fboss-asic-config-gen.GEN_PY_EXE "$@" From a9214bd328819e3ad7ed40188514042232736694 Mon Sep 17 00:00:00 2001 From: marif-nexthop Date: Thu, 23 Apr 2026 00:08:46 +0000 Subject: [PATCH 4/5] accept --extra-cmake-defines and merge Callers can now pass a JSON object of additional cmake defines which is merged over the hardcoded {CMAKE_BUILD_TYPE, CMAKE_CXX_STANDARD} defaults. Caller keys win on conflict. Existing callers that do not pass the flag are unaffected. --- fboss/lib/oss/run-helper.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/fboss/lib/oss/run-helper.py b/fboss/lib/oss/run-helper.py index 3ceeffeabbb26..b12982dfeb4af 100644 --- a/fboss/lib/oss/run-helper.py +++ b/fboss/lib/oss/run-helper.py @@ -13,24 +13,36 @@ """ import argparse +import json import os import subprocess import sys from pathlib import Path -def get_command_line_args() -> tuple[str, list[str]]: +def get_command_line_args() -> tuple[str, dict[str, str], list[str]]: parser = argparse.ArgumentParser( description="OSS FBOSS build and run helper script." ) parser.add_argument("--target", type=str, required=True, help="Target to build") + parser.add_argument( + "--extra-cmake-defines", + type=str, + default="{}", + help=("JSON object of additional cmake defines"), + ) args, unknown_args = parser.parse_known_args() - return args.target, unknown_args + extra_defines = json.loads(args.extra_cmake_defines) + if not isinstance(extra_defines, dict): + print("--extra-cmake-defines must be a JSON object", file=sys.stderr) + sys.exit(1) + + return args.target, extra_defines, unknown_args def main() -> None: - target, command_line_args = get_command_line_args() + target, extra_cmake_defines, command_line_args = get_command_line_args() run_path = os.getcwd() parents = Path(__file__).parents @@ -69,10 +81,14 @@ def main() -> None: if is_facebook_machine: get_deps_path = f"{proxy_env_vars} {get_deps_path}" + cmake_defines = {"CMAKE_BUILD_TYPE": "MinSizeRel", "CMAKE_CXX_STANDARD": "20"} + cmake_defines.update(extra_cmake_defines) + cmake_defines_json = json.dumps(cmake_defines) + print(f"Starting build for {target}") subprocess.run( f"""{get_deps_path} build """ - + '--allow-system-packages --num-jobs 32 --extra-cmake-defines=\'{"CMAKE_BUILD_TYPE": "MinSizeRel", "CMAKE_CXX_STANDARD": "20"}\' --cmake-target' + + f"--allow-system-packages --num-jobs 32 --extra-cmake-defines='{cmake_defines_json}' --cmake-target" + f" {target} fboss", check=False, shell=True, From fa615d92c247df081ac8952304fffcdef57faf8f Mon Sep 17 00:00:00 2001 From: marif-nexthop Date: Thu, 23 Apr 2026 00:09:00 +0000 Subject: [PATCH 5/5] disable range-v3 tests via cmake defines range-v3's test suite fails to compile under clang's -Werror,-Wnrvo. Disable it at the cmake level via --extra-cmake-defines. --- fboss/lib/asic_config_v2/run-helper.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fboss/lib/asic_config_v2/run-helper.sh b/fboss/lib/asic_config_v2/run-helper.sh index c3b3a53e09780..02491b608cb6e 100755 --- a/fboss/lib/asic_config_v2/run-helper.sh +++ b/fboss/lib/asic_config_v2/run-helper.sh @@ -1,2 +1,5 @@ #!/bin/bash -python3 fboss/lib/oss/run-helper.py --target fboss-asic-config-gen.GEN_PY_EXE "$@" +python3 fboss/lib/oss/run-helper.py \ + --target fboss-asic-config-gen.GEN_PY_EXE \ + --extra-cmake-defines='{"RANGE_V3_TESTS": "OFF"}' \ + "$@"