diff --git a/.travis.yml b/.travis.yml index 60af103..f5e037e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,33 +1,29 @@ ## Documentation: http://docs.travis-ci.com/user/languages/julia/ language: julia + os: - osx + #- linux # TODO: Enable Linux + julia: - 0.6 - 0.7 + - 1.0 - nightly -#matrix: -# allow_failures: -# - julia: nightly + +# # Uncomment the following lines to allow failures on nightly julia +# # (tests will run but not make your overall status red) +# matrix: +# allow_failures: +# - julia: nightly notifications: email: false -git: - depth: 99999999 -## uncomment and modify the following lines to manually install system packages -#addons: -# apt: # apt-get for linux -# packages: -# - gfortran -before_script: # homebrew for mac - - julia -e 'if (VERSION < v"0.7-") Pkg.add("Blink"); Pkg.build("Blink"); using Blink; Blink.AtomShell.install(); end' +#script: # the default script is equivalent to the following +# - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi +# - julia -e 'Pkg.clone(pwd()); Pkg.build("Example"); Pkg.test("Example"; coverage=true)'; -## uncomment the following lines to override the default test script -#script: -# - julia -e 'Pkg.add("Blink"); Pkg.clone(pwd()); Pkg.build("ApplicationBuilder""); Pkg.test("ApplicationBuilder""; coverage=true)' after_success: - # push coverage results to Coveralls - - julia -e 'cd(Pkg.dir("ApplicationBuilder")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())' - # push coverage results to Codecov - - julia -e 'cd(Pkg.dir("ApplicationBuilder")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())' + - julia -e 'if VERSION >= v"0.7.0-" using Pkg end; cd(Pkg.dir("Example")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'; +# - julia -e 'if VERSION >= v"0.7.0-" using Pkg end; cd(Pkg.dir("Example")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'; diff --git a/README.md b/README.md index a8f2495..67b6719 100644 --- a/README.md +++ b/README.md @@ -37,8 +37,9 @@ To build a julia program into an application, you'll need to do two steps: ## Compatibility -`ApplicationBuilder` supports macOS, Windows, and Linux on `julia v0.6` and `julia v0.7`. -Currently, ApplicationBuilder doesn't do cross-compilation, so to compile for Windows, you need to run it from a Windows machine, etc. +`ApplicationBuilder` supports macOS, Windows, and Linux. +Currently, ApplicationBuilder doesn't do cross-compilation, so to compile for +Windows, you need to run it from a Windows machine, etc. ## Running an example: After cloning the repository, you can build an App out of the example program, `examples/hello.jl`, like this: diff --git a/REQUIRE b/REQUIRE index 45fe395..ee5b5e0 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,5 +1,4 @@ -julia 0.6 +julia 0.7 PackageCompiler Glob ArgParse -Compat diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..9dcf199 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,43 @@ +environment: + matrix: + - julia_version: 0.7 + - julia_version: 1 + - julia_version: nightly + +platform: + - x86 # 32-bit + - x64 # 64-bit + +# Uncomment the following lines to allow failures on nightly julia +# (tests will run but not make your overall status red) +matrix: + allow_failures: + - julia_version: nightly + +branches: + only: + - master + - /release-.*/ + +notifications: + - provider: Email + on_build_success: false + on_build_failure: false + on_build_status_changed: false + +install: + - ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1")) + +build_script: + - echo "%JL_BUILD_SCRIPT%" + - C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%" + +test_script: + - echo "%JL_TEST_SCRIPT%" + - C:\julia\bin\julia -e "%JL_TEST_SCRIPT%" + +# # Uncomment to support code coverage upload. Should only be enabled for packages +# # which would have coverage gaps without running on Windows +# on_success: +# - echo "%JL_CODECOV_SCRIPT%" +# - C:\julia\bin\julia -e "%JL_CODECOV_SCRIPT%" diff --git a/examples/blink.jl b/examples/blink.jl index 9e523c9..a2ad43c 100644 --- a/examples/blink.jl +++ b/examples/blink.jl @@ -23,24 +23,23 @@ using Blink if get(ENV, "COMPILING_APPLE_BUNDLE", "false") == "true" println("Overriding Blink dependency paths.") println("Overriding Blink dependency paths.") - eval(Blink.AtomShell, :(_electron = "Julia.app/Contents/MacOS/Julia")) - eval(Blink.AtomShell, :(mainjs = "main.js")) - eval(Blink, :(buzz = "main.html")) - eval(Blink, :(resources = Dict("spinner.css" => "res/spinner.css", + Core.eval(Blink.AtomShell, :(_electron = "Julia.app/Contents/MacOS/Julia")) + Core.eval(Blink.AtomShell, :(mainjs = "main.js")) + Core.eval(Blink, :(buzz = "main.html")) + Core.eval(Blink, :(resources = Dict("spinner.css" => "res/spinner.css", "blink.js" => "res/blink.js", "blink.css" => "res/blink.css", "reset.css" => "res/reset.css"))) # Clear out Blink.__inits__, since it will attempt to evaluate hardcoded paths. # (We've defined all the variables manually, above: `resources` and `port`.) - eval(Blink, :(empty!(__inits__))) + Core.eval(Blink, :(empty!(__inits__))) - eval(HttpParser, :(lib = basename(lib))) - eval(MbedTLS, :(const libmbedcrypto = basename(libmbedcrypto))) + Core.eval(Blink.Mux.HTTP.MbedTLS, :(const libmbedcrypto = basename(libmbedcrypto))) - using WebSockets - eval(WebSockets, :(using HttpServer)) # needed to cause @require lines to execute & compile - eval(WebSockets, - :(include(joinpath(Pkg.dir("WebSockets"),"src/HttpServer.jl")))) # Manually load this from the @requires line. +# WebSockets = Blink.WebSockets +# Core.eval(WebSockets, :(using HttpServer)) # needed to cause @require lines to execute & compile +# Core.eval(WebSockets, +# :(include(joinpath(Pkg.dir("WebSockets"),"src/HttpServer.jl")))) # Manually load this from the @requires line. println("Done changing dependencies.") end @@ -57,7 +56,7 @@ html() = """ function helloFromBlink() # Set Blink port randomly before anything else. - eval(Blink, :(const port = get(ENV, "BLINK_PORT", rand(2_000:10_000)))) + Blink.port[] = get(ENV, "BLINK_PORT", rand(2_000:10_000)) # Create Blink window and load HTML. win = Blink.Window(Blink.shell(), Dict(:width=>850)); sleep(5.0) diff --git a/examples/libui.jl b/examples/libui.jl index 1759531..9824ec8 100644 --- a/examples/libui.jl +++ b/examples/libui.jl @@ -2,9 +2,6 @@ using Libui using Libui -@static if VERSION < v"0.7-" - using Compat: Nothing -end #const progressbar::Ptr{uiProgressBar} = C_NULL #const spinbox::Ptr{uiProgressBar} = C_NULL diff --git a/examples/sdl.jl b/examples/sdl.jl index d14f500..e6231b2 100644 --- a/examples/sdl.jl +++ b/examples/sdl.jl @@ -9,16 +9,16 @@ using SimpleDirectMediaLayer SDL2 = SimpleDirectMediaLayer -using Compat.Pkg +using Pkg fontFile = joinpath(Pkg.dir("SimpleDirectMediaLayer"), "assets","fonts","FiraCode","ttf","FiraCode-Regular.ttf") # Override SDL libs + assets locations if this script is being compiled for mac .app builds if get(ENV, "COMPILING_APPLE_BUNDLE", "false") == "true" - eval(SDL2, :(libSDL2 = "libSDL2.dylib")) - eval(SDL2, :(libSDL2_ttf = "libSDL2_ttf.dylib")) - eval(SDL2, :(libSDL2_mixer = "libSDL2_mixer.dylib")) + Core.eval(SDL2, :(libSDL2 = "libSDL2.dylib")) + Core.eval(SDL2, :(libSDL2_ttf = "libSDL2_ttf.dylib")) + Core.eval(SDL2, :(libSDL2_mixer = "libSDL2_mixer.dylib")) fontFile = basename(fontFile) end diff --git a/src/ApplicationBuilder.jl b/src/ApplicationBuilder.jl index 924c644..001c27b 100644 --- a/src/ApplicationBuilder.jl +++ b/src/ApplicationBuilder.jl @@ -1,21 +1,10 @@ module ApplicationBuilder -using Compat -Compat.@warn """ApplicationBuilder has changed since JuliaCon 2018. - - `module BuildApp` has been removed. You should remove `using BuildApp` - from your build scripts, and just use `using ApplicationBuilder`. - - You should also _remove_ `using ApplicationBuilder` from the source-code of - programs being built, since the `change_dir_if_bundle` behavior will - now come default for all applications. `using ApplicationBuilder` in - your program source may cause it to fail to build. - This message will be removed in the next version of ApplicationBuilder. -""" - using Glob, PackageCompiler export build_app_bundle -@static if Compat.Sys.isapple() +@static if Sys.isapple() include("sign_mac_app.jl") include("mac_commandline_app.jl") @@ -104,7 +93,7 @@ function build_app_bundle(juliaprog_main; elseif !isempty(glob(pattern)) run_verbose(verbose, `cp -rf $(glob(pattern)) $dest/`) # Copy the specified glob pattern to dest. else - Compat.@warn "Skipping unknown file '$pattern'!" + @warn "Skipping unknown file '$pattern'!" end end @@ -153,11 +142,9 @@ function build_app_bundle(juliaprog_main; """ include("$(abspath(juliaprog_main))") """*raw""" - using Compat - - Base.@ccallable function cd_to_bundle_resources()::Compat.Nothing + Base.@ccallable function cd_to_bundle_resources()::Nothing full_binary_name = PROGRAM_FILE # PROGRAM_FILE is set manually in program.c - if Compat.Sys.isapple() + if Sys.isapple() m = match(r".app/Contents/MacOS/[^/]+$", full_binary_name) if m != nothing resources_dir = joinpath(dirname(dirname(full_binary_name)), "Resources") @@ -190,7 +177,7 @@ function build_app_bundle(juliaprog_main; try # an example output line from otool: " path /Applications/Dev Apps/Julia-0.6.app/Contents/Resources/julia/lib (offset 12)" external_julia_deps = readlines(pipeline(`otool -l $binary_file`, - `grep $(dirname(Compat.Sys.BINDIR))`, # filter julia lib deps + `grep $(dirname(Sys.BINDIR))`, # filter julia lib deps `sed 's/\s*path//'`, # remove leading " path" `sed 's/(.*)$//'`)) # remove trailing parens for line in external_julia_deps @@ -259,15 +246,15 @@ function build_app_bundle(juliaprog_main; write("$appDir/Info.plist", info_plist()); # Copy Julia icons - julia_app_resources_dir() = joinpath(Compat.Sys.BINDIR, "..","..") + julia_app_resources_dir() = joinpath(Sys.BINDIR, "..","..") if (icns_file == nothing) icns_file = joinpath(julia_app_resources_dir(),"julia.icns") verbose && println("Attempting to copy default icons from Julia.app: $icns_file") end if isfile(icns_file) - Compat.cp(icns_file, "$resourcesDir/$appname.icns", force=true); + cp(icns_file, "$resourcesDir/$appname.icns", force=true); else - Compat.@warn "Skipping nonexistent icons file: '$icns_file'" + @warn "Skipping nonexistent icons file: '$icns_file'" end # --------------- CLEAN UP before distributing --------------- @@ -312,11 +299,11 @@ end end # isapple -@static if Compat.Sys.islinux() || Compat.Sys.iswindows() +@static if Sys.islinux() || Sys.iswindows() include("bundle.jl") end -@static if Compat.Sys.iswindows() +@static if Sys.iswindows() include("installer.jl") end diff --git a/src/bundle.jl b/src/bundle.jl index e9f8330..0c28a08 100644 --- a/src/bundle.jl +++ b/src/bundle.jl @@ -1,4 +1,4 @@ -if Compat.Sys.iswindows() +if Sys.iswindows() include("installer.jl") end function build_app_bundle(script::String; @@ -25,27 +25,27 @@ function build_app_bundle(script::String; mkpath(lib_path) mkpath(res_path) - delim = Compat.Sys.iswindows() ? '\\' : '/' + delim = Sys.iswindows() ? '\\' : '/' @info "Copying resources:" for res in resources print("Copying $res...") - Compat.cp(res, joinpath(res_path, split(res, delim)[end]), force = true) + cp(res, joinpath(res_path, split(res, delim)[end]), force = true) println("... done.") end @info "Copying libraries" for lib in libraries print("Copying $lib...") - Compat.cp(lib, joinpath(lib_path, split(lib, delim)[end]), force = true) + cp(lib, joinpath(lib_path, split(lib, delim)[end]), force = true) println("... done.") end build_executable(script, builddir = core_path) - (create_installer && Compat.Sys.islinux()) && throw(error("Cannot create installer on Linux")) + (create_installer && Sys.islinux()) && throw(error("Cannot create installer on Linux")) - if Compat.Sys.iswindows() + if Sys.iswindows() create_installer && installer(builddir, name = appname) end diff --git a/src/mac_commandline_app.jl b/src/mac_commandline_app.jl index f35374d..15c0f6f 100644 --- a/src/mac_commandline_app.jl +++ b/src/mac_commandline_app.jl @@ -24,7 +24,7 @@ function build_commandline_app_bundle(builddir, binary_name, appname, verbose) applet_name = "applet" if binary_name == applet_name # Prevent collisions. applet_name = "applet_wrapper" - Compat.mv("$app_path/Contents/MacOS/applet", "$app_path/Contents/MacOS/$applet_name", force=true) + mv("$app_path/Contents/MacOS/applet", "$app_path/Contents/MacOS/$applet_name", force=true) end # Remove unneeded applet files it creates. rm("$app_path/Contents/Resources/applet.icns") diff --git a/test/ApplicationBuilder.jl b/test/ApplicationBuilder.jl index 88e2d50..30dcfa4 100644 --- a/test/ApplicationBuilder.jl +++ b/test/ApplicationBuilder.jl @@ -1,11 +1,7 @@ -using Compat - -using Compat.Test -using Compat.Pkg +using Test +using Pkg using ApplicationBuilder -const julia_v07 = VERSION > v"0.7-" - builddir = mktempdir() @assert isdir(builddir) @@ -39,14 +35,14 @@ end function testRunAndKillProgramSucceeds(cmd, timeout=10) - out, _, p = readandwrite(cmd) # Make sure it runs correctly + p = open(cmd, "r+") # Make sure it runs correctly sleep(1) - process_exited(p) && (println("Test Failed: failed to launch: \n", readstring(out)); return false) + process_exited(p) && (println("Test Failed: failed to launch: \n", read(p.out, String)); return false) sleep(timeout) - process_exited(p) && (println("Test Failed: Process died: \n", readstring(out)); return false) + process_exited(p) && (println("Test Failed: Process died: \n", read(p.out, String)); return false) # Manually kill program after it's been running for a bit. kill(p); sleep(1) - process_exited(p) || (println("Test Failed: Process failed to exit: \n", readstring(out)); return false) + process_exited(p) || (println("Test Failed: Process failed to exit: \n", read(p.out, String)); return false) return true end @@ -54,12 +50,13 @@ end function testBundledSuccessfully_macro(cmd_expr, timeout=10) quote val = false - mv(Pkg.dir(), Pkg.dir()*".bak") # NOTE: MUST mv() THIS BACK + julia_dir = Pkg.Pkg2._pkgroot() + mv(julia_dir, julia_dir*".bak") # NOTE: MUST mv() THIS BACK try val = testRunAndKillProgramSucceeds($cmd_expr, $timeout) catch end - mv(Pkg.dir()*".bak", Pkg.dir()) # NOTE: MUST RUN THIS LINE IF ABOVE IS RUN + mv(julia_dir*".bak", julia_dir) # NOTE: MUST RUN THIS LINE IF ABOVE IS RUN val end end @@ -67,8 +64,6 @@ macro testBundledSuccessfully(expr...) testBundledSuccessfully_macro(expr...) end -if !julia_v07 # Blink and SDL don't yet work on julia v0.7. - # Disabling the SDL tests since Cairo is currently broken in METADATA. #@testset "sdl: simple example of binary dependencies" begin #@test 0 == include("build_examples/sdl.jl") @@ -88,6 +83,11 @@ if !julia_v07 # Blink and SDL don't yet work on julia v0.7. # Test that it runs correctly @test testRunAndKillProgramSucceeds(`$builddir/HelloBlink.app/Contents/MacOS/blink`) # Test that it can run without .julia directory -@test @testBundledSuccessfully(`$builddir/HelloBlink.app/Contents/MacOS/blink`, 10) -end + +# TODO: This is broken because Blink currently can't be statically compiled +# https://github.com/JunoLab/Blink.jl/pull/174 +# (It appears to work in this test, but the application does nothing because it errors.) +# @test @testBundledSuccessfully(`$builddir/HelloBlink.app/Contents/MacOS/blink`, 10) +# Replacing with a test_broken so we remember. +@test_broken false end diff --git a/test/REQUIRE b/test/REQUIRE index 5b90635..9e504cd 100644 --- a/test/REQUIRE +++ b/test/REQUIRE @@ -1,3 +1,5 @@ -Blink +Blink#master # This test is going to be failing until https://github.com/JunoLab/Blink.jl/pull/174 is merged +MacroTools#master # Needed for Blink. MacroTools is statically compilable only on master. + # SimpleDirectMediaLayer # disabled since Cairo is currently broken in METADATA. diff --git a/test/build_app-cli.jl b/test/build_app-cli.jl index 3ca9350..8169551 100644 --- a/test/build_app-cli.jl +++ b/test/build_app-cli.jl @@ -1,4 +1,4 @@ -using Base.Test +using Test julia = Base.julia_cmd().exec[1] build_app_jl = joinpath(@__DIR__, "..", "build_app.jl") diff --git a/test/build_examples/blink.jl b/test/build_examples/blink.jl index 7435e88..c81f1a6 100644 --- a/test/build_examples/blink.jl +++ b/test/build_examples/blink.jl @@ -1,21 +1,18 @@ using ApplicationBuilder -using Compat -using Compat.Pkg +using Pkg examples_blink = joinpath(@__DIR__, "..", "..", "examples", "blink.jl") # Allow this file to be called either as a standalone file to build the above # example, or from runtests.jl using a provided builddir. -Compat.isdefined(:builddir) || (builddir="builddir") - -blinkPkg = Pkg.dir("Blink") -httpParserPkg = Pkg.dir("HttpParser") -mbedTLSPkg = Pkg.dir("MbedTLS") - -@assert blinkPkg != nothing "Blink is not installed!" +@isdefined(builddir) || (builddir="builddir") using Blink +MbedTLS = Blink.Mux.HTTP.MbedTLS + +blinkPkg = dirname(dirname(pathof(Blink))) +mbedTLSPkg = dirname(dirname(pathof(MbedTLS))) ApplicationBuilder.build_app_bundle(examples_blink; verbose = true, @@ -25,6 +22,5 @@ ApplicationBuilder.build_app_bundle(examples_blink; joinpath(blinkPkg, "res")], # Get the current library names directly from the packages that use them, # which keeps this build script robust against lib version changes. - libraries = [HttpParser.lib, - MbedTLS.libmbedcrypto], + libraries = [MbedTLS.libmbedcrypto], appname="HelloBlink", builddir=builddir) diff --git a/test/build_examples/commandline_hello.jl b/test/build_examples/commandline_hello.jl index c751e6f..f549fb3 100644 --- a/test/build_examples/commandline_hello.jl +++ b/test/build_examples/commandline_hello.jl @@ -1,10 +1,8 @@ using ApplicationBuilder -using Compat - # Allow this file to be called either as a standalone file to build the above # example, or from runtests.jl using a provided builddir. -Compat.isdefined(:builddir) || (builddir="builddir") +@isdefined(builddir) || (builddir="builddir") build_app_bundle(joinpath(@__DIR__,"..","..","examples","commandline_hello.jl"), appname="hello", diff --git a/test/build_examples/hello.jl b/test/build_examples/hello.jl index d02119b..d104640 100644 --- a/test/build_examples/hello.jl +++ b/test/build_examples/hello.jl @@ -1,12 +1,10 @@ using ApplicationBuilder -using Compat - examples_hello = joinpath(@__DIR__, "..", "..", "examples", "hello.jl") # Allow this file to be called either as a standalone file to build the above # example, or from runtests.jl using a provided builddir. -Compat.isdefined(:builddir) || (builddir="builddir") +@isdefined(builddir) || (builddir="builddir") ApplicationBuilder.build_app_bundle(examples_hello; verbose=true, appname="HelloWorld", builddir=builddir) diff --git a/test/build_examples/libui.jl b/test/build_examples/libui.jl index 3f7abac..1e1f165 100644 --- a/test/build_examples/libui.jl +++ b/test/build_examples/libui.jl @@ -1,11 +1,10 @@ using ApplicationBuilder -using Compat -using Compat.Pkg +using Pkg # Allow this file to be called either as a standalone file to build the above # example, or from runtests.jl using a provided builddir. -Compat.isdefined(:builddir) || (builddir="builddir") +@isdefined(builddir) || (builddir="builddir") libUIPkg = Pkg.dir("Libui") diff --git a/test/build_examples/sdl.jl b/test/build_examples/sdl.jl index ac8de5e..5cd12a4 100644 --- a/test/build_examples/sdl.jl +++ b/test/build_examples/sdl.jl @@ -1,12 +1,11 @@ using ApplicationBuilder -using Compat -using Compat.Pkg +using Pkg examples_blink = joinpath(@__DIR__, "..", "..", "examples", "sdl.jl") # Allow this file to be called either as a standalone file to build the above # example, or from runtests.jl using a globally-defined builddir. -Compat.isdefined(:builddir) || (builddir="builddir") +@isdefined(builddir) || (builddir="builddir") using SimpleDirectMediaLayer SDL2 = SimpleDirectMediaLayer @@ -23,7 +22,7 @@ libs = joinpath(builddir, "sdl_libs") mkpath(libs) function cp_lib(l) name = basename(l) - Compat.cp(l, joinpath(libs, name), follow_symlinks=true, force=true) + cp(l, joinpath(libs, name), follow_symlinks=true, force=true) l = joinpath(libs, name) run(`install_name_tool -id "$name" $l`) try diff --git a/test/runtests.jl b/test/runtests.jl index 1159f99..c4621de 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,4 +1,4 @@ -using Compat.Test +using Test @testset "Test ApplicationBuilder (by compiling examples/*.jl)" begin include("ApplicationBuilder.jl")