Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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 @@ -100,20 +100,28 @@ function cleanupEmptyFilesAndFolders(filepath /*: string */) {
function readGeneratedAutolinkingOutput(
baseOutputPath /*: string */,
) /*: $FlowFixMe */ {
// NOTE: Generated by scripts/cocoapods/autolinking.rb in list_native_modules (called by use_native_modules)
const autolinkingGeneratedPath = path.resolve(
const outputPathCandidates = [
// The `outputDir` may not be set correctly if it's set to the a temporary output directory
process.env.RCT_SCRIPT_OUTPUT_DIR,
// NOTE: Generated by scripts/cocoapods/autolinking.rb in list_native_modules (called by use_native_modules)
baseOutputPath,
'build/generated/autolinking/autolinking.json',
);
if (fs.existsSync(autolinkingGeneratedPath)) {
// $FlowFixMe[unsupported-syntax]
return require(autolinkingGeneratedPath);
} else {
codegenLog(
`Could not find generated autolinking output at: ${autolinkingGeneratedPath}`,
);
return null;
];
for (const outputPathCandidate of outputPathCandidates) {
if (outputPathCandidate != null && outputPathCandidate.length > 0) {
const autolinkingGeneratedPath = path.resolve(
outputPathCandidate,
'build/generated/autolinking/autolinking.json',
);
if (fs.existsSync(autolinkingGeneratedPath)) {
// $FlowFixMe[unsupported-syntax]
return require(autolinkingGeneratedPath);
}
codegenLog(
`Could not find generated autolinking output at: ${autolinkingGeneratedPath}`,
);
}
}
return null;
}

function readReactNativeConfig(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,6 @@ generateCodegenArtifactsFromSchema () {
popd >/dev/null || exit 1
}

generateArtifacts () {
describe "Generating codegen artifacts"
pushd "$RCT_SCRIPT_RN_DIR" >/dev/null || exit 1
"$NODE_BINARY" "scripts/generate-codegen-artifacts.js" --path "$RCT_SCRIPT_APP_PATH" --outputPath "$TEMP_OUTPUT_DIR" --targetPlatform "ios"
popd >/dev/null || exit 1
}

moveOutputs () {
mkdir -p "$RCT_SCRIPT_OUTPUT_DIR"

Expand All @@ -110,22 +103,21 @@ moveOutputs () {
}

withCodegenDiscovery () {
setup_dirs
find_node
find_codegen
generateArtifacts
moveOutputs
describe "Generating codegen artifacts"
pushd "$RCT_SCRIPT_RN_DIR" >/dev/null || exit 1
"$NODE_BINARY" "scripts/generate-codegen-artifacts.js" --path "$RCT_SCRIPT_APP_PATH" --outputPath "$RCT_SCRIPT_OUTPUT_DIR" --targetPlatform "ios"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value of RCT_SCRIPT_OUTPUT_DIR is always RCT_SCRIPT_POD_INSTALLATION_ROOT, which is set to be

pushd "$PODS_ROOT/../" > /dev/null
RCT_SCRIPT_POD_INSTALLATION_ROOT=$(pwd)

So it will always be Pods/.., which is where we want codegen to be generated.
Just adding the comment for the future.

popd >/dev/null || exit 1
}

noCodegenDiscovery () {
setup_dirs
find_node
find_codegen
generateCodegenSchemaFromJavaScript
generateCodegenArtifactsFromSchema
moveOutputs
}

find_node
find_codegen
if [ "$RCT_SCRIPT_TYPE" = "withCodegenDiscovery" ]; then
withCodegenDiscovery "$@"
else
Expand Down
Loading