250231.0.0 • Published 1 year ago

jsc-android v250231.0.0

Weekly downloads
475,704
License
BSD-2-Clause
Repository
github
Last release
1 year ago

npm version Build Status

JSC build scripts for Android

The aim of this project is to provide maintainable build scripts for the JavaScriptCore JavaScript engine and allow the React Native project to incorporate up-to-date releases of JSC into the framework on Android.

This project is based on facebook/android-jsc but instead of rewriting JSC's build scripts into BUCK files, it relies on CMake build scripts maintained in a GTK branch of WebKit maintained by the WebKitGTK team (great work btw!). Thanks to that, with just a small amount of work we should be able to build not only current but also future releases of JSC. An obvious benefit for everyone using React Native is that this will allow us to update JSC for React Native on Android much more often than before (note that facebook/android-jsc uses JSC version from Nov 2014), which is especially helpful since React Native on iOS uses the built-in copy of JSC that is updated with each major iOS release (see this as a reference).

Requirements

  • Homebrew (https://brew.sh/)
  • GNU coreutils brew install coreutils
  • Node brew install node
  • Java 8: brew tap caskroom/versions && brew cask install java8
  • Android SDK: brew cask install android-sdk
    • Run sdkmanager --list and install all platforms, tools, cmake, ndk (android images are not needed)
    • Set $ANDROID_HOME to the correct path (in ~/.bashrc or similar)
    • Set export ANDROID_NDK=$ANDROID_HOME/ndk-bundle
    • Set export PATH=$PATH:$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools/bin
  • Make sure you have Ruby (>2.3), Python (>2.7), Git, SVN, gperf

Build instructions

  1. Clone this repo
  2. npm run clean will clean everything (artifacts, downloaded sources)
  3. Update the version in package.json. The version will be printed by JSC lib as soon as it loads.
  4. Update the config section under package.json to the desired build configuration
  5. Update patches if needed (don't forget to update the printVersion patch in jsc.patch)
  6. npm run download: downloads all needed sources
  7. 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.

Distribution

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:

  1. Add jsc-android to the "dependencies" section in your package.json:
dependencies {
+  "jsc-android": "236355.x.x",

then run npm install or yarn (depending which npm client you use) in order for the new dependency to be installed in node_modules

  1. Modify android/build.gradle file to add new local maven repository packaged in the jsc-android package to the search path:
allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
+       maven {
+           // Local Maven repo containing AARs with JSC library built for Android
+           url "$rootDir/../node_modules/jsc-android/dist"
+       }
    }
}
  1. Update your app's build.gradle file located in android/app/build.gradle to force app builds to use new version of the JSC library as opposed to the version specified in react-native gradle module as a dependency:
}

+configurations.all {
+    resolutionStrategy {
+        force 'org.webkit:android-jsc:r236355'
+    }
+}

dependencies {
    compile fileTree(dir: "libs", include: ["*.jar"])
  1. Make sure your app's build.gradle uses a minimum sdk version of 21
defaultConfig {
    applicationId "com.myApp"
-    minSdkVersion 16
+    minSdkVersion 21
    targetSdkVersion 22
    versionCode 1
  1. You're done, rebuild your app and enjoy updated version of JSC on android!

International variant

International variant includes ICU i18n library and necessary data allowing to use e.g. Date.toLocaleString and String.localeCompare that give correct results when using with locales other than en-US. Note that this variant is about 6MiB larger per architecture than default.

To use this variant instead replace the third installation step with:

+configurations.all {
+    resolutionStrategy {
+        eachDependency { DependencyResolveDetails details ->
+            if (details.requested.name == 'android-jsc') {
+                details.useTarget group: details.requested.group, name: 'android-jsc-intl', version: 'r236355'
+            }
+        }
+    }
+}

Testing

See Measurements page that contains synthetic perf test results for the most notable versions of JSC we have tried.

Resources

Credits

Check the list of contributors here. This project is supported by:

expo Expo.io

swm Software Mansion

wix Wix

@wouterds/react-native-tvoseasy-select-rnsola-react-nativereact-native-bluetooth2killi8n-react-native-fast-imagereact-native-for-sanbotreact-native-template-rfbaseairscanairscan-examplereact-native-esc-pos-sahaab@borisovart/atol-kkt-moduledeneme323112@ntt_app/react-native-custom-notificationreact-native-custom-text-hwjameshotqa-sdkreact-native-savvreact-native-covid-sdkreact-native-printer-brothersrn-pdf-reader-offlinereact-native-shekhar-bridge-testreact-native-wegowilscanner@oiti/documentoscopy-react-nativequoc-testreact-native-slider-kfluminos-ui-corereact-native-macosreact-nativereact-native-windows@everything-registry/sub-chunk-1979jawwy-sdkjawwy_gamification_releasereact-native-sphereuisphereuijawwy_libraryreact-native-credit-card-pkgreact-native-jawwy_samplereact-native-animate-textreact-native-android-video-player-viewreact-native-badge-controlreact-native-basic-appreact-native-basic-screenreact-native-bubble-chartreact-native-create-video-thumbnailreact-native-cplusreact-native-build-vesion-getterreact-native-additionreact-native-arps-authorize-netreact-native-arun-ramya-testreact-native-arunjeyam1987react-native-arunmeena1987react-native-arunramya151react-native-bluetooth-device-detectreact-native-booking-calendarreact-native-bleccs-componentsreact-native-biometric-authenticatereact-native-check-componentreact-native-chenaarreact-native-conekta-card-tokenizerreact-native-contact-listreact-native-components-designsentral.rnsharingcomponent2react-native-recent-framework-updatereact-native-reanimated-sortable-listreact-native-rom-componentsreact-native-get-countriesreact-native-innity-2react-native-innity-remasterreact-native-input-libraryreact-native-intent-lancher-demoreact-native-omental-frameworkreact-native-onrampreact-native-plugpag-wrapperreact-native-sfreact-native-remote-cloverreact-native-screen-idle-timerreact-native-scroll-tab-to-indexreact-native-okhttp-forkreact-native-payu-payment-testingreact-native-responsive-sizereact-native-return-usb-datareact-native-rn-icons-libraryreact-native-rn-appreact-native-rtn-ips-poslin-testreact-native-sayhello-modulereact-native-savczuk-feature-libraryreact-native-sandycomponentreact-native-sample-android-toast-version10react-native-flyyreact-native-ghn-ekycreact-native-dimensions-layoutreact-native-dhp-printerreact-native-dishreact-native-expendable-viewreact-native-dm-playerreact-native-dsphoto-modulereact-native-firebase-messagingreact-native-cc-test-libaryreact-native-ctp-odp
250231.0.0

1 year ago

294992.0.0

2 years ago

250230.2.1

3 years ago

245459.0.0

5 years ago

241213.2.0

5 years ago

241213.1.0

5 years ago

241213.0.0

5 years ago

236355.1.1

5 years ago

236355.1.0

5 years ago

174650.0.2

5 years ago

174650.0.1

5 years ago

174650.0.0

5 years ago

236355.0.0

5 years ago

225067.0.0

6 years ago

224109.1.0

6 years ago

224109.0.0

6 years ago

216113.0.3

6 years ago

216113.0.2

7 years ago

216113.0.1

7 years ago

216113.0.0

7 years ago