Skip to content
This repository was archived by the owner on Jun 9, 2023. It is now read-only.
Merged
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
15 changes: 12 additions & 3 deletions src/PackageCompilerX.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ yesno(b::Bool) = b ? "yes" : "no"
bitflag() = Int == Int32 ? `-m32` : `-m64`
march() = (Int == Int32 ? `-march=pentium4` : ``)

# Overwriting an open file is problematic in Windows
# so move it out of the way first
function move_default_sysimage_if_windows()
if Sys.iswindows() && isfile(default_sysimg_path())
mv(default_sysimg_path(), tempname())
end
end

function windows_compiler_artifact_path(f, compiler)
if Sys.iswindows()
withenv("PATH" => string(ENV["PATH"], ";", dirname(compiler))) do
Expand Down Expand Up @@ -352,8 +360,9 @@ function create_sysimage(packages::Union{Symbol, Vector{Symbol}};
@debug "making a backup of default sysimg"
cp(default_sysimg_path(), backup_default_sysimg_path())
end
@info "PackageCompilerX: default sysimg replaced, restart Julia for the new sysimg to be in effect"
move_default_sysimage_if_windows()
mv(sysimage_path, default_sysimg_path(); force=true)
@info "PackageCompilerX: default sysimg replaced, restart Julia for the new sysimg to be in effect"
end
rm(object_file; force=true)
return nothing
Expand Down Expand Up @@ -389,8 +398,8 @@ function restore_default_sysimage()
if !isfile(backup_default_sysimg_path())
error("did not find a backup sysimg")
end
cp(backup_default_sysimg_path(), default_sysimg_path(); force=true)
rm(backup_default_sysimg_path())
move_default_sysimage_if_windows()
mv(backup_default_sysimg_path(), default_sysimg_path(); force=true)
@info "PackageCompilerX: default sysimg restored, restart Julia for the new sysimg to be in effect"
return nothing
end
Expand Down