Skip to content

Commit

Permalink
Merge pull request #34 from NHDaly/julia1.0
Browse files Browse the repository at this point in the history
Bump minimum supported Julia version
  • Loading branch information
NHDaly authored Nov 17, 2018
2 parents 2aa551a + a22d993 commit e9bafd3
Show file tree
Hide file tree
Showing 19 changed files with 129 additions and 115 deletions.
34 changes: 15 additions & 19 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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())';
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
julia 0.6
julia 0.7
PackageCompiler
Glob
ArgParse
Compat
43 changes: 43 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -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%"
23 changes: 11 additions & 12 deletions examples/blink.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions examples/libui.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions examples/sdl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 10 additions & 23 deletions src/ApplicationBuilder.jl
Original file line number Diff line number Diff line change
@@ -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")
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 ---------------
Expand Down Expand Up @@ -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

Expand Down
12 changes: 6 additions & 6 deletions src/bundle.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if Compat.Sys.iswindows()
if Sys.iswindows()
include("installer.jl")
end
function build_app_bundle(script::String;
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/mac_commandline_app.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
32 changes: 16 additions & 16 deletions test/ApplicationBuilder.jl
Original file line number Diff line number Diff line change
@@ -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)

Expand Down Expand Up @@ -39,36 +35,35 @@ 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

# Test that it can run without .julia directory (Dangerous!)
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
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")
Expand All @@ -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
Loading

0 comments on commit e9bafd3

Please sign in to comment.