Skip to content

Commit 717e824

Browse files
committed
Use kotlin 2.1.0
1 parent dd6376c commit 717e824

File tree

8 files changed

+66
-49
lines changed

8 files changed

+66
-49
lines changed

build.gradle.kts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import org.gradle.internal.os.OperatingSystem
22
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
33
import org.jetbrains.dokka.Platform
4+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
45
import java.util.*
56

67
plugins {
7-
kotlin("multiplatform") version "1.9.22"
8-
id("org.jetbrains.dokka") version "1.9.10"
8+
kotlin("multiplatform") version "2.1.10"
9+
id("org.jetbrains.dokka") version "1.9.20"
910
`maven-publish`
1011
}
1112

@@ -17,7 +18,6 @@ buildscript {
1718

1819
dependencies {
1920
classpath("com.android.tools.build:gradle:8.2.2")
20-
classpath("org.jetbrains.dokka:dokka-gradle-plugin:1.9.10")
2121
}
2222
}
2323

@@ -39,8 +39,8 @@ kotlin {
3939
val commonMain by sourceSets.getting
4040

4141
jvm {
42-
compilations.all {
43-
kotlinOptions.jvmTarget = "1.8"
42+
compilerOptions {
43+
jvmTarget.set(JvmTarget.JVM_18)
4444
}
4545
}
4646

@@ -102,7 +102,11 @@ allprojects {
102102
compileTaskProvider { enabled = false }
103103
tasks[processResourcesTaskName].enabled = false
104104
}
105-
binaries.all { linkTask.enabled = false }
105+
binaries.all {
106+
linkTaskProvider.configure {
107+
enabled = false
108+
}
109+
}
106110

107111
mavenPublication {
108112
val publicationToDisable = this

gradle/wrapper/gradle-wrapper.jar

-16.9 KB
Binary file not shown.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
46
zipStoreBase=GRADLE_USER_HOME
57
zipStorePath=wrapper/dists

gradlew

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
# Darwin, MinGW, and NonStop.
5656
#
5757
# (3) This script is generated from the Groovy template
58-
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
58+
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
5959
# within the Gradle project.
6060
#
6161
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -80,13 +80,11 @@ do
8080
esac
8181
done
8282

83-
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
84-
85-
APP_NAME="Gradle"
83+
# This is normally unused
84+
# shellcheck disable=SC2034
8685
APP_BASE_NAME=${0##*/}
87-
88-
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89-
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
86+
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87+
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
9088

9189
# Use the maximum available, or set MAX_FD != -1 to use that value.
9290
MAX_FD=maximum
@@ -133,22 +131,29 @@ location of your Java installation."
133131
fi
134132
else
135133
JAVACMD=java
136-
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
134+
if ! command -v java >/dev/null 2>&1
135+
then
136+
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137137
138138
Please set the JAVA_HOME variable in your environment to match the
139139
location of your Java installation."
140+
fi
140141
fi
141142

142143
# Increase the maximum file descriptors if we can.
143144
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144145
case $MAX_FD in #(
145146
max*)
147+
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
148+
# shellcheck disable=SC2039,SC3045
146149
MAX_FD=$( ulimit -H -n ) ||
147150
warn "Could not query maximum file descriptor limit"
148151
esac
149152
case $MAX_FD in #(
150153
'' | soft) :;; #(
151154
*)
155+
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
156+
# shellcheck disable=SC2039,SC3045
152157
ulimit -n "$MAX_FD" ||
153158
warn "Could not set maximum file descriptor limit to $MAX_FD"
154159
esac
@@ -193,11 +198,15 @@ if "$cygwin" || "$msys" ; then
193198
done
194199
fi
195200

196-
# Collect all arguments for the java command;
197-
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
198-
# shell script including quotes and variable substitutions, so put them in
199-
# double quotes to make sure that they get re-expanded; and
200-
# * put everything else in single quotes, so that it's not re-expanded.
201+
202+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
203+
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
204+
205+
# Collect all arguments for the java command:
206+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
207+
# and any embedded shellness will be escaped.
208+
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
209+
# treated as '${Hostname}' itself on the command line.
201210

202211
set -- \
203212
"-Dorg.gradle.appname=$APP_BASE_NAME" \

gradlew.bat

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal
2626

2727
set DIRNAME=%~dp0
2828
if "%DIRNAME%"=="" set DIRNAME=.
29+
@rem This is normally unused
2930
set APP_BASE_NAME=%~n0
3031
set APP_HOME=%DIRNAME%
3132

@@ -42,11 +43,11 @@ set JAVA_EXE=java.exe
4243
%JAVA_EXE% -version >NUL 2>&1
4344
if %ERRORLEVEL% equ 0 goto execute
4445

45-
echo.
46-
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47-
echo.
48-
echo Please set the JAVA_HOME variable in your environment to match the
49-
echo location of your Java installation.
46+
echo. 1>&2
47+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
48+
echo. 1>&2
49+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
50+
echo location of your Java installation. 1>&2
5051

5152
goto fail
5253

@@ -56,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
5657

5758
if exist "%JAVA_EXE%" goto execute
5859

59-
echo.
60-
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61-
echo.
62-
echo Please set the JAVA_HOME variable in your environment to match the
63-
echo location of your Java installation.
60+
echo. 1>&2
61+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
62+
echo. 1>&2
63+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
64+
echo location of your Java installation. 1>&2
6465

6566
goto fail
6667

jni/c/src/fr_acinq_secp256k1_Secp256k1CFunctions.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ JNIEXPORT jbyteArray JNICALL Java_fr_acinq_secp256k1_Secp256k1CFunctions_secp256
741741
CHECKRESULT((*penv)->GetArrayLength(penv, jauxrand32) != 32, "auxiliary random data must be 32 bytes");
742742
}
743743
seckey = (*penv)->GetByteArrayElements(penv, jseckey, 0);
744-
result = secp256k1_keypair_create(ctx, &keypair, seckey);
744+
result = secp256k1_keypair_create(ctx, &keypair, (const unsigned char*)seckey);
745745
(*penv)->ReleaseByteArrayElements(penv, jseckey, seckey, 0);
746746
CHECKRESULT(!result, "secp256k1_keypair_create failed");
747747

@@ -751,7 +751,7 @@ JNIEXPORT jbyteArray JNICALL Java_fr_acinq_secp256k1_Secp256k1CFunctions_secp256
751751
auxrand32 = (*penv)->GetByteArrayElements(penv, jauxrand32, 0);
752752
}
753753

754-
result = secp256k1_schnorrsig_sign32(ctx, signature, (unsigned char *)msg, &keypair, auxrand32);
754+
result = secp256k1_schnorrsig_sign32(ctx, signature, (unsigned char *)msg, &keypair, (const unsigned char*)auxrand32);
755755
(*penv)->ReleaseByteArrayElements(penv, jmsg, msg, 0);
756756
if (auxrand32 != 0)
757757
{
@@ -930,13 +930,13 @@ JNIEXPORT jbyteArray JNICALL Java_fr_acinq_secp256k1_Secp256k1CFunctions_secp256
930930
return NULL;
931931

932932
seckey = (*penv)->GetByteArrayElements(penv, jseckey, 0);
933-
result = secp256k1_keypair_create(ctx, &keypair, seckey);
933+
result = secp256k1_keypair_create(ctx, &keypair, (const unsigned char*)seckey);
934934
(*penv)->ReleaseByteArrayElements(penv, jseckey, seckey, 0);
935935
CHECKRESULT(!result, "secp256k1_keypair_create failed");
936936

937937
size = (*penv)->GetArrayLength(penv, jseckey);
938938
CHECKRESULT(size != 32, "invalid private key size");
939-
copy_bytes_from_java(penv, jseckey, size, seckey);
939+
copy_bytes_from_java(penv, jseckey, size, (unsigned char*)seckey);
940940

941941
if (jmsg32 != NULL)
942942
{
@@ -1125,14 +1125,14 @@ JNIEXPORT jbyteArray JNICALL Java_fr_acinq_secp256k1_Secp256k1CFunctions_secp256
11251125
CHECKRESULT((*penv)->GetArrayLength(penv, jtweak32) != 32, "tweak must be 32 bytes");
11261126
tweak32 = (*penv)->GetByteArrayElements(penv, jtweak32, 0);
11271127

1128-
result = secp256k1_musig_pubkey_ec_tweak_add(ctx, &pubkey, &keyaggcache, tweak32);
1128+
result = secp256k1_musig_pubkey_ec_tweak_add(ctx, &pubkey, &keyaggcache, (const unsigned char*)tweak32);
11291129
(*penv)->ReleaseByteArrayElements(penv, jtweak32, tweak32, 0);
11301130
CHECKRESULT(!result, "secp256k1_musig_pubkey_ec_tweak_add failed");
11311131

11321132
jpubkey = (*penv)->NewByteArray(penv, 65);
11331133
pub = (*penv)->GetByteArrayElements(penv, jpubkey, 0);
11341134
size = 65;
1135-
result = secp256k1_ec_pubkey_serialize(ctx, pub, &size, &pubkey, SECP256K1_EC_UNCOMPRESSED);
1135+
result = secp256k1_ec_pubkey_serialize(ctx, (unsigned char*)pub, &size, &pubkey, SECP256K1_EC_UNCOMPRESSED);
11361136
(*penv)->ReleaseByteArrayElements(penv, jpubkey, pub, 0);
11371137
CHECKRESULT(!result, "secp256k1_ec_pubkey_serialize failed");
11381138

@@ -1170,14 +1170,14 @@ JNIEXPORT jbyteArray JNICALL Java_fr_acinq_secp256k1_Secp256k1CFunctions_secp256
11701170
CHECKRESULT((*penv)->GetArrayLength(penv, jtweak32) != 32, "tweak must be 32 bytes");
11711171
tweak32 = (*penv)->GetByteArrayElements(penv, jtweak32, 0);
11721172

1173-
result = secp256k1_musig_pubkey_xonly_tweak_add(ctx, &pubkey, &keyaggcache, tweak32);
1173+
result = secp256k1_musig_pubkey_xonly_tweak_add(ctx, &pubkey, &keyaggcache, (const unsigned char*)tweak32);
11741174
(*penv)->ReleaseByteArrayElements(penv, jtweak32, tweak32, 0);
11751175
CHECKRESULT(!result, "secp256k1_musig_pubkey_xonly_tweak_add failed");
11761176

11771177
jpubkey = (*penv)->NewByteArray(penv, 65);
11781178
pub = (*penv)->GetByteArrayElements(penv, jpubkey, 0);
11791179
size = 65;
1180-
result = secp256k1_ec_pubkey_serialize(ctx, pub, &size, &pubkey, SECP256K1_EC_UNCOMPRESSED);
1180+
result = secp256k1_ec_pubkey_serialize(ctx, (unsigned char*)pub, &size, &pubkey, SECP256K1_EC_UNCOMPRESSED);
11811181
(*penv)->ReleaseByteArrayElements(penv, jpubkey, pub, 0);
11821182
CHECKRESULT(!result, "secp256k1_ec_pubkey_serialize failed");
11831183

@@ -1218,7 +1218,7 @@ JNIEXPORT jbyteArray JNICALL Java_fr_acinq_secp256k1_Secp256k1CFunctions_secp256
12181218
CHECKRESULT((*penv)->GetArrayLength(penv, jkeyaggcache) != fr_acinq_secp256k1_Secp256k1CFunctions_SECP256K1_MUSIG_KEYAGG_CACHE_SIZE, "invalid keyagg cache size");
12191219

12201220
ptr = (*penv)->GetByteArrayElements(penv, jaggnonce, 0);
1221-
result = secp256k1_musig_aggnonce_parse(ctx, &aggnonce, ptr);
1221+
result = secp256k1_musig_aggnonce_parse(ctx, &aggnonce, (const unsigned char*)ptr);
12221222
(*penv)->ReleaseByteArrayElements(penv, jaggnonce, ptr, 0);
12231223
CHECKRESULT(!result, "secp256k1_musig_aggnonce_parse failed");
12241224

@@ -1321,17 +1321,17 @@ JNIEXPORT jint JNICALL Java_fr_acinq_secp256k1_Secp256k1CFunctions_secp256k1_1mu
13211321
CHECKRESULT((*penv)->GetArrayLength(penv, jsession) != fr_acinq_secp256k1_Secp256k1CFunctions_SECP256K1_MUSIG_SESSION_SIZE, "invalid session size");
13221322

13231323
ptr = (*penv)->GetByteArrayElements(penv, jpsig, 0);
1324-
result = secp256k1_musig_partial_sig_parse(ctx, &psig, ptr);
1324+
result = secp256k1_musig_partial_sig_parse(ctx, &psig, (const unsigned char*)ptr);
13251325
(*penv)->ReleaseByteArrayElements(penv, jpsig, ptr, 0);
13261326
CHECKRESULT(!result, "secp256k1_musig_partial_sig_parse failed");
13271327

13281328
ptr = (*penv)->GetByteArrayElements(penv, jpubnonce, 0);
1329-
result = secp256k1_musig_pubnonce_parse(ctx, &pubnonce, ptr);
1329+
result = secp256k1_musig_pubnonce_parse(ctx, &pubnonce, (const unsigned char*)ptr);
13301330
(*penv)->ReleaseByteArrayElements(penv, jpubnonce, ptr, 0);
13311331
CHECKRESULT(!result, "secp256k1_musig_pubnonce_parse failed");
13321332

13331333
ptr = (*penv)->GetByteArrayElements(penv, jpubkey, 0);
1334-
result = secp256k1_ec_pubkey_parse(ctx, &pubkey, ptr, (*penv)->GetArrayLength(penv, jpubkey));
1334+
result = secp256k1_ec_pubkey_parse(ctx, &pubkey, (const unsigned char*)ptr, (*penv)->GetArrayLength(penv, jpubkey));
13351335
(*penv)->ReleaseByteArrayElements(penv, jpubkey, ptr, 0);
13361336
CHECKRESULT(!result, "secp256k1_musig_pubkey_parse failed");
13371337

jni/jvm/src/main/kotlin/fr/acinq/secp256k1/jni/OSInfo.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ internal object OSInfo {
2626

2727
@JvmStatic val hardwareName: String get() =
2828
try {
29-
val p = Runtime.getRuntime().exec("uname -m")
29+
val p = Runtime.getRuntime().exec(arrayOf("uname", "-m"))
3030
p.waitFor()
3131
val input = p.inputStream
3232
input.use {
@@ -83,7 +83,7 @@ internal object OSInfo {
8383
val javaHome = System.getProperty("java.home")
8484
try {
8585
// determine if first JVM found uses ARM hard-float ABI
86-
var exitCode = Runtime.getRuntime().exec("which readelf").waitFor()
86+
var exitCode = Runtime.getRuntime().exec(arrayOf("which", "readelf")).waitFor()
8787
if (exitCode == 0) {
8888
val cmdarray = arrayOf(
8989
"/bin/sh", "-c", "find '" + javaHome +
@@ -119,7 +119,7 @@ internal object OSInfo {
119119
val javaHome = System.getProperty("java.home")
120120
try {
121121
// determine if first JVM found uses ARM hard-float ABI
122-
var exitCode = Runtime.getRuntime().exec("which readelf").waitFor()
122+
var exitCode = Runtime.getRuntime().exec(arrayOf("which", "readelf")).waitFor()
123123
if (exitCode == 0) {
124124
val cmdarray = arrayOf(
125125
"/bin/sh", "-c", "find '" + javaHome +

tests/build.gradle.kts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
12
import org.jetbrains.kotlin.gradle.targets.jvm.tasks.KotlinJvmTest
23
import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeHostTest
34
import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeSimulatorTest
@@ -29,8 +30,8 @@ kotlin {
2930
}
3031

3132
jvm {
32-
compilations.all {
33-
kotlinOptions.jvmTarget = "1.8"
33+
compilerOptions {
34+
jvmTarget.set(JvmTarget.JVM_18)
3435
}
3536
compilations["main"].dependencies {
3637
implementation(project(":jni:jvm:all"))
@@ -42,8 +43,8 @@ kotlin {
4243

4344
if (includeAndroid) {
4445
androidTarget {
45-
compilations.all {
46-
kotlinOptions.jvmTarget = "1.8"
46+
compilerOptions {
47+
jvmTarget.set(JvmTarget.JVM_1_8)
4748
}
4849
sourceSets["androidMain"].dependencies {
4950
implementation(project(":jni:android"))

0 commit comments

Comments
 (0)