Build codegen package in pod install (#32678)

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

In D32420306 (3d8b5a35f9) (3d8b5a35f9), I added a phase which uses a codegen, but it assumed that the codegen package has already been built. This diff fixes the issue where it checks and build the codegen packaage.

I also reverted the change that I made for the circle CI test since it now builds the codegen when running pod install.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D32707588

fbshipit-source-id: a287ff96e8123833da093228fe60e2069884eb45
This commit is contained in:
Sota Ogo 2021-11-30 17:09:24 -08:00 committed by Facebook GitHub Bot
parent 94abcffe2f
commit 363ff5c0fc
3 changed files with 24 additions and 10 deletions

View File

@ -92,12 +92,6 @@ commands:
- ~/.cache/yarn
key: v4-yarn-cache-{{ arch }}-{{ checksum "yarn.lock" }}
build_codegen:
steps:
- run:
name: "Codegen: Build react-native-codegen package"
command: cd packages/react-native-codegen && yarn build
install_buck_tooling:
steps:
- restore_cache:
@ -373,7 +367,6 @@ jobs:
- setup_artifacts
- setup_ruby
- run_yarn
- build_codegen
- run: |
cd packages/rn-tester

View File

@ -881,7 +881,7 @@ SPEC CHECKSUMS:
CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99
DoubleConversion: 831926d9b8bf8166fd87886c4abab286c2422662
FBLazyVector: b81a2b70c72d8b0aefb652cea22c11e9ffd02949
FBReactNativeSpec: d297498b40da6673284de825e985e66f8da1064e
FBReactNativeSpec: 755b7fee1b08aefd74fb2fa9f7312b253719d536
Flipper: 30e8eeeed6abdc98edaf32af0cda2f198be4b733
Flipper-Boost-iOSX: fd1e2b8cbef7e662a122412d7ac5f5bea715403c
Flipper-DoubleConversion: 57ffbe81ef95306cc9e69c4aa3aeeeeb58a6a28c
@ -923,10 +923,10 @@ SPEC CHECKSUMS:
React-RCTTest: 12bbd7fc2e72bd9920dc7286c5b8ef96639582b6
React-RCTText: e9146b2c0550a83d1335bfe2553760070a2d75c7
React-RCTVibration: 50be9c390f2da76045ef0dfdefa18b9cf9f35cfa
React-rncore: 8b90ee397e8a5730c2819b083def06bf94e593ba
React-rncore: d09af3a25cbff0b484776785676c28f3729e07f5
React-runtimeexecutor: 4b0c6eb341c7d3ceb5e2385cb0fdb9bf701024f3
ReactCommon: 7a2714d1128f965392b6f99a8b390e3aa38c9569
ScreenshotManager: 4d1f5c3330ef0a096bb560457f51238ed133688e
ScreenshotManager: e8a3fc9b2e24b81127b36cb4ebe0eed65090c949
Yoga: c0d06f5380d34e939f55420669a60fe08b79bd75
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a

View File

@ -202,6 +202,24 @@ def react_native_post_install(installer)
fix_library_search_paths(installer)
end
def build_codegen!(react_native_path)
codegen_repo_path = "#{react_native_path}/packages/react-native-codegen";
codegen_npm_path = "#{react_native_path}/../react-native-codegen";
codegen_cli_path = ""
if Dir.exist?(codegen_repo_path)
codegen_cli_path = codegen_repo_path
elsif Dir.exist?(codegen_npm_path)
codegen_cli_path = codegen_npm_path
else
raise "[codegen] Couldn't not find react-native-codegen."
end
if !Dir.exist?("#{codegen_cli_path}/lib")
Pod::UI.puts "[Codegen] building #{codegen_cli_path}."
system("#{codegen_cli_path}/scripts/oss/build.sh")
end
end
# This is a temporary supporting function until we enable use_react_native_codegen_discovery by default.
def checkAndGenerateEmptyThirdPartyProvider!(react_native_path)
return if ENV['USE_CODEGEN_DISCOVERY'] == '1'
@ -213,6 +231,9 @@ def checkAndGenerateEmptyThirdPartyProvider!(react_native_path)
provider_cpp_path ="#{output_dir}/RCTThirdPartyFabricComponentsProvider.cpp"
if(!File.exist?(provider_h_path) || !File.exist?(provider_cpp_path))
# build codegen
build_codegen!(react_native_path)
# Just use a temp empty schema list.
temp_schema_list_path = "#{output_dir}/tmpSchemaList.txt"
File.open(temp_schema_list_path, 'w') do |f|