Junxiao Shi | f719124 | 2015-03-19 05:53:41 -0700 | [diff] [blame] | 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- |
| 2 | top = '..' |
| 3 | |
Shock Jiang | 0f0bc4b | 2015-06-22 15:11:30 -0700 | [diff] [blame] | 4 | from waflib import Options, Logs, Errors |
| 5 | |
| 6 | def options(opt): |
| 7 | for subdir in opt.path.ant_glob(['*'], dir=True, src=False): |
| 8 | opt.add_option('--enable-%s' % subdir, |
| 9 | help='Build tool %s, enabled by default' % subdir, |
| 10 | action="store_true", |
| 11 | dest='enable_%s' % subdir) |
| 12 | |
| 13 | opt.add_option('--disable-%s' % subdir, |
| 14 | help='Do not build tool %s', |
| 15 | action="store_true", |
| 16 | dest='disable_%s' % subdir) |
| 17 | |
| 18 | opt.recurse(str(subdir), mandatory=False) |
| 19 | |
| 20 | |
Junxiao Shi | f719124 | 2015-03-19 05:53:41 -0700 | [diff] [blame] | 21 | def configure(conf): |
Shock Jiang | 0f0bc4b | 2015-06-22 15:11:30 -0700 | [diff] [blame] | 22 | all_tools = set() # all available tools |
| 23 | enabled_tools = set() # --enable-X |
| 24 | disabled_tools = set() # --disable-X |
| 25 | |
Junxiao Shi | f719124 | 2015-03-19 05:53:41 -0700 | [diff] [blame] | 26 | for subdir in conf.path.ant_glob(['*'], dir=True, src=False): |
Shock Jiang | 0f0bc4b | 2015-06-22 15:11:30 -0700 | [diff] [blame] | 27 | tool = str(subdir) |
| 28 | all_tools.add(tool) |
| 29 | |
| 30 | is_enabled = getattr(Options.options, 'enable_%s' % tool) |
| 31 | is_disabled = getattr(Options.options, 'disable_%s' % tool) |
| 32 | |
| 33 | if is_enabled and is_disabled: |
| 34 | raise Errors.WafError("--enable-%s and --disable-%s cannot be both specified" % (tool, tool)) |
| 35 | |
| 36 | if is_enabled: |
| 37 | enabled_tools.add(tool) |
| 38 | |
| 39 | if is_disabled: |
| 40 | disabled_tools.add(tool) |
| 41 | |
| 42 | if len(enabled_tools) == 0: |
| 43 | conf.env['BUILD_TOOLS'] = list(all_tools - disabled_tools) |
| 44 | else: |
| 45 | conf.env['BUILD_TOOLS'] = list(enabled_tools) |
| 46 | |
| 47 | for tool in conf.env['BUILD_TOOLS']: |
| 48 | conf.recurse(tool, mandatory=False) |
| 49 | |
| 50 | conf.msg("Tools to build", ", ".join(conf.env['BUILD_TOOLS'])) |
Junxiao Shi | f719124 | 2015-03-19 05:53:41 -0700 | [diff] [blame] | 51 | |
| 52 | def build(bld): |
Shock Jiang | 0f0bc4b | 2015-06-22 15:11:30 -0700 | [diff] [blame] | 53 | for tool in bld.env['BUILD_TOOLS']: |
| 54 | bld.recurse(tool) |