Files
react-native/scripts/set-rn-engine.js
T
Vincenzo Vitale 90e7f510dc Test the Android Template with the JSC engine (#34664)
Summary:
https://www.internalfb.com/T131530362

We are testing the New App template in CircleCI.

For Android we test the combination of Debug/Release and Old/New Architecture, and always use the Hermes engine.
We don't test the JSC engines (in iOS this is already happening).

We're not automatically testing that we can create a new project with JSC, forcing release managers to do it manually.

## Changelog

[Android] [Added] - Automatic testing of the new project template with the JSC engine.

Pull Request resolved: https://github.com/facebook/react-native/pull/34664

Test Plan:
- Open the circle-ci dashboard
- Verify there are now 8 jobs adeed to the pipeline:
```
test_android_template-Debug-Hermes-false
test_android_template-Debug-Hermes-true
test_android_template-Debug-JSC-false
test_android_template-Debug-JSC-true
test_android_template-Release-Hermes-false
test_android_template-Release-Hermes-true
test_android_template-Release-JSC-false
test_android_template-Release-JSC-true
```
- Verify they are all passing.

Reviewed By: cortinico

Differential Revision: D39426388

Pulled By: vincenzovitale

fbshipit-source-id: e5d606b1cc3ace53f8dab0f7d6d7d06ab11a2b46
2022-09-12 12:33:07 -07:00

54 lines
1.2 KiB
JavaScript
Executable File

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
'use strict';
/**
* This script updates the engine used by React Native
*/
const {echo, exec, exit, sed} = require('shelljs');
const yargs = require('yargs');
let argv = yargs.option('e', {
alias: 'engine',
describe: 'Choose an engine',
type: 'string',
choices: ['hermes', 'jsc'],
}).argv;
const engine = argv.engine;
if (!engine) {
echo('You must specify an engine using -e');
exit(1);
}
// Change the template build.gradle
sed(
'-i',
/enableHermes:.*/,
engine === 'jsc' ? 'enableHermes: false' : 'enableHermes: true',
'template/android/app/build.gradle',
);
// Validate the hermes flag has been changed properly
const hermes =
exec(
'grep enableHermes: template/android/app/build.gradle | awk \'{split($0,a,"[:,]"); print a[2]}\'',
{silent: true},
).stdout.trim() === 'true';
if ((engine === 'jsc' && hermes) || (engine === 'hermes' && !hermes)) {
echo('Failed to update the engine in template/android/app/build.gradle');
echo('Fix the issue and try again');
exit(1);
}
exit(0);