@@ -6,6 +6,8 @@ export Dependency, BuildDependency, HostBuildDependency,
66
77# Pkg.PackageSpec return different types in different Julia versions so...
88const PkgSpec = typeof (Pkg. PackageSpec (name= " dummy" ))
9+ const PKG_VERSIONS = Base. VERSION >= v " 1.7-" ? Pkg. Versions : Pkg. Types
10+
911
1012"""
1113An `AbstractDependency` is a binary dependency of the JLL package. Dependencies
@@ -52,7 +54,7 @@ Return whether `dep` is a runtime dependency or not.
5254is_runtime_dependency
5355
5456"""
55- Dependency(dep::Union{PackageSpec,String})
57+ Dependency(dep::Union{PackageSpec,String}, build_version; compat )
5658
5759Define a binary dependency that is necessary to build the package and load the
5860generated JLL package. The argument can be either a string with the name of the
@@ -61,20 +63,28 @@ JLL package or a `Pkg.PackageSpec`.
6163The optional keyword argument `build_version` can be used to specify the version
6264of the dependency to be installed when building it.
6365
64- The optional keyword argument `compat` can be used to specify a string for
65- use in the `Project.toml` of the generated Julia package.
66+ The optional keyword argument `compat` can be used to specify a string for use
67+ in the `Project.toml` of the generated Julia package. If `compat` is non-empty
68+ and `build_version` is not passed, the latter defaults to the minimum version
69+ compatible with the `compat` specifier.
6670"""
6771struct Dependency <: AbstractDependency
6872 pkg:: PkgSpec
6973 build_version:: Union{VersionNumber,Nothing}
7074 compat:: String # semver string for use in Project.toml of the JLL
7175 function Dependency (pkg:: PkgSpec , build_version = nothing ; compat:: String = " " )
7276 if length (compat) > 0
73- spec = Pkg. Types. semver_spec (compat) # verify compat is valid
74- if build_version != = nothing && ! (build_version in spec)
77+ spec = PKG_VERSIONS. semver_spec (compat) # verify compat is valid
78+ if build_version === nothing
79+ # Since we usually want to build against the oldest compatible
80+ # version, if `build_version` isn't set but `compat` is, make it
81+ # default to the minimum compatible version.
82+ build_version = minimum (VersionNumber (rng. lower. t) for rng in spec. ranges)
83+ end
84+ if build_version ∉ spec
7585 throw (ArgumentError (" build_version and compat for $(pkg) are incompatible" ))
7686 end
77- if pkg. version != Pkg . Types . VersionSpec (" *" ) && ! (pkg. version in spec)
87+ if pkg. version != PKG_VERSIONS . VersionSpec (" *" ) && ! (pkg. version in spec)
7888 throw (ArgumentError (" PackageSpec version and compat for $(pkg) are incompatible" ))
7989 end
8090 end
0 commit comments