run: ./build-release-jar.sh
- name: Check latest headers are in git
run: |
+ git checkout pom.xml
git diff --exit-code
- name: Check latest library and jars are in bins repo
run: |
with open(f"{sys.argv[3]}/structs/UtilMethods{consts.file_ext}", "a") as util:
util.write(consts.util_fn_pfx)
-with open(sys.argv[1]) as in_h, open(sys.argv[2], "w") as out_java:
+with open(sys.argv[1]) as in_h, open(f"{sys.argv[2]}/bindings{consts.file_ext}", "w") as out_java:
# Map a top-level function
def map_fn(line, re_match, ret_arr_len, c_call_string, doc_comment):
method_return_type = re_match.group(1)
write_c("\treturn tuple->" + e + ";\n")
write_c("}\n")
- out_java.write(consts.bindings_header.replace('<git_version_ldk_garbagecollected>', local_git_version))
+ out_java.write(consts.bindings_header)
+ with open(f"{sys.argv[2]}/version{consts.file_ext}", "w") as out_java_version:
+ out_java_version.write(consts.bindings_version_file.replace('<git_version_ldk_garbagecollected>', local_git_version))
with open(f"{sys.argv[3]}/structs/CommonBase{consts.file_ext}", "w") as out_java_struct:
out_java_struct.write(consts.common_base)
with open(f"{sys.argv[3]}/structs/{struct_name.replace('LDKCResult', 'Result')}{consts.file_ext}", "a") as out_java_struct:
out_java_struct.write("}\n")
-with open(sys.argv[4], "w") as out_c:
- out_c.write(consts.c_file_pfx.replace('<git_version_ldk_garbagecollected>', local_git_version))
+with open(f"{sys.argv[4]}/bindings.c.body", "w") as out_c:
+ out_c.write(consts.c_file_pfx)
out_c.write(consts.init_str())
out_c.write(c_file)
+with open(f"{sys.argv[4]}/version.c", "w") as out_c:
+ out_c.write(consts.c_version_file.replace('<git_version_ldk_garbagecollected>', local_git_version))
with open(f"{sys.argv[3]}/structs/UtilMethods{consts.file_ext}", "a") as util:
util.write(consts.util_fn_sfx)
DEBUG_ARG="true"
fi
if [ "$4" = "true" ]; then
- ./genbindings.py "./lightning.h" src/main/java/org/ldk/impl/bindings.java src/main/java/org/ldk src/main/jni/bindings.c.body $DEBUG_ARG android $4
+ ./genbindings.py "./lightning.h" src/main/java/org/ldk/impl src/main/java/org/ldk src/main/jni/ $DEBUG_ARG android $4
else
- ./genbindings.py "./lightning.h" src/main/java/org/ldk/impl/bindings.java src/main/java/org/ldk src/main/jni/bindings.c.body $DEBUG_ARG java $4
+ ./genbindings.py "./lightning.h" src/main/java/org/ldk/impl src/main/java/org/ldk src/main/jni/ $DEBUG_ARG java $4
fi
echo "#define LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ LDKCVec_TransactionOutputsZ" > src/main/jni/bindings.c
echo "#define CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free CVec_TransactionOutputsZ_free" >> src/main/jni/bindings.c
cat src/main/jni/bindings.c.body >> src/main/jni/bindings.c
-javac -h src/main/jni src/main/java/org/ldk/enums/*.java src/main/java/org/ldk/impl/bindings.java
+javac -h src/main/jni src/main/java/org/ldk/enums/*.java src/main/java/org/ldk/impl/*.java
rm src/main/java/org/ldk/enums/*.class src/main/java/org/ldk/impl/bindings*.class
IS_MAC=false
echo "Creating TS bindings..."
mkdir -p ts/{enums,structs}
rm -f ts/{enums,structs}/*.ts
-./genbindings.py "./lightning.h" ts/bindings.ts ts ts/bindings.c.body $DEBUG_ARG typescript
+./genbindings.py "./lightning.h" ts ts ts $DEBUG_ARG typescript
echo "#define LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ LDKCVec_TransactionOutputsZ" > ts/bindings.c
echo "#define CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free CVec_TransactionOutputsZ_free" >> ts/bindings.c
cat ts/bindings.c.body >> ts/bindings.c
self.bindings_header = """package org.ldk.impl;
import org.ldk.enums.*;
+import org.ldk.impl.version;
import java.io.File;
import java.io.InputStream;
import java.io.IOException;
}
init(java.lang.Enum.class, VecOrSliceDef.class);
init_class_cache();
- if (!get_lib_version_string().equals(get_ldk_java_bindings_version()))
+ if (!get_lib_version_string().equals(version.get_ldk_java_bindings_version()))
throw new IllegalArgumentException("Compiled LDK library and LDK class failes do not match");
// Fetching the LDK versions from C also checks that the header and binaries match
get_ldk_c_bindings_version();
static native void init_class_cache();
static native String get_lib_version_string();
- public static String get_ldk_java_bindings_version() {
- return "<git_version_ldk_garbagecollected>";
- }
public static native String get_ldk_c_bindings_version();
public static native String get_ldk_version();
public static native long new_empty_slice_vec();
"""
+ self.bindings_version_file = """package org.ldk.impl;
+
+public class version {
+ public static String get_ldk_java_bindings_version() {
+ return "<git_version_ldk_garbagecollected>";
+ }
+}"""
self.bindings_footer = "}\n"
return res;
}
-JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1lib_1version_1string(JNIEnv *env, jclass _c) {
- return str_ref_to_java(env, "<git_version_ldk_garbagecollected>", strlen("<git_version_ldk_garbagecollected>"));
-}
JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1c_1bindings_1version(JNIEnv *env, jclass _c) {
return str_ref_to_java(env, check_get_ldk_bindings_version(), strlen(check_get_ldk_bindings_version()));
}
JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1version(JNIEnv *env, jclass _c) {
return str_ref_to_java(env, check_get_ldk_version(), strlen(check_get_ldk_version()));
}
+#include "version.c"
"""
+ self.c_version_file = """JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1lib_1version_1string(JNIEnv *env, jclass _c) {
+ return str_ref_to_java(env, "<git_version_ldk_garbagecollected>", strlen("<git_version_ldk_garbagecollected>"));
+}"""
self.hu_struct_file_prefix = """package org.ldk.structs;
<groupId>org.lightningdevkit</groupId>
<artifactId>ldk-java</artifactId>
- <version>0.0.101.0</version>
+ <version>Set in genbindings.sh automagically</version>
<name>LDK Java Bindings and Binaries</name>
<description>LDK Java Bindings and Release Binaries</description>
"""
+ self.bindings_version_file = ""
+
self.bindings_footer = """
export async function initializeWasm(allowDoubleInitialization: boolean = false): Promise<void> {
if(isWasmInitialized && !allowDoubleInitialization) {
}
"""
+ self.c_version_file = ""
+
self.hu_struct_file_prefix = f"""
import CommonBase from './CommonBase';
import * as bindings from '../bindings' // TODO: figure out location