Skip to content

Commit dd1c006

Browse files
test JLL deps on Windows
1 parent 5488386 commit dd1c006

File tree

1 file changed

+55
-1
lines changed

1 file changed

+55
-1
lines changed

test/stdlib_dependencies.jl

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,53 @@ function get_deps_readelf(lib_path::String)
117117
return libs
118118
end
119119

120+
function get_deps_dumpbin(lib_path::String)
121+
# Use dumpbin to get the imports from a Windows DLL
122+
libs = split(readchomp(`dumpbin /imports $(lib_path)`), "\n")
123+
libs = filter(contains("dll"), libs)
124+
libs = map(libs) do lib
125+
m = match(r"\s+(\S+\.dll)$"i, lib)
126+
if m !== nothing
127+
return lowercase(m.captures[1])
128+
end
129+
return ""
130+
end
131+
libs = filter(!isempty, strip.(libs))
132+
libs = strip_soversion_windows.(libs)
133+
# Remove self-reference
134+
self_lib = strip_soversion_windows(lowercase(basename(lib_path)))
135+
libs = filter(!=(self_lib), libs)
136+
return libs
137+
end
120138

139+
function is_system_lib_windows(lib)
140+
system_libs = [
141+
"kernel32",
142+
"user32",
143+
"gdi32",
144+
"advapi32",
145+
"ole32",
146+
"oleaut32",
147+
"shell32",
148+
"ws2_32",
149+
"comdlg32",
150+
"shlwapi",
151+
"rpcrt4",
152+
"msvcrt",
153+
"comctl32",
154+
"ucrtbase",
155+
"vcruntime140",
156+
"msvcp140"
157+
]
158+
return any(syslib -> lowercase(lib) == syslib, system_libs)
159+
end
160+
161+
throw_no_test = true
121162
skip = false
122-
# On linux, we need `readelf` available, otherwise we refuse to attempt this
163+
# Check for required tools based on platform
123164
if Sys.islinux() || Sys.isfreebsd()
124165
if Sys.which("readelf") === nothing
166+
throw_no_test && error("`readelf` is required to run `stdlib_dependencies.jl` on Linux or FreeBSD.")
125167
@debug("Silently skipping stdlib_dependencies.jl as `readelf` not available.")
126168
skip = true
127169
end
@@ -131,13 +173,25 @@ if Sys.islinux() || Sys.isfreebsd()
131173
elseif Sys.isapple()
132174
# On macOS, we need `otool` available
133175
if Sys.which("otool") === nothing
176+
throw_no_test && error("`otool` is required to run `stdlib_dependencies.jl` on macOS.")
134177
@debug("Silently skipping stdlib_dependencies.jl as `otool` not available.")
135178
skip = true
136179
end
137180
get_deps = get_deps_otool
138181
strip_soversion = strip_soversion_macos
139182
is_system_lib = is_system_lib_macos
183+
elseif Sys.iswindows()
184+
# On Windows, we need `dumpbin` available
185+
if Sys.which("dumpbin") === nothing
186+
throw_no_test && error("`dumpbin` is required to run `stdlib_dependencies.jl` on Windows.")
187+
@debug("Silently skipping stdlib_dependencies.jl as `dumpbin` not available.")
188+
skip = true
189+
end
190+
get_deps = get_deps_dumpbin
191+
strip_soversion = strip_soversion_windows
192+
is_system_lib = is_system_lib_windows
140193
else
194+
throw_no_test && error("Unsupported platform for `stdlib_dependencies.jl`. Only Linux, FreeBSD, macOS, and Windows are supported.")
141195
@debug("Don't know how to run `stdlib_dependencies.jl` on this platform")
142196
skip = true
143197
end

0 commit comments

Comments
 (0)