-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild
More file actions
executable file
·37 lines (31 loc) · 1.13 KB
/
build
File metadata and controls
executable file
·37 lines (31 loc) · 1.13 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
#!/usr/bin/env python3
import shutil
import pathlib
import argparse
import subprocess
def main():
parser = argparse.ArgumentParser()
parser.add_argument('-r', '--release', action='store_true', help='Make release build')
parser.add_argument('-c', '--config', action='store_true', help='Force config step')
parser.add_argument('-t', '--target', help='Target to build')
args = parser.parse_args()
build = 'Release' if args.release else 'Debug'
cmake = shutil.which('cmake')
assert isinstance(cmake, str)
build_dir = pathlib.Path('build-dir') / build
if not (build_dir / 'build.ninja').exists() or args.config:
subprocess.run([
cmake, '-S', '.', '-B', build_dir,
f'-DCMAKE_BUILD_TYPE={build}',
'-DCMAKE_C_COMPILER=clang',
'-DCMAKE_CXX_COMPILER=clang++',
'-DCMAKE_EXPORT_COMPILE_COMMANDS=YES',
'-G', 'Ninja'])
shutil.copy(build_dir / 'compile_commands.json', pathlib.Path.cwd())
command = [cmake, '--build', build_dir, '--config', build]
if args.target is not None:
command += ['--target', args.target]
print(command)
subprocess.run(command)
if __name__ == '__main__':
main()