Skip to content

Commit

Permalink
figure out if extension from pkgorigins
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth committed Sep 9, 2024
1 parent 95c643a commit f09cad1
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1242,9 +1242,9 @@ function _include_from_serialized(pkg::PkgId, path::String, ocachepath::Union{No
elapsed = round((time_ns() - t_before) / 1e6, digits = 1)
comp_time, recomp_time = cumulative_compile_time_ns() .- t_comp_before
print(lpad(elapsed, 9), " ms ")
parentid = get(EXT_PRIMED, pkg, nothing)
if parentid !== nothing
print(parentid.name, "")
ext_parent = extension_parent(M)
if ext_parent !== nothing
print(ext_parent::String, "")
end
print(pkg.name)
if comp_time > 0
Expand All @@ -1266,6 +1266,25 @@ function _include_from_serialized(pkg::PkgId, path::String, ocachepath::Union{No
end
end

function extension_parent(M::Module)
@show _pkgdir = pkgdir(M)
_pkgdir === nothing && return nothing
pkgdir_parts = splitpath(_pkgdir)
ext_pos = findlast(==("ext"), pkgdir_parts)
if ext_pos !== nothing && ext_pos >= length(pkgdir_parts) - 1
@show parent_package_root = joinpath(pkgdir_parts[1:ext_pos-1]...)
@show parent_package_project_file = locate_project_file(parent_package_root)
if parent_package_project_file isa String
d = parsed_toml(parent_package_project_file)
name = get(d, "name", nothing)
if name !== nothing
return name
end
end
end
return nothing
end

function register_restored_modules(sv::SimpleVector, pkg::PkgId, path::String)
# This function is also used by PkgCacheInspector.jl
restored = sv[1]::Vector{Any}
Expand Down Expand Up @@ -1447,7 +1466,7 @@ function _insert_extension_triggers(parent::PkgId, extensions::Dict{String, Any}
triggers = triggers::Union{String, Vector{String}}
triggers isa String && (triggers = [triggers])
id = PkgId(uuid5(parent.uuid::UUID, ext), ext)
if id in keys(EXT_PRIMED) || haskey(Base.loaded_modules, id)
if haskey(EXT_PRIMED, id) || haskey(Base.loaded_modules, id)
continue # extension is already primed or loaded, don't add it again
end
EXT_PRIMED[id] = parent
Expand Down

0 comments on commit f09cad1

Please sign in to comment.