@@ -65,7 +65,7 @@ Return whether `dep` is a runtime dependency or not.
65
65
is_runtime_dependency
66
66
67
67
"""
68
- is_top_level_dependency(dep::AbstractDependency) ->
68
+ is_top_level_dependency(dep::AbstractDependency) -> Bool
69
69
70
70
Return wheter `dep` is a top-level dependency or not.
71
71
"""
@@ -128,6 +128,7 @@ struct Dependency <: AbstractDependency
128
128
end
129
129
end
130
130
if top_level
131
+ @warn (" Dependency(\" $(getname (pkg)) \" ) was defined as top-level but this is deprecated, use `RuntimeDependency` instead" )
131
132
if ! (isempty (platforms) || all (p-> p== AnyPlatform (), platforms))
132
133
throw (ArgumentError (" A top-level dependency can't be restricted to platforms." ))
133
134
end
@@ -147,7 +148,7 @@ is_runtime_dependency(::Dependency) = true
147
148
is_top_level_dependency (dep:: Dependency ) = dep. top_level
148
149
149
150
"""
150
- RuntimeDependency(dep::Union{PackageSpec,String}; compat::String, platforms::Vector{<:AbstractPlatform})
151
+ RuntimeDependency(dep::Union{PackageSpec,String}; compat::String, platforms::Vector{<:AbstractPlatform}, top_level::Bool=false )
151
152
152
153
Define a binary dependency that is only listed as dependency of the generated JLL package,
153
154
but its artifact is not installed in the prefix during the build. The `dep` argument can be
@@ -159,27 +160,40 @@ in the `Project.toml` of the generated Julia package.
159
160
The optional keyword argument `platforms` is a vector of `AbstractPlatform`s which indicates
160
161
for which platforms the dependency should be used. By default `platforms=[AnyPlatform()]`,
161
162
to mean that the dependency is compatible with all platforms.
163
+
164
+ The optional keyword argument `top_level` specifies whether the dependency should be use
165
+ only at the top-level of the generated JLL package, instead of inside each platform-specific
166
+ wrapper. Using `top_level=true` is useful for packages needed for platform augmentation
167
+ (e.g. `MPIPreferences.jl`).
162
168
"""
163
169
struct RuntimeDependency <: AbstractDependency
164
170
pkg:: PkgSpec
165
171
compat:: String # semver string for use in Project.toml of the JLL
166
172
platforms:: Vector{<:AbstractPlatform}
173
+ top_level:: Bool
167
174
function RuntimeDependency (pkg:: PkgSpec ; compat:: String = " " ,
168
- platforms:: Vector{<:AbstractPlatform} = [AnyPlatform ()])
175
+ platforms:: Vector{<:AbstractPlatform} = [AnyPlatform ()],
176
+ top_level:: Bool = false )
169
177
if ! isempty (compat)
170
178
spec = PKG_VERSIONS. semver_spec (compat) # verify compat is valid
171
179
if pkg. version != PKG_VERSIONS. VersionSpec (" *" ) && ! (pkg. version in spec)
172
180
throw (ArgumentError (" PackageSpec version and compat for $(pkg) are incompatible" ))
173
181
end
174
182
end
175
- return new (pkg, compat, platforms)
183
+ if top_level
184
+ if ! (isempty (platforms) || all (== (AnyPlatform ()), platforms))
185
+ throw (ArgumentError (" A top-level dependency can't be restricted to platforms." ))
186
+ end
187
+ end
188
+ return new (pkg, compat, platforms, top_level)
176
189
end
177
190
end
178
- RuntimeDependency (name:: AbstractString ; compat:: String = " " , platforms:: Vector{<:AbstractPlatform} = [AnyPlatform ()]) =
179
- RuntimeDependency (PackageSpec (; name); compat, platforms)
191
+ RuntimeDependency (name:: AbstractString ; compat:: String = " " , platforms:: Vector{<:AbstractPlatform} = [AnyPlatform ()], top_level :: Bool = false ) =
192
+ RuntimeDependency (PackageSpec (; name); compat, platforms, top_level )
180
193
is_host_dependency (:: RuntimeDependency ) = false
181
194
is_build_dependency (:: RuntimeDependency ) = false
182
195
is_runtime_dependency (:: RuntimeDependency ) = true
196
+ is_top_level_dependency (dep:: RuntimeDependency ) = dep. top_level
183
197
# In some cases we may want to automatically convert a `RuntimeDependency` to a `Dependency`
184
198
Base. convert (:: Type{Dependency} , dep:: RuntimeDependency ) =
185
199
Dependency (dep. pkg; compat= dep. compat, platforms= dep. platforms)
@@ -355,7 +369,7 @@ function dependencify(d::Dict)
355
369
if d[" type" ] == " dependency"
356
370
return Dependency (spec; compat, platforms, top_level)
357
371
elseif d[" type" ] == " runtimedependency"
358
- return RuntimeDependency (spec; compat, platforms)
372
+ return RuntimeDependency (spec; compat, platforms, top_level )
359
373
elseif d[" type" ] == " builddependency"
360
374
return BuildDependency (spec; platforms)
361
375
elseif d[" type" ] == " hostdependency"
0 commit comments