Skip to content

Commit e61aa81

Browse files
committed
Enable BinDeps
1 parent 0f6202c commit e61aa81

File tree

3 files changed

+39
-4
lines changed

3 files changed

+39
-4
lines changed

REQUIRE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
julia 0.4
2+
BinDeps

deps/build.jl

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using BinDeps
2+
3+
@BinDeps.setup
4+
5+
deps = [
6+
libiconv = library_dependency("libiconv", aliases = ["libc", "iconv"],
7+
# Check whether libc provides iconv_open (as on Linux)
8+
validate = (n, h) -> Libdl.dlsym_e(h, "iconv_open") != C_NULL)
9+
]
10+
11+
@windows_only begin
12+
using WinRPM
13+
provides(WinRPM.RPM, "win_iconv", libiconv, os = :Windows)
14+
end
15+
16+
@osx_only begin
17+
if Pkg.installed("Homebrew") === nothing
18+
error("Homebrew package not installed, please run Pkg.add(\"Homebrew\")")
19+
end
20+
using Homebrew
21+
provides(Homebrew.HB, "libiconv", libiconv, os = :Darwin)
22+
end
23+
24+
provides(Sources, URI("http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz"), libiconv)
25+
26+
provides(BuildProcess, Autotools(libtarget = "lib/libiconv.la",
27+
installed_libname = "libiconv"*BinDeps.shlib_ext),
28+
libiconv,
29+
os = :Unix)
30+
31+
@BinDeps.install Dict(:libiconv => :libiconv_path)

src/iconv.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import Base: close, eof, flush, read, readall, write
55
import Base.Libc: errno, strerror
66
export StringEncoder, StringDecoder, encode, decode
77

8+
include("../deps/deps.jl")
9+
10+
811
## iconv wrappers
912

1013
const E2BIG = 7
@@ -13,13 +16,13 @@ const EILSEQ = 84
1316

1417
function iconv_close(cd::Ptr{Void})
1518
if cd != C_NULL
16-
ccall((:iconv_close, :libc), Cint, (Ptr{Void},), cd) == 0 ||
19+
ccall((:iconv_close, libiconv_path), Cint, (Ptr{Void},), cd) == 0 ||
1720
error("failed to call iconv_close: error $(errno()) ($(strerror(errno())))")
1821
end
1922
end
2023

2124
function iconv_open(tocode, fromcode)
22-
p = ccall((:iconv_open, :libc), Ptr{Void}, (Cstring, Cstring), tocode, fromcode)
25+
p = ccall((:iconv_open, libiconv_path), Ptr{Void}, (Cstring, Cstring), tocode, fromcode)
2326
if p != Ptr{Void}(-1)
2427
return p
2528
elseif errno() == EINVAL
@@ -66,7 +69,7 @@ function iconv!(cd::Ptr{Void}, inbuf::Vector{UInt8}, outbuf::Vector{UInt8},
6669
inbytesleft_orig = inbytesleft[]
6770
outbytesleft[] = BUFSIZE
6871

69-
ret = ccall((:iconv, :libc), Csize_t,
72+
ret = ccall((:iconv, libiconv_path), Csize_t,
7073
(Ptr{Void}, Ptr{Ptr{UInt8}}, Ref{Csize_t}, Ptr{Ptr{UInt8}}, Ref{Csize_t}),
7174
cd, inbufptr, inbytesleft, outbufptr, outbytesleft)
7275

@@ -98,7 +101,7 @@ function iconv_reset!(s::Union{StringEncoder, StringDecoder})
98101

99102
s.outbufptr[] = pointer(s.outbuf)
100103
s.outbytesleft[] = BUFSIZE
101-
ret = ccall((:iconv, :libc), Csize_t,
104+
ret = ccall((:iconv, libiconv_path), Csize_t,
102105
(Ptr{Void}, Ptr{Ptr{UInt8}}, Ref{Csize_t}, Ptr{Ptr{UInt8}}, Ref{Csize_t}),
103106
s.cd, C_NULL, C_NULL, s.outbufptr, s.outbytesleft)
104107

0 commit comments

Comments
 (0)