Skip to content

Commit 2412a7f

Browse files
committed
Split into JSC and V8 apps
1 parent 9ed4b46 commit 2412a7f

28 files changed

+403
-13
lines changed

android/build.gradle

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,6 @@ buildscript {
2323
allprojects {
2424
repositories {
2525
mavenLocal()
26-
maven {
27-
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
28-
url("$rootDir/../node_modules/react-native/android")
29-
}
30-
maven {
31-
// Android JSC is installed from npm
32-
url("$rootDir/../node_modules/jsc-android/dist")
33-
}
34-
3526
google()
3627
jcenter()
3728
}

android/jsc/build.gradle

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
apply plugin: "com.android.application"
22

3+
repositories {
4+
maven {
5+
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
6+
url("$rootDir/../node_modules/react-native/android")
7+
}
8+
maven {
9+
// Android JSC is installed from npm
10+
url("$rootDir/../node_modules/jsc-android/dist")
11+
}
12+
}
13+
314
import com.android.build.OutputFile
415

516
/**
@@ -114,7 +125,7 @@ android {
114125
}
115126

116127
defaultConfig {
117-
applicationId "com.rnbenchmark"
128+
applicationId "com.rnbenchmark.jsc"
118129
minSdkVersion rootProject.ext.minSdkVersion
119130
targetSdkVersion rootProject.ext.targetSdkVersion
120131
versionCode 1

android/jsc/src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55

66
<application
77
android:name=".MainApplication"
8-
android:label="@string/app_name"
8+
android:label="RNBenchmark JSC"
99
android:icon="@mipmap/ic_launcher"
1010
android:roundIcon="@mipmap/ic_launcher_round"
1111
android:allowBackup="false"
1212
android:theme="@style/AppTheme">
1313
<activity
1414
android:name=".MainActivity"
15-
android:label="@string/app_name"
15+
android:label="RNBench JSC"
1616
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
1717
android:windowSoftInputMode="adjustResize">
1818
<intent-filter>

android/jsc/src/main/res/raw/app.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "RNBenchmark",
3+
"displayName": "RNBenchmark"
4+
}

android/settings.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
rootProject.name = 'RNBenchmark'
22
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
3-
include ':app'
3+
include ':jsc'
4+
include ':v8'

android/v8/BUCK

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# To learn about Buck see [Docs](https://buckbuild.com/).
2+
# To run your application with Buck:
3+
# - install Buck
4+
# - `npm start` - to start the packager
5+
# - `cd android`
6+
# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
7+
# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
8+
# - `buck install -r android/app` - compile, install and run application
9+
#
10+
11+
load(":build_defs.bzl", "create_aar_targets", "create_jar_targets")
12+
13+
lib_deps = []
14+
15+
create_aar_targets(glob(["libs/*.aar"]))
16+
17+
create_jar_targets(glob(["libs/*.jar"]))
18+
19+
android_library(
20+
name = "all-libs",
21+
exported_deps = lib_deps,
22+
)
23+
24+
android_library(
25+
name = "app-code",
26+
srcs = glob([
27+
"src/main/java/**/*.java",
28+
]),
29+
deps = [
30+
":all-libs",
31+
":build_config",
32+
":res",
33+
],
34+
)
35+
36+
android_build_config(
37+
name = "build_config",
38+
package = "com.rnbenchmark",
39+
)
40+
41+
android_resource(
42+
name = "res",
43+
package = "com.rnbenchmark",
44+
res = "src/main/res",
45+
)
46+
47+
android_binary(
48+
name = "app",
49+
keystore = "//android/keystores:debug",
50+
manifest = "src/main/AndroidManifest.xml",
51+
package_type = "debug",
52+
deps = [
53+
":app-code",
54+
],
55+
)

android/v8/build.gradle

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
apply plugin: "com.android.application"
2+
3+
repositories {
4+
maven {
5+
url("$rootDir/../node_modules/react-native-v8/dist")
6+
}
7+
maven {
8+
url("$rootDir/../node_modules/v8-android/dist")
9+
}
10+
}
11+
12+
import com.android.build.OutputFile
13+
14+
/**
15+
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
16+
* and bundleReleaseJsAndAssets).
17+
* These basically call `react-native bundle` with the correct arguments during the Android build
18+
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
19+
* bundle directly from the development server. Below you can see all the possible configurations
20+
* and their defaults. If you decide to add a configuration block, make sure to add it before the
21+
* `apply from: "../../node_modules/react-native/react.gradle"` line.
22+
*
23+
* project.ext.react = [
24+
* // the name of the generated asset file containing your JS bundle
25+
* bundleAssetName: "index.android.bundle",
26+
*
27+
* // the entry file for bundle generation
28+
* entryFile: "index.android.js",
29+
*
30+
* // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
31+
* bundleCommand: "ram-bundle",
32+
*
33+
* // whether to bundle JS and assets in debug mode
34+
* bundleInDebug: false,
35+
*
36+
* // whether to bundle JS and assets in release mode
37+
* bundleInRelease: true,
38+
*
39+
* // whether to bundle JS and assets in another build variant (if configured).
40+
* // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
41+
* // The configuration property can be in the following formats
42+
* // 'bundleIn${productFlavor}${buildType}'
43+
* // 'bundleIn${buildType}'
44+
* // bundleInFreeDebug: true,
45+
* // bundleInPaidRelease: true,
46+
* // bundleInBeta: true,
47+
*
48+
* // whether to disable dev mode in custom build variants (by default only disabled in release)
49+
* // for example: to disable dev mode in the staging build type (if configured)
50+
* devDisabledInStaging: true,
51+
* // The configuration property can be in the following formats
52+
* // 'devDisabledIn${productFlavor}${buildType}'
53+
* // 'devDisabledIn${buildType}'
54+
*
55+
* // the root of your project, i.e. where "package.json" lives
56+
* root: "../../",
57+
*
58+
* // where to put the JS bundle asset in debug mode
59+
* jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
60+
*
61+
* // where to put the JS bundle asset in release mode
62+
* jsBundleDirRelease: "$buildDir/intermediates/assets/release",
63+
*
64+
* // where to put drawable resources / React Native assets, e.g. the ones you use via
65+
* // require('./image.png')), in debug mode
66+
* resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
67+
*
68+
* // where to put drawable resources / React Native assets, e.g. the ones you use via
69+
* // require('./image.png')), in release mode
70+
* resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
71+
*
72+
* // by default the gradle tasks are skipped if none of the JS files or assets change; this means
73+
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
74+
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
75+
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
76+
* // for example, you might want to remove it from here.
77+
* inputExcludes: ["android/**", "ios/**"],
78+
*
79+
* // override which node gets called and with what additional arguments
80+
* nodeExecutableAndArgs: ["node"],
81+
*
82+
* // supply additional arguments to the packager
83+
* extraPackagerArgs: []
84+
* ]
85+
*/
86+
87+
project.ext.react = [
88+
entryFile: "index.js"
89+
]
90+
91+
apply from: "../../node_modules/react-native/react.gradle"
92+
93+
/**
94+
* Set this to true to create two separate APKs instead of one:
95+
* - An APK that only works on ARM devices
96+
* - An APK that only works on x86 devices
97+
* The advantage is the size of the APK is reduced by about 4MB.
98+
* Upload all the APKs to the Play Store and people will download
99+
* the correct one based on the CPU architecture of their device.
100+
*/
101+
def enableSeparateBuildPerCPUArchitecture = false
102+
103+
/**
104+
* Run Proguard to shrink the Java bytecode in release builds.
105+
*/
106+
def enableProguardInReleaseBuilds = false
107+
108+
/**
109+
* Use international variant JavaScriptCore
110+
* International variant includes ICU i18n library and necessary data allowing to use
111+
* e.g. Date.toLocaleString and String.localeCompare that give correct results
112+
* when using with locales other than en-US.
113+
* Note that this variant is about 6MiB larger per architecture than default.
114+
*/
115+
def useIntlJsc = false
116+
117+
android {
118+
compileSdkVersion rootProject.ext.compileSdkVersion
119+
120+
compileOptions {
121+
sourceCompatibility JavaVersion.VERSION_1_8
122+
targetCompatibility JavaVersion.VERSION_1_8
123+
}
124+
125+
defaultConfig {
126+
applicationId "com.rnbenchmark.v8"
127+
minSdkVersion rootProject.ext.minSdkVersion
128+
targetSdkVersion rootProject.ext.targetSdkVersion
129+
versionCode 1
130+
versionName "1.0"
131+
}
132+
splits {
133+
abi {
134+
reset()
135+
enable enableSeparateBuildPerCPUArchitecture
136+
universalApk false // If true, also generate a universal APK
137+
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
138+
}
139+
}
140+
signingConfigs {
141+
debug {
142+
storeFile file('debug.keystore')
143+
storePassword 'android'
144+
keyAlias 'androiddebugkey'
145+
keyPassword 'android'
146+
}
147+
}
148+
buildTypes {
149+
debug {
150+
signingConfig signingConfigs.debug
151+
}
152+
release {
153+
// Caution! In production, you need to generate your own keystore file.
154+
// see https://facebook.github.io/react-native/docs/signed-apk-android.
155+
signingConfig signingConfigs.debug
156+
minifyEnabled enableProguardInReleaseBuilds
157+
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
158+
}
159+
}
160+
// applicationVariants are e.g. debug, release
161+
applicationVariants.all { variant ->
162+
variant.outputs.each { output ->
163+
// For each separate APK per architecture, set a unique version code as described here:
164+
// https://developer.android.com/studio/build/configure-apk-splits.html
165+
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
166+
def abi = output.getFilter(OutputFile.ABI)
167+
if (abi != null) { // null for the universal-debug, universal-release variants
168+
output.versionCodeOverride =
169+
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
170+
}
171+
}
172+
}
173+
}
174+
175+
dependencies {
176+
implementation fileTree(dir: "libs", include: ["*.jar"])
177+
implementation "com.facebook.react:react-native:+" // From node_modules
178+
implementation 'org.chromium:v8-android:+'
179+
}
180+
181+
// Run this once to be able to run the application with BUCK
182+
// puts all compile dependencies into folder libs for BUCK to use
183+
task copyDownloadableDepsToLibs(type: Copy) {
184+
from configurations.compile
185+
into 'libs'
186+
}
187+
188+
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

android/v8/build_defs.bzl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""Helper definitions to glob .aar and .jar targets"""
2+
3+
def create_aar_targets(aarfiles):
4+
for aarfile in aarfiles:
5+
name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")]
6+
lib_deps.append(":" + name)
7+
android_prebuilt_aar(
8+
name = name,
9+
aar = aarfile,
10+
)
11+
12+
def create_jar_targets(jarfiles):
13+
for jarfile in jarfiles:
14+
name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")]
15+
lib_deps.append(":" + name)
16+
prebuilt_jar(
17+
name = name,
18+
binary_jar = jarfile,
19+
)

android/v8/proguard-rules.pro

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:

0 commit comments

Comments
 (0)