Skip to content

Commit 78308b0

Browse files
WasabiFansalkinium
authored andcommitted
[scons] Emit explicit error when chosen gcc isn't found on PATH
Previously, if the compiler was not on PATH, shutil.which would return None and the error from "realpath" would be: TypeError: expected str, bytes or os.PathLike object, not NoneType
1 parent 8844efc commit 78308b0

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

tools/build_script_generator/scons/resources/SConscript.in

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,15 @@ env.Append(toolpath=[
3737
%% for tool in tools | sort
3838
env.Tool("{{tool}}")
3939
%% endfor
40-
env["GCC_PATH"] = dirname(dirname(realpath(shutil.which(env["CC"]))))
40+
41+
c_compiler_name = env["CC"]
42+
c_compiler_path = shutil.which(c_compiler_name)
43+
44+
if c_compiler_path is None:
45+
print(f'Selected compiler "{c_compiler_name}" not found on PATH. Please add its installation directory to the PATH environment variable.')
46+
exit(1)
47+
48+
env["GCC_PATH"] = dirname(dirname(realpath(c_compiler_path)))
4149

4250
%% macro generate_flags_for_profile(name, profile, append=False)
4351
env{% if append %}.Append({{name | upper}}{% else %}["{{name | upper}}"]{% endif %} = [

0 commit comments

Comments
 (0)