Skip to content

Commit

Permalink
update precompilation for Pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofferC committed Aug 4, 2018
1 parent 43a0285 commit afbba1a
Show file tree
Hide file tree
Showing 3 changed files with 417 additions and 54 deletions.
19 changes: 6 additions & 13 deletions contrib/generate_precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,12 @@ cd("complet_path\t\t$CTRL_C
julia_cmd() = (julia = joinpath(Sys.BINDIR, Base.julia_exename()); `$julia`)
have_repl = haskey(Base.loaded_modules,
Base.PkgId(Base.UUID("3fa0cd96-eef1-5676-8a61-b3b8758bbffb"), "REPL"))
have_pkg = haskey(Base.loaded_modules,
Base.PkgId(Base.UUID("44cfe95a-1eb2-52ea-b672-e2afdf69b78f"), "Pkg"))

if have_pkg
precompile_script *= """
tmp = mktempdir()
cd(tmp)
touch("Project.toml")
] activate .
st
$CTRL_C
rm(tmp; recursive=true)
"""
Pkg = get(Base.loaded_modules,
Base.PkgId(Base.UUID("44cfe95a-1eb2-52ea-b672-e2afdf69b78f"), "Pkg"),
nothing)

if Pkg !== nothing
precompile_script *= Pkg.precompile_script
end

function generate_precompile_statements()
Expand Down
29 changes: 26 additions & 3 deletions stdlib/Pkg/src/Pkg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export UpgradeLevel, UPLEVEL_MAJOR, UPLEVEL_MAJOR, UPLEVEL_MINOR, UPLEVEL_PATCH
depots() = Base.DEPOT_PATH
function depots1()
d = depots()
isempty(d) && pkgerror("no depots found in DEPOT_PATH")
isempty(d) && Pkg.Types.pkgerror("no depots found in DEPOT_PATH")
return d[1]
end

Expand Down Expand Up @@ -42,6 +42,7 @@ import .REPLMode: @pkg_str
import .Types: UPLEVEL_MAJOR, UPLEVEL_MINOR, UPLEVEL_PATCH, UPLEVEL_FIXED
import .Types: PKGMODE_MANIFEST, PKGMODE_PROJECT


"""
PackageMode
Expand Down Expand Up @@ -347,6 +348,30 @@ function __init__()
end
end

METADATA_compatible_uuid(pkg::String) = Types.uuid5(Types.uuid_package, pkg)

##################
# Precompilation #
##################

const CTRL_C = '\x03'
const precompile_script = """
import Pkg
tmp = mktempdir()
cd(tmp)
empty!(DEPOT_PATH)
pushfirst!(DEPOT_PATH, tmp)
# Prevent cloning registry
mkdir("registries")
touch("registries/blocker") # prevents default registry from cloning
touch("Project.toml")
] activate .
$CTRL_C
Pkg.add("Test") # adding an stdlib doesn't require internet access
] st
$CTRL_C
rm(tmp; recursive=true)"""

module PrecompileArea
import ..Pkg
using ..Types
Expand All @@ -357,6 +382,4 @@ module PrecompileArea
include("precompile.jl")
end

METADATA_compatible_uuid(pkg::String) = Types.uuid5(Types.uuid_package, pkg)

end # module
Loading

0 comments on commit afbba1a

Please sign in to comment.