From afcabda21c8fa39dfd671925df2c61349d43a684 Mon Sep 17 00:00:00 2001 From: Gustavo Jose de Sousa Date: Mon, 23 May 2016 10:48:39 -0300 Subject: [PATCH] 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. --- Tools/ardupilotwaf/ardupilotwaf.py | 24 +++++++++++++--------- wscript | 33 ++++++++++++++++-------------- 2 files changed, 32 insertions(+), 25 deletions(-) diff --git a/Tools/ardupilotwaf/ardupilotwaf.py b/Tools/ardupilotwaf/ardupilotwaf.py index 8579f451ec..b5dcd1e272 100644 --- a/Tools/ardupilotwaf/ardupilotwaf.py +++ b/Tools/ardupilotwaf/ardupilotwaf.py @@ -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 / 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 / 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') + action='store_true', + help='Output all test programs.') def build(bld): diff --git a/wscript b/wscript index c51a1d1be8..bb19d1e073 100644 --- a/wscript +++ b/wscript @@ -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) + action='store', + choices=boards_names, + default='sitl', + 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.') + dest='submodule_update', + action='store_false', + default=True, + 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') + action='store_true', + default=False, + help='Enable benchmarks.') g.add_option('--debug', - action='store_true', - default=False, - help='Configure as debug variant') + action='store_true', + default=False, + help='Configure as debug variant.') def configure(cfg): cfg.env.BOARD = cfg.options.board