Update CodeGen to leverage the outputDir as suggested in diff review (#33729)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33729

This PR addresses [this comment](https://www.internalfb.com/diff/D35820848?dst_version_fbid=496290878846487&transaction_fbid=355967423221044).

It makes the CodeGen to the `outputDir` as base directory for the codegen.

Finally, it updates the unit tests accordingly.

## Changelog
[iOS][Changed] - use `outputDir` as base directory for the codegen and remove the possibility to customize the intermediate path. The generated code requires specific paths in the `#include` directive.

Reviewed By: cortinico, dmitryrykun

Differential Revision: D35935282

fbshipit-source-id: a9ad4e296efb042cf34b20db5eebb59614beb5f6
This commit is contained in:
Riccardo Cipolleschi
2022-05-04 04:04:10 -07:00
committed by Facebook GitHub Bot
parent 0465c3fd10
commit e4d0153a67
11 changed files with 68 additions and 128 deletions
+11 -11
View File
@@ -30,10 +30,7 @@ const GENERATORS = {
},
};
function deprecated_createOutputDirectoryIfNeeded(
outputDirectory,
libraryName,
) {
function createOutputDirectoryIfNeeded(outputDirectory, libraryName) {
if (!outputDirectory) {
outputDirectory = path.resolve(__dirname, '..', 'Libraries', libraryName);
}
@@ -81,16 +78,21 @@ function generateSpec(
libraryName,
packageName,
libraryType,
componentsOutputDir,
modulesOutputDir,
) {
validateLibraryType(libraryType);
let schema = readAndParseSchema(schemaPath);
createFolderIfDefined(componentsOutputDir);
createFolderIfDefined(modulesOutputDir);
deprecated_createOutputDirectoryIfNeeded(outputDirectory, libraryName);
createOutputDirectoryIfNeeded(outputDirectory, libraryName);
function composePath(intermediate) {
return path.join(outputDirectory, intermediate, libraryName);
}
// These are hardcoded and should not be changed.
// The codegen creates some C++ code with #include directive
// which uses these paths. Those directive are not customizable yet.
createFolderIfDefined(composePath('react/renderer/components/'));
createFolderIfDefined(composePath('./'));
RNCodegen.generate(
{
@@ -98,8 +100,6 @@ function generateSpec(
schema,
outputDirectory,
packageName,
componentsOutputDir,
modulesOutputDir,
},
{
generators: GENERATORS[libraryType][platform],