Skip to content

Commit 201aefc

Browse files
figure out if extension from pkgorigins
1 parent 88c90ca commit 201aefc

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

base/loading.jl

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,9 +1242,9 @@ function _include_from_serialized(pkg::PkgId, path::String, ocachepath::Union{No
12421242
elapsed = round((time_ns() - t_before) / 1e6, digits = 1)
12431243
comp_time, recomp_time = cumulative_compile_time_ns() .- t_comp_before
12441244
print(lpad(elapsed, 9), " ms ")
1245-
parentid = get(EXT_PRIMED, pkg, nothing)
1246-
if parentid !== nothing
1247-
print(parentid.name, "")
1245+
ext_parent = extension_parent_name(M)
1246+
if ext_parent !== nothing
1247+
print(ext_parent::String, "")
12481248
end
12491249
print(pkg.name)
12501250
if comp_time > 0
@@ -1266,6 +1266,27 @@ function _include_from_serialized(pkg::PkgId, path::String, ocachepath::Union{No
12661266
end
12671267
end
12681268

1269+
# if M is an extension, return the string name of the parent. Otherwise return nothing
1270+
function extension_parent_name(M::Module)
1271+
rootmodule = moduleroot(M)
1272+
src_path = pathof(rootmodule)
1273+
src_path === nothing && return nothing
1274+
pkgdir_parts = splitpath(src_path)
1275+
ext_pos = findlast(==("ext"), pkgdir_parts)
1276+
if ext_pos !== nothing && ext_pos >= length(pkgdir_parts) - 2
1277+
parent_package_root = joinpath(pkgdir_parts[1:ext_pos-1]...)
1278+
parent_package_project_file = locate_project_file(parent_package_root)
1279+
if parent_package_project_file isa String
1280+
d = parsed_toml(parent_package_project_file)
1281+
name = get(d, "name", nothing)
1282+
if name !== nothing
1283+
return name
1284+
end
1285+
end
1286+
end
1287+
return nothing
1288+
end
1289+
12691290
function register_restored_modules(sv::SimpleVector, pkg::PkgId, path::String)
12701291
# This function is also used by PkgCacheInspector.jl
12711292
restored = sv[1]::Vector{Any}
@@ -1447,7 +1468,7 @@ function _insert_extension_triggers(parent::PkgId, extensions::Dict{String, Any}
14471468
triggers = triggers::Union{String, Vector{String}}
14481469
triggers isa String && (triggers = [triggers])
14491470
id = PkgId(uuid5(parent.uuid::UUID, ext), ext)
1450-
if id in keys(EXT_PRIMED) || haskey(Base.loaded_modules, id)
1471+
if haskey(EXT_PRIMED, id) || haskey(Base.loaded_modules, id)
14511472
continue # extension is already primed or loaded, don't add it again
14521473
end
14531474
EXT_PRIMED[id] = parent

0 commit comments

Comments
 (0)