Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 2053a0d9eaaf755b990f80ce4df504a7 > files > 155

waf-1.5.9-1mdv2010.0.noarch.rpm

#! /usr/bin/env python
# encoding: utf-8
# Thomas Nagy, 2006 (ita)

# look for 'meow' below
#import Options

# the following two variables are used by the target "waf dist"
VERSION='0.0.1'
APPNAME='cpp_test'

# these variables are mandatory ('/' are converted automatically)
srcdir = '.'
blddir = 'build'

def init(ctx):
	pass

def set_options(opt):
	# options provided in a script in a subdirectory named "src"
	opt.sub_options('src')

	# options provided by the modules
	opt.tool_options('compiler_cxx')

	# custom options
	opt.add_option('--exe', action='store_true', default=False, help='Execute the program after it is compiled')

def configure(conf):
	# conf.env.CXX = Options.options.meow
	# 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')

	conf.env.CXXFLAGS_MYPROG  = '-O3'
	conf.env.LIB_MYPROG       = 'm'
	conf.env.SOME_INSTALL_DIR = '/tmp/ahoy/lib/'

	# works in a procedural way, so the order of calls does matter
	#conf.check_tool(['KDE3'])

	# testcase for variants, look below
	env = conf.env.copy()
	env.set_variant('debug')
	conf.set_env_name('debug', env)
	conf.setenv('debug')
	conf.env.CXXFLAGS = ['-D_REENTRANT', '-DDBG_ENABLED', '-Wall', '-O0', '-ggdb3', '-ftemplate-depth-128']

def build(bld):
	# process subfolders from here
	bld.env.CXXDEPS_MYPROG = '3344539'

	bld.add_subdirs('src src2')

	## installing resources and files - call them under build(bld) or shutdown()
	## to trigger the glob, ad a star in the name
	## the functions are not called if not in install mode
	#bld.install_files('${PREFIX}', 'src/a2.h src/a1.h')
	bld.install_files('${PREFIX}/subfolder/subsubfolder', 'src/*.h')
	#install_as('${PREFIX}/dir/bar.png', 'foo.png')

	# testcase for variants
	for obj in bld.all_task_gen[:]:
		new_obj = obj.clone('debug')

	def post(bld):
		# command to execute
		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
		import os, Options
		if Options.options.exe:
			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)