forked from Emerge-Lab/gpudrive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.py
28 lines (22 loc) · 884 Bytes
/
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
import subprocess
import os
import sys
import logging
import shutil
logging.basicConfig(level=logging.INFO)
def main():
# Cloning the repository, although typically you would not do this in the build step
# as the code should already be present. Including it just for completeness.
subprocess.check_call(['git', 'submodule', 'update', '--init', '--recursive', '--force'])
# Create and enter the build directory
if not os.path.exists('build'):
os.mkdir('build')
os.chdir('build')
# Run CMake and Make
subprocess.check_call(['cmake', '..', '-DCMAKE_BUILD_TYPE=Release'])
subprocess.check_call(['make', f"-j{os.cpu_count()}"]) # Utilize all available cores
# Going back to the root directory
os.chdir('..')
if __name__ == '__main__':
logging.info("Building the C++ code and installing the Python package")
main()