Browse Source

waf: add --define command-line option

Allows CPP defines to be specified on command-line

Eases enable/disable of optional features
apm_2208
Peter Barker 3 years ago committed by Andrew Tridgell
parent
commit
c0243772b4
  1. 4
      Tools/ardupilotwaf/ardupilotwaf.py
  2. 7
      Tools/ardupilotwaf/boards.py

4
Tools/ardupilotwaf/ardupilotwaf.py

@ -563,6 +563,10 @@ arducopter and upload it to my board". @@ -563,6 +563,10 @@ arducopter and upload it to my board".
action='store_true',
help='Output all test programs.')
g.add_option('--define',
action='append',
help='Add C++ define to build.')
g = opt.ap_groups['clean']
g.add_option('--clean-all-sigs',

7
Tools/ardupilotwaf/boards.py

@ -136,6 +136,13 @@ class Board: @@ -136,6 +136,13 @@ class Board:
# make easy to override them. Convert back to list before consumption.
env.DEFINES = {}
# potentially set extra defines from an environment variable:
if cfg.options.define is not None:
for (n, v) in [d.split("=") for d in cfg.options.define]:
cfg.msg("Defining: %s" % (n, ), v)
env.CFLAGS += ['-D%s=%s' % (n, v)]
env.CXXFLAGS += ['-D%s=%s' % (n, v)]
env.CFLAGS += [
'-ffunction-sections',
'-fdata-sections',

Loading…
Cancel
Save