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

add an option to remove symlinks in bundled libraries and artifacts #821

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all 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
30 changes: 28 additions & 2 deletions src/PackageCompiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,8 @@ compiler (can also include extra arguments to the compiler, like `-g`).
for example `-O1 --check-bounds=yes`.

- `script::String`: Path to a file that gets executed in the `--output-o` process.

- `remove_symlinks::Bool`: Experimental! If `true`, remove symlinks from bundled libraries and artifacts. Defaults to `false`.
"""
function create_app(package_dir::String,
app_dir::String;
Expand All @@ -769,7 +771,8 @@ function create_app(package_dir::String,
include_lazy_artifacts::Bool=false,
sysimage_build_args::Cmd=``,
include_transitive_dependencies::Bool=true,
script::Union{Nothing, String}=nothing)
script::Union{Nothing, String}=nothing,
remove_symlinks::Bool=false)
warn_official()
if filter_stdlibs && incremental
error("must use `incremental=false` to use `filter_stdlibs=true`")
Expand All @@ -791,6 +794,9 @@ function create_app(package_dir::String,
bundle_julia_executable(app_dir)
bundle_project(ctx, app_dir)
bundle_cert(app_dir)
if remove_symlinks
do_remove_symlinks(app_dir)
end

sysimage_path = joinpath(app_dir, "lib", "julia", "sys." * Libdl.dlext)

Expand Down Expand Up @@ -836,6 +842,20 @@ function create_executable_from_sysimg(exe_path::String,
return nothing
end

function do_remove_symlinks(app_dir::String)
app_libdir = joinpath(app_dir, Sys.isunix() ? "lib" : "bin")
artifact_dir = joinpath(app_dir, "share", "julia", "artifacts")
for dir in (app_libdir, artifact_dir)
for (root, dirs, files) in walkdir(dir)
for file in files
path = joinpath(root, file)
if islink(path)
rm(path)
end
end
end
end
end

###########
# Library #
Expand Down Expand Up @@ -937,6 +957,8 @@ compiler (can also include extra arguments to the compiler, like `-g`).

- `sysimage_build_args::Cmd`: A set of command line options that is used in the Julia process building the sysimage,
for example `-O1 --check-bounds=yes`.

- `remove_symlinks::Bool`: Experimental! If `true`, remove symlinks from bundled libraries and artifacts. Defaults to `false`.
"""
function create_library(package_dir::String,
dest_dir::String;
Expand All @@ -954,7 +976,8 @@ function create_library(package_dir::String,
include_lazy_artifacts::Bool=false,
sysimage_build_args::Cmd=``,
include_transitive_dependencies::Bool=true,
script::Union{Nothing,String}=nothing
script::Union{Nothing,String}=nothing,
remove_symlinks::Bool=false,
)


Expand All @@ -981,6 +1004,9 @@ function create_library(package_dir::String,
bundle_artifacts(ctx, dest_dir; include_lazy_artifacts)
bundle_headers(dest_dir, header_files)
bundle_cert(dest_dir)
if remove_symlinks
do_remove_symlinks(dest_dir)
end

lib_dir = Sys.iswindows() ? joinpath(dest_dir, "bin") : joinpath(dest_dir, "lib")

Expand Down