Skip to content

Commit a9296c0

Browse files
committed
merge from master
2 parents 66785c1 + 8872638 commit a9296c0

File tree

9 files changed

+55
-11
lines changed

9 files changed

+55
-11
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ This project is based on [facebook/android-jsc](https://github.com/facebook/andr
2323
## Build instructions
2424

2525
1. Clone this repo
26-
1. Update the config section under `package.json` to the desired build configuration
27-
1. `npm run download`: downloads all needed sources
28-
1. `npm run start`: builds jsc (this might take some time...)
26+
2. `npm run clean` will clean everything (artifacts, downloaded sources)
27+
3. Update the config section under `package.json` to the desired build configuration
28+
4. Update patches if needed (don't forget to update the `printVersion` patch in jsc.patch)
29+
5. `npm run download`: downloads all needed sources
30+
6. `npm run start`: builds jsc (this might take some time...)
2931

3032
The zipfile containing the android-jsc AAR will be available at `/dist`.
3133
The library is packaged as a local Maven repository containing AAR files that include the binaries.
@@ -36,6 +38,8 @@ JSC library built using this project is distributed over npm: [npm/jsc-android](
3638
The library is packaged as a local Maven repository containing AAR files that include the binaries.
3739
Please refer to the section below in order to learn how your app can consume this format.
3840

41+
On load, JSC prints the version out to logcat, under "JavaScriptCore.Version" tag.
42+
3943
## How to use it with my React Native app
4044

4145
Follow steps below in order for your React Native app to use new version of JSC VM on android:

measure/android/build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ ext {
77

88
def i18nProp = project.findProperty("i18n")
99
JSC_NAME = Boolean.valueOf(i18nProp) ? "android-jsc-intl" : "android-jsc"
10+
11+
isIDE = System.getProperties()['idea.platform.prefix'] != null
1012
}
1113

12-
if (JSC_VERSION) {
14+
if (!isIDE && JSC_VERSION) {
1315
println "\n\n\t\tUsing JavaScriptCore for Android, version ${(char) 27}[35m${JSC_NAME}:${JSC_VERSION}${(char) 27}[0m \n\n"
1416

1517
allprojects {
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

measure/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@
1919
"devDependencies": {
2020
"shell-utils": "1.x.x"
2121
}
22-
}
22+
}

patches/jsc.patch

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,3 +268,27 @@ diff -aur target-org/webkit/Source/JavaScriptCore/CMakeLists.txt target/webkit/S
268268
${LLVM_LIBRARIES}
269269
)
270270

271+
diff -aur target-org/webkit/Source/JavaScriptCore/API/JSBase.cpp target/webkit/Source/JavaScriptCore/API/JSBase.cpp
272+
--- target-org/webkit/Source/JavaScriptCore/API/JSBase.cpp 2017-05-05 02:37:52.000000000 +0300
273+
+++ target/webkit/Source/JavaScriptCore/API/JSBase.cpp 2018-10-09 14:38:30.000000000 +0300
274+
@@ -191,3 +191,9 @@
275+
const char iosInstallName60 = 0;
276+
const char iosInstallName61 = 0;
277+
#endif
278+
+
279+
+extern "C" int __android_log_print(int prio, const char *tag, const char *fmt, ...);
280+
+__attribute__((constructor))
281+
+void printVersion() {
282+
+ __android_log_print(3, "JavaScriptCore.Version", "%s", "224109.1.0");
283+
+}
284+
diff -aur target-org/webkit/Source/JavaScriptCore/CMakeLists.txt target/webkit/Source/JavaScriptCore/CMakeLists.txt
285+
--- target-org/webkit/Source/JavaScriptCore/CMakeLists.txt 2017-10-16 15:19:26.000000000 +0300
286+
+++ target/webkit/Source/JavaScriptCore/CMakeLists.txt 2018-10-09 14:44:23.000000000 +0300
287+
@@ -1073,6 +1073,7 @@
288+
WTF${DEBUG_SUFFIX}
289+
${ICU_I18N_LIBRARIES}
290+
${LLVM_LIBRARIES}
291+
+ log
292+
)
293+
294+
set(JavaScriptCore_SCRIPTS_SOURCES_DIR "${JAVASCRIPTCORE_DIR}/Scripts")

scripts/compile/all.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/bin/bash -e
22

33
SCRIPT_DIR=$(cd `dirname $0`; pwd)
4-
export ANDROID_API=21
54

65
compile_arch() {
76
echo -e '\033]2;'"compiling toolchain for $JSC_ARCH $FLAVOR"'\007'

scripts/compile/jsc.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@ $JSC_LDFLAGS \
2727
$PLATFORM_LDFLAGS \
2828
"
2929

30+
export AR=$CROSS_COMPILE_PLATFORM-ar
31+
export AS=$CROSS_COMPILE_PLATFORM-clang
32+
export CC=$CROSS_COMPILE_PLATFORM-clang
33+
export CXX=$CROSS_COMPILE_PLATFORM-clang++
34+
export LD=$CROSS_COMPILE_PLATFORM-ld
35+
export STRIP=$CROSS_COMPILE_PLATFORM-strip
36+
37+
ARCH_NAME_PLATFORM_arm="arm"
38+
ARCH_NAME_PLATFORM_arm64="aarch64"
39+
ARCH_NAME_PLATFORM_x86="i686"
40+
ARCH_NAME_PLATFORM_x86_64="x86_64"
41+
var="ARCH_NAME_PLATFORM_$JSC_ARCH"
42+
export ARCH_NAME=${!var}
43+
3044
$TARGETDIR/webkit/Tools/Scripts/build-webkit \
3145
--jsc-only \
3246
--release \
@@ -39,7 +53,7 @@ $TARGETDIR/webkit/Tools/Scripts/build-webkit \
3953
--cmakeargs="-DCMAKE_SYSTEM_NAME=Android \
4054
$SWITCH_BUILD_WEBKIT_CMAKE_ARGS_COMPAT \
4155
-DCMAKE_SYSTEM_VERSION=$ANDROID_API \
42-
-DCMAKE_SYSTEM_PROCESSOR=$ARCH \
56+
-DCMAKE_SYSTEM_PROCESSOR=$ARCH_NAME \
4357
-DCMAKE_ANDROID_STANDALONE_TOOLCHAIN=$TOOLCHAIN_DIR \
4458
-DWEBKIT_LIBRARIES_INCLUDE_DIR=$TARGETDIR/icu/source/common \
4559
-DWEBKIT_LIBRARIES_LINK_DIR=$TARGETDIR/icu/${CROSS_COMPILE_PLATFORM}-${FLAVOR}/lib \

scripts/start.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#!/bin/bash -e
22

3-
ROOTDIR=$PWD
4-
TARGETDIR=$ROOTDIR/build/target
5-
source $PWD/scripts/info.sh
3+
export ANDROID_API=21
4+
export ROOTDIR=$PWD
5+
export TARGETDIR=$ROOTDIR/build/target
6+
source $ROOTDIR/scripts/info.sh
67

78
patchAndMakeICU() {
89
printf "\n\n\t\t===================== patch and make icu into target/icu/host =====================\n\n"

0 commit comments

Comments
 (0)