Skip to content

Commit 248ee37

Browse files
committed
simplify
1 parent 32d8efb commit 248ee37

File tree

2 files changed

+30
-36
lines changed

2 files changed

+30
-36
lines changed

src/AutoBuild.jl

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ end
4545

4646
const devdir = Ref(Pkg.devdir())
4747

48-
codedir(name) = joinpath(devdir[], "$(name)_jll")
48+
namejll(name::AbstractString) = name * "_jll"
49+
codedir(name::AbstractString) = joinpath(devdir[], namejll(name))
4950

5051
exclude_logs(_, f) = f != "logs"
5152
only_logs(_, f) = f == "logs"
@@ -237,9 +238,9 @@ function build_tarballs(ARGS, src_name, src_version, sources, script,
237238
meta_json, meta_json_file = extract_flag!(ARGS, "--meta-json")
238239

239240
# This sets whether we are going to deploy our binaries/wrapper code to GitHub releases
240-
deploy, deploy_repo = extract_flag!(ARGS, "--deploy", "JuliaBinaryWrappers/$(src_name)_jll.jl")
241-
deploy_bin, deploy_bin_repo = extract_flag!(ARGS, "--deploy-bin", "JuliaBinaryWrappers/$(src_name)_jll.jl")
242-
deploy_jll, deploy_jll_repo = extract_flag!(ARGS, "--deploy-jll", "JuliaBinaryWrappers/$(src_name)_jll.jl")
241+
deploy, deploy_repo = extract_flag!(ARGS, "--deploy", "JuliaBinaryWrappers/$(namejll(src_name)).jl")
242+
deploy_bin, deploy_bin_repo = extract_flag!(ARGS, "--deploy-bin", "JuliaBinaryWrappers/$(namejll(src_name)).jl")
243+
deploy_jll, deploy_jll_repo = extract_flag!(ARGS, "--deploy-jll", "JuliaBinaryWrappers/$(namejll(src_name)).jl")
243244

244245
# Resolve deploy settings
245246
if deploy
@@ -385,7 +386,7 @@ function build_tarballs(ARGS, src_name, src_version, sources, script,
385386
products_dir = joinpath(pwd(), "products")
386387
if deploy_jll
387388
if verbose
388-
@info("Committing and pushing $(src_name)_jll.jl wrapper code version $(build_version)...")
389+
@info("Committing and pushing $(namejll(src_name)).jl wrapper code version $(build_version)...")
389390
end
390391

391392
# For deploy keep only runtime dependencies.
@@ -528,12 +529,11 @@ function get_next_wrapper_version(src_name::AbstractString, src_version::Version
528529
# Force-update the registry here, since we may have pushed a new version recently
529530
update_registry(devnull)
530531

531-
jll_name = "$(src_name)_jll"
532-
uuid = jll_uuid(jll_name)
532+
uuid = jll_uuid(namejll(src_name))
533533

534534
# If it does, we need to bump the build number up to the next value
535535
build_number = UInt64(0)
536-
if uuid in Pkg.Types.registered_uuids(ctx.registries, jll_name)
536+
if uuid in Pkg.Types.registered_uuids(ctx.registries, namejll(src_name))
537537
# Collect all version numbers of the package across all registries.
538538
versions = VersionNumber[]
539539
for reg in ctx.registries
@@ -587,7 +587,7 @@ is_yggdrasil() = get(ENV, "YGGDRASIL", "false") == "true"
587587
yggdrasil_head() = get(ENV, "BUILDKITE_COMMIT", "")
588588

589589
function register_jll(name, build_version, dependencies, julia_compat;
590-
deploy_repo="JuliaBinaryWrappers/$(name)_jll.jl",
590+
deploy_repo="JuliaBinaryWrappers/$(namejll(name)).jl",
591591
code_dir=_code_dir(name),
592592
gh_auth=Wizard.github_auth(;allow_anonymous=false),
593593
gh_username=gh_get_json(DEFAULT_API, "/user"; auth=gh_auth)["login"],
@@ -625,12 +625,7 @@ function register_jll(name, build_version, dependencies, julia_compat;
625625
@error(reg_branch.metadata["error"])
626626
else
627627
upstream_registry_url = "https://github.com/JuliaRegistries/General"
628-
name_jll = "$(name)_jll"
629-
if _package_is_registered(upstream_registry_url, name_jll)
630-
pr_title = "New version: $(name_jll) v$(build_version)"
631-
else
632-
pr_title = "New package: $(name_jll) v$(build_version)"
633-
end
628+
pr_title = "New $(_package_is_registered(upstream_registry_url, namejll(name)) ? "version" : "package"): $(namejll(name)) v$(build_version)"
634629
# Open pull request against JuliaRegistries/General
635630
body = """
636631
Autogenerated JLL package registration
@@ -1143,7 +1138,7 @@ function rebuild_jll_package(obj::Dict;
11431138
end
11441139
if download_dir === nothing
11451140
download_dir = mktempdir()
1146-
repo = "$(gh_org)/$(obj["name"])_jll.jl"
1141+
repo = "$(gh_org)/$(namejll(obj["name"])).jl"
11471142
tag = "$(obj["name"])-v$(build_version)"
11481143
download_github_release(download_dir, repo, tag; verbose=verbose)
11491144
upload_prefix = "https://github.com/$(repo)/releases/download/$(tag)"
@@ -1303,7 +1298,6 @@ function build_jll_package(src_name::String,
13031298
)
13041299
# Make way, for prince artifacti
13051300
mkpath(joinpath(code_dir, "src", "wrappers"))
1306-
@show code_dir
13071301

13081302
# Drop build dependencies
13091303
dependencies = [d for d in dependencies if is_runtime_dependency(d)]
@@ -1333,7 +1327,7 @@ function build_jll_package(src_name::String,
13331327

13341328
# Generate the platform-specific wrapper code
13351329
open(joinpath(code_dir, "src", "wrappers", "$(triplet(platform)).jl"), "w") do io
1336-
println(io, "# Autogenerated wrapper script for $(src_name)_jll for $(triplet(platform))")
1330+
println(io, "# Autogenerated wrapper script for $(namejll(src_name)) for $(triplet(platform))")
13371331
if !isempty(products_info)
13381332
println(io, """
13391333
export $(join(sort(variable_name.(first.(collect(products_info)))), ", "))
@@ -1574,10 +1568,10 @@ function build_jll_package(src_name::String,
15741568
end
15751569

15761570
# Generate target-demuxing main source file.
1577-
open(joinpath(code_dir, "src", "$(src_name)_jll.jl"), "w") do io
1571+
open(joinpath(code_dir, "src", "$(namejll(src_name)).jl"), "w") do io
15781572
print(io, """
15791573
# Use baremodule to shave off a few KB from the serialized `.ji` file
1580-
baremodule $(src_name)_jll
1574+
baremodule $(namejll(src_name))
15811575
using Base
15821576
using Base: UUID
15831577
""")
@@ -1601,8 +1595,8 @@ function build_jll_package(src_name::String,
16011595
import JLLWrappers
16021596
16031597
JLLWrappers.@generate_main_file_header($(repr(src_name)))
1604-
JLLWrappers.@generate_main_file($(repr(src_name)), $(repr(jll_uuid("$(src_name)_jll"))))
1605-
end # module $(src_name)_jll
1598+
JLLWrappers.@generate_main_file($(repr(src_name)), $(repr(jll_uuid("$(namejll(src_name))"))))
1599+
end # module $(namejll(src_name))
16061600
""")
16071601
end
16081602

@@ -1631,10 +1625,10 @@ function build_jll_package(src_name::String,
16311625
open(joinpath(code_dir, "README.md"), "w") do io
16321626
println(io,
16331627
"""
1634-
# `$(src_name)_jll.jl` (v$(build_version))
1628+
# `$(namejll(src_name)).jl` (v$(build_version))
16351629
""")
16361630
if is_yggdrasil()
1637-
println(io, "[![deps](https://juliahub.com/docs/$(src_name)_jll/deps.svg)](https://juliahub.com/ui/Packages/General/$(src_name)_jll/)\n")
1631+
println(io, "[![deps](https://juliahub.com/docs/$(namejll(src_name))/deps.svg)](https://juliahub.com/ui/Packages/General/$(namejll(src_name))/)\n")
16381632
end
16391633
println(io, """
16401634
This is an autogenerated package constructed using [`BinaryBuilder.jl`](https://github.com/JuliaPackaging/BinaryBuilder.jl).
@@ -1658,15 +1652,15 @@ function build_jll_package(src_name::String,
16581652
println(io, """
16591653
## Sources
16601654
1661-
The tarballs for `$(src_name)_jll.jl` have been built from these sources:""")
1655+
The tarballs for `$(namejll(src_name)).jl` have been built from these sources:""")
16621656
println(io)
16631657
print_source.(Ref(io), sources)
16641658
println(io)
16651659
end
16661660
println(io, """
16671661
## Platforms
16681662
1669-
`$(src_name)_jll.jl` is available for the following platforms:
1663+
`$(namejll(src_name)).jl` is available for the following platforms:
16701664
""")
16711665
for p in sort(collect(platforms), by = triplet)
16721666
println(io, "* `", p, "` (`", triplet(p), "`)")
@@ -1678,7 +1672,7 @@ function build_jll_package(src_name::String,
16781672
println(io, """
16791673
## Dependencies
16801674
1681-
The following JLL packages are required by `$(src_name)_jll.jl`:""")
1675+
The following JLL packages are required by `$(namejll(src_name)).jl`:""")
16821676
println(io)
16831677
print_jll.(Ref(io), sort(dependencies, by = getname))
16841678
end
@@ -1739,12 +1733,12 @@ end
17391733

17401734
function push_jll_package(name, build_version;
17411735
code_dir = codedir(name),
1742-
deploy_repo = "JuliaBinaryWrappers/$(name)_jll.jl",
1736+
deploy_repo = "JuliaBinaryWrappers/$(namejll(name)).jl",
17431737
gh_auth = Wizard.github_auth(;allow_anonymous=false))
17441738
# Next, push up the wrapper code repository
17451739
wrapper_repo = LibGit2.GitRepo(code_dir)
17461740
LibGit2.add!(wrapper_repo, ".")
1747-
commit = LibGit2.commit(wrapper_repo, "$(name)_jll build $(build_version)")
1741+
commit = LibGit2.commit(wrapper_repo, "$(namejll(src_name)) build $(build_version)")
17481742
Wizard.with_gitcreds("x-access-token", gh_auth.token) do creds
17491743
refspecs = ["refs/heads/main"]
17501744
# Fetch the remote repository, to have the relevant refspecs up to date.
@@ -1774,7 +1768,7 @@ end
17741768
const uuid_package = UUID("cfb74b52-ec16-5bb7-a574-95d9e393895e")
17751769
# For even more interesting historical reasons, we append an extra
17761770
# "_jll" to the name of the new package before computing its UUID.
1777-
jll_uuid(name) = bb_specific_uuid5(uuid_package, "$(name)_jll")
1771+
jll_uuid(name) = bb_specific_uuid5(uuid_package, namejll(name))
17781772

17791773
function find_uuid(ctx, pkg)
17801774
if Pkg.Types.has_uuid(pkg)
@@ -1809,8 +1803,8 @@ function build_project_dict(name, version, dependencies::Array{<:AbstractDepende
18091803

18101804
Pkg.Types.semver_spec(julia_compat) # verify julia_compat is valid
18111805
project = Dict(
1812-
"name" => "$(name)_jll",
1813-
"uuid" => string(jll_uuid("$(name)_jll")),
1806+
"name" => namejll(name),
1807+
"uuid" => string(jll_uuid(namejll(name))),
18141808
"version" => string(version),
18151809
"deps" => Dict{String,Any}(),
18161810
# We require at least Julia 1.3+, for Pkg.Artifacts support, but we only claim

test/building.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
mktempdir() do build_path
55
name = "libfoo"
66
build_output_meta = build_tarballs(
7-
["--verbose", "--deploy=local"], name, v"1.0.0", [DirectorySource(build_tests_dir)],
7+
["--deploy=local"], name, v"1.0.0", [DirectorySource(build_tests_dir)],
88
libfoo_make_script, [platform], libfoo_products, Dependency[];
99
skip_audit = true,
1010
)
@@ -14,9 +14,9 @@
1414
for artifact in artifacts_toml[name]
1515
for dl in artifact["download"]
1616
url = dl["url"]
17-
tarball_path = joinpath(build_path, basename(url))
18-
Downloads.download(url, tarball_path)
19-
unpack(tarball_path, testdir)
17+
path = joinpath(build_path, basename(url))
18+
Downloads.download(url, path)
19+
unpack(path, testdir)
2020
end
2121
end
2222
@test isfile(joinpath(Prefix(testdir), "share", "licenses", "libfoo", "LICENSE.md")) # libfoo_make_script

0 commit comments

Comments
 (0)