Skip to content

Commit 9f457b8

Browse files
bhcopelandroxell
authored andcommitted
build: raise CompilerNotFoundError for null runtime
When the null runtime detects a missing compiler via is_supported(), raise a specific CompilerNotFoundError instead of the generic UnsupportedArchitectureToolchainCombination. This gives the user an actionable error message naming the missing compiler and suggesting to install it or use a container-based runtime. Before: E: Unsupported architecture/toolchain combination: sparc64/gcc After: E: Compiler not found: sparc64-linux-gnu-gcc Install the compiler or use a container-based runtime (e.g. --runtime=docker/podman) Signed-off-by: Ben Copeland <ben.copeland@linaro.org>
1 parent 472ce8f commit 9f457b8

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

test/test_build.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,10 +889,15 @@ def test_errors(self, build):
889889

890890
class TestUnsupportedToolchainArchitectureCombination:
891891
def test_exception(self, linux, mocker):
892-
mocker.patch("tuxmake.runtime.NullRuntime.is_supported", return_value=False)
892+
mocker.patch("tuxmake.runtime.Runtime.is_supported", return_value=False)
893893
with pytest.raises(
894894
tuxmake.exceptions.UnsupportedArchitectureToolchainCombination
895895
):
896+
Build(tree=linux, target_arch="arc", toolchain="clang", runtime="docker")
897+
898+
def test_null_runtime_compiler_not_found(self, linux, mocker):
899+
mocker.patch("tuxmake.runtime.NullRuntime.is_supported", return_value=False)
900+
with pytest.raises(tuxmake.exceptions.CompilerNotFoundError):
896901
Build(tree=linux, target_arch="arc", toolchain="clang")
897902

898903

tuxmake/build.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from tuxmake.runtime import Runtime, DockerRuntime
2323
from tuxmake.runtime import Terminated
2424
from tuxmake.metadata import MetadataCollector
25+
from tuxmake.exceptions import CompilerNotFoundError
2526
from tuxmake.exceptions import DecodeStacktraceMissingVariable
2627
from tuxmake.exceptions import EnvironmentCheckFailed
2728
from tuxmake.exceptions import KorgGccPreparationFailed
@@ -246,6 +247,9 @@ def __init__(
246247
self.runtime.set_image(get_image(self))
247248

248249
if not self.runtime.is_supported(self.target_arch, self.toolchain):
250+
if self.runtime.name == "null":
251+
compiler = self.toolchain.compiler(self.target_arch)
252+
raise CompilerNotFoundError(compiler)
249253
raise UnsupportedArchitectureToolchainCombination(
250254
f"{self.target_arch}/{self.toolchain}"
251255
)

tuxmake/exceptions.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,5 +115,12 @@ class KorgGccDownloadAllToolchainFailed(TuxMakeUserError):
115115
msg = "Korg GCC download all toochains failed"
116116

117117

118+
class CompilerNotFoundError(TuxMakeUserError):
119+
msg = (
120+
"Compiler not found: {name}\n"
121+
"Install the compiler or use a container-based runtime (e.g. --runtime=docker/podman)"
122+
)
123+
124+
118125
class DecodeStacktraceMissingVariable(TuxMakeUserError):
119126
msg = "Missing environment variable: {name}"

0 commit comments

Comments
 (0)