Skip to content

Commit

Permalink
use precompiletools
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofferC committed Aug 29, 2023
1 parent 00c8612 commit f2d8b64
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
5 changes: 3 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Expand All @@ -28,9 +29,9 @@ p7zip_jll = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0"
HistoricalStdlibVersions = "1.2"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Preferences = "21216c6a-2e73-6563-6e65-726566657250"
HistoricalStdlibVersions = "6df8b67a-e8a0-4029-b4b7-ac196fe72102"
Preferences = "21216c6a-2e73-6563-6e65-726566657250"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test", "Preferences", "HistoricalStdlibVersions"]
15 changes: 8 additions & 7 deletions src/precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ using LibGit2: LibGit2
using Tar: Tar
using Downloads
using REPL
# using SnoopPrecompile
using PrecompileTools


let
function _run_precompilation_script_setup()
tmp = mktempdir()
cd(tmp)
Expand Down Expand Up @@ -77,15 +77,16 @@ end

# SnoopPrecompile is useful but not available in Base
function pkg_precompile()
@info "running..."
Pkg.UPDATED_REGISTRY_THIS_SESSION[] = true
# Default 30 sec grace period means we hang 30 seconds before precompiling finishes
DEFAULT_IO[] = UnstableIO(devnull)
Downloads.DOWNLOADER[] = Downloads.Downloader(; grace=1.0)

withenv("JULIA_PKG_SERVER" => nothing) do
# @precompile_setup begin
@setup_workload begin
tmp = _run_precompilation_script_setup()
# @precompile_all_calls begin
@compile_workload begin
withenv("JULIA_PKG_PRECOMPILE_AUTO" => 0) do
Pkg.add("TestPkg")
Pkg.develop(Pkg.PackageSpec(path="TestPkg.jl"))
Expand All @@ -99,6 +100,7 @@ function pkg_precompile()
catch
end

@info "Compiling these...."
Base.precompile(Tuple{typeof(Pkg.REPLMode.promptf)})
Base.precompile(Tuple{typeof(Pkg.REPLMode.repl_init), REPL.LineEditREPL})
Base.precompile(Tuple{typeof(Pkg.API.status)})
Expand All @@ -108,10 +110,9 @@ function pkg_precompile()
Base.precompile(Tuple{typeof(REPL.LineEdit.complete_line), Pkg.REPLMode.PkgCompletionProvider, REPL.LineEdit.PromptState})
Base.precompile(Tuple{typeof(Pkg.REPLMode.complete_argument), Pkg.REPLMode.CommandSpec, Array{String, 1}, String, Int64, Int64})
Base.precompile(Tuple{typeof(Pkg.REPLMode.complete_add_dev), Base.Dict{Symbol, Any}, String, Int64, Int64})
# end
# end
end
end
end
end

pkg_precompile()
end

0 comments on commit f2d8b64

Please sign in to comment.