Sophie

Sophie

distrib > Fedora > 14 > x86_64 > by-pkgid > 42620103d8ee8a2d972d3103bad0ab73 > files > 28

waf-1.5.19-1.fc14.noarch.rpm

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

# WARNING
# nearly all the code in this file requires importing misc.py
# the system of command-output is still provided for compatibility,
# and for the cases where it is better to launch commands by
# using the direct arguments, without a shell (spaces in names, speed, ..)
#
# these apis may be less convenient than the rule-based processing

# make sure to import this somewhere else the command-output thing will not work
import misc

#######################################################################

# This file is not a module, and all the code
# from it will be executed upon compile step
#
# This is really the content of a "def build(bld):" function definition
#
# By contrast, only functions can be defined in a wscript
#

# and look in the file misc.py!


# a program that links using the GLIB library, defined in the configuration
# it also processes coin files, defined in the dang.py module (coin hook)
obj = bld(
	features = 'cxx cshlib',
	includes = '. ..',
	uselib = 'GLIB',
	target = 'shlib3',
	vnum = '1.2.3')
obj.find_sources_in_dirs('. gui')

# process file.pc.in -> file.pc - by default it uses the task "env" attribute
obj = bld(
	features = 'subst',
	source = 'test.pc.in')
# next line is for adding various keys to the task env
obj.env.table.update({'LIBS': '-lkdecore', 'LIBICONV': '-lqt-mt', 'XPM_CFLAGS': '-lm',
    'VERSION': '1.0', 'XPM_LIBS': '-lxpm', 'PREFIX': 'foo'})

# the following still works but it is better to use the rule-based processing
#
# a function to execute in the middle of the build
#def print_hello(task):
#	print "\n->> ahoy"
#	return 0
# execute arbitrary code in the middle of the build
#obj = bld('cmd')
#obj.fun = print_hello
#

# build dir traversal
bld.add_subdirs('gui gui2')

# generate files from a command
out1 = bld(
	features = 'command-output',
	stdout = 'test1',
	stdin = 'wscript_build',
	command = 'some-script',
	argv = ['--output-md5', misc.output_file('test1.md5')],
	vars = 'COINCOIN')
out1.env.COINCOIN = 'Some string to trigger rebuilds'


out2 = bld(
	features = 'command-output',
	stdout = 'test2',
	command = 'some-script',
	argv = ['--input', misc.input_file('test1')],
	vars='MIAOU',
	dependencies = [out1])
out2.env.MIAOU = 'Another string to trigger rebuilds'
out2.dependencies = [out1]


out3 = bld(
	features = 'command-output',
	stdin = 'test2',
	stdout = 'test3',
	command = 'cat',
	command_is_external = True,
	dependencies = [out2])

bld(
	features = 'command-output',
	stdin = 'test3',
	stdout = 'test4',
	command = 'cat',
	command_is_external = True,
	dependencies = [out3])

# compile a generated cpp file into a program
bld(
	features = 'command-output',
	before = 'cxx',
	stdout = 'main1.cpp',
	command = 'cat',
	command_is_external = True,
	argv = [misc.input_file('main.cpp')])

bld(
	features = 'cxx cprogram',
	source = 'main1.cpp',
	target = 'main1',
	includes = '..')

# when copying files to the build dir, it is important to name the files differently
# a file is either in the source dir or in the build dir but not in both
#
# source != target
bld(
	features = 'copy',
	source = 'main.cpp',
	target = 'blah')

# -- run a command and retrive stderr into a file
bld(
	features = 'command-output',
	stderr = 'ls-error.out',
	command = 'bash',
	argv = ['-c', 'ls --xpto-foo-bar || true;'],
	stdin = 'wscript_build',
	command_is_external = True)