From 2448ea161147389cef80f18eb432b8814cffdd91 Mon Sep 17 00:00:00 2001 From: Gustavo Jose de Sousa Date: Fri, 15 Jan 2016 14:02:21 -0200 Subject: [PATCH] waf: ardupilotwaf: add function build_shortcut That enable the easy creation of custom build commands with the purpose of creating "shortcuts" for execution from command line. For example, consider the following code fragment from a wscript: ``` copter = ardupilotwaf.build_shortcut(targets='ArduCopter') ``` With that, one can just issue `waf copter` instead of `waf --target ArduCopter`. The parameter target is made optional because more parameters might be added to this function in the future. --- Tools/ardupilotwaf/ardupilotwaf.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Tools/ardupilotwaf/ardupilotwaf.py b/Tools/ardupilotwaf/ardupilotwaf.py index 90efd04121..c8a3ac2292 100644 --- a/Tools/ardupilotwaf/ardupilotwaf.py +++ b/Tools/ardupilotwaf/ardupilotwaf.py @@ -2,7 +2,7 @@ # encoding: utf-8 from __future__ import print_function -from waflib import Logs, Utils +from waflib import Logs, Options, Utils SOURCE_EXTS = [ '*.S', @@ -236,3 +236,15 @@ def test_summary(bld): for filename in fails: Logs.error(' %s' % filename) + +def build_shortcut(targets=None): + def build_fn(bld): + if targets: + if Options.options.targets: + Options.options.targets += ',' + targets + else: + Options.options.targets = targets + + Options.commands = ['build'] + Options.commands + + return build_fn