Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
});
}

Expand All @@ -33,6 +40,7 @@ function generateCode(
schemaInfo /*: $FlowFixMe */,
includesGeneratedCode /*: boolean */,
platform /*: string */,
forceOutputPath /*: boolean */ = false,
) {
if (shouldSkipGenerationForFBReactNativeSpec(schemaInfo, platform)) {
codegenLog(
Expand Down Expand Up @@ -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}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ function execute(
optionalBaseOutputPath /*: ?string */,
source /*: string */,
runReactNativeCodegen /*: boolean */ = true,
forceOutputPath /*: boolean */ = false,
) {
try {
codegenLog(`Analyzing ${path.join(projectRoot, 'package.json')}`);
Expand Down Expand Up @@ -146,6 +147,7 @@ function execute(
),
pkgJsonIncludesGeneratedCode(pkgJson),
platform,
forceOutputPath,
);
}

Expand Down
22 changes: 20 additions & 2 deletions packages/react-native/scripts/generate-codegen-artifacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Loading