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 2af598d
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 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,27 @@ function _include_from_serialized(pkg::PkgId, path::String, ocachepath::Union{No
end
end

# if M is an extension, return the string name of the parent. Otherwise return nothing
function extension_parent_name(M::Module)
rootmodule = moduleroot(M)
src_path = pathof(rootmodule)
src_path === nothing && return nothing
pkgdir_parts = splitpath(src_path)
ext_pos = findlast(==("ext"), pkgdir_parts)
if ext_pos !== nothing && ext_pos >= length(pkgdir_parts) - 2
parent_package_root = joinpath(pkgdir_parts[1:ext_pos-1]...)
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 +1468,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 2af598d

Please sign in to comment.