|
| 1 | +using Pkg |
| 2 | + |
1 | 3 | @static if VERSION < v"1.1" |
2 | 4 | const PackageEntry = Vector{Dict{String,Any}} |
3 | 5 | else |
4 | 6 | using Pkg.Types: PackageEntry |
5 | 7 | end |
6 | 8 |
|
| 9 | +@static if isdefined(Base, :parsed_toml) |
| 10 | + parsed_toml(args...) = Base.parsed_toml(args...) |
| 11 | +else |
| 12 | + parsed_toml(file) = Pkg.TOML.parsefile(file) |
| 13 | +end |
| 14 | + |
7 | 15 | """ |
8 | 16 | manifest(c::Pkg.Types.Context) |
9 | 17 | Retrieves the UUID -> PackageEntry map from the manifest of a Context. |
@@ -445,13 +453,13 @@ pkg_src_dir(m::Module) = dirname(pathof(m)) |
445 | 453 | function modify_dir(f, s1, s2) |
446 | 454 | # @assert startswith(f, s1) |
447 | 455 | # Removed assertion because of Enums issue |
448 | | - string(s2, f[length(s1)+1:end]) |
| 456 | + replace(f, s1 => s2) |
449 | 457 | end |
450 | 458 |
|
451 | 459 |
|
452 | 460 | # tools to retrieve cache from the cloud |
453 | 461 |
|
454 | | -function get_file_from_cloud(manifest, uuid, environment_path, depot_dir, cache_dir = "../cache", download_dir = "../downloads/", symbolcache_upstream = "https://www.julia-vscode.org/symbolcache") |
| 462 | +function get_file_from_cloud(manifest, uuid, environment_path, depot_dir, cache_dir="../cache", download_dir="../downloads/", symbolcache_upstream="https://www.julia-vscode.org/symbolcache") |
455 | 463 | paths = get_cache_path(manifest, uuid) |
456 | 464 | name = packagename(manifest, uuid) |
457 | 465 | link = string(first(splitext(join([symbolcache_upstream, "store/v1/packages", paths...], '/'))), ".tar.gz") |
@@ -510,7 +518,7 @@ function get_file_from_cloud(manifest, uuid, environment_path, depot_dir, cache_ |
510 | 518 | end |
511 | 519 |
|
512 | 520 | @debug "dirname" dirname(pkg_path) |
513 | | - modify_dirs(cache.val, f -> modify_dir(f, "PLACEHOLDER", joinpath(pkg_path, "src"))) |
| 521 | + modify_dirs(cache.val, f -> modify_dir(f, r"^PLACEHOLDER", joinpath(pkg_path, "src"))) |
514 | 522 | open(file, "w") do io |
515 | 523 | CacheStore.write(io, cache) |
516 | 524 | end |
@@ -556,27 +564,37 @@ function get_pkg_path(pkg::Base.PkgId, env, depot_path) |
556 | 564 | project_file isa Bool && return nothing |
557 | 565 | manifest_file = Base.project_file_manifest_path(project_file) |
558 | 566 |
|
559 | | - d = Base.parsed_toml(manifest_file) |
560 | | - entries = get(d, pkg.name, nothing)::Union{Nothing, Vector{Any}} |
| 567 | + d = parsed_toml(manifest_file) |
| 568 | + if get(d, "manifest_format", "0.0") == "2.0" |
| 569 | + entries = get(d, "deps", nothing) |
| 570 | + entries === nothing && return nothing |
| 571 | + entries = map(e -> e[1], values(entries)) |
| 572 | + else |
| 573 | + entries = get(d, pkg.name, nothing) |
| 574 | + end |
561 | 575 | entries === nothing && return nothing # TODO: allow name to mismatch? |
562 | 576 | for entry in entries |
563 | | - entry = entry::Dict{String, Any} |
564 | | - uuid = get(entry, "uuid", nothing)::Union{Nothing, String} |
| 577 | + entry = entry::Dict{String,Any} |
| 578 | + uuid = get(entry, "uuid", nothing)::Union{Nothing,String} |
565 | 579 | uuid === nothing && continue |
566 | 580 | if UUID(uuid) === pkg.uuid |
567 | | - path = get(entry, "path", nothing)::Union{Nothing, String} |
| 581 | + path = get(entry, "path", nothing)::Union{Nothing,String} |
568 | 582 | # this can only be true for explicitly dev'ed packages |
569 | 583 | if path !== nothing |
570 | 584 | path = normpath(abspath(dirname(manifest_file), path)) |
571 | 585 | return path |
572 | 586 | end |
573 | | - hash = get(entry, "git-tree-sha1", nothing)::Union{Nothing, String} |
| 587 | + hash = get(entry, "git-tree-sha1", nothing)::Union{Nothing,String} |
574 | 588 | hash === nothing && return nothing |
575 | 589 | hash = Base.SHA1(hash) |
576 | 590 | # empty default path probably means that we should use the default Julia depots |
577 | 591 | if depot_path == "" |
578 | 592 | depot_paths = [] |
579 | | - Base.append_default_depot_path!(depot_paths) |
| 593 | + if isdefined(Base, :append_default_depot_path!) |
| 594 | + Base.append_default_depot_path!(depot_paths) |
| 595 | + else |
| 596 | + depot_paths = Pkg.depots() |
| 597 | + end |
580 | 598 | else |
581 | 599 | depot_paths = [depot_path] |
582 | 600 | end |
|
0 commit comments