#3115, #3125: Update natives build script, switch to Cloudflare zlib

This commit is contained in:
md_5 2021-06-26 11:28:42 +10:00
parent 15b39887c5
commit da27924a49
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11
8 changed files with 33 additions and 6 deletions

6
.gitmodules vendored Normal file
View File

@ -0,0 +1,6 @@
[submodule "native/mbedtls"]
path = native/mbedtls
url = https://github.com/ARMmbed/mbedtls.git
[submodule "native/zlib"]
path = native/zlib
url = https://github.com/cloudflare/zlib.git

View File

@ -1,6 +1,14 @@
#!/bin/sh #!/bin/sh
CXX="g++ -shared -fPIC -O3 -Wall -Werror -I$JAVA_HOME/include/ -I$JAVA_HOME/include/linux/" set -eu
$CXX src/main/c/NativeCipherImpl.cpp -o src/main/resources/native-cipher.so -lcrypto echo "Compiling mbedtls"
$CXX src/main/c/NativeCompressImpl.cpp -o src/main/resources/native-compress.so -lz (cd mbedtls && make no_test)
echo "Compiling zlib"
(cd zlib && CFLAGS=-fPIC ./configure --static && make)
CXX="g++ -shared -fPIC -Wl,--wrap=memcpy -O3 -Wall -Werror -I$JAVA_HOME/include/ -I$JAVA_HOME/include/linux/"
$CXX -Imbedtls/include src/main/c/NativeCipherImpl.cpp -o src/main/resources/native-cipher.so mbedtls/library/libmbedcrypto.a
$CXX -Izlib src/main/c/NativeCompressImpl.cpp -o src/main/resources/native-compress.so zlib/libz.a

1
native/mbedtls Submodule

@ -0,0 +1 @@
Subproject commit e483a77c85e1f9c1dd2eb1c5a8f552d2617fe400

View File

@ -1,12 +1,15 @@
// Support for CentOS 6
__asm__(".symver memcpy,memcpy@GLIBC_2.2.5");
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <mbedtls/aes.h> #include <mbedtls/aes.h>
#include "net_md_5_bungee_jni_cipher_NativeCipherImpl.h" #include "net_md_5_bungee_jni_cipher_NativeCipherImpl.h"
// Support for CentOS 6
__asm__(".symver memcpy,memcpy@GLIBC_2.2.5");
void *__wrap_memcpy(void *dest, const void *src, size_t n) {
return memcpy(dest, src, n);
}
typedef unsigned char byte; typedef unsigned char byte;
struct crypto_context { struct crypto_context {

View File

@ -1,7 +1,15 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <zlib.h> #include <zlib.h>
#include "net_md_5_bungee_jni_zlib_NativeCompressImpl.h" #include "net_md_5_bungee_jni_zlib_NativeCompressImpl.h"
// Support for CentOS 6
__asm__(".symver memcpy,memcpy@GLIBC_2.2.5");
void *__wrap_memcpy(void *dest, const void *src, size_t n) {
return memcpy(dest, src, n);
}
typedef unsigned char byte; typedef unsigned char byte;
static jfieldID consumedID; static jfieldID consumedID;

1
native/zlib Submodule

@ -0,0 +1 @@
Subproject commit 959b4ea305821e753385e873ec4edfaa9a5d49b7