From 7b557538faa37b40e4c5d18d98e6a7e8b0343514 Mon Sep 17 00:00:00 2001 From: Roger-Luo Date: Wed, 26 May 2021 17:15:35 -0400 Subject: [PATCH] fix native system image build --- src/build.jl | 17 ++++++++++------- src/install.jl | 6 +++--- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/build.jl b/src/build.jl index 67150e3..0f147da 100644 --- a/src/build.jl +++ b/src/build.jl @@ -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 @@ -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" diff --git a/src/install.jl b/src/install.jl index 8f43bc2..349b984 100644 --- a/src/install.jl +++ b/src/install.jl @@ -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, )