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 | |
Alexander Afanasyev | 20c85cb | 2018-03-09 17:50:14 -0500 | [diff] [blame] | 4 | from waflib import Options |
Shock Jiang | 0f0bc4b | 2015-06-22 15:11:30 -0700 | [diff] [blame] | 5 | |
| 6 | def options(opt): |
Davide Pesavento | 3347eaa | 2019-01-16 18:41:46 -0500 | [diff] [blame] | 7 | for subdir in opt.path.ant_glob('*', dir=True, src=False): |
Davide Pesavento | 1aa9143 | 2018-02-19 22:43:31 -0500 | [diff] [blame] | 8 | tool = subdir.path_from(opt.path) |
Davide Pesavento | b6e10dd | 2023-09-11 21:41:24 -0400 | [diff] [blame^] | 9 | opt.add_option(f'--enable-{tool}', |
| 10 | help=f'Build tool {tool} (enabled by default)', |
| 11 | action='store_true', dest=f'enable_{tool}') |
| 12 | opt.add_option(f'--disable-{tool}', |
| 13 | help=f'Do not build tool {tool}', |
| 14 | action='store_true', dest=f'disable_{tool}') |
Davide Pesavento | 1aa9143 | 2018-02-19 22:43:31 -0500 | [diff] [blame] | 15 | opt.recurse(str(tool), mandatory=False) |
Shock Jiang | 0f0bc4b | 2015-06-22 15:11:30 -0700 | [diff] [blame] | 16 | |
Junxiao Shi | f719124 | 2015-03-19 05:53:41 -0700 | [diff] [blame] | 17 | def configure(conf): |
Shock Jiang | 0f0bc4b | 2015-06-22 15:11:30 -0700 | [diff] [blame] | 18 | all_tools = set() # all available tools |
| 19 | enabled_tools = set() # --enable-X |
| 20 | disabled_tools = set() # --disable-X |
| 21 | |
Alexander Afanasyev | 20c85cb | 2018-03-09 17:50:14 -0500 | [diff] [blame] | 22 | for subdir in conf.path.ant_glob('*', dir=True, src=False): |
| 23 | tool = subdir.path_from(conf.path) |
Shock Jiang | 0f0bc4b | 2015-06-22 15:11:30 -0700 | [diff] [blame] | 24 | all_tools.add(tool) |
| 25 | |
Davide Pesavento | b6e10dd | 2023-09-11 21:41:24 -0400 | [diff] [blame^] | 26 | is_enabled = getattr(Options.options, f'enable_{tool}') |
| 27 | is_disabled = getattr(Options.options, f'disable_{tool}') |
Shock Jiang | 0f0bc4b | 2015-06-22 15:11:30 -0700 | [diff] [blame] | 28 | |
| 29 | if is_enabled and is_disabled: |
Davide Pesavento | b6e10dd | 2023-09-11 21:41:24 -0400 | [diff] [blame^] | 30 | conf.fatal(f'--enable-{tool} and --disable-{tool} cannot be both specified') |
Shock Jiang | 0f0bc4b | 2015-06-22 15:11:30 -0700 | [diff] [blame] | 31 | |
| 32 | if is_enabled: |
| 33 | enabled_tools.add(tool) |
| 34 | |
| 35 | if is_disabled: |
| 36 | disabled_tools.add(tool) |
| 37 | |
| 38 | if len(enabled_tools) == 0: |
Davide Pesavento | ae37cf3 | 2019-02-20 18:19:22 -0500 | [diff] [blame] | 39 | conf.env.BUILD_TOOLS = list(all_tools - disabled_tools) |
Shock Jiang | 0f0bc4b | 2015-06-22 15:11:30 -0700 | [diff] [blame] | 40 | else: |
Davide Pesavento | ae37cf3 | 2019-02-20 18:19:22 -0500 | [diff] [blame] | 41 | conf.env.BUILD_TOOLS = list(enabled_tools) |
Shock Jiang | 0f0bc4b | 2015-06-22 15:11:30 -0700 | [diff] [blame] | 42 | |
Davide Pesavento | ae37cf3 | 2019-02-20 18:19:22 -0500 | [diff] [blame] | 43 | for tool in conf.env.BUILD_TOOLS: |
Shock Jiang | 0f0bc4b | 2015-06-22 15:11:30 -0700 | [diff] [blame] | 44 | conf.recurse(tool, mandatory=False) |
| 45 | |
Junxiao Shi | f719124 | 2015-03-19 05:53:41 -0700 | [diff] [blame] | 46 | def build(bld): |
Davide Pesavento | ae37cf3 | 2019-02-20 18:19:22 -0500 | [diff] [blame] | 47 | for tool in bld.env.BUILD_TOOLS: |
Shock Jiang | 0f0bc4b | 2015-06-22 15:11:30 -0700 | [diff] [blame] | 48 | bld.recurse(tool) |