This repository has been archived by the owner on Oct 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbuild.py
54 lines (44 loc) · 1.7 KB
/
build.py
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
#!/usr/bin/env python
# Copyright (C) 2016 D Levin (http://www.kfrlib.com)
# This file is part of KFR
#
# KFR is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# KFR is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with KFR.
from __future__ import print_function
import os
import subprocess
import sys
path = os.path.dirname(os.path.realpath(__file__))
build_dir = os.path.join(path, 'build')
try:
os.makedirs(build_dir)
except:
pass
print('Checking clang...', end=' ')
if subprocess.call(['clang', '--version'], stdout=subprocess.PIPE):
raise Exception('clang is not on your PATH')
print('ok')
print('Checking clang++...', end=' ')
if subprocess.call(['clang++', '--version'], stdout=subprocess.PIPE):
raise Exception('clang++ is not on your PATH')
print('ok')
if sys.platform.startswith('win32'):
generator = 'MinGW Makefiles'
else:
generator = 'Unix Makefiles'
options = [
'-DCMAKE_BUILD_TYPE=Release',
]
if subprocess.call(['cmake', '-G', generator, '..'] + options, cwd=build_dir): raise Exception('Can\'t make project')
if subprocess.call(['cmake', '--build', '.', '--', '-j4'], cwd=build_dir): raise Exception('Can\'t build project')
if subprocess.call(['ctest'], cwd=os.path.join(build_dir, 'tests')): raise Exception('Can\'t test project')