Skip to content

Commit

Permalink
add symbol / string versions of find_library
Browse files Browse the repository at this point in the history
relax find_library argument types to any iterable
  • Loading branch information
jakebolewski committed Nov 18, 2015
1 parent ea2ab73 commit 7e8c4a3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 3 additions & 1 deletion base/libdl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function dlclose(p::Ptr)
0 == ccall(:jl_dlclose, Cint, (Ptr{Void},), p)
end

function find_library(libnames::Vector, extrapaths::Vector=ASCIIString[])
function find_library(libnames, extrapaths=ASCIIString[])
for lib in libnames
for path in extrapaths
l = joinpath(path, lib)
Expand All @@ -64,6 +64,8 @@ function find_library(libnames::Vector, extrapaths::Vector=ASCIIString[])
end
return ""
end
find_library(libname::Union{Symbol,AbstractString}, extrapaths=ASCIIString[]) =
find_library([string(libname)], extrapaths)

function dlpath(handle::Ptr{Void})
p = ccall(:jl_pathname_for_handle, Ptr{UInt8}, (Ptr{Void},), handle)
Expand Down
12 changes: 7 additions & 5 deletions test/libdl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@ end

cd(dirname(@__FILE__)) do

# @test !isempty(Libdl.find_library(["libccalltest"], [dirname(@__FILE__)]))

# Find the private library directory by finding the path of libjulia (or libjulia-debug, as the case may be)
if ccall(:jl_is_debugbuild, Cint, ()) != 0
private_libdir = dirname(abspath(Libdl.dlpath("libjulia-debug")))
private_libdir = if ccall(:jl_is_debugbuild, Cint, ()) != 0
dirname(abspath(Libdl.dlpath("libjulia-debug")))
else
private_libdir = dirname(abspath(Libdl.dlpath("libjulia")))
dirname(abspath(Libdl.dlpath("libjulia")))
end

@test !isempty(Libdl.find_library(["libccalltest"], [private_libdir]))
@test !isempty(Libdl.find_library("libccalltest", [private_libdir]))
@test !isempty(Libdl.find_library(:libccalltest, [private_libdir]))

# dlopen should be able to handle absolute and relative paths, with and without dlext
let dl = C_NULL
try
Expand Down

0 comments on commit 7e8c4a3

Please sign in to comment.