mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Add option to force all codegen output into the provided directory (#55996)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/55996 Changelog: [Internal] Adds a new, optional, flag to the `generate-codegen-artifacts` script, which forces React Native Core artifacts to be generated in the output path set from the CLI instead of inside React Native. This will allow the C++ API snapshot generator to get entire codegen output for a given platform in a single place. Reviewed By: cipolleschi Differential Revision: D95788767 fbshipit-source-id: 36f8974ecb3aedbe27dd3bc246c09a80051ff67c
This commit is contained in:
1 parent
7d80d6e5a1
commit
01629586df
3 files changed
+34
-5
No files matched your search
+12
-3
@@ -22,9 +22,16 @@ function generateNativeCode(
|
||||
schemaInfos /*: $ReadOnlyArray<$FlowFixMe> */,
|
||||
includesGeneratedCode /*: boolean */,
|
||||
platform /*: string */,
|
||||
forceOutputPath /*: boolean */ = false,
|
||||
) /*: Array<void> */ {
|
||||
return schemaInfos.map(schemaInfo => {
|
||||
generateCode(outputPath, schemaInfo, includesGeneratedCode, platform);
|
||||
generateCode(
|
||||
outputPath,
|
||||
schemaInfo,
|
||||
includesGeneratedCode,
|
||||
platform,
|
||||
forceOutputPath,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -33,6 +40,7 @@ function generateCode(
|
||||
schemaInfo /*: $FlowFixMe */,
|
||||
includesGeneratedCode /*: boolean */,
|
||||
platform /*: string */,
|
||||
forceOutputPath /*: boolean */ = false,
|
||||
) {
|
||||
if (shouldSkipGenerationForFBReactNativeSpec(schemaInfo, platform)) {
|
||||
codegenLog(
|
||||
@@ -60,8 +68,9 @@ function generateCode(
|
||||
);
|
||||
|
||||
// Finally, copy artifacts to the final output directory.
|
||||
const outputDir =
|
||||
reactNativeCoreLibraryOutputPath(libraryName, platform) ?? outputPath;
|
||||
const outputDir = forceOutputPath
|
||||
? outputPath
|
||||
: (reactNativeCoreLibraryOutputPath(libraryName, platform) ?? outputPath);
|
||||
fs.mkdirSync(outputDir, {recursive: true});
|
||||
cpSyncRecursiveIfChanged(tmpOutputDir, outputDir);
|
||||
codegenLog(`Generated artifacts: ${outputDir}`);
|
||||
|
||||
@@ -66,6 +66,7 @@ function execute(
|
||||
optionalBaseOutputPath /*: ?string */,
|
||||
source /*: string */,
|
||||
runReactNativeCodegen /*: boolean */ = true,
|
||||
forceOutputPath /*: boolean */ = false,
|
||||
) {
|
||||
try {
|
||||
codegenLog(`Analyzing ${path.join(projectRoot, 'package.json')}`);
|
||||
@@ -146,6 +147,7 @@ function execute(
|
||||
),
|
||||
pkgJsonIncludesGeneratedCode(pkgJson),
|
||||
platform,
|
||||
forceOutputPath,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+20
-2
@@ -31,8 +31,26 @@ const argv = yargs
|
||||
description: 'Whether the script is invoked from an `app` or a `library`',
|
||||
default: 'app',
|
||||
})
|
||||
.option('f', {
|
||||
alias: 'forceOutputPath',
|
||||
description:
|
||||
'Whether to force React Native Core artifacts to output to the specified path',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
})
|
||||
.usage('Usage: $0 -p [path to app] -t [target platform] -o [output path]')
|
||||
.demandOption(['p', 't']).argv;
|
||||
|
||||
// $FlowFixMe[prop-missing]
|
||||
executor.execute(argv.path, argv.targetPlatform, argv.outputPath, argv.source);
|
||||
executor.execute(
|
||||
// $FlowFixMe[prop-missing]
|
||||
argv.path,
|
||||
// $FlowFixMe[prop-missing]
|
||||
argv.targetPlatform,
|
||||
// $FlowFixMe[prop-missing]
|
||||
argv.outputPath,
|
||||
// $FlowFixMe[prop-missing]
|
||||
argv.source,
|
||||
true, // runReactNativeCodegen
|
||||
// $FlowFixMe[prop-missing]
|
||||
argv.forceOutputPath,
|
||||
);
|
||||
Reference in new issue
Block a user