diff --git a/Project.toml b/Project.toml index afe6262c..5985908b 100644 --- a/Project.toml +++ b/Project.toml @@ -12,6 +12,7 @@ Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" RelocatableFolders = "05181044-ff0b-4ac5-8273-598c1e38db00" TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76" UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" +p7zip_jll = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" [compat] Artifacts = "1" diff --git a/examples/MyLib/build/Manifest.toml b/examples/MyLib/build/Manifest.toml index 2741375e..3d17a555 100644 --- a/examples/MyLib/build/Manifest.toml +++ b/examples/MyLib/build/Manifest.toml @@ -83,10 +83,10 @@ uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" version = "1.2.0" [[PackageCompiler]] -deps = ["Artifacts", "Glob", "LazyArtifacts", "Libdl", "Pkg", "Printf", "REPL", "RelocatableFolders", "TOML", "UUIDs"] +deps = ["Artifacts", "Glob", "LazyArtifacts", "Libdl", "Pkg", "Printf", "RelocatableFolders", "TOML", "UUIDs", "p7zip_jll"] path = "../../.." uuid = "9b87118b-4619-50d2-8e1e-99f35a4d4d9d" -version = "2.1.7" +version = "2.1.12" [[Pkg]] deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] diff --git a/src/PackageCompiler.jl b/src/PackageCompiler.jl index 8dbeabd9..afcd611c 100644 --- a/src/PackageCompiler.jl +++ b/src/PackageCompiler.jl @@ -10,6 +10,7 @@ using UUIDs: UUID, uuid1 using RelocatableFolders using TOML using Glob +using p7zip_jll: p7zip_path export create_sysimage, create_app, create_library @@ -824,6 +825,7 @@ function create_app(package_dir::String, bundle_artifacts(ctx, app_dir; include_lazy_artifacts) stdlibs = filter_stdlibs ? gather_stdlibs_project(ctx; only_in_sysimage=false) : _STDLIBS bundle_julia_libraries(app_dir, stdlibs) + bundle_julia_libexec(ctx, app_dir) bundle_julia_executable(app_dir) bundle_project(ctx, app_dir) include_preferences && bundle_preferences(ctx, app_dir) @@ -1038,6 +1040,7 @@ function create_library(package_or_project::String, mkpath(dest_dir) stdlibs = filter_stdlibs ? gather_stdlibs_project(ctx; only_in_sysimage=false) : _STDLIBS bundle_julia_libraries(dest_dir, stdlibs) + bundle_julia_libexec(ctx, dest_dir) bundle_artifacts(ctx, dest_dir; include_lazy_artifacts) bundle_headers(dest_dir, header_files) bundle_project(ctx, dest_dir) @@ -1363,6 +1366,29 @@ function bundle_julia_libraries(dest_dir, stdlibs) return end +function bundle_julia_libexec(ctx, dest_dir) + # We only bundle the `7z` executable at the moment + @assert ctx.env.manifest !== nothing + if !any(x -> x.name == "p7zip_jll", values(ctx.env.manifest)) + return + end + + # Use Julia-private `libexec` folder if it exsts + # (normpath is required in case `bin` does not exist in `dest_dir`) + libexecdir_rel = if isdefined(Base, :PRIVATE_LIBEXECDIR) + Base.PRIVATE_LIBEXECDIR + else + Base.LIBEXECDIR + end + bundle_libexec_dir = normpath(joinpath(dest_dir, "bin", libexecdir_rel)) + mkpath(bundle_libexec_dir) + + p7zip_exe = basename(p7zip_path) + cp(p7zip_path, joinpath(bundle_libexec_dir, p7zip_exe)) + + return +end + function recursive_dir_size(path) size = 0 try