diff --git a/demos/variants/wscript b/demos/variants/wscript index c20d655e..f8abd845 100644 --- a/demos/variants/wscript +++ b/demos/variants/wscript @@ -11,12 +11,12 @@ out = 'build' """ Variant system for waf 1.6 -call for example +Call for example: $ waf configure build_debug build_release clean_debug clean_release -""" -def options(opt): - opt.load('compiler_c') +The builds will end in different build folders +note how "bld.variant" is used to detect the current variant +""" def configure(conf): @@ -57,11 +57,8 @@ def build(bld): # * add an 'env' parameter to a particular task generator: # bld.program(..., env=bld.all_envs['release'].derive()) -# ------ new declaration for variants ------- -# -# calling 'waf clean_debug debug' will build into another output directory -# note how "bld.variant" is used to detect the current variant -# +def options(opt): + opt.load('compiler_c') def init(ctx): from waflib.Build import BuildContext, CleanContext, InstallContext, UninstallContext @@ -87,3 +84,27 @@ def init(ctx): # the commands will be "build_win32/debug" or "build_win32/release" # in this case you may want to modify Options.commands in this "init" function +# -------------------------- +# or, if you want to memorize the default variant and just type "waf", +# +#def options(opt): +# opt.load('compiler_c') +#def init(ctx): +# from waflib import ConfigSet, Options +# env = ConfigSet.ConfigSet() +# try: +# env.load('build/c4che/foo.txt') +# except: +# the_variant = 'debug' +# else: +# the_variant = env.the_variant or debug +# +# if getattr(Options.options, 'the_variant', ''): +# if Options.options.the_variant != the_variant: +# the_variant = env.the_variant = Options.options.the_variant +# env.store('build/c4che/foo.txt') +# +# for y in (BuildContext, CleanContext, InstallContext, UninstallContext): +# class tmp(y): +# variant = the_variant +