diff --git a/cime/scripts/Tools/case.build b/cime/scripts/Tools/case.build index 0c2702c02a04..6d7a55fd6604 100755 --- a/cime/scripts/Tools/case.build +++ b/cime/scripts/Tools/case.build @@ -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.") @@ -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): @@ -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) diff --git a/cime/scripts/lib/CIME/SystemTests/system_tests_common.py b/cime/scripts/lib/CIME/SystemTests/system_tests_common.py index 2f107e97de55..bc16819d1e59 100644 --- a/cime/scripts/lib/CIME/SystemTests/system_tests_common.py +++ b/cime/scripts/lib/CIME/SystemTests/system_tests_common.py @@ -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): @@ -69,7 +69,7 @@ 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 @@ -77,7 +77,7 @@ def build(self, sharedlib_only=False, model_only=False, old_build=False, use_gma """ 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)]: @@ -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: diff --git a/cime/scripts/lib/CIME/build.py b/cime/scripts/lib/CIME/build.py index c7ef7f2cb3c2..04229c8ff1f0 100644 --- a/cime/scripts/lib/CIME/build.py +++ b/cime/scripts/lib/CIME/build.py @@ -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") @@ -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) @@ -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") @@ -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() @@ -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, @@ -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) ###############################################################################