forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrate Native Module codegen into Xcode build pipeline (facebook#3…
…0449) Summary: Move the codegen invocation out of Podfiles and into the FBReactNativeSpec Pod itself. With this change, developers do not need to modify their existing project's Podfiles, and yet the codegen will be integrated into their projects automatically by way of the FBReactNativeSpec Pod. This is accomplished in part by injecting a script build phase into the Pods Xcode project that is generated by CocoaPods. The build phase will be executed if the generated FBReactNativeSpec{.h, -generated.mm} files are not present, or if the contents of the Libraries directory has changed. The codegen is also triggered by `pod install` via `prepare_command`. The codegen will thus be invoked in these situations: **RNTester:** * When `pod install` is invoked in `packages/rn-tester/` (`prepare_command`) * When `packages/rn-tester/RNTesterPods.xcworkspace` is built, if the output files are not present or if the input files have changed (`script_phase`). **OSS React Native apps:** * When `pod install` is invoked in `ios/` (`prepare_command`) * When `ios/AwesomeProject.xcworkspace` is built, if the output files are not present or if the input files have changed (`script_phase`). Pull Request resolved: facebook#30449 Changelog: [Internal] - Moved codegen invocation out of Podfile and into FBReactNativeSpec Pod Differential Revision: D25138896 fbshipit-source-id: 753ef8d3514f090774e7b50b38987ed559ac7467
- Loading branch information
1 parent
ae6f4f3
commit 4f7ed2b
Showing
7 changed files
with
60 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/ruby | ||
# Copyright (c) Facebook, Inc. and its affiliates. | ||
# | ||
# This source code is licensed under the MIT license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
require 'tmpdir' | ||
|
||
# Handle Core Modules | ||
def codegen_core_modules(codegenPath) | ||
reactNativePath = File.join(__dir__, "..") | ||
srcsDir = File.join(reactNativePath, "Libraries") | ||
libraryName = "FBReactNativeSpec" | ||
outputDir = File.join(srcsDir, libraryName, libraryName) | ||
|
||
codegen(codegenPath, srcsDir, libraryName, outputDir) | ||
end | ||
|
||
def codegen(codegenPath, srcsDir, libraryName, outputDir) | ||
Dir.mktmpdir do |dir| | ||
schemaFilePath = File.join(dir, "schema-#{libraryName}.json") | ||
combineCliPath = File.join(codegenPath, "lib", "cli", "combine", "combine-js-to-schema-cli.js") | ||
generateSpecsCliPath = File.join(__dir__, "generate-native-modules-specs-cli.js") | ||
system("node #{combineCliPath} #{schemaFilePath} #{srcsDir}") or raise "Could not generate Native Module schema" | ||
system("node #{generateSpecsCliPath} ios #{schemaFilePath} #{outputDir} #{libraryName}") or raise "Could not generate code for #{libraryName}" | ||
end | ||
end | ||
|
||
def main() | ||
codegenPath = ENV["CODEGEN_PATH"] ||= File.join(reactNativePath, "..", "react-native-codegen") | ||
codegen_core_modules(codegenPath) | ||
end | ||
|
||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters