Skip to content

Commit a3d21e6

Browse files
authored
Produce compat entries in Project.toml (#1023)
... using the optional meta data provided by users in BBB's Dependency type.
1 parent 2e355c2 commit a3d21e6

File tree

4 files changed

+21
-26
lines changed

4 files changed

+21
-26
lines changed

Manifest.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
2828

2929
[[BinaryBuilderBase]]
3030
deps = ["CodecZlib", "Downloads", "InteractiveUtils", "JSON", "LibGit2", "Libdl", "Logging", "OutputCollectors", "Pkg", "Random", "SHA", "Scratch", "SimpleBufferStream", "TOML", "Tar", "UUIDs", "p7zip_jll", "pigz_jll"]
31-
git-tree-sha1 = "87236ea2e2cf83b4a5bbeb29bc76c94f4a3252d4"
31+
git-tree-sha1 = "c3ceefb6a48993dd35514fac7f00f8e7b7addb2b"
3232
repo-rev = "master"
3333
repo-url = "https://github.com/JuliaPackaging/BinaryBuilderBase.jl.git"
3434
uuid = "7f725544-6523-48cd-82d1-3fa08ff4056e"

src/AutoBuild.jl

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,18 @@ function build_tarballs(ARGS, src_name, src_version, sources, script,
133133
sources = coerce_source.(sources)
134134
dependencies = coerce_dependency.(dependencies)
135135

136+
# Reject user supplied dependencies using a VersionSpec: these should
137+
# either use compat, or build_version, or both (depending on what they are
138+
# trying to achieve). We cannot check for this in the Dependency
139+
# constructor, as there are several valid situations in which we *do* want
140+
# to store versions here (e.g. after running the dependency through the
141+
# package resolver).
142+
for dep in dependencies
143+
if dep isa Dependency && dep.pkg.version != Pkg.Types.VersionSpec("*")
144+
error("Dependency $(dep.pkg.name) specifies a version, use build_version and/or compat instead")
145+
end
146+
end
147+
136148
# Do not clobber caller's ARGS
137149
ARGS = deepcopy(ARGS)
138150

@@ -1369,24 +1381,6 @@ const uuid_package = UUID("cfb74b52-ec16-5bb7-a574-95d9e393895e")
13691381
# "_jll" to the name of the new package before computing its UUID.
13701382
jll_uuid(name) = bb_specific_uuid5(uuid_package, "$(name)_jll")
13711383
function build_project_dict(name, version, dependencies::Array{Dependency}, julia_compat::String=DEFAULT_JULIA_VERSION_SPEC; lazy_artifacts::Bool=false, kwargs...)
1372-
function has_compat_info(d::Dependency)
1373-
r = Pkg.Types.VersionRange()
1374-
return isa(d.pkg.version, VersionNumber) ||
1375-
length(d.pkg.version.ranges) != 1 ||
1376-
d.pkg.version.ranges[1] != r
1377-
end
1378-
function exactly_this_version(v::VersionNumber)
1379-
return string("=", VersionNumber(v.major, v.minor, v.patch))
1380-
end
1381-
function exactly_this_version(v::Pkg.Types.VersionSpec)
1382-
if length(v.ranges) == 1 &&
1383-
v.ranges[1].lower.n == 3 &&
1384-
v.ranges[1].lower == v.ranges[1].upper
1385-
return string("=", v)
1386-
end
1387-
return string(v)
1388-
end
1389-
exactly_this_version(v) = v
13901384
Pkg.Types.semver_spec(julia_compat) # verify julia_compat is valid
13911385
project = Dict(
13921386
"name" => "$(name)_jll",
@@ -1401,8 +1395,9 @@ function build_project_dict(name, version, dependencies::Array{Dependency}, juli
14011395
for dep in dependencies
14021396
depname = getname(dep)
14031397
project["deps"][depname] = string(jll_uuid(depname))
1404-
if has_compat_info(dep)
1405-
project["compat"][depname] = string(exactly_this_version(dep.pkg.version))
1398+
if dep isa Dependency && length(dep.compat) > 0
1399+
Pkg.Types.semver_spec(dep.compat) # verify dep.compat is valid
1400+
project["compat"][depname] = dep.compat
14061401
end
14071402
end
14081403
# Always add Libdl, Pkg and Artifacts as dependencies

test/basic.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,21 +221,21 @@ end
221221

222222
# Ensure passing compat bounds works
223223
dependencies = [
224-
Dependency(PackageSpec(name="libLLVM_jll", version=v"9")),
224+
Dependency(PackageSpec(name="libLLVM_jll"), compat="=9.0.0"),
225225
]
226226
dict = build_project_dict("Clang", v"9.0.1+2", dependencies)
227227
@test dict["compat"]["julia"] == "1.0"
228228
@test dict["compat"]["libLLVM_jll"] == "=9.0.0"
229229

230230
dependencies = [
231-
Dependency(PackageSpec(name="libLLVM_jll", version="8.3-10")),
231+
Dependency(PackageSpec(name="libLLVM_jll"), compat="8.3 - 10"),
232232
]
233233
dict = build_project_dict("Clang", v"9.0.1+2", dependencies)
234234
@test dict["compat"]["julia"] == "1.0"
235-
@test dict["compat"]["libLLVM_jll"] == "8.3-10"
235+
@test dict["compat"]["libLLVM_jll"] == "8.3 - 10"
236236

237237
dependencies = [
238-
Dependency(PackageSpec(name="libLLVM_jll", version="8.3.0-8.3")),
238+
Dependency(PackageSpec(name="libLLVM_jll"), compat="8.3"),
239239
]
240240
dict = build_project_dict("Clang", v"9.0.1+2", dependencies)
241241
@test dict["compat"]["libLLVM_jll"] == "8.3"

test/jll.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module TestJLL end
88
@test jll_uuid("Zlib_jll") == UUID("83775a58-1f1d-513f-b197-d71354ab007a")
99
@test jll_uuid("FFMPEG_jll") == UUID("b22a6f82-2f65-5046-a5b2-351ab43fb4e5")
1010

11-
project = build_project_dict("LibFoo", v"1.3.5", [Dependency("Zlib_jll"), Dependency(PackageSpec(name = "XZ_jll", version = v"2.4.6"))])
11+
project = build_project_dict("LibFoo", v"1.3.5", [Dependency("Zlib_jll"), Dependency(PackageSpec(name = "XZ_jll"), compat = "=2.4.6")])
1212
@test project["deps"] == Dict("JLLWrappers" => "692b3bcd-3c85-4b1f-b108-f13ce0eb3210",
1313
"Artifacts" => "56f22d72-fd6d-98f1-02f0-08ddc0907c33",
1414
"Pkg" => "44cfe95a-1eb2-52ea-b672-e2afdf69b78f",

0 commit comments

Comments
 (0)