Skip to content

Commit

Permalink
Merge branch 'jgfouca/cime/case_build_use_old' into next (PR #3043)
Browse files Browse the repository at this point in the history
Switch E3SM build system to CMake!

Merge three for this PR.

[BFB]

* jgfouca/cime/case_build_use_old:
  Switch back to gmake as default backend
  • Loading branch information
jgfouca committed Nov 16, 2019
2 parents fdc88c1 + 5f73364 commit 6e50f94
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 24 deletions.
23 changes: 10 additions & 13 deletions cime/scripts/Tools/case.build
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@ def parse_command_line(args, description):
parser.add_argument("--use-old", action="store_true",
help="Use old Makefile build system (not cmake)")

parser.add_argument("--use-gmake", action="store_true",
help="Use gmake backed for CMake (instead of ninja). "
"The gmake backend does not always correctly scan fortran dependencies")
parser.add_argument("--ninja", action="store_true",
help="Use ninja backed for CMake (instead of gmake). "
"The ninja backend is better at scanning fortran dependencies but "
"seems to be less reliable across different platforms and compilers.")

parser.add_argument("--dry-run", action="store_true",
help="Just print the cmake and ninja commands.")
Expand Down Expand Up @@ -118,25 +119,21 @@ def parse_command_line(args, description):
buildlist = None if args.build is None or len(args.build) == 0 else args.build

if get_model() != "e3sm":
args.use_old = False
args.use_gmake = False
args.use_old = False
args.ninja = False

return args.caseroot, args.sharedlib_only, args.model_only, cleanlist, args.clean_all, buildlist, clean_depends, not args.skip_provenance_check, args.use_old, args.use_gmake, args.dry_run
return args.caseroot, args.sharedlib_only, args.model_only, cleanlist, args.clean_all, buildlist, clean_depends, not args.skip_provenance_check, args.use_old, args.ninja, args.dry_run

###############################################################################
def _main_func(description):
###############################################################################
caseroot, sharedlib_only, model_only, cleanlist, clean_all, buildlist,clean_depends, save_build_provenance, use_old, use_gmake, dry_run = \
caseroot, sharedlib_only, model_only, cleanlist, clean_all, buildlist,clean_depends, save_build_provenance, use_old, ninja, dry_run = \
parse_command_line(sys.argv, description)

success = True
with Case(caseroot, read_only=False) as case:
testname = case.get_value('TESTCASE')

if get_model() == "e3sm" and case.get_value("COMPILER") == "pgi" and not use_gmake:
logging.warning("ninja CMake backend does not work with pgi, switching to gmake backend")
use_gmake = True

if cleanlist is not None or clean_all or clean_depends is not None:
build.clean(case, cleanlist=cleanlist, clean_all=clean_all, clean_depends=clean_depends)
elif(testname is not None):
Expand All @@ -155,12 +152,12 @@ def _main_func(description):
raise

expect(buildlist is None, "Build lists don't work with tests")
success = test.build(sharedlib_only=sharedlib_only, model_only=model_only, old_build=use_old, use_gmake=use_gmake, dry_run=dry_run)
success = test.build(sharedlib_only=sharedlib_only, model_only=model_only, old_build=use_old, ninja=ninja, dry_run=dry_run)
else:
success = build.case_build(caseroot, case=case, sharedlib_only=sharedlib_only,
model_only=model_only, buildlist=buildlist,
save_build_provenance=save_build_provenance,
use_old=use_old, use_gmake=use_gmake, dry_run=dry_run)
use_old=use_old, ninja=ninja, dry_run=dry_run)

sys.exit(0 if success else 1)

Expand Down
8 changes: 4 additions & 4 deletions cime/scripts/lib/CIME/SystemTests/system_tests_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(self, case, expected=None):
self._skip_pnl = False
self._cpllog = "med" if self._case.get_value("COMP_INTERFACE")=="nuopc" else "cpl"
self._old_build = False
self._use_gmake = False
self._ninja = False
self._dry_run = False

def _init_environment(self, caseroot):
Expand Down Expand Up @@ -69,15 +69,15 @@ def _resetup_case(self, phase, reset=False):

self._case.case_setup(reset=True, test_mode=True)

def build(self, sharedlib_only=False, model_only=False, old_build=False, use_gmake=False, dry_run=False):
def build(self, sharedlib_only=False, model_only=False, old_build=False, ninja=False, dry_run=False):
"""
Do NOT override this method, this method is the framework that
controls the build phase. build_phase is the extension point
that subclasses should use.
"""
success = True
self._old_build = old_build
self._use_gmake = use_gmake
self._ninja = ninja
self._dry_run = dry_run
for phase_name, phase_bool in [(SHAREDLIB_BUILD_PHASE, not model_only),
(MODEL_BUILD_PHASE, not sharedlib_only)]:
Expand Down Expand Up @@ -127,7 +127,7 @@ def build_indv(self, sharedlib_only=False, model_only=False):
build.case_build(self._caseroot, case=self._case,
sharedlib_only=sharedlib_only, model_only=model_only,
save_build_provenance=not model=='cesm',
use_old=self._old_build, use_gmake=self._use_gmake, dry_run=self._dry_run)
use_old=self._old_build, ninja=self._ninja, dry_run=self._dry_run)

def clean_build(self, comps=None):
if comps is None:
Expand Down
14 changes: 7 additions & 7 deletions cime/scripts/lib/CIME/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def _build_model(build_threaded, exeroot, incroot, complist,

###############################################################################
def _build_model_cmake(exeroot, complist, lid, cimeroot, buildlist,
comp_interface, sharedpath, use_gmake, dry_run, case):
comp_interface, sharedpath, ninja, dry_run, case):
###############################################################################
cime_model = get_model()
bldroot = os.path.join(exeroot, "cmake-bld")
Expand Down Expand Up @@ -183,7 +183,7 @@ def _build_model_cmake(exeroot, complist, lid, cimeroot, buildlist,
cmake_args = get_standard_cmake_args(case, sharedpath)
cmake_env = ""
ninja_path = os.path.join(srcroot, "externals/ninja/bin")
if not use_gmake:
if ninja:
cmake_args += " -GNinja "
cmake_env += "PATH={}:$PATH ".format(ninja_path)

Expand All @@ -201,7 +201,7 @@ def _build_model_cmake(exeroot, complist, lid, cimeroot, buildlist,

# Call Make
if stat == 0:
make_cmd = "{} -j {}".format(gmake if use_gmake else "{} -v".format(os.path.join(ninja_path, "ninja")), gmake_j)
make_cmd = "{} -j {}".format(gmake if not ninja else "{} -v".format(os.path.join(ninja_path, "ninja")), gmake_j)
if dry_run:
logger.info("Build cmd:\ncd {} && {}\n\n".format(bldroot, make_cmd))
expect(False, "User requested dry-run only, terminating build")
Expand Down Expand Up @@ -482,7 +482,7 @@ def _clean_impl(case, cleanlist, clean_all, clean_depends):

###############################################################################
def _case_build_impl(caseroot, case, sharedlib_only, model_only, buildlist,
save_build_provenance, use_old, use_gmake, dry_run):
save_build_provenance, use_old, ninja, dry_run):
###############################################################################

t1 = time.time()
Expand Down Expand Up @@ -607,7 +607,7 @@ def _case_build_impl(caseroot, case, sharedlib_only, model_only, buildlist,
if not sharedlib_only:
if get_model() == "e3sm" and not use_old:
logs.extend(_build_model_cmake(exeroot, complist, lid, cimeroot, buildlist,
comp_interface, sharedpath, use_gmake, dry_run, case))
comp_interface, sharedpath, ninja, dry_run, case))
else:
os.environ["INSTALL_SHAREDPATH"] = os.path.join(exeroot, sharedpath) # for MPAS makefile generators
logs.extend(_build_model(build_threaded, exeroot, incroot, complist,
Expand Down Expand Up @@ -652,10 +652,10 @@ def post_build(case, logs, build_complete=False, save_build_provenance=True):
lock_file("env_build.xml", caseroot=case.get_value("CASEROOT"))

###############################################################################
def case_build(caseroot, case, sharedlib_only=False, model_only=False, buildlist=None, save_build_provenance=True, use_old=False, use_gmake=False, dry_run=False):
def case_build(caseroot, case, sharedlib_only=False, model_only=False, buildlist=None, save_build_provenance=True, use_old=False, ninja=False, dry_run=False):
###############################################################################
functor = lambda: _case_build_impl(caseroot, case, sharedlib_only, model_only, buildlist,
save_build_provenance, use_old, use_gmake, dry_run)
save_build_provenance, use_old, ninja, dry_run)
return run_and_log_case_status(functor, "case.build", caseroot=caseroot)

###############################################################################
Expand Down

0 comments on commit 6e50f94

Please sign in to comment.