Skip to content

Commit

Permalink
Cleanup the template documentation after RNGP & hermesEnabled to grad…
Browse files Browse the repository at this point in the history
…le.properties (#35108)

Summary:
Pull Request resolved: #35108

I've rewritten the comment in the android/app/build.gradle.
They were really old, contained wrong links and most of the people ignored it.

I've also moved the enabling of Hermes to the `gradle.properties` file.
RNGP still supports the old method, but we must be sure that we notify
library authors if they were reading project.ext.react.enableHermes in the past
(also the website needs to be updated).

I've also cleaned up the CircleCI setup as now we can specify Hermes enabled/disabled
via the CLI (this will also make easier to do e2e testing).

Changelog:
[Android] [Changed] - Cleanup the template documentation after RNGP & hermesEnabled to gradle.properties

Reviewed By: cipolleschi

Differential Revision: D40762872

fbshipit-source-id: 2c09245e0a923faac53cc6c8a89e99788ae47f8a
  • Loading branch information
cortinico authored and facebook-github-bot committed Oct 27, 2022
1 parent f550606 commit 6a43faf
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 256 deletions.
35 changes: 18 additions & 17 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -760,9 +760,11 @@ jobs:
description: The Android build type. Must be one of "Debug", "Release".
type: enum
enum: ["Debug", "Release"]
newarchitecture:
type: boolean
default: false
architecture:
default: "OldArch"
description: Which React Native architecture to use. Must be one of "NewArch", "OldArch".
type: enum
enum: [ "NewArch", "OldArch" ]
jsengine:
default: "Hermes"
description: Which JavaScript engine to use. Must be one of "Hermes", "JSC".
Expand All @@ -775,17 +777,6 @@ jobs:
- run_yarn
- attach_workspace:
at: .
- when:
condition:
equal: ["JSC", << parameters.jsengine >>]
steps:
- run:
name: Set enableHermes in buld.gradle to false
command: |
node ./scripts/set-rn-engine.js -e jsc
echo "Hermes disabled."
grep enableHermes: template/android/app/build.gradle
- run:
name: Create Android template project
command: |
Expand All @@ -796,10 +787,20 @@ jobs:
yarn
- run:
name: Build the template application for << parameters.flavor >> with New Architecture set to << parameters.newarchitecture >>, and using the << parameters.jsengine>> JS engine.
name: Build the template application for << parameters.flavor >> with Architecture set to << parameters.architecture >>, and using the << parameters.jsengine>> JS engine.
command: |
cd /tmp/$PROJECT_NAME/android/
./gradlew assemble<< parameters.flavor >> -PnewArchEnabled=<< parameters.newarchitecture >> -PREACT_NATIVE_MAVEN_LOCAL_REPO=/root/react-native/maven-local
if [[ << parameters.architecture >> == "NewArch" ]]; then
export ORG_GRADLE_PROJECT_newArchEnabled=true
else
export ORG_GRADLE_PROJECT_newArchEnabled=false
fi
if [[ << parameters.jsengine >> == "Hermes" ]]; then
export ORG_GRADLE_PROJECT_hermesEnabled=true
else
export ORG_GRADLE_PROJECT_hermesEnabled=false
fi
./gradlew assemble<< parameters.flavor >> -PREACT_NATIVE_MAVEN_LOCAL_REPO=/root/react-native/maven-local
# -------------------------
# JOBS: Test iOS Template
Expand Down Expand Up @@ -1602,7 +1603,7 @@ workflows:
- build_npm_package
matrix:
parameters:
newarchitecture: [true, false]
architecture: ["NewArch", "OldArch"]
jsengine: ["Hermes", "JSC"]
flavor: ["Debug", "Release"]
- test_buck
Expand Down
132 changes: 46 additions & 86 deletions packages/rn-tester/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,92 +11,57 @@ plugins {
}

/**
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
* and bundleReleaseJsAndAssets).
* These basically call `react-native bundle` with the correct arguments during the Android build
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
* bundle directly from the development server. Below you can see all the possible configurations
* and their defaults. If you decide to add a configuration block, make sure to add it before the
* `apply from: "react.gradle"` line.
*
* project.ext.react = [
* // the name of the generated asset file containing your JS bundle
* bundleAssetName: "index.android.bundle",
*
* // the entry file for bundle generation
* entryFile: "index.android.js",
*
* // whether to bundle JS and assets in debug mode
* bundleInDebug: false,
*
* // whether to bundle JS and assets in release mode
* bundleInRelease: true,
*
* // whether to bundle JS and assets in another build variant (if configured).
* // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
* // The configuration property is in the format 'bundleIn${productFlavor}${buildType}'
* // bundleInFreeDebug: true,
* // bundleInPaidRelease: true,
* // bundleInBeta: true,
*
* // the root of your project, i.e. where "package.json" lives
* root: "../../",
*
* // where to put the JS bundle asset in debug mode
* jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
*
* // where to put the JS bundle asset in release mode
* jsBundleDirRelease: "$buildDir/intermediates/assets/release",
*
* // where to put drawable resources / React Native assets, e.g. the ones you use via
* // require('./image.png')), in debug mode
* resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
*
* // where to put drawable resources / React Native assets, e.g. the ones you use via
* // require('./image.png')), in release mode
* resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
*
* // by default the gradle tasks are skipped if none of the JS files or assets change; this means
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
* // for example, you might want to remove it from here.
* inputExcludes: ["android/**", "ios/**"],
*
* // Root dir for all JS files for the app. Defaults to `root` above.
* jsRootDir: "../..",
*
* // Enable Fabric at runtime.
* enableFabric: true,
*
* // Java package name to use for any codegen artifacts produced during build time.
* // Defaults to "com.facebook.fbreact.specs".
* codegenJavaPackageName: "com.facebook.fbreact.specs",
* ]
* This is the configuration block to customize your React Native Android app.
* By default you don't need to apply any configuration, just uncomment the lines you need.
*/

react {
/* Folders */
// The root of your project, i.e. where "package.json" lives. Default is '..'
root = file("../../")
// The folder where the react-native NPM package is. Default is ../node_modules/react-native
reactNativeDir = rootDir
// The folder where the react-native Codegen package is. Default is ../node_modules/react-native-codegen
codegenDir = file("$rootDir/node_modules/react-native-codegen")
// The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
cliFile = file("$rootDir/cli.js")

/* Variants */
// The list of variants to that are debuggable. For those we're going to
// skip the bundling of the JS bundle and the assets. By default is just 'debug'.
// If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
debuggableVariants = ["hermesDebug", "jscDebug"]

/* Bundling */
// A list containing the node command and its flags. Default is just 'node'.
// nodeExecutableAndArgs = ["node"]
//
// The command to run when bundling. By default is 'bundle'
// bundleCommand = "ram-bundle"
//
// The path to the CLI configuration file. Default is empty.
// bundleConfig = file(../rn-cli.config.js)
//
// The name of the generated asset file containing your JS bundle
bundleAssetName = "RNTesterApp.android.bundle"
//
// The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
entryFile = file("../../js/RNTesterApp.android.js")
root = file("../../")
//
// A list of extra flags to pass to the 'bundle' commands.
// See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
// extraPackagerArgs = []

/* Hermes Commands */
// The hermes compiler command to run. By default it is 'hermesc'
hermesCommand = "$rootDir/ReactAndroid/hermes-engine/build/hermes/bin/hermesc"
debuggableVariants = ["hermesDebug", "jscDebug"]
enableHermesOnlyInVariants = ["hermesDebug", "hermesRelease"]

// Codegen Configs
reactNativeDir = rootDir
codegenDir = file("$rootDir/node_modules/react-native-codegen")
}

/**
* Set this to true to create three separate APKs instead of one:
* - A universal APK that works on all devices
* - An APK that only works on ARM devices
* - An APK that only works on x86 devices
* The advantage is the size of the APK is reduced by about 4MB.
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
* Set this to true to create four separate APKs instead of one,
* one for each native architecture. This is useful if you don't
* use App Bundles (https://developer.android.com/guide/app-bundle/)
* and want to have separate APKs to upload to the Play Store.
*/
def enableSeparateBuildPerCPUArchitecture = true

Expand All @@ -106,12 +71,11 @@ def enableSeparateBuildPerCPUArchitecture = true
def enableProguardInReleaseBuilds = true

/**
* Use the international variant of JavaScriptCore
* This variant includes the ICU i18n library to make APIs like `Date.toLocaleString`
* and `String.localeCompare` work when using with locales other than en-US.
* Note that this variant is about 6MiB larger per architecture than the default.
* The preferred build flavor of JavaScriptCore (JSC)
* For example, to use the international variant, you can use:
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
*/
def useIntlJsc = false
def jscFlavor = 'org.webkit:android-jsc:+'

/**
* Architectures to build native code for.
Expand Down Expand Up @@ -206,11 +170,7 @@ dependencies {
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}")
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")

if (useIntlJsc) {
jscImplementation 'org.webkit:android-jsc-intl:+'
} else {
jscImplementation 'org.webkit:android-jsc:+'
}
jscImplementation jscFlavor

androidTestImplementation 'junit:junit:4.12'
}
Expand Down
53 changes: 0 additions & 53 deletions scripts/set-rn-engine.js

This file was deleted.

Loading

0 comments on commit 6a43faf

Please sign in to comment.