summaryrefslogtreecommitdiff
path: root/var/spack/repos
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@gmail.com>2022-10-26 20:17:32 +0200
committerGitHub <noreply@github.com>2022-10-26 20:17:32 +0200
commit30c9ff50dd048573e3cd7a63a8ab9c05c0bee339 (patch)
tree188f4739697adc00669c75b7e91b1d1e769db97e /var/spack/repos
parent83ee5001086672a45e140d5858eacc0b8ef90941 (diff)
downloadspack-30c9ff50dd048573e3cd7a63a8ab9c05c0bee339.tar.gz
spack-30c9ff50dd048573e3cd7a63a8ab9c05c0bee339.tar.bz2
spack-30c9ff50dd048573e3cd7a63a8ab9c05c0bee339.tar.xz
spack-30c9ff50dd048573e3cd7a63a8ab9c05c0bee339.zip
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.
Diffstat (limited to 'var/spack/repos')
-rw-r--r--var/spack/repos/builder.test/packages/callbacks/package.py45
-rw-r--r--var/spack/repos/builder.test/packages/custom-phases/package.py31
-rw-r--r--var/spack/repos/builder.test/packages/gnuconfig/package.py15
-rw-r--r--var/spack/repos/builder.test/packages/inheritance/package.py26
-rw-r--r--var/spack/repos/builder.test/packages/old-style-autotools/package.py50
-rw-r--r--var/spack/repos/builder.test/packages/old-style-custom-phases/package.py34
-rw-r--r--var/spack/repos/builder.test/packages/old-style-derived/package.py21
-rw-r--r--var/spack/repos/builder.test/repo.yaml2
-rw-r--r--var/spack/repos/builtin.mock/packages/a/package.py12
-rw-r--r--var/spack/repos/builtin.mock/packages/attributes-foo/package.py1
-rw-r--r--var/spack/repos/builtin.mock/packages/canfail/package.py12
-rw-r--r--var/spack/repos/builtin.mock/packages/cmake-client/package.py10
-rw-r--r--var/spack/repos/builtin.mock/packages/cmake/package.py7
-rw-r--r--var/spack/repos/builtin.mock/packages/dev-build-test-dependent/package.py7
-rw-r--r--var/spack/repos/builtin.mock/packages/dev-build-test-install-phases/package.py1
-rw-r--r--var/spack/repos/builtin.mock/packages/dev-build-test-install/package.py9
-rw-r--r--var/spack/repos/builtin.mock/packages/fail-test-audit/package.py21
-rw-r--r--var/spack/repos/builtin.mock/packages/libtool-deletion/package.py13
-rw-r--r--var/spack/repos/builtin.mock/packages/libtool-installation/package.py15
-rw-r--r--var/spack/repos/builtin.mock/packages/nosource-install/package.py3
-rw-r--r--var/spack/repos/builtin.mock/packages/test-build-callbacks/package.py21
-rw-r--r--var/spack/repos/builtin.mock/packages/test-install-callbacks/package.py16
-rw-r--r--var/spack/repos/builtin.mock/packages/transitive-conditional-virtual-dependency/package.py4
-rw-r--r--var/spack/repos/builtin.mock/packages/trivial-smoke-test/package.py3
-rw-r--r--var/spack/repos/builtin/packages/alpgen/package.py119
-rw-r--r--var/spack/repos/builtin/packages/arpack-ng/package.py111
-rw-r--r--var/spack/repos/builtin/packages/binutils/package.py136
-rw-r--r--var/spack/repos/builtin/packages/clara/package.py24
-rw-r--r--var/spack/repos/builtin/packages/flex/package.py29
-rw-r--r--var/spack/repos/builtin/packages/gobject-introspection/package.py32
-rw-r--r--var/spack/repos/builtin/packages/harfbuzz/package.py67
-rw-r--r--var/spack/repos/builtin/packages/ibm-databroker/package.py2
-rw-r--r--var/spack/repos/builtin/packages/intel-tbb/package.py106
-rw-r--r--var/spack/repos/builtin/packages/json-c/package.py23
-rw-r--r--var/spack/repos/builtin/packages/libtree/package.py36
-rw-r--r--var/spack/repos/builtin/packages/libxkbcommon/package.py32
-rw-r--r--var/spack/repos/builtin/packages/lua/package.py9
-rw-r--r--var/spack/repos/builtin/packages/mesa/package.py44
-rw-r--r--var/spack/repos/builtin/packages/metis/gklib_path.patch11
-rw-r--r--var/spack/repos/builtin/packages/metis/package.py258
-rw-r--r--var/spack/repos/builtin/packages/mmg/package.py33
-rw-r--r--var/spack/repos/builtin/packages/nasm/package.py19
-rw-r--r--var/spack/repos/builtin/packages/netlib-lapack/package.py71
-rw-r--r--var/spack/repos/builtin/packages/openmpi/package.py6
-rw-r--r--var/spack/repos/builtin/packages/plasma/package.py55
-rw-r--r--var/spack/repos/builtin/packages/py-dm-tree/package.py13
-rw-r--r--var/spack/repos/builtin/packages/py-onnx-runtime/package.py2
-rw-r--r--var/spack/repos/builtin/packages/py-pillow/package.py15
-rw-r--r--var/spack/repos/builtin/packages/py-pybind11/package.py54
-rw-r--r--var/spack/repos/builtin/packages/py-pykokkos-base/package.py2
-rw-r--r--var/spack/repos/builtin/packages/py-tfdlpack/package.py2
-rw-r--r--var/spack/repos/builtin/packages/quantum-espresso/package.py55
-rw-r--r--var/spack/repos/builtin/packages/racket/package.py59
-rw-r--r--var/spack/repos/builtin/packages/rkt-base/package.py2
-rw-r--r--var/spack/repos/builtin/packages/rkt-cext-lib/package.py1
-rw-r--r--var/spack/repos/builtin/packages/rkt-compiler-lib/package.py2
-rw-r--r--var/spack/repos/builtin/packages/rkt-dynext-lib/package.py1
-rw-r--r--var/spack/repos/builtin/packages/rkt-rackunit-lib/package.py1
-rw-r--r--var/spack/repos/builtin/packages/rkt-scheme-lib/package.py1
-rw-r--r--var/spack/repos/builtin/packages/rkt-testing-util-lib/package.py1
-rw-r--r--var/spack/repos/builtin/packages/rkt-zo-lib/package.py2
-rw-r--r--var/spack/repos/builtin/packages/ruby/package.py133
-rw-r--r--var/spack/repos/builtin/packages/scotch/package.py129
-rw-r--r--var/spack/repos/builtin/packages/superlu/package.py143
-rw-r--r--var/spack/repos/builtin/packages/swig/package.py36
-rw-r--r--var/spack/repos/builtin/packages/sz/package.py125
-rw-r--r--var/spack/repos/builtin/packages/timemory/package.py2
-rw-r--r--var/spack/repos/builtin/packages/uncrustify/package.py35
-rw-r--r--var/spack/repos/builtin/packages/zlib/package.py59
69 files changed, 1227 insertions, 1250 deletions
diff --git a/var/spack/repos/builder.test/packages/callbacks/package.py b/var/spack/repos/builder.test/packages/callbacks/package.py
new file mode 100644
index 0000000000..ea6787d9b5
--- /dev/null
+++ b/var/spack/repos/builder.test/packages/callbacks/package.py
@@ -0,0 +1,45 @@
+# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+import os
+
+import spack.build_systems.generic
+from spack.package import *
+
+
+class Callbacks(Package):
+ """Package used to verify that callbacks on phases work correctly, including conditions"""
+
+ homepage = "http://www.example.com"
+ url = "http://www.example.com/a-1.0.tar.gz"
+
+ version("2.0", "abcdef0123456789abcdef0123456789")
+ version("1.0", "0123456789abcdef0123456789abcdef")
+
+
+class GenericBuilder(spack.build_systems.generic.GenericBuilder):
+ def install(self, pkg, spec, prefix):
+ os.environ["CALLBACKS_INSTALL_CALLED"] = "1"
+ os.environ["INSTALL_VALUE"] = "CALLBACKS"
+ mkdirp(prefix.bin)
+
+ @run_before("install")
+ def before_install_1(self):
+ os.environ["BEFORE_INSTALL_1_CALLED"] = "1"
+ os.environ["TEST_VALUE"] = "1"
+
+ @run_before("install")
+ def before_install_2(self):
+ os.environ["BEFORE_INSTALL_2_CALLED"] = "1"
+ os.environ["TEST_VALUE"] = "2"
+
+ @run_after("install")
+ def after_install_1(self):
+ os.environ["AFTER_INSTALL_1_CALLED"] = "1"
+ os.environ["TEST_VALUE"] = "3"
+
+ @run_after("install", when="@1.0")
+ def after_install_2(self):
+ os.environ["AFTER_INSTALL_2_CALLED"] = "1"
+ os.environ["TEST_VALUE"] = "4"
diff --git a/var/spack/repos/builder.test/packages/custom-phases/package.py b/var/spack/repos/builder.test/packages/custom-phases/package.py
new file mode 100644
index 0000000000..37b26e37d0
--- /dev/null
+++ b/var/spack/repos/builder.test/packages/custom-phases/package.py
@@ -0,0 +1,31 @@
+# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+import os
+
+import spack.build_systems.generic
+from spack.package import *
+
+
+class CustomPhases(Package):
+ """Package used to verify that we can set custom phases on builders"""
+
+ homepage = "http://www.example.com"
+ url = "http://www.example.com/a-1.0.tar.gz"
+
+ version("2.0", "abcdef0123456789abcdef0123456789")
+ version("1.0", "0123456789abcdef0123456789abcdef")
+
+
+class GenericBuilder(spack.build_systems.generic.GenericBuilder):
+ phases = ["configure", "install"]
+
+ def configure(self, pkg, spec, prefix):
+ os.environ["CONFIGURE_CALLED"] = "1"
+ os.environ["LAST_PHASE"] = "CONFIGURE"
+
+ def install(self, pkg, spec, prefix):
+ os.environ["INSTALL_CALLED"] = "1"
+ os.environ["LAST_PHASE"] = "INSTALL"
+ mkdirp(prefix.bin)
diff --git a/var/spack/repos/builder.test/packages/gnuconfig/package.py b/var/spack/repos/builder.test/packages/gnuconfig/package.py
new file mode 100644
index 0000000000..53f8a10705
--- /dev/null
+++ b/var/spack/repos/builder.test/packages/gnuconfig/package.py
@@ -0,0 +1,15 @@
+# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+from spack.package import *
+
+
+class Gnuconfig(Package):
+ """This package is needed to allow mocking AutotoolsPackage objects"""
+
+ homepage = "http://www.example.com"
+ url = "http://www.example.com/a-1.0.tar.gz"
+
+ version("2.0", "abcdef0123456789abcdef0123456789")
+ version("1.0", "0123456789abcdef0123456789abcdef")
diff --git a/var/spack/repos/builder.test/packages/inheritance/package.py b/var/spack/repos/builder.test/packages/inheritance/package.py
new file mode 100644
index 0000000000..307d93ca80
--- /dev/null
+++ b/var/spack/repos/builder.test/packages/inheritance/package.py
@@ -0,0 +1,26 @@
+# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+import os
+
+import spack.pkg.builder.test.callbacks
+from spack.package import *
+
+
+class Inheritance(spack.pkg.builder.test.callbacks.Callbacks):
+ """Package used to verify that inheritance among packages work as expected"""
+
+ pass
+
+
+class GenericBuilder(spack.pkg.builder.test.callbacks.GenericBuilder):
+ def install(self, pkg, spec, prefix):
+ super(GenericBuilder, self).install(pkg, spec, prefix)
+ os.environ["INHERITANCE_INSTALL_CALLED"] = "1"
+ os.environ["INSTALL_VALUE"] = "INHERITANCE"
+
+ @run_before("install")
+ def derived_before_install(self):
+ os.environ["DERIVED_BEFORE_INSTALL_CALLED"] = "1"
+ os.environ["TEST_VALUE"] = "0"
diff --git a/var/spack/repos/builder.test/packages/old-style-autotools/package.py b/var/spack/repos/builder.test/packages/old-style-autotools/package.py
new file mode 100644
index 0000000000..56213d7158
--- /dev/null
+++ b/var/spack/repos/builder.test/packages/old-style-autotools/package.py
@@ -0,0 +1,50 @@
+# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+import os
+
+from spack.package import *
+
+
+class OldStyleAutotools(AutotoolsPackage):
+ """Package used to verify that old-style packages work correctly when executing the
+ installation procedure.
+ """
+
+ homepage = "http://www.example.com"
+ url = "http://www.example.com/a-1.0.tar.gz"
+
+ version("2.0", "abcdef0123456789abcdef0123456789")
+ version("1.0", "0123456789abcdef0123456789abcdef")
+
+ def configure(self, spec, prefix):
+ pass
+
+ def build(self, spec, prefix):
+ pass
+
+ def install(self, spec, prefix):
+ mkdirp(prefix.bin)
+
+ def configure_args(self):
+ """This override a function in the builder and construct the result using a method
+ defined in this class and a super method defined in the builder.
+ """
+ return [self.foo()] + super(OldStyleAutotools, self).configure_args()
+
+ def foo(self):
+ return "--with-foo"
+
+ @run_before("autoreconf")
+ def create_configure(self):
+ mkdirp(self.configure_directory)
+ touch(self.configure_abs_path)
+
+ @run_after("autoreconf", when="@1.0")
+ def after_autoreconf_1(self):
+ os.environ["AFTER_AUTORECONF_1_CALLED"] = "1"
+
+ @run_after("autoreconf", when="@2.0")
+ def after_autoreconf_2(self):
+ os.environ["AFTER_AUTORECONF_2_CALLED"] = "1"
diff --git a/var/spack/repos/builder.test/packages/old-style-custom-phases/package.py b/var/spack/repos/builder.test/packages/old-style-custom-phases/package.py
new file mode 100644
index 0000000000..afa5b52d70
--- /dev/null
+++ b/var/spack/repos/builder.test/packages/old-style-custom-phases/package.py
@@ -0,0 +1,34 @@
+# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+import os
+
+from spack.package import *
+
+
+class OldStyleCustomPhases(AutotoolsPackage):
+ """Package used to verify that old-style packages work correctly when defining custom
+ phases (though it's not recommended for packagers to do so).
+ """
+
+ homepage = "http://www.example.com"
+ url = "http://www.example.com/a-1.0.tar.gz"
+
+ version("2.0", "abcdef0123456789abcdef0123456789")
+ version("1.0", "0123456789abcdef0123456789abcdef")
+
+ phases = ["configure"]
+
+ def configure(self, spec, prefix):
+ mkdirp(prefix.bin)
+
+ @run_after("configure")
+ def after_configure(self):
+ os.environ["AFTER_CONFIGURE_CALLED"] = "1"
+ os.environ["TEST_VALUE"] = "0"
+
+ @run_after("install")
+ def after_install(self):
+ os.environ["AFTER_INSTALL_CALLED"] = "1"
+ os.environ["TEST_VALUE"] = "1"
diff --git a/var/spack/repos/builder.test/packages/old-style-derived/package.py b/var/spack/repos/builder.test/packages/old-style-derived/package.py
new file mode 100644
index 0000000000..a7dd026217
--- /dev/null
+++ b/var/spack/repos/builder.test/packages/old-style-derived/package.py
@@ -0,0 +1,21 @@
+# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+import spack.pkg.builder.test.old_style_autotools
+from spack.package import *
+
+
+class OldStyleDerived(spack.pkg.builder.test.old_style_autotools.OldStyleAutotools):
+ """Package used to verify that old-style packages work correctly when executing the
+ installation procedure.
+ """
+
+ homepage = "http://www.example.com"
+ url = "http://www.example.com/a-1.0.tar.gz"
+
+ version("2.0", "abcdef0123456789abcdef0123456789")
+ version("1.0", "0123456789abcdef0123456789abcdef")
+
+ def configure_args(self):
+ return ["--with-bar"] + super(OldStyleDerived, self).configure_args()
diff --git a/var/spack/repos/builder.test/repo.yaml b/var/spack/repos/builder.test/repo.yaml
new file mode 100644
index 0000000000..a9031afe21
--- /dev/null
+++ b/var/spack/repos/builder.test/repo.yaml
@@ -0,0 +1,2 @@
+repo:
+ namespace: builder.test
diff --git a/var/spack/repos/builtin.mock/packages/a/package.py b/var/spack/repos/builtin.mock/packages/a/package.py
index b556fbf06f..5dbcd1f9c2 100644
--- a/var/spack/repos/builtin.mock/packages/a/package.py
+++ b/var/spack/repos/builtin.mock/packages/a/package.py
@@ -2,7 +2,7 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-
+import spack.build_systems.autotools
from spack.package import *
@@ -32,21 +32,23 @@ class A(AutotoolsPackage):
parallel = False
+
+class AutotoolsBuilder(spack.build_systems.autotools.AutotoolsBuilder):
def with_or_without_fee(self, activated):
if not activated:
return "--no-fee"
return "--fee-all-the-time"
- def autoreconf(self, spec, prefix):
+ def autoreconf(self, pkg, spec, prefix):
pass
- def configure(self, spec, prefix):
+ def configure(self, pkg, spec, prefix):
pass
- def build(self, spec, prefix):
+ def build(self, pkg, spec, prefix):
pass
- def install(self, spec, prefix):
+ def install(self, pkg, spec, prefix):
# sanity_check_prefix requires something in the install directory
# Test requires overriding the one provided by `AutotoolsPackage`
mkdirp(prefix.bin)
diff --git a/var/spack/repos/builtin.mock/packages/attributes-foo/package.py b/var/spack/repos/builtin.mock/packages/attributes-foo/package.py
index 9010c52958..83b41b98ac 100644
--- a/var/spack/repos/builtin.mock/packages/attributes-foo/package.py
+++ b/var/spack/repos/builtin.mock/packages/attributes-foo/package.py
@@ -8,7 +8,6 @@ from spack.package import *
class AttributesFoo(BundlePackage):
- phases = ["install"]
version("1.0")
provides("bar")
diff --git a/var/spack/repos/builtin.mock/packages/canfail/package.py b/var/spack/repos/builtin.mock/packages/canfail/package.py
index eb35fdec56..75bb66df25 100644
--- a/var/spack/repos/builtin.mock/packages/canfail/package.py
+++ b/var/spack/repos/builtin.mock/packages/canfail/package.py
@@ -2,6 +2,7 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+import os
from spack.package import *
@@ -14,7 +15,16 @@ class Canfail(Package):
version("1.0", "0123456789abcdef0123456789abcdef")
- succeed = False
+ def set_install_succeed(self):
+ os.environ["CANFAIL_SUCCEED"] = "1"
+
+ def set_install_fail(self):
+ os.environ.pop("CANFAIL_SUCCEED", None)
+
+ @property
+ def succeed(self):
+ result = True if "CANFAIL_SUCCEED" in os.environ else False
+ return result
def install(self, spec, prefix):
if not self.succeed:
diff --git a/var/spack/repos/builtin.mock/packages/cmake-client/package.py b/var/spack/repos/builtin.mock/packages/cmake-client/package.py
index 54842fd2d8..ed3998e550 100644
--- a/var/spack/repos/builtin.mock/packages/cmake-client/package.py
+++ b/var/spack/repos/builtin.mock/packages/cmake-client/package.py
@@ -15,7 +15,7 @@ def check(condition, msg):
class CmakeClient(CMakePackage):
- """A dumy package that uses cmake."""
+ """A dummy package that uses cmake."""
homepage = "https://www.example.com"
url = "https://www.example.com/cmake-client-1.0.tar.gz"
@@ -38,14 +38,16 @@ class CmakeClient(CMakePackage):
did_something = False
@run_after("cmake")
- @run_before("cmake", "build", "install")
+ @run_before("cmake")
+ @run_before("build")
+ @run_before("install")
def increment(self):
- self.callback_counter += 1
+ CmakeClient.callback_counter += 1
@run_after("cmake")
@on_package_attributes(run_this=True, check_this_is_none=None)
def flip(self):
- self.flipped = True
+ CmakeClient.flipped = True
@run_after("cmake")
@on_package_attributes(does_not_exist=None)
diff --git a/var/spack/repos/builtin.mock/packages/cmake/package.py b/var/spack/repos/builtin.mock/packages/cmake/package.py
index 30c3647df2..dac2c19875 100644
--- a/var/spack/repos/builtin.mock/packages/cmake/package.py
+++ b/var/spack/repos/builtin.mock/packages/cmake/package.py
@@ -18,12 +18,17 @@ def check(condition, msg):
class Cmake(Package):
- """A dumy package for the cmake build system."""
+ """A dummy package for the cmake build system."""
homepage = "https://www.cmake.org"
url = "https://cmake.org/files/v3.4/cmake-3.4.3.tar.gz"
version(
+ "3.23.1",
+ "4cb3ff35b2472aae70f542116d616e63",
+ url="https://cmake.org/files/v3.4/cmake-3.4.3.tar.gz",
+ )
+ version(
"3.4.3",
"4cb3ff35b2472aae70f542116d616e63",
url="https://cmake.org/files/v3.4/cmake-3.4.3.tar.gz",
diff --git a/var/spack/repos/builtin.mock/packages/dev-build-test-dependent/package.py b/var/spack/repos/builtin.mock/packages/dev-build-test-dependent/package.py
index 44374cd1a7..a5ac04d282 100644
--- a/var/spack/repos/builtin.mock/packages/dev-build-test-dependent/package.py
+++ b/var/spack/repos/builtin.mock/packages/dev-build-test-dependent/package.py
@@ -7,14 +7,12 @@
from spack.package import *
-class DevBuildTestDependent(Package):
+class DevBuildTestDependent(MakefilePackage):
homepage = "example.com"
url = "fake.com"
version("0.0.0", sha256="0123456789abcdef0123456789abcdef")
- phases = ["edit", "install"]
-
filename = "dev-build-test-file.txt"
original_string = "This file should be edited"
replacement_string = "This file has been edited"
@@ -28,5 +26,8 @@ class DevBuildTestDependent(Package):
f.truncate()
f.write(self.replacement_string)
+ def build(self, spec, prefix):
+ pass
+
def install(self, spec, prefix):
install(self.filename, prefix)
diff --git a/var/spack/repos/builtin.mock/packages/dev-build-test-install-phases/package.py b/var/spack/repos/builtin.mock/packages/dev-build-test-install-phases/package.py
index fa0f6b794e..916156c1f5 100644
--- a/var/spack/repos/builtin.mock/packages/dev-build-test-install-phases/package.py
+++ b/var/spack/repos/builtin.mock/packages/dev-build-test-install-phases/package.py
@@ -29,4 +29,5 @@ class DevBuildTestInstallPhases(Package):
print("Three locomoco")
def install(self, spec, prefix):
+ mkdirp(prefix.bin)
print("install")
diff --git a/var/spack/repos/builtin.mock/packages/dev-build-test-install/package.py b/var/spack/repos/builtin.mock/packages/dev-build-test-install/package.py
index 185fe5552c..ba0b1400a3 100644
--- a/var/spack/repos/builtin.mock/packages/dev-build-test-install/package.py
+++ b/var/spack/repos/builtin.mock/packages/dev-build-test-install/package.py
@@ -2,19 +2,15 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-
-
from spack.package import *
-class DevBuildTestInstall(Package):
+class DevBuildTestInstall(MakefilePackage):
homepage = "example.com"
url = "fake.com"
version("0.0.0", sha256="0123456789abcdef0123456789abcdef")
- phases = ["edit", "install"]
-
filename = "dev-build-test-file.txt"
original_string = "This file should be edited"
replacement_string = "This file has been edited"
@@ -26,5 +22,8 @@ class DevBuildTestInstall(Package):
f.truncate()
f.write(self.replacement_string)
+ def build(self, spec, prefix):
+ pass
+
def install(self, spec, prefix):
install(self.filename, prefix)
diff --git a/var/spack/repos/builtin.mock/packages/fail-test-audit/package.py b/var/spack/repos/builtin.mock/packages/fail-test-audit/package.py
new file mode 100644
index 0000000000..1e290724d1
--- /dev/null
+++ b/var/spack/repos/builtin.mock/packages/fail-test-audit/package.py
@@ -0,0 +1,21 @@
+# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+from spack.package import *
+
+
+class FailTestAudit(MakefilePackage):
+ """Simple package with one optional dependency"""
+
+ homepage = "http://www.example.com"
+ url = "http://www.example.com/a-1.0.tar.gz"
+
+ version("1.0", "0123456789abcdef0123456789abcdef")
+ version("2.0", "abcdef0123456789abcdef0123456789")
+
+ build_time_test_callbacks = ["test"]
+
+ def test(self):
+ print("test: test-install-callbacks")
+ print("PASSED")
diff --git a/var/spack/repos/builtin.mock/packages/libtool-deletion/package.py b/var/spack/repos/builtin.mock/packages/libtool-deletion/package.py
index a169a78d2e..8ab87d2064 100644
--- a/var/spack/repos/builtin.mock/packages/libtool-deletion/package.py
+++ b/var/spack/repos/builtin.mock/packages/libtool-deletion/package.py
@@ -4,6 +4,7 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os.path
+import spack.build_systems.autotools
from spack.package import *
@@ -19,17 +20,21 @@ class LibtoolDeletion(AutotoolsPackage):
def do_stage(self):
mkdirp(self.stage.source_path)
- def autoreconf(self, spec, prefix):
+
+class AutotoolsBuilder(spack.build_systems.autotools.AutotoolsBuilder):
+ install_libtool_archives = False
+
+ def autoreconf(self, pkg, spec, prefix):
mkdirp(os.path.dirname(self.configure_abs_path))
touch(self.configure_abs_path)
- def configure(self, spec, prefix):
+ def configure(self, pkg, spec, prefix):
pass
- def build(self, spec, prefix):
+ def build(self, pkg, spec, prefix):
pass
- def install(self, spec, prefix):
+ def install(self, pkg, spec, prefix):
mkdirp(os.path.dirname(self.libtool_archive_file))
touch(self.libtool_archive_file)
diff --git a/var/spack/repos/builtin.mock/packages/libtool-installation/package.py b/var/spack/repos/builtin.mock/packages/libtool-installation/package.py
new file mode 100644
index 0000000000..72883b9042
--- /dev/null
+++ b/var/spack/repos/builtin.mock/packages/libtool-installation/package.py
@@ -0,0 +1,15 @@
+# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+from spack.package import *
+from spack.pkg.builtin.mock.libtool_deletion import AutotoolsBuilder as BuilderBase
+from spack.pkg.builtin.mock.libtool_deletion import LibtoolDeletion
+
+
+class LibtoolInstallation(LibtoolDeletion, AutotoolsPackage):
+ """Mock AutotoolsPackage to check proper installation of libtool archives."""
+
+
+class AutotoolsBuilder(BuilderBase):
+ install_libtool_archives = True
diff --git a/var/spack/repos/builtin.mock/packages/nosource-install/package.py b/var/spack/repos/builtin.mock/packages/nosource-install/package.py
index a1ca724448..5166480dd4 100644
--- a/var/spack/repos/builtin.mock/packages/nosource-install/package.py
+++ b/var/spack/repos/builtin.mock/packages/nosource-install/package.py
@@ -16,9 +16,6 @@ class NosourceInstall(BundlePackage):
depends_on("dependency-install")
- # The install phase must be specified.
- phases = ["install"]
-
# The install method must also be present.
def install(self, spec, prefix):
touch(join_path(self.prefix, "install.txt"))
diff --git a/var/spack/repos/builtin.mock/packages/test-build-callbacks/package.py b/var/spack/repos/builtin.mock/packages/test-build-callbacks/package.py
index 4b4b74e9b3..d45f0d295b 100644
--- a/var/spack/repos/builtin.mock/packages/test-build-callbacks/package.py
+++ b/var/spack/repos/builtin.mock/packages/test-build-callbacks/package.py
@@ -2,9 +2,9 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-
+import spack.build_systems._checks as checks
+import spack.build_systems.generic
from spack.package import *
-from spack.package_base import run_after
class TestBuildCallbacks(Package):
@@ -15,17 +15,16 @@ class TestBuildCallbacks(Package):
version("1.0", "0123456789abcdef0123456789abcdef")
+
+class GenericBuilder(spack.build_systems.generic.GenericBuilder):
phases = ["build", "install"]
- # Include undefined method (runtime failure) and 'test' (audit failure)
- build_time_test_callbacks = ["undefined-build-test", "test"]
- run_after("build")(Package._run_default_build_time_test_callbacks)
- def build(self, spec, prefix):
+ # Include undefined method (runtime failure)
+ build_time_test_callbacks = ["undefined-build-test"]
+ run_after("build")(checks.execute_build_time_tests)
+
+ def build(self, pkg, spec, prefix):
pass
- def install(self, spec, prefix):
+ def install(self, pkg, spec, prefix):
mkdirp(prefix.bin)
-
- def test(self):
- print("test: running test-build-callbacks")
- print("PASSED")
diff --git a/var/spack/repos/builtin.mock/packages/test-install-callbacks/package.py b/var/spack/repos/builtin.mock/packages/test-install-callbacks/package.py
index 27a31227c3..0d348c0d67 100644
--- a/var/spack/repos/builtin.mock/packages/test-install-callbacks/package.py
+++ b/var/spack/repos/builtin.mock/packages/test-install-callbacks/package.py
@@ -2,9 +2,9 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-
+import spack.build_systems._checks as checks
+import spack.build_systems.generic
from spack.package import *
-from spack.package_base import run_after
class TestInstallCallbacks(Package):
@@ -15,13 +15,11 @@ class TestInstallCallbacks(Package):
version("1.0", "0123456789abcdef0123456789abcdef")
+
+class GenericBuilder(spack.build_systems.generic.GenericBuilder):
# Include an undefined callback method
- install_time_test_callbacks = ["undefined-install-test", "test"]
- run_after("install")(Package._run_default_install_time_test_callbacks)
+ install_time_test_callbacks = ["undefined-install-test"]
+ run_after("install")(checks.execute_install_time_tests)
- def install(self, spec, prefix):
+ def install(self, pkg, spec, prefix):
mkdirp(prefix.bin)
-
- def test(self):
- print("test: test-install-callbacks")
- print("PASSED")
diff --git a/var/spack/repos/builtin.mock/packages/transitive-conditional-virtual-dependency/package.py b/var/spack/repos/builtin.mock/packages/transitive-conditional-virtual-dependency/package.py
index a7c4658810..9078d63b4d 100644
--- a/var/spack/repos/builtin.mock/packages/transitive-conditional-virtual-dependency/package.py
+++ b/var/spack/repos/builtin.mock/packages/transitive-conditional-virtual-dependency/package.py
@@ -5,12 +5,10 @@
from spack.package import *
-class TransitiveConditionalVirtualDependency(Package):
+class TransitiveConditionalVirtualDependency(BundlePackage):
"""Depends on a package with a conditional virtual dependency."""
homepage = "https://dev.null"
- has_code = False
- phases = []
version("1.0")
depends_on("conditional-virtual-dependency")
diff --git a/var/spack/repos/builtin.mock/packages/trivial-smoke-test/package.py b/var/spack/repos/builtin.mock/packages/trivial-smoke-test/package.py
index ec80640d21..35983a18f4 100644
--- a/var/spack/repos/builtin.mock/packages/trivial-smoke-test/package.py
+++ b/var/spack/repos/builtin.mock/packages/trivial-smoke-test/package.py
@@ -16,6 +16,9 @@ class TrivialSmokeTest(Package):
test_source_filename = "cached_file.in"
+ def install(self, spec, prefix):
+ pass
+
@run_before("install")
def create_extra_test_source(self):
mkdirp(self.install_test_root)
diff --git a/var/spack/repos/builtin/packages/alpgen/package.py b/var/spack/repos/builtin/packages/alpgen/package.py
index 717b513cc3..e0816eeca7 100644
--- a/var/spack/repos/builtin/packages/alpgen/package.py
+++ b/var/spack/repos/builtin/packages/alpgen/package.py
@@ -2,15 +2,16 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-
import os
+import spack.build_systems.makefile
from spack.package import *
-class Alpgen(MakefilePackage):
- """A collection of codes for the generation of
- multi-parton processes in hadronic collisions."""
+class Alpgen(CMakePackage, MakefilePackage):
+ """A collection of codes for the generation of multi-parton processes
+ in hadronic collisions.
+ """
homepage = "http://mlm.home.cern.ch/mlm/alpgen/"
url = "http://mlm.home.cern.ch/mlm/alpgen/V2.1/v214.tgz"
@@ -18,102 +19,44 @@ class Alpgen(MakefilePackage):
maintainers = ["iarspider"]
tags = ["hep"]
- patch("alpgen-214.patch", when="recipe=cms")
- patch("alpgen-214-Darwin-x86_84-gfortran.patch", when="platform=darwin recipe=cms")
- patch("alpgen-2.1.4-sft.patch", when="recipe=sft", level=0)
+ version("2.1.4", sha256="2f43f7f526793fe5f81a3a3e1adeffe21b653a7f5851efc599ed69ea13985c5e")
- depends_on("cmake", type="build", when="recipe=sft")
+ build_system("makefile", "cmake", default="makefile")
variant(
"recipe",
- values=("cms", "sft"),
+ values=(
+ conditional("cms", when="build_system=makefile"),
+ conditional("sft", when="build_system=cmake"),
+ ),
default="sft",
- description="Select build recipe: CMS for CMS experiment, " + "SFT for ATLAS/LHCb/others.",
+ description="CMS for CMS experiment, SFT for ATLAS/LHCb/others.",
)
- version("2.1.4", sha256="2f43f7f526793fe5f81a3a3e1adeffe21b653a7f5851efc599ed69ea13985c5e")
-
- phases = ["cmake", "build", "install"]
-
- # copied from CMakePackage
- @property
- def build_dirname(self):
- """Returns the directory name to use when building the package
-
- :return: name of the subdirectory for building the package
- """
- return "spack-build-%s" % self.spec.dag_hash(7)
-
- @property
- def build_directory(self):
- """Returns the directory to use when building the package
-
- :return: directory where to build the package
- """
- return os.path.join(self.stage.path, self.build_dirname)
-
- @property
- def root_cmakelists_dir(self):
- """The relative path to the directory containing CMakeLists.txt
-
- This path is relative to the root of the extracted tarball,
- not to the ``build_directory``. Defaults to the current directory.
-
- :return: directory containing CMakeLists.txt
- """
- return self.stage.source_path
-
- def cmake_args(self):
- """Produces a list containing all the arguments that must be passed to
- cmake, except:
-
- * CMAKE_INSTALL_PREFIX
- * CMAKE_BUILD_TYPE
-
- which will be set automatically.
-
- :return: list of arguments for cmake
- """
- return []
-
- @property
- def std_cmake_args(self):
- """Standard cmake arguments provided as a property for
- convenience of package writers
-
- :return: standard cmake arguments
- """
- # standard CMake arguments
- std_cmake_args = CMakePackage._std_args(self)
- std_cmake_args += getattr(self, "cmake_flag_args", [])
- return std_cmake_args
-
- # end
+ patch("alpgen-214.patch", when="recipe=cms")
+ patch("alpgen-214-Darwin-x86_84-gfortran.patch", when="platform=darwin recipe=cms")
+ patch("alpgen-2.1.4-sft.patch", when="recipe=sft", level=0)
def url_for_version(self, version):
root = self.url.rsplit("/", 2)[0]
return "{0}/V{1}/v{2}.tgz".format(root, version.up_to(2), version.joined)
def patch(self):
- if self.spec.satisfies("recipe=sft"):
+ if self.spec.satisfies("build_system=cmake"):
copy(join_path(os.path.dirname(__file__), "CMakeLists.txt"), "CMakeLists.txt")
- if self.spec.satisfies("recipe=cms"):
+ if self.spec.satisfies("build_system=makefile"):
filter_file("-fno-automatic", "-fno-automatic -std=legacy", "compile.mk")
copy(join_path(os.path.dirname(__file__), "cms_build.sh"), "cms_build.sh")
copy(join_path(os.path.dirname(__file__), "cms_install.sh"), "cms_install.sh")
- @when("recipe=cms")
- def cmake(self, spec, prefix):
- return
- @when("recipe=cms")
- def build(self, spec, prefix):
+class MakefileBuilder(spack.build_systems.makefile.MakefileBuilder):
+ def build(self, pkg, spec, prefix):
bash = which("bash")
bash("./cms_build.sh")
- @when("recipe=cms")
- def install(self, spec, prefix):
+ def install(self, pkg, spec, prefix):
bash = which("bash")
bash("./cms_install.sh", prefix)
@@ -121,25 +64,3 @@ class Alpgen(MakefilePackage):
set_install_permissions(root)
for file in files:
set_install_permissions(join_path(root, file))
-
- @when("recipe=sft")
- def cmake(self, spec, prefix):
- """Runs ``cmake`` in the build directory"""
- options = self.std_cmake_args
- options += self.cmake_args()
- options.append(os.path.abspath(self.root_cmakelists_dir))
- with working_dir(self.build_directory, create=True):
- cmake_x = which("cmake")
- cmake_x(*options)
-
- @when("recipe=sft")
- def build(self, spec, prefix):
- """Make the build targets"""
- with working_dir(self.build_directory):
- make()
-
- @when("recipe=sft")
- def install(self, spec, prefix):
- """Make the install targets"""
- with working_dir(self.build_directory):
- make("install")
diff --git a/var/spack/repos/builtin/packages/arpack-ng/package.py b/var/spack/repos/builtin/packages/arpack-ng/package.py
index 70b1b4820c..49feb262cb 100644
--- a/var/spack/repos/builtin/packages/arpack-ng/package.py
+++ b/var/spack/repos/builtin/packages/arpack-ng/package.py
@@ -2,11 +2,12 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-
+import spack.build_systems.autotools
+import spack.build_systems.cmake
from spack.package import *
-class ArpackNg(Package):
+class ArpackNg(CMakePackage, AutotoolsPackage):
"""ARPACK-NG is a collection of Fortran77 subroutines designed to solve
large scale eigenvalue problems.
@@ -38,6 +39,8 @@ class ArpackNg(Package):
url = "https://github.com/opencollab/arpack-ng/archive/3.3.0.tar.gz"
git = "https://github.com/opencollab/arpack-ng.git"
+ build_system("cmake", "autotools", default="cmake")
+
version("develop", branch="master")
version("3.8.0", sha256="ada5aeb3878874383307239c9235b716a8a170c6d096a6625bfd529844df003d")
version("3.7.0", sha256="972e3fc3cd0b9d6b5a737c9bf6fd07515c0d6549319d4ffb06970e64fa3cc2d6")
@@ -74,13 +77,14 @@ class ArpackNg(Package):
depends_on("blas")
depends_on("lapack")
- depends_on("automake", when="@3.3.0", type="build")
- depends_on("autoconf", when="@3.3.0", type="build")
- depends_on("libtool@2.4.2:", when="@3.3.0", type="build")
- depends_on("cmake@2.8.6:", when="@3.4.0:", type="build")
-
depends_on("mpi", when="+mpi")
+ with when("build_system=autotools"):
+ depends_on("automake", type="build")
+ depends_on("autoconf", type="build")
+ depends_on("libtool@2.4.2:", type="build")
+ depends_on("pkgconfig", type="build")
+
def flag_handler(self, name, flags):
spec = self.spec
iflags = []
@@ -105,36 +109,26 @@ class ArpackNg(Package):
return find_libraries(libraries, root=self.prefix, shared=True, recursive=True)
- @when("@:3.7.0 %gcc@10:")
- def setup_build_environment(self, env):
- # version up to and including 3.7.0 are not ported to gcc 10
- # https://github.com/opencollab/arpack-ng/issues/242
- env.set("FFLAGS", "-fallow-argument-mismatch")
-
- @when("@3.4.0:")
- def install(self, spec, prefix):
- options = ["-DEXAMPLES=ON"]
- options.extend(std_cmake_args)
- options.append("-DCMAKE_INSTALL_NAME_DIR:PATH=%s/lib" % prefix)
-
- # Make sure we use Spack's blas/lapack:
+class CMakeBuilder(spack.build_systems.cmake.CMakeBuilder):
+ def cmake_args(self):
+ spec = self.spec
lapack_libs = spec["lapack"].libs.joined(";")
blas_libs = spec["blas"].libs.joined(";")
- options.extend(
- [
- "-DLAPACK_FOUND=true",
- "-DLAPACK_INCLUDE_DIRS={0}".format(spec["lapack"].prefix.include),
- "-DLAPACK_LIBRARIES={0}".format(lapack_libs),
- "-DBLAS_FOUND=true",
- "-DBLAS_INCLUDE_DIRS={0}".format(spec["blas"].prefix.include),
- "-DBLAS_LIBRARIES={0}".format(blas_libs),
- ]
- )
-
- if "+mpi" in spec:
- options.append("-DMPI=ON")
+ options = [
+ self.define("EXAMPLES", "ON"),
+ self.define("CMAKE_INSTALL_NAME_DIR", self.prefix.lib),
+ self.define("LAPACK_FOUND", True),
+ self.define("LAPACK_INCLUDE_DIRS", spec["lapack"].prefix.include),
+ self.define("LAPACK_LIBRARIES", lapack_libs),
+ self.define("BLAS_FOUND", True),
+ self.define("BLAS_INCLUDE_DIRS", spec["blas"].prefix.include),
+ self.define("BLAS_LIBRARIES", blas_libs),
+ self.define_from_variant("MPI", "mpi"),
+ self.define_from_variant("BUILD_SHARED_LIBS", "shared"),
+ self.define("CMAKE_POSITION_INDEPENDENT_CODE", True),
+ ]
# If 64-bit BLAS is used:
if (
@@ -144,41 +138,28 @@ class ArpackNg(Package):
):
options.append("-DINTERFACE64=1")
- if "+shared" in spec:
- options.append("-DBUILD_SHARED_LIBS=ON")
- else:
- options.append("-DBUILD_SHARED_LIBS=OFF")
- options.append("-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=true")
-
- cmake(".", *options)
- make()
- if self.run_tests:
- make("test")
- make("install")
-
- @when("@3.3.0")
- def install(self, spec, prefix):
- # Apparently autotools are not bootstrapped
- which("libtoolize")()
- bootstrap = Executable("./bootstrap")
-
- options = ["--prefix=%s" % prefix]
+ return options
- if "+mpi" in spec:
- options.extend(["--enable-mpi", "F77=%s" % spec["mpi"].mpif77])
- options.extend(
- [
+class AutotoolsBuilder(spack.build_systems.autotools.AutotoolsBuilder):
+ def configure_args(self):
+ spec = self.spec
+ options = (
+ self.enable_or_disable("mpi")
+ + [
"--with-blas={0}".format(spec["blas"].libs.ld_flags),
"--with-lapack={0}".format(spec["lapack"].libs.ld_flags),
]
+ + self.enable_or_disable("shared")
)
- if "+shared" not in spec:
- options.append("--enable-shared=no")
-
- bootstrap()
- configure(*options)
- make()
- if self.run_tests:
- make("check")
- make("install")
+
+ if "+mpi" in spec:
+ options.append("F77={0}".format(spec["mpi"].mpif77))
+
+ return options
+
+ @when("@:3.7.0 %gcc@10:")
+ def setup_build_environment(self, env):
+ # version up to and including 3.7.0 are not ported to gcc 10
+ # https://github.com/opencollab/arpack-ng/issues/242
+ env.set("FFLAGS", "-fallow-argument-mismatch")
diff --git a/var/spack/repos/builtin/packages/binutils/package.py b/var/spack/repos/builtin/packages/binutils/package.py
index 9ba963b019..f5a9ae7fd9 100644
--- a/var/spack/repos/builtin/packages/binutils/package.py
+++ b/var/spack/repos/builtin/packages/binutils/package.py
@@ -4,6 +4,7 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import re
+import spack.build_systems.autotools
from spack.package import *
@@ -40,13 +41,21 @@ class Binutils(AutotoolsPackage, GNUMirrorPackage):
version("2.20.1", sha256="71d37c96451333c5c0b84b170169fdcb138bbb27397dc06281905d9717c8ed64")
variant("plugins", default=True, description="enable plugins, needed for gold linker")
- variant("gold", default=False, description="build the gold linker")
+ # When you build ld.gold you automatically get ld, even when you add the
+ # --disable-ld flag
+ variant("gold", default=False, when="+ld", description="build the gold linker")
variant("libiberty", default=False, description="Also install libiberty.")
variant("nls", default=True, description="Enable Native Language Support")
variant("headers", default=False, description="Install extra headers (e.g. ELF)")
variant("lto", default=False, description="Enable lto.")
variant("ld", default=False, description="Enable ld.")
- variant("gas", default=False, description="Enable as assembler.")
+ # When you build binutils with ~ld and +gas and load it in your PATH, you
+ # may end up with incompatibilities between a potentially older system ld
+ # and a recent assembler. For instance the linker on ubuntu 16.04 from
+ # binutils 2.26 and the assembler from binutils 2.36.1 will result in:
+ # "unable to initialize decompress status for section .debug_info"
+ # when compiling with debug symbols on gcc.
+ variant("gas", default=False, when="+ld", description="Enable as assembler.")
variant("interwork", default=False, description="Enable interwork.")
variant(
"libs",
@@ -81,83 +90,12 @@ class Binutils(AutotoolsPackage, GNUMirrorPackage):
conflicts("+gold", when="platform=darwin", msg="Binutils cannot build linkers on macOS")
- # When you build binutils with ~ld and +gas and load it in your PATH, you
- # may end up with incompatibilities between a potentially older system ld
- # and a recent assembler. For instance the linker on ubuntu 16.04 from
- # binutils 2.26 and the assembler from binutils 2.36.1 will result in:
- # "unable to initialize decompress status for section .debug_info"
- # when compiling with debug symbols on gcc.
- conflicts("+gas", "~ld", msg="Assembler not always compatible with system ld")
-
- # When you build ld.gold you automatically get ld, even when you add the
- # --disable-ld flag
- conflicts("~ld", "+gold")
-
@classmethod
def determine_version(cls, exe):
output = Executable(exe)("--version", output=str, error=str)
match = re.search(r"GNU (nm|readelf).* (\S+)", output)
return Version(match.group(2)).dotted.up_to(3) if match else None
- def setup_build_environment(self, env):
-
- if self.spec.satisfies("%cce"):
- env.append_flags("LDFLAGS", "-Wl,-z,muldefs")
-
- if "+nls" in self.spec:
- env.append_flags("LDFLAGS", "-lintl")
-
- def configure_args(self):
- spec = self.spec
-
- args = [
- "--disable-dependency-tracking",
- "--disable-werror",
- "--enable-multilib",
- "--enable-64-bit-bfd",
- "--enable-targets=all",
- "--with-system-zlib",
- "--with-sysroot=/",
- ]
-
- args += self.enable_or_disable("libs")
- args += self.enable_or_disable("lto")
- args += self.enable_or_disable("ld")
- args += self.enable_or_disable("gas")
- args += self.enable_or_disable("interwork")
- args += self.enable_or_disable("gold")
- args += self.enable_or_disable("plugins")
-
- if "+libiberty" in spec:
- args.append("--enable-install-libiberty")
- else:
- args.append("--disable-install-libiberty")
-
- if "+nls" in spec:
- args.append("--enable-nls")
- else:
- args.append("--disable-nls")
-
- # To avoid namespace collisions with Darwin/BSD system tools,
- # prefix executables with "g", e.g., gar, gnm; see Homebrew
- # https://github.com/Homebrew/homebrew-core/blob/master/Formula/binutils.rb
- if spec.satisfies("platform=darwin"):
- args.append("--program-prefix=g")
-
- return args
-
- @run_after("install")
- def install_headers(self):
- # some packages (like TAU) need the ELF headers, so install them
- # as a subdirectory in include/extras
- if "+headers" in self.spec:
- extradir = join_path(self.prefix.include, "extra")
- mkdirp(extradir)
- # grab the full binutils set of headers
- install_tree("include", extradir)
- # also grab the headers from the bfd directory
- install(join_path(self.build_directory, "bfd", "*.h"), extradir)
-
def flag_handler(self, name, flags):
spec = self.spec
# Use a separate variable for injecting flags. This way, installing
@@ -204,3 +142,55 @@ class Binutils(AutotoolsPackage, GNUMirrorPackage):
self.run_test(
exe, "--version", expected, installed=True, purpose=reason, skip_missing=True
)
+
+
+class AutotoolsBuilder(spack.build_systems.autotools.AutotoolsBuilder):
+ def configure_args(self):
+ args = [
+ "--disable-dependency-tracking",
+ "--disable-werror",
+ "--enable-multilib",
+ "--enable-64-bit-bfd",
+ "--enable-targets=all",
+ "--with-system-zlib",
+ "--with-sysroot=/",
+ ]
+ args += self.enable_or_disable("libs")
+ args += self.enable_or_disable("lto")
+ args += self.enable_or_disable("ld")
+ args += self.enable_or_disable("gas")
+ args += self.enable_or_disable("interwork")
+ args += self.enable_or_disable("gold")
+ args += self.enable_or_disable("nls")
+ args += self.enable_or_disable("plugins")
+
+ if "+libiberty" in self.spec:
+ args.append("--enable-install-libiberty")
+ else:
+ args.append("--disable-install-libiberty")
+
+ # To avoid namespace collisions with Darwin/BSD system tools,
+ # prefix executables with "g", e.g., gar, gnm; see Homebrew
+ # https://github.com/Homebrew/homebrew-core/blob/master/Formula/binutils.rb
+ if self.spec.satisfies("platform=darwin"):
+ args.append("--program-prefix=g")
+
+ return args
+
+ @run_after("install", when="+headers")
+ def install_headers(self):
+ # some packages (like TAU) need the ELF headers, so install them
+ # as a subdirectory in include/extras
+ extradir = join_path(self.prefix.include, "extra")
+ mkdirp(extradir)
+ # grab the full binutils set of headers
+ install_tree("include", extradir)
+ # also grab the headers from the bfd directory
+ install(join_path(self.build_directory, "bfd", "*.h"), extradir)
+
+ def setup_build_environment(self, env):
+ if self.spec.satisfies("%cce"):
+ env.append_flags("LDFLAGS", "-Wl,-z,muldefs")
+
+ if "+nls" in self.spec:
+ env.append_flags("LDFLAGS", "-lintl")
diff --git a/var/spack/repos/builtin/packages/clara/package.py b/var/spack/repos/builtin/packages/clara/package.py
index 3eaea61ce5..fadec16835 100644
--- a/var/spack/repos/builtin/packages/clara/package.py
+++ b/var/spack/repos/builtin/packages/clara/package.py
@@ -2,19 +2,26 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-
+import spack.build_systems.generic
from spack.package import *
-class Clara(CMakePackage):
+class Clara(CMakePackage, Package):
"""A simple to use, composable, command line parser for C++ 11
- and beyond."""
+ and beyond.
+ """
homepage = "https://github.com/catchorg/Clara"
url = "https://github.com/catchorg/Clara/archive/v1.1.5.tar.gz"
maintainers = ["bvanessen"]
+ build_system(
+ conditional("generic", when="+single_header"),
+ conditional("cmake", when="~single_header"),
+ default="generic",
+ )
+
variant("single_header", default=True, description="Install a single header only.")
version("1.1.5", sha256="767dc1718e53678cbea00977adcd0a8a195802a505aec3c537664cf25a173142")
@@ -24,15 +31,8 @@ class Clara(CMakePackage):
version("1.1.1", sha256="10915a49a94d371f05af360d40e9cc9615ab86f200d261edf196a8ddd7efa7f8")
version("1.1.0", sha256="29ca29d843150aabad702356f79009f5b30dda05ac9674a064362b7edcba5477")
- @when("+single_header")
- def cmake(self, spec, prefix):
- pass
-
- @when("+single_header")
- def build(self, spec, prefix):
- pass
- @when("+single_header")
- def install(self, spec, prefix):
+class GenericBuilder(spack.build_systems.generic.GenericBuilder):
+ def install(self, pkg, spec, prefix):
mkdirp(prefix.include)
install_tree("single_include", prefix.include)
diff --git a/var/spack/repos/builtin/packages/flex/package.py b/var/spack/repos/builtin/packages/flex/package.py
index 8f3d496bb5..f0754ec86d 100644
--- a/var/spack/repos/builtin/packages/flex/package.py
+++ b/var/spack/repos/builtin/packages/flex/package.py
@@ -113,20 +113,19 @@ class Flex(AutotoolsPackage):
args += self.enable_or_disable("nls")
return args
- @run_after("install")
+ @run_after("install", when="+lex")
def symlink_lex(self):
"""Install symlinks for lex compatibility."""
- if self.spec.satisfies("+lex"):
- dso = dso_suffix
- for dir, flex, lex in (
- (self.prefix.bin, "flex", "lex"),
- (self.prefix.lib, "libfl.a", "libl.a"),
- (self.prefix.lib, "libfl." + dso, "libl." + dso),
- (self.prefix.lib64, "libfl.a", "libl.a"),
- (self.prefix.lib64, "libfl." + dso, "libl." + dso),
- ):
-
- if os.path.isdir(dir):
- with working_dir(dir):
- if os.path.isfile(flex) and not os.path.lexists(lex):
- symlink(flex, lex)
+ dso = dso_suffix
+ for dir, flex, lex in (
+ (self.prefix.bin, "flex", "lex"),
+ (self.prefix.lib, "libfl.a", "libl.a"),
+ (self.prefix.lib, "libfl." + dso, "libl." + dso),
+ (self.prefix.lib64, "libfl.a", "libl.a"),
+ (self.prefix.lib64, "libfl." + dso, "libl." + dso),
+ ):
+
+ if os.path.isdir(dir):
+ with working_dir(dir):
+ if os.path.isfile(flex) and not os.path.lexists(lex):
+ symlink(flex, lex)
diff --git a/var/spack/repos/builtin/packages/gobject-introspection/package.py b/var/spack/repos/builtin/packages/gobject-introspection/package.py
index 9ea90684e8..624d0941f8 100644
--- a/var/spack/repos/builtin/packages/gobject-introspection/package.py
+++ b/var/spack/repos/builtin/packages/gobject-introspection/package.py
@@ -2,15 +2,16 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-
+import spack.build_systems.autotools
import spack.hooks.sbang as sbang
from spack.package import *
-class GobjectIntrospection(MesonPackage):
+class GobjectIntrospection(MesonPackage, AutotoolsPackage):
"""The GObject Introspection is used to describe the program APIs and
collect them in a uniform, machine readable format.Cairo is a 2D graphics
- library with support for multiple output"""
+ library with support for multiple output
+ """
homepage = "https://wiki.gnome.org/Projects/GObjectIntrospection"
url = "https://download.gnome.org/sources/gobject-introspection/1.72/gobject-introspection-1.72.0.tar.xz"
@@ -22,6 +23,12 @@ class GobjectIntrospection(MesonPackage):
version("1.49.2", sha256="73d59470ba1a546b293f54d023fd09cca03a951005745d86d586b9e3a8dde9ac")
version("1.48.0", sha256="fa275aaccdbfc91ec0bc9a6fd0562051acdba731e7d584b64a277fec60e75877")
+ build_system(
+ conditional("autotools", when="@:1.60"),
+ conditional("meson", when="@1.61:"),
+ default="meson",
+ )
+
depends_on("pkgconfig", type="build")
depends_on("bison", type="build")
depends_on("flex", type="build")
@@ -94,22 +101,9 @@ class GobjectIntrospection(MesonPackage):
def parallel(self):
return not self.spec.satisfies("%fj")
- def meson_args(self):
- return []
- @when("@:1.60")
- def meson(self, spec, prefix):
- """Run the AutotoolsPackage configure phase"""
- configure("--prefix={0}".format(prefix))
-
- @when("@:1.60")
- def build(self, spec, prefix):
- """Run the AutotoolsPackage build phase"""
+class AutotoolsBuilderPackage(spack.build_systems.autotools.AutotoolsBuilder):
+ @run_before("build")
+ def filter_file_to_avoid_overly_long_shebangs(self):
# we need to filter this file to avoid an overly long hashbang line
filter_file("#!/usr/bin/env @PYTHON@", "#!@PYTHON@", "tools/g-ir-tool-template.in")
- make()
-
- @when("@:1.60")
- def install(self, spec, prefix):
- """Run the AutotoolsPackage install phase"""
- make("install", parallel=False)
diff --git a/var/spack/repos/builtin/packages/harfbuzz/package.py b/var/spack/repos/builtin/packages/harfbuzz/package.py
index 0400c0a21a..e746ed6fbf 100644
--- a/var/spack/repos/builtin/packages/harfbuzz/package.py
+++ b/var/spack/repos/builtin/packages/harfbuzz/package.py
@@ -2,11 +2,12 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-
+import spack.build_systems.autotools
+import spack.build_systems.meson
from spack.package import *
-class Harfbuzz(MesonPackage):
+class Harfbuzz(MesonPackage, AutotoolsPackage):
"""The Harfbuzz package contains an OpenType text shaping engine."""
homepage = "https://github.com/harfbuzz/harfbuzz"
@@ -14,6 +15,10 @@ class Harfbuzz(MesonPackage):
git = "https://github.com/harfbuzz/harfbuzz.git"
version("5.1.0", sha256="2edb95db668781aaa8d60959d21be2ff80085f31b12053cdd660d9a50ce84f05")
+ build_system(
+ conditional("autotools", when="@:2.9"), conditional("meson", when="@3:"), default="meson"
+ )
+
version("4.2.1", sha256="bd17916513829aeff961359a5ccebba6de2f4bf37a91faee3ac29c120e3d7ee1")
version("4.1.0", sha256="f7984ff4241d4d135f318a93aa902d910a170a8265b7eaf93b5d9a504eed40c8")
version("4.0.1", sha256="98f68777272db6cd7a3d5152bac75083cd52a26176d87bc04c8b3929d33bce49")
@@ -99,31 +104,33 @@ class Harfbuzz(MesonPackage):
def setup_run_environment(self, env):
env.prepend_path("GI_TYPELIB_PATH", join_path(self.prefix.lib, "girepository-1.0"))
- def setup_dependent_build_environment(self, env, dependent_spec):
+ def setup_dependent_run_environment(self, env, dependent_spec):
env.prepend_path("XDG_DATA_DIRS", self.prefix.share)
env.prepend_path("GI_TYPELIB_PATH", join_path(self.prefix.lib, "girepository-1.0"))
- def setup_dependent_run_environment(self, env, dependent_spec):
+ def patch(self):
+ change_sed_delimiter("@", ";", "src/Makefile.in")
+
+
+class SetupEnvironment(object):
+ def setup_dependent_build_environment(self, env, dependent_spec):
env.prepend_path("XDG_DATA_DIRS", self.prefix.share)
env.prepend_path("GI_TYPELIB_PATH", join_path(self.prefix.lib, "girepository-1.0"))
- def meson_args(self):
- args = []
-
- # disable building of gtk-doc files following #9885 and #9771
- args.append("-Ddocs=disabled")
- args.append(
- "-Dgraphite2=" + ("enabled" if self.spec.satisfies("+graphite2") else "disabled")
- )
- if "+coretext" in self.spec:
- args.append("-Dcoretext=enabled")
- elif "~coretext" in self.spec:
- args.append("-Dcoretext=disabled")
+class MesonBuilder(spack.build_systems.meson.MesonBuilder, SetupEnvironment):
+ def meson_args(self):
+ graphite2 = "enabled" if self.pkg.spec.satisfies("+graphite2") else "disabled"
+ coretext = "enabled" if self.pkg.spec.satisfies("+coretext") else "disabled"
+ return [
+ # disable building of gtk-doc files following #9885 and #9771
+ "-Ddocs=disabled",
+ "-Dgraphite2={0}".format(graphite2),
+ "-Dcoretext={0}".format(coretext),
+ ]
- return args
- @when("@:2.9")
+class AutotoolsBuilder(spack.build_systems.autotools.AutotoolsBuilder, SetupEnvironment):
def configure_args(self):
args = []
@@ -135,28 +142,6 @@ class Harfbuzz(MesonPackage):
args.append("GTKDOC_MKPDF={0}".format(true))
args.append("GTKDOC_REBASE={0}".format(true))
args.extend(self.with_or_without("graphite2"))
-
- if "+coretext" in self.spec:
- args.append("--with-coretext")
- elif "~coretext" in self.spec:
- args.append("--without-coretext")
+ args.extend(self.with_or_without("coretext"))
return args
-
- def patch(self):
- change_sed_delimiter("@", ";", "src/Makefile.in")
-
- @when("@:2.9")
- def meson(self, spec, prefix):
- """Run the AutotoolsPackage configure phase"""
- configure("--prefix=" + prefix, *self.configure_args())
-
- @when("@:2.9")
- def build(self, spec, prefix):
- """Run the AutotoolsPackage build phase"""
- make()
-
- @when("@:2.9")
- def install(self, spec, prefix):
- """Run the AutotoolsPackage install phase"""
- make("install")
diff --git a/var/spack/repos/builtin/packages/ibm-databroker/package.py b/var/spack/repos/builtin/packages/ibm-databroker/package.py
index ae80f92439..9c0516844b 100644
--- a/var/spack/repos/builtin/packages/ibm-databroker/package.py
+++ b/var/spack/repos/builtin/packages/ibm-databroker/package.py
@@ -7,7 +7,7 @@
from spack.package import *
-class IbmDatabroker(CMakePackage, PythonPackage):
+class IbmDatabroker(CMakePackage, PythonExtension):
"""The Data Broker (DBR) is a distributed, in-memory container of key-value
stores enabling applications in a workflow to exchange data through one or
more shared namespaces. Thanks to a small set of primitives, applications
diff --git a/var/spack/repos/builtin/packages/intel-tbb/package.py b/var/spack/repos/builtin/packages/intel-tbb/package.py
index 1bc13ac1a3..8921604b08 100644
--- a/var/spack/repos/builtin/packages/intel-tbb/package.py
+++ b/var/spack/repos/builtin/packages/intel-tbb/package.py
@@ -8,10 +8,12 @@ import inspect
import platform
import sys
+import spack.build_systems.cmake
+import spack.build_systems.makefile
from spack.package import *
-class IntelTbb(CMakePackage):
+class IntelTbb(CMakePackage, MakefilePackage):
"""Widely used C++ template library for task parallelism.
Intel Threading Building Blocks (Intel TBB) lets you easily write parallel
C++ programs that take full advantage of multicore performance, that are
@@ -74,6 +76,12 @@ class IntelTbb(CMakePackage):
version("4.4.1", sha256="05737bf6dd220b31aad63d77ca59c742271f81b4cc6643aa6f93d37450ae32b5")
version("4.4", sha256="93c74b6054c69c86fa49d0fce7c50061fc907cb198a7237b8dd058298fd40c0e")
+ build_system(
+ conditional("makefile", when="@:2020.3"),
+ conditional("cmake", when="@2021:"),
+ default="cmake",
+ )
+
provides("tbb")
# Clang builds incorrectly determine GCC version which in turn incorrectly
@@ -161,12 +169,54 @@ class IntelTbb(CMakePackage):
name = "{0}".format(version)
return url.format(name)
+ @property
+ def libs(self):
+ shared = True if "+shared" in self.spec else False
+ return find_libraries("libtbb*", root=self.prefix, shared=shared, recursive=True)
+
+
+class SetupEnvironment(object):
# We set OS here in case the user has it set to something else
# that TBB doesn't expect.
def setup_build_environment(self, env):
env.set("OS", platform.system())
- @when("@:2020.3")
+
+class CMakeBuilder(spack.build_systems.cmake.CMakeBuilder, SetupEnvironment):
+ def cmake_args(self):
+ spec = self.spec
+ options = [
+ self.define("CMAKE_HWLOC_2_INCLUDE_PATH", spec["hwloc"].prefix.include),
+ self.define("CMAKE_HWLOC_2_LIBRARY_PATH", spec["hwloc"].libs),
+ self.define("-DTBB_CPF", True),
+ self.define("TBB_STRICT", False),
+ ]
+ if spec.variants["cxxstd"].value != "default":
+ options.append(self.define("CMAKE_CXX_STANDARD", spec.variants["cxxstd"].value))
+ return options
+
+ @run_after("install")
+ def install_pkgconfig(self):
+ # pkg-config generation is introduced in May 5, 2021.
+ # It must not be overwritten by spack-generated tbb.pc.
+ # https://github.com/oneapi-src/oneTBB/commit/478de5b1887c928e52f029d706af6ea640a877be
+ if self.spec.satisfies("@:2021.2.0", strict=True):
+ mkdirp(self.prefix.lib.pkgconfig)
+
+ with open(join_path(self.prefix.lib.pkgconfig, "tbb.pc"), "w") as f:
+ f.write("prefix={0}\n".format(self.prefix))
+ f.write("exec_prefix=${prefix}\n")
+ f.write("libdir={0}\n".format(self.prefix.lib))
+ f.write("includedir={0}\n".format(self.prefix.include))
+ f.write("\n")
+ f.write("Name: Threading Building Blocks\n")
+ f.write("Description: Intel's parallelism library for C++\n")
+ f.write("Version: {0}\n".format(self.spec.version))
+ f.write("Cflags: -I${includedir}\n")
+ f.write("Libs: -L${libdir} -ltbb -latomic\n")
+
+
+class MakefileBuilder(spack.build_systems.makefile.MakefileBuilder, SetupEnvironment):
def coerce_to_spack(self, tbb_build_subdir):
for compiler in ["icc", "gcc", "clang"]:
fs = glob.glob(join_path(tbb_build_subdir, "*.%s.inc" % compiler))
@@ -183,16 +233,7 @@ class IntelTbb(CMakePackage):
else:
of.write(lin)
- @when("@:2020.3")
- def cmake(self, spec, prefix):
- return
-
- @when("@:2020.3")
- def cmake_args(self):
- return
-
- @when("@:2020.3")
- def build(self, spec, prefix):
+ def build(self, pkg, spec, prefix):
# Deactivate use of RTM with GCC when on an OS with a very old
# assembler.
if (
@@ -239,8 +280,7 @@ class IntelTbb(CMakePackage):
make_opts.append("compiler={0}".format(tbb_compiler))
make(*make_opts)
- @when("@:2020.3")
- def install(self, spec, prefix):
+ def install(self, pkg, spec, prefix):
mkdirp(prefix)
mkdirp(prefix.lib)
@@ -267,46 +307,8 @@ class IntelTbb(CMakePackage):
with working_dir(join_path(self.stage.source_path, "cmake")):
inspect.getmodule(self).cmake(*cmake_args)
- @when("@:2020.3")
@run_after("install")
def darwin_fix(self):
# Replace @rpath in ids with full path
if sys.platform == "darwin":
fix_darwin_install_name(self.prefix.lib)
-
- @property
- def libs(self):
- shared = True if "+shared" in self.spec else False
- return find_libraries("libtbb*", root=self.prefix, shared=shared, recursive=True)
-
- @when("@2021.1.1:")
- def cmake_args(self):
- spec = self.spec
- options = []
- options.append("-DCMAKE_HWLOC_2_INCLUDE_PATH=%s" % spec["hwloc"].prefix.include)
- options.append("-DCMAKE_HWLOC_2_LIBRARY_PATH=%s" % spec["hwloc"].libs)
- options.append("-DTBB_CPF=ON")
- options.append("-DTBB_STRICT=OFF")
- if spec.variants["cxxstd"].value != "default":
- options.append("-DCMAKE_CXX_STANDARD=%s" % spec.variants["cxxstd"].value)
- return options
-
- @run_after("install")
- def install_pkgconfig(self):
- # pkg-config generation is introduced in May 5, 2021.
- # It must not be overwritten by spack-generated tbb.pc.
- # https://github.com/oneapi-src/oneTBB/commit/478de5b1887c928e52f029d706af6ea640a877be
- if self.spec.satisfies("@:2021.2.0", strict=True):
- mkdirp(self.prefix.lib.pkgconfig)
-
- with open(join_path(self.prefix.lib.pkgconfig, "tbb.pc"), "w") as f:
- f.write("prefix={0}\n".format(self.prefix))
- f.write("exec_prefix=${prefix}\n")
- f.write("libdir={0}\n".format(self.prefix.lib))
- f.write("includedir={0}\n".format(self.prefix.include))
- f.write("\n")
- f.write("Name: Threading Building Blocks\n")
- f.write("Description: Intel's parallelism library for C++\n")
- f.write("Version: {0}\n".format(self.spec.version))
- f.write("Cflags: -I${includedir}\n")
- f.write("Libs: -L${libdir} -ltbb -latomic\n")
diff --git a/var/spack/repos/builtin/packages/json-c/package.py b/var/spack/repos/builtin/packages/json-c/package.py
index 559039f21d..a62e0323ea 100644
--- a/var/spack/repos/builtin/packages/json-c/package.py
+++ b/var/spack/repos/builtin/packages/json-c/package.py
@@ -6,7 +6,7 @@
from spack.package import *
-class JsonC(CMakePackage):
+class JsonC(CMakePackage, AutotoolsPackage):
"""A JSON implementation in C."""
homepage = "https://github.com/json-c/json-c/wiki"
@@ -20,7 +20,13 @@ class JsonC(CMakePackage):
version("0.12", sha256="000c01b2b3f82dcb4261751eb71f1b084404fb7d6a282f06074d3c17078b9f3f")
version("0.11", sha256="28dfc65145dc0d4df1dfe7701ac173c4e5f9347176c8983edbfac9149494448c")
- depends_on("autoconf", when="@:0.13.1", type="build")
+ build_system(
+ conditional("cmake", when="@0.14:"),
+ conditional("autotools", when="@:0.13.1"),
+ default="cmake",
+ )
+
+ depends_on("autoconf", when="build_system=autotools", type="build")
parallel = False
@@ -32,19 +38,6 @@ class JsonC(CMakePackage):
"Makefile.in",
)
- @when("@:0.13.1")
- def cmake(self, spec, prefix):
- configure_args = ["--prefix=" + prefix]
- configure(*configure_args)
-
- @when("@:0.13.1")
- def build(self, spec, prefix):
- make()
-
- @when("@:0.13.1")
- def install(self, spec, prefix):
- make("install")
-
@when("%cce@11.0.3:")
def patch(self):
filter_file("-Werror", "", "CMakeLists.txt")
diff --git a/var/spack/repos/builtin/packages/libtree/package.py b/var/spack/repos/builtin/packages/libtree/package.py
index 572f459b43..a1c97dfd76 100644
--- a/var/spack/repos/builtin/packages/libtree/package.py
+++ b/var/spack/repos/builtin/packages/libtree/package.py
@@ -2,11 +2,12 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-
+import spack.build_systems.cmake
+import spack.build_systems.makefile
from spack.package import *
-class Libtree(MakefilePackage):
+class Libtree(MakefilePackage, CMakePackage):
"""ldd as a tree"""
homepage = "https://github.com/haampie/libtree"
@@ -35,6 +36,10 @@ class Libtree(MakefilePackage):
version("1.0.4", sha256="b15a54b6f388b8bd8636e288fcb581029f1e65353660387b0096a554ad8e9e45")
version("1.0.3", sha256="67ce886c191d50959a5727246cdb04af38872cd811c9ed4e3822f77a8f40b20b")
+ build_system(
+ conditional("cmake", when="@:2"), conditional("makefile", when="@3:"), default="makefile"
+ )
+
def url_for_version(self, version):
if version < Version("2.0.0"):
return (
@@ -45,13 +50,8 @@ class Libtree(MakefilePackage):
return "https://github.com/haampie/libtree/archive/refs/tags/v{0}.tar.gz".format(version)
- # Version 3.x (Makefile)
- @when("@3:")
- def install(self, spec, prefix):
- make("install", "PREFIX=" + prefix)
-
# Version 2.x and earlier (CMake)
- with when("@:2"):
+ with when("build_system=cmake"):
variant("chrpath", default=False, description="Use chrpath for deployment")
variant("strip", default=False, description="Use binutils strip for deployment")
variant(
@@ -70,23 +70,19 @@ class Libtree(MakefilePackage):
depends_on("cxxopts", when="@2.0.0:2", type="build")
depends_on("elfio@:3.9", when="@2.0.0:2", type="build")
+
+class CMakeBuilder(spack.build_systems.cmake.CMakeBuilder):
def cmake_args(self):
- tests_enabled = "ON" if self.run_tests else "OFF"
+ tests_enabled = "ON" if self.pkg.run_tests else "OFF"
if self.spec.satisfies("@2.0:"):
tests_define = "LIBTREE_BUILD_TESTS"
else:
tests_define = "BUILD_TESTING"
- return [CMakePackage.define(tests_define, tests_enabled)]
+ return [self.define(tests_define, tests_enabled)]
- @when("@:2")
- def edit(self, spec, prefix):
- options = CMakePackage._std_args(self) + self.cmake_args()
- options.append(self.stage.source_path)
- with working_dir(self.build_directory):
- cmake(*options)
- @when("@:2")
- def check(self):
- with working_dir(self.build_directory):
- ctest("--output-on-failure")
+class MakefileBuilder(spack.build_systems.makefile.MakefileBuilder):
+ @property
+ def install_targets(self):
+ return ["install", "PREFIX=" + self.prefix]
diff --git a/var/spack/repos/builtin/packages/libxkbcommon/package.py b/var/spack/repos/builtin/packages/libxkbcommon/package.py
index b7003ab5a9..054f05e9bd 100644
--- a/var/spack/repos/builtin/packages/libxkbcommon/package.py
+++ b/var/spack/repos/builtin/packages/libxkbcommon/package.py
@@ -2,11 +2,12 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-
+import spack.build_systems.autotools
+import spack.build_systems.meson
from spack.package import *
-class Libxkbcommon(MesonPackage):
+class Libxkbcommon(MesonPackage, AutotoolsPackage):
"""xkbcommon is a library to handle keyboard descriptions, including
loading them from disk, parsing them and handling their state. It's mainly
meant for client toolkits, window systems, and other system
@@ -15,6 +16,10 @@ class Libxkbcommon(MesonPackage):
homepage = "https://xkbcommon.org/"
url = "https://xkbcommon.org/download/libxkbcommon-0.8.2.tar.xz"
+ build_system(
+ conditional("meson", when="@0.9:"), conditional("autotools", when="@:0.8"), default="meson"
+ )
+
version("1.4.0", sha256="106cec5263f9100a7e79b5f7220f889bc78e7d7ffc55d2b6fdb1efefb8024031")
version(
"0.8.2",
@@ -44,6 +49,8 @@ class Libxkbcommon(MesonPackage):
depends_on("wayland@1.2.0:", when="+wayland")
depends_on("wayland-protocols@1.7:", when="+wayland")
+
+class MesonBuilder(spack.build_systems.meson.MesonBuilder):
def meson_args(self):
return [
"-Dxkb-config-root={0}".format(self.spec["xkbdata"].prefix),
@@ -51,26 +58,11 @@ class Libxkbcommon(MesonPackage):
"-Denable-wayland=" + str(self.spec.satisfies("+wayland")),
]
- @when("@:0.8")
+
+class AutotoolsBuilder(spack.build_systems.autotools.AutotoolsBuilder):
def configure_args(self):
"""Configure arguments are passed using meson_args functions"""
return [
"--with-xkb-config-root={0}".format(self.spec["xkbdata"].prefix),
"--disable-docs",
- "--" + ("en" if self.spec.satisfies("+wayland") else "dis") + "able-wayland",
- ]
-
- @when("@:0.8")
- def meson(self, spec, prefix):
- """Run the AutotoolsPackage configure phase in source_path"""
- configure("--prefix=" + prefix, *self.configure_args())
-
- @when("@:0.8")
- def build(self, spec, prefix):
- """Run the AutotoolsPackage build phase in source_path"""
- make()
-
- @when("@:0.8")
- def install(self, spec, prefix):
- """Run the AutotoolsPackage install phase in source_path"""
- make("install")
+ ] + self.enable_or_disable("wayland")
diff --git a/var/spack/repos/builtin/packages/lua/package.py b/var/spack/repos/builtin/packages/lua/package.py
index cd314f3df5..4894ab2b91 100644
--- a/var/spack/repos/builtin/packages/lua/package.py
+++ b/var/spack/repos/builtin/packages/lua/package.py
@@ -26,11 +26,6 @@ class LuaImplPackage(MakefilePackage):
description="Fetcher to use in the LuaRocks package manager",
)
- phases = MakefilePackage.phases + ["add_luarocks"]
- #: This attribute is used in UI queries that need to know the build
- #: system base class
- build_system_class = "LuaImplPackage"
-
lua_version_override = None
def __init__(self, *args, **kwargs):
@@ -105,7 +100,9 @@ class LuaImplPackage(MakefilePackage):
)
symlink(real_lib, "liblua" + ext)
- def add_luarocks(self, spec, prefix):
+ @run_after("install")
+ def add_luarocks(self):
+ prefix = self.spec.prefix
with working_dir(os.path.join("luarocks", "luarocks")):
configure("--prefix=" + prefix, "--with-lua=" + prefix)
make("build")
diff --git a/var/spack/repos/builtin/packages/mesa/package.py b/var/spack/repos/builtin/packages/mesa/package.py
index e82bdc3764..caa47f8d64 100644
--- a/var/spack/repos/builtin/packages/mesa/package.py
+++ b/var/spack/repos/builtin/packages/mesa/package.py
@@ -2,9 +2,9 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-
import sys
+import spack.build_systems.meson
from spack.package import *
@@ -158,6 +158,28 @@ class Mesa(MesonPackage):
flags.append("-std=c99")
return super(Mesa, self).flag_handler(name, flags)
+ @property
+ def libglx_headers(self):
+ return find_headers("GL/glx", root=self.spec.prefix.include, recursive=False)
+
+ @property
+ def libglx_libs(self):
+ return find_libraries("libGL", root=self.spec.prefix, recursive=True)
+
+ @property
+ def libosmesa_headers(self):
+ return find_headers("GL/osmesa", root=self.spec.prefix.include, recursive=False)
+
+ @property
+ def libosmesa_libs(self):
+ if "platform=windows" in self.spec:
+ lib_name = "osmesa"
+ else:
+ lib_name = "libOSMesa"
+ return find_libraries(lib_name, root=self.spec.prefix, recursive=True)
+
+
+class MesonBuilder(spack.build_systems.meson.MesonBuilder):
def meson_args(self):
spec = self.spec
args = [
@@ -274,23 +296,3 @@ class Mesa(MesonPackage):
args.append("-Ddri-drivers=" + ",".join(args_dri_drivers))
return args
-
- @property
- def libglx_headers(self):
- return find_headers("GL/glx", root=self.spec.prefix.include, recursive=False)
-
- @property
- def libglx_libs(self):
- return find_libraries("libGL", root=self.spec.prefix, recursive=True)
-
- @property
- def libosmesa_headers(self):
- return find_headers("GL/osmesa", root=self.spec.prefix.include, recursive=False)
-
- @property
- def libosmesa_libs(self):
- if "platform=windows" in self.spec:
- lib_name = "osmesa"
- else:
- lib_name = "libOSMesa"
- return find_libraries(lib_name, root=self.spec.prefix, recursive=True)
diff --git a/var/spack/repos/builtin/packages/metis/gklib_path.patch b/var/spack/repos/builtin/packages/metis/gklib_path.patch
new file mode 100644
index 0000000000..2cee12d044
--- /dev/null
+++ b/var/spack/repos/builtin/packages/metis/gklib_path.patch
@@ -0,0 +1,11 @@
+--- a/CMakeLists.txt 2022-07-20 21:17:20.352231603 +0200
++++ b/CMakeLists.txt 2022-07-20 21:19:28.998269385 +0200
+@@ -1,7 +1,7 @@
+ cmake_minimum_required(VERSION 2.8)
+ project(METIS)
+
+-set(GKLIB_PATH "GKlib" CACHE PATH "path to GKlib")
++set(GKLIB_PATH "${CMAKE_SOURCE_DIR}/GKlib" CACHE PATH "path to GKlib")
+ set(SHARED FALSE CACHE BOOL "build a shared library")
+
+ if(MSVC)
diff --git a/var/spack/repos/builtin/packages/metis/package.py b/var/spack/repos/builtin/packages/metis/package.py
index edf99be5ee..da6e798783 100644
--- a/var/spack/repos/builtin/packages/metis/package.py
+++ b/var/spack/repos/builtin/packages/metis/package.py
@@ -2,20 +2,22 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-
-
import os
import sys
+import spack.build_systems.cmake
+import spack.build_systems.makefile
from spack.package import *
-class Metis(Package):
+class Metis(CMakePackage, MakefilePackage):
"""METIS is a set of serial programs for partitioning graphs, partitioning
finite element meshes, and producing fill reducing orderings for sparse
- matrices. The algorithms implemented in METIS are based on the
- multilevel recursive-bisection, multilevel k-way, and multi-constraint
- partitioning schemes."""
+ matrices.
+
+ The algorithms implemented in METIS are based on the multilevel
+ recursive-bisection, multilevel k-way, and multi-constraint partitioning schemes.
+ """
homepage = "http://glaros.dtc.umn.edu/gkhome/metis/metis/overview"
url = "http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/metis-5.1.0.tar.gz"
@@ -27,52 +29,29 @@ class Metis(Package):
version("5.1.0", sha256="76faebe03f6c963127dbb73c13eab58c9a3faeae48779f049066a21c087c5db2")
version("4.0.3", sha256="5efa35de80703c1b2c4d0de080fafbcf4e0d363a21149a1ad2f96e0144841a55")
- variant("shared", default=True, description="Enables the build of shared libraries.")
- variant("gdb", default=False, description="Enables gdb support (version 5+).")
- variant("int64", default=False, description="Sets the bit width of METIS's index type to 64.")
- variant("real64", default=False, description="Sets the bit width of METIS's real type to 64.")
-
- # For Metis version 5:, the build system is CMake, provide the
- # `build_type` variant.
- variant(
- "build_type",
- default="Release",
- description="The build type for the installation (only Debug or"
- " Release allowed for version 4).",
- values=("Debug", "Release", "RelWithDebInfo", "MinSizeRel"),
+ build_system(
+ conditional("cmake", when="@5:"), conditional("makefile", when="@:4"), default="cmake"
)
+ variant("shared", default=True, description="Build shared libraries")
+ with when("build_system=cmake"):
+ variant("gdb", default=False, description="Enable gdb support")
+ variant("int64", default=False, description="Use index type of 64 bit")
+ variant("real64", default=False, description="Use real type of 64 bit")
+
+ # Use the correct path to GKLIB when building out of source
+ patch("gklib_path.patch")
+ # Install both gklib_defs.h and gklib_rename.h
+ patch("install_gklib_defs_rename.patch")
+ # Disable the "misleading indentation" warning when compiling
+ patch("gklib_nomisleadingindentation_warning.patch", when="%gcc@6:")
+
+ with when("build_system=makefile"):
+ variant("debug", default=False, description="Compile in debug mode")
- # Prior to version 5, the (non-cmake) build system only knows about
- # 'build_type=Debug|Release'.
- conflicts("@:4", when="build_type=RelWithDebInfo")
- conflicts("@:4", when="build_type=MinSizeRel")
- conflicts("@:4", when="+gdb")
- conflicts("@:4", when="+int64")
- conflicts("@:4", when="+real64")
-
- depends_on("cmake@2.8:", when="@5:", type="build")
-
- patch("install_gklib_defs_rename.patch", when="@5:")
- patch("gklib_nomisleadingindentation_warning.patch", when="@5: %gcc@6:")
-
- def setup_build_environment(self, env):
- # Ignore warnings/errors re unrecognized omp pragmas on %intel
- if "%intel@14:" in self.spec:
- env.append_flags("CFLAGS", "-diag-disable 3180")
- # Ignore some warnings to get it to compile with %nvhpc
- # 111: statement is unreachable
- # 177: variable "foo" was declared but never referenced
- # 188: enumerated type mixed with another type
- # 550: variable "foo" was set but never used
- if "%nvhpc" in self.spec:
- env.append_flags("CFLAGS", "--display_error_number")
- env.append_flags("CFLAGS", "--diag_suppress 111")
- env.append_flags("CFLAGS", "--diag_suppress 177")
- env.append_flags("CFLAGS", "--diag_suppress 188")
- env.append_flags("CFLAGS", "--diag_suppress 550")
-
- @when("@5:")
def patch(self):
+ if not self.spec.satisfies("build_system=cmake"):
+ return
+
source_path = self.stage.source_path
metis_header = FileFilter(join_path(source_path, "include", "metis.h"))
@@ -96,18 +75,38 @@ class Metis(Package):
join_path(source_path, "GKlib", "error.c"),
)
- @when("@:4")
- def install(self, spec, prefix):
- # Process library spec and options
+
+class SetupEnvironment(object):
+ def setup_build_environment(self, env):
+ # Ignore warnings/errors re unrecognized omp pragmas on %intel
+ if "%intel@14:" in self.spec:
+ env.append_flags("CFLAGS", "-diag-disable 3180")
+ # Ignore some warnings to get it to compile with %nvhpc
+ # 111: statement is unreachable
+ # 177: variable "foo" was declared but never referenced
+ # 188: enumerated type mixed with another type
+ # 550: variable "foo" was set but never used
+ if "%nvhpc" in self.spec:
+ env.append_flags("CFLAGS", "--display_error_number")
+ env.append_flags("CFLAGS", "--diag_suppress 111")
+ env.append_flags("CFLAGS", "--diag_suppress 177")
+ env.append_flags("CFLAGS", "--diag_suppress 188")
+ env.append_flags("CFLAGS", "--diag_suppress 550")
+
+
+class MakefileBuilder(spack.build_systems.makefile.MakefileBuilder, SetupEnvironment):
+ @property
+ def build_targets(self):
options = []
- if "+shared" in spec:
- options.append("COPTIONS={0}".format(self.compiler.cc_pic_flag))
- if spec.variants["build_type"].value == "Debug":
+ if "+shared" in self.spec:
+ options.append("COPTIONS={0}".format(self.pkg.compiler.cc_pic_flag))
+ if "+debug" in self.spec:
options.append("OPTFLAGS=-g -O0")
- make(*options)
+ return options
+ def install(self, pkg, spec, prefix):
# Compile and install library files
- ccompile = Executable(self.compiler.cc)
+ ccompile = Executable(pkg.compiler.cc)
mkdir(prefix.bin)
binfiles = (
@@ -140,7 +139,7 @@ class Metis(Package):
install(sharefile, prefix.share)
if "+shared" in spec:
- shared_flags = [self.compiler.cc_pic_flag, "-shared"]
+ shared_flags = [pkg.compiler.cc_pic_flag, "-shared"]
if sys.platform == "darwin":
shared_suffix = "dylib"
shared_flags.extend(["-Wl,-all_load", "libmetis.a"])
@@ -157,7 +156,7 @@ class Metis(Package):
ccompile(
"-I%s" % prefix.include,
"-L%s" % prefix.lib,
- (self.compiler.cc_rpath_arg + prefix.lib if "+shared" in spec else ""),
+ (pkg.compiler.cc_rpath_arg + prefix.lib if "+shared" in spec else ""),
join_path("Programs", "io.o"),
join_path("Test", "mtest.c"),
"-o",
@@ -166,58 +165,32 @@ class Metis(Package):
"-lm",
)
- if self.run_tests:
- test_bin = lambda testname: join_path(prefix.bin, testname)
- test_graph = lambda graphname: join_path(prefix.share, graphname)
-
- graph = test_graph("4elt.graph")
- os.system("%s %s" % (test_bin("mtest"), graph))
- os.system("%s %s 40" % (test_bin("kmetis"), graph))
- os.system("%s %s" % (test_bin("onmetis"), graph))
- graph = test_graph("test.mgraph")
- os.system("%s %s 2" % (test_bin("pmetis"), graph))
- os.system("%s %s 2" % (test_bin("kmetis"), graph))
- os.system("%s %s 5" % (test_bin("kmetis"), graph))
- graph = test_graph("metis.mesh")
- os.system("%s %s 10" % (test_bin("partnmesh"), graph))
- os.system("%s %s 10" % (test_bin("partdmesh"), graph))
- os.system("%s %s" % (test_bin("mesh2dual"), graph))
-
- # FIXME: The following code should replace the testing code in the
- # block above since it causes installs to fail when one or more of
- # the Metis tests fail, but it currently doesn't work because the
- # 'mtest', 'onmetis', and 'partnmesh' tests return error codes that
- # trigger false positives for failure.
- """
- Executable(test_bin('mtest'))(test_graph('4elt.graph'))
- Executable(test_bin('kmetis'))(test_graph('4elt.graph'), '40')
- Executable(test_bin('onmetis'))(test_graph('4elt.graph'))
-
- Executable(test_bin('pmetis'))(test_graph('test.mgraph'), '2')
- Executable(test_bin('kmetis'))(test_graph('test.mgraph'), '2')
- Executable(test_bin('kmetis'))(test_graph('test.mgraph'), '5')
-
- Executable(test_bin('partnmesh'))(test_graph('metis.mesh'), '10')
- Executable(test_bin('partdmesh'))(test_graph('metis.mesh'), '10')
- Executable(test_bin('mesh2dual'))(test_graph('metis.mesh'))
- """
-
- @when("@5:")
- def install(self, spec, prefix):
- source_directory = self.stage.source_path
- build_directory = join_path(self.stage.path, "build")
-
- options = CMakePackage._std_args(self)
- options.append("-DGKLIB_PATH:PATH=%s/GKlib" % source_directory)
-
- # Normally this is available via the 'CMakePackage' object, but metis
- # IS-A 'Package' (not a 'CMakePackage') to support non-cmake metis@:5.
- build_type = spec.variants["build_type"].value
- options.extend(["-DCMAKE_BUILD_TYPE:STRING={0}".format(build_type)])
-
- if "+shared" in spec:
- options.append("-DSHARED:BOOL=ON")
- else:
+ def check(self):
+ test_bin = lambda testname: join_path(prefix.bin, testname)
+ test_graph = lambda graphname: join_path(prefix.share, graphname)
+
+ graph = test_graph("4elt.graph")
+ os.system("%s %s" % (test_bin("mtest"), graph))
+ os.system("%s %s 40" % (test_bin("kmetis"), graph))
+ os.system("%s %s" % (test_bin("onmetis"), graph))
+ graph = test_graph("test.mgraph")
+ os.system("%s %s 2" % (test_bin("pmetis"), graph))
+ os.system("%s %s 2" % (test_bin("kmetis"), graph))
+ os.system("%s %s 5" % (test_bin("kmetis"), graph))
+ graph = test_graph("metis.mesh")
+ os.system("%s %s 10" % (test_bin("partnmesh"), graph))
+ os.system("%s %s 10" % (test_bin("partdmesh"), graph))
+ os.system("%s %s" % (test_bin("mesh2dual"), graph))
+
+
+class CMakeBuilder(spack.build_systems.cmake.CMakeBuilder, SetupEnvironment):
+ def cmake_args(self):
+ options = [
+ self.define_from_variant("SHARED", "shared"),
+ self.define_from_variant("GDB", "gdb"),
+ ]
+
+ if self.spec.satisfies("~shared"):
# Remove all RPATH options
# (RPATHxxx options somehow trigger cmake to link dynamically)
rpath_options = []
@@ -226,40 +199,41 @@ class Metis(Package):
rpath_options.append(o)
for o in rpath_options:
options.remove(o)
- if "+gdb" in spec:
- options.append("-DGDB:BOOL=ON")
- with working_dir(build_directory, create=True):
- cmake(source_directory, *options)
- make()
- make("install")
+ return options
+ @run_after("install")
+ def install_headers(self):
+ with working_dir(self.build_directory):
# install all headers, which will be needed for ParMETIS and other programs
- subdirs = ["GKlib", "libmetis", "programs"]
- for subd in subdirs:
- inc_dist = join_path(prefix.include, subd)
+ directories = ["GKlib", "libmetis", "programs"]
+ for directory in directories:
+ inc_dist = join_path(self.prefix.include, directory)
mkdirp(inc_dist)
- install(join_path(source_directory, subd, "*.h"), inc_dist)
-
- if self.run_tests:
- # FIXME: On some systems, the installed binaries for METIS cannot
- # be executed without first being read.
- ls = which("ls")
- ls("-a", "-l", prefix.bin)
-
- for f in ["4elt", "copter2", "mdual"]:
- graph = join_path(source_directory, "graphs", "%s.graph" % f)
- Executable(join_path(prefix.bin, "graphchk"))(graph)
- Executable(join_path(prefix.bin, "gpmetis"))(graph, "2")
- Executable(join_path(prefix.bin, "ndmetis"))(graph)
-
- graph = join_path(source_directory, "graphs", "test.mgraph")
- Executable(join_path(prefix.bin, "gpmetis"))(graph, "2")
- graph = join_path(source_directory, "graphs", "metis.mesh")
- Executable(join_path(prefix.bin, "mpmetis"))(graph, "2")
-
- @run_after("install")
+ install(join_path(self.stage.source_path, directory, "*.h"), inc_dist)
+
+ def check(self):
+ # On some systems, the installed binaries for METIS cannot
+ # be executed without first being read.
+ ls = which("ls")
+ ls("-a", "-l", self.prefix.bin)
+
+ graphchk = Executable(join_path(self.prefix.bin, "graphchk"))
+ gpmetis = Executable(join_path(self.prefix.bin, "gpmetis"))
+ ndmetis = Executable(join_path(self.prefix.bin, "ndmetis"))
+ mpmetis = Executable(join_path(self.prefix.bin, "mpmetis"))
+ for f in ["4elt", "copter2", "mdual"]:
+ graph = join_path(self.stage.source_path, "graphs", "%s.graph" % f)
+ graphchk(graph)
+ gpmetis(graph, "2")
+ ndmetis(graph)
+
+ graph = join_path(self.stage.source_path, "graphs", "test.mgraph")
+ gpmetis(graph, "2")
+ graph = join_path(self.stage.source_path, "graphs", "metis.mesh")
+ mpmetis(graph, "2")
+
+ @run_after("install", when="+shared platform=darwin")
def darwin_fix(self):
# The shared library is not installed correctly on Darwin; fix this
- if (sys.platform == "darwin") and ("+shared" in self.spec):
- fix_darwin_install_name(prefix.lib)
+ fix_darwin_install_name(prefix.lib)
diff --git a/var/spack/repos/builtin/packages/mmg/package.py b/var/spack/repos/builtin/packages/mmg/package.py
index f0269ca430..3cd579dff1 100644
--- a/var/spack/repos/builtin/packages/mmg/package.py
+++ b/var/spack/repos/builtin/packages/mmg/package.py
@@ -5,6 +5,7 @@
import os
+import spack.build_systems.cmake
from spack.package import *
from spack.util.executable import which
@@ -43,24 +44,22 @@ class Mmg(CMakePackage):
depends_on("doxygen", when="+doc")
depends_on("vtk", when="+vtk")
- def cmake_args(self):
- args = []
-
- args.append(self.define_from_variant("USE_SCOTCH", "scotch"))
- args.append(self.define_from_variant("USE_VTK", "vtk"))
- if "+shared" in self.spec:
- args.append("-DLIBMMG3D_SHARED=ON")
- args.append("-DLIBMMG2D_SHARED=ON")
- args.append("-DLIBMMGS_SHARED=ON")
- args.append("-DLIBMMG_SHARED=ON")
- else:
- args.append("-DLIBMMG3D_STATIC=ON")
- args.append("-DLIBMMG2D_STATIC=ON")
- args.append("-DLIBMMGS_STATIC=ON")
- args.append("-DLIBMMG_STATIC=ON")
-
- return args
+class CMakeBuilder(spack.build_systems.cmake.CMakeBuilder):
+ def cmake_args(self):
+ shared_active = self.spec.satisfies("+shared")
+ return [
+ self.define_from_variant("USE_SCOTCH", "scotch"),
+ self.define_from_variant("USE_VTK", "vtk"),
+ self.define("LIBMMG3D_SHARED", shared_active),
+ self.define("LIBMMG2D_SHARED", shared_active),
+ self.define("LIBMMGS_SHARED", shared_active),
+ self.define("LIBMMG_SHARED", shared_active),
+ self.define("LIBMMG3D_STATIC", not shared_active),
+ self.define("LIBMMG2D_STATIC", not shared_active),
+ self.define("LIBMMGS_STATIC", not shared_active),
+ self.define("LIBMMG_STATIC", not shared_active),
+ ]
# parmmg requires this for its build
@run_after("install")
diff --git a/var/spack/repos/builtin/packages/nasm/package.py b/var/spack/repos/builtin/packages/nasm/package.py
index e7d76b1d8f..5514b26b5e 100644
--- a/var/spack/repos/builtin/packages/nasm/package.py
+++ b/var/spack/repos/builtin/packages/nasm/package.py
@@ -8,7 +8,7 @@ import os
from spack.package import *
-class Nasm(Package):
+class Nasm(AutotoolsPackage):
"""NASM (Netwide Assembler) is an 80x86 assembler designed for
portability and modularity. It includes a disassembler as well."""
@@ -17,6 +17,8 @@ class Nasm(Package):
list_url = "https://www.nasm.us/pub/nasm/releasebuilds"
list_depth = 1
+ build_system("autotools", conditional("generic", when="platform=windows"), default="autotools")
+
version("2.15.05", sha256="9182a118244b058651c576baa9d0366ee05983c4d4ae1d9ddd3236a9f2304997")
version("2.14.02", sha256="b34bae344a3f2ed93b2ca7bf25f1ed3fb12da89eeda6096e3551fd66adeae9fc")
version("2.13.03", sha256="23e1b679d64024863e2991e5c166e19309f0fe58a9765622b35bd31be5b2cc99")
@@ -31,11 +33,11 @@ class Nasm(Package):
when="@2.13.03 %gcc@8:",
)
- patch("msvc.mak.patch", when="@2.15.05 platform=windows")
-
- conflicts("%intel@:14", when="@2.14:", msg="Intel 14 has immature C11 support")
+ with when("platform=windows"):
+ depends_on("perl")
+ patch("msvc.mak.patch", when="@2.15.05")
- depends_on("perl", when="platform=windows")
+ conflicts("%intel@:14", when="@2.14:", msg="Intel <= 14 lacks support for C11")
def patch(self):
# Remove flags not recognized by the NVIDIA compiler
@@ -51,13 +53,8 @@ class Nasm(Package):
"configure",
)
- def install(self, spec, prefix):
- with working_dir(self.stage.source_path, create=True):
- configure(*["--prefix={0}".format(self.prefix)])
- make("V=1")
- make("install")
- @when("platform=windows")
+class GenericBuilder(spack.build_systems.generic.GenericBuilder):
def install(self, spec, prefix):
with working_dir(self.stage.source_path, create=True):
# build NASM with nmake
diff --git a/var/spack/repos/builtin/packages/netlib-lapack/package.py b/var/spack/repos/builtin/packages/netlib-lapack/package.py
index 4908fc1b9d..387657d1ca 100644
--- a/var/spack/repos/builtin/packages/netlib-lapack/package.py
+++ b/var/spack/repos/builtin/packages/netlib-lapack/package.py
@@ -2,7 +2,7 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-
+import spack.build_systems.cmake
from spack.package import *
@@ -55,6 +55,8 @@ class NetlibLapack(CMakePackage):
# netlib-lapack is the reference implementation of LAPACK
for ver in [
+ "3.10.1",
+ "3.10.0",
"3.9.1",
"3.9.0",
"3.8.0",
@@ -182,82 +184,53 @@ class NetlibLapack(CMakePackage):
lapacke_h = join_path(include_dir, "lapacke.h")
return HeaderList([cblas_h, lapacke_h])
- @property
- def build_directory(self):
- return join_path(
- self.stage.source_path,
- "spack-build-shared" if self._building_shared else "spack-build-static",
- )
+class CMakeBuilder(spack.build_systems.cmake.CMakeBuilder):
def cmake_args(self):
- args = ["-DBUILD_SHARED_LIBS:BOOL=" + ("ON" if self._building_shared else "OFF")]
-
- if self.spec.satisfies("+lapacke"):
- args.extend(["-DLAPACKE:BOOL=ON", "-DLAPACKE_WITH_TMG:BOOL=ON"])
- else:
- args.extend(["-DLAPACKE:BOOL=OFF", "-DLAPACKE_WITH_TMG:BOOL=OFF"])
-
- if self.spec.satisfies("@3.6.0:"):
- args.append("-DCBLAS=ON") # always build CBLAS
+ args = [
+ self.define_from_variant("BUILD_SHARED_LIBS", "shared"),
+ self.define_from_variant("LAPACKE", "lapacke"),
+ self.define_from_variant("LAPACKE_WITH_TMG", "lapacke"),
+ self.define("CBLAS", self.spec.satisfies("@3.6.0:")),
+ ]
if self.spec.satisfies("%intel"):
# Intel compiler finds serious syntax issues when trying to
# build CBLAS and LapackE
- args.extend(["-DCBLAS=OFF", "-DLAPACKE:BOOL=OFF"])
+ args.extend([self.define("CBLAS", False), self.define("LAPACKE", False)])
if self.spec.satisfies("%xl") or self.spec.satisfies("%xl_r"):
# use F77 compiler if IBM XL
args.extend(
[
- "-DCMAKE_Fortran_COMPILER=" + self.compiler.f77,
- "-DCMAKE_Fortran_FLAGS="
- + (" ".join(self.spec.compiler_flags["fflags"]))
- + " -O3 -qnohot",
+ self.define("CMAKE_Fortran_COMPILER", self.compiler.f77),
+ self.define(
+ "CMAKE_Fortran_FLAGS",
+ " ".join(self.spec.compiler_flags["fflags"]) + " -O3 -qnohot",
+ ),
]
)
# deprecated routines are commonly needed by, for example, suitesparse
# Note that OpenBLAS spack is built with deprecated routines
- args.append("-DBUILD_DEPRECATED:BOOL=ON")
+ args.append(self.define("BUILD_DEPRECATED", True))
if self.spec.satisfies("+external-blas"):
args.extend(
[
- "-DUSE_OPTIMIZED_BLAS:BOOL=ON",
- "-DBLAS_LIBRARIES:PATH=" + self.spec["blas"].libs.joined(";"),
+ self.define("USE_OPTIMIZED_BLAS", True),
+ self.define("BLAS_LIBRARIES:PATH", self.spec["blas"].libs.joined(";")),
]
)
if self.spec.satisfies("+xblas"):
args.extend(
[
- "-DXBLAS_INCLUDE_DIR=" + self.spec["netlib-xblas"].prefix.include,
- "-DXBLAS_LIBRARY=" + self.spec["netlib-xblas"].libs.joined(";"),
+ self.define("XBLAS_INCLUDE_DIR", self.spec["netlib-xblas"].prefix.include),
+ self.define("XBLAS_LIBRARY", self.spec["netlib-xblas"].libs.joined(";")),
]
)
- args.append("-DBUILD_TESTING:BOOL=" + ("ON" if self.run_tests else "OFF"))
+ args.append(self.define("BUILD_TESTING", self.pkg.run_tests))
return args
-
- # Build, install, and check both static and shared versions of the
- # libraries when +shared
- @when("+shared")
- def cmake(self, spec, prefix):
- for self._building_shared in (False, True):
- super(NetlibLapack, self).cmake(spec, prefix)
-
- @when("+shared")
- def build(self, spec, prefix):
- for self._building_shared in (False, True):
- super(NetlibLapack, self).build(spec, prefix)
-
- @when("+shared")
- def install(self, spec, prefix):
- for self._building_shared in (False, True):
- super(NetlibLapack, self).install(spec, prefix)
-
- @when("+shared")
- def check(self):
- for self._building_shared in (False, True):
- super(NetlibLapack, self).check()
diff --git a/var/spack/repos/builtin/packages/openmpi/package.py b/var/spack/repos/builtin/packages/openmpi/package.py
index e1a34ac6b3..9405951c35 100644
--- a/var/spack/repos/builtin/packages/openmpi/package.py
+++ b/var/spack/repos/builtin/packages/openmpi/package.py
@@ -1053,8 +1053,7 @@ class Openmpi(AutotoolsPackage, CudaPackage):
return config_args
- @when("+wrapper-rpath")
- @run_after("install")
+ @run_after("install", when="+wrapper-rpath")
def filter_rpaths(self):
def filter_lang_rpaths(lang_tokens, rpath_arg):
if self.compiler.cc_rpath_arg == rpath_arg:
@@ -1086,8 +1085,7 @@ class Openmpi(AutotoolsPackage, CudaPackage):
filter_lang_rpaths(["c++", "CC", "cxx"], self.compiler.cxx_rpath_arg)
filter_lang_rpaths(["fort", "f77", "f90"], self.compiler.fc_rpath_arg)
- @when("@:3.0.4+wrapper-rpath")
- @run_after("install")
+ @run_after("install", when="@:3.0.4+wrapper-rpath")
def filter_pc_files(self):
files = find(self.spec.prefix.lib.pkgconfig, "*.pc")
x = FileFilter(*[f for f in files if not os.path.islink(f)])
diff --git a/var/spack/repos/builtin/packages/plasma/package.py b/var/spack/repos/builtin/packages/plasma/package.py
index 5e32b5af31..f6f32d0629 100644
--- a/var/spack/repos/builtin/packages/plasma/package.py
+++ b/var/spack/repos/builtin/packages/plasma/package.py
@@ -2,7 +2,8 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-
+import spack.build_systems.cmake
+import spack.build_systems.makefile
from spack.package import *
@@ -38,6 +39,12 @@ class Plasma(CMakePackage):
url="https://github.com/icl-utk-edu/plasma/releases/download/17.01/plasma-17.01.tar.gz",
)
+ build_system(
+ conditional("makefile", when="@:17.1"),
+ conditional("cmake", when="@18.9:"),
+ default="cmake",
+ )
+
variant("shared", default=True, description="Build shared library (disables static library)")
variant("lua", default=False, description="Build Lua support for tuning tile sizes")
@@ -82,18 +89,15 @@ class Plasma(CMakePackage):
def patch(self):
python("tools/generate_precisions.py")
- @when("@18.9.0:")
- def cmake_args(self):
- options = list()
-
- options.extend(
- [
- "-DBLAS_LIBRARIES=%s" % self.spec["blas"].libs.joined(";"),
- "-DLAPACK_LIBRARIES=%s" % self.spec["lapack"].libs.joined(";"),
- ]
- )
- options += ["-DBUILD_SHARED_LIBS=%s" % ("ON" if ("+shared" in self.spec) else "OFF")]
+class CMakeBuilder(spack.build_systems.cmake.CMakeBuilder):
+ def cmake_args(self):
+ options = [
+ self.define("BLAS_LIBRARIES", self.spec["blas"].libs.joined(";")),
+ self.define("LAPACK_LIBRARIES", self.spec["lapack"].libs.joined(";")),
+ self.define_from_variant("BUILD_SHARED_LIBS", "shared"),
+ self.define_from_variant("PLASMA_DETECT_LUA", "lua"),
+ ]
for package, provider in (
("openblas", "openblas"),
@@ -102,32 +106,13 @@ class Plasma(CMakePackage):
):
if package in self.spec:
for lib in ("CBLAS", "LAPACKE"):
- options.append("-D%s_PROVIDER=%s" % (lib, provider))
-
- if "lua" in self.spec:
- options.append("-DPLASMA_DETECT_LUA=TRUE")
+ options.append(self.define("{}_PROVIDER".format(lib), provider))
return options
- # Before 18.9.0 it was an Makefile package
- @when("@:17.1")
- def cmake(self, spec, prefix):
- pass
-
- # Before 18.9.0 it was an Makefile package
- @when("@:17.1")
- def build(self, spec, prefix):
- pass
-
- # Before 18.9.0 it was an Makefile package
- @when("@:17.1")
- def install(self, spec, prefix):
- self.edit(spec, prefix)
- make()
- make("install")
-
- @when("@:17.1")
- def edit(self, spec, prefix):
+
+class MakefileBuilder(spack.build_systems.makefile.MakefileBuilder):
+ def edit(self, pkg, spec, prefix):
# copy "make.inc.mkl-gcc" provided by default into "make.inc"
open("make.inc", "w").write(open("make.inc.mkl-gcc").read())
diff --git a/var/spack/repos/builtin/packages/py-dm-tree/package.py b/var/spack/repos/builtin/packages/py-dm-tree/package.py
index 36dcdc910f..1c8b7eca36 100644
--- a/var/spack/repos/builtin/packages/py-dm-tree/package.py
+++ b/var/spack/repos/builtin/packages/py-dm-tree/package.py
@@ -26,20 +26,23 @@ class PyDmTree(PythonPackage):
depends_on("bazel", type="build")
depends_on("py-six@1.12.0:", type=("build", "run"))
+ # This is set later
+ tmp_path = None
+
@run_after("install")
def clean(self):
- remove_linked_tree(self.tmp_path)
+ remove_linked_tree(PyDmTree.tmp_path)
def patch(self):
- self.tmp_path = tempfile.mkdtemp(prefix="spack")
- env["TEST_TMPDIR"] = self.tmp_path
- env["HOME"] = self.tmp_path
+ PyDmTree.tmp_path = tempfile.mkdtemp(prefix="spack")
+ env["TEST_TMPDIR"] = PyDmTree.tmp_path
+ env["HOME"] = PyDmTree.tmp_path
args = [
# Don't allow user or system .bazelrc to override build settings
"'--nohome_rc',\n",
"'--nosystem_rc',\n",
# Bazel does not work properly on NFS, switch to /tmp
- "'--output_user_root={0}',\n".format(self.tmp_path),
+ "'--output_user_root={0}',\n".format(PyDmTree.tmp_path),
"'build',\n",
# Spack logs don't handle colored output well
"'--color=no',\n",
diff --git a/var/spack/repos/builtin/packages/py-onnx-runtime/package.py b/var/spack/repos/builtin/packages/py-onnx-runtime/package.py
index 62ea531395..fa956086b8 100644
--- a/var/spack/repos/builtin/packages/py-onnx-runtime/package.py
+++ b/var/spack/repos/builtin/packages/py-onnx-runtime/package.py
@@ -6,7 +6,7 @@
from spack.package import *
-class PyOnnxRuntime(CMakePackage, PythonPackage):
+class PyOnnxRuntime(CMakePackage, PythonExtension):
"""ONNX Runtime is a performance-focused complete scoring
engine for Open Neural Network Exchange (ONNX) models, with
an open extensible architecture to continually address the
diff --git a/var/spack/repos/builtin/packages/py-pillow/package.py b/var/spack/repos/builtin/packages/py-pillow/package.py
index 8f3488fce3..aa98037062 100644
--- a/var/spack/repos/builtin/packages/py-pillow/package.py
+++ b/var/spack/repos/builtin/packages/py-pillow/package.py
@@ -15,6 +15,18 @@ class PyPillowBase(PythonPackage):
# These defaults correspond to Pillow defaults
# https://pillow.readthedocs.io/en/stable/installation.html#external-libraries
+ VARIANTS_IN_SETUP_CFG = (
+ "zlib",
+ "jpeg",
+ "tiff",
+ "freetype",
+ "lcms",
+ "webp",
+ "webpmux",
+ "jpeg2000",
+ "imagequant",
+ "xcb",
+ )
variant("zlib", default=True, description="Compressed PNG functionality")
variant("jpeg", default=True, description="JPEG functionality")
variant("tiff", default=False, description="Compressed TIFF functionality")
@@ -79,8 +91,7 @@ class PyPillowBase(PythonPackage):
with open("setup.cfg", "a") as setup:
setup.write("[build_ext]\n")
- variants = list(self.spec.variants)
- for variant in variants:
+ for variant in self.VARIANTS_IN_SETUP_CFG:
setup.write(variant_to_cfg(variant))
setup.write("rpath={0}\n".format(":".join(self.rpath)))
diff --git a/var/spack/repos/builtin/packages/py-pybind11/package.py b/var/spack/repos/builtin/packages/py-pybind11/package.py
index b8a234c668..d50bdeef8e 100644
--- a/var/spack/repos/builtin/packages/py-pybind11/package.py
+++ b/var/spack/repos/builtin/packages/py-pybind11/package.py
@@ -2,13 +2,14 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-
import os
+import spack.build_systems.cmake
+import spack.build_systems.python
from spack.package import *
-class PyPybind11(CMakePackage, PythonPackage):
+class PyPybind11(CMakePackage, PythonExtension):
"""pybind11 -- Seamless operability between C++11 and Python.
pybind11 is a lightweight header-only library that exposes C++ types in
@@ -16,7 +17,8 @@ class PyPybind11(CMakePackage, PythonPackage):
code. Its goals and syntax are similar to the excellent Boost.Python
library by David Abrahams: to minimize boilerplate code in traditional
extension modules by inferring type information using compile-time
- introspection."""
+ introspection.
+ """
homepage = "https://pybind11.readthedocs.io"
url = "https://github.com/pybind/pybind11/archive/v2.6.2.tar.gz"
@@ -26,6 +28,7 @@ class PyPybind11(CMakePackage, PythonPackage):
version("master", branch="master")
version("2.10.0", sha256="eacf582fa8f696227988d08cfc46121770823839fe9e301a20fbce67e7cd70ec")
+ version("2.9.2", sha256="6bd528c4dbe2276635dc787b6b1f2e5316cf6b49ee3e150264e455a0d68d19c1")
version("2.9.1", sha256="c6160321dc98e6e1184cc791fbeadd2907bb4a0ce0e447f2ea4ff8ab56550913")
version("2.9.0", sha256="057fb68dafd972bc13afb855f3b0d8cf0fa1a78ef053e815d9af79be7ff567cb")
version("2.8.1", sha256="f1bcc07caa568eb312411dde5308b1e250bd0e1bc020fae855bf9f43209940cc")
@@ -45,30 +48,25 @@ class PyPybind11(CMakePackage, PythonPackage):
version("2.1.1", sha256="f2c6874f1ea5b4ad4ffffe352413f7d2cd1a49f9050940805c2a082348621540")
version("2.1.0", sha256="2860f2b8d0c9f65f0698289a161385f59d099b7ead1bf64e8993c486f2b93ee0")
- depends_on("ninja", type="build")
depends_on("py-setuptools@42:", type="build")
depends_on("py-pytest", type="test")
depends_on("python@2.7:2.8,3.5:", type=("build", "run"))
depends_on("python@3.6:", when="@2.10.0:", type=("build", "run"))
- depends_on("cmake@3.13:", type="build")
- depends_on("cmake@3.18:", type="build", when="@2.6.0:")
+
+ depends_on("py-pip", type="build")
+ depends_on("py-wheel", type="build")
+ extends("python")
+
+ with when("build_system=cmake"):
+ depends_on("ninja", type="build")
+ depends_on("cmake@3.13:", type="build")
+ depends_on("cmake@3.18:", type="build", when="@2.6.0:")
# compiler support
conflicts("%gcc@:4.7")
conflicts("%clang@:3.2")
conflicts("%intel@:16")
- build_directory = "."
-
- def cmake_args(self):
- args = []
- args.append("-DPYTHON_EXECUTABLE:FILEPATH=%s" % self.spec["python"].command.path)
- args += [self.define("PYBIND11_TEST", self.run_tests)]
- return args
-
- def setup_build_environment(self, env):
- env.set("PYBIND11_USE_CMAKE", 1)
-
# https://github.com/pybind/pybind11/pull/1995
@when("@:2.4")
def patch(self):
@@ -80,13 +78,27 @@ class PyPybind11(CMakePackage, PythonPackage):
string=True,
)
- def install(self, spec, prefix):
- CMakePackage.install(self, spec, prefix)
- PythonPackage.install(self, spec, prefix)
+
+class CMakeBuilder(spack.build_systems.cmake.CMakeBuilder):
+ def cmake_args(self):
+ return [
+ self.define("PYTHON_EXECUTABLE:FILEPATH", self.spec["python"].command.path),
+ self.define("PYBIND11_TEST", self.pkg.run_tests),
+ ]
+
+ def install(self, pkg, spec, prefix):
+ super(CMakeBuilder, self).install(pkg, spec, prefix)
+ python_builder = spack.build_systems.python.PythonPipBuilder(pkg)
+ python_builder.install(pkg, spec, prefix)
+
+ def setup_build_environment(self, env):
+ env.set("PYBIND11_USE_CMAKE", 1)
@run_after("install")
- @on_package_attributes(run_tests=True)
def install_test(self):
+ if not self.pkg.run_tests:
+ return
+
with working_dir("spack-test", create=True):
# test include helper points to right location
python = self.spec["python"].command
diff --git a/var/spack/repos/builtin/packages/py-pykokkos-base/package.py b/var/spack/repos/builtin/packages/py-pykokkos-base/package.py
index 5d3427b4bb..f9b02c9ae9 100644
--- a/var/spack/repos/builtin/packages/py-pykokkos-base/package.py
+++ b/var/spack/repos/builtin/packages/py-pykokkos-base/package.py
@@ -8,7 +8,7 @@
from spack.package import *
-class PyPykokkosBase(CMakePackage, PythonPackage):
+class PyPykokkosBase(CMakePackage, PythonExtension):
"""Minimal set of bindings for Kokkos interoperability with Python
(initialize, finalize, View, DynRankView, Kokkos-tools)"""
diff --git a/var/spack/repos/builtin/packages/py-tfdlpack/package.py b/var/spack/repos/builtin/packages/py-tfdlpack/package.py
index 2bc5186d92..1304184c2e 100644
--- a/var/spack/repos/builtin/packages/py-tfdlpack/package.py
+++ b/var/spack/repos/builtin/packages/py-tfdlpack/package.py
@@ -7,7 +7,7 @@
from spack.package import *
-class PyTfdlpack(CMakePackage, PythonPackage):
+class PyTfdlpack(CMakePackage, PythonExtension):
"""Tensorflow plugin for DLPack."""
homepage = "https://github.com/VoVAllen/tf-dlpack"
diff --git a/var/spack/repos/builtin/packages/quantum-espresso/package.py b/var/spack/repos/builtin/packages/quantum-espresso/package.py
index acc07692cf..47fb80e6f9 100644
--- a/var/spack/repos/builtin/packages/quantum-espresso/package.py
+++ b/var/spack/repos/builtin/packages/quantum-espresso/package.py
@@ -2,11 +2,12 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-
+import spack.build_systems.cmake
+import spack.build_systems.generic
from spack.package import *
-class QuantumEspresso(CMakePackage):
+class QuantumEspresso(CMakePackage, Package):
"""Quantum ESPRESSO is an integrated suite of Open-Source computer codes
for electronic-structure calculations and materials modeling at the
nanoscale. It is based on density-functional theory, plane waves, and
@@ -19,6 +20,8 @@ class QuantumEspresso(CMakePackage):
maintainers = ["ye-luo", "danielecesarini", "bellenlau"]
+ build_system(conditional("cmake", when="@6.8:"), "generic", default="cmake")
+
version("develop", branch="develop")
version("7.1", sha256="d56dea096635808843bd5a9be2dee3d1f60407c01dbeeda03f8256a3bcfc4eb6")
version("7.0", sha256="85beceb1aaa1678a49e774c085866d4612d9d64108e0ac49b23152c8622880ee")
@@ -56,10 +59,8 @@ class QuantumEspresso(CMakePackage):
destination=".",
)
- variant("cmake", default=True, description="Builds via CMake")
- with when("+cmake"):
+ with when("build_system=cmake"):
depends_on("cmake@3.14.0:", type="build")
- conflicts("@:6.7", msg="+cmake works since QE v6.8")
variant("libxc", default=False, description="Uses libxc")
depends_on("libxc@5.1.2:", when="+libxc")
@@ -93,7 +94,7 @@ class QuantumEspresso(CMakePackage):
msg="bugs with NVHPCSDK from v21.11 to v22.3, OpenMP and GPU",
)
# only cmake is supported
- conflicts("~cmake", msg="Only CMake supported for GPU-enabled version")
+ conflicts("build_system=generic", msg="Only CMake supported for GPU-enabled version")
# NVTX variant for profiling
# requires linking to CUDA runtime APIs , handled by CMake
@@ -121,9 +122,10 @@ class QuantumEspresso(CMakePackage):
with when("+elpa"):
# CMake builds only support elpa without openmp
- depends_on("elpa~openmp", when="+cmake")
- depends_on("elpa+openmp", when="+openmp~cmake")
- depends_on("elpa~openmp", when="~openmp~cmake")
+ depends_on("elpa~openmp", when="build_system=cmake")
+ with when("build_system=generic"):
+ depends_on("elpa+openmp", when="+openmp")
+ depends_on("elpa~openmp", when="~openmp")
# Elpa is formally supported by @:5.4.0, but QE configure searches
# for it in the wrong folders (or tries to download it within
# the build directory). Instead of patching Elpa to provide the
@@ -181,12 +183,14 @@ class QuantumEspresso(CMakePackage):
with when("@7.0.1:"):
# when QE doesn't use hdf5 library, the converter plugin still needs it
depends_on("hdf5@1.8.16:+hl~mpi", when="hdf5=none")
- conflicts("~cmake", msg="QE-to-QMCPACK wave function converter requires cmake")
+ conflicts(
+ "build_system=generic", msg="QE-to-QMCPACK wave function converter requires cmake"
+ )
# Enables building Electron-phonon Wannier 'epw.x' executable
# http://epw.org.uk/Main/About
- variant("epw", default=False, description="Builds Electron-phonon Wannier executable")
- conflicts("~epw", when="+cmake", msg="epw cannot be turned off when using CMake")
+ variant("epw", default=True, description="Builds Electron-phonon Wannier executable")
+ conflicts("~epw", when="build_system=cmake", msg="epw cannot be turned off when using CMake")
with when("+epw"):
# The first version of Q-E to feature integrated EPW is 6.0.0,
@@ -198,8 +202,10 @@ class QuantumEspresso(CMakePackage):
# Constraints may be relaxed as successful reports
# of different compiler+mpi combinations arrive
- # TODO: enable building EPW when ~mpi and ~cmake
- conflicts("~mpi", when="~cmake", msg="EPW needs MPI when ~cmake")
+ # TODO: enable building EPW when ~mpi and build_system=generic
+ conflicts(
+ "~mpi", when="build_system=generic", msg="EPW needs MPI when build_system=generic"
+ )
# EPW doesn't gets along well with OpenMPI 2.x.x
conflicts("^openmpi@2.0.0:2", msg="OpenMPI version incompatible with EPW")
@@ -212,19 +218,19 @@ class QuantumEspresso(CMakePackage):
variant(
"environ",
default=False,
+ when="build_system=generic",
description="Enables support for introducing environment effects "
"into atomistic first-principles simulations."
"See http://quantum-environ.org/about.html",
)
- conflicts("+environ", when="+cmake", msg="environ doesn't work with CMake")
variant(
"gipaw",
default=False,
+ when="build_system=generic",
description="Builds Gauge-Including Projector Augmented-Waves executable",
)
with when("+gipaw"):
- conflicts("+cmake", msg="gipaw doesn't work with CMake")
conflicts(
"@:6.3", msg="gipaw standard support available for QE 6.3 or grater version only"
)
@@ -370,6 +376,8 @@ class QuantumEspresso(CMakePackage):
# extlibs_makefile updated to work with fujitsu compilers
patch("fj-fox.patch", when="+patch %fj")
+
+class CMakeBuilder(spack.build_systems.cmake.CMakeBuilder):
def cmake_args(self):
spec = self.spec
@@ -400,18 +408,9 @@ class QuantumEspresso(CMakePackage):
return cmake_args
- @when("~cmake")
- def cmake(self, spec, prefix):
- print("Bypass cmake stage when building via configure")
-
- @when("~cmake")
- def build(self, spec, prefix):
- print("Bypass build stage when building via configure")
-
- @when("~cmake")
- def install(self, spec, prefix):
- print("Override install stage when building via configure")
+class GenericBuilder(spack.build_systems.generic.GenericBuilder):
+ def install(self, pkg, spec, prefix):
prefix_path = prefix.bin if "@:5.4.0" in spec else prefix
options = ["-prefix={0}".format(prefix_path)]
@@ -577,7 +576,7 @@ class QuantumEspresso(CMakePackage):
# can't be applied to the '+qmcpack' variant
if spec.variants["hdf5"].value != "none":
if spec.satisfies("@6.1.0:6.4.0") or (spec.satisfies("@6.4.1") and "+qmcpack" in spec):
- make_inc = join_path(self.stage.source_path, "make.inc")
+ make_inc = join_path(self.pkg.stage.source_path, "make.inc")
zlib_libs = spec["zlib"].prefix.lib + " -lz"
filter_file(zlib_libs, format(spec["zlib"].libs.ld_flags), make_inc)
diff --git a/var/spack/repos/builtin/packages/racket/package.py b/var/spack/repos/builtin/packages/racket/package.py
index cc9e1ba25b..7031e234ea 100644
--- a/var/spack/repos/builtin/packages/racket/package.py
+++ b/var/spack/repos/builtin/packages/racket/package.py
@@ -2,13 +2,11 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-
-import sys
-
+import spack.build_systems.makefile
from spack.package import *
-class Racket(Package):
+class Racket(MakefilePackage):
"""The Racket programming language."""
homepage = "https://www.racket-lang.org"
@@ -21,13 +19,6 @@ class Racket(Package):
depends_on("patchutils")
depends_on("libtool", type=("build"))
- phases = ["configure", "build", "install"]
-
- def url_for_version(self, version):
- return "https://mirror.racket-lang.org/installers/{0}/racket-minimal-{0}-src-builtpkgs.tgz".format(
- version
- )
-
variant("cs", default=True, description="Build Racket CS (new ChezScheme VM)")
variant("bc", default=False, description="Build Racket BC (old MZScheme VM)")
variant("shared", default=True, description="Enable shared")
@@ -36,12 +27,22 @@ class Racket(Package):
parallel = False
extendable = True
+ def url_for_version(self, version):
+ return "https://mirror.racket-lang.org/installers/{0}/racket-minimal-{0}-src-builtpkgs.tgz".format(
+ version
+ )
+
+
+class MakefileBuilder(spack.build_systems.makefile.MakefileBuilder):
+
+ build_directory = "src"
+
def toggle(self, spec, variant):
toggle_text = "enable" if spec.variants[variant].value else "disable"
return "--{0}-{1}".format(toggle_text, variant)
- def configure(self, spec, prefix):
- with working_dir("src"):
+ def edit(self, pkg, spec, prefix):
+ with working_dir(self.build_directory):
configure = Executable("./configure")
configure_args = [
self.toggle(spec, "cs"),
@@ -49,7 +50,7 @@ class Racket(Package):
self.toggle(spec, "jit"),
]
toggle_shared = self.toggle(spec, "shared")
- if sys.platform == "darwin":
+ if spec.satisfies("platform=darwin"):
configure_args += ["--enable-macprefix"]
if "+xonx" in spec:
configure_args += ["--enable-xonx", toggle_shared]
@@ -58,16 +59,20 @@ class Racket(Package):
configure_args += ["--prefix={0}".format(prefix)]
configure(*configure_args)
- def build(self, spec, prefix):
- with working_dir("src"):
- if spec.variants["bc"].value:
- make("bc")
- if spec.variants["cs"].value:
- make("cs")
-
- def install(self, spec, prefix):
- with working_dir("src"):
- if spec.variants["bc"].value:
- make("install-bc")
- if spec.variants["cs"].value:
- make("install-cs")
+ @property
+ def build_targets(self):
+ result = []
+ if "+bc" in self.spec:
+ result.append("bc")
+ if "+cs" in self.spec:
+ result.append("cs")
+ return result
+
+ @property
+ def install_targets(self):
+ result = []
+ if "+bc" in self.spec:
+ result.append("install-bc")
+ if "+cs" in self.spec:
+ result.append("install-cs")
+ return result
diff --git a/var/spack/repos/builtin/packages/rkt-base/package.py b/var/spack/repos/builtin/packages/rkt-base/package.py
index 256f90106e..3eb21e485d 100644
--- a/var/spack/repos/builtin/packages/rkt-base/package.py
+++ b/var/spack/repos/builtin/packages/rkt-base/package.py
@@ -18,5 +18,3 @@ class RktBase(RacketPackage):
depends_on("racket@8.3", type=("build", "run"), when="@8.3")
racket_name = "base"
- pkgs = True
- subdirectory = "pkgs/{0}".format(racket_name)
diff --git a/var/spack/repos/builtin/packages/rkt-cext-lib/package.py b/var/spack/repos/builtin/packages/rkt-cext-lib/package.py
index 8d9b257c05..daa1ef5226 100644
--- a/var/spack/repos/builtin/packages/rkt-cext-lib/package.py
+++ b/var/spack/repos/builtin/packages/rkt-cext-lib/package.py
@@ -21,5 +21,4 @@ class RktCextLib(RacketPackage):
depends_on("rkt-scheme-lib@8.3", type=("build", "run"), when="@8.3")
racket_name = "cext-lib"
- pkgs = True
subdirectory = racket_name
diff --git a/var/spack/repos/builtin/packages/rkt-compiler-lib/package.py b/var/spack/repos/builtin/packages/rkt-compiler-lib/package.py
index fee9b3ea9a..6a21c774cb 100644
--- a/var/spack/repos/builtin/packages/rkt-compiler-lib/package.py
+++ b/var/spack/repos/builtin/packages/rkt-compiler-lib/package.py
@@ -21,5 +21,3 @@ class RktCompilerLib(RacketPackage):
depends_on("rkt-zo-lib@1.3", type=("build", "run"), when="@8.3")
racket_name = "compiler-lib"
- pkgs = True
- subdirectory = "pkgs/{0}".format(racket_name)
diff --git a/var/spack/repos/builtin/packages/rkt-dynext-lib/package.py b/var/spack/repos/builtin/packages/rkt-dynext-lib/package.py
index 81f7ca811f..9164571ed3 100644
--- a/var/spack/repos/builtin/packages/rkt-dynext-lib/package.py
+++ b/var/spack/repos/builtin/packages/rkt-dynext-lib/package.py
@@ -17,5 +17,4 @@ class RktDynextLib(RacketPackage):
depends_on("rkt-base@8.3", type=("build", "run"), when="@8.3")
racket_name = "dynext-lib"
- pkgs = True
subdirectory = racket_name
diff --git a/var/spack/repos/builtin/packages/rkt-rackunit-lib/package.py b/var/spack/repos/builtin/packages/rkt-rackunit-lib/package.py
index 783aebe306..3391050258 100644
--- a/var/spack/repos/builtin/packages/rkt-rackunit-lib/package.py
+++ b/var/spack/repos/builtin/packages/rkt-rackunit-lib/package.py
@@ -18,5 +18,4 @@ class RktRackunitLib(RacketPackage):
depends_on("rkt-testing-util-lib@8.3", type=("build", "run"), when="@8.3")
racket_name = "rackunit-lib"
- pkgs = True
subdirectory = racket_name
diff --git a/var/spack/repos/builtin/packages/rkt-scheme-lib/package.py b/var/spack/repos/builtin/packages/rkt-scheme-lib/package.py
index 75346eac70..689d3af7c5 100644
--- a/var/spack/repos/builtin/packages/rkt-scheme-lib/package.py
+++ b/var/spack/repos/builtin/packages/rkt-scheme-lib/package.py
@@ -17,4 +17,3 @@ class RktSchemeLib(RacketPackage):
depends_on("rkt-base@8.3", type=("build", "run"), when="@8.3")
racket_name = "scheme-lib"
- pkgs = True
diff --git a/var/spack/repos/builtin/packages/rkt-testing-util-lib/package.py b/var/spack/repos/builtin/packages/rkt-testing-util-lib/package.py
index 9186845fc9..aa1aafda4e 100644
--- a/var/spack/repos/builtin/packages/rkt-testing-util-lib/package.py
+++ b/var/spack/repos/builtin/packages/rkt-testing-util-lib/package.py
@@ -17,5 +17,4 @@ class RktTestingUtilLib(RacketPackage):
depends_on("rkt-base@8.3:", type=("build", "run"), when="@8.3")
racket_name = "testing-util-lib"
- pkgs = True
subdirectory = racket_name
diff --git a/var/spack/repos/builtin/packages/rkt-zo-lib/package.py b/var/spack/repos/builtin/packages/rkt-zo-lib/package.py
index 66f3d498af..a6b70cd075 100644
--- a/var/spack/repos/builtin/packages/rkt-zo-lib/package.py
+++ b/var/spack/repos/builtin/packages/rkt-zo-lib/package.py
@@ -17,5 +17,3 @@ class RktZoLib(RacketPackage):
depends_on("rkt-base@8.3:", type=("build", "run"), when="@1.3")
racket_name = "zo-lib"
- pkgs = True
- subdirectory = "pkgs/{0}".format(racket_name)
diff --git a/var/spack/repos/builtin/packages/ruby/package.py b/var/spack/repos/builtin/packages/ruby/package.py
index 9cc7f92151..a472509e08 100644
--- a/var/spack/repos/builtin/packages/ruby/package.py
+++ b/var/spack/repos/builtin/packages/ruby/package.py
@@ -2,19 +2,17 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-
import re
-import sys
-from typing import List
+import spack.build_systems.autotools
+import spack.build_systems.nmake
from spack.package import *
-is_windows = sys.platform == "win32"
-
-class Ruby(Package):
+class Ruby(AutotoolsPackage, NMakePackage):
"""A dynamic, open source programming language with a focus on
- simplicity and productivity."""
+ simplicity and productivity.
+ """
maintainers = ["Kerilk"]
@@ -33,24 +31,25 @@ class Ruby(Package):
version("2.5.3", sha256="9828d03852c37c20fa333a0264f2490f07338576734d910ee3fd538c9520846c")
version("2.2.0", sha256="7671e394abfb5d262fbcd3b27a71bf78737c7e9347fa21c39e58b0bb9c4840fc")
- if not is_windows:
- variant("openssl", default=True, description="Enable OpenSSL support")
- variant("readline", default=False, description="Enable Readline support")
- depends_on("pkgconfig", type=("build"))
- depends_on("libffi")
- depends_on("libx11", when="@:2.3")
- depends_on("tcl", when="@:2.3")
- depends_on("tk", when="@:2.3")
- depends_on("readline", when="+readline")
- depends_on("zlib")
- with when("+openssl"):
- depends_on("openssl@:1")
- depends_on("openssl@:1.0", when="@:2.3")
+ build_system("autotools", "nmake", default="autotools")
+
+ for _platform_condition in ("platform=linux", "platform=darwin", "platform=cray"):
+ with when(_platform_condition):
+ variant("openssl", default=True, description="Enable OpenSSL support")
+ variant("readline", default=False, description="Enable Readline support")
+ depends_on("pkgconfig", type="build")
+ depends_on("libffi")
+ depends_on("libx11", when="@:2.3")
+ depends_on("tcl", when="@:2.3")
+ depends_on("tk", when="@:2.3")
+ depends_on("readline", when="+readline")
+ depends_on("zlib")
+ with when("+openssl"):
+ depends_on("openssl@:1")
+ depends_on("openssl@:1.0", when="@:2.3")
extendable = True
- phases = ["configure", "build", "install"]
- build_targets = [] # type: List[str]
- install_targets = ["install"]
+
# Known build issues when Avira antivirus software is running:
# https://github.com/rvm/rvm/issues/4313#issuecomment-374020379
# TODO: add check for this and warn user
@@ -82,28 +81,6 @@ class Ruby(Package):
url = "https://cache.ruby-lang.org/pub/ruby/{0}/ruby-{1}.tar.gz"
return url.format(version.up_to(2), version)
- def configure_args(self):
- args = []
- if "+openssl" in self.spec:
- args.append("--with-openssl-dir=%s" % self.spec["openssl"].prefix)
- if "+readline" in self.spec:
- args.append("--with-readline-dir=%s" % self.spec["readline"].prefix)
- if "^tk" in self.spec:
- args.append("--with-tk=%s" % self.spec["tk"].prefix)
- if self.spec.satisfies("%fj"):
- args.append("--disable-dtrace")
- return args
-
- def setup_dependent_build_environment(self, env, dependent_spec):
- # TODO: do this only for actual extensions.
- # Set GEM_PATH to include dependent gem directories
- for d in dependent_spec.traverse(deptype=("build", "run", "test"), root=True):
- if d.package.extends(self.spec):
- env.prepend_path("GEM_PATH", d.prefix)
-
- # The actual installation path for this gem
- env.set("GEM_HOME", dependent_spec.prefix)
-
def setup_dependent_run_environment(self, env, dependent_spec):
for d in dependent_spec.traverse(deptype=("run"), root=True):
if d.package.extends(self.spec):
@@ -122,31 +99,31 @@ class Ruby(Package):
module.gem = Executable(self.prefix.bin.gem)
module.rake = Executable(self.prefix.bin.rake)
- def configure(self, spec, prefix):
- with working_dir(self.stage.source_path, create=True):
- if is_windows:
- Executable("win32\\configure.bat")("--prefix=%s" % self.prefix)
- else:
- options = getattr(self, "configure_flag_args", [])
- options += ["--prefix={0}".format(prefix)]
- options += self.configure_args()
- configure(*options)
-
- def build(self, spec, prefix):
- with working_dir(self.stage.source_path):
- if is_windows:
- nmake()
- else:
- params = ["V=1"]
- params += self.build_targets
- make(*params)
-
- def install(self, spec, prefix):
- with working_dir(self.stage.source_path):
- if is_windows:
- nmake("install")
- else:
- make(*self.install_targets)
+
+class SetupEnvironment(object):
+ def setup_dependent_build_environment(self, env, dependent_spec):
+ # TODO: do this only for actual extensions.
+ # Set GEM_PATH to include dependent gem directories
+ for d in dependent_spec.traverse(deptype=("build", "run", "test"), root=True):
+ if d.package.extends(self.spec):
+ env.prepend_path("GEM_PATH", d.prefix)
+
+ # The actual installation path for this gem
+ env.set("GEM_HOME", dependent_spec.prefix)
+
+
+class AutotoolsBuilder(spack.build_systems.autotools.AutotoolsBuilder, SetupEnvironment):
+ def configure_args(self):
+ args = []
+ if "+openssl" in self.spec:
+ args.append("--with-openssl-dir=%s" % self.spec["openssl"].prefix)
+ if "+readline" in self.spec:
+ args.append("--with-readline-dir=%s" % self.spec["readline"].prefix)
+ if "^tk" in self.spec:
+ args.append("--with-tk=%s" % self.spec["tk"].prefix)
+ if self.spec.satisfies("%fj"):
+ args.append("--disable-dtrace")
+ return args
@run_after("install")
def post_install(self):
@@ -158,7 +135,7 @@ class Ruby(Package):
"""
if self.spec.satisfies("+openssl"):
rubygems_updated_cert_path = join_path(
- self.stage.source_path, "rubygems-updated-ssl-cert", "GlobalSignRootCA.pem"
+ self.pkg.stage.source_path, "rubygems-updated-ssl-cert", "GlobalSignRootCA.pem"
)
rubygems_certs_path = join_path(
self.spec.prefix.lib,
@@ -171,11 +148,19 @@ class Ruby(Package):
rbconfig = find(self.prefix, "rbconfig.rb")[0]
filter_file(
- r'^(\s*CONFIG\["CXX"\]\s*=\s*).*', r'\1"{0}"'.format(self.compiler.cxx), rbconfig
+ r'^(\s*CONFIG\["CXX"\]\s*=\s*).*', r'\1"{0}"'.format(self.pkg.compiler.cxx), rbconfig
)
filter_file(
- r'^(\s*CONFIG\["CC"\]\s*=\s*).*', r'\1"{0}"'.format(self.compiler.cc), rbconfig
+ r'^(\s*CONFIG\["CC"\]\s*=\s*).*', r'\1"{0}"'.format(self.pkg.compiler.cc), rbconfig
)
filter_file(
- r'^(\s*CONFIG\["MJIT_CC"\]\s*=\s*).*', r'\1"{0}"'.format(self.compiler.cc), rbconfig
+ r'^(\s*CONFIG\["MJIT_CC"\]\s*=\s*).*',
+ r'\1"{0}"'.format(self.pkg.compiler.cc),
+ rbconfig,
)
+
+
+class NMakeBuilder(spack.build_systems.nmake.NMakeBuilder, SetupEnvironment):
+ def edit(self, pkg, spec, prefix):
+ with working_dir(self.pkg.stage.source_path, create=True):
+ Executable("win32\\configure.bat")("--prefix=%s" % self.prefix)
diff --git a/var/spack/repos/builtin/packages/scotch/package.py b/var/spack/repos/builtin/packages/scotch/package.py
index 166455876e..b957db31bf 100644
--- a/var/spack/repos/builtin/packages/scotch/package.py
+++ b/var/spack/repos/builtin/packages/scotch/package.py
@@ -3,12 +3,15 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+import spack.build_systems.cmake
+import spack.build_systems.makefile
from spack.package import *
-class Scotch(CMakePackage):
+class Scotch(CMakePackage, MakefilePackage):
"""Scotch is a software package for graph and mesh/hypergraph
- partitioning, graph clustering, and sparse matrix ordering."""
+ partitioning, graph clustering, and sparse matrix ordering.
+ """
homepage = "https://gitlab.inria.fr/scotch/scotch"
git = "https://gitlab.inria.fr/scotch/scotch.git"
@@ -32,13 +35,10 @@ class Scotch(CMakePackage):
version("6.0.0", sha256="8206127d038bda868dda5c5a7f60ef8224f2e368298fbb01bf13fa250e378dd4")
version("5.1.10b", sha256="54c9e7fafefd49d8b2017d179d4f11a655abe10365961583baaddc4eeb6a9add")
- variant("mpi", default=True, description="Activate the compilation of parallel libraries")
- variant(
- "compression", default=True, description="Activate the posibility to use compressed files"
- )
- variant(
- "esmumps", default=False, description="Activate the compilation of esmumps needed by mumps"
- )
+ build_system(conditional("cmake", when="@7:"), "makefile", default="cmake")
+ variant("mpi", default=True, description="Compile parallel libraries")
+ variant("compression", default=True, description="May use compressed files")
+ variant("esmumps", default=False, description="Compile esmumps (needed by mumps)")
variant("shared", default=True, description="Build a shared version of the library")
variant(
"metis", default=False, description="Expose vendored METIS/ParMETIS libraries and wrappers"
@@ -70,8 +70,6 @@ class Scotch(CMakePackage):
conflicts("^metis", when="+metis")
conflicts("^parmetis", when="+metis")
- # NOTE: In cross-compiling environment parallel build
- # produces weird linker errors.
parallel = False
# NOTE: Versions of Scotch up to version 6.0.0 don't include support for
@@ -107,16 +105,30 @@ class Scotch(CMakePackage):
return scotchlibs + zlibs
- @when("@:6")
- def patch(self):
- self.configure()
- # NOTE: Configuration of Scotch is achieved by writing a 'Makefile.inc'
- # file that contains all of the configuration variables and their desired
- # values for the installation. This function writes this file based on
- # the given installation variants.
- @when("@:6")
- def configure(self):
+class CMakeBuilder(spack.build_systems.cmake.CMakeBuilder):
+ def cmake_args(self):
+ spec = self.spec
+ args = [
+ self.define_from_variant("BUILD_LIBSCOTCHMETIS", "metis"),
+ self.define_from_variant("INSTALL_METIS_HEADERS", "metis"),
+ self.define_from_variant("BUILD_LIBESMUMPS", "esmumps"),
+ self.define_from_variant("BUILD_SHARED_LIBS", "shared"),
+ self.define_from_variant("BUILD_PTSCOTCH", "mpi"),
+ ]
+
+ # TODO should we enable/disable THREADS?
+
+ if "+int64" in spec:
+ args.append("-DINTSIZE=64")
+
+ return args
+
+
+class MakefileBuilder(spack.build_systems.makefile.MakefileBuilder):
+ build_directory = "src"
+
+ def edit(self, pkg, spec, prefix):
makefile_inc = []
cflags = [
"-O3",
@@ -147,7 +159,7 @@ class Scotch(CMakePackage):
makefile_inc.extend(
[
"LIB = .dylib",
- "CLIBFLAGS = -dynamiclib {0}".format(self.compiler.cc_pic_flag),
+ "CLIBFLAGS = -dynamiclib {0}".format(pkg.compiler.cc_pic_flag),
"RANLIB = echo",
"AR = $(CC)",
(
@@ -162,13 +174,13 @@ class Scotch(CMakePackage):
makefile_inc.extend(
[
"LIB = .so",
- "CLIBFLAGS = -shared {0}".format(self.compiler.cc_pic_flag),
+ "CLIBFLAGS = -shared {0}".format(pkg.compiler.cc_pic_flag),
"RANLIB = echo",
"AR = $(CC)",
"ARFLAGS = -shared $(LDFLAGS) -o",
]
)
- cflags.append(self.compiler.cc_pic_flag)
+ cflags.append(pkg.compiler.cc_pic_flag)
else:
makefile_inc.extend(
[
@@ -182,9 +194,9 @@ class Scotch(CMakePackage):
# Compiler-Specific Options #
- if self.compiler.name == "gcc":
+ if pkg.compiler.name == "gcc":
cflags.append("-Drestrict=__restrict")
- elif self.compiler.name == "intel":
+ elif pkg.compiler.name == "intel":
cflags.append("-Drestrict=")
mpicc_path = self.spec["mpi"].mpicc if "+mpi" in self.spec else "mpicc"
@@ -237,8 +249,8 @@ class Scotch(CMakePackage):
with open("Makefile.inc", "w") as fh:
fh.write("\n".join(makefile_inc))
- @when("@:6")
- def install(self, spec, prefix):
+ @property
+ def build_targets(self):
targets = ["scotch"]
if "+mpi" in self.spec:
targets.append("ptscotch")
@@ -248,65 +260,4 @@ class Scotch(CMakePackage):
targets.append("esmumps")
if "+mpi" in self.spec:
targets.append("ptesmumps")
-
- with working_dir("src"):
- for target in targets:
- # It seems that building ptesmumps in parallel fails, for
- # version prior to 6.0.0 there is no separated targets force
- # ptesmumps, this library is built by the ptscotch target. This
- # should explain the test for the can_make_parallel variable
- can_make_parallel = not (
- target == "ptesmumps"
- or (self.spec.version < Version("6.0.0") and target == "ptscotch")
- )
- make(target, parallel=can_make_parallel)
-
- lib_ext = dso_suffix if "+shared" in self.spec else "a"
- # It seems easier to remove metis wrappers from the folder that will be
- # installed than to tweak the Makefiles
- if "+metis" not in self.spec:
- with working_dir("lib"):
- force_remove("libscotchmetis.{0}".format(lib_ext))
- force_remove("libptscotchparmetis.{0}".format(lib_ext))
-
- with working_dir("include"):
- force_remove("metis.h")
- force_remove("parmetis.h")
-
- if "~esmumps" in self.spec and self.spec.version < Version("6.0.0"):
- with working_dir("lib"):
- force_remove("libesmumps.{0}".format(lib_ext))
- force_remove("libptesmumps.{0}".format(lib_ext))
-
- with working_dir("include"):
- force_remove("esmumps.h")
-
- install_tree("bin", prefix.bin)
- install_tree("lib", prefix.lib)
- install_tree("include", prefix.include)
- install_tree("man/man1", prefix.share.man.man1)
-
- @when("@:6")
- def cmake(self, spec, prefix):
- self.configure()
-
- @when("@:6")
- def build(self, spec, prefix):
- pass
-
- def cmake_args(self):
- spec = self.spec
- args = [
- self.define_from_variant("BUILD_LIBSCOTCHMETIS", "metis"),
- self.define_from_variant("INSTALL_METIS_HEADERS", "metis"),
- self.define_from_variant("BUILD_LIBESMUMPS", "esmumps"),
- self.define_from_variant("BUILD_SHARED_LIBS", "shared"),
- self.define_from_variant("BUILD_PTSCOTCH", "mpi"),
- ]
-
- # TODO should we enable/disable THREADS?
-
- if "+int64" in spec:
- args.append("-DINTSIZE=64")
-
- return args
+ return targets
diff --git a/var/spack/repos/builtin/packages/superlu/package.py b/var/spack/repos/builtin/packages/superlu/package.py
index 8f20f90ea4..e8bd7c38f6 100644
--- a/var/spack/repos/builtin/packages/superlu/package.py
+++ b/var/spack/repos/builtin/packages/superlu/package.py
@@ -2,15 +2,16 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-
import os
from llnl.util import tty
+import spack.build_systems.cmake
+import spack.build_systems.generic
from spack.package import *
-class Superlu(CMakePackage):
+class Superlu(CMakePackage, Package):
"""SuperLU is a general purpose library for the direct solution of large,
sparse, nonsymmetric systems of linear equations on high performance
machines. SuperLU is designed for sequential machines."""
@@ -36,9 +37,12 @@ class Superlu(CMakePackage):
url="https://crd-legacy.lbl.gov/~xiaoye/SuperLU/superlu_4.2.tar.gz",
)
+ build_system(
+ conditional("cmake", when="@5:"), conditional("autotools", when="@:4"), default="cmake"
+ )
+
variant("pic", default=True, description="Build with position independent code")
- depends_on("cmake", when="@5:", type="build")
depends_on("blas")
conflicts(
"@:5.2.1",
@@ -48,76 +52,7 @@ class Superlu(CMakePackage):
test_requires_compiler = True
- # CMake installation method
- def cmake_args(self):
- if self.version > Version("5.2.1"):
- _blaslib_key = "enable_internal_blaslib"
- else:
- _blaslib_key = "enable_blaslib"
- args = [
- self.define(_blaslib_key, False),
- self.define("CMAKE_INSTALL_LIBDIR", self.prefix.lib),
- self.define_from_variant("CMAKE_POSITION_INDEPENDENT_CODE", "pic"),
- self.define("enable_tests", self.run_tests),
- ]
-
- return args
-
# Pre-cmake installation method
- @when("@:4")
- def cmake(self, spec, prefix):
- """Use autotools before version 5"""
- config = []
-
- # Define make.inc file
- config.extend(
- [
- "PLAT = _x86_64",
- "SuperLUroot = %s" % self.stage.source_path,
- # 'SUPERLULIB = $(SuperLUroot)/lib/libsuperlu$(PLAT).a',
- "SUPERLULIB = $(SuperLUroot)/lib/libsuperlu_{0}.a".format(self.spec.version),
- "BLASDEF = -DUSE_VENDOR_BLAS",
- "BLASLIB = {0}".format(spec["blas"].libs.ld_flags),
- # or BLASLIB = -L/usr/lib64 -lblas
- "TMGLIB = libtmglib.a",
- "LIBS = $(SUPERLULIB) $(BLASLIB)",
- "ARCH = ar",
- "ARCHFLAGS = cr",
- "RANLIB = {0}".format("ranlib" if which("ranlib") else "echo"),
- "CC = {0}".format(env["CC"]),
- "FORTRAN = {0}".format(env["FC"]),
- "LOADER = {0}".format(env["CC"]),
- "CDEFS = -DAdd_",
- ]
- )
-
- if "+pic" in spec:
- config.extend(
- [
- # Use these lines instead when pic_flag capability arrives
- "CFLAGS = -O3 {0}".format(self.compiler.cc_pic_flag),
- "NOOPTS = {0}".format(self.compiler.cc_pic_flag),
- "FFLAGS = -O2 {0}".format(self.compiler.f77_pic_flag),
- "LOADOPTS = {0}".format(self.compiler.cc_pic_flag),
- ]
- )
- else:
- config.extend(
- ["CFLAGS = -O3", "NOOPTS = ", "FFLAGS = -O2", "LOADOPTS = "]
- )
-
- # Write configuration options to make.inc file
- with open("make.inc", "w") as inc:
- for option in config:
- inc.write("{0}\n".format(option))
-
- make(parallel=False)
-
- # Install manually
- install_tree("lib", prefix.lib)
- mkdir(prefix.include)
- install(join_path("SRC", "*.h"), prefix.include)
-
examples_src_dir = "EXAMPLE"
make_hdr_file = "make.inc"
@@ -221,3 +156,67 @@ class Superlu(CMakePackage):
return
self.run_superlu_test(test_dir, exe, args)
+
+
+class CMakeBuilder(spack.build_systems.cmake.CMakeBuilder):
+ def cmake_args(self):
+ if self.pkg.version > Version("5.2.1"):
+ _blaslib_key = "enable_internal_blaslib"
+ else:
+ _blaslib_key = "enable_blaslib"
+ args = [
+ self.define(_blaslib_key, False),
+ self.define("CMAKE_INSTALL_LIBDIR", self.prefix.lib),
+ self.define_from_variant("CMAKE_POSITION_INDEPENDENT_CODE", "pic"),
+ self.define("enable_tests", self.pkg.run_tests),
+ ]
+ return args
+
+
+class GenericBuilder(spack.build_systems.generic.GenericBuilder):
+ def install(self, pkg, spec, prefix):
+ """Use autotools before version 5"""
+ # Define make.inc file
+ config = [
+ "PLAT = _x86_64",
+ "SuperLUroot = %s" % self.pkg.stage.source_path,
+ # 'SUPERLULIB = $(SuperLUroot)/lib/libsuperlu$(PLAT).a',
+ "SUPERLULIB = $(SuperLUroot)/lib/libsuperlu_{0}.a".format(self.pkg.spec.version),
+ "BLASDEF = -DUSE_VENDOR_BLAS",
+ "BLASLIB = {0}".format(spec["blas"].libs.ld_flags),
+ # or BLASLIB = -L/usr/lib64 -lblas
+ "TMGLIB = libtmglib.a",
+ "LIBS = $(SUPERLULIB) $(BLASLIB)",
+ "ARCH = ar",
+ "ARCHFLAGS = cr",
+ "RANLIB = {0}".format("ranlib" if which("ranlib") else "echo"),
+ "CC = {0}".format(env["CC"]),
+ "FORTRAN = {0}".format(env["FC"]),
+ "LOADER = {0}".format(env["CC"]),
+ "CDEFS = -DAdd_",
+ ]
+
+ if "+pic" in spec:
+ config.extend(
+ [
+ # Use these lines instead when pic_flag capability arrives
+ "CFLAGS = -O3 {0}".format(self.pkg.compiler.cc_pic_flag),
+ "NOOPTS = {0}".format(self.pkg.compiler.cc_pic_flag),
+ "FFLAGS = -O2 {0}".format(self.pkg.compiler.f77_pic_flag),
+ "LOADOPTS = {0}".format(self.pkg.compiler.cc_pic_flag),
+ ]
+ )
+ else:
+ config.extend(
+ ["CFLAGS = -O3", "NOOPTS = ", "FFLAGS = -O2", "LOADOPTS = "]
+ )
+
+ with open("make.inc", "w") as inc:
+ for option in config:
+ inc.write("{0}\n".format(option))
+
+ make(parallel=False)
+
+ install_tree("lib", prefix.lib)
+ mkdir(prefix.include)
+ install(join_path("SRC", "*.h"), prefix.include)
diff --git a/var/spack/repos/builtin/packages/swig/package.py b/var/spack/repos/builtin/packages/swig/package.py
index d1a760ffec..2bb9853526 100644
--- a/var/spack/repos/builtin/packages/swig/package.py
+++ b/var/spack/repos/builtin/packages/swig/package.py
@@ -2,10 +2,10 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-
import os
import re
+import spack.build_systems.autotools
from spack.package import *
@@ -57,10 +57,10 @@ class Swig(AutotoolsPackage, SourceforgePackage):
depends_on("pcre")
- _autoconf_versions = ["@master", "@fortran", "@4.0.2-fortran", "@4.1.dev1-fortran"]
+ AUTOCONF_VERSIONS = ["@master", "@fortran", "@4.0.2-fortran", "@4.1.dev1-fortran"]
# Git releases do *not* include configure script
- for _version in _autoconf_versions:
+ for _version in AUTOCONF_VERSIONS:
depends_on("autoconf", type="build", when=_version)
depends_on("automake", type="build", when=_version)
depends_on("libtool", type="build", when=_version)
@@ -70,8 +70,6 @@ class Swig(AutotoolsPackage, SourceforgePackage):
depends_on("automake@1.15:", type="build", when="target={0}:".format(_target))
depends_on("pkgconfig", type="build")
- build_directory = "spack-build"
-
conflicts("%nvhpc", when="@:4.0.2")
@classmethod
@@ -80,18 +78,6 @@ class Swig(AutotoolsPackage, SourceforgePackage):
match = re.search(r"SWIG\s+Version\s+(\S+)", output)
return match.group(1) if match else None
- @run_after("install")
- def create_symlink(self):
- # CMake compatibility: see https://github.com/spack/spack/pull/6240
- with working_dir(self.prefix.bin):
- os.symlink("swig", "swig{0}".format(self.spec.version.up_to(2)))
-
- for _version in _autoconf_versions:
-
- @when(_version)
- def autoreconf(self, spec, prefix):
- which("sh")("./autogen.sh")
-
@property
def _installed_exe(self):
return join_path(self.prefix, "bin", "swig")
@@ -134,3 +120,19 @@ class Swig(AutotoolsPackage, SourceforgePackage):
def test(self):
self._test_version()
self._test_swiglib()
+
+
+class AutotoolsBuilder(spack.build_systems.autotools.AutotoolsBuilder):
+ build_directory = "spack-build"
+
+ @run_after("install")
+ def create_symlink(self):
+ # CMake compatibility: see https://github.com/spack/spack/pull/6240
+ with working_dir(self.prefix.bin):
+ os.symlink("swig", "swig{0}".format(self.spec.version.up_to(2)))
+
+ for _version in Swig.AUTOCONF_VERSIONS:
+
+ @when(_version)
+ def autoreconf(self, pkg, spec, prefix):
+ which("sh")("./autogen.sh")
diff --git a/var/spack/repos/builtin/packages/sz/package.py b/var/spack/repos/builtin/packages/sz/package.py
index e16657a6b6..d83e0a52d5 100644
--- a/var/spack/repos/builtin/packages/sz/package.py
+++ b/var/spack/repos/builtin/packages/sz/package.py
@@ -2,11 +2,12 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-
+import spack.build_systems.autotools
+import spack.build_systems.cmake
from spack.package import *
-class Sz(CMakePackage):
+class Sz(CMakePackage, AutotoolsPackage):
"""Error-bounded Lossy Compressor for HPC Data"""
homepage = "https://szcompressor.org"
@@ -43,6 +44,12 @@ class Sz(CMakePackage):
version("1.4.10.0", sha256="cf23cf1ffd7c69c3d3128ae9c356b6acdc03a38f92c02db5d9bfc04f3fabc506")
version("1.4.9.2", sha256="9dc785274d068d04c2836955fc93518a9797bfd409b46fea5733294b7c7c18f8")
+ build_system(
+ conditional("autotools", when="@:2.1.8.0"),
+ conditional("cmake", when="@2.1.8.1:"),
+ default="cmake",
+ )
+
variant("python", default=False, description="builds the python wrapper")
variant("netcdf", default=False, description="build the netcdf reader")
variant("hdf5", default=False, description="build the hdf5 filter")
@@ -71,86 +78,6 @@ class Sz(CMakePackage):
patch("ctags-only-if-requested.patch", when="@2.1.8.1:2.1.8.3")
- @property
- def build_directory(self):
- """autotools needs a different build directory to work"""
- if self.version >= Version("2.1.8.1"):
- return "spack-build"
- else:
- return "."
-
- @when("@:2.1.8.0")
- def cmake(self, spec, prefix):
- """use autotools before 2.1.8.1"""
- configure_args = ["--prefix=" + prefix]
- if "+fortran" in spec:
- configure_args.append("--enable-fortran")
- else:
- configure_args.append("--disable-fortran")
- configure(*configure_args)
- # at least the v2.0.2.0 tarball contains object files
- # which need to be cleaned out
- make("clean")
-
- def cmake_args(self):
- """configure the package with CMake for version 2.1.8.1 and later"""
- args = []
-
- if "+python" in self.spec:
- args.append("-DBUILD_PYTHON_WRAPPER=ON")
- args.append("-DSZ_PYTHON_SITELIB={0}".format(python_platlib))
- else:
- args.append("-DBUILD_PYTHON_WRAPPER=OFF")
-
- if "+netcdf" in self.spec:
- args.append("-DBUILD_NETCDF_READER=ON")
- else:
- args.append("-DBUILD_NETCDF_READER=OFF")
-
- if "+hdf5" in self.spec:
- args.append("-DBUILD_HDF5_FILTER=ON")
- else:
- args.append("-DBUILD_HDF5_FILTER=OFF")
-
- if "+pastri" in self.spec:
- args.append("-DBUILD_PASTRI=ON")
- else:
- args.append("-DBUILD_PASTRI=OFF")
-
- if "+time_compression" in self.spec:
- args.append("-DBUILD_TIMECMPR=ON")
- else:
- args.append("-DBUILD_TIMECMPR=OFF")
-
- if "+random_access" in self.spec:
- args.append("-DBUILD_RANDOMACCESS=ON")
- else:
- args.append("-DBUILD_RANDOMACCESS=OFF")
-
- if "+fortran" in self.spec:
- args.append("-DBUILD_FORTRAN=ON")
- else:
- args.append("-DBUILD_FORTRAN=OFF")
-
- if "+shared" in self.spec:
- args.append("-DBUILD_SHARED_LIBS=ON")
- else:
- args.append("-DBUILD_SHARED_LIBS=OFF")
-
- if "+stats" in self.spec:
- args.append("-DBUILD_STATS=ON")
- else:
- args.append("-DBUILD_STATS=OFF")
-
- args.append(self.define("BUILD_TESTS", self.run_tests))
-
- return args
-
- @run_after("build")
- @on_package_attributes(run_tests=True)
- def test_build(self):
- make("test")
-
def _test_2d_float(self):
"""This test performs simple 2D compression/decompression (float)"""
test_data_dir = self.test_suite.current_test_data_dir
@@ -232,3 +159,37 @@ class Sz(CMakePackage):
self._test_2d_float()
# run 3D compression and decompression (float)
self._test_3d_float()
+
+
+class AutotoolsBuilder(spack.build_systems.autotools.AutotoolsBuilder):
+ build_directory = "."
+
+ def configure_args(self):
+ return self.enable_or_disable("fortran")
+
+ @run_before("build")
+ def make_clean(self):
+ # at least the v2.0.2.0 tarball contains object files
+ # which need to be cleaned out
+ make("clean")
+
+
+class CMakeBuilder(spack.build_systems.cmake.CMakeBuilder):
+ def cmake_args(self):
+ result = [
+ self.define_from_variant("BUILD_NETCDF_READER", "netcdf"),
+ self.define_from_variant("BUILD_HDF5_FILTER", "hdf5"),
+ self.define_from_variant("BUILD_PASTRI", "pastri"),
+ self.define_from_variant("BUILD_TIMECPR", "time_compression"),
+ self.define_from_variant("BUILD_RANDOMACCESS", "random_access"),
+ self.define_from_variant("BUILD_FORTRAN", "fortran"),
+ self.define_from_variant("BUILD_SHARED_LIBS", "shared"),
+ self.define_from_variant("BUILD_STATS", "stats"),
+ self.define("BUILD_TESTS", self.pkg.run_tests),
+ self.define_from_variant("BUILD_PYTHON_WRAPPER", "python"),
+ ]
+
+ if "+python" in self.spec:
+ result.append(self.define("SZ_PYTHON_SITELIB", python_platlib))
+
+ return result
diff --git a/var/spack/repos/builtin/packages/timemory/package.py b/var/spack/repos/builtin/packages/timemory/package.py
index 759a7437d1..f30e578779 100644
--- a/var/spack/repos/builtin/packages/timemory/package.py
+++ b/var/spack/repos/builtin/packages/timemory/package.py
@@ -8,7 +8,7 @@
from spack.package import *
-class Timemory(CMakePackage, PythonPackage):
+class Timemory(CMakePackage, PythonExtension):
"""Modular profiling toolkit and suite of libraries and tools
for C/C++/Fortran/CUDA/Python"""
diff --git a/var/spack/repos/builtin/packages/uncrustify/package.py b/var/spack/repos/builtin/packages/uncrustify/package.py
index a9148c01e5..b528302ff6 100644
--- a/var/spack/repos/builtin/packages/uncrustify/package.py
+++ b/var/spack/repos/builtin/packages/uncrustify/package.py
@@ -6,7 +6,7 @@
from spack.package import *
-class Uncrustify(Package):
+class Uncrustify(CMakePackage, AutotoolsPackage):
"""Source Code Beautifier for C, C++, C#, ObjectiveC, Java, and others."""
homepage = "http://uncrustify.sourceforge.net/"
@@ -31,28 +31,15 @@ class Uncrustify(Package):
version("0.62", commit="5987f2")
version("0.61", sha256="1df0e5a2716e256f0a4993db12f23d10195b3030326fdf2e07f8e6421e172df9")
- depends_on("cmake", type="build", when="@0.64:")
- depends_on("automake", type="build", when="@0.63")
- depends_on("autoconf", type="build", when="@0.63")
-
- @when("@0.64:")
- def install(self, spec, prefix):
- with working_dir("spack-build", create=True):
- cmake("..", *std_cmake_args)
- make()
- make("install")
-
- @when("@0.63")
- def install(self, spec, prefix):
- which("bash")("autogen.sh")
- configure("--prefix={0}".format(self.prefix))
- make()
- make("install")
-
- @when("@:0.62")
- def install(self, spec, prefix):
- configure("--prefix={0}".format(self.prefix))
- make()
- make("install")
+ build_system(
+ conditional("cmake", when="@0.64:"),
+ conditional("autotools", when="@:0.63"),
+ default="cmake",
+ )
+
+ with when("build_system=autotools"):
+ depends_on("automake", type="build")
+ depends_on("autoconf", type="build")
+ depends_on("libtool", type="build", when="@0.63")
patch("uncrustify-includes.patch", when="@0.73")
diff --git a/var/spack/repos/builtin/packages/zlib/package.py b/var/spack/repos/builtin/packages/zlib/package.py
index 76add72552..58db86f6b2 100644
--- a/var/spack/repos/builtin/packages/zlib/package.py
+++ b/var/spack/repos/builtin/packages/zlib/package.py
@@ -9,10 +9,12 @@
import glob
import os
+import spack.build_systems.generic
+import spack.build_systems.makefile
from spack.package import *
-class Zlib(Package):
+class Zlib(MakefilePackage, Package):
"""A free, general-purpose, legally unencumbered lossless
data-compression library.
"""
@@ -43,10 +45,14 @@ class Zlib(Package):
deprecated=True,
)
+ build_system("makefile", conditional("generic", when="platform=windows"), default="makefile")
+
variant("pic", default=True, description="Produce position-independent code (for shared libs)")
variant("shared", default=True, description="Enables the build of shared libraries.")
variant("optimize", default=True, description="Enable -O2 for a more optimized lib")
+ conflicts("build_system=makefile", when="platform=windows")
+
patch("w_patch.patch", when="@1.2.11%cce")
patch("configure-cc.patch", when="@1.2.12")
@@ -55,11 +61,31 @@ class Zlib(Package):
shared = "+shared" in self.spec
return find_libraries(["libz"], root=self.prefix, recursive=True, shared=shared)
- def win_install(self):
- build_dir = self.stage.source_path
- install_tree = {}
- install_tree["bin"] = glob.glob(os.path.join(build_dir, "*.dll"))
- install_tree["lib"] = glob.glob(os.path.join(build_dir, "*.lib"))
+
+class SetupEnvironment(object):
+ def setup_build_environment(self, env):
+ if "+pic" in self.spec:
+ env.append_flags("CFLAGS", self.pkg.compiler.cc_pic_flag)
+ if "+optimize" in self.spec:
+ env.append_flags("CFLAGS", "-O2")
+
+
+class MakefileBuilder(spack.build_systems.makefile.MakefileBuilder, SetupEnvironment):
+ def edit(self, pkg, spec, prefix):
+ config_args = []
+ if "~shared" in self.spec:
+ config_args.append("--static")
+ configure("--prefix={0}".format(prefix), *config_args)
+
+
+class GenericBuilder(spack.build_systems.generic.GenericBuilder, SetupEnvironment):
+ def install(self, spec, prefix):
+ nmake("-f" "win32\\Makefile.msc")
+ build_dir = self.pkg.stage.source_path
+ install_tree = {
+ "bin": glob.glob(os.path.join(build_dir, "*.dll")),
+ "lib": glob.glob(os.path.join(build_dir, "*.lib")),
+ }
compose_src_path = lambda x: os.path.join(build_dir, x)
install_tree["include"] = [compose_src_path("zlib.h"), compose_src_path("zconf.h")]
# Windows path seps are fine here as this method is Windows specific.
@@ -76,24 +102,3 @@ class Zlib(Package):
install(file, install_dst)
installtree(self.prefix, install_tree)
-
- def setup_build_environment(self, env):
- if "+pic" in self.spec:
- env.append_flags("CFLAGS", self.compiler.cc_pic_flag)
- if "+optimize" in self.spec:
- env.append_flags("CFLAGS", "-O2")
-
- def install(self, spec, prefix):
- if "platform=windows" in self.spec:
- nmake("-f" "win32\\Makefile.msc")
- self.win_install()
- else:
- config_args = []
- if "~shared" in spec:
- config_args.append("--static")
- configure("--prefix={0}".format(prefix), *config_args)
-
- make()
- if self.run_tests:
- make("check")
- make("install")