Sophie

Sophie

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

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

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

# 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'
srcdir = '.'
blddir = 'build'

def set_options(opt):
	pass

def configure(conf):
	pass

def build(bld):

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

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

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

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

	# no input and no output, ('always' attribute -> the task is always executed)
	bld.new_task_gen(
		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.new_task_gen(
		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.new_task_gen(
		name='hi',
		rule=run
	)

	# the dependant task copy_svnversion is executed
	# when the actual output of svnversion changes (on_results attribute)
	bld.new_task_gen(
		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.new_task_gen(
		name='copy_svnversion',
		after='svnversion',
		source='ver.h',
		target='ver2.h',
		rule='cp ${SRC} ${TGT}',
		scan = scan_met,
	)