Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Julia v0.7 support #143

Merged
merged 46 commits into from
Aug 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
d596127
fix most 0.7 deprecations and errors
rdeits Jul 21, 2018
4df9c7f
some fixes for 0.7
vdayanand Jul 31, 2018
849985c
fix wrong use of jsstring
vdayanand Aug 7, 2018
c8532e0
use the right random port
vdayanand Aug 11, 2018
8429b7a
spawn -> run
rdeits Aug 11, 2018
1209954
more deprecations
rdeits Aug 11, 2018
7a2eddd
make port a const Ref
rdeits Aug 11, 2018
4c4d7ac
more deprecation fixes
rdeits Aug 11, 2018
76a8a1e
test all supported versions on CI
rdeits Aug 16, 2018
c53e3ef
fix Compat requirement
rdeits Aug 16, 2018
2878f71
Compat.Test
rdeits Aug 16, 2018
c04e911
don't use kwarg for run() on 0.6
rdeits Aug 16, 2018
cb177b7
checkout WebIO.jl master on 0.7 and 1.0
rdeits Aug 17, 2018
b02f1b9
update travis scripts
rdeits Aug 17, 2018
78a139e
don't build PR pushes
rdeits Aug 17, 2018
1e7a678
make install.jl more standalone
rdeits Aug 17, 2018
168c958
fix missing kwarg
rdeits Aug 17, 2018
912c572
longer sleep
rdeits Aug 17, 2018
a5eb56b
simpler travis config
rdeits Aug 17, 2018
2dc5640
fix finalizer syntax
rdeits Aug 17, 2018
f5ed611
use pkg string macro
rdeits Aug 17, 2018
26b375b
don't use pkg macro
rdeits Aug 17, 2018
78379c8
blink doesn't need HttpServer.jl
rdeits Aug 17, 2018
3038783
debug
rdeits Aug 17, 2018
bca508e
debug is broken
rdeits Aug 17, 2018
01e12a8
more debugging
rdeits Aug 17, 2018
75d5f41
fewer changes on v0.6:
rdeits Aug 17, 2018
cd880c2
drop Julia v0.6 and remove Compat.jl usage
rdeits Aug 17, 2018
76d840d
try to find an available port instead of picking one randomly
rdeits Aug 17, 2018
46d3da0
more port monkey business
rdeits Aug 17, 2018
bffb5ab
more debug
rdeits Aug 17, 2018
fccf7df
manual port
rdeits Aug 17, 2018
6b77c7f
a lot more tries
rdeits Aug 17, 2018
ed9fa52
show error
rdeits Aug 17, 2018
dfc0adc
debug electron process
rdeits Aug 17, 2018
f5c1bdc
block
rdeits Aug 17, 2018
902b390
more asserts
rdeits Aug 17, 2018
1753aff
more debugging
rdeits Aug 17, 2018
78ce030
undo all my weird hacks
rdeits Aug 17, 2018
4a6eb84
fix script
rdeits Aug 17, 2018
4485af0
update CI again
rdeits Aug 17, 2018
9932875
undo some prints
rdeits Aug 17, 2018
a047736
check out WebIO and JSExpr master on CI
rdeits Aug 19, 2018
dc004a0
use releases of webio and jsexpr
rdeits Aug 19, 2018
167af8e
suppress log messages from HTTP.jl
rdeits Aug 21, 2018
37a5ca0
don't clean up on windows for now
rdeits Aug 21, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,29 @@ notifications:
matrix:
include:
- os: linux
julia: 0.6
julia: 0.7
env: TESTCMD="xvfb-run julia"
- os: linux
julia: 1.0
env: TESTCMD="xvfb-run julia"
- os: linux
julia: nightly
env: TESTCMD="xvfb-run julia"
- os: osx
julia: 0.6
julia: 0.7
env: TESTCMD="julia"
- os: osx
julia: 1.0
env: TESTCMD="julia"
- os: osx
julia: nightly
env: TESTCMD="julia"
allow_failures:
- julia: nightly
branches:
only:
- master
script:
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
- $TESTCMD -e 'Pkg.clone(pwd()); Pkg.build("Blink"); import Blink; Pkg.test("Blink"; coverage=true)'
- $TESTCMD --color=yes -e "VERSION >= v\"0.7.0-DEV.5183\" && using Pkg; Pkg.clone(pwd()); Pkg.build(\"Blink\"); Pkg.test(\"Blink\"; coverage=true)"
after_success:
- julia -e 'using Pkg; Pkg.add("Coverage"); using Coverage; Codecov.submit(process_folder()); Coveralls.submit(process_folder())'
8 changes: 3 additions & 5 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
julia 0.6
julia 0.7
WebSockets 0.2.3
HttpServer
Lazy 0.11.3
JSON
Reexport
Mustache
MacroTools
Mux
BinDeps
Compat 0.8.6
WebIO
JSExpr
WebIO 0.3
JSExpr 0.3
37 changes: 24 additions & 13 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
environment:
matrix:
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe"
- 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:
Expand All @@ -15,18 +26,18 @@ notifications:
on_build_status_changed: false

install:
# Download most recent Julia Windows binary
- ps: (new-object net.webclient).DownloadFile(
$env:JULIA_URL,
"C:\projects\julia-binary.exe")
# Run installer silently, output to C:\projects\julia
- C:\projects\julia-binary.exe /S /D=C:\projects\julia
- ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1"))

build_script:
# Need to convert from shallow to complete for Pkg.clone to work
- IF EXIST .git\shallow (git fetch --unshallow)
- C:\projects\julia\bin\julia -e "versioninfo();
Pkg.clone(pwd(), \"Blink\"); Pkg.build(\"Blink\"); using Blink; Blink.AtomShell.install()"
- echo "%JL_BUILD_SCRIPT%"
- C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%"

test_script:
- C:\projects\julia\bin\julia -e "Pkg.test(\"Blink\")"
- 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%"
4 changes: 2 additions & 2 deletions deps/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ module BuildBlink
include(joinpath(@__DIR__, "../src/AtomShell/install.jl"))

function get_installed_version()
_path = is_apple() ?
_path = Sys.isapple() ?
joinpath(folder(), "version") :
joinpath(folder(), "atom", "version")
strip(readstring(_path), 'v')
strip(read(_path, String), 'v')
end

if isinstalled() && !(version == get_installed_version())
Expand Down
2 changes: 1 addition & 1 deletion src/AtomShell/AtomShell.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module AtomShell

using Compat; import Compat.String
using Sockets

abstract type Shell end

Expand Down
14 changes: 7 additions & 7 deletions src/AtomShell/install.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ const version = "2.0.5"

folder() = normpath(joinpath(@__FILE__, "../../../deps"))

@static if is_apple()
@static if Sys.isapple()
uninstall() = map(rm′, filter(x -> !endswith(x, "build.jl"), readdir(folder())))
else
uninstall() = rm′(joinpath(folder(), "atom"))
end

isinstalled() = is_apple() ?
isinstalled() = Sys.isapple() ?
isfile(joinpath(folder(), "version")) :
isdir(joinpath(folder(), "atom"))


function install()
dir = folder()
if is_apple()
const _icons = normpath(joinpath(@__FILE__, "../../../res/julia-icns.icns"))
if Sys.isapple()
_icons = normpath(joinpath(@__FILE__, "../../../res/julia-icns.icns"))
end
!isdir(dir) && mkpath(dir)
uninstall()
Expand All @@ -29,7 +29,7 @@ function install()

download("http://junolab.s3.amazonaws.com/blink/julia.png")

if is_apple()
if Sys.isapple()
file = "electron-v$version-darwin-x64.zip"
download("https://github.com/electron/electron/releases/download/v$version/$file")
run(`unzip -q $file`)
Expand All @@ -41,15 +41,15 @@ function install()
run(`touch Julia.app`) # Apparently this is necessary to tell the OS to double-check for the new icons.
end

if is_windows()
if Sys.iswindows()
arch = Int == Int64 ? "x64" : "ia32"
file = "electron-v$version-win32-$arch.zip"
download("https://github.com/electron/electron/releases/download/v$version/$file")
run(`7z x $file -oatom`)
rm(file)
end

if is_linux()
if Sys.islinux()
arch = Int == Int64 ? "x64" : "ia32"
file = "electron-v$version-linux-$arch.zip"
download("https://github.com/electron/electron/releases/download/v$version/$file")
Expand Down
39 changes: 24 additions & 15 deletions src/AtomShell/process.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
using Lazy, JSON, MacroTools

hascommand(c) =
try readstring(`which $c`); true catch e false end
try read(`which $c`, String); true catch e false end

spawn_rdr(cmd) = spawn(cmd, Base.spawn_opts_inherit()...)
run_rdr(cmd; kw...) = run(cmd, Base.spawn_opts_inherit()...; kw...)

resolve(pkg, path...) =
joinpath(Base.find_in_path(pkg, nothing), "..","..", path...) |> normpath
"""
resolve_blink_asset(path...)

Find a file, expressed as a relative path from the Blink package
folder. Example:

resolve_blink_asset("src", "Blink.jl") -> /home/<user>/.julia/v0.6/Blink/src/Blink.jl
"""
resolve_blink_asset(path...) = abspath(joinpath(@__DIR__, "..", "..", path...))

@deprecate resolve(pkg, path...) resolve_blink_asset(path...)

# node-inspector

Expand All @@ -27,26 +36,26 @@ end

# atom-shell

import Base: Process, TCPSocket
import Base: Process

export Electron

type Electron <: Shell
mutable struct Electron <: Shell
proc::Process
sock::TCPSocket
handlers::Dict{String, Any}
end

Electron(proc, sock) = Electron(proc, sock, Dict())

@static if is_apple()
const _electron = resolve("Blink", "deps/Julia.app/Contents/MacOS/Julia")
elseif is_linux()
const _electron = resolve("Blink", "deps/atom/electron")
elseif is_windows()
const _electron = resolve("Blink", "deps", "atom", "electron.exe")
@static if Sys.isapple()
const _electron = resolve_blink_asset("deps/Julia.app/Contents/MacOS/Julia")
elseif Sys.islinux()
const _electron = resolve_blink_asset("deps/atom/electron")
elseif Sys.iswindows()
const _electron = resolve_blink_asset("deps", "atom", "electron.exe")
end
const mainjs = resolve("Blink", "src", "AtomShell", "main.js")
const mainjs = resolve_blink_asset("src", "AtomShell", "main.js")

function electron()
path = get(ENV, "ELECTRON_PATH", _electron)
Expand All @@ -72,7 +81,7 @@ function init(; debug = false)
p, dp = port(), port()
debug && inspector(dp)
dbg = debug ? "--debug=$dp" : []
proc = (debug ? spawn_rdr : spawn)(`$(electron()) $dbg $mainjs port $p`)
proc = (debug ? run_rdr : run)(`$(electron()) $dbg $mainjs port $p`; wait=false)
conn = try_connect(ip"127.0.0.1", p)
shell = Electron(proc, conn)
initcbs(shell)
Expand All @@ -89,7 +98,7 @@ handlers(shell::Electron) = shell.handlers

function initcbs(shell)
enable_callbacks!(shell)
@schedule begin
@async begin
while active(shell)
@errs handle_message(shell, JSON.parse(shell.sock))
end
Expand Down
14 changes: 7 additions & 7 deletions src/AtomShell/window.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export Window, flashframe, shell, progress, title,
centre, floating, loadurl, opentools, closetools, tools,
loadhtml, loadfile, css, front

type Window
mutable struct Window
id::Int
shell::Shell
content
Expand All @@ -20,17 +20,17 @@ const window_defaults = @d(:url => "about:blank",
:title => "Julia",
"node-integration" => false,
"use-content-size" => true,
:icon => resolve("Blink", "deps", "julia.png"))
:icon => resolve_blink_asset("deps", "julia.png"))

raw_window(a::Electron, opts) = @js a createWindow($(merge(window_defaults, opts)))

function Window(a::Shell, opts::Associative = Dict())
function Window(a::Shell, opts::AbstractDict = Dict())
return haskey(opts, :url) ?
Window(raw_window(a, opts), a, nothing) :
Window(a, Page(), opts)
end

function Window(a::Shell, content::Page, opts::Associative = Dict())
function Window(a::Shell, content::Page, opts::AbstractDict = Dict())
opts = merge(opts, Dict(:url => Blink.localurl(content)))
return Window(raw_window(a, opts), a, content)
end
Expand Down Expand Up @@ -120,15 +120,15 @@ close(win::Window) =

# Window content APIs

active(::Void) = false
active(::Nothing) = false

handlers(w::Window) = handlers(w.content)

msg(win::Window, m) = msg(win.content, m)

js(win::Window, s::JSString; callback = true) =
active(win.content) ? js(win.content, s, callback = callback) :
dot(win, :(this.webContents.executeJavaScript($(jsstring(s)))), callback = callback)
dot(win, :(this.webContents.executeJavaScript($(s.s))), callback = callback)

const initcss = """
<style>html,body{margin:0;padding:0;border:0;text-align:center;}</style>
Expand All @@ -141,6 +141,6 @@ function loadhtml(win::Window, html::AbstractString)
println(io, html)
end
loadfile(win, tmp)
@schedule (sleep(1); rm(tmp))
@async (sleep(1); rm(tmp))
return
end
7 changes: 5 additions & 2 deletions src/Blink.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ __precompile__()
module Blink

using Reexport
using Compat; import Compat.String
using Distributed: Future
using Sockets
using Logging
using Base64: stringmime

include("rpc/rpc.jl")
include("content/content.jl")

include("AtomShell/AtomShell.jl")
export AtomShell
@reexport using .AtomShell
import .AtomShell: resolve
import .AtomShell: resolve_blink_asset

end # module
2 changes: 1 addition & 1 deletion src/content/api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function load!(w, file; async=false)
elseif ext == "css"
loadcss!(w, file)
elseif ext == "html"
importhtml!(w, file; async)
importhtml!(w, file; async=async)
else
error("Blink: Unsupported file type")
end
Expand Down
14 changes: 8 additions & 6 deletions src/content/config.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
export localips

@init global const port = get(ENV, "BLINK_PORT", rand(2_000:10_000))
const port = Ref{Int}()

@init port[] = haskey(ENV, "BLINK_PORT") ? parse(Int, get(ENV, "BLINK_PORT")) : rand(2_000:10_000)

const ippat = r"([0-9]+\.){3}[0-9]+"

@static if is_unix()
@static if Sys.isunix()
localips() = map(IPv4, readlines(`ifconfig` |>
`grep -Eo $("inet (addr:)?$(ippat.pattern)")` |>
`grep -Eo $(ippat.pattern)` |>
Expand All @@ -13,14 +15,14 @@ end

# Browser Window

@static if is_apple()
@static if Sys.isapple()
launch(x) = run(`open $x`)
elseif is_linux()
elseif Sys.islinux()
launch(x) = run(`xdg-open $x`)
elseif is_windows()
elseif Sys.iswindows()
launch(x) = run(`cmd /C start $x`)
end

localurl(p::Page) = "http://127.0.0.1:$port/$(id(p))"
localurl(p::Page) = "http://127.0.0.1:$(port[])/$(id(p))"

launch(p::Page) = (launch(localurl(p)); p)
Loading