-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move build code into create_binaries package (#762)
Follow up to #740. --------- Co-authored-by: Hofer-Julian <[email protected]>
- Loading branch information
1 parent
92478c7
commit 8366c28
Showing
11 changed files
with
121 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using create_binaries | ||
|
||
""" | ||
Build the Ribasim CLI, libribasim, or both, using PackageCompiler. | ||
Run from the command line with: | ||
julia --project build.jl --app --lib | ||
""" | ||
function main(ARGS) | ||
# change directory to this script's location | ||
cd(@__DIR__) | ||
|
||
if "--app" in ARGS | ||
build_app() | ||
elseif "--lib" in ARGS | ||
build_lib() | ||
end | ||
end | ||
|
||
main(ARGS) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
"Build the Ribasim CLI using PackageCompiler" | ||
function build_app() | ||
project_dir = "../ribasim_cli" | ||
license_file = "../../LICENSE" | ||
output_dir = "ribasim_cli" | ||
git_repo = "../.." | ||
|
||
create_app( | ||
project_dir, | ||
output_dir; | ||
# map from binary name to julia function name | ||
executables = ["ribasim" => "julia_main"], | ||
precompile_execution_file = "precompile.jl", | ||
include_lazy_artifacts = true, | ||
force = true, | ||
) | ||
|
||
add_metadata(project_dir, license_file, output_dir, git_repo) | ||
|
||
# On Windows, write ribasim.cmd in the output_dir, that starts ribasim.exe. | ||
# Since the bin dir contains a julia.exe and many DLLs that you may not want in your path, | ||
# with this script you can put output_dir in your path instead. | ||
if Sys.iswindows() | ||
cmd = raw""" | ||
@echo off | ||
"%~dp0bin\ribasim.exe" %* | ||
""" | ||
open(normpath(output_dir, "ribasim.cmd"); write = true) do io | ||
print(io, cmd) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,15 @@ | ||
__precompile__(false) | ||
module create_binaries | ||
|
||
# This is not really a package, but needs to be set up like one so we can run | ||
# `dev build/create_binaries` from the root project. | ||
using Artifacts | ||
using PackageCompiler | ||
using TOML | ||
using LibGit2 | ||
|
||
export build_app, build_lib | ||
|
||
include("strip_cldr.jl") | ||
include("add_metadata.jl") | ||
include("create_app.jl") | ||
include("create_lib.jl") | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
"Build libribasim using PackageCompiler" | ||
function build_lib() | ||
project_dir = "../libribasim" | ||
license_file = "../../LICENSE" | ||
output_dir = "libribasim" | ||
git_repo = "../.." | ||
|
||
create_library( | ||
project_dir, | ||
output_dir; | ||
lib_name = "libribasim", | ||
precompile_execution_file = "precompile.jl", | ||
include_lazy_artifacts = true, | ||
force = true, | ||
) | ||
|
||
add_metadata(project_dir, license_file, output_dir, git_repo) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
""" | ||
The cldr artifact has such long paths that it errors on Windows unless long paths are enabled. | ||
Also the artifact has many files and is over 300 MB, while we only need a single small file. | ||
This modifies the artifact to remove everything except the file we need. | ||
Since the artifact is only used on Windows, only strip do it there. | ||
This needs exactly TimeZones 1.13.0, which is fixed in the Project.toml. | ||
https://github.com/JuliaTime/TimeZones.jl/issues/373 | ||
""" | ||
function strip_cldr() | ||
if Sys.iswindows() | ||
# Get the artifact directory and the file path we need to keep | ||
hash = Base.SHA1("40b35727ea0aff9a9f28b7454004b68849caf67b") | ||
@assert artifact_exists(hash) | ||
artifact_dir = artifact_path(hash) | ||
keep_file = | ||
normpath(artifact_dir, "cldr-release-43-1/common/supplemental/windowsZones.xml") | ||
@assert isfile(keep_file) | ||
|
||
# Read the file into memory, empty the artifact dir, and write the file back | ||
keep_file_content = read(keep_file) | ||
rm(artifact_dir; recursive = true) | ||
mkpath(dirname(keep_file)) | ||
write(keep_file, keep_file_content) | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters