.. _model_config_build_lib: BUILD_LIB_FILE ============== .. contents:: :local: Each library will need to provide a ``buildlib`` to configure and build the library. Entry ----- The following is an exmple entry for ``BUILD_LIB_FILE`` in ``config_files.xml``. Each ``value`` corresponds to a library that can be built. The ``lib`` attribute is the name of the library and the ``value`` is the path to the buildlib script. .. code-block:: xml char $SRCROOT/share/build/buildlib.kokkos $SRCROOT/share/build/buildlib.gptl $CIMEROOT/CIME/build_scripts/buildlib.pio $SRCROOT/share/build/buildlib.spio $SRCROOT/share/build/buildlib.mct $SRCROOT/share/build/buildlib.csm_share $SRCROOT/share/build/buildlib.mpi-serial $CIMEROOT/CIME/build_scripts/buildlib.cprnc case_last env_case.xml path to buildlib script for the given library Build library -------------- Implementing a ``buildlib`` for a component is as simple as creating a python file and defining a single function; *buildlib*. Below are the arguments for the ``buildlib`` function. +-------------+------------------------------------------+ | Parameter | Description | +=============+==========================================+ | bldroot | The root directory to build the library. | +-------------+------------------------------------------+ | installpath | The directory to install the library. | +-------------+------------------------------------------+ | case | This is a CIME.case.case.Case object. | +-------------+------------------------------------------+ Use this function to setup, build the library and run any post-processing after the build. .. note:: It's best to start by copying a `buildlib` from another component for a stating point. Example ``````` .. code-block:: python import glob from CIME.utils import copyifnewer, run_bld_cmd_ensure_logging from CIME.build import get_standard_cmake_args def buildlib(bldroot, installpath, case): paths = glob.glob(...) for x in paths: copyifnewer(x, os.path.join(...)) libdir = os.path.join(...) cmake_args = get_standard_cmake_args(case, installpath) run_bld_cmd_ensure_logging(f"cmake {cmake_args}", logger, from_dir=libdir)