Source code for spack.build_systems.scons

# Copyright Spack Project Developers. See COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import spack.builder
import spack.package_base
import spack.phase_callbacks
import spack.spec
import spack.util.prefix
from spack.directives import build_system, depends_on

from ._checks import BuilderWithDefaults, execute_build_time_tests


[docs] class SConsPackage(spack.package_base.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 legacy_buildsystem = "scons" build_system("scons") depends_on("scons", type="build", when="build_system=scons")
[docs] @spack.builder.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 legacy_methods = ("build_test",) #: Same as legacy_methods, but the signature is different legacy_long_methods = ("build_args", "install_args") #: Names associated with package attributes in the old build-system format legacy_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: spack.spec.Spec, prefix: spack.util.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: spack.spec.Spec, prefix: spack.util.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
spack.phase_callbacks.run_after("build")(execute_build_time_tests)