Skip to content

Commit

Permalink
fixing windows bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
Janis Erdmanis committed Jun 27, 2024
1 parent 455e547 commit 357f4a5
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 12 deletions.
39 changes: 30 additions & 9 deletions recipes/windows/main.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

ENV["BUNDLE_IDENTIFIER"] = "{{BUNDLE_IDENTIFIER}}"
ENV["APP_DIR_NAME"] = "{{APP_DIR_NAME}}"
ENV["APP_NAME"] = "{{APP_NAME}}"

ENV["ROOT"] = @__DIR__
ENV["JULIA"] = joinpath(Sys.BINDIR, "julia.exe")
Expand Down Expand Up @@ -60,15 +61,36 @@ end

println("User data directory: " * ENV["USER_DATA"])

popfirst!(DEPOT_PATH)
pushfirst!(DEPOT_PATH, @__DIR__)
pushfirst!(DEPOT_PATH, joinpath(ENV["USER_DATA"], "cache"))
ENV["JULIA_DEPOT_PATH"] = join(DEPOT_PATH, ";")
Base.ACTIVE_PROJECT[] = joinpath(@__DIR__, ENV["APP_NAME"])

empty!(LOAD_PATH)
append!(LOAD_PATH, [
joinpath(@__DIR__, "packages"),
"@",
"@stdlib"
])

pushfirst!(LOAD_PATH, @__DIR__) # Needed for the app
pushfirst!(LOAD_PATH, joinpath(@__DIR__, "packages"))
empty!(DEPOT_PATH)
append!(DEPOT_PATH, [
joinpath(ENV["USER_DATA"], "cache"),
@__DIR__
])

# Setting up environment variables in case one starts subproceeses with `run`
ENV["JULIA_PROJECT"] = Base.ACTIVE_PROJECT[]
ENV["JULIA_DEPOT_PATH"] = join(DEPOT_PATH, ";")
ENV["JULIA_LOAD_PATH"] = join(LOAD_PATH, ";")

println("DEPOT_PATH:")
for i in DEPOT_PATH
println("\t$i")
end

println("LOAD_PATH:")
for i in LOAD_PATH
println("\t$i")
end

PRECOMPILED = joinpath(ENV["USER_DATA"], "cache", "precompiled")

if !WINDOWS_STARTUP.debug
Expand Down Expand Up @@ -104,5 +126,4 @@ if !WINDOWS_STARTUP.debug

include(joinpath(@__DIR__, "startup", "init.jl")) # One may set up a logging there
end

include(joinpath(@__DIR__, ENV["APP_DIR_NAME"], "main.jl"))
include(joinpath(@__DIR__, ENV["APP_NAME"], "main.jl"))
2 changes: 1 addition & 1 deletion recipes/windows/precompile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ $JULIA="$PSScriptRoot\julia\bin\julia.exe"

$env:JULIA_LOAD_PATH="$PSScriptRoot\packages;@stdlib;@"
$env:JULIA_DEPOT_PATH="$PSScriptRoot"
$env:JULIA_PROJECT="$PSScriptRoot\{{APP_DIR_NAME}}"
$env:JULIA_PROJECT="$PSScriptRoot\{{APP_NAME}}"

& $JULIA --startup-file=no "$PSScriptRoot\startup\precompile.jl"
2 changes: 1 addition & 1 deletion src/bundler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function get_bundle_parameters(project_toml)

app_name = haskey(toml_dict, "APP_NAME") ? toml_dict["APP_NAME"] : haskey(toml_dict, "name") ? toml_dict["name"] : basename(dirname(project_toml))
parameters["APP_NAME"] = lowercase(join(split(app_name, " "), "-"))
parameters["APP_DIR_NAME"] = haskey(toml_dict, "name") ? toml_dict["name"] : basename(dirname(project_toml))
#parameters["APP_DIR_NAME"] = haskey(toml_dict, "name") ? toml_dict["name"] : basename(dirname(project_toml))

parameters["APP_VERSION"] = haskey(toml_dict, "version") ? toml_dict["version"] : "0.0.1"

Expand Down
2 changes: 1 addition & 1 deletion src/recipes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ function bundle_app(platform::Windows, source, destination; with_splash_screen=n
retrieve_packages(source, "$app_dir/packages"; with_splash_screen)
retrieve_artifacts(platform, "$app_dir/packages", "$app_dir/artifacts")

copy_app(source, joinpath(app_dir, parameters["APP_DIR_NAME"]))
copy_app(source, "$app_dir/$app_name")

ensure_windows_compatability(app_dir; path_length_threshold, skip_long_paths)

Expand Down

0 comments on commit 357f4a5

Please sign in to comment.