#! /usr/bin/env python # encoding: utf-8 # Thomas Nagy, 2006 (ita) # look for a command-line option named 'meow' by using "./waf --help" (where is it defined?) import Utils import Options # VERSION and APPNAME are required by 'waf dist' VERSION='0.0.1' APPNAME='cpp_test' # srcdir is almost always set to '.' except for some proprietary projects where the wscript # file cannot be found in the top-level; those projects usually provide: srcdir='..' top = '.' out = 'build' def set_options(opt): # command-line options provided in a script in a subdirectory named "src" opt.sub_options('src') # command-line options provided by a waf tool opt.tool_options('compiler_cxx') # custom command-line options opt.add_option('--exe', action='store_true', default=False, help='Execute the program after it is compiled') opt.add_option('--build_kind', action='store', default='debug,release', help='build the selected variants') def configure(conf): # conf.env.CXX = Options.options.meow # to configure using another compiler, use a command-line like this # CXX=g++-3.0 ./waf.py configure will use g++-3.0 instead of 'g++' conf.check_tool('compiler_cxx') ## batched builds can be enabled by including the module optim_cc # conf.check_tool('batched_cc') conf.sub_config('src') # here is how to override flags conf.env.CXXFLAGS_MYPROG = ['-O3'] if not Utils.is_win32: conf.env.LIB_MYPROG = ['m'] conf.env.SOME_INSTALL_DIR = '/tmp/ahoy/lib/' # create a debug and release builds (variants) dbg = conf.env.copy() rel = conf.env.copy() dbg.set_variant('debug') conf.set_env_name('debug', dbg) conf.setenv('debug') conf.env.CXXFLAGS = ['-D_REENTRANT', '-DDBG_ENABLED', '-Wall', '-O0', '-ggdb3', '-ftemplate-depth-128'] rel.set_variant('release') conf.set_env_name('release', rel) conf.setenv('release') conf.env.CXXFLAGS = ['-O2'] def build(bld): # process subfolders from here bld.env.CXXDEPS_MYPROG = '3344539' bld.add_subdirs('src app') # Examples for installing resources and files when doing './waf install' bld.install_files('${PREFIX}/subfolder/subsubfolder', 'src/*.h') #bld.install_files('${PREFIX}', 'src/a2.h src/a1.h') #install_as('${PREFIX}/dir/bar.png', 'foo.png') # enable the debug or the release variant, depending on the one wanted for obj in bld.all_task_gen[:]: # task generator instances (bld.new_task_gen...) should be created in the same order # to avoid unnecessary rebuilds (remember that cloning task generators is cheap, but copying task instances are expensive) debug_obj = obj.clone('debug') release_obj = obj.clone('release') # stupid reminder: do not make clones for the same variant (default -> default) # disable the original task generator for the default variant (do not use it) obj.posted = 1 # disable the unwanted variant(s) kind = Options.options.build_kind if kind.find('debug') < 0: debug_obj.posted = 1 if kind.find('release') < 0: release_obj.posted = 1 # here is how to execute a command when the build finishes def post(bld): cmd = "PATH=plugins:$PATH LD_LIBRARY_PATH=build/default/src/:$LD_LIBRARY_PATH build/default/src/testprogram" # if the custom option is set, execute the program if Options.options.exe: import os os.popen(cmd) # in case if more people ask #if Options.commands['install']: # try: os.popen("/sbin/ldconfig") # except: pass bld.add_post_fun(post)