Skip to content

Commit 796a860

Browse files
copy libzstd over for trimming tests
comment-out bad ccall with a fixme Revert "comment-out bad ccall with a fixme" This reverts commit 6fc66a2. Revert "copy libzstd over for trimming tests" This reverts commit dc4c2dc. vendor the old Zstd_jll
1 parent 1dc3c50 commit 796a860

File tree

5 files changed

+100
-2
lines changed

5 files changed

+100
-2
lines changed

test/trimming/Project.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[deps]
22
JLLWrappers = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210"
33
Zstd_jll = "3161d3a3-bdf6-5164-811a-617609db77b4"
4+
5+
[sources]
6+
Zstd_jll = {path = "Zstd_jll"}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name = "Zstd_jll"
2+
uuid = "3161d3a3-bdf6-5164-811a-617609db77b4"
3+
version = "1.5.7+1"
4+
5+
[deps]
6+
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
7+
8+
[compat]
9+
julia = "1.6"
10+
11+
[extras]
12+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
13+
14+
[targets]
15+
test = ["Test"]
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# This file is a part of Julia. License is MIT: https://julialang.org/license
2+
3+
## dummy stub for https://github.com/JuliaBinaryWrappers/Zstd_jll.j:
4+
#
5+
baremodule Zstd_jll
6+
using Base, Libdl
7+
8+
export libzstd, zstd, zstdmt
9+
10+
# These get calculated in __init__()
11+
libzstd_handle::Ptr{Cvoid} = C_NULL
12+
13+
if Sys.iswindows()
14+
const libzstd = "libzstd-1.dll"
15+
elseif Sys.isapple()
16+
const libzstd = "@rpath/libzstd.1.dylib"
17+
else
18+
const libzstd = "libzstd.so.1"
19+
end
20+
21+
if Sys.iswindows()
22+
const zstd_exe = "zstd.exe"
23+
const zstdmt_exe = "zstdmt.exe"
24+
else
25+
const zstd_exe = "zstd"
26+
const zstdmt_exe = "zstdmt"
27+
end
28+
29+
if Sys.iswindows()
30+
const pathsep = ';'
31+
elseif Sys.isapple()
32+
const pathsep = ':'
33+
else
34+
const pathsep = ':'
35+
end
36+
37+
if Sys.iswindows()
38+
function adjust_ENV(cmd::Cmd)
39+
dllPATH = Sys.BINDIR
40+
oldPATH = get(ENV, "PATH", "")
41+
newPATH = isempty(oldPATH) ? dllPATH : "$dllPATH$pathsep$oldPATH"
42+
return addenv(cmd, "PATH"=>newPATH)
43+
end
44+
else
45+
adjust_ENV(cmd::Cmd) = cmd
46+
end
47+
48+
function adjust_ENV()
49+
addPATH = joinpath(Sys.BINDIR, Base.PRIVATE_LIBEXECDIR)
50+
oldPATH = get(ENV, "PATH", "")
51+
newPATH = isempty(oldPATH) ? addPATH : "$addPATH$pathsep$oldPATH"
52+
return ("PATH"=>newPATH,)
53+
end
54+
55+
function zstd(f::Function; adjust_PATH::Bool = true, adjust_LIBPATH::Bool = true) # deprecated, for compat only
56+
withenv((adjust_PATH ? adjust_ENV() : ())...) do
57+
f(zstd())
58+
end
59+
end
60+
function zstdmt(f::Function; adjust_PATH::Bool = true, adjust_LIBPATH::Bool = true) # deprecated, for compat only
61+
withenv((adjust_PATH ? adjust_ENV() : ())...) do
62+
f(zstdmt())
63+
end
64+
end
65+
zstd() = adjust_ENV(`$(joinpath(Sys.BINDIR, Base.PRIVATE_LIBEXECDIR, zstd_exe))`)
66+
zstdmt() = adjust_ENV(`$(joinpath(Sys.BINDIR, Base.PRIVATE_LIBEXECDIR, zstdmt_exe))`)
67+
68+
function __init__()
69+
global libzstd_handle = dlopen(libzstd)
70+
nothing
71+
end
72+
73+
end # module Zstd_jll
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This file is a part of Julia. License is MIT: https://julialang.org/license
2+
3+
using Test, Zstd_jll
4+
5+
@testset "Zstd_jll" begin
6+
@test ccall((:ZSTD_versionNumber, libzstd), Cuint, ()) == 1_05_07
7+
end

test/trimming/basic_jll.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
using Libdl
2-
using Zstd_jll
2+
using Zstd_jll # Note this uses the vendored older non-LazyLibrary version of Zstd_jll
33

44
function @main(args::Vector{String})::Cint
55
println(Core.stdout, "Julia! Hello, world!")
6-
fptr = dlsym(Zstd_jll.libzstd, :ZSTD_versionString)
6+
fptr = dlsym(Zstd_jll.libzstd_handle, :ZSTD_versionString)
77
println(Core.stdout, unsafe_string(ccall(fptr, Cstring, ())))
88
println(Core.stdout, unsafe_string(ccall((:ZSTD_versionString, libzstd), Cstring, ())))
99
return 0

0 commit comments

Comments
 (0)