From 212374149f7c957ea25ea12404f92c625fdc211a Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 4 Aug 2014 10:44:21 +0200 Subject: 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. --- wscript | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'wscript') diff --git a/wscript b/wscript index ee1ece5744..e0d71235e5 100644 --- a/wscript +++ b/wscript @@ -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) -- cgit v1.2.3