Skip to content

Commit 47ea73a

Browse files
authored
Bundle 7z[.exe] with libaries/apps (#877)
* Bundle `7z[.exe]` with libaries/apps * destdir -> app_dir * destdir -> dest_dir * Use p7zip_jll for package and path info * Add missing dep to example Manifest * Make it work for Julia v1.6 * Simplify check for `p7zip_jll`
1 parent 254c988 commit 47ea73a

3 files changed

Lines changed: 29 additions & 2 deletions

File tree

Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
1212
RelocatableFolders = "05181044-ff0b-4ac5-8273-598c1e38db00"
1313
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
1414
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
15+
p7zip_jll = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0"
1516

1617
[compat]
1718
Artifacts = "1"

examples/MyLib/build/Manifest.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908"
8383
version = "1.2.0"
8484

8585
[[PackageCompiler]]
86-
deps = ["Artifacts", "Glob", "LazyArtifacts", "Libdl", "Pkg", "Printf", "REPL", "RelocatableFolders", "TOML", "UUIDs"]
86+
deps = ["Artifacts", "Glob", "LazyArtifacts", "Libdl", "Pkg", "Printf", "RelocatableFolders", "TOML", "UUIDs", "p7zip_jll"]
8787
path = "../../.."
8888
uuid = "9b87118b-4619-50d2-8e1e-99f35a4d4d9d"
89-
version = "2.1.7"
89+
version = "2.1.12"
9090

9191
[[Pkg]]
9292
deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"]

src/PackageCompiler.jl

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ using UUIDs: UUID, uuid1
1010
using RelocatableFolders
1111
using TOML
1212
using Glob
13+
using p7zip_jll: p7zip_path
1314

1415
export create_sysimage, create_app, create_library
1516

@@ -824,6 +825,7 @@ function create_app(package_dir::String,
824825
bundle_artifacts(ctx, app_dir; include_lazy_artifacts)
825826
stdlibs = filter_stdlibs ? gather_stdlibs_project(ctx; only_in_sysimage=false) : _STDLIBS
826827
bundle_julia_libraries(app_dir, stdlibs)
828+
bundle_julia_libexec(ctx, app_dir)
827829
bundle_julia_executable(app_dir)
828830
bundle_project(ctx, app_dir)
829831
include_preferences && bundle_preferences(ctx, app_dir)
@@ -1038,6 +1040,7 @@ function create_library(package_or_project::String,
10381040
mkpath(dest_dir)
10391041
stdlibs = filter_stdlibs ? gather_stdlibs_project(ctx; only_in_sysimage=false) : _STDLIBS
10401042
bundle_julia_libraries(dest_dir, stdlibs)
1043+
bundle_julia_libexec(ctx, dest_dir)
10411044
bundle_artifacts(ctx, dest_dir; include_lazy_artifacts)
10421045
bundle_headers(dest_dir, header_files)
10431046
bundle_project(ctx, dest_dir)
@@ -1363,6 +1366,29 @@ function bundle_julia_libraries(dest_dir, stdlibs)
13631366
return
13641367
end
13651368

1369+
function bundle_julia_libexec(ctx, dest_dir)
1370+
# We only bundle the `7z` executable at the moment
1371+
@assert ctx.env.manifest !== nothing
1372+
if !any(x -> x.name == "p7zip_jll", values(ctx.env.manifest))
1373+
return
1374+
end
1375+
1376+
# Use Julia-private `libexec` folder if it exsts
1377+
# (normpath is required in case `bin` does not exist in `dest_dir`)
1378+
libexecdir_rel = if isdefined(Base, :PRIVATE_LIBEXECDIR)
1379+
Base.PRIVATE_LIBEXECDIR
1380+
else
1381+
Base.LIBEXECDIR
1382+
end
1383+
bundle_libexec_dir = normpath(joinpath(dest_dir, "bin", libexecdir_rel))
1384+
mkpath(bundle_libexec_dir)
1385+
1386+
p7zip_exe = basename(p7zip_path)
1387+
cp(p7zip_path, joinpath(bundle_libexec_dir, p7zip_exe))
1388+
1389+
return
1390+
end
1391+
13661392
function recursive_dir_size(path)
13671393
size = 0
13681394
try

0 commit comments

Comments
 (0)