Pass fabric_enabled flag to control whether to generate fabric components

Summary:
There will still be a case where this script is used when fabric is disabled. This diff adds the flag so that whether to generate fabric components can be controlled by the user.

Changelog: [internal]

Reviewed By: cortinico

Differential Revision: D32380881

fbshipit-source-id: 786931848b1eca5015c8f58f4361b395c8d341cc
This commit is contained in:
Sota Ogo 2021-11-12 08:27:00 -08:00 коммит произвёл Facebook GitHub Bot
Родитель 5518b6dc6f
Коммит a44962fbd3
2 изменённых файлов: 12 добавлений и 1 удалений

Просмотреть файл

@ -42,12 +42,19 @@ const argv = yargs
description:
'The key that contains the codegen configuration in the config file.',
})
.option('e', {
alias: 'fabricEnabled',
default: true,
description: 'A flag to control whether to generate fabric components.',
boolean: 'e',
})
.usage('Usage: $0 -p [path to app]')
.demandOption(['p']).argv;
const RN_ROOT = path.join(__dirname, '..');
const CODEGEN_CONFIG_FILENAME = argv.f;
const CODEGEN_CONFIG_KEY = argv.k;
const CODEGEN_FABRIC_ENABLED = argv.e;
const CODEGEN_REPO_PATH = `${RN_ROOT}/packages/react-native-codegen`;
const CODEGEN_NPM_PATH = `${RN_ROOT}/../react-native-codegen`;
const CORE_LIBRARIES = new Set(['rncore', 'FBReactNativeSpec']);
@ -157,6 +164,9 @@ function main(appRootDir, outputPath) {
// 5. For each codegen-enabled library, generate the native code spec files
libraries.forEach(library => {
if (!CODEGEN_FABRIC_ENABLED && library.config.type === 'components') {
return;
}
const tmpDir = fs.mkdtempSync(
path.join(os.tmpdir(), library.config.name),
);

Просмотреть файл

@ -286,8 +286,9 @@ def use_react_native_codegen_discovery!(options={})
Pod::UI.warn '[Codegen] warn: using experimental new codegen integration'
react_native_path = options[:react_native_path] ||= "../node_modules/react-native"
app_path = options[:app_path]
fabric_enabled = options[:fabric_enabled] ||= false
if app_path
Pod::Executable.execute_command('node', ["#{react_native_path}/scripts/generate-artifacts.js", "-p", "#{app_path}", "-o", Pod::Config.instance.installation_root])
Pod::Executable.execute_command('node', ["#{react_native_path}/scripts/generate-artifacts.js", "-p", "#{app_path}", "-o", Pod::Config.instance.installation_root, "-e", "#{fabric_enabled}"])
else
Pod::UI.warn '[Codegen] error: no app_path was provided'
exit 1