2011-09-10 11:13:51 +02:00
|
|
|
#! /usr/bin/env python
|
|
|
|
# encoding: utf-8
|
|
|
|
|
|
|
|
top = '.'
|
|
|
|
out = 'bin'
|
|
|
|
|
2014-01-14 20:01:05 +01:00
|
|
|
import os, re
|
2011-09-10 11:13:51 +02:00
|
|
|
from waflib import Utils
|
|
|
|
|
|
|
|
def configure(conf):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def build(bld):
|
|
|
|
|
|
|
|
# the test.pc.in is a special case which is always handled
|
2015-02-07 22:27:54 +01:00
|
|
|
bld(source='test.pc.in', VERSION='1.1', LIBS='moo', XPM_LIBS='-lxpm', LIBICONV='-liconv', XPM_CFLAGS='-O3', INTVAR=12)
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
tg = bld(
|
|
|
|
features = 'subst', # the feature 'subst' overrides the source/target processing
|
|
|
|
source = 'foo.in', # list of string or nodes
|
|
|
|
target = 'foo.txt', # list of strings or nodes
|
2012-05-08 19:01:30 +02:00
|
|
|
encoding = 'ascii', # file encoding for python3, default is ISO8859-1
|
2011-09-10 11:13:51 +02:00
|
|
|
install_path = '/tmp/uff/', # installation path, optional
|
|
|
|
chmod = Utils.O755, # installation mode, optional
|
|
|
|
PREFIX = bld.env.PREFIX, # variables to use in the substitution
|
2014-01-14 20:01:05 +01:00
|
|
|
re_m4 = re.compile('%%(\w+)%%', re.M), # custom substitution
|
2011-09-10 11:13:51 +02:00
|
|
|
BINDIR = bld.env.BINDIR)
|
|
|
|
|
|
|
|
# if you are using an external dict, here is to merge the key/values:
|
|
|
|
dct = {'BINDIR': '/opt'}
|
|
|
|
tg.__dict__.update(dct)
|
|
|
|
|
2012-03-29 00:04:34 +02:00
|
|
|
# if you want a file copy, pass "is_copy=True"
|
|
|
|
bld(features='subst', source='wscript', target='wscript', is_copy=True)
|
|
|
|
|
2012-10-08 18:30:47 +02:00
|
|
|
# same thing with a simple function
|
|
|
|
def fun(task, text):
|
|
|
|
return text
|
|
|
|
bld(features='subst', subst_fun=fun, source='wscript', target='wscript2')
|
|
|
|
|
2013-05-05 22:54:19 +02:00
|
|
|
def hlink(task):
|
|
|
|
try:
|
|
|
|
link = os.link
|
2014-01-01 16:07:08 +01:00
|
|
|
except AttributeError:
|
2013-05-05 22:54:19 +02:00
|
|
|
task.outputs[0].write(task.inputs[0].read('rb'), 'wb')
|
|
|
|
else:
|
|
|
|
for x, y in zip(task.inputs, task.outputs):
|
|
|
|
try:
|
|
|
|
os.remove(y.abspath())
|
|
|
|
except OSError:
|
|
|
|
pass
|
|
|
|
os.link(x.abspath(), y.abspath())
|
|
|
|
bld(features='subst', fun=hlink, source='wscript', target='wscript3')
|
|
|
|
|
2011-09-10 11:13:51 +02:00
|
|
|
# this one is just a reminder that simple files can be created (and a test too)
|
2015-02-14 15:41:32 +01:00
|
|
|
bld(rule='echo "การไฟ่" > ${TGT}', target='uni.txt')
|
2011-09-10 11:13:51 +02:00
|
|
|
|
2012-09-17 23:45:59 +02:00
|
|
|
# and this is an alternate syntax
|
|
|
|
#@bld.rule(source='wscript', target='wscript2')
|
|
|
|
#def _(tsk):
|
|
|
|
# tsk.outputs[0].write(tsk.inputs[0].read())
|
|
|
|
|