forked from deepvision/libdispatch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigure
More file actions
executable file
·90 lines (75 loc) · 3 KB
/
configure
File metadata and controls
executable file
·90 lines (75 loc) · 3 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
#!/usr/bin/env python
# encoding: utf-8
import errno
import pipes
import os
import sys
import subprocess
HERE = os.path.dirname(__file__)
SOURCE_TREE = HERE
THIRD_PARTY = os.path.join(HERE, 'thirdparty')
sys.path.insert(1, os.path.join(THIRD_PARTY, 'click'))
import click
del sys.path[1]
def shelljoin(args):
return " ".join(pipes.quote(arg) for arg in args)
@click.command()
@click.pass_context
@click.option('--prefix', type=click.Path(), show_default=True,
default='/usr/local')
@click.option('--cc', 'c_compiler', default='clang', metavar='COMPILER',
envvar='CC', help='The C compiler to use')
@click.option('--c++', 'cxx_compiler', default='clang++', metavar='COMPILER',
envvar='CXX', help='The C++ compiler to use')
@click.option('--enable-test-suite/--disable-test-suite', default=False)
@click.option('--release', 'build_type', flag_value='Release')
@click.option('--debug', 'build_type', flag_value='Debug')
@click.option('--build-type', type=click.Choice(["Debug", "Release"]),
show_default=True, default='Release')
@click.option('-G', '--cmake-generator', default="Unix Makefiles",
show_default=True,
help='The CMake build system generator to use.')
@click.option('--cmake', '--cmake-executable', default='cmake',
type=click.Path(), show_default=True)
@click.option('-n', '--dry-run', help="Don't actually invoke CMake.",
is_flag=True)
@click.argument('extra-cmake-args', nargs=-1)
def configure(
ctx,
prefix,
build_type,
c_compiler,
cxx_compiler,
enable_test_suite,
cmake_generator,
cmake_executable,
dry_run,
extra_cmake_args):
"""Script for configuring libdispatch's build."""
command_line = []
command_line.extend([cmake_executable,
SOURCE_TREE,
'-DCMAKE_BUILD_TYPE={0}'.format(build_type),
'-G{0}'.format(cmake_generator)])
command_line.append('-DCMAKE_INSTALL_PREFIX={0}'.format(prefix))
command_line.append('-DCMAKE_C_COMPILER={0}'.format(c_compiler))
command_line.append('-DCMAKE_CXX_COMPILER={0}'.format(cxx_compiler))
command_line.append(
'-DDISPATCH_ENABLE_TEST_SUITE={0}'.format(int(enable_test_suite)))
command_line.append('--no-warn-unused-cli')
command_line.append('--warn-uninitialized')
command_line.append('-DCMAKE_EXPORT_COMPILE_COMMANDS=ON')
command_line.extend(extra_cmake_args)
click.secho("Invoking CMake:", fg='blue', bold=True, err=True)
click.echo(shelljoin(command_line), err=True)
if not dry_run:
try:
ctx.exit(subprocess.call(command_line))
except OSError as e:
if e.errno == errno.ENOENT:
ctx.fail("No such executable '{0}'".format(cmake_executable))
else:
ctx.fail("Could not launch executable '{0}'".format(
cmake_executable))
if __name__ == '__main__':
configure()