Skip to content

Commit

Permalink
Merge branch 'ianshmean-simpler_softerroring'
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelpowell committed Mar 25, 2020
2 parents 5824e88 + 8cf52d1 commit c8a176c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 63 deletions.
50 changes: 0 additions & 50 deletions deps/build.jl

This file was deleted.

47 changes: 34 additions & 13 deletions src/Spinnaker.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,27 @@ module Spinnaker

using FixedPointNumbers

import Libdl
using Libdl
import Base: unsafe_convert, show, length, getindex, size, convert, range

export System, Camera, CameraList

const __built__ = Ref(false)
functional() = __built__[]

# Include build configuration
const depsfile = joinpath(@__DIR__, "..", "deps", "deps.jl")
if isfile(depsfile)
include(depsfile)
__built__[] = true
@static if Sys.iswindows()
path = joinpath(ENV["ProgramFiles"], "Point Grey Research", "Spinnaker", "bin", "vs2015")
libspinnaker = "SpinnakerC_v140.dll"
libspinvideo = ""
elseif Sys.islinux()
path = "/usr/lib"
libspinnaker = "libSpinnaker_C.so"
libspinvideo = "libSpinVideo_C.so"
elseif Sys.isapple()
path = "/usr/local/lib"
libspinnaker = "libSpinnaker_C.dylib"
libspinvideo = "libSpinVideo_C.dylib"
end
if (@isdefined libspinnaker) && (@isdefined libspinvideo)
const libSpinnaker_C = joinpath(path, libspinnaker)
const libSpinVideo_C = joinpath(path, libspinvideo)
end

const MAX_BUFFER_LEN = Csize_t(1023)
Expand Down Expand Up @@ -55,15 +63,28 @@ include("Nodes.jl")

# Create a System object at runtime
function __init__()
if !functional()
@error """Package configuration file missing, run 'Pkg.build(\"Spinnaker\")' to configure, or `Pkg.build(\"Spinnaker\", verbose=true)` to debug."""
if (!@isdefined libSpinnaker_C) || (!@isdefined libSpinVideo_C)
@error "Spinnaker SDK only supported on Linux, Windows and MacOS platforms"
return
end
if !isfile(libSpinnaker_C)
@error "Spinnaker SDK cannot be found. This package can be loaded, but will not be functional."
return
end
try
libSpinnaker_C_handle = dlopen(libSpinnaker_C)
!Sys.iswindows() && (libSpinVideo_C_handle = dlopen(libSpinVideo_C))
catch ex
bt = catch_backtrace()
@error "Spinnaker SDK cannot be dlopen-ed"
showerror(stderr, ex, bt)
end
try
global spinsys = System()
catch ex
# don't actually fail to keep the package loadable
error("Spinnaker.jl failed to initialize", exception=(ex, catch_backtrace()))
bt = catch_backtrace()
@error "Spinnaker SDK loaded but Spinnaker.jl failed to initialize"
showerror(stderr, ex, bt)
end
end

Expand Down

0 comments on commit c8a176c

Please sign in to comment.