Skip to content

Commit 4e56419

Browse files
committed
Add support for cmd-line cmake params to control jigsaw build
1 parent e1a5679 commit 4e56419

File tree

1 file changed

+46
-6
lines changed

1 file changed

+46
-6
lines changed

build.py

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22
import os
33
import subprocess
44
import shutil
5+
import argparse
56

67
HERE = os.path.abspath(os.path.dirname(__file__))
78

8-
def build_external():
9+
def build_external(build_type="Release",
10+
netcdf_user_path=None,
11+
openmp_user_path=None
12+
):
913
#-- The actual cmake-based build steps for JIGSAW
1014

1115
cwd_pointer = os.getcwd()
@@ -41,17 +45,26 @@ def build_external():
4145
os.chdir(builds_path)
4246

4347
config_call = [
44-
"cmake",
45-
"..", "-DCMAKE_BUILD_TYPE=Release"]
48+
"cmake", "..",
49+
"-DCMAKE_BUILD_TYPE=" + build_type]
4650

51+
if (netcdf_user_path is not None):
52+
config_call+= [
53+
"-DNETCDF_USER_PATH="+netcdf_user_path]
54+
55+
if (openmp_user_path is not None):
56+
config_call+= [
57+
"-DOPENMP_USER_PATH="+openmp_user_path]
58+
59+
print(config_call)
4760
subprocess.run(config_call, check=True)
4861

4962
print("cmake compile for jigsaw...")
5063

5164
try:
5265
compilecall = [
5366
"cmake", "--build", ".",
54-
"--config", "Release",
67+
"--config", build_type,
5568
"--target", "install",
5669
"--parallel", "4"
5770
]
@@ -61,7 +74,7 @@ def build_external():
6174
except:
6275
compilecall = [
6376
"cmake", "--build", ".",
64-
"--config", "Release",
77+
"--config", build_type,
6578
"--target", "install"
6679
]
6780
subprocess.run(
@@ -78,5 +91,32 @@ def build_external():
7891
shutil.rmtree(builds_path)
7992

8093

81-
if (__name__ == "__main__"): build_external()
94+
if (__name__ == "__main__"):
95+
parser = argparse.ArgumentParser(
96+
description=__doc__,
97+
formatter_class=argparse.RawTextHelpFormatter)
98+
99+
parser.add_argument(
100+
"--cmake-build-type", dest="cmake_build_type",
101+
required=False,
102+
type=str, default="Release",
103+
help="Build JIGSAW in {Release}, Debug mode.")
104+
105+
parser.add_argument(
106+
"--netcdf-user-path", dest="netcdf_user_path",
107+
required=False,
108+
type=str, default=None,
109+
help="(Optional) dir. containing netcdf lib.")
110+
111+
parser.add_argument(
112+
"--openmp-user-path", dest="openmp_user_path",
113+
required=False,
114+
type=str, default=None,
115+
help="(Optional) dir. containing openmp lib.")
116+
117+
args = parser.parse_args()
118+
119+
build_external(args.cmake_build_type,
120+
args.netcdf_user_path,
121+
args.openmp_user_path)
82122

0 commit comments

Comments
 (0)