-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwscript
More file actions
110 lines (82 loc) · 2.92 KB
/
wscript
File metadata and controls
110 lines (82 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#! /usr/bin/env python
# encoding: utf-8
from waflib.Build import BuildContext
APPNAME = 'YaFFT'
VERSION = '0.1'
top = '.'
out = 'build'
def options(opt):
opt.add_option('--variant',
action='store',
choices=['debug', 'release'],
default='debug',
help='build variant (debug/release) [default: debug]')
opt.add_option('--test',
action='store_true',
help='build tests')
opt.add_option('--example',
action='store_true',
help='build examples')
opt.load('compiler_c')
opt.load('python')
def configure(conf):
print('Configuring YaFFT in ' + conf.path.abspath())
conf.env.TEST = conf.options.test
# Debug variant
conf.setenv('debug')
conf.load('compiler_c')
conf.load('python')
conf.load('swig')
conf.env.CFLAGS = ['-g', '-O0', '-Wall', '-std=c99']
conf.env.TEST = conf.options.test
conf.env.EXAMPLE = conf.options.example
conf.check_python_headers()
conf.check_python_version((2, 5, 0))
if conf.check_swig_version() < (3, 0, 0):
conf.fatal('Swig version must be >= 3.0.0')
conf.write_config_header('debug/config.h', remove=False)
# Release variant
conf.setenv('release', env=conf.env.derive()) # start with a copy
conf.env.CFLAGS = ['-O2', '-Wall', '-std=c99']
conf.write_config_header('release/config.h')
def build(bld):
if not bld.variant:
bld.fatal('Build variant not specified')
print('Build variant: ' + bld.variant)
source_files = [x for x in bld.path.ant_glob('src/**/*.c')]
# Shared library
bld.shlib(source=source_files[:],
target='yafft',
includes='src')
# SWIG interface for tests
if bld.env.TEST:
source_files.append('swig/yafft.i')
bld.shlib(features='pyext',
source=source_files[:],
target='_yafft',
swig_flags='-python -Wall',
includes='. src')
# Program for examples
if bld.env.EXAMPLE:
bld.program(source='example/sine.c',
target='example/sine',
use='yafft',
includes='src',
lib='m')
def init(ctx):
from waflib.Options import options
from waflib.Build import BuildContext, CleanContext, InstallContext, UninstallContext
from waflib.Configure import ConfigurationContext
for y in (BuildContext, CleanContext, InstallContext, UninstallContext, ConfigurationContext):
name = y.__name__.replace('Context', '').lower()
class tmp(y):
cmd = name
variant = options.variant
def test(ctx):
if not ctx.env.TEST:
ctx.fatal('Test flag not specified during configuration')
from test import test_suite
test_suite.run()
class TestSubclass(BuildContext):
cmd = 'test'
fun = 'test'