Skip to content

Commit

Permalink
Pass fabric_enabled flag to control whether to generate fabric compon…
Browse files Browse the repository at this point in the history
…ents

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
  • Loading branch information
sota000 authored and facebook-github-bot committed Nov 12, 2021
1 parent 5518b6d commit a44962f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions scripts/generate-artifacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand Down Expand Up @@ -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),
);
Expand Down
3 changes: 2 additions & 1 deletion scripts/react_native_pods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a44962f

Please sign in to comment.