Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions tools/build_script_generator/compilation_db/module.lb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ def prepare(module, options):
def build(env):
def flag_format(flag):
subs = {
"target_base": "\"${TARGET.base}\"",
"linkdir": "\"modm/link\""
"target_base": '"${TARGET.base}"',
"project_source_dir": 'env["BASEPATH"]',
"gccpath": 'env["GCC_PATH"]'
}
flag = '"{}"'.format(flag)
vals = ["{}={}".format(t, r) for t, r in subs.items() if "{{{}}}".format(t) in flag]
Expand All @@ -52,7 +53,7 @@ def post_build(env):
subs["memories"] = []
# Add SCons specific data
subs.update({
"build_path": env.relative_outpath(env[":build:build.path"]),
"build_path": env.relcwdoutpath(env[":build:build.path"]),
"generated_paths": repositories,
"common_source_flag_map": common_source_flag_map,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ from pathlib import Path
env = defaultdict(list)

env["CONFIG_PROJECT_NAME"] = "{{ options[":build:project.name"] }}"
env["CONFIG_BUILD_BASE"] = "{{ build_path }}"
env["CONFIG_BUILD_BASE"] = os.path.abspath("{{ build_path | modm.windowsify(escape_level=1)}}")
env["CONFIG_BUILD_PROFILE"] = "debug" if "--debug" in sys.argv else "release"

env["BUILDPATH"] = os.path.join(env["CONFIG_BUILD_BASE"], env["CONFIG_BUILD_PROFILE"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from os.path import join, abspath
from os.path import join, abspath, realpath, dirname
import sys, shutil

profile = env["CONFIG_BUILD_PROFILE"]
Expand All @@ -19,7 +19,7 @@ env["COMPILERPREFIX"] = "arm-none-eabi-"
%% else
%% if family == "darwin"
# Using homebrew gcc on macOS instead of clang
env["COMPILERSUFFIX"] = next(c[3:] for c in ["gcc-9", "gcc-8", "gcc-7"] if shutil.which(c) is not None)
env["COMPILERSUFFIX"] = next(c[3:] for c in ["gcc-15", "gcc-14"] if shutil.which(c) is not None)
%% endif
%% endif

Expand Down Expand Up @@ -48,6 +48,12 @@ env["SIZE"] = prefix + "size"
env["STRIP"] = prefix + "strip"
env["LINK"] = env["CXX"]

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)))

%% endif

%% macro generate_flags_for_profile(name, profile, append=False)
Expand Down
2 changes: 2 additions & 0 deletions tools/scripts/examples_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ def build(project):
commands = []
if ":build:scons" in project_cfg:
commands.append( ("scons build --cache-show --random", "SCons") )
if ":build:compilation_db" in project_cfg:
commands.append( ("scons compilation_db", "CompilationDB (via SCons)") )
if ":build:make" in project_cfg and not is_running_on_windows:
commands.append( ("make build", "Make") )
elif ":build:cmake" in project_cfg and not is_running_on_windows:
Expand Down
Loading