wscript (1930B)
1 #!/usr/bin/env python 2 # encoding: utf-8 3 # Thomas Nagy, 2010 4 5 from waflib import Logs 6 7 APPNAME = 'wafcython' 8 VERSION = '1.0' 9 10 top = '.' 11 out = 'build' 12 13 def options(ctx): 14 ctx.load('compiler_c') 15 ctx.load('compiler_cxx') 16 ctx.load('python') 17 ctx.load('cython') 18 ctx.load('cython_cache', tooldir='.') 19 20 def configure(ctx): 21 ctx.load('compiler_c') 22 ctx.load('compiler_cxx') 23 ctx.load('python') 24 ctx.check_python_headers() 25 try: 26 ctx.load('cython') 27 except ctx.errors.ConfigurationError: 28 Logs.warn('Cython was not found, using the cache') 29 30 def build(ctx): 31 # a C library 32 ctx(features = 'c cshlib', 33 source = 'c_lib/lib.c', 34 target = 'c_lib', 35 includes = 'c_lib') 36 37 # a C++ library 38 ctx(features = 'cxx cxxshlib', 39 source = 'cxx_lib/lib.cxx', 40 target = 'cxx_lib', 41 includes = 'cxx_lib') 42 43 # build a C-based cython extension 44 ctx( 45 features = 'c cshlib pyext', 46 source = 'src/cy_ctest.pyx', 47 target = 'cy_ctest', 48 includes = 'c_lib', 49 use = 'c_lib') 50 51 # then a C++-based one 52 ctx( 53 features = 'cxx cxxshlib pyext', 54 source = 'src/cy_cxxtest.pyx', 55 target = 'cy_cxxtest', 56 includes = 'cxx_lib', 57 use = 'cxx_lib') 58 59 # a C++ application which uses a C function from a cython module 60 ctx( 61 features = 'cxx cxxprogram pyembed', 62 source = 'cxx_lib/app.cxx', 63 target = 'cy-app', 64 includes = 'cxx_lib src', 65 use = 'cxx_lib') 66 67 # --------------------------------------------------------------- 68 # Testcase for #2244 below 69 70 ctx.get_tgen_by_name('cy_ctest').features += ' subst_header_order' 71 72 # a generated header for cy_ctest 73 ctx( 74 features = 'subst', 75 source = 'c_lib/extra_dep.h.in', 76 target = 'c_lib/extra_dep.h', 77 ) 78 79 from waflib import TaskGen 80 @TaskGen.feature('subst_header_order') 81 @TaskGen.after('process_source') 82 def set_subst_before_cython_tasks(self): 83 tg = self.bld.get_tgen_by_name('c_lib/extra_dep.h') 84 tg.post() 85 for tsk in self.tasks: 86 tsk.run_after.add(tg.tasks[-1])