diff --git a/crypto/build.gradle b/crypto/build.gradle index 73d2a5a..8f05595 100644 --- a/crypto/build.gradle +++ b/crypto/build.gradle @@ -14,7 +14,7 @@ task compileRust { project.logger.info("#####################" + System.getProperty("os.name").toLowerCase()) doLast { // nix build detection - if (!System.getenv('NIX_CC').empty) { + if (System.getenv('NIX_CC') != null) { exec { workingDir 'src/jni-crypto' commandLine 'cargo', 'build', '--release', '--target=aarch64-unknown-linux-gnu', '--target-dir=../../build/jni-crypto' @@ -29,11 +29,25 @@ task compileRust { environment RUSTFLAGS: "-L ${System.getenv('PTHREAD_LOCATION')}" } } else { + // keep the old build behavior while not running in nix shell + if (System.getProperty("os.name").toLowerCase().contains("linux")) { + exec { + workingDir 'src/jni-crypto' + commandLine 'cargo', 'build', '--release', '--target=x86_64-unknown-linux-gnu', '--target-dir=../../build/jni-crypto' + } + } else if (System.getProperty("os.name").toLowerCase().contains("windows")) { + exec { + workingDir 'src/jni-crypto' + commandLine 'cargo', 'build', '--release', '--target=x86_64-pc-windows-gnu', '--target-dir=../../build/jni-crypto' + } + } // Does not cover solaris, just MacOS. See potential return types here: - // https://docs.gradle.org/current/javadoc/org/gradle/nativeplatform/platform/OperatingSystem.html - exec { - workingDir 'src/jni-crypto' - commandLine 'cargo', 'build', '--release', '--target-dir=../../build/jni-crypto' + // https://docs.gradle.org/current/javadoc/org/gradle/nativeplatform/platform/OperatingSystem.html + else { + exec { + workingDir 'src/jni-crypto' + commandLine 'cargo', 'build', '--release', '--target-dir=../../build/jni-crypto' + } } } } diff --git a/crypto/src/main/java/com/strategyobject/substrateclient/crypto/sr25519/Native.java b/crypto/src/main/java/com/strategyobject/substrateclient/crypto/sr25519/Native.java index ab9be02..fae76da 100644 --- a/crypto/src/main/java/com/strategyobject/substrateclient/crypto/sr25519/Native.java +++ b/crypto/src/main/java/com/strategyobject/substrateclient/crypto/sr25519/Native.java @@ -56,7 +56,7 @@ private static String copyLibraryFromResourcesToTempDir() throws IOException { osDir = "x86_64-linux"; } else if (IS_LINUX && IS_AARCH64) { osDir = "aarch64-linux"; - } else if (IS_MAC) { // TODO 'MasOS support problem' + } else if (IS_MAC) { // TODO 'MacOS support problem' osDir = "macos"; } else { throw new RuntimeException("JNI library can't be loaded because OS wasn't detected as supported.");