Skip to content

Commit

Permalink
libsodium
Browse files Browse the repository at this point in the history
  • Loading branch information
alexarchambault committed Jul 29, 2022
1 parent cf986f2 commit bcbb1fd
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ jobs:
UPDATE_GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SCALA_CLI_IT_FORCED_LAUNCHER_DIRECTORY: artifacts/
SCALA_CLI_IT_GROUP: 1
SCALA_CLI_SODIUM_JNI_ALLOW: false

native-linux-tests-2:
needs: generate-linux-launcher
Expand All @@ -160,6 +161,7 @@ jobs:
UPDATE_GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SCALA_CLI_IT_FORCED_LAUNCHER_DIRECTORY: artifacts/
SCALA_CLI_IT_GROUP: 2
SCALA_CLI_SODIUM_JNI_ALLOW: false

native-linux-tests-3:
needs: generate-linux-launcher
Expand All @@ -183,6 +185,7 @@ jobs:
UPDATE_GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SCALA_CLI_IT_FORCED_LAUNCHER_DIRECTORY: artifacts/
SCALA_CLI_IT_GROUP: 3
SCALA_CLI_SODIUM_JNI_ALLOW: false

generate-macos-launcher:
timeout-minutes: 120
Expand Down Expand Up @@ -232,6 +235,7 @@ jobs:
UPDATE_GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SCALA_CLI_IT_FORCED_LAUNCHER_DIRECTORY: artifacts/
SCALA_CLI_IT_GROUP: 1
SCALA_CLI_SODIUM_JNI_ALLOW: false

native-macos-tests-2:
needs: generate-macos-launcher
Expand All @@ -255,6 +259,7 @@ jobs:
UPDATE_GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SCALA_CLI_IT_FORCED_LAUNCHER_DIRECTORY: artifacts/
SCALA_CLI_IT_GROUP: 2
SCALA_CLI_SODIUM_JNI_ALLOW: false

native-macos-tests-3:
needs: generate-macos-launcher
Expand All @@ -278,6 +283,7 @@ jobs:
UPDATE_GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SCALA_CLI_IT_FORCED_LAUNCHER_DIRECTORY: artifacts/
SCALA_CLI_IT_GROUP: 3
SCALA_CLI_SODIUM_JNI_ALLOW: false

generate-windows-launcher:
timeout-minutes: 120
Expand Down Expand Up @@ -336,6 +342,7 @@ jobs:
UPDATE_GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SCALA_CLI_IT_FORCED_LAUNCHER_DIRECTORY: artifacts/
SCALA_CLI_IT_GROUP: 1
SCALA_CLI_SODIUM_JNI_ALLOW: false

native-windows-tests-2:
needs: generate-windows-launcher
Expand Down Expand Up @@ -363,6 +370,7 @@ jobs:
UPDATE_GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SCALA_CLI_IT_FORCED_LAUNCHER_DIRECTORY: artifacts/
SCALA_CLI_IT_GROUP: 2
SCALA_CLI_SODIUM_JNI_ALLOW: false

native-windows-tests-3:
needs: generate-windows-launcher
Expand Down Expand Up @@ -390,6 +398,7 @@ jobs:
UPDATE_GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SCALA_CLI_IT_FORCED_LAUNCHER_DIRECTORY: artifacts/
SCALA_CLI_IT_GROUP: 3
SCALA_CLI_SODIUM_JNI_ALLOW: false

generate-mostly-static-launcher:
timeout-minutes: 120
Expand Down Expand Up @@ -438,6 +447,7 @@ jobs:
UPDATE_GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SCALA_CLI_IT_FORCED_LAUNCHER_DIRECTORY: artifacts/
SCALA_CLI_IT_GROUP: 1
SCALA_CLI_SODIUM_JNI_ALLOW: false
- name: Docker integration tests
run: ./mill integration.docker-slim.test
- name: Login to GitHub Container Registry
Expand Down Expand Up @@ -472,6 +482,7 @@ jobs:
UPDATE_GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SCALA_CLI_IT_FORCED_LAUNCHER_DIRECTORY: artifacts/
SCALA_CLI_IT_GROUP: 2
SCALA_CLI_SODIUM_JNI_ALLOW: false

native-mostly-static-tests-3:
needs: generate-mostly-static-launcher
Expand All @@ -495,6 +506,7 @@ jobs:
UPDATE_GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SCALA_CLI_IT_FORCED_LAUNCHER_DIRECTORY: artifacts/
SCALA_CLI_IT_GROUP: 3
SCALA_CLI_SODIUM_JNI_ALLOW: false

generate-static-launcher:
timeout-minutes: 120
Expand Down Expand Up @@ -543,6 +555,7 @@ jobs:
UPDATE_GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SCALA_CLI_IT_FORCED_LAUNCHER_DIRECTORY: artifacts/
SCALA_CLI_IT_GROUP: 1
SCALA_CLI_SODIUM_JNI_ALLOW: false
- name: Docker integration tests
run: ./mill integration.docker.test
- name: Login to GitHub Container Registry
Expand Down Expand Up @@ -579,6 +592,7 @@ jobs:
UPDATE_GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SCALA_CLI_IT_FORCED_LAUNCHER_DIRECTORY: artifacts/
SCALA_CLI_IT_GROUP: 2
SCALA_CLI_SODIUM_JNI_ALLOW: false

native-static-tests-3:
needs: generate-static-launcher
Expand All @@ -604,6 +618,7 @@ jobs:
UPDATE_GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SCALA_CLI_IT_FORCED_LAUNCHER_DIRECTORY: artifacts/
SCALA_CLI_IT_GROUP: 3
SCALA_CLI_SODIUM_JNI_ALLOW: false

docs-tests:
# for now, lets run those tests only on ubuntu
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import coursier.util.Task

import java.io.InputStream
import java.nio.charset.StandardCharsets
import java.util.Locale

import scala.build.EitherCps.{either, value}
import scala.build.Logger
Expand Down Expand Up @@ -116,7 +117,7 @@ object LibSodiumJni {

if (!allStaticallyLinked) {
val (archiveUrl, pathInArchive) = archiveUrlAndPath()
val sodiumLib = value {
val sodiumLibOpt = value {
FetchExternalBinary.fetchLauncher(
archiveUrl,
changing = false,
Expand All @@ -130,11 +131,28 @@ object LibSodiumJni {

val f = jniLibArtifact(cache)

System.load(sodiumLib.toString)
sodiumLibOpt match {
case Some(sodiumLib) =>
System.load(sodiumLib.toString)
case None =>
val allow = Option(System.getenv("SCALA_CLI_SODIUM_JNI_ALLOW"))
.map(_.toLowerCase(Locale.ROOT))
.forall {
case "false" | "0" => false
case _ => true
}
if (allow)
System.loadLibrary("sodium")
else
value(Left(new LibSodiumNotFound(archiveUrl)))
}

libsodiumjni.internal.LoadLibrary.initialize(f.toString)
}

libsodiumjni.Sodium.init()
}

final class LibSodiumNotFound(url: String) extends BuildException(s"libsodium: $url not found")

}

0 comments on commit bcbb1fd

Please sign in to comment.