diff --git a/Project.toml b/Project.toml index c8d4ce8..e6e6610 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ApplicationBuilder" uuid = "f9309374-59cc-5ff5-a120-e3e470a57b4a" authors = ["Nathan Daly ", "Ranjan Anantharaman "] -version = "0.4.0" +version = "0.4.1" [deps] ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63" diff --git a/src/bundle.jl b/src/bundle.jl index 0c28a08..621c928 100644 --- a/src/bundle.jl +++ b/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") @@ -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 diff --git a/src/installer.jl b/src/win-installer.jl similarity index 94% rename from src/installer.jl rename to src/win-installer.jl index d0d7d79..1cbe11d 100644 --- a/src/installer.jl +++ b/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`) diff --git a/test/build_examples/commandline_hello.jl b/test/build_examples/commandline_hello.jl index f549fb3..1150a8c 100644 --- a/test/build_examples/commandline_hello.jl +++ b/test/build_examples/commandline_hello.jl @@ -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) diff --git a/test/bundle.jl b/test/bundle.jl new file mode 100644 index 0000000..46c63f4 --- /dev/null +++ b/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 diff --git a/test/runtests.jl b/test/runtests.jl index 99612ec..5cf3b7e 100644 --- a/test/runtests.jl +++ b/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