Skip to content

Commit b8a5284

Browse files
committed
Distinguish between C and C++ flags
1 parent 7e13689 commit b8a5284

File tree

5 files changed

+15
-8
lines changed

5 files changed

+15
-8
lines changed

tools/build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@
230230
else:
231231
# Build
232232
extra_flags = {'cflags': options.cflags, 'asmflags': options.asmflags,
233-
'ldflags': options.ldflags}
233+
'ldflags': options.ldflags, 'cxxflags': options.cxxflags}
234234
for toolchain in toolchains:
235235
for target in targets:
236236
tt_id = "%s::%s" % (toolchain, target)

tools/build_api.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,10 @@ def prepare_toolchain(src_paths, target, toolchain_name,
318318
except KeyError:
319319
raise KeyError("Toolchain %s not supported" % toolchain_name)
320320

321-
if extra_flags and 'cflags' in extra_flags:
322-
toolchain.hook.hook_cmdline_compiler(
323-
lambda name, flags: flags + extra_flags['cflags'])
321+
if extra_flags and 'cflags' in extra_flags:
322+
toolchain.cc.extend(extra_flags['cflags'])
323+
if extra_flags and 'cxxflags' in extra_flags:
324+
toolchain.cppc.extend(extra_flags['cxxflags'])
324325
if extra_flags and 'ldflags' in extra_flags:
325326
toolchain.hook.hook_cmdline_linker(
326327
lambda name, flags: flags + extra_flags['ldflags'])
@@ -550,7 +551,7 @@ def build_library(src_paths, build_path, target, toolchain_name,
550551
toolchain = prepare_toolchain(
551552
src_paths, target, toolchain_name, macros=macros, options=options,
552553
clean=clean, jobs=jobs, notify=notify, silent=silent, verbose=verbose,
553-
extra_verbose=extra_verbose, extra_flags=None)
554+
extra_verbose=extra_verbose, extra_flags=extra_flags)
554555

555556
# The first path will give the name to the library
556557
if name is None:

tools/make.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@
261261

262262
try:
263263
extra_flags = {'cflags': options.cflags, 'asmflags': options.asmflags,
264-
'ldflags': options.ldflags}
264+
'ldflags': options.ldflags, 'cxxflags': options.cxxflags}
265265
bin_file = build_project(test.source_dir, build_dir, mcu, toolchain, test.dependencies, options.options,
266266
linker_script=options.linker_script,
267267
clean=options.clean,

tools/options.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ def get_default_options_parser(add_clean=True, add_options=True):
5757
parser.add_argument("--cflags", default=[], action="append",
5858
help="Extra flags to provide to the C compiler")
5959

60+
parser.add_argument("--cxxflags", default=[], dest="cxxflags",
61+
action="append",
62+
help="Extra flags to provide to the C++ compiler")
63+
6064
parser.add_argument("--asmflags", default=[], action="append",
6165
help="Extra flags to provide to the assembler")
6266

tools/test.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@
167167
library_build_success = False
168168
try:
169169
extra_flags = {'cflags': options.cflags, 'asmflags': options.asmflags,
170-
'ldflags': options.ldflags}
170+
'ldflags': options.ldflags,
171+
'cxxflags': options.cxxflags}
171172
# Build sources
172173
build_library(base_source_paths, options.build_dir, mcu, toolchain,
173174
options=options.options,
@@ -200,7 +201,8 @@
200201
# Build all the tests
201202
extra_flags = {'cflags': options.cflags,
202203
'asmflags': options.asmflags,
203-
'ldflags': options.ldflags}
204+
'ldflags': options.ldflags,
205+
'cxxflags': options.cxxflags}
204206
test_build_success, test_build = build_tests(
205207
tests, [options.build_dir], options.build_dir, mcu, toolchain,
206208
options=options.options,

0 commit comments

Comments
 (0)