Skip to content
This repository has been archived by the owner on Dec 2, 2021. It is now read-only.

Commit

Permalink
fix native system image build
Browse files Browse the repository at this point in the history
  • Loading branch information
Roger-luo committed May 26, 2021
1 parent e96b5e7 commit 7b55753
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
17 changes: 10 additions & 7 deletions src/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -121,19 +121,21 @@ end

function download_sysimg(m::Module, options::ComoniconOptions.Comonicon)
url = sysimg_url(m, options)
PlatformEngines.probe_platform_engines!()

try
tarball = download(url)
path = pkgdir(m, options.sysimg.path)
unpack(tarball, path)
# NOTE: sysimg won't be shared, so we can just remove it
isfile(tarball) && rm(tarball)
if !isnothing(url)
tarball = download(url)
path = pkgdir(m, options.sysimg.path)
unpack(tarball, path)
# NOTE: sysimg won't be shared, so we can just remove it
isfile(tarball) && rm(tarball)
return
end
catch e
@warn "fail to download $url, building the system image locally"
# force incremental build
build_sysimg(m, options; incremental = true, filter_stdlibs = false, cpu_target = "native")
end
build_sysimg(m, options; incremental = true, filter_stdlibs = false, cpu_target = "native")
return
end

Expand All @@ -154,6 +156,7 @@ end

function sysimg_url(mod::Module, options::ComoniconOptions.Comonicon)
name = options.name
isnothing(options.download) && return
host = options.download.host

if host == "github.com"
Expand Down
6 changes: 3 additions & 3 deletions src/install.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,17 @@ function install_script(m::Module, options::ComoniconOptions.Comonicon; project=
shadow = joinpath(bin, options.name * ".jl")

if isnothing(options.sysimg)
sysimg = nothing
sysimg_path = nothing
else
download_sysimg(m, options)
sysimg = pkgdir(m, options.sysimg.path, "lib", sysimg(options.name))
sysimg_path = pkgdir(m, options.sysimg.path, "lib", sysimg(options.name))
end

shell_script = cmd_script(
m,
shadow;
project,
sysimg = sysimg,
sysimg = sysimg_path,
compile = options.install.compile,
optimize = options.install.optimize,
)
Expand Down

0 comments on commit 7b55753

Please sign in to comment.