Skip to content

Commit 60eba38

Browse files
committed
[scons] Fix duplicates in SConscript for external lbuild repos
1 parent 9e480a8 commit 60eba38

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

tools/build_script_generator/scons/resources/SConscript.in

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88

99
#!/usr/bin/env python3
1010

11-
from os.path import join, abspath, realpath, dirname
12-
import shutil
11+
from os.path import join, abspath
1312
Import("env")
1413

1514
profile = ARGUMENTS.get("profile", "release")
@@ -28,25 +27,18 @@ env["COMPILERSUFFIX"] = "-12"
2827
%% endif
2928
%% endif
3029

30+
%% if toolpaths
3131
# SCons tools
3232
env.Append(toolpath=[
3333
%% for toolpath in toolpaths | sort
3434
abspath("{{ toolpath | modm.windowsify(escape_level=1) }}"),
3535
%% endfor
3636
])
37+
%% endif
3738
%% for tool in tools | sort
3839
env.Tool("{{tool}}")
3940
%% endfor
4041

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)))
49-
5042
%% macro generate_flags_for_profile(name, profile, append=False)
5143
env{% if append %}.Append({{name | upper}}{% else %}["{{name | upper}}"]{% endif %} = [
5244
%% for flag in flags[name][profile] | sort
@@ -205,6 +197,7 @@ env.AppendUnique(LIBPATH=[
205197
env.ParseConfig("pkg-config --cflags --libs {{ packages | sort | join(" ") }}")
206198
%% endif
207199

200+
%% if is_modm
208201
for flags in ["CCFLAGS", "CFLAGS", "CXXFLAGS", "ASFLAGS", "ARCHFLAGS", "LINKFLAGS"]:
209202
flags_str = ARGUMENTS.get(flags)
210203
if flags_str is not None:
@@ -220,5 +213,6 @@ for flags in ["CCFLAGS", "CFLAGS", "CXXFLAGS", "ASFLAGS", "ARCHFLAGS", "LINKFLAG
220213
exit(1)
221214
else:
222215
env[flags].append(flag)
216+
%% endif
223217

224218
Return("library")

tools/build_script_generator/scons/site_tools/gcc_retarget.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
# - 2018, Niklas Hauser
1414

1515
import os
16+
from os.path import realpath, dirname
17+
import shutil
1618

1719
from SCons.Script import *
1820

@@ -92,7 +94,13 @@ def generate(env, **kw):
9294
env.AddMethod(strip_binary, 'Strip')
9395
env.AddMethod(list_symbols, 'Symbols')
9496

97+
c_compiler_name = env["CC"]
98+
assert (c_compiler_path := shutil.which(c_compiler_name)), \
99+
f'Selected compiler "{c_compiler_name}" not found on PATH. ' \
100+
"Please add its installation directory to the PATH environment variable."
101+
env["GCC_PATH"] = dirname(dirname(realpath(c_compiler_path)))
102+
95103

96104
def exists(env):
97-
return True
105+
return env.Detect(env["CC"])
98106

0 commit comments

Comments
 (0)