Skip to content

Commit 01ba549

Browse files
committed
twister: add an option to force a toolchain variant for a platform
Using --force-platform-toolchain native_sim/native:llvm will force building native_sim tests with llvm while everything else is built with whatever variant was set in the environment. This option can be provided multiple times for multiple platforms and toolchain variants. Signed-off-by: Anas Nashif <[email protected]>
1 parent 545cbe4 commit 01ba549

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

scripts/pylib/twister/twisterlib/environment.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,10 @@ def add_parse_arguments(parser = None) -> argparse.ArgumentParser:
421421
help="Do not filter based on toolchain, use the set "
422422
" toolchain unconditionally")
423423

424+
parser.add_argument("--force-platform-toolchain", action="append",
425+
help="Force a toolchain variant for a platform in the form of <platform>:<toolchain variant>. "
426+
"(Can be specified multiple time)")
427+
424428
parser.add_argument("--gcov-tool", type=Path, default=None,
425429
help="Path to the gcov tool to use for code coverage "
426430
"reports")

scripts/pylib/twister/twisterlib/runner.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,8 +616,13 @@ def run_cmake(self, args="", filter_stages=[]):
616616
f'-D{warning_command}={warnings_as_errors}',
617617
f'-DEXTRA_GEN_EDT_ARGS={gen_edt_args}',
618618
f'-G{self.env.generator}',
619-
f'-DPython3_EXECUTABLE={pathlib.Path(sys.executable).as_posix()}'
619+
f'-DPython3_EXECUTABLE={pathlib.Path(sys.executable).as_posix()}',
620620
]
621+
if self.env.options.force_platform_toolchain:
622+
for e in self.env.options.force_platform_toolchain:
623+
platform, variant = e.split(":")
624+
if platform and variant and self.platform.name == platform:
625+
cmake_args.append(f'-DZEPHYR_TOOLCHAIN_VARIANT={variant}')
621626

622627
# If needed, run CMake using the package_helper script first, to only run
623628
# a subset of all cmake modules. This output will be used to filter

0 commit comments

Comments
 (0)