Skip to content

Instantly share code, notes, and snippets.

@aggieben
Created September 28, 2009 16:48
Show Gist options
  • Save aggieben/195555 to your computer and use it in GitHub Desktop.
Save aggieben/195555 to your computer and use it in GitHub Desktop.
def init():
pass
def set_options(opt):
import optparse
modes = ('debug', 'release', 'diagnostic')
bld_group = optparse.OptionGroup(opt.parser, "Build Options")
bld_group.add_option('-m', '--mode', choices=modes, type='choice', default='debug', action='store',
help='Build mode: can be one of {0} [default=debug]'.format(modes))
opt.add_option_group(bld_group)
opt.tool_options('compiler_cxx')
def configure(conf):
conf.check_tool('compiler_cxx')
conf.check_tool('batched_cc')
if Options.options.mode == 'release':
env_rel = conf.env.copy()
env_rel.append_value('CXXFLAGS', '-02')
env_rel.set_variant('release')
conf.set_env_name('release', env_rel)
conf.setenv('release')
if Options.options.mode == 'debug':
env_dbg = conf.env.copy()
env_dbg.append_value('CXXFLAGS', '-g')
env_dbg.set_variant('debug')
conf.set_env_name('debug', env_dbg)
conf.setenv('debug')
def build(bld):
if Options.options.mode:
print '======= Building in {0} mode ======='.format(Options.options.mode)
inc_buildnum('{0}/.buildnum'.format(TOP))
print 'version.cpp.in -> version.cpp'
reversion(bld.env, TOP)
for obj in bld.all_task_gen[:]:
new_obj = obj.clone(Options.options.mode)
bld.add_subdirs('src')
def shutdown():
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment