Skip to content

Commit c73a538

Browse files
Kudokmagiera
authored andcommitted
Use API 16 for armv7, x86 as current react-native spec (#66)
Summary: While building arm7, x86, use API 16. While building arm64, x86_64, use API 21. (Android introduced 64 bits support after API 21). There are some patches for missing symbols from NDK API 16. 1. log2() is supported until API 18. Solved this by introduced a log2() polyfill. 2. getline() is supported until API 18. As the WebKit WTF code is not being used in JSC, just comment out it. For discussion details, see the PR commants: #66 (comment) 3. Add '-Wl,--no-undefined' ldflags to prevent missing NDK symbols in the future.
1 parent bfb932e commit c73a538

File tree

5 files changed

+49
-3
lines changed

5 files changed

+49
-3
lines changed

lib/android-jsc/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ android {
44
compileSdkVersion 28
55

66
defaultConfig {
7-
minSdkVersion 21
7+
minSdkVersion 16
88
targetSdkVersion 28
99
versionCode 1
1010
versionName "1.0"

patches/jsc.patch

+40
Original file line numberDiff line numberDiff line change
@@ -291,3 +291,43 @@ diff -aur target-org/webkit/Source/JavaScriptCore/CMakeLists.txt target/webkit/S
291291
)
292292
+add_definitions(-DJSC_VERSION="${JSC_VERSION}")
293293

294+
diff -aur target-org/webkit/Source/WTF/wtf/linux/MemoryFootprintLinux.cpp target/webkit/Source/WTF/wtf/linux/MemoryFootprintLinux.cpp
295+
--- target-org/webkit/Source/WTF/wtf/linux/MemoryFootprintLinux.cpp 2018-11-11 23:05:48.000000000 +0800
296+
+++ target/webkit/Source/WTF/wtf/linux/MemoryFootprintLinux.cpp 2018-11-12 23:39:22.000000000 +0800
297+
@@ -23,6 +23,10 @@
298+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
299+
*/
300+
301+
+// CUSTOMIZE_REACT_NATIVE: getline() does not implemented until Android NDK API 18.
302+
+// Since MemoryFootprint does not being used in JSC, comment out to prevent build break.
303+
+#if !defined(CUSTOMIZE_REACT_NATIVE)
304+
+
305+
#include "config.h"
306+
#include "MemoryFootprint.h"
307+
308+
@@ -107,3 +111,4 @@
309+
}
310+
311+
}
312+
+#endif // !defined(CUSTOMIZE_REACT_NATIVE)
313+
diff -aur target-org/webkit/Source/JavaScriptCore/Sources.txt target/webkit/Source/JavaScriptCore/Sources.txt
314+
--- target-org/webkit/Source/JavaScriptCore/Sources.txt 2018-11-11 23:05:40.000000000 +0800
315+
+++ target/webkit/Source/JavaScriptCore/Sources.txt 2018-11-12 00:03:26.000000000 +0800
316+
@@ -1046,3 +1046,6 @@
317+
318+
// Derived Sources
319+
yarr/YarrCanonicalizeUnicode.cpp
320+
+
321+
+// Polyfills
322+
+polyfills/log2.cpp
323+
diff -aur /dev/null target/webkit/Source/JavaScriptCore/polyfills/log2.cpp
324+
--- /dev/null 2018-11-12 01:21:57.000000000 +0800
325+
+++ target/webkit/Source/JavaScriptCore/polyfills/log2.cpp 2018-11-12 01:19:49.000000000 +0800
326+
@@ -0,0 +1,7 @@
327+
+#include <math.h>
328+
+
329+
+#if defined(__ANDROID__) && __ANDROID_API__ < 18
330+
+double log2(double x) {
331+
+ return log(x) / log(2.0);
332+
+}
333+
+#endif

scripts/compile/all.sh

+2
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ compile_arch() {
2121
compile() {
2222
for arch in arm x86
2323
do
24+
export ANDROID_API=$ANDROID_API_FOR_ABI_32
2425
export JSC_ARCH=$arch
2526
export ENABLE_COMPAT=1
2627
compile_arch
2728
done
2829

2930
for arch in arm64 x86_64
3031
do
32+
export ANDROID_API=$ANDROID_API_FOR_ABI_64
3133
export JSC_ARCH=$arch
3234
export ENABLE_COMPAT=0
3335
compile_arch

scripts/compile/common.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ process_switch_options "INTL"
110110

111111
# checks
112112
err=false
113-
if ! [[ $ANDROID_API ]]; then echo "set ANDROID_API to the minimum supported Android platform version (e.g. 15)"; err=true; fi
113+
if ! [[ $ANDROID_API_FOR_ABI_32 ]]; then echo "set ANDROID_API_FOR_ABI_32 to the minimum supported Android platform version for arm and x86 (e.g. 16)"; err=true; fi
114+
if ! [[ $ANDROID_API_FOR_ABI_64 ]]; then echo "set ANDROID_API_FOR_ABI_64 to the minimum supported Android platform version for arm64 and x86_64 (e.g. 21)"; err=true; fi
114115
if ! [[ $FLAVOR ]]; then echo "set FLAVOR to the name of the flavor"; err=true; fi
115116
if ! [[ $CROSS_COMPILE_PLATFORM ]]; then echo "set JSC_ARCH to one of {arm,arm64,x86,x86_64}"; err=true; fi
116117
if ! [[ $ANDROID_HOME ]]; then echo "set ANDROID_HOME to android sdk dir"; err=true; fi
@@ -127,6 +128,7 @@ COMMON_LDFLAGS=" \
127128
-Wl,--gc-sections \
128129
-Wl,--exclude-libs,libgcc.a \
129130
-Wl,--exclude-libs,libunwind.a \
131+
-Wl,--no-undefined \
130132
"
131133

132134
COMMON_CFLAGS=" \
@@ -141,6 +143,7 @@ COMMON_CFLAGS=" \
141143
-fPIC \
142144
-fvisibility=hidden \
143145
-DNDEBUG \
146+
-DCUSTOMIZE_REACT_NATIVE \
144147
$SWITCH_COMMON_CFLAGS_INTL \
145148
"
146149

scripts/start.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash -e
22

3-
export ANDROID_API=21
3+
export ANDROID_API_FOR_ABI_32=16
4+
export ANDROID_API_FOR_ABI_64=21
45
export ROOTDIR=$PWD
56
export TARGETDIR=$ROOTDIR/build/target
67
source $ROOTDIR/scripts/info.sh

0 commit comments

Comments
 (0)