Skip to content

Commit

Permalink
merge from master
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielZlotin committed Oct 9, 2018
2 parents 66785c1 + 8872638 commit a9296c0
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 11 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ This project is based on [facebook/android-jsc](https://github.com/facebook/andr
## Build instructions

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

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

On load, JSC prints the version out to logcat, under "JavaScriptCore.Version" tag.

## How to use it with my React Native app

Follow steps below in order for your React Native app to use new version of JSC VM on android:
Expand Down
4 changes: 3 additions & 1 deletion measure/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ ext {

def i18nProp = project.findProperty("i18n")
JSC_NAME = Boolean.valueOf(i18nProp) ? "android-jsc-intl" : "android-jsc"

isIDE = System.getProperties()['idea.platform.prefix'] != null
}

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

allprojects {
Expand Down
Binary file modified measure/android/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion measure/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion measure/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
"devDependencies": {
"shell-utils": "1.x.x"
}
}
}
24 changes: 24 additions & 0 deletions patches/jsc.patch
Original file line number Diff line number Diff line change
Expand Up @@ -268,3 +268,27 @@ diff -aur target-org/webkit/Source/JavaScriptCore/CMakeLists.txt target/webkit/S
${LLVM_LIBRARIES}
)

diff -aur target-org/webkit/Source/JavaScriptCore/API/JSBase.cpp target/webkit/Source/JavaScriptCore/API/JSBase.cpp
--- target-org/webkit/Source/JavaScriptCore/API/JSBase.cpp 2017-05-05 02:37:52.000000000 +0300
+++ target/webkit/Source/JavaScriptCore/API/JSBase.cpp 2018-10-09 14:38:30.000000000 +0300
@@ -191,3 +191,9 @@
const char iosInstallName60 = 0;
const char iosInstallName61 = 0;
#endif
+
+extern "C" int __android_log_print(int prio, const char *tag, const char *fmt, ...);
+__attribute__((constructor))
+void printVersion() {
+ __android_log_print(3, "JavaScriptCore.Version", "%s", "224109.1.0");
+}
diff -aur target-org/webkit/Source/JavaScriptCore/CMakeLists.txt target/webkit/Source/JavaScriptCore/CMakeLists.txt
--- target-org/webkit/Source/JavaScriptCore/CMakeLists.txt 2017-10-16 15:19:26.000000000 +0300
+++ target/webkit/Source/JavaScriptCore/CMakeLists.txt 2018-10-09 14:44:23.000000000 +0300
@@ -1073,6 +1073,7 @@
WTF${DEBUG_SUFFIX}
${ICU_I18N_LIBRARIES}
${LLVM_LIBRARIES}
+ log
)

set(JavaScriptCore_SCRIPTS_SOURCES_DIR "${JAVASCRIPTCORE_DIR}/Scripts")
1 change: 0 additions & 1 deletion scripts/compile/all.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/bin/bash -e

SCRIPT_DIR=$(cd `dirname $0`; pwd)
export ANDROID_API=21

compile_arch() {
echo -e '\033]2;'"compiling toolchain for $JSC_ARCH $FLAVOR"'\007'
Expand Down
16 changes: 15 additions & 1 deletion scripts/compile/jsc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ $JSC_LDFLAGS \
$PLATFORM_LDFLAGS \
"

export AR=$CROSS_COMPILE_PLATFORM-ar
export AS=$CROSS_COMPILE_PLATFORM-clang
export CC=$CROSS_COMPILE_PLATFORM-clang
export CXX=$CROSS_COMPILE_PLATFORM-clang++
export LD=$CROSS_COMPILE_PLATFORM-ld
export STRIP=$CROSS_COMPILE_PLATFORM-strip

ARCH_NAME_PLATFORM_arm="arm"
ARCH_NAME_PLATFORM_arm64="aarch64"
ARCH_NAME_PLATFORM_x86="i686"
ARCH_NAME_PLATFORM_x86_64="x86_64"
var="ARCH_NAME_PLATFORM_$JSC_ARCH"
export ARCH_NAME=${!var}

$TARGETDIR/webkit/Tools/Scripts/build-webkit \
--jsc-only \
--release \
Expand All @@ -39,7 +53,7 @@ $TARGETDIR/webkit/Tools/Scripts/build-webkit \
--cmakeargs="-DCMAKE_SYSTEM_NAME=Android \
$SWITCH_BUILD_WEBKIT_CMAKE_ARGS_COMPAT \
-DCMAKE_SYSTEM_VERSION=$ANDROID_API \
-DCMAKE_SYSTEM_PROCESSOR=$ARCH \
-DCMAKE_SYSTEM_PROCESSOR=$ARCH_NAME \
-DCMAKE_ANDROID_STANDALONE_TOOLCHAIN=$TOOLCHAIN_DIR \
-DWEBKIT_LIBRARIES_INCLUDE_DIR=$TARGETDIR/icu/source/common \
-DWEBKIT_LIBRARIES_LINK_DIR=$TARGETDIR/icu/${CROSS_COMPILE_PLATFORM}-${FLAVOR}/lib \
Expand Down
7 changes: 4 additions & 3 deletions scripts/start.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/bin/bash -e

ROOTDIR=$PWD
TARGETDIR=$ROOTDIR/build/target
source $PWD/scripts/info.sh
export ANDROID_API=21
export ROOTDIR=$PWD
export TARGETDIR=$ROOTDIR/build/target
source $ROOTDIR/scripts/info.sh

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

0 comments on commit a9296c0

Please sign in to comment.