Sophie

Sophie

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

waf-1.5.19-1.fc14.noarch.rpm

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

# Illustrate how to enable a makefile-like syntax
#
# WARNING: this wscript file is the source of some of the tasks
# if you modify it, the files will be rebuilt
#

VERSION= '0.0.1'
APPNAME= 'make_like'
top = '.'
out = 'build'

def set_options(opt):
	pass

def configure(conf):
	pass

def build(bld):

	# a source file and one output
	bld(
		source='wscript',
		target='test.k1',
		rule='cp ${SRC} ${TGT}'
	)

	# a source file but no outputs
	bld(
		source='wscript',
		rule='echo ${SRC}'
	)

	# no source file but one output (execute when PREFIX changes)
	bld(
		target='test.k3',
		rule='echo ${PREFIX} > ${TGT}',
	)

	# no inputs and no outputs (execute when PREFIX changes)
	bld(
		rule='echo ${PREFIX}'
	)

	# no input and no output, ('always' attribute -> the task is always executed)
	bld(
		rule="echo 'task always run'",
		always=True
	)

	# a source file and a target with a more complicated
	# rule and a constraint on the order (before)
	# a cwd attribute may be provided to set the directory to execute from
	bld(
		source='wscript',
		target='test.k',
		rule='./create.py && mv ${TGT[0].abspath()} ${TGT[0].abspath(env)}',
		cwd=bld.path.abspath(),
		before='test.k1'
	)

	# no input and no output, the task executes a function
	def run(self):
		print 'hi there'

	bld(
		name='hi',
		rule=run
	)

	# the dependant task copy_svnversion is executed
	# when the actual output of svnversion changes (on_results attribute)
	bld(
		name='svnversion',
		target='ver.h',
		rule='svnversion > ${TGT[0].abspath(env)}',
		cwd=bld.path.abspath(),
		always=True,
		on_results=True
	)

	def scan_met(self):
		# add additional node dependencies at runtime
		node = self.generator.path.find_resource('wscript')
		return ([node], [])

	bld(
		name='copy_svnversion',
		after='svnversion',
		source='ver.h',
		target='ver2.h',
		rule='cp ${SRC} ${TGT}',
		scan = scan_met,
	)