diff options
author | Stefano Pigozzi <stefano.pigozzi@gmail.com> | 2014-08-04 10:44:21 +0200 |
---|---|---|
committer | Stefano Pigozzi <stefano.pigozzi@gmail.com> | 2014-08-06 09:31:59 +0200 |
commit | 212374149f7c957ea25ea12404f92c625fdc211a (patch) | |
tree | 3438e2ef3a6735ebcb37e1d88d3ea77ac5133203 /wscript | |
parent | c8cf864bfff3e56c45f129e9d825cb41d54a647e (diff) | |
download | mpv-212374149f7c957ea25ea12404f92c625fdc211a.tar.bz2 mpv-212374149f7c957ea25ea12404f92c625fdc211a.tar.xz |
build: expose waf variants to the user
This allows the user to execute multiple configuration and build steps. It
can be used for several scenarios where you need different compiler flags.
Diffstat (limited to 'wscript')
-rw-r--r-- | wscript | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -773,6 +773,10 @@ def options(opt): help = 'directory for installing {0} [{1}]' \ .format(desc, default)) + group.add_option('--variant', + default = '', + help = 'variant name for saving configuration and build results') + opt.parse_features('build and install options', build_options) optional_features = main_dependencies + libav_dependencies opt.parse_features('optional feaures', optional_features) @@ -798,6 +802,7 @@ def is_debug_build(ctx): return getattr(ctx.options, 'enable_debug-build') def configure(ctx): + ctx.resetenv(ctx.options.variant) ctx.check_waf_version(mini='1.7.15') target = os.environ.get('TARGET') (cc, pkg_config, windres) = ('cc', 'pkg-config', 'windres') @@ -858,5 +863,27 @@ def configure(ctx): ctx.store_dependencies_lists() def build(ctx): + if ctx.options.variant not in ctx.all_envs: + from waflib import Errors + raise Errors.WafError( + 'The project was not configured: run "waf --variant={0} configure" first!' + .format(ctx.options.variant)) ctx.unpack_dependencies_lists() ctx.load('wscript_build') + +def init(ctx): + from waflib.Build import BuildContext, CleanContext, InstallContext, UninstallContext + for y in (BuildContext, CleanContext, InstallContext, UninstallContext): + class tmp(y): + variant = ctx.options.variant + + # This is needed because waf initializes the ConfigurationContext with + # an arbitrary setenv('') which would rewrite the previous configuration + # cache for the default variant if the configure step finishes. + # Ideally ConfigurationContext should just let us override this at class + # level like the other Context subclasses do with variant + from waflib.Configure import ConfigurationContext + class cctx(ConfigurationContext): + def resetenv(self, name): + self.all_envs = {} + self.setenv(name) |