Skip to content

Commit

Permalink
Merge pull request #55 from rdeits/rd/0.7-support
Browse files Browse the repository at this point in the history
Support Julia 0.7
  • Loading branch information
rdeits committed Aug 23, 2018
2 parents 32e60e0 + 28624a4 commit bef0414
Show file tree
Hide file tree
Showing 13 changed files with 133 additions and 175 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.ipynb_checkpoints
deps/build.log

17 changes: 9 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ matrix:
- os: linux
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"
Expand All @@ -17,17 +20,17 @@ matrix:
- os: osx
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
- julia: 0.7

notifications:
email: false
git:
depth: 99999999

branches:
only:
Expand All @@ -43,13 +46,11 @@ addons:
before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install ffmpeg; fi


script:
# - julia -e 'Pkg.clone(pwd()); Pkg.build("MeshCat"); Pkg.test("MeshCat"; coverage=true)'
- $TESTCMD -e 'Pkg.clone(pwd()); Pkg.build("MeshCat"); Pkg.test("MeshCat"; coverage=true)'
- $TESTCMD -e 'if VERSION < v"0.7-"; Pkg.clone(pwd()); else; import Pkg; Pkg.add(Pkg.PackageSpec(path=pwd())); end; Pkg.build("MeshCat"); Pkg.test("MeshCat"; coverage=true)'
- julia --code-coverage=user -e 'using MeshCat; MeshCat.develop_meshcat_assets(true)'
- julia -e 'Pkg.build("MeshCat")'
- julia -e 'if VERSION >= v"0.7-"; import Pkg; end; Pkg.build("MeshCat")'
after_success:
# push coverage results to Coveralls
# push coverage results to Codecov
- julia -e 'cd(Pkg.dir("MeshCat")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'
- julia -e 'if VERSION >= v"0.7-"; import Pkg; end; Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'
6 changes: 3 additions & 3 deletions REQUIRE
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ Requires

# Communication
MsgPack 0.1.1
WebIO 0.2.0
Mux 0.2.3
JSExpr 0.1.0
WebIO # TODO: require v0.3.0 when we drop Julia v0.6
Mux 0.2.3 # TODO: require v0.5.2 when we drop Julia v0.6
JSExpr # TODO: require v0.3.0 when we drop Julia v0.6
AssetRegistry 0.0.1
JSON
48 changes: 23 additions & 25 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
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_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
# - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
- julia_version: 0.6
- julia_version: 0.7
- julia_version: 1
- julia_version: nightly

# uncomment the following lines to allow failures on nightly julia
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_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
allow_failures:
- julia_version: nightly

branches:
only:
- master
- /release-.*/

notifications:
- provider: Email
Expand All @@ -23,24 +27,18 @@ notifications:
on_build_status_changed: false

install:
- ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12"
# If there's a newer build queued for the same PR, cancel this one
- ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod `
https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | `
Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { `
throw "There are newer queued builds for this pull request, failing early." }
# 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(), \"MeshCat\"); Pkg.build(\"MeshCat\")"
- echo "%JL_BUILD_SCRIPT%"
- C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%"

test_script:
- C:\projects\julia\bin\julia -e "Pkg.test(\"MeshCat\")"
- 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%"
13 changes: 9 additions & 4 deletions demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"source": [
"# Activate the MeshCat package, and import some other \n",
"# useful functions\n",
"using Compat\n",
"using MeshCat\n",
"using CoordinateTransformations\n",
"import GeometryTypes: HyperRectangle, Vec, Point, HomogenousMesh, SignedDistanceField\n",
Expand Down Expand Up @@ -335,7 +336,11 @@
"# just simple boxes. Let's load a 3D mesh and visualize it:\n",
"using MeshIO\n",
"using FileIO\n",
"cat_mesh = load(joinpath(Pkg.dir(\"GeometryTypes\"), \"test\", \"data\", \"cat.obj\"))\n",
"if VERSION < v\"0.7-\"\n",
" cat_mesh = load(joinpath(Pkg.dir(\"GeometryTypes\"), \"test\", \"data\", \"cat.obj\"))\n",
"else\n",
" cat_mesh = load(joinpath(dirname(pathof(GeometryTypes)), \"..\", \"test\", \"data\", \"cat.obj\"))\n",
"end\n",
"setobject!(vis, cat_mesh)\n",
"settransform!(vis, LinearMap(AngleAxis(pi/2, 1, 0, 0)))"
]
Expand Down Expand Up @@ -399,7 +404,7 @@
"outputs": [],
"source": [
"delete!(vis)\n",
"pointcloud = PointCloud([[x, 0 + 0.01 * randn(), 0.5] for x in linspace(-1, 1, 1000)])\n",
"pointcloud = PointCloud([[x, 0 + 0.01 * randn(), 0.5] for x in Compat.range(-1, stop=1, length=1000)])\n",
"setobject!(vis[:pointcloud], pointcloud)"
]
},
Expand Down Expand Up @@ -472,15 +477,15 @@
],
"metadata": {
"kernelspec": {
"display_name": "Julia 0.6.3",
"display_name": "Julia 0.6.4",
"language": "julia",
"name": "julia-0.6"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "0.6.3"
"version": "0.6.4"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions deps/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function update_meshcat()
return
end
if isdir(meshcat_dir) && isfile(stamp_file)
stamped_sha = strip(open(readstring, stamp_file))
stamped_sha = strip(open(f -> read(f, String), stamp_file))
if stamped_sha == meshcat_sha
return
else
Expand All @@ -36,7 +36,7 @@ function update_meshcat()
download_path = joinpath(download_dir, "meshcat.zip")
run(download_cmd(meshcat_url, download_path))
run(unpack_cmd(download_path, download_dir, ".zip", nothing))
mv(joinpath(download_dir, "meshcat-$meshcat_sha"), meshcat_dir; remove_destination=true)
Compat.mv(joinpath(download_dir, "meshcat-$meshcat_sha"), meshcat_dir; force=true)
end
open(stamp_file, "w") do file
print(file, meshcat_sha)
Expand Down
22 changes: 17 additions & 5 deletions src/MeshCat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,25 @@ __precompile__()

module MeshCat

using Compat
using WebIO
import Mux
import AssetRegistry
using GeometryTypes, CoordinateTransformations
using Rotations: rotation_between, Rotation
using Colors: Color, Colorant, RGB, RGBA, alpha
using Colors: Color, Colorant, RGB, RGBA, alpha, hex
using StaticArrays: StaticVector, SVector, SDiagonal
using GeometryTypes: raw
using Parameters: @with_kw
using Compat.UUIDs: UUID, uuid1
using DocStringExtensions: SIGNATURES
using JSExpr: @js, @new, @var
using Requires: @require
using Base.Filesystem: rm
using BinDeps: download_cmd, unpack_cmd
using Compat.LinearAlgebra: UniformScaling
using Compat
using Compat.UUIDs: UUID, uuid1
using Compat.LinearAlgebra: UniformScaling, norm
using Compat.Sockets: listen
using Compat.Base64: base64encode

import Base: delete!, length
import MsgPack: pack, Ext
Expand Down Expand Up @@ -73,7 +76,6 @@ include("servers.jl")

const VIEWER_ROOT = joinpath(@__DIR__, "..", "assets", "meshcat", "dist")


function develop_meshcat_assets(skip_confirmation=false)
meshcat_dir = abspath(joinpath(@__DIR__, "..", "assets", "meshcat"))
if !skip_confirmation
Expand All @@ -98,6 +100,16 @@ const ASSET_KEYS = String[]

function __init__()
push!(ASSET_KEYS, AssetRegistry.register(abspath(joinpath(VIEWER_ROOT, "main.min.js"))))

@require Blink="ad839575-38b3-5650-b840-f874b8c74a25" begin
function Base.open(core::CoreVisualizer, w::Blink.AtomShell.Window)
# Ensure the window is ready
Blink.js(w, "ok")
# Set its contents
Blink.body!(w, core.scope)
w
end
end
end

end
7 changes: 4 additions & 3 deletions src/lowering.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ end
js_array_type(::Type{Float32}) = "Float32Array"
js_array_type(::Type{UInt32}) = "Uint32Array"

struct PackedVector{V <: AbstractVector} # TODO: should require contiguous layout
data::V
struct PackedVector{T}
data::Vector{T}
end

function lower(points::Vector{P}) where {P <: Union{StaticVector, Colorant}}
Expand All @@ -125,7 +125,8 @@ function lower(points::Vector{P}) where {P <: Union{StaticVector, Colorant}}
Dict{String, Any}(
"itemSize" => N,
"type" => js_array_type(T),
"array" => PackedVector(reinterpret(T, points, (N * length(points),))),
"array" => PackedVector{T}(
reshape(reinterpret(T, points), (N * length(points),))),
)
end

Expand Down
7 changes: 5 additions & 2 deletions src/msgpack.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
extcode(v::PackedVector) = extcode(eltype(v.data))
extcode(v::PackedVector{T}) where {T} = extcode(T)
extcode(::Type{UInt8}) = 0x12
extcode(::Type{Int32}) = 0x15
extcode(::Type{UInt32}) = 0x16
extcode(::Type{Float32}) = 0x17

pack(io::IO, v::PackedVector) = pack(io, Ext(extcode(v), reinterpret(UInt8, v.data, (sizeof(v.data),))))
pack(io::IO, v::PackedVector) = pack(io, Ext(extcode(v),
convert(Vector{UInt8},
reshape(reinterpret(UInt8, v.data),
(sizeof(v.data),)))))
Loading

0 comments on commit bef0414

Please sign in to comment.