Skip to content

Commit

Permalink
Merge d8956e0 into 732bf5c
Browse files Browse the repository at this point in the history
  • Loading branch information
NHDaly committed Apr 16, 2019
2 parents 732bf5c + d8956e0 commit a721a0d
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -3,7 +3,7 @@ language: julia

os:
- osx
#- linux # TODO: Enable Linux
- linux

julia:
- 1.0
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
@@ -1,7 +1,7 @@
name = "ApplicationBuilder"
uuid = "f9309374-59cc-5ff5-a120-e3e470a57b4a"
authors = ["Nathan Daly <nhdaly@gmail.com>", "Ranjan Anantharaman <benditlikeranjan@gmail.com>"]
version = "0.4.0"
version = "0.4.1"

[deps]
ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63"
Expand Down
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 a721a0d

Please sign in to comment.