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.
This commit is contained in:
Gustavo Jose de Sousa 2016-01-15 14:02:21 -02:00 committed by Lucas De Marchi
parent 0b8eff79af
commit 2448ea1611
1 changed files with 13 additions and 1 deletions

View File

@ -2,7 +2,7 @@
# encoding: utf-8 # encoding: utf-8
from __future__ import print_function from __future__ import print_function
from waflib import Logs, Utils from waflib import Logs, Options, Utils
SOURCE_EXTS = [ SOURCE_EXTS = [
'*.S', '*.S',
@ -236,3 +236,15 @@ def test_summary(bld):
for filename in fails: for filename in fails:
Logs.error(' %s' % filename) 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