diff --git a/Tools/ardupilotwaf/ardupilotwaf.py b/Tools/ardupilotwaf/ardupilotwaf.py index cc5272b139..d9b3c3d992 100644 --- a/Tools/ardupilotwaf/ardupilotwaf.py +++ b/Tools/ardupilotwaf/ardupilotwaf.py @@ -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', diff --git a/Tools/ardupilotwaf/boards.py b/Tools/ardupilotwaf/boards.py index 26b106f649..5a20f3ce9d 100644 --- a/Tools/ardupilotwaf/boards.py +++ b/Tools/ardupilotwaf/boards.py @@ -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',