Source code for spack_repo.builtin.build_systems.scons

# Copyright Spack Project Developers. See COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack.package import (
    BuilderWithDefaults,
    PackageBase,
    Prefix,
    Spec,
    build_system,
    depends_on,
    register_builder,
    run_after,
)

from ._checks import execute_build_time_tests


[docs] class SConsPackage(PackageBase): """Specialized class for packages built using SCons. See http://scons.org/documentation.html for more information. """ #: To be used in UI queries that require to know which #: build-system class we are using build_system_class = "SConsPackage" #: Legacy buildsystem attribute used to deserialize and install old specs default_buildsystem = "scons" build_system("scons") depends_on("scons", type="build", when="build_system=scons")
[docs] @register_builder("scons") class SConsBuilder(BuilderWithDefaults): """The Scons builder provides the following phases that can be overridden: 1. :py:meth:`~.SConsBuilder.build` 2. :py:meth:`~.SConsBuilder.install` Packages that use SCons as a build system are less uniform than packages that use other build systems. Developers can add custom subcommands or variables that control the build. You will likely need to override :py:meth:`~.SConsBuilder.build_args` to pass the appropriate variables. """ #: Phases of a SCons package phases = ("build", "install") #: Names associated with package methods in the old build-system format package_methods = ("build_test",) #: Same as package_methods, but the signature is different package_long_methods = ("build_args", "install_args") #: Names associated with package attributes in the old build-system format package_attributes = ("build_time_test_callbacks",) #: Callback names for build-time test build_time_test_callbacks = ["build_test"]
[docs] def build_args(self, spec, prefix): """Arguments to pass to build.""" return []
[docs] def build(self, pkg: SConsPackage, spec: Spec, prefix: Prefix) -> None: """Build the package.""" pkg.module.scons(*self.build_args(spec, prefix))
[docs] def install_args(self, spec, prefix): """Arguments to pass to install.""" return []
[docs] def install(self, pkg: SConsPackage, spec: Spec, prefix: Prefix) -> None: """Install the package.""" pkg.module.scons("install", *self.install_args(spec, prefix))
[docs] def build_test(self): """Run unit tests after build. By default, does nothing. Override this if you want to add package-specific tests. """ pass
run_after("build")(execute_build_time_tests)