From ab7b4d4cd89cf6a7cb76d2b6a60163919cc3c689 Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Mon, 31 Oct 2022 12:31:00 -0700 Subject: [PATCH] Restore Filtering platform in codegen (#35028) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/35028 **This Diff require a bump in the react-native-codegen (including this [commit](https://github.com/facebook/react-native/commit/7680bdeb4f96a8092393372a59c77a9d7b729cae)) to work** This diff sets up iOS and Android to pass their platform to the codegen so that we can have platform-specific specs. ## Changelog [General][Added] - Enable platform-specific Codegen Specs Reviewed By: cortinico Differential Revision: D40516395 fbshipit-source-id: 0624f0bfb93c90f78131a605a4847e780783bbaf --- .../com/facebook/react/tasks/GenerateCodegenSchemaTask.kt | 5 ++--- .../facebook/react/tasks/GenerateCodegenSchemaTaskTest.kt | 6 +++--- scripts/codegen/generate-artifacts-executor.js | 3 +-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GenerateCodegenSchemaTask.kt b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GenerateCodegenSchemaTask.kt index b86b2e2b1299f7..d72bc0a379f214 100644 --- a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GenerateCodegenSchemaTask.kt +++ b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GenerateCodegenSchemaTask.kt @@ -63,7 +63,6 @@ abstract class GenerateCodegenSchemaTask : Exec() { } internal fun setupCommandLine() { - // TODO: restore the --platform android parameters as soon as we publish the codegen package. commandLine( windowsAwareCommandLine( *nodeExecutableAndArgs.get().toTypedArray(), @@ -72,8 +71,8 @@ abstract class GenerateCodegenSchemaTask : Exec() { .get() .asFile .absolutePath, - // "--platform", - // "android", + "--platform", + "android", generatedSchemaFile.get().asFile.absolutePath, jsRootDir.asFile.get().absolutePath, )) diff --git a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GenerateCodegenSchemaTaskTest.kt b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GenerateCodegenSchemaTaskTest.kt index bf546613fabf9b..98e2b39795c1cb 100644 --- a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GenerateCodegenSchemaTaskTest.kt +++ b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GenerateCodegenSchemaTaskTest.kt @@ -144,13 +144,13 @@ class GenerateCodegenSchemaTaskTest { } task.setupCommandLine() - // TODO: restore the --platform android parameters as soon as we publish the codegen package. + assertEquals( listOf( "--verbose", File(codegenDir, "lib/cli/combine/combine-js-to-schema-cli.js").toString(), - // "--platform", - // "android", + "--platform", + "android", File(outputDir, "schema.json").toString(), jsRootDir.toString(), ), diff --git a/scripts/codegen/generate-artifacts-executor.js b/scripts/codegen/generate-artifacts-executor.js index d51bceb8c811fe..68a47b6fab5bf9 100644 --- a/scripts/codegen/generate-artifacts-executor.js +++ b/scripts/codegen/generate-artifacts-executor.js @@ -311,7 +311,6 @@ function generateSchema(tmpDir, library, node, codegenCliPath) { console.log(`\n\n[Codegen] >>>>> Processing ${library.config.name}`); // Generate one schema for the entire library... - // TODO: restore the `--platform ios` parameters as soon as we publish the codegen package. executeNodeScript( node, `${path.join( @@ -320,7 +319,7 @@ function generateSchema(tmpDir, library, node, codegenCliPath) { 'cli', 'combine', 'combine-js-to-schema-cli.js', - )} ${pathToSchema} ${pathToJavaScriptSources}`, + )} --platform ios ${pathToSchema} ${pathToJavaScriptSources}`, ); console.log(`[Codegen] Generated schema: ${pathToSchema}`); return pathToSchema;