@@ -789,98 +789,6 @@ function _auto_precompile(ctx::Types.Context, pkgs::Vector{PackageSpec}=PackageS
789789 end
790790end
791791
792- using LibGit2: LibGit2
793- using Tar: Tar
794- function _run_precompilation_script_setup ()
795- tmp = mktempdir ()
796- cd (tmp)
797- empty! (DEPOT_PATH )
798- pushfirst! (DEPOT_PATH , tmp)
799- touch (" Project.toml" )
800- Pkg. activate (" ." )
801- Pkg. generate (" TestPkg" )
802- uuid = TOML. parsefile (joinpath (" TestPkg" , " Project.toml" ))[" uuid" ]
803- mv (" TestPkg" , " TestPkg.jl" )
804- tree_hash = cd (" TestPkg.jl" ) do
805- sig
= LibGit2
. Signature (
" TEST" ,
" [email protected] " ,
round (
time ()),
0 )
806- repo = LibGit2. init (" ." )
807- LibGit2. add! (repo, " " )
808- commit = LibGit2. commit (repo, " initial commit" ; author= sig, committer= sig)
809- th = LibGit2. peel (LibGit2. GitTree, LibGit2. GitObject (repo, commit)) |> LibGit2. GitHash |> string
810- close (repo)
811- th
812- end
813- # Prevent cloning the General registry by adding a fake one
814- mkpath (" registries/Registry/T/TestPkg" )
815- write (" registries/Registry/Registry.toml" , """
816- name = "Registry"
817- uuid = "37c07fec-e54c-4851-934c-2e3885e4053e"
818- repo = "https://github.com/JuliaRegistries/Registry.git"
819- [packages]
820- $uuid = { name = "TestPkg", path = "T/TestPkg" }
821- """ )
822- write (" registries/Registry/T/TestPkg/Compat.toml" , """
823- ["0"]
824- julia = "1"
825- """ )
826- write (" registries/Registry/T/TestPkg/Deps.toml" , """
827- ["0"]
828- Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
829- """ )
830- write (" registries/Registry/T/TestPkg/Versions.toml" , """
831- ["0.1.0"]
832- git-tree-sha1 = "$tree_hash "
833- """ )
834- write (" registries/Registry/T/TestPkg/Package.toml" , """
835- name = "TestPkg"
836- uuid = "$uuid "
837- repo = "$(escape_string (tmp)) /TestPkg.jl"
838- """ )
839- Tar. create (" registries/Registry" , " registries/Registry.tar" )
840- cmd = ` $(Pkg. PlatformEngines. exe7z ()) a "registries/Registry.tar.gz" -tgzip "registries/Registry.tar"`
841- run (pipeline (cmd, stdout = stdout_f (), stderr = stderr_f ()))
842- write (" registries/Registry.toml" , """
843- git-tree-sha1 = "11b5fad51c4f98cfe0c145ceab0b8fb63fed6f81"
844- uuid = "37c07fec-e54c-4851-934c-2e3885e4053e"
845- path = "Registry.tar.gz"
846- """ )
847- Base. rm (" registries/Registry" ; recursive= true )
848- return tmp
849- end
850-
851- function _run_precompilation_script_artifact ()
852- # Create simple artifact, bind it, then use it:
853- foo_hash = Pkg. Artifacts. create_artifact (dir -> touch (joinpath (dir, " foo" )))
854- Artifacts. bind_artifact! (" ./Artifacts.toml" , " foo" , foo_hash)
855- # Also create multiple platform-specific ones because that's a codepath we need precompiled
856- Artifacts. bind_artifact! (" ./Artifacts.toml" , " foo_plat" , foo_hash; platform= Base. BinaryPlatforms. HostPlatform ())
857- # Because @artifact_str doesn't work at REPL-level, we JIT out a file that we can include()
858- write (" load_artifact.jl" , """
859- Pkg.Artifacts.artifact"foo"
860- Pkg.Artifacts.artifact"foo_plat"
861- """ )
862- foo_path = include (" load_artifact.jl" )
863- end
864-
865- const CTRL_C = ' \x 03'
866- const precompile_script = """
867- import Pkg
868- _pwd = pwd()
869- Pkg.UPDATED_REGISTRY_THIS_SESSION[] = true
870- tmp = Pkg._run_precompilation_script_setup()
871- $CTRL_C
872- Pkg.add("TestPkg")
873- Pkg.develop(Pkg.PackageSpec(path="TestPkg.jl"))
874- Pkg.add(Pkg.PackageSpec(path="TestPkg.jl/"))
875- Pkg.REPLMode.try_prompt_pkg_add(Symbol[:notapackage])
876- Pkg.update(; update_registry=false)
877- Pkg.precompile()
878- ] add Te\t\t $CTRL_C
879- ] st
880- $CTRL_C
881- Pkg._run_precompilation_script_artifact()
882- rm(tmp; recursive=true)
883- cd(_pwd)
884- """
792+ include (" precompile.jl" )
885793
886794end # module
0 commit comments