blob: 05041e76a4eb31e6a745e101f52b841c3d5c178a [file] [log] [blame]
Junxiao Shif7191242015-03-19 05:53:41 -07001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
2top = '..'
3
Alexander Afanasyev20c85cb2018-03-09 17:50:14 -05004from waflib import Options
Shock Jiang0f0bc4b2015-06-22 15:11:30 -07005
6def options(opt):
Davide Pesavento3347eaa2019-01-16 18:41:46 -05007 for subdir in opt.path.ant_glob('*', dir=True, src=False):
Davide Pesavento1aa91432018-02-19 22:43:31 -05008 tool = subdir.path_from(opt.path)
Davide Pesaventob6e10dd2023-09-11 21:41:24 -04009 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 Pesavento1aa91432018-02-19 22:43:31 -050015 opt.recurse(str(tool), mandatory=False)
Shock Jiang0f0bc4b2015-06-22 15:11:30 -070016
Junxiao Shif7191242015-03-19 05:53:41 -070017def configure(conf):
Shock Jiang0f0bc4b2015-06-22 15:11:30 -070018 all_tools = set() # all available tools
19 enabled_tools = set() # --enable-X
20 disabled_tools = set() # --disable-X
21
Alexander Afanasyev20c85cb2018-03-09 17:50:14 -050022 for subdir in conf.path.ant_glob('*', dir=True, src=False):
23 tool = subdir.path_from(conf.path)
Shock Jiang0f0bc4b2015-06-22 15:11:30 -070024 all_tools.add(tool)
25
Davide Pesaventob6e10dd2023-09-11 21:41:24 -040026 is_enabled = getattr(Options.options, f'enable_{tool}')
27 is_disabled = getattr(Options.options, f'disable_{tool}')
Shock Jiang0f0bc4b2015-06-22 15:11:30 -070028
29 if is_enabled and is_disabled:
Davide Pesaventob6e10dd2023-09-11 21:41:24 -040030 conf.fatal(f'--enable-{tool} and --disable-{tool} cannot be both specified')
Shock Jiang0f0bc4b2015-06-22 15:11:30 -070031
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 Pesaventoae37cf32019-02-20 18:19:22 -050039 conf.env.BUILD_TOOLS = list(all_tools - disabled_tools)
Shock Jiang0f0bc4b2015-06-22 15:11:30 -070040 else:
Davide Pesaventoae37cf32019-02-20 18:19:22 -050041 conf.env.BUILD_TOOLS = list(enabled_tools)
Shock Jiang0f0bc4b2015-06-22 15:11:30 -070042
Davide Pesaventoae37cf32019-02-20 18:19:22 -050043 for tool in conf.env.BUILD_TOOLS:
Shock Jiang0f0bc4b2015-06-22 15:11:30 -070044 conf.recurse(tool, mandatory=False)
45
Junxiao Shif7191242015-03-19 05:53:41 -070046def build(bld):
Davide Pesaventoae37cf32019-02-20 18:19:22 -050047 for tool in bld.env.BUILD_TOOLS:
Shock Jiang0f0bc4b2015-06-22 15:11:30 -070048 bld.recurse(tool)