wscript (1481B)
1 #!/usr/bin/env python 2 3 import os, re, subprocess 4 from waflib import Options, TaskGen, Utils 5 6 def options(opt): 7 opt.load('rst') 8 opt.load('tex') 9 10 def configure(conf): 11 conf.load('rst') 12 conf.load('tex') 13 14 def build(bld): 15 bld( 16 features='rst', 17 target='test0.html', 18 source='test0.rst', 19 ) 20 21 bld( 22 target='generated.rst', 23 rule=lambda tsk: Utils.writef( tsk.outputs[0].abspath(), "Generated contents in %s" % tsk.outputs[0].name), 24 ) 25 26 bld( 27 target='generated.csv', 28 rule=lambda tsk: Utils.writef( tsk.outputs[0].abspath(), "a,b,c\n1,2,%s" % tsk.outputs[0].name), 29 ) 30 31 bld( 32 target='generated.html', 33 rule=lambda tsk: Utils.writef( tsk.outputs[0].abspath(), "<p>Generated HTML data</p>"), 34 ) 35 36 bld( 37 features='rst', 38 target='test1.html', 39 source='test1.rst', 40 ) 41 42 bld( 43 features='rst', 44 target='test1.pdf', 45 source='test1.rst', 46 ) 47 48 for x in bld.path.ant_glob("**/*.svg"): 49 bld( 50 rule='inkscape --export-area-drawing --export-png=${TGT[0].bldpath()} ${SRC[0].bldpath()}', 51 source=x, 52 target=x.change_ext('.png'), 53 ) 54 bld( 55 rule='inkscape --export-area-drawing --export-pdf=${TGT[0].bldpath()} ${SRC[0].bldpath()}', 56 source=x, 57 target=x.change_ext('.pdf'), 58 ) 59 60 bld( 61 target='generated.tex', 62 rule=lambda tsk: Utils.writef( tsk.outputs[0].abspath(), "Generated contents in %s" % tsk.outputs[0].name), 63 ) 64 65 bld( 66 features='rst', 67 type='rst2latex', 68 target='test2.tex', 69 source='test2.rst', 70 ) 71 72 bld( 73 features='tex', 74 source='test2.tex', 75 ) 76