forked from HdrHistogram/HdrHistogram
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SConstruct
60 lines (48 loc) · 2.2 KB
/
SConstruct
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
# SConstruct
# Written by Michael Barker and released to the public domain,
# as explained at http://creativecommons.org/publicdomain/zero/1.0/
import os
import xml.etree.ElementTree as ET
version = ET.parse('pom.xml').getroot().findtext('{http://maven.apache.org/POM/4.0.0}version')
version_directory = 'target/c/hdr_histogram-' + version
lib_directory = version_directory + '/lib/'
bin_directory = version_directory + '/bin/'
src_directory = version_directory + '/src/'
test_directory = version_directory + '/test/'
example_directory = version_directory + '/examples'
include_directory = version_directory + '/include/'
debug = ARGUMENTS.get('debug', 0)
optimise = ARGUMENTS.get('optimise', 2)
cc = ARGUMENTS.get('cc', 'clang')
env = Environment()
env['ENV']['PATH'] = os.environ['PATH']
env['CC'] = cc
env['CPATH'] = []
env['CFLAGS'] = ['-std=c99', '-Wall']
if cc == 'clang':
env.Append(CFLAGS = ['-fcolor-diagnostics', '-fdiagnostics-show-option'])
if int(optimise) != 0:
env.Append(CFLAGS = '-O' + str(optimise))
if int(debug):
env.Append(CFLAGS = '-g')
bin = env.Clone()
bin.Append(CPPDEFINES = '_BSD_SOURCE')
static_library = bin.StaticLibrary(lib_directory + 'hdr_histogram', Glob('src/main/c/*.c'))
tst = env.Clone()
tst['CPPPATH'] = ['src/main/c']
tst['LIBS'] = ['hdr_histogram.a', 'm', 'z']
tst['LIBPATH'] = [lib_directory]
tst.Program(bin_directory + 'alltests', Glob('src/test/c/*_test.c'))
os_libs = {'darwin': [], 'posix': ['rt']}
prf = tst.Clone();
prf['LIBS'] = prf['LIBS'] + os_libs[env['PLATFORM']]
prf.Append(CPPDEFINES = '_POSIX_C_SOURCE=199309L')
prf.Program(bin_directory + 'perftests', Glob('src/test/c/*_perf.c'))
exp = tst.Clone()
exp.Program(bin_directory + 'format_example', ['src/examples/c/hdr_histogram_format_example.c'])
env.Install(include_directory, Glob('src/main/c/*.h'))
env.Install(src_directory, Glob('src/main/c/*.c') + Glob('src/main/c/*.h'))
env.Install(test_directory, Glob('src/test/c/*.c') + Glob('src/test/c/*.h'))
env.Install(example_directory, Glob('src/examples/c/*.c') + Glob('src/examples/c/*.h'))
env.Tar('target/c/hdr_histogram-' + version + '.tar.gz', Dir('hdr_histogram-' + version),
TARFLAGS = ['-c', '-z', '-Ctarget/c'])