wscript 1.9 KB

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