Skip to content

Commit 40764e2

Browse files
authored
Merge pull request #134 from TheBlueMatt/main
0.0.115.1
2 parents 01303b3 + afbe520 commit 40764e2

File tree

91 files changed

+582
-330
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+582
-330
lines changed

.github/workflows/build.yml

Lines changed: 160 additions & 58 deletions
Large diffs are not rendered by default.

gen_type_mapping.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ def _do_map_type_with_info(self, ty_info, print_void, ret_arr_len, is_free, hold
393393
if holds_ref:
394394
base_conv += "\n" + ty_info.var_name + "_conv = " + ty_info.rust_obj.replace("LDK", "") + "_clone(&" + ty_info.var_name + "_conv);"
395395
else:
396-
from_hu_conv = (ty_info.var_name + " == null ? " + self.consts.native_zero_ptr + " : " + ty_info.var_name + ".clone_ptr()", "")
396+
from_hu_conv = (ty_info.var_name + ".clone_ptr()", "")
397397
base_conv += "\n" + "FREE(untag_ptr(" + ty_info.var_name + "));"
398398
else:
399399
base_conv = base_conv + self.consts.trait_struct_inc_refcnt(ty_info)
@@ -402,7 +402,7 @@ def _do_map_type_with_info(self, ty_info, print_void, ret_arr_len, is_free, hold
402402
else:
403403
base_conv = base_conv + "\n" + "FREE(untag_ptr(" + ty_info.var_name + "));"
404404
if from_hu_conv is None:
405-
from_hu_conv = (ty_info.var_name + " == null ? " + self.consts.native_zero_ptr + " : " + self.consts.get_ptr(ty_info.var_name), "")
405+
from_hu_conv = (self.consts.get_ptr(ty_info.var_name), "")
406406
from_hu_conv = (from_hu_conv[0], self.consts.add_ref("this", ty_info.var_name))
407407
return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name,
408408
arg_conv = base_conv, arg_conv_name = ty_info.var_name + "_conv", arg_conv_cleanup = None,
@@ -553,6 +553,7 @@ def _do_map_type_with_info(self, ty_info, print_void, ret_arr_len, is_free, hold
553553
arg_conv += "if (ptr_is_owned(" + ty_info.var_name + ")) { CHECK_ACCESS(" + ty_info.var_name + "_ptr); }\n"
554554
arg_conv += ty_info.rust_obj + "* " + ty_info.var_name + "_conv = (" + ty_info.rust_obj + "*)" + ty_info.var_name + "_ptr;"
555555
arg_conv_name = ty_info.var_name + "_conv"
556+
from_hu_conv_pfx = self.consts.get_ptr(ty_info.var_name)
556557
else:
557558
# We map Option<Trait> as *mut Trait, which we can differentiate from &Trait by the NONNULL_PTR annotation.
558559
# We handle the Option<Trait> case here.
@@ -567,23 +568,22 @@ def _do_map_type_with_info(self, ty_info, print_void, ret_arr_len, is_free, hold
567568
arg_conv += "\t*" + ty_info.var_name + "_conv_ptr = " + ty_info.var_name + "_conv;\n"
568569
arg_conv += "}"
569570
arg_conv_name = ty_info.var_name + "_conv_ptr"
571+
from_hu_conv_pfx = ty_info.var_name + " == null ? " + self.consts.native_zero_ptr + " : " + self.consts.get_ptr(ty_info.var_name)
570572
if ty_info.rust_obj.replace("LDK", "") + "_clone" in self.clone_fns:
571573
return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name,
572574
arg_conv = arg_conv, arg_conv_name = arg_conv_name, arg_conv_cleanup = None,
573575
ret_conv = (ty_info.rust_obj + " *" + ty_info.var_name + "_clone = MALLOC(sizeof(" + ty_info.rust_obj + "), \"" + ty_info.rust_obj + "\");\n" +
574576
"*" + ty_info.var_name + "_clone = " + ty_info.rust_obj.replace("LDK", "") + "_clone(", ");"),
575577
ret_conv_name = "tag_ptr(" + ty_info.var_name + "_clone, true)",
576578
to_hu_conv = self.consts.var_decl_statement(ty_info.java_hu_ty, "ret_hu_conv", "new " + ty_info.java_hu_ty + "(null, " + ty_info.var_name + ")") + ";\n" + self.consts.add_ref("ret_hu_conv", "this") + ";",
577-
to_hu_conv_name = "ret_hu_conv",
578-
from_hu_conv = (ty_info.var_name + " == null ? " + self.consts.native_zero_ptr + " : " + self.consts.get_ptr(ty_info.var_name), ""))
579+
to_hu_conv_name = "ret_hu_conv", from_hu_conv = (from_hu_conv_pfx, ""))
579580
else:
580581
return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name,
581582
arg_conv = arg_conv, arg_conv_name = arg_conv_name, arg_conv_cleanup = None,
582583
ret_conv = ("// WARNING: This object doesn't live past this scope, needs clone!\n" + self.consts.ptr_c_ty + " ret_" + ty_info.var_name + " = tag_ptr(", ", false);"),
583584
ret_conv_name = "ret_" + ty_info.var_name,
584585
to_hu_conv = self.consts.var_decl_statement(ty_info.java_hu_ty, "ret_hu_conv", "new " + ty_info.java_hu_ty + "(null, " + ty_info.var_name + ")") + ";\n" + self.consts.add_ref("ret_hu_conv", "this") + ";",
585-
to_hu_conv_name = "ret_hu_conv",
586-
from_hu_conv = (ty_info.var_name + " == null ? " + self.consts.native_zero_ptr + " : " + self.consts.get_ptr(ty_info.var_name), self.consts.add_ref("this", ty_info.var_name)))
586+
to_hu_conv_name = "ret_hu_conv", from_hu_conv = (from_hu_conv_pfx, self.consts.add_ref("this", ty_info.var_name)))
587587
ret_conv = (self.consts.ptr_c_ty + " ret_" + ty_info.var_name + " = tag_ptr(", ", true);")
588588
if holds_ref:
589589
ret_conv = (ret_conv[0], ", false);")

genbindings.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env python3
22
import os, sys, re, subprocess
33

4-
if len(sys.argv) < 7:
5-
print("USAGE: /path/to/lightning.h /path/to/bindings/output /path/to/bindings/ /path/to/bindings/output.c debug lang")
4+
if len(sys.argv) < 8:
5+
print("USAGE: /path/to/lightning.h /path/to/bindings/output /path/to/bindings/ /path/to/bindings/output.c debug lang target-tuple")
66
sys.exit(1)
77

88
if sys.argv[5] == "false":
@@ -20,6 +20,8 @@
2020
target = java_strings.Target.JAVA
2121
if sys.argv[6] == "android":
2222
target = java_strings.Target.ANDROID
23+
if "apple" in sys.argv[8]:
24+
target = java_strings.Target.MACOS
2325
elif sys.argv[6] == "typescript":
2426
import typescript_strings
2527
from typescript_strings import Consts
@@ -38,7 +40,6 @@
3840
print("Only java, typescript, python, or c_sharp can be set for lang")
3941
sys.exit(1)
4042

41-
4243
consts = Consts(DEBUG, target=target, outdir=sys.argv[4])
4344

4445
local_git_version = os.getenv("LDK_GARBAGECOLLECTED_GIT_OVERRIDE")

genbindings.sh

Lines changed: 56 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,47 @@ function is_gnu_sed(){
2020
sed --version >/dev/null 2>&1
2121
}
2222

23-
if [ "$CC" != "" ]; then
24-
COMMON_COMPILE="$CC -std=c11 -Wall -Wextra -Wno-unused-parameter -Wno-ignored-qualifiers -Wno-unused-function -Wno-nullability-completeness -Wno-pointer-sign -Wdate-time -ffile-prefix-map=$(pwd)="
25-
else
23+
if [ "$CC" = "" ]; then
2624
CC=clang
27-
COMMON_COMPILE="clang -std=c11 -Wall -Wextra -Wno-unused-parameter -Wno-ignored-qualifiers -Wno-unused-function -Wno-nullability-completeness -Wno-pointer-sign -Wdate-time -ffile-prefix-map=$(pwd)="
2825
fi
2926

27+
TARGET_STRING="$LDK_TARGET"
28+
if [ "$TARGET_STRING" = "" ]; then
29+
# We assume clang-style $CC --version here, but worst-case we just get an empty suffix
30+
TARGET_STRING="$($CC --version | grep Target | awk '{ print $2 }')"
31+
fi
32+
33+
IS_MAC=false
34+
[ "$($CC --version | grep apple-darwin)" != "" ] && IS_MAC=true
35+
IS_APPLE_CLANG=false
36+
[ "$($CC --version | grep "Apple clang version")" != "" ] && IS_APPLE_CLANG=true
37+
38+
case "$TARGET_STRING" in
39+
"x86_64-pc-linux"*)
40+
LDK_TARGET_SUFFIX="_Linux-amd64"
41+
LDK_JAR_TARGET=true
42+
;;
43+
"x86_64-apple-darwin"*)
44+
LDK_TARGET_SUFFIX="_MacOSX-x86_64"
45+
LDK_JAR_TARGET=true
46+
IS_MAC=true
47+
;;
48+
"aarch64-apple-darwin"*)
49+
LDK_TARGET_CPU="apple-a14"
50+
LDK_TARGET_SUFFIX="_MacOSX-aarch64"
51+
LDK_JAR_TARGET=true
52+
IS_MAC=true
53+
;;
54+
*)
55+
LDK_TARGET_SUFFIX="_${TARGET_STRING}"
56+
esac
57+
if [ "$LDK_TARGET_CPU" = "" ]; then
58+
LDK_TARGET_CPU="sandybridge"
59+
fi
60+
61+
COMMON_COMPILE="$CC -std=c11 -Wall -Wextra -Wno-unused-parameter -Wno-ignored-qualifiers -Wno-unused-function -Wno-nullability-completeness -Wno-pointer-sign -Wdate-time -ffile-prefix-map=$(pwd)="
62+
[ "$IS_MAC" = "true" -a "$2" != "wasm" ] && COMMON_COMPILE="$COMMON_COMPILE --target=$TARGET_STRING -mcpu=$LDK_TARGET_CPU"
63+
3064
DEBUG_ARG="$3"
3165
if [ "$3" = "leaks" ]; then
3266
DEBUG_ARG="true"
@@ -50,36 +84,10 @@ fi
5084

5185

5286
if [ "$2" = "c_sharp" ]; then
53-
TARGET_STRING="$LDK_TARGET"
54-
if [ "$TARGET_STRING" = "" ]; then
55-
# We assume clang-style $CC --version here, but worst-case we just get an empty suffix
56-
TARGET_STRING="$($CC --version | grep Target | awk '{ print $2 }')"
57-
fi
58-
case "$TARGET_STRING" in
59-
"x86_64-pc-linux"*)
60-
LDK_TARGET_SUFFIX="_Linux-amd64"
61-
LDK_JAR_TARGET=true
62-
;;
63-
"x86_64-apple-darwin"*)
64-
LDK_TARGET_SUFFIX="_MacOSX-x86_64"
65-
LDK_JAR_TARGET=true
66-
;;
67-
"aarch64-apple-darwin"*)
68-
LDK_TARGET_CPU="apple-a14"
69-
LDK_TARGET_SUFFIX="_MacOSX-aarch64"
70-
LDK_JAR_TARGET=true
71-
;;
72-
*)
73-
LDK_TARGET_SUFFIX="_${TARGET_STRING}"
74-
esac
75-
if [ "$LDK_TARGET_CPU" = "" ]; then
76-
LDK_TARGET_CPU="sandybridge"
77-
fi
78-
7987
echo "Creating C# bindings..."
8088
mkdir -p c_sharp/src/org/ldk/{enums,structs,impl}
8189
rm -f c_sharp/src/org/ldk/{enums,structs,impl}/*.cs
82-
./genbindings.py "./lightning.h" c_sharp/src/org/ldk/impl c_sharp/src/org/ldk c_sharp/ $DEBUG_ARG c_sharp $4
90+
./genbindings.py "./lightning.h" c_sharp/src/org/ldk/impl c_sharp/src/org/ldk c_sharp/ $DEBUG_ARG c_sharp $4 $TARGET_STRING
8391
rm -f c_sharp/bindings.c
8492
if [ "$3" = "true" ]; then
8593
echo "#define LDK_DEBUG_BUILD" > c_sharp/bindings.c
@@ -108,7 +116,7 @@ if [ "$2" = "c_sharp" ]; then
108116
mv ./-out:csharpldk.dll csharpldk.dll # Mono is braindead, apparently
109117

110118
echo "Building C# bindings..."
111-
COMPILE="$COMMON_COMPILE -mcpu=$LDK_TARGET_CPU -Isrc/main/jni -pthread -fPIC"
119+
COMPILE="$COMMON_COMPILE -Isrc/main/jni -pthread -fPIC"
112120
LINK="-ldl -shared"
113121
[ "$IS_MAC" = "false" ] && LINK="$LINK -Wl,--no-undefined"
114122
[ "$IS_MAC" = "true" ] && COMPILE="$COMPILE -mmacosx-version-min=10.9"
@@ -122,39 +130,13 @@ if [ "$2" = "c_sharp" ]; then
122130
else
123131
$COMPILE -o bindings.o -c -flto -O3 -I"$1"/lightning-c-bindings/include/ $2 c_sharp/bindings.c
124132
$COMPILE $LINK -o liblightningjni_release$LDK_TARGET_SUFFIX.so -flto -O3 -Wl,--lto-O3 -Wl,-O3 -Wl,--version-script=c_sharp/libcode.version -I"$1"/lightning-c-bindings/include/ $2 bindings.o "$1"/lightning-c-bindings/target/$LDK_TARGET/release/libldk.a -lm
125-
llvm-strip liblightningjni_release$LDK_TARGET_SUFFIX.so
133+
[ "$IS_APPLE_CLANG" != "true" ] && llvm-strip liblightningjni_release$LDK_TARGET_SUFFIX.so
126134
fi
127135
elif [ "$2" = "python" ]; then
128-
TARGET_STRING="$LDK_TARGET"
129-
if [ "$TARGET_STRING" = "" ]; then
130-
# We assume clang-style $CC --version here, but worst-case we just get an empty suffix
131-
TARGET_STRING="$($CC --version | grep Target | awk '{ print $2 }')"
132-
fi
133-
case "$TARGET_STRING" in
134-
"x86_64-pc-linux"*)
135-
LDK_TARGET_SUFFIX="_Linux-amd64"
136-
LDK_JAR_TARGET=true
137-
;;
138-
"x86_64-apple-darwin"*)
139-
LDK_TARGET_SUFFIX="_MacOSX-x86_64"
140-
LDK_JAR_TARGET=true
141-
;;
142-
"aarch64-apple-darwin"*)
143-
LDK_TARGET_CPU="apple-a14"
144-
LDK_TARGET_SUFFIX="_MacOSX-aarch64"
145-
LDK_JAR_TARGET=true
146-
;;
147-
*)
148-
LDK_TARGET_SUFFIX="_${TARGET_STRING}"
149-
esac
150-
if [ "$LDK_TARGET_CPU" = "" ]; then
151-
LDK_TARGET_CPU="sandybridge"
152-
fi
153-
154136
echo "Creating Python bindings..."
155137
mkdir -p python/src/{enums,structs,impl}
156138
rm -f python/src/{enums,structs,impl}/*.py
157-
./genbindings.py "./lightning.h" python/src/impl python/src python/ $DEBUG_ARG python $4
139+
./genbindings.py "./lightning.h" python/src/impl python/src python/ $DEBUG_ARG python $4 $TARGET_STRING
158140
rm -f python/bindings.c
159141
if [ "$3" = "true" ]; then
160142
echo "#define LDK_DEBUG_BUILD" > python/bindings.c
@@ -173,7 +155,7 @@ elif [ "$2" = "python" ]; then
173155
[ "$($CC --version | grep "Apple clang version")" != "" ] && IS_APPLE_CLANG=true
174156

175157
echo "Building Python bindings..."
176-
COMPILE="$COMMON_COMPILE -mcpu=$LDK_TARGET_CPU -Isrc/main/jni -pthread -fPIC"
158+
COMPILE="$COMMON_COMPILE -Isrc/main/jni -pthread -fPIC"
177159
LINK="-ldl -shared"
178160
[ "$IS_MAC" = "false" ] && LINK="$LINK -Wl,--no-undefined"
179161
[ "$IS_MAC" = "true" ] && COMPILE="$COMPILE -mmacosx-version-min=10.9"
@@ -187,16 +169,16 @@ elif [ "$2" = "python" ]; then
187169
else
188170
$COMPILE -o bindings.o -c -flto -O3 -I"$1"/lightning-c-bindings/include/ $2 c_sharp/bindings.c
189171
$COMPILE $LINK -o liblightningpython_release$LDK_TARGET_SUFFIX.so -Wl,--version-script=python/libcode.version -flto -O3 -Wl,--lto-O3 -Wl,-O3 -I"$1"/lightning-c-bindings/include/ $2 bindings.o "$1"/lightning-c-bindings/target/$LDK_TARGET/release/libldk.a -lm
190-
llvm-strip liblightningpython_release$LDK_TARGET_SUFFIX.so
172+
[ "$IS_APPLE_CLANG" != "true" ] && llvm-strip liblightningpython_release$LDK_TARGET_SUFFIX.so
191173
fi
192174
elif [ "$2" = "wasm" ]; then
193175
echo "Creating TS bindings..."
194176
mkdir -p ts/{enums,structs}
195177
rm -f ts/{enums,structs,}/*.{mjs,mts,mts.part}
196178
if [ "$4" = "false" ]; then
197-
./genbindings.py "./lightning.h" ts ts ts $DEBUG_ARG typescript node
179+
./genbindings.py "./lightning.h" ts ts ts $DEBUG_ARG typescript node wasm
198180
else
199-
./genbindings.py "./lightning.h" ts ts ts $DEBUG_ARG typescript browser
181+
./genbindings.py "./lightning.h" ts ts ts $DEBUG_ARG typescript browser wasm
200182
fi
201183
rm -f ts/bindings.c
202184
sed -i 's/^ "version": .*/ "version": "'${LDK_GARBAGECOLLECTED_GIT_OVERRIDE:1:100}'",/g' ts/package.json
@@ -250,32 +232,6 @@ elif [ "$2" = "wasm" ]; then
250232
fi
251233
fi
252234
else
253-
TARGET_STRING="$LDK_TARGET"
254-
if [ "$TARGET_STRING" = "" ]; then
255-
# We assume clang-style $CC --version here, but worst-case we just get an empty suffix
256-
TARGET_STRING="$($CC --version | grep Target | awk '{ print $2 }')"
257-
fi
258-
case "$TARGET_STRING" in
259-
"x86_64-pc-linux"*)
260-
LDK_TARGET_SUFFIX="_Linux-amd64"
261-
LDK_JAR_TARGET=true
262-
;;
263-
"x86_64-apple-darwin"*)
264-
LDK_TARGET_SUFFIX="_MacOSX-x86_64"
265-
LDK_JAR_TARGET=true
266-
;;
267-
"aarch64-apple-darwin"*)
268-
LDK_TARGET_CPU="apple-a14"
269-
LDK_TARGET_SUFFIX="_MacOSX-aarch64"
270-
LDK_JAR_TARGET=true
271-
;;
272-
*)
273-
LDK_TARGET_SUFFIX="_${TARGET_STRING}"
274-
esac
275-
if [ "$LDK_TARGET_CPU" = "" ]; then
276-
LDK_TARGET_CPU="sandybridge"
277-
fi
278-
279235
if is_gnu_sed; then
280236
sed -i "s/^ <version>.*<\/version>/ <version>${LDK_GARBAGECOLLECTED_GIT_OVERRIDE:1:100}<\/version>/g" pom.xml
281237
else
@@ -288,9 +244,9 @@ else
288244
rm -f src/main/java/org/ldk/{enums,structs}/*.java
289245
rm -f src/main/jni/*.h
290246
if [ "$4" = "true" ]; then
291-
./genbindings.py "./lightning.h" src/main/java/org/ldk/impl src/main/java/org/ldk src/main/jni/ $DEBUG_ARG android $4
247+
./genbindings.py "./lightning.h" src/main/java/org/ldk/impl src/main/java/org/ldk src/main/jni/ $DEBUG_ARG android $4 $TARGET_STRING
292248
else
293-
./genbindings.py "./lightning.h" src/main/java/org/ldk/impl src/main/java/org/ldk src/main/jni/ $DEBUG_ARG java $4
249+
./genbindings.py "./lightning.h" src/main/java/org/ldk/impl src/main/java/org/ldk src/main/jni/ $DEBUG_ARG java $4 $TARGET_STRING
294250
fi
295251
rm -f src/main/jni/bindings.c
296252
if [ "$3" = "true" ]; then
@@ -306,13 +262,8 @@ else
306262
javac -h src/main/jni src/main/java/org/ldk/enums/*.java src/main/java/org/ldk/impl/*.java
307263
rm src/main/java/org/ldk/enums/*.class src/main/java/org/ldk/impl/bindings*.class
308264

309-
IS_MAC=false
310-
[ "$($CC --version | grep apple-darwin)" != "" ] && IS_MAC=true
311-
IS_APPLE_CLANG=false
312-
[ "$($CC --version | grep "Apple clang version")" != "" ] && IS_APPLE_CLANG=true
313-
314265
echo "Building Java bindings..."
315-
COMPILE="$COMMON_COMPILE -mcpu=$LDK_TARGET_CPU -Isrc/main/jni -pthread -fPIC"
266+
COMPILE="$COMMON_COMPILE -Isrc/main/jni -pthread -fPIC"
316267
LINK="-ldl -shared"
317268
[ "$IS_MAC" = "false" ] && LINK="$LINK -Wl,--no-undefined"
318269
[ "$IS_MAC" = "true" ] && COMPILE="$COMPILE -mmacosx-version-min=10.9"
@@ -322,6 +273,10 @@ else
322273
if [ "$3" = "true" ]; then
323274
$COMPILE $LINK -o liblightningjni_debug$LDK_TARGET_SUFFIX.so -g -fsanitize=address -shared-libasan -rdynamic -I"$1"/lightning-c-bindings/include/ $2 src/main/jni/bindings.c "$1"/lightning-c-bindings/target/$LDK_TARGET/debug/libldk.a -lm
324275
else
276+
[ "$IS_MAC" = "false" ] && LINK="$LINK -Wl,--no-undefined -flto -Wl,-O3 -Wl,--lto-O3"
277+
[ "$IS_MAC" = "false" ] && COMPILE="$COMPILE -flto"
278+
[ "$IS_MAC" = "true" -a "$IS_APPLE_CLANG" = "false" ] && LINK="$LINK -flto -Wl,-O3 -Wl,--lto-O3"
279+
[ "$IS_MAC" = "true" -a "$IS_APPLE_CLANG" = "false" ] && COMPILE="$COMPILE -flto"
325280
LDK_LIB="$1"/lightning-c-bindings/target/$LDK_TARGET/release/libldk.a
326281
if [ "$IS_MAC" = "false" -a "$4" = "false" ]; then
327282
LINK="$LINK -Wl,--version-script=libcode.version -fuse-ld=lld"
@@ -365,9 +320,9 @@ else
365320
popd
366321
LDK_LIB="tmp/libldk.bc tmp/libldk.a"
367322
fi
368-
$COMPILE -o bindings.o -c -flto -O3 -I"$1"/lightning-c-bindings/include/ $2 src/main/jni/bindings.c
369-
$COMPILE $LINK -o liblightningjni_release$LDK_TARGET_SUFFIX.so -flto -Wl,--lto-O3 -Wl,-O3 -O3 -I"$1"/lightning-c-bindings/include/ $2 bindings.o $LDK_LIB -lm
370-
llvm-strip liblightningjni_release$LDK_TARGET_SUFFIX.so
323+
$COMPILE -o bindings.o -c -O3 -I"$1"/lightning-c-bindings/include/ $2 src/main/jni/bindings.c
324+
$COMPILE $LINK -o liblightningjni_release$LDK_TARGET_SUFFIX.so -O3 -I"$1"/lightning-c-bindings/include/ $2 bindings.o $LDK_LIB -lm
325+
[ "$IS_APPLE_CLANG" != "true" ] && llvm-strip liblightningjni_release$LDK_TARGET_SUFFIX.so
371326
if [ "$IS_MAC" = "false" -a "$4" = "false" ]; then
372327
GLIBC_SYMBS="$(objdump -T liblightningjni_release$LDK_TARGET_SUFFIX.so | grep GLIBC_ | grep -v "GLIBC_2\.2\." | grep -v "GLIBC_2\.3\(\.\| \)" | grep -v "GLIBC_2.\(14\|17\) " || echo)"
373328
if [ "$GLIBC_SYMBS" != "" ]; then

java_strings.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
class Target(Enum):
66
JAVA = 1,
77
ANDROID = 2
8+
MACOS = 3
89

910
class Consts:
1011
def __init__(self, DEBUG: bool, target: Target, **kwargs):
@@ -193,7 +194,7 @@ class CommonBase {
193194
else:
194195
self.c_file_pfx = self.c_file_pfx + "#define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)\n"
195196

196-
if not DEBUG or sys.platform == "darwin":
197+
if not DEBUG or self.target == Target.MACOS:
197198
self.c_file_pfx = self.c_file_pfx + """#define MALLOC(a, _) malloc(a)
198199
#define FREE(p) if ((uint64_t)(p) > 4096) { free(p); }
199200
#define CHECK_ACCESS(p)
@@ -218,7 +219,7 @@ class CommonBase {
218219
}
219220
"""
220221

221-
if sys.platform != "darwin":
222+
if self.target != Target.MACOS:
222223
self.c_file_pfx += """
223224
// Running a leak check across all the allocations and frees of the JDK is a mess,
224225
// so instead we implement our own naive leak checker here, relying on the -wrap
@@ -600,7 +601,7 @@ def init_str(self):
600601
res = res + "\t" + ty + "_clz = (*env)->FindClass(env, \"" + ty.replace("arr_of_", "[") + "\");\n"
601602
res = res + "\tCHECK(" + ty + "_clz != NULL);\n"
602603
res = res + "\t" + ty + "_clz = (*env)->NewGlobalRef(env, " + ty + "_clz);\n"
603-
res = res + "\tString_clz = (*env)->FindClass(env, \"Ljava/lang/String;\");\n"
604+
res = res + "\tString_clz = (*env)->FindClass(env, \"java/lang/String\");\n"
604605
res = res + "\tCHECK(String_clz != NULL);\n"
605606
res = res + "\tString_clz = (*env)->NewGlobalRef(env, String_clz);\n"
606607

0 commit comments

Comments
 (0)