Skip to content

Commit 30c9ff5

Browse files
authored
Allow for packages with multiple build-systems (#30738)
This commit extends the DSL that can be used in packages to allow declaring that a package uses different build-systems under different conditions. It requires each spec to have a `build_system` single valued variant. The variant can be used in many context to query, manipulate or select the build system associated with a concrete spec. The knowledge to build a package has been moved out of the PackageBase hierarchy, into a new Builder hierarchy. Customization of the default behavior for a given builder can be obtained by coding a new derived builder in package.py. The "run_after" and "run_before" decorators are now applied to methods on the builder. They can also incorporate a "when=" argument to specify that a method is run only when certain conditions apply. For packages that do not define their own builder, forwarding logic is added between the builder and package (methods not found in one will be retrieved from the other); this PR is expected to be fully backwards compatible with unmodified packages that use a single build system.
1 parent 83ee500 commit 30c9ff5

File tree

155 files changed

+7465
-3573
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

155 files changed

+7465
-3573
lines changed

lib/spack/docs/build_systems.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ on these ideas for each distinct build system that Spack supports:
6565
build_systems/custompackage
6666
build_systems/inteloneapipackage
6767
build_systems/intelpackage
68-
build_systems/multiplepackage
6968
build_systems/rocmpackage
7069
build_systems/sourceforgepackage
7170

lib/spack/docs/build_systems/autotoolspackage.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
66
.. _autotoolspackage:
77

8-
----------------
9-
AutotoolsPackage
10-
----------------
8+
---------
9+
Autotools
10+
---------
1111

1212
Autotools is a GNU build system that provides a build-script generator.
1313
By running the platform-independent ``./configure`` script that comes
@@ -17,7 +17,7 @@ with the package, you can generate a platform-dependent Makefile.
1717
Phases
1818
^^^^^^
1919

20-
The ``AutotoolsPackage`` base class comes with the following phases:
20+
The ``AutotoolsBuilder`` and ``AutotoolsPackage`` base classes come with the following phases:
2121

2222
#. ``autoreconf`` - generate the configure script
2323
#. ``configure`` - generate the Makefiles

lib/spack/docs/build_systems/bundlepackage.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
66
.. _bundlepackage:
77

8-
-------------
9-
BundlePackage
10-
-------------
8+
------
9+
Bundle
10+
------
1111

1212
``BundlePackage`` represents a set of packages that are expected to work well
1313
together, such as a collection of commonly used software libraries. The

lib/spack/docs/build_systems/cmakepackage.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
66
.. _cmakepackage:
77

8-
------------
9-
CMakePackage
10-
------------
8+
-----
9+
CMake
10+
-----
1111

1212
Like Autotools, CMake is a widely-used build-script generator. Designed
1313
by Kitware, CMake is the most popular build system for new C, C++, and
@@ -21,7 +21,7 @@ whereas Autotools is Unix-only.
2121
Phases
2222
^^^^^^
2323

24-
The ``CMakePackage`` base class comes with the following phases:
24+
The ``CMakeBuilder`` and ``CMakePackage`` base classes come with the following phases:
2525

2626
#. ``cmake`` - generate the Makefile
2727
#. ``build`` - build the package
@@ -130,8 +130,8 @@ Adding flags to cmake
130130
To add additional flags to the ``cmake`` call, simply override the
131131
``cmake_args`` function. The following example defines values for the flags
132132
``WHATEVER``, ``ENABLE_BROKEN_FEATURE``, ``DETECT_HDF5``, and ``THREADS`` with
133-
and without the :meth:`~spack.build_systems.cmake.CMakePackage.define` and
134-
:meth:`~spack.build_systems.cmake.CMakePackage.define_from_variant` helper functions:
133+
and without the :meth:`~spack.build_systems.cmake.CMakeBuilder.define` and
134+
:meth:`~spack.build_systems.cmake.CMakeBuilder.define_from_variant` helper functions:
135135

136136
.. code-block:: python
137137

lib/spack/docs/build_systems/luapackage.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
66
.. _luapackage:
77

8-
------------
9-
LuaPackage
10-
------------
8+
---
9+
Lua
10+
---
1111

12-
LuaPackage is a helper for the common case of Lua packages that provide
12+
The ``Lua`` build-system is a helper for the common case of Lua packages that provide
1313
a rockspec file. This is not meant to take a rock archive, but to build
1414
a source archive or repository that provides a rockspec, which should cover
1515
most lua packages. In the case a Lua package builds by Make rather than
@@ -19,7 +19,7 @@ luarocks, prefer MakefilePackage.
1919
Phases
2020
^^^^^^
2121

22-
The ``LuaPackage`` base class comes with the following phases:
22+
The ``LuaBuilder`` and `LuaPackage`` base classes come with the following phases:
2323

2424
#. ``unpack`` - if using a rock, unpacks the rock and moves into the source directory
2525
#. ``preprocess`` - adjust sources or rockspec to fix build

lib/spack/docs/build_systems/makefilepackage.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
66
.. _makefilepackage:
77

8-
---------------
9-
MakefilePackage
10-
---------------
8+
--------
9+
Makefile
10+
--------
1111

1212
The most primitive build system a package can use is a plain Makefile.
1313
Makefiles are simple to write for small projects, but they usually
@@ -18,7 +18,7 @@ variables.
1818
Phases
1919
^^^^^^
2020

21-
The ``MakefilePackage`` base class comes with 3 phases:
21+
The ``MakefileBuilder`` and ``MakefilePackage`` base classes come with 3 phases:
2222

2323
#. ``edit`` - edit the Makefile
2424
#. ``build`` - build the project

lib/spack/docs/build_systems/mavenpackage.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
66
.. _mavenpackage:
77

8-
------------
9-
MavenPackage
10-
------------
8+
-----
9+
Maven
10+
-----
1111

1212
Apache Maven is a general-purpose build system that does not rely
1313
on Makefiles to build software. It is designed for building and
@@ -17,7 +17,7 @@ managing and Java-based project.
1717
Phases
1818
^^^^^^
1919

20-
The ``MavenPackage`` base class comes with the following phases:
20+
The ``MavenBuilder`` and ``MavenPackage`` base classes come with the following phases:
2121

2222
#. ``build`` - compile code and package into a JAR file
2323
#. ``install`` - copy to installation prefix

lib/spack/docs/build_systems/mesonpackage.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
66
.. _mesonpackage:
77

8-
------------
9-
MesonPackage
10-
------------
8+
-----
9+
Meson
10+
-----
1111

1212
Much like Autotools and CMake, Meson is a build system. But it is
1313
meant to be both fast and as user friendly as possible. GNOME's goal
@@ -17,7 +17,7 @@ is to port modules to use the Meson build system.
1717
Phases
1818
^^^^^^
1919

20-
The ``MesonPackage`` base class comes with the following phases:
20+
The ``MesonBuilder`` and ``MesonPackage`` base classes come with the following phases:
2121

2222
#. ``meson`` - generate ninja files
2323
#. ``build`` - build the project

0 commit comments

Comments
 (0)