waf: use better style for add_option() calls

Setting the "help" keyword argument may not fit in one line sometimes. This
patch adds the following convention to calls to add_option() in order to
address that issue in a better way:

    1) The "help" keyword must always be the last argument to be passed.

    2) If the help string is a literal string or a literal string with some
    operation (e.g. "%" operator) and setting the "help" keyword in the code
    doesn't fit a line (considering the limit of characters in a line), then
    the help string must be a triple-quoted string. That has the advantage of
    not having to have several "+" operations for long help strings. In that
    case, the help message must start on the next line and the closing
    triple-quotes must be on a separate line together with the closing
    parenthesis.

The requirement (1) makes it easier to make the style exception in (2)
acceptable.
This commit is contained in:
Gustavo Jose de Sousa 2016-05-23 10:48:39 -03:00 committed by Lucas De Marchi
parent 64b8ec61c7
commit afcabda21c
2 changed files with 32 additions and 25 deletions

View File

@ -366,25 +366,29 @@ def _select_programs_from_group(bld):
def options(opt):
g = opt.ap_groups['build']
g.add_option('--program-group',
action='append',
default=[],
help='Select all programs that go in <PROGRAM_GROUP>/ for the ' +
'build. Example: `waf --program-group examples` builds all ' +
'examples. The special group "all" selects all programs.',
)
help='''
Select all programs that go in <PROGRAM_GROUP>/ for the build. Example: `waf
--program-group examples` builds all examples. The special group "all" selects
all programs.
''')
g.add_option('--upload',
action='store_true',
help='Upload applicable targets to a connected device. Not all ' +
'platforms may support this. Example: `waf copter --upload` ' +
'means "build arducopter and upload it to my board".',
)
help='''
Upload applicable targets to a connected device. Not all platforms may support
this. Example: `waf copter --upload` means "build arducopter and upload it to
my board".
''')
g = opt.ap_groups['check']
g.add_option('--check-verbose',
action='store_true',
help='Output all test programs')
help='Output all test programs.')
def build(bld):

13
wscript
View File

@ -52,29 +52,32 @@ def options(opt):
opt.load('ardupilotwaf')
g = opt.ap_groups['configure']
boards_names = boards.get_boards_names()
g.add_option('--board',
action='store',
choices=boards_names,
default='sitl',
help='Target board to build, choices are %s' % boards_names)
help='Target board to build, choices are %s.' % boards_names)
g.add_option('--no-submodule-update',
dest='submodule_update',
action='store_false',
default=True,
help='Don\'t update git submodules. Useful for building ' +
'with submodules at specific revisions.')
help='''
Don't update git submodules. Useful for building with submodules at specific
revisions.
''')
g.add_option('--enable-benchmarks',
action='store_true',
default=False,
help='Enable benchmarks')
help='Enable benchmarks.')
g.add_option('--debug',
action='store_true',
default=False,
help='Configure as debug variant')
help='Configure as debug variant.')
def configure(cfg):
cfg.env.BOARD = cfg.options.board