Skip to content

Commit

Permalink
twister: Fix toolchain assignment for posix
Browse files Browse the repository at this point in the history
twister was unconditionally setting the toolchain to "host" for the
"posix" and "unit" architectures, clobbering the toolchain setup in the
environment.

Signed-off-by: Keith Short <[email protected]>
  • Loading branch information
keith-zephyr committed Jan 9, 2025
1 parent 5aeda6f commit 17fc84a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
14 changes: 3 additions & 11 deletions scripts/pylib/twister/twisterlib/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -1143,14 +1143,6 @@ def run_cmake_script(args=None):
return results

def get_toolchain(self):
toolchain_script = Path(ZEPHYR_BASE) / Path('cmake/verify-toolchain.cmake')
result = self.run_cmake_script([toolchain_script, "FORMAT=json"])

try:
if result['returncode']:
raise TwisterRuntimeError(f"E: {result['returnmsg']}")
except Exception as e:
print(str(e))
sys.exit(2)
self.toolchain = json.loads(result['stdout'])['ZEPHYR_TOOLCHAIN_VARIANT']
logger.info(f"Using '{self.toolchain}' toolchain.")
self.toolchain = os.environ.get("ZEPHYR_TOOLCHAIN_VARIANT")
if self.toolchain:
logger.info(f"Using '{self.toolchain}' toolchain.")
7 changes: 5 additions & 2 deletions scripts/pylib/twister/twisterlib/testplan.py
Original file line number Diff line number Diff line change
Expand Up @@ -898,9 +898,12 @@ def apply_filters(self, **kwargs):
):
if itoolchain:
toolchain = itoolchain
elif self.env.toolchain:
toolchain = self.env.toolchain
elif plat.arch in ['posix', 'unit']:
toolchain = "host"
else:
default_toolchain = "zephyr" if not self.env.toolchain else self.env.toolchain
toolchain = default_toolchain if plat.arch not in ['posix', 'unit'] else "host"
toolchain = "zephyr"

instance = TestInstance(ts, plat, toolchain, self.env.outdir)
instance.run = instance.check_runnable(
Expand Down

0 comments on commit 17fc84a

Please sign in to comment.