Skip to content

Commit 3502929

Browse files
committed
[tools] Update compilation_db for build system changes
1 parent 3cae630 commit 3502929

3 files changed

Lines changed: 13 additions & 6 deletions

File tree

tools/build_script_generator/compilation_db/module.lb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ def prepare(module, options):
2626
def build(env):
2727
def flag_format(flag):
2828
subs = {
29-
"target_base": "\"${TARGET.base}\"",
30-
"linkdir": "\"modm/link\""
29+
"target_base": '"${TARGET.base}"',
30+
"project_source_dir": 'env["BASEPATH"]',
31+
"gccpath": 'env["GCC_PATH"]'
3132
}
3233
flag = '"{}"'.format(flag)
3334
vals = ["{}={}".format(t, r) for t, r in subs.items() if "{{{}}}".format(t) in flag]
@@ -52,7 +53,7 @@ def post_build(env):
5253
subs["memories"] = []
5354
# Add SCons specific data
5455
subs.update({
55-
"build_path": env.relative_outpath(env[":build:build.path"]),
56+
"build_path": env.relcwdoutpath(env[":build:build.path"]),
5657
"generated_paths": repositories,
5758
"common_source_flag_map": common_source_flag_map,
5859
})

tools/build_script_generator/compilation_db/resources/builder_compilation_db.py.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ from pathlib import Path
1313
env = defaultdict(list)
1414

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

1919
env["BUILDPATH"] = os.path.join(env["CONFIG_BUILD_BASE"], env["CONFIG_BUILD_PROFILE"])

tools/build_script_generator/compilation_db/resources/compilation_db.py.in

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# License, v. 2.0. If a copy of the MPL was not distributed with this
77
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
88

9-
from os.path import join, abspath
9+
from os.path import join, abspath, realpath, dirname
1010
import sys, shutil
1111

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

@@ -48,6 +48,12 @@ env["SIZE"] = prefix + "size"
4848
env["STRIP"] = prefix + "strip"
4949
env["LINK"] = env["CXX"]
5050

51+
c_compiler_name = env["CC"]
52+
assert (c_compiler_path := shutil.which(c_compiler_name)), \
53+
f'Selected compiler "{c_compiler_name}" not found on PATH. ' \
54+
"Please add its installation directory to the PATH environment variable."
55+
env["GCC_PATH"] = dirname(dirname(realpath(c_compiler_path)))
56+
5157
%% endif
5258

5359
%% macro generate_flags_for_profile(name, profile, append=False)

0 commit comments

Comments
 (0)