|
@ -1,5 +1,6 @@ |
|
|
#!/usr/bin/env python |
|
|
#!/usr/bin/env python |
|
|
import os |
|
|
import os |
|
|
|
|
|
import multiprocessing |
|
|
import sys |
|
|
import sys |
|
|
import subprocess |
|
|
import subprocess |
|
|
import datetime |
|
|
import datetime |
|
@ -34,7 +35,9 @@ class CMakeExtension(Extension): |
|
|
|
|
|
|
|
|
class CMakeBuild(build_ext): |
|
|
class CMakeBuild(build_ext): |
|
|
user_options = build_ext.user_options + [ |
|
|
user_options = build_ext.user_options + [ |
|
|
('storm-dir=', None, 'Path to storm root (binary) location') |
|
|
|
|
|
|
|
|
('storm-dir=', None, 'Path to storm root (binary) location'), |
|
|
|
|
|
('jobs=', 'j', 'Number of jobs to use for compiling'), |
|
|
|
|
|
('debug', None, 'Build in Debug mode'), |
|
|
] |
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -61,13 +64,11 @@ class CMakeBuild(build_ext): |
|
|
spec = importlib.util.spec_from_file_location("genconfig", os.path.join(build_temp_version, 'generated/config.py')) |
|
|
spec = importlib.util.spec_from_file_location("genconfig", os.path.join(build_temp_version, 'generated/config.py')) |
|
|
self.conf = importlib.util.module_from_spec(spec) |
|
|
self.conf = importlib.util.module_from_spec(spec) |
|
|
spec.loader.exec_module(self.conf) |
|
|
spec.loader.exec_module(self.conf) |
|
|
print(self.conf.HAVE_STORM_DFT) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Check storm version |
|
|
storm_v_major, storm_v_minor, storm_v_patch = parse_storm_version(self.conf.STORM_VERSION) |
|
|
storm_v_major, storm_v_minor, storm_v_patch = parse_storm_version(self.conf.STORM_VERSION) |
|
|
check_storm_compatible(storm_v_major, storm_v_minor, storm_v_patch) |
|
|
check_storm_compatible(storm_v_major, storm_v_minor, storm_v_patch) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for ext in self.extensions: |
|
|
for ext in self.extensions: |
|
|
if ext.name == "core": |
|
|
if ext.name == "core": |
|
|
with open(os.path.join(self.extdir(ext.name), ext.subdir, "_config.py"), "w") as f: |
|
|
with open(os.path.join(self.extdir(ext.name), ext.subdir, "_config.py"), "w") as f: |
|
@ -110,11 +111,14 @@ class CMakeBuild(build_ext): |
|
|
self.build_extension(ext) |
|
|
self.build_extension(ext) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def initialize_options(self): |
|
|
def initialize_options(self): |
|
|
build_ext.initialize_options(self) |
|
|
build_ext.initialize_options(self) |
|
|
self.storm_dir = None |
|
|
self.storm_dir = None |
|
|
|
|
|
self.debug = False |
|
|
|
|
|
try: |
|
|
|
|
|
self.jobs = multiprocessing.cpu_count() if multiprocessing.cpu_count() is not None else 1 |
|
|
|
|
|
except NotImplementedError: |
|
|
|
|
|
self.jobs = 1 |
|
|
|
|
|
|
|
|
def finalize_options(self): |
|
|
def finalize_options(self): |
|
|
if self.storm_dir is not None: |
|
|
if self.storm_dir is not None: |
|
@ -123,15 +127,13 @@ class CMakeBuild(build_ext): |
|
|
|
|
|
|
|
|
def build_extension(self, ext): |
|
|
def build_extension(self, ext): |
|
|
extdir = self.extdir(ext.name) |
|
|
extdir = self.extdir(ext.name) |
|
|
print(extdir) |
|
|
|
|
|
cmake_args = ['-DSTORMPY_LIB_DIR=' + extdir, |
|
|
cmake_args = ['-DSTORMPY_LIB_DIR=' + extdir, |
|
|
'-DPYTHON_EXECUTABLE=' + sys.executable] |
|
|
'-DPYTHON_EXECUTABLE=' + sys.executable] |
|
|
|
|
|
|
|
|
cfg = 'Release' # if self.debug else 'Release' |
|
|
|
|
|
build_args = ['--config', cfg] |
|
|
|
|
|
|
|
|
|
|
|
cmake_args += ['-DCMAKE_BUILD_TYPE=' + cfg] |
|
|
|
|
|
build_args += ['--', '-j{}'.format(os.cpu_count() if os.cpu_count() is not None else 2)] |
|
|
|
|
|
|
|
|
build_type = 'Debug' if self.debug else 'Release' |
|
|
|
|
|
build_args = ['--config', build_type] |
|
|
|
|
|
build_args += ['--', '-j{}'.format(self.jobs)] |
|
|
|
|
|
cmake_args += ['-DCMAKE_BUILD_TYPE=' + build_type] |
|
|
if self.conf.STORM_DIR is not None: |
|
|
if self.conf.STORM_DIR is not None: |
|
|
cmake_args += ['-Dstorm_DIR=' + self.conf.STORM_DIR] |
|
|
cmake_args += ['-Dstorm_DIR=' + self.conf.STORM_DIR] |
|
|
if self.conf.HAVE_STORM_DFT: |
|
|
if self.conf.HAVE_STORM_DFT: |
|
@ -142,6 +144,8 @@ class CMakeBuild(build_ext): |
|
|
self.distribution.get_version()) |
|
|
self.distribution.get_version()) |
|
|
if not os.path.exists(self.build_temp): |
|
|
if not os.path.exists(self.build_temp): |
|
|
os.makedirs(self.build_temp) |
|
|
os.makedirs(self.build_temp) |
|
|
|
|
|
print("CMake args={}".format(cmake_args)) |
|
|
|
|
|
# Call cmake |
|
|
subprocess.check_call(['cmake', ext.sourcedir] + cmake_args, cwd=self.build_temp, env=env) |
|
|
subprocess.check_call(['cmake', ext.sourcedir] + cmake_args, cwd=self.build_temp, env=env) |
|
|
subprocess.check_call(['cmake', '--build', '.', '--target', ext.name] + build_args, cwd=self.build_temp) |
|
|
subprocess.check_call(['cmake', '--build', '.', '--target', ext.name] + build_args, cwd=self.build_temp) |
|
|
|
|
|
|
|
|