Skip to content

Commit f0ce5cd

Browse files
committed
Fix BinDeps on Windows
Also clean the code.
1 parent 9c02952 commit f0ce5cd

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

deps/build.jl

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ using BinDeps
22

33
@BinDeps.setup
44

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-
]
5+
libiconv = library_dependency("libiconv", aliases = ["libc", "iconv"],
6+
# Check whether libc provides iconv_open (as on Linux)
7+
validate = (n, h) -> Libdl.dlsym_e(h, "iconv_open") != C_NULL)
108

119
@windows_only begin
1210
using WinRPM
@@ -20,9 +18,10 @@ end
2018

2119
provides(Sources, URI("http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz"), libiconv)
2220

23-
provides(BuildProcess, Autotools(libtarget = "lib/libiconv.la",
24-
installed_libname = "libiconv"*BinDeps.shlib_ext),
21+
provides(BuildProcess,
22+
Autotools(libtarget = "lib/libiconv.la",
23+
installed_libname = "libiconv"*BinDeps.shlib_ext),
2524
libiconv,
2625
os = :Unix)
2726

28-
@BinDeps.install Dict(:libiconv => :libiconv_path)
27+
@BinDeps.install

src/iconv.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ 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")
8+
depsjl = joinpath(dirname(@__FILE__), "..", "deps", "deps.jl")
9+
isfile(depsjl) ? include(depsjl) : error("libiconv not properly installed. Please run\nPkg.build(\"iconv\")")
910

1011

1112
## iconv wrappers
@@ -16,13 +17,13 @@ const EILSEQ = 84
1617

1718
function iconv_close(cd::Ptr{Void})
1819
if cd != C_NULL
19-
ccall((:iconv_close, libiconv_path), Cint, (Ptr{Void},), cd) == 0 ||
20+
ccall((:iconv_close, libiconv), Cint, (Ptr{Void},), cd) == 0 ||
2021
error("failed to call iconv_close: error $(errno()) ($(strerror(errno())))")
2122
end
2223
end
2324

2425
function iconv_open(tocode, fromcode)
25-
p = ccall((:iconv_open, libiconv_path), Ptr{Void}, (Cstring, Cstring), tocode, fromcode)
26+
p = ccall((:iconv_open, libiconv), Ptr{Void}, (Cstring, Cstring), tocode, fromcode)
2627
if p != Ptr{Void}(-1)
2728
return p
2829
elseif errno() == EINVAL
@@ -69,7 +70,7 @@ function iconv!(cd::Ptr{Void}, inbuf::Vector{UInt8}, outbuf::Vector{UInt8},
6970
inbytesleft_orig = inbytesleft[]
7071
outbytesleft[] = BUFSIZE
7172

72-
ret = ccall((:iconv, libiconv_path), Csize_t,
73+
ret = ccall((:iconv, libiconv), Csize_t,
7374
(Ptr{Void}, Ptr{Ptr{UInt8}}, Ref{Csize_t}, Ptr{Ptr{UInt8}}, Ref{Csize_t}),
7475
cd, inbufptr, inbytesleft, outbufptr, outbytesleft)
7576

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

102103
s.outbufptr[] = pointer(s.outbuf)
103104
s.outbytesleft[] = BUFSIZE
104-
ret = ccall((:iconv, libiconv_path), Csize_t,
105+
ret = ccall((:iconv, libiconv), Csize_t,
105106
(Ptr{Void}, Ptr{Ptr{UInt8}}, Ref{Csize_t}, Ptr{Ptr{UInt8}}, Ref{Csize_t}),
106107
s.cd, C_NULL, C_NULL, s.outbufptr, s.outbytesleft)
107108

0 commit comments

Comments
 (0)