Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(JLLEnvs): try to load local Artifacts.toml if existed #372

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Clang_jll = "0ee61d77-7f21-5576-8119-9fcc46b10100"
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[compat]
CEnum = "0.4"
Expand Down
27 changes: 25 additions & 2 deletions src/shards/JLLEnvs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,41 @@ module JLLEnvs
using Pkg
using Pkg.Artifacts
using Downloads
using UUIDs

include("utils.jl")

const JLL_ENV_SHARDS_URL = "https://raw.githubusercontent.com/JuliaPackaging/BinaryBuilderBase.jl/master/Artifacts.toml"
const JLL_ENV_SHARDS = Dict{String,Any}()

function _checked_import(pkgid)
Base.root_module_exists(pkgid) && return Base.root_module(pkgid)
Base.require(pkgid)
end

function __init__()
if haskey(ENV, "JULIA_CLANG_SHARDS_URL") && !isempty(get(ENV, "JULIA_CLANG_SHARDS_URL", ""))
merge!(JLL_ENV_SHARDS, Artifacts.load_artifacts_toml(ENV["JULIA_CLANG_SHARDS_URL"]))
else
merge!(JLL_ENV_SHARDS, Artifacts.load_artifacts_toml(Downloads.download(JLL_ENV_SHARDS_URL)))
return
end
Comment on lines 19 to 22
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still keep the JULIA_CLANG_SHARDS_URL environment flag of the highest priority so that people can still debug with specific Artifacts.toml version.


# If possible, try to load stable version of Artifacts.toml from local disk cache and thus
# makes `using Clang` faster. This requires `BinaryBuilderBase` available in `DEPOT_PATH`,
# e.g., via `(@v1.7) pkg> add BinaryBuilderBase`.
id_BinaryBuilderBase = Base.PkgId(UUID("7f725544-6523-48cd-82d1-3fa08ff4056e"), "BinaryBuilderBase")
artifact_file = ""
try
artifact_file = joinpath(pkgdir(_checked_import(id_BinaryBuilderBase)), "Artifacts.toml")
catch e
@debug e
end
if isfile(artifact_file)
merge!(JLL_ENV_SHARDS, Artifacts.load_artifacts_toml(artifact_file))
end
isempty(JLL_ENV_SHARDS) || return

@debug "Failed to load package `BinaryBuilderBase`, fetching from remote resources..."
merge!(JLL_ENV_SHARDS, Artifacts.load_artifacts_toml(Downloads.download(JLL_ENV_SHARDS_URL)))
end

const JLL_ENV_HOST_TRIPLE = "x86_64-linux-musl"
Expand Down