-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathbuildlib
More file actions
executable file
·69 lines (53 loc) · 2.54 KB
/
buildlib
File metadata and controls
executable file
·69 lines (53 loc) · 2.54 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env python3
"""
build mizuRoute library
"""
import sys, os
_CIMEROOT = os.environ.get("CIMEROOT")
if _CIMEROOT is None:
raise SystemExit("ERROR: must set CIMEROOT environment variable")
_LIBDIR = os.path.join(_CIMEROOT, "scripts", "Tools")
sys.path.append(_LIBDIR)
from standard_script_setup import *
from CIME.buildlib import parse_input
from CIME.build import get_standard_makefile_args
from CIME.case import Case
from CIME.utils import run_cmd, expect
logger = logging.getLogger(__name__)
###############################################################################
def _main_func():
###############################################################################
caseroot, libroot, bldroot = parse_input(sys.argv)
with Case(caseroot) as case:
casetools = case.get_value("CASETOOLS")
rof_root = case.get_value("COMP_ROOT_DIR_ROF")
gmake_j = case.get_value("GMAKE_J")
gmake = case.get_value("GMAKE")
driver = case.get_value("COMP_INTERFACE").lower()
expect( driver == "nuopc", "mizuRoute only has a nuopc COMP_INTERFACE" )
#-------------------------------------------------------
# create Filepath file
#-------------------------------------------------------
filepath_file = os.path.join(bldroot,"Filepath")
if not os.path.isfile(filepath_file):
caseroot = case.get_value("CASEROOT")
paths = [os.path.join(caseroot,"SourceMods","src.mizuroute"),
os.path.join(rof_root,"route","build","src"),
os.path.join(rof_root,"route","build","cpl"),
os.path.join(rof_root,"route","build","cpl",driver)]
with open(filepath_file, "w") as filepath:
filepath.write("\n".join(paths))
filepath.write("\n")
#-------------------------------------------------------
# create the library in libroot
#-------------------------------------------------------
complib = os.path.join(libroot,"librof.a")
makefile = os.path.join(casetools, "Makefile")
cmd = "{} complib -j {} COMP_NAME=mizuRoute COMPLIB={} -f {} {}" \
.format(gmake, gmake_j, complib, makefile, get_standard_makefile_args(case))
rc, out, err = run_cmd(cmd)
logger.info("%s: \n\n output:\n %s \n\n err:\n\n%s\n"%(cmd,out,err))
expect(rc == 0, "Command %s failed with rc=%s" % (cmd, rc))
###############################################################################
if __name__ == "__main__":
_main_func()