-
Notifications
You must be signed in to change notification settings - Fork 383
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch mosart buildlib to python and cmake
- Loading branch information
Showing
1 changed file
with
54 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,64 @@ | ||
#! /usr/bin/env perl | ||
use strict; | ||
#!/usr/bin/env python | ||
|
||
if ($#ARGV == -1) { | ||
die " ERROR mosart.buildexe: must specify a caseroot input argument"; | ||
} | ||
my ($CASEROOT) = @ARGV; | ||
chdir "${CASEROOT}"; | ||
""" | ||
build mosart library | ||
""" | ||
import sys, os | ||
|
||
my $CASEBUILD = `./xmlquery CASEBUILD -value`; | ||
my $SRCROOT = `./xmlquery SRCROOT -value`; | ||
my $CASETOOLS = `./xmlquery CASETOOLS -value`; | ||
my $OBJROOT = `./xmlquery OBJROOT -value`; | ||
my $LIBROOT = `./xmlquery LIBROOT -value`; | ||
my $GMAKE_J = `./xmlquery GMAKE_J -value`; | ||
my $GMAKE = `./xmlquery GMAKE -value`; | ||
my $MAKE_ARGS = `./Tools/get_standard_makefile_args`; | ||
chomp($MAKE_ARGS); | ||
_CIMEROOT = os.environ.get("CIMEROOT") | ||
if _CIMEROOT is None: | ||
raise SystemExit("ERROR: must set CIMEROOT environment variable") | ||
|
||
chdir "${OBJROOT}/rof/obj"; | ||
_LIBDIR = os.path.join(_CIMEROOT, "scripts", "Tools") | ||
sys.path.append(_LIBDIR) | ||
|
||
open(file,">tmp_filepath") or die "ERROT: mosart.buildexe could not open file Filepath to write"; | ||
print file "$CASEROOT/SourceMods/src.mosart \n"; | ||
print file "$SRCROOT/components/mosart/src/riverroute \n"; | ||
print file "$SRCROOT/components/mosart/src/cpl \n"; | ||
print file "$SRCROOT/components/mosart/src/cpl_share \n"; | ||
close(file); | ||
from standard_script_setup import * | ||
from CIME.buildlib import parse_input | ||
from CIME.case import Case | ||
from CIME.utils import expect, run_bld_cmd_ensure_logging | ||
from CIME.build import get_standard_cmake_args | ||
|
||
if (-f "Filepath") { | ||
my $sysmod = "cmp -s tmp_filepath Filepath || mv -f tmp_filepath Filepath "; | ||
system($sysmod) == 0 or die "ERROR: mosart.buidexe $sysmod failed: $?\n"; | ||
} else { | ||
my $sysmod = "mv -f tmp_filepath Filepath "; | ||
system($sysmod) == 0 or die "ERROR: mosart.buidexe $sysmod failed: $?\n"; | ||
} | ||
logger = logging.getLogger(__name__) | ||
|
||
my $sysmod = "$GMAKE complib -j $GMAKE_J MODEL=mosart COMPLIB=$LIBROOT/librof.a -f $CASETOOLS/Makefile ${MAKE_ARGS}"; | ||
system($sysmod) == 0 or die "ERROR: mosart.buildexe $sysmod failed: $?\n"; | ||
############################################################################### | ||
def buildlib(bldroot, installpath, case): | ||
############################################################################### | ||
caseroot = case.get_value("CASEROOT") | ||
srcroot = case.get_value("SRCROOT") | ||
gmake_j = case.get_value("GMAKE_J") | ||
gmake = case.get_value("GMAKE") | ||
cmake_args = get_standard_cmake_args(case) | ||
|
||
exit(0); | ||
#------------------------------------------------------- | ||
# create Filepath in bldroot, unlike most other components, | ||
# mosart makes it's Filepath right here. | ||
#------------------------------------------------------- | ||
|
||
filepaths = \ | ||
"""{caseroot}/SourceMods/src.mosart | ||
{srcroot}/components/mosart/src/riverroute | ||
{srcroot}/components/mosart/src/cpl | ||
{srcroot}/components/mosart/src/cpl_share | ||
""".format(caseroot=caseroot, srcroot=srcroot) | ||
|
||
with open(os.path.join(bldroot, "Filepath"), "w") as fd: | ||
fd.write(filepaths) | ||
|
||
#------------------------------------------------------- | ||
# create the library in libroot | ||
#------------------------------------------------------- | ||
|
||
run_bld_cmd_ensure_logging('cmake -DMODEL=mosart -DCOMPLIB=rof {cmake_args} {srcroot}/components'.format(cmake_args=cmake_args, srcroot=srcroot), logger, from_dir=bldroot) | ||
run_bld_cmd_ensure_logging("{} -j {}".format(gmake, gmake_j), logger, from_dir=bldroot) | ||
|
||
############################################################################### | ||
def _main_func(): | ||
############################################################################### | ||
caseroot, libroot, bldroot = parse_input(sys.argv) | ||
with Case(caseroot, read_only=False) as case: | ||
buildlib(bldroot, libroot, case) | ||
|
||
############################################################################### | ||
|
||
if __name__ == "__main__": | ||
_main_func() |