Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bundle 7z[.exe] with libaries/apps #877

Merged
merged 8 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Glob = "1"
Expand Down
2 changes: 1 addition & 1 deletion examples/MyLib/build/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908"
version = "1.2.0"

[[PackageCompiler]]
deps = ["Artifacts", "Glob", "LazyArtifacts", "Libdl", "Pkg", "Printf", "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"
Expand Down
33 changes: 33 additions & 0 deletions src/PackageCompiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using RelocatableFolders
using TOML
using Glob
using p7zip_jll: p7zip_path

export create_sysimage, create_app, create_library

Expand Down Expand Up @@ -824,6 +825,7 @@
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)
Expand Down Expand Up @@ -1038,6 +1040,7 @@
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)
Expand Down Expand Up @@ -1363,6 +1366,36 @@
return
end

function bundle_julia_libexec(ctx, dest_dir)
# We only bundle the `7z` executable at the moment
@assert ctx.env.manifest !== nothing
uses_p7zip_jll = false
for (_, package) in ctx.env.manifest
sloede marked this conversation as resolved.
Show resolved Hide resolved
if package.name == "p7zip_jll"
uses_p7zip_jll = true
break
end
end
if !uses_p7zip_jll
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

Check warning on line 1386 in src/PackageCompiler.jl

View check run for this annotation

Codecov / codecov/patch

src/PackageCompiler.jl#L1386

Added line #L1386 was not covered by tests
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
Expand Down
Loading