From a44962fbd39836a622960bda1399cb636198f8c4 Mon Sep 17 00:00:00 2001 From: Sota Ogo Date: Fri, 12 Nov 2021 08:27:00 -0800 Subject: [PATCH] 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 --- scripts/generate-artifacts.js | 10 ++++++++++ scripts/react_native_pods.rb | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/generate-artifacts.js b/scripts/generate-artifacts.js index 3982a5f40dcb12..2565bd50f87233 100644 --- a/scripts/generate-artifacts.js +++ b/scripts/generate-artifacts.js @@ -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), ); diff --git a/scripts/react_native_pods.rb b/scripts/react_native_pods.rb index 648892ae029ddf..57605c24412af6 100644 --- a/scripts/react_native_pods.rb +++ b/scripts/react_native_pods.rb @@ -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