diff --git a/Project.toml b/Project.toml index 1ef5abcc..ae825ad6 100644 --- a/Project.toml +++ b/Project.toml @@ -6,10 +6,12 @@ version = "1.6.0" LazyArtifacts = "4af54fe1-eca0-43a8-85a7-787d91b784e3" Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb" Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" +RelocatableFolders = "05181044-ff0b-4ac5-8273-598c1e38db00" UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" [compat] julia = "1.6" +RelocatableFolders = "0.1" [extras] Example = "7876af07-990d-54b4-ab0e-23690620f79a" diff --git a/docs/Manifest.toml b/docs/Manifest.toml index 9ed2e956..e6333e09 100644 --- a/docs/Manifest.toml +++ b/docs/Manifest.toml @@ -50,6 +50,10 @@ git-tree-sha1 = "8076680b162ada2a031f707ac7b4953e30667a37" uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" version = "0.21.2" +[[LazyArtifacts]] +deps = ["Artifacts", "Pkg"] +uuid = "4af54fe1-eca0-43a8-85a7-787d91b784e3" + [[LibCURL]] deps = ["LibCURL_jll", "MozillaCACerts_jll"] uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" @@ -90,10 +94,10 @@ uuid = "14a3606d-f60d-562e-9121-12d972cd8159" uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" [[PackageCompiler]] -deps = ["Libdl", "Pkg", "UUIDs"] +deps = ["LazyArtifacts", "Libdl", "Pkg", "RelocatableFolders", "UUIDs"] path = ".." -uuid = "dffaa6cc-da53-48e5-b007-4292dfcc27f1" -version = "1.5.0" +uuid = "9b87118b-4619-50d2-8e1e-99f35a4d4d9d" +version = "1.6.0" [[Parsers]] deps = ["Dates"] @@ -117,9 +121,21 @@ uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" deps = ["Serialization"] uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" +[[RelocatableFolders]] +deps = ["SHA", "Scratch"] +git-tree-sha1 = "9a4b7698b59b24003e8475df70c1b83b958b1f62" +uuid = "05181044-ff0b-4ac5-8273-598c1e38db00" +version = "0.1.1" + [[SHA]] uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" +[[Scratch]] +deps = ["Dates"] +git-tree-sha1 = "0b4b7f1393cff97c33891da2a0bf69c6ed241fda" +uuid = "6c6a2e73-6563-6170-7368-637461726353" +version = "1.1.0" + [[Serialization]] uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" diff --git a/docs/Project.toml b/docs/Project.toml index e8d80518..c66262af 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -1,3 +1,3 @@ [deps] Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" -PackageCompiler = "dffaa6cc-da53-48e5-b007-4292dfcc27f1" +PackageCompiler = "9b87118b-4619-50d2-8e1e-99f35a4d4d9d" diff --git a/docs/src/apps.md b/docs/src/apps.md index 39b0d86f..6e1f2713 100644 --- a/docs/src/apps.md +++ b/docs/src/apps.md @@ -70,8 +70,8 @@ relocatable way?" The answer is to use the "artifact system" introduced in Julia 1.3, and described in the following [blog post](https://julialang.org/blog/2019/11/artifacts). The artifact system is a declarative way of downloading and using "external files" like binaries and -libraries. How this is used in practice is described later. - +libraries. How this is used in practice is described later. Another useful +tool is the Julia package [RelocatableFolders.jl](https://github.com/JuliaPackaging/RelocatableFolders.jl). ## Creating an app diff --git a/src/PackageCompiler.jl b/src/PackageCompiler.jl index 50aac29a..78109f65 100644 --- a/src/PackageCompiler.jl +++ b/src/PackageCompiler.jl @@ -5,6 +5,7 @@ using Libdl: Libdl using Pkg: Pkg using LazyArtifacts using UUIDs: UUID, uuid1 +using RelocatableFolders export create_sysimage, create_app, create_library, audit_app, restore_default_sysimage @@ -13,6 +14,11 @@ include("juliaconfig.jl") const NATIVE_CPU_TARGET = "native" const TLS_SYNTAX = VERSION >= v"1.7.0-DEV.1205" ? `-DNEW_DEFINE_FAST_TLS_SYNTAX` : `` +const DEFAULT_EMBEDDING_WRAPPER = @path joinpath(@__DIR__, "embedding_wrapper.c") +const DEFAULT_JULIA_INIT = @path joinpath(@__DIR__, "julia_init.c") +const DEFAULT_JULIA_INIT_HEADER = @path joinpath(@__DIR__, "julia_init.h") + + # See https://github.com/JuliaCI/julia-buildbot/blob/489ad6dee5f1e8f2ad341397dc15bb4fce436b26/master/inventory.py function default_app_cpu_target() if Sys.ARCH === :i686 @@ -819,7 +825,7 @@ function create_app(package_dir::String, filter_stdlibs=false, audit=true, force=false, - c_driver_program::String=joinpath(@__DIR__, "embedding_wrapper.c"), + c_driver_program::String=String(DEFAULT_EMBEDDING_WRAPPER), cpu_target::String=default_app_cpu_target(), include_lazy_artifacts::Bool=true, sysimage_build_args::Cmd=``, @@ -940,7 +946,7 @@ function create_library(package_dir::String, audit=true, force=false, header_files::Vector{String} = String[], - julia_init_c_file::String=joinpath(@__DIR__, "julia_init.c"), + julia_init_c_file::String=String(DEFAULT_JULIA_INIT), version=nothing, compat_level="major", cpu_target::String=default_app_cpu_target(), @@ -948,7 +954,7 @@ function create_library(package_dir::String, sysimage_build_args::Cmd=``, include_transitive_dependencies::Bool=true) - julia_init_h_file::String=joinpath(@__DIR__, "julia_init.h") + julia_init_h_file = String(DEFAULT_JULIA_INIT_HEADER) if !(julia_init_h_file in header_files) push!(header_files, julia_init_h_file)