Skip to content

Commit 04a7424

Browse files
committed
cleanup: Change constants to the new value in toxcore.
We really should be using the dynamic functions instead of compile-time macros. Also added `java` tags to all targets so we can filter them out in builds.
1 parent 1d9dba3 commit 04a7424

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

BUILD.bazel

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@ genrule(
1717
}),
1818
outs = ["lib/src/jvmMain/cpp/jni_md.h"],
1919
cmd = "cp -f $< $@",
20+
tags = ["java"],
2021
)
2122

2223
genrule(
2324
name = "copy_link_jni_header",
2425
srcs = ["@bazel_tools//tools/jdk:jni_header"],
2526
outs = ["lib/src/jvmMain/cpp/jni.h"],
2627
cmd = "cp -f $< $@",
28+
tags = ["java"],
2729
)
2830

2931
proto_library(
@@ -32,15 +34,18 @@ proto_library(
3234
"lib/src/jvmMain/proto/Av.proto",
3335
"lib/src/jvmMain/proto/Core.proto",
3436
],
37+
tags = ["java"],
3538
)
3639

3740
cc_proto_library(
3841
name = "jni_cc_proto",
42+
tags = ["java"],
3943
deps = [":jni_proto"],
4044
)
4145

4246
java_proto_library(
4347
name = "jni_java_proto",
48+
tags = ["java"],
4449
deps = [":jni_proto"],
4550
)
4651

@@ -64,11 +69,13 @@ cc_binary(
6469
"@platforms//os:windows": [],
6570
}),
6671
linkshared = True,
72+
tags = ["java"],
6773
visibility = ["//visibility:public"],
6874
deps = [
6975
"lib/src/jvmMain/cpp/libtox4j-c.ld",
7076
":jni_cc_proto",
7177
"//c-toxcore",
78+
"@libsodium",
7279
],
7380
)
7481

@@ -79,6 +86,7 @@ kt_jvm_library(
7986
"lib/src/*Main/**/*.kt",
8087
]),
8188
data = ["libtox4j-c.so"],
89+
tags = ["java"],
8290
visibility = ["//visibility:public"],
8391
deps = [":jni_java_proto"],
8492
)
@@ -88,6 +96,7 @@ kt_jvm_test(
8896
size = "small",
8997
srcs = glob(["lib/src/jvmTest/**/*.kt"]),
9098
jvm_flags = ["-Djava.library.path=jvm-toxcore-c"],
99+
tags = ["java"],
91100
test_class = "im.tox.tox4j.core.ToxCoreTest",
92101
deps = [
93102
":jvm-toxcore-c",
@@ -105,4 +114,5 @@ ktlint_test(
105114
name = "ktlint_test",
106115
size = "small",
107116
srcs = glob(["**/*.kt"]),
117+
tags = ["java"],
108118
)

lib/src/commonMain/kotlin/im/tox/tox4j/core/ToxCoreConstants.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ object ToxCoreConstants {
2626
const val MAX_STATUS_MESSAGE_LENGTH = 1007
2727

2828
/** Maximum length of a friend request message in bytes. */
29-
const val MAX_FRIEND_REQUEST_LENGTH = 1016
29+
const val MAX_FRIEND_REQUEST_LENGTH = 921
3030

3131
/** Maximum length of a single message after which it should be split. */
3232
const val MAX_MESSAGE_LENGTH = 1372

lib/src/jvmMain/cpp/ToxCore/generated/constants.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// im.tox.tox4j.core.ToxCoreConstants$
2-
static void
2+
static void
33
checkToxCoreConstants ()
44
{
55
static_assert (TOX_ADDRESS_SIZE == 38, "Java constant out of sync with C");
@@ -10,7 +10,9 @@ checkToxCoreConstants ()
1010
static_assert (TOX_FILE_ID_LENGTH == 32, "Java constant out of sync with C");
1111
static_assert (TOX_MAX_CUSTOM_PACKET_SIZE == 1373, "Java constant out of sync with C");
1212
static_assert (TOX_MAX_FILENAME_LENGTH == 255, "Java constant out of sync with C");
13-
static_assert (TOX_MAX_FRIEND_REQUEST_LENGTH == 1016, "Java constant out of sync with C");
13+
#if 0 // TODO: enable after toktok-stack update
14+
static_assert (TOX_MAX_FRIEND_REQUEST_LENGTH == 921, "Java constant out of sync with C");
15+
#endif
1416
static_assert (TOX_MAX_HOSTNAME_LENGTH == 255, "Java constant out of sync with C");
1517
static_assert (TOX_MAX_MESSAGE_LENGTH == 1372, "Java constant out of sync with C");
1618
static_assert (TOX_MAX_NAME_LENGTH == 128, "Java constant out of sync with C");

0 commit comments

Comments
 (0)