Skip to content

Commit

Permalink
Update linux/windows bundle API to support newer ApplicationBuilder f…
Browse files Browse the repository at this point in the history
…eatures:

  - binary_name
  - cpu_target
  - commandline_app
  - snoopfile
  - autosnoop
  • Loading branch information
NHDaly committed Apr 16, 2019
1 parent 6c1cdff commit 23c0a72
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 12 deletions.
34 changes: 25 additions & 9 deletions src/bundle.jl
@@ -1,22 +1,28 @@
if Sys.iswindows()
include("installer.jl")
include("win-installer.jl")
end
function build_app_bundle(script::String;
TODO = nothing
function build_app_bundle(juliaprog_main::String;
resources = String[],
libraries = String[],
builddir = "builddir",
appname = "nothing",
binary_name = splitext(basename(juliaprog_main))[1],
verbose = false,
cpu_target = nothing,
commandline_app = TODO,
snoopfile = nothing, autosnoop = TODO,
create_installer = false)


# Create build directory
script = abspath(script)
base_path = dirname(script)
builddir = joinpath(base_path, builddir, appname)
juliaprog_main = abspath(juliaprog_main)
builddir = abspath(builddir)
builddir = joinpath(builddir, appname)
@info "Building at path $builddir"
mkpath(builddir)

core_path = joinpath(builddir, "core")
core_path = joinpath(builddir, "bin")
lib_path = joinpath(builddir, "lib")
res_path = joinpath(builddir, "res")

Expand All @@ -41,12 +47,22 @@ function build_app_bundle(script::String;
println("... done.")
end

build_executable(script, builddir = core_path)
# ----------- Compile a binary ---------------------
# Compile the binary right into the app.
println("~~~~~~ Compiling a binary from '$juliaprog_main'... ~~~~~~~")

(create_installer && Sys.islinux()) && throw(error("Cannot create installer on Linux"))
PackageCompiler.build_executable(juliaprog_main, binary_name;
builddir=core_path, verbose=verbose, optimize="3",
snoopfile=snoopfile, debug="0", cpu_target=cpu_target,
compiled_modules="yes",
#cc_flags=`-mmacosx-version-min=10.10 -headerpad_max_install_names`,
)

(create_installer && Sys.islinux()) && @warn("Cannot create installer on Linux")

if Sys.iswindows()
create_installer && installer(builddir, name = appname)
create_installer && win_installer(builddir, name = appname)
end

return 0
end
2 changes: 1 addition & 1 deletion src/installer.jl → src/win-installer.jl
@@ -1,4 +1,4 @@
function installer(builddir; name = "nothing",
function win_installer(builddir; name = "nothing",
license = "$JULIA_HOME/../License.md")

# check = success(`makensis`)
Expand Down
2 changes: 1 addition & 1 deletion test/build_examples/commandline_hello.jl
Expand Up @@ -5,5 +5,5 @@ using ApplicationBuilder
@isdefined(builddir) || (builddir="builddir")

build_app_bundle(joinpath(@__DIR__,"..","..","examples","commandline_hello.jl"),
appname="hello",
appname="hello", binary_name="hello",
commandline_app=true, builddir=builddir)
15 changes: 15 additions & 0 deletions test/bundle.jl
@@ -0,0 +1,15 @@
# Windows and Linux tests

using Test
using Pkg
using ApplicationBuilder

builddir = mktempdir()
@assert isdir(builddir)

@testset "HelloWorld.app" begin
@test 0 == include("build_examples/commandline_hello.jl")
@test isdir(joinpath(builddir, "hello"))
@test success(`$builddir/hello/bin/hello`)
#@test success(`open $builddir/hello.app`)
end
9 changes: 8 additions & 1 deletion test/runtests.jl
@@ -1,15 +1,22 @@
using Test

@testset "ApplicationBuilder.jl" begin

# TODO: Make the tests work on Windows and Linux!!! :'(
@static if Sys.isapple()

@testset "ApplicationBuilder.jl" begin
@testset "Test ApplicationBuilder (by compiling examples/*.jl)" begin
include("ApplicationBuilder.jl")
end
@testset "Command-line interface (compiling examples/*.jl)" begin
include("build_app-cli.jl")
end

else # Windows and Linux

@testset "bundle.jl" begin
include("bundle.jl")
end

end
end

0 comments on commit 23c0a72

Please sign in to comment.