|
| 1 | +#!/usr/bin/env python3 |
| 2 | +{{ batchdirectives }} |
| 3 | + |
| 4 | +""" |
| 5 | +Batch script template for building the case when BATCHED_BUILD is TRUE. |
| 6 | +This script is submitted as a batch job by case.build and should not be |
| 7 | +run directly. |
| 8 | +
|
| 9 | +DO NOT RUN THIS SCRIPT MANUALLY |
| 10 | +Use ./case.build from the case directory instead. |
| 11 | +""" |
| 12 | + |
| 13 | +import os, sys |
| 14 | +os.chdir( '{{ caseroot }}') |
| 15 | + |
| 16 | +_LIBDIR = os.path.join("{{ cimeroot }}", "CIME", "Tools") |
| 17 | +sys.path.append(_LIBDIR) |
| 18 | + |
| 19 | +from standard_script_setup import * |
| 20 | + |
| 21 | +import CIME.build as build |
| 22 | +from CIME.case import Case |
| 23 | + |
| 24 | +logger = logging.getLogger(__name__) |
| 25 | + |
| 26 | +############################################################################### |
| 27 | +def _main_func(description): |
| 28 | +############################################################################### |
| 29 | + # Expand any additional args injected via ARGS_FOR_SCRIPT by the submitter. |
| 30 | + sys.argv.extend( |
| 31 | + [] if "ARGS_FOR_SCRIPT" not in os.environ |
| 32 | + else os.environ["ARGS_FOR_SCRIPT"].split() |
| 33 | + ) |
| 34 | + |
| 35 | + import argparse |
| 36 | + parser = argparse.ArgumentParser(description=description, prog=".case.build") |
| 37 | + CIME.utils.setup_standard_logging_options(parser) |
| 38 | + |
| 39 | + parser.add_argument("--caseroot", default=os.getcwd(), |
| 40 | + help="Case directory to build") |
| 41 | + parser.add_argument("--no-batch-build", action="store_true", |
| 42 | + help="Ignore, this is always True") |
| 43 | + parser.add_argument("--sharedlib-only", action="store_true", |
| 44 | + help="Only build shared libraries") |
| 45 | + parser.add_argument("--model-only", "-m", action="store_true", |
| 46 | + help="Assume shared libraries are already built") |
| 47 | + parser.add_argument("--separate-builds", action="store_true", |
| 48 | + help="Build each component separately") |
| 49 | + parser.add_argument("--ninja", action="store_true", |
| 50 | + help="Use ninja backend for CMake") |
| 51 | + parser.add_argument("--skip-provenance-check", action="store_true", |
| 52 | + help="Do not check and save build provenance") |
| 53 | + parser.add_argument("--build", nargs="+", dest="buildlist", |
| 54 | + help="Specific libraries/components to build") |
| 55 | + |
| 56 | + args = CIME.utils.parse_args_and_handle_standard_logging_options(args=sys.argv, parser=parser) |
| 57 | + |
| 58 | + if args.caseroot is not None: |
| 59 | + os.chdir(args.caseroot) |
| 60 | + caseroot = args.caseroot |
| 61 | + else: |
| 62 | + caseroot = os.getcwd() |
| 63 | + |
| 64 | + with Case(caseroot, read_only=False, record=True) as case: |
| 65 | + success = build.case_build( |
| 66 | + caseroot, |
| 67 | + case=case, |
| 68 | + sharedlib_only=args.sharedlib_only, |
| 69 | + model_only=args.model_only, |
| 70 | + buildlist=args.buildlist, |
| 71 | + save_build_provenance=not args.skip_provenance_check, |
| 72 | + separate_builds=args.separate_builds, |
| 73 | + ninja=args.ninja, |
| 74 | + batched_build_active=True, # This is a batch script |
| 75 | + ) |
| 76 | + |
| 77 | + sys.exit(0 if success else 1) |
| 78 | + |
| 79 | + |
| 80 | +if __name__ == "__main__": |
| 81 | + _main_func(__doc__) |
0 commit comments