Skip to content

Commit 40a80e1

Browse files
committed
Build optimized release version of the native libs
1 parent ce6dd01 commit 40a80e1

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

rebuild_native.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,22 +76,22 @@ build_arch() {
7676
# Generate JNI header if needed
7777
if [ ! -f "jni/com_eclipsesource_v8_V8Impl.h" ]; then
7878
echo "Generating JNI headers..."
79-
if [ -d "build/intermediates/javac/debug/classes" ]; then
80-
javah -cp build/intermediates/javac/debug/classes -o jni com.eclipsesource.v8.V8Impl || echo "Warning: Could not generate JNI headers"
79+
if [ -d "build/intermediates/javac/release/classes" ]; then
80+
javah -cp build/intermediates/javac/release/classes -o jni com.eclipsesource.v8.V8Impl || echo "Warning: Could not generate JNI headers"
8181
else
8282
echo "Warning: Java classes not found, using existing JNI headers"
8383
fi
8484
fi
8585

86-
# Compile flags
86+
# Compile flags with release optimizations
8787
local CPPFLAGS="-I$ANDROID_NDK_HOME/sysroot/usr/include"
8888
CPPFLAGS="$CPPFLAGS -I$ANDROID_NDK_HOME/sysroot/usr/include/$ndk_arch"
8989
CPPFLAGS="$CPPFLAGS -Iv8.out/include"
9090
CPPFLAGS="$CPPFLAGS -Ijni"
91-
CPPFLAGS="$CPPFLAGS -fPIC -std=c++17"
91+
CPPFLAGS="$CPPFLAGS -fPIC -std=c++17 -O3 -DNDEBUG"
9292

93-
# Link flags with 16KB alignment for Google Play compliance
94-
local LDFLAGS="-shared -llog"
93+
# Link flags with 16KB alignment for Google Play compliance and symbol stripping
94+
local LDFLAGS="-shared -llog -s"
9595
LDFLAGS="$LDFLAGS -Wl,-z,max-page-size=16384"
9696
LDFLAGS="$LDFLAGS -Wl,-z,common-page-size=16384"
9797

-6.3 MB
Binary file not shown.
-6.74 MB
Binary file not shown.

src/main/jniLibs/x86/libj2v8.so

-4.98 MB
Binary file not shown.

src/main/jniLibs/x86_64/libj2v8.so

-5.33 MB
Binary file not shown.

0 commit comments

Comments
 (0)