wscript (2715B)
1 # vim: syntax=python 2 # 3 # needs waf created with 4 # python waf-light --tools=resx,satellite_assembly,wix 5 # 6 # Assumed situation: 7 # - Logic in C, which depends on an external device; some code is generated 8 # - Wrapper for C# 9 # - GUI in C# using C# Wrapper 10 # - GUI localization via satellite assemblies 11 # - Wrapper for Python 12 # 13 # Python libs required: bottle, cffi, pytest 14 # 15 # This project requires plenty of applications and libraries such as: 16 # gcc, mono-devel, pytest, cffi 17 # LD_LIBRARY_PATH=$PWD/../build/api/: PATH=$PATH:$LD_LIBRARY_PATH waf configure build test --stubs 18 # 19 20 21 from waflib import Utils 22 import sys, os, shutil 23 24 APPNAME = "funigui" 25 DLLNAME = "funi" 26 VERSION = "1.0" 27 28 COMPANY = "FuniCo" 29 MAXFUNI = 4 30 31 top = "." 32 out = "../build" 33 34 def options(ctx): 35 ctx.add_option("--stubs", action="store_true", default=False, help="Compile with stubs instead of using external device") 36 ctx.load('compiler_c compiler_cxx cs') 37 38 PYTEST = '' 39 def configure (ctx): 40 global PYTEST 41 try: 42 PYTEST = ctx.find_program('py.test')[0] 43 except: 44 PYTEST = ctx.find_program('py.test',path_list=[r'C:\Python35\Scripts']) [0] 45 46 if ctx.options.stubs: 47 print('!USING STUBS!') 48 ctx.env.append_value('DEFINES',['STUBS','DEBUG']) 49 else: 50 ctx.env.append_value('DEFINES',['NDEBUG']) 51 52 ctx.load('compiler_c compiler_cxx cs resx satellite_assembly') 53 if Utils.is_win32: 54 ctx.load('wix') 55 56 if ctx.env['CC_NAME'] == 'msvc': 57 if ctx.options.stubs: 58 ctx.env.append_value('CFLAGS',['/Z7','/EHsc','/W3']) 59 ctx.env.append_value('CXXFLAGS',['/Z7','/EHsc','/W3']) 60 else: 61 ctx.env.append_value('CFLAGS',['/Ox','/EHsc','/DNDEBUG','/W3']) 62 ctx.env.append_value('CXXFLAGS',['/Ox','/EHsc','/DNDEBUG','/W3']) 63 print(ctx.env['CC_NAME']) 64 else: 65 if ctx.options.stubs: 66 ctx.env.append_value('CFLAGS',['-g','-w']) 67 ctx.env.append_value('CXXFLAGS',['-g','-w']) 68 else: 69 ctx.env.append_value('CFLAGS',['-O2','-w']) 70 ctx.env.append_value('CXXFLAGS',['-O2','-w']) 71 ctx.env.guiname = APPNAME 72 ctx.env.version = VERSION 73 ctx.env.dllname = DLLNAME 74 ctx.env.maxfuni = MAXFUNI 75 ctx.env.company = COMPANY 76 ctx.load('print_commands') 77 78 def build(ctx): 79 ctx.load('build', tooldir='.') # additional stuff 80 ctx.recurse('api') 81 ctx.recurse('gui') 82 if Utils.is_win32: 83 ctx.recurse('msi') 84 85 def test(ctx): 86 if ctx.options.stubs: 87 cwd = ctx.path.find_node('../build/api').abspath() 88 print('running test in ',cwd) 89 ctx.cmd_and_log(os.path.join(cwd,'test_funi'),cwd=cwd) 90 ctx.cmd_and_log(PYTEST+' test_funi.py',cwd=cwd) 91