2018-01-26 16:01:20 -06:00
|
|
|
import os
|
|
|
|
|
import shutil
|
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
|
|
|
2025-03-05 22:45:27 +01:00
|
|
|
def install(omp=False, mpi=False, phdf5=False, dagmc=False, libmesh=False):
|
2018-01-26 16:01:20 -06:00
|
|
|
# Create build directory and change to it
|
|
|
|
|
shutil.rmtree('build', ignore_errors=True)
|
|
|
|
|
os.mkdir('build')
|
|
|
|
|
os.chdir('build')
|
|
|
|
|
|
2026-02-25 17:12:18 -06:00
|
|
|
# Build in RelWithDebInfo mode by default with support for MCPL
|
|
|
|
|
cmake_cmd = ['cmake', '-DCMAKE_BUILD_TYPE=RelWithDebInfo', '-DOPENMC_USE_MCPL=on']
|
2018-01-26 16:01:20 -06:00
|
|
|
|
|
|
|
|
# Turn off OpenMP if specified
|
|
|
|
|
if not omp:
|
2022-03-22 10:46:34 -05:00
|
|
|
cmake_cmd.append('-DOPENMC_USE_OPENMP=off')
|
2018-01-26 16:01:20 -06:00
|
|
|
|
2018-02-05 08:09:47 -06:00
|
|
|
# Use MPI wrappers when building in parallel
|
2018-01-26 16:01:20 -06:00
|
|
|
if mpi:
|
2022-04-05 15:56:10 -05:00
|
|
|
cmake_cmd.append('-DOPENMC_USE_MPI=on')
|
2018-01-26 16:01:20 -06:00
|
|
|
|
|
|
|
|
# Tell CMake to prefer parallel HDF5 if specified
|
|
|
|
|
if phdf5:
|
|
|
|
|
if not mpi:
|
|
|
|
|
raise ValueError('Parallel HDF5 must be used in '
|
|
|
|
|
'conjunction with MPI.')
|
2018-01-29 15:26:29 -06:00
|
|
|
cmake_cmd.append('-DHDF5_PREFER_PARALLEL=ON')
|
|
|
|
|
else:
|
|
|
|
|
cmake_cmd.append('-DHDF5_PREFER_PARALLEL=OFF')
|
2018-01-26 16:01:20 -06:00
|
|
|
|
2018-09-21 16:22:54 -04:00
|
|
|
if dagmc:
|
2022-03-22 10:46:34 -05:00
|
|
|
cmake_cmd.append('-DOPENMC_USE_DAGMC=ON')
|
2025-01-07 17:31:25 -06:00
|
|
|
cmake_cmd.append('-DOPENMC_USE_UWUW=ON')
|
2024-10-10 22:05:32 +06:00
|
|
|
dagmc_path = os.environ.get('HOME') + '/DAGMC'
|
|
|
|
|
cmake_cmd.append('-DCMAKE_PREFIX_PATH=' + dagmc_path)
|
2019-02-21 22:03:17 -06:00
|
|
|
|
2020-05-20 21:04:01 -05:00
|
|
|
if libmesh:
|
2022-03-22 10:46:34 -05:00
|
|
|
cmake_cmd.append('-DOPENMC_USE_LIBMESH=ON')
|
2021-01-20 18:15:30 -06:00
|
|
|
libmesh_path = os.environ.get('HOME') + '/LIBMESH'
|
2020-12-23 12:20:45 -06:00
|
|
|
cmake_cmd.append('-DCMAKE_PREFIX_PATH=' + libmesh_path)
|
2020-05-20 21:04:01 -05:00
|
|
|
|
2019-05-20 14:26:15 -04:00
|
|
|
# Build in coverage mode for coverage testing
|
2022-03-22 10:46:34 -05:00
|
|
|
cmake_cmd.append('-DOPENMC_ENABLE_COVERAGE=on')
|
2019-05-20 14:26:15 -04:00
|
|
|
|
2026-02-25 17:12:18 -06:00
|
|
|
# Enable strict FP for cross-platform reproducibility in CI
|
|
|
|
|
cmake_cmd.append('-DOPENMC_ENABLE_STRICT_FP=on')
|
|
|
|
|
|
2018-01-26 16:01:20 -06:00
|
|
|
# Build and install
|
|
|
|
|
cmake_cmd.append('..')
|
2019-12-06 10:25:54 -06:00
|
|
|
print(' '.join(cmake_cmd))
|
2018-01-29 16:30:57 -06:00
|
|
|
subprocess.check_call(cmake_cmd)
|
2018-10-02 21:27:00 -05:00
|
|
|
subprocess.check_call(['make', '-j4'])
|
2018-01-29 16:30:57 -06:00
|
|
|
subprocess.check_call(['sudo', 'make', 'install'])
|
2018-01-26 16:01:20 -06:00
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
# Convert Travis matrix environment variables into arguments for install()
|
|
|
|
|
omp = (os.environ.get('OMP') == 'y')
|
|
|
|
|
mpi = (os.environ.get('MPI') == 'y')
|
|
|
|
|
phdf5 = (os.environ.get('PHDF5') == 'y')
|
2018-09-21 16:22:54 -04:00
|
|
|
dagmc = (os.environ.get('DAGMC') == 'y')
|
2020-05-20 21:04:01 -05:00
|
|
|
libmesh = (os.environ.get('LIBMESH') == 'y')
|
2018-07-06 11:01:35 -05:00
|
|
|
|
2018-01-26 16:01:20 -06:00
|
|
|
# Build and install
|
2025-03-05 22:45:27 +01:00
|
|
|
install(omp, mpi, phdf5, dagmc, libmesh)
|
2018-01-26 16:01:20 -06:00
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
main()
|