Skip to content

Commit ab23ef8

Browse files
fingolfinstaticfloat
authored andcommitted
Add julia_compat keyword argument to build_tarballs
1 parent bc6ecad commit ab23ef8

File tree

2 files changed

+31
-11
lines changed

2 files changed

+31
-11
lines changed

src/AutoBuild.jl

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ using RegistryTools, Registrator
66
import LibGit2
77
import PkgLicenses
88

9+
const DEFAULT_JULIA_VERSION_SPEC = "1.0"
10+
911
const BUILD_HELP = (
1012
"""
1113
Usage: build_tarballs.jl [target1,target2,...] [--help]
@@ -85,6 +87,10 @@ see what it can do, you can call it with `--help` in the `ARGS` or see the
8587
The `kwargs` are passed on to [`autobuild`](@ref), see there for a list of
8688
supported ones. A few additional keyword arguments are accept:
8789
90+
* `julia_compat` can be set to a version string which is used to set the
91+
supported Julia version in the `[compat]` section of the `Project.toml` of
92+
the generated JLL package. The default value is `"1.0"`.
93+
8894
* `lazy_artifacts` sets whether the artifacts should be lazy.
8995
9096
* `init_block` may be set to a string containing Julia code; if present, this
@@ -224,7 +230,7 @@ function build_tarballs(ARGS, src_name, src_version, sources, script,
224230
# Dependencies that must be downloaded
225231
dependencies,
226232
)
227-
extra_kwargs = extract_kwargs(kwargs, (:lazy_artifacts, :init_block))
233+
extra_kwargs = extract_kwargs(kwargs, (:julia_compat, :lazy_artifacts, :init_block))
228234

229235
if meta_json_stream !== nothing
230236
# If they've asked for the JSON metadata, by all means, give it to them!
@@ -272,7 +278,7 @@ function build_tarballs(ARGS, src_name, src_version, sources, script,
272278
@info("Registering new wrapper code version $(build_version)...")
273279
end
274280

275-
register_jll(src_name, build_version, dependencies;
281+
register_jll(src_name, build_version, dependencies, julia_compat;
276282
deploy_repo=deploy_jll_repo, code_dir=code_dir)
277283
end
278284
end
@@ -427,7 +433,7 @@ function _package_is_registered(registry_url::AbstractString,
427433
return package in registered_packages
428434
end
429435

430-
function register_jll(name, build_version, dependencies;
436+
function register_jll(name, build_version, dependencies, julia_compat;
431437
deploy_repo="JuliaBinaryWrappers/$(name)_jll.jl",
432438
code_dir=joinpath(Pkg.devdir(), "$(name)_jll"),
433439
gh_auth=Wizard.github_auth(;allow_anonymous=false),
@@ -443,7 +449,7 @@ function register_jll(name, build_version, dependencies;
443449
cache = RegistryTools.RegistryCache(joinpath(Pkg.depots1(), "registries_binarybuilder"))
444450
registry_url = "https://$(gh_username):$(gh_auth.token)@github.com/JuliaRegistries/General"
445451
cache.registries[registry_url] = Base.UUID("23338594-aafe-5451-b93e-139f81909106")
446-
project = Pkg.Types.Project(build_project_dict(name, build_version, dependencies))
452+
project = Pkg.Types.Project(build_project_dict(name, build_version, dependencies, julia_compat))
447453
errors = setdiff(RegistryTools.registrator_errors, [:version_less_than_all_existing])
448454
reg_branch = RegistryTools.register(
449455
"https://github.com/$(deploy_repo).git",
@@ -490,6 +496,7 @@ function get_meta_json(
490496
platforms::Vector,
491497
products::Vector{<:Product},
492498
dependencies::Vector{<:AbstractDependency};
499+
julia_compat::String = DEFAULT_JULIA_VERSION_SPEC,
493500
lazy_artifacts::Bool = false,
494501
init_block::String = "")
495502

@@ -500,6 +507,7 @@ function get_meta_json(
500507
"script" => script,
501508
"products" => products,
502509
"dependencies" => dependencies,
510+
"julia_compat" => julia_compat,
503511
"lazy_artifacts" => lazy_artifacts,
504512
"init_block" => init_block,
505513
)
@@ -926,6 +934,7 @@ function rebuild_jll_package(obj::Dict;
926934
upload_prefix;
927935
verbose=verbose,
928936
lazy_artifacts = lazy_artifacts,
937+
julia_compat = get(obj, "julia_compat", DEFAULT_JULIA_VERSION_SPEC),
929938
init_block = get(obj, "init_block", ""),
930939
from_scratch = from_scratch,
931940
)
@@ -935,8 +944,8 @@ function rebuild_jll_package(name::String, build_version::VersionNumber, sources
935944
platforms::Vector, products::Vector, dependencies::Vector,
936945
download_dir::String, upload_prefix::String;
937946
code_dir::String = joinpath(Pkg.devdir(), "$(name)_jll"),
938-
verbose::Bool = false, lazy_artifacts::Bool = false,
939-
init_block::String = "", from_scratch::Bool = true)
947+
verbose::Bool = false, from_scratch::Bool = true,
948+
kwargs...)
940949
# We're going to recreate "build_output_meta"
941950
build_output_meta = Dict()
942951

@@ -999,7 +1008,7 @@ function rebuild_jll_package(name::String, build_version::VersionNumber, sources
9991008
# Finally, generate the full JLL package
10001009
build_jll_package(name, build_version, sources, code_dir, build_output_meta,
10011010
dependencies, upload_prefix; verbose=verbose,
1002-
lazy_artifacts=lazy_artifacts, init_block=init_block)
1011+
kwargs...)
10031012
end
10041013
end
10051014

@@ -1011,6 +1020,7 @@ function build_jll_package(src_name::String,
10111020
dependencies::Vector,
10121021
bin_path::String;
10131022
verbose::Bool = false,
1023+
julia_compat::String = DEFAULT_JULIA_VERSION_SPEC,
10141024
lazy_artifacts::Bool = false,
10151025
init_block = "")
10161026
if !Base.isidentifier(src_name)
@@ -1444,7 +1454,7 @@ function build_jll_package(src_name::String,
14441454
rm(joinpath(code_dir, "LICENSE.md"); force=true)
14451455

14461456
# Add a Project.toml
1447-
project = build_project_dict(src_name, build_version, dependencies)
1457+
project = build_project_dict(src_name, build_version, dependencies, julia_compat)
14481458
open(joinpath(code_dir, "Project.toml"), "w") do io
14491459
Pkg.TOML.print(io, project)
14501460
end
@@ -1486,7 +1496,7 @@ const uuid_package = UUID("cfb74b52-ec16-5bb7-a574-95d9e393895e")
14861496
# For even more interesting historical reasons, we append an extra
14871497
# "_jll" to the name of the new package before computing its UUID.
14881498
jll_uuid(name) = bb_specific_uuid5(uuid_package, "$(name)_jll")
1489-
function build_project_dict(name, version, dependencies::Array{Dependency})
1499+
function build_project_dict(name, version, dependencies::Array{Dependency}, julia_compat::String=DEFAULT_JULIA_VERSION_SPEC)
14901500
function has_compat_info(d::Dependency)
14911501
r = Pkg.Types.VersionRange()
14921502
return isa(d.pkg.version, VersionNumber) ||
@@ -1504,14 +1514,15 @@ function build_project_dict(name, version, dependencies::Array{Dependency})
15041514
return string(v)
15051515
end
15061516
exactly_this_version(v) = v
1517+
Pkg.Types.semver_spec(julia_compat) # verify julia_compat is valid
15071518
project = Dict(
15081519
"name" => "$(name)_jll",
15091520
"uuid" => string(jll_uuid("$(name)_jll")),
15101521
"version" => string(version),
15111522
"deps" => Dict{String,Any}(),
15121523
# We require at least Julia 1.3+, for Pkg.Artifacts support, but we only claim
1513-
# Julia 1.0+ so that empty JLLs can be installed on older versions.
1514-
"compat" => Dict{String,Any}("julia" => "1.0")
1524+
# Julia 1.0+ by default so that empty JLLs can be installed on older versions.
1525+
"compat" => Dict{String,Any}("julia" => "$(julia_compat)")
15151526
)
15161527
for dep in dependencies
15171528
depname = getname(dep)

test/basic.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,15 @@ end
210210
@test next_version.minor == version.minor
211211
@test next_version.patch == version.patch
212212

213+
# Ensure passing a Julia dependency bound works
214+
dict = build_project_dict(name, version, dependencies, "1.4")
215+
@test dict["compat"] == Dict{String,Any}("julia" => "1.4")
216+
217+
dict = build_project_dict(name, version, dependencies, "~1.4")
218+
@test dict["compat"] == Dict{String,Any}("julia" => "~1.4")
219+
220+
@test_throws ErrorException build_project_dict(name, version, dependencies, "nonsense")
221+
213222
# Ensure passing compat bounds works
214223
dependencies = [
215224
Dependency(PackageSpec(name="libLLVM_jll", version=v"9")),

0 commit comments

Comments
 (0)