forked from deepvision/libdispatch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·100 lines (87 loc) · 3.29 KB
/
configure
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
#!/usr/bin/env python
# encoding: utf-8
"""
%prog [options] [-- extra_cmake_args...]
Configure script for libdispatch-linux.
"""
import errno
import optparse
import os
import pipes
import subprocess
import sys
SOURCE_TREE = os.path.dirname(__file__)
def shelljoin(args):
return " ".join(pipes.quote(arg) for arg in args)
def main():
parser = optparse.OptionParser(usage=__doc__.strip())
parser.set_defaults(
prefix='/usr/local',
c_compiler=os.getenv('CC', 'clang'),
cxx_compiler=os.getenv('CXX', 'clang++'),
enable_test_suite=os.getenv('DISPATCH_ENABLE_TEST_SUITE', False),
build_type=os.getenv('DISPATCH_BUILD_TYPE', 'Release'),
cmake_generator='Unix Makefiles',
cmake_executable='cmake',
llvm_sanitizers=os.getenv('DISPATCH_SANITIZE', ''),
dry_run=False)
parser.add_option('--prefix')
parser.add_option('--cc',
dest='c_compiler',
metavar='COMPILER',
help='The C compiler to use')
parser.add_option('--c++',
dest='cxx_compiler',
metavar='COMPILER',
help='The C++ compiler to use')
parser.add_option('--enable-test-suite', action='store_true')
parser.add_option('--disable-test-suite',
dest='enable_test_suite',
action='store_false')
parser.add_option('--build-type', choices=["Debug", "Release"])
parser.add_option('--release',
dest='build_type',
action='store_const',
const='Release')
parser.add_option('--debug',
dest='build_type',
action='store_const',
const='Debug')
parser.add_option('-G',
'--cmake-generator',
help='The CMake build system generator to use.')
parser.add_option('--cmake', '--cmake-executable')
parser.add_option('--with-sanitizers', dest='llvm_sanitizers')
parser.add_option('-n',
'--dry-run',
help="Don't actually invoke CMake.",
action='store_true')
opts, args = parser.parse_args()
command_line = [
opts.cmake_executable,
SOURCE_TREE,
'-DCMAKE_BUILD_TYPE=%s' % opts.build_type,
'-G%s' % opts.cmake_generator,
'-DCMAKE_INSTALL_PREFIX=%s' % opts.prefix,
'-DCMAKE_C_COMPILER=%s' % opts.c_compiler,
'-DCMAKE_CXX_COMPILER=%s' % opts.cxx_compiler,
'-DDISPATCH_ENABLE_TEST_SUITE=%d' % int(opts.enable_test_suite),
'-DDISPATCH_SANITIZE=%s' % opts.llvm_sanitizers,
'--no-warn-unused-cli',
'--warn-uninitialized',
'-DCMAKE_EXPORT_COMPILE_COMMANDS=ON',
]
command_line.extend(args)
print >> sys.stderr, "Invoking CMake:"
print >> sys.stderr, shelljoin(command_line)
if not opts.dry_run:
try:
sys.exit(subprocess.call(command_line))
except OSError as e:
if e.errno == errno.ENOENT:
parser.error('No such executable %r' % opts.cmake_executable)
else:
parser.error('Could not launch executable %r' %
opts.cmake_executable)
if __name__ == '__main__':
main()