Skip to content

Commit

Permalink
[scons] Fix duplicates in SConscript for external lbuild repos
Browse files Browse the repository at this point in the history
  • Loading branch information
salkinium committed Dec 12, 2024
1 parent 9e480a8 commit 60eba38
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
16 changes: 5 additions & 11 deletions tools/build_script_generator/scons/resources/SConscript.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

#!/usr/bin/env python3

from os.path import join, abspath, realpath, dirname
import shutil
from os.path import join, abspath
Import("env")

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

%% if toolpaths
# SCons tools
env.Append(toolpath=[
%% for toolpath in toolpaths | sort
abspath("{{ toolpath | modm.windowsify(escape_level=1) }}"),
%% endfor
])
%% endif
%% for tool in tools | sort
env.Tool("{{tool}}")
%% endfor

c_compiler_name = env["CC"]
c_compiler_path = shutil.which(c_compiler_name)

if c_compiler_path is None:
print(f'Selected compiler "{c_compiler_name}" not found on PATH. Please add its installation directory to the PATH environment variable.')
exit(1)

env["GCC_PATH"] = dirname(dirname(realpath(c_compiler_path)))

%% macro generate_flags_for_profile(name, profile, append=False)
env{% if append %}.Append({{name | upper}}{% else %}["{{name | upper}}"]{% endif %} = [
%% for flag in flags[name][profile] | sort
Expand Down Expand Up @@ -205,6 +197,7 @@ env.AppendUnique(LIBPATH=[
env.ParseConfig("pkg-config --cflags --libs {{ packages | sort | join(" ") }}")
%% endif

%% if is_modm
for flags in ["CCFLAGS", "CFLAGS", "CXXFLAGS", "ASFLAGS", "ARCHFLAGS", "LINKFLAGS"]:
flags_str = ARGUMENTS.get(flags)
if flags_str is not None:
Expand All @@ -220,5 +213,6 @@ for flags in ["CCFLAGS", "CFLAGS", "CXXFLAGS", "ASFLAGS", "ARCHFLAGS", "LINKFLAG
exit(1)
else:
env[flags].append(flag)
%% endif

Return("library")
10 changes: 9 additions & 1 deletion tools/build_script_generator/scons/site_tools/gcc_retarget.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
# - 2018, Niklas Hauser

import os
from os.path import realpath, dirname
import shutil

from SCons.Script import *

Expand Down Expand Up @@ -92,7 +94,13 @@ def generate(env, **kw):
env.AddMethod(strip_binary, 'Strip')
env.AddMethod(list_symbols, 'Symbols')

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


def exists(env):
return True
return env.Detect(env["CC"])

0 comments on commit 60eba38

Please sign in to comment.