Skip to content

Commit 4402c80

Browse files
Fix static linking of libsodium in Windows launcher (#1115)
1 parent 59a339c commit 4402c80

File tree

1 file changed

+7
-24
lines changed

1 file changed

+7
-24
lines changed

project/settings.sc

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -220,35 +220,18 @@ trait CliLaunchers extends SbtModule { self =>
220220
else "lib"
221221
os.copy.over(libPath, destDir / s"${prefix}sodiumjni.$ext")
222222
}
223-
private def copyLibsodiumTo(cs: String, destDir: os.Path): Unit = {
224-
val (osPart, suffix, relPath, ext) = sys.props.get("os.arch") match {
225-
case Some("x86_64" | "amd64") =>
226-
if (Properties.isWin)
227-
("win-64", "-h62dcd97_1", os.rel / "Library" / "lib" / "libsodium.lib", "lib")
228-
else if (Properties.isLinux)
229-
("linux-64", "-h36c2ea0_1", os.rel / "lib" / "libsodium.a", "a")
230-
else if (Properties.isMac) ("osx-64", "-hbcb3906_1", os.rel / "lib" / "libsodium.a", "a")
231-
else sys.error(s"Unsupported OS for x86_64 platform: ${sys.props("os.name")}")
232-
case Some("aarch64") =>
233-
if (Properties.isLinux)
234-
("linux-aarch64", "-hb9de7d4_1", os.rel / "lib" / "libsodium.a", "a")
235-
else sys.error(s"Unsupported OS for aarch64 platform: ${sys.props("os.name")}")
236-
case Some(arch) =>
237-
sys.error(s"Unsupported architecture: $arch")
238-
case None =>
239-
sys.error("Cannot determine CPU architecture")
240-
}
223+
private def copyLibsodiumStaticTo(cs: String, destDir: os.Path): Unit = {
241224
val dirRes = os.proc(
242225
cs,
243226
"get",
244227
"--archive",
245-
s"https://anaconda.org/conda-forge/libsodium/$libsodiumVersion/download/$osPart/libsodium-$libsodiumVersion$suffix.tar.bz2"
228+
"https://download.libsodium.org/libsodium/releases/libsodium-1.0.18-stable-msvc.zip"
246229
).call()
247230
val dir = os.Path(dirRes.out.text().trim, os.pwd)
248-
val prefix =
249-
if (Properties.isWin) ""
250-
else "lib"
251-
os.copy.over(dir / relPath, destDir / s"${prefix}sodium.$ext")
231+
os.copy.over(
232+
dir / "libsodium" / "x64" / "Release" / "v143" / "static" / "libsodium.lib",
233+
destDir / "sodium.lib"
234+
)
252235
}
253236
private def copyAlpineLibsodiumTo(cs: String, destDir: os.Path): Unit = {
254237
val arcPath = os.proc(
@@ -284,7 +267,7 @@ trait CliLaunchers extends SbtModule { self =>
284267
os.makeDir.all(dir)
285268

286269
if (Properties.isWin) {
287-
copyLibsodiumTo(cs(), dir)
270+
copyLibsodiumStaticTo(cs(), dir)
288271
copyLibsodiumjniTo(cs(), dir)
289272
copyCsjniutilTo(cs(), dir)
290273
}

0 commit comments

Comments
 (0)