Windows: Port Libuv (#45413)

* On Windows it is built with CMake, however CMake is built against
  libuv, so libuv must depend on cmake+ownlibs to short circuit the
  circular dependency
* libuv currently fetches the -dist source distribution of libuv for
  certain versions because those versions contain a pre-generated
  ./configure script. However those distributions have all CMake
  files removed, so they cannot be used to build on Windows.
  Because the source distributions are different, this means the
  checksums are different, and necessitates an additional version
  declaration for each version we want to support with CMake.
This commit is contained in:
John W. Parent 2024-08-09 12:13:57 -04:00 committed by GitHub
parent 899ac78887
commit 92e42bbed9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 77 additions and 14 deletions

View File

@ -52,6 +52,7 @@ class Gloo(CMakePackage, CudaPackage):
depends_on("pkgconfig", type="build")
depends_on("libuv@1.26:", when="+libuv")
depends_on("cmake@2.8.12:", type="build")
depends_on("libuv", when="platform=windows")
def cmake_args(self):
return [

View File

@ -2,25 +2,63 @@
# 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
from spack.package import *
class Libuv(AutotoolsPackage):
class Libuv(CMakePackage, AutotoolsPackage):
"""Multi-platform library with a focus on asynchronous IO"""
homepage = "https://libuv.org"
url = "https://dist.libuv.org/dist/v1.44.1/libuv-v1.44.1-dist.tar.gz"
url = "https://dist.libuv.org/dist/v1.44.1/libuv-v1.44.1.tar.gz"
list_url = "https://dist.libuv.org/dist"
list_depth = 1
license("MIT")
version("1.48.0", sha256="c593139feb9061699fdd2f7fde47bb6c1ca77761ae9ec04f052083f1ef46c13b")
version("1.46.0", sha256="94f101111ef3209340d7f09c2aa150ddb4feabd2f9d87d47d9f5bded835b8094")
version("1.45.0", sha256="3793d8c0d6fa587721d010d0555b7e82443fd4e8b3c91e529eb6607592f52b87")
version("1.44.2", sha256="8ff28f6ac0d6d2a31d2eeca36aff3d7806706c7d3f5971f5ee013ddb0bdd2e9e")
version("1.44.1", sha256="b7293cefb470e17774dcf5d62c4c969636172726155b55ceef5092b7554863cc")
version("1.44.0", sha256="6c52494401cfe8d08fb4ec245882f0bd4b1572b5a8e79d6c418b855422a1a27d")
if sys.platform == "win32":
version(
"1.48.0", sha256="7f1db8ac368d89d1baf163bac1ea5fe5120697a73910c8ae6b2fffb3551d59fb"
)
version(
"1.47.0", sha256="20c37a4ca77a2107879473c6c8fa0dc1350e80045df98bfbe78f7cd6d7dd2965"
)
version(
"1.46.0", sha256="111f83958b9fdc65f1489195d25f342b9f7a3e683140c60e62c00fbaccddddce"
)
version(
"1.45.0", sha256="f5b07f65a1e8166e47983a7ed1f42fae0bee08f7458142170c37332fc676a748"
)
version(
"1.44.2", sha256="ccfcdc968c55673c6526d8270a9c8655a806ea92468afcbcabc2b16040f03cb4"
)
version(
"1.44.1", sha256="9d37b63430fe3b92a9386b949bebd8f0b4784a39a16964c82c9566247a76f64a"
)
version(
"1.44.0", sha256="d969fc47b8e39ec909d3f8cfa6a6e616e7c370637068ce2d95fdfcbb7f8467f5"
)
else:
version(
"1.48.0", sha256="c593139feb9061699fdd2f7fde47bb6c1ca77761ae9ec04f052083f1ef46c13b"
)
version(
"1.46.0", sha256="94f101111ef3209340d7f09c2aa150ddb4feabd2f9d87d47d9f5bded835b8094"
)
version(
"1.45.0", sha256="3793d8c0d6fa587721d010d0555b7e82443fd4e8b3c91e529eb6607592f52b87"
)
version(
"1.44.2", sha256="8ff28f6ac0d6d2a31d2eeca36aff3d7806706c7d3f5971f5ee013ddb0bdd2e9e"
)
version(
"1.44.1", sha256="b7293cefb470e17774dcf5d62c4c969636172726155b55ceef5092b7554863cc"
)
version(
"1.44.0", sha256="6c52494401cfe8d08fb4ec245882f0bd4b1572b5a8e79d6c418b855422a1a27d"
)
version("1.43.0", sha256="90d72bb7ae18de2519d0cac70eb89c319351146b90cd3f91303a492707e693a4")
version("1.42.0", sha256="43129625155a8aed796ebe90b8d4c990a73985ec717de2b2d5d3a23cfe4deb72")
version("1.41.1", sha256="65db0c7f2438bc8cd48865de282bf6670027f3557d6e3cb62fb65b2e350a687d")
@ -35,17 +73,33 @@ class Libuv(AutotoolsPackage):
depends_on("c", type="build") # generated
def url_for_version(self, version):
if self.spec.satisfies("@:1.43"):
if self.spec.satisfies("@:1.43") or self.spec.satisfies("build_system=cmake"):
# This version includes CMake files unlike the '-dist' source distribution below
url = "https://dist.libuv.org/dist/v{0}/libuv-v{0}.tar.gz"
else:
# From 1.44 on, the `-dist` download includes a configure script
url = "https://dist.libuv.org/dist/v{0}/libuv-v{0}-dist.tar.gz"
return url.format(version, version)
depends_on("automake", type="build", when="@:1.43.0")
depends_on("autoconf", type="build", when="@:1.43.0")
depends_on("libtool", type="build", when="@:1.43.0")
depends_on("m4", type="build", when="@:1.43.0")
# Windows needs a CMake build, but the cmake-enabled sources do not have a
# pre-generated configure script to enable the autotools build, so: (a)
# pull different sources if you are on Windows and (b) make sure cmake
# build is not chosen on Linux
# (because Linux does not download the cmake-enabled source).
# new libuv versions should only use CMake to prevent the scenario
# described above
build_system(conditional("cmake", when="platform=windows"), "autotools", default="autotools")
with when("build_system=autotools"):
depends_on("automake", type="build", when="@:1.43.0")
depends_on("autoconf", type="build", when="@:1.43.0")
depends_on("libtool", type="build", when="@:1.43.0")
depends_on("m4", type="build", when="@:1.43.0")
with when("build_system=cmake"):
# explicitly require ownlibs to indicate we're short
# circuiting the cmake<->libuv cyclic dependency here
depends_on("cmake+ownlibs")
conflicts(
"%gcc@:4.8",
@ -63,9 +117,17 @@ def url_for_version(self, version):
msg="libuv does not compile with GCC on macOS yet, use clang. "
"See: https://github.com/libuv/libuv/issues/2805",
)
conflicts(
"platform=windows",
when="@:1.20",
msg="Build system for Windows in versions older than 1.21 is"
"broken for versions of MSVC supported by Spack",
)
class AutotoolsBuilder(spack.build_systems.autotools.AutotoolsBuilder):
@when("@:1.43")
def autoreconf(self, spec, prefix):
def autoreconf(self, pkg, spec, prefix):
# This is needed because autogen.sh generates on-the-fly
# an m4 macro needed during configuration
Executable("./autogen.sh")()