Skip to content

Commit

Permalink
Allow for futurue expansion in pkgorigins
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy committed Sep 6, 2020
1 parent ffb8e01 commit 7887cd9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 8 additions & 3 deletions base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -813,13 +813,18 @@ function require(into::Module, mod::Symbol)
return require(uuidkey, cache)
end

const pkgcachefiles = Dict{PkgId,String}()
struct PkgOrigin
# version::VersionNumber
# path::String
cachepath::Union{String,Nothing}
end
const pkgorigins = Dict{PkgId,PkgOrigin}()

function require(uuidkey::PkgId, cache::TOMLCache=TOMLCache())
if !root_module_exists(uuidkey)
cachefile = _require(uuidkey, cache)
if cachefile !== nothing
pkgcachefiles[uuidkey] = cachefile
pkgorigins[uuidkey] = PkgOrigin(cachefile)
end
# After successfully loading, notify downstream consumers
for callback in package_callbacks
Expand Down Expand Up @@ -1480,7 +1485,7 @@ function stale_cachefile(modpath::String, cachefile::String, cache::TOMLCache)
end

if isa(id, PkgId)
pkgcachefiles[id] = cachefile
pkgorigins[id] = PkgOrigin(cachefile)
end

return depmods # fresh cachefile
Expand Down
4 changes: 2 additions & 2 deletions test/precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,8 @@ try
cachefile = joinpath(cachedir, "$UsesB_module.ji")
modules, (deps, requires), required_modules = Base.parse_cache_header(cachefile)
id1, id2 = only(requires)
@test Base.pkgcachefiles[id1] == cachefile
@test Base.pkgcachefiles[id2] == joinpath(cachedir, "$B_module.ji")
@test Base.pkgorigins[id1].cachepath == cachefile
@test Base.pkgorigins[id2].cachepath == joinpath(cachedir, "$B_module.ji")

Baz_file = joinpath(dir, "Baz.jl")
write(Baz_file,
Expand Down

0 comments on commit 7887cd9

Please sign in to comment.