Skip to content

Commit

Permalink
Generate an empty ThirdPartyFabricComponentProvider when codegen disc…
Browse files Browse the repository at this point in the history
…overy isn't enabled

Summary:
This diff adds a support to generate ThirdPartyFabricComponentProvider when codegen discovery isn't enabled. This functionality will be removed when we start using the new way of generating code as a default.

Changelog: [internal]

Reviewed By: fkgozali

Differential Revision: D32420306

fbshipit-source-id: 219bcdf6cb186196ca62e651086dedab485b063e
  • Loading branch information
sota000 authored and facebook-github-bot committed Nov 17, 2021
1 parent aabf7f7 commit 3d8b5a3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/rn-tester/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ SPEC CHECKSUMS:
RCTTypeSafety: c7a7f67ae5b1b986b78d817baa408fc984ab7c0c
React: f64c9f6db5428717922a3292ba6a448615a2e143
React-callinvoker: c5d61e29df57793f0dc10ec2bc01c846f863e51f
React-Codegen: 5c20632d128f21b4b94d00d70690821a8ac5dbef
React-Codegen: 2256e335ccce7326eeca6d7a668e05c4de259289
React-Core: 22bc86b79dd931dbfb7fd2af91a35a98d41ceb64
React-CoreModules: a8e2bdc1ebbf8d440478456197abd58d1691f61a
React-cxxreact: cfc1663dae1ea52b465bbf021ef7b1527c5dc80c
Expand Down
34 changes: 33 additions & 1 deletion scripts/react_native_pods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def use_react_native! (options={})
pod temp_podinfo['spec']['name'], :path => temp_podinfo['path']

if fabric_enabled
checkAndGenerateEmptyThirdPartyProvider!(prefix)
pod 'React-Fabric', :path => "#{prefix}/ReactCommon"
pod 'React-rncore', :path => "#{prefix}/ReactCommon"
pod 'React-graphics', :path => "#{prefix}/ReactCommon/react/renderer/graphics"
Expand Down Expand Up @@ -201,6 +202,36 @@ def react_native_post_install(installer)
fix_library_search_paths(installer)
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'

relative_installation_root = Pod::Config.instance.installation_root.relative_path_from(Pathname.pwd)
output_dir = "#{relative_installation_root}/#{$CODEGEN_OUTPUT_DIR}"

provider_h_path = "#{output_dir}/RCTThirdPartyFabricComponentsProvider.h"
provider_cpp_path ="#{output_dir}/RCTThirdPartyFabricComponentsProvider.cpp"

if(!File.exist?(provider_h_path) || !File.exist?(provider_cpp_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|
f.write('[]')
f.fsync
end

Pod::UI.puts '[Codegen] generating an empty RCTThirdPartyFabricComponentsProvider'
Pod::Executable.execute_command(
'node',
[
"#{react_native_path}/scripts/generate-provider-cli.js",
"--platform", 'ios',
"--schemaListPath", temp_schema_list_path,
"--outputDir", "#{output_dir}"
])
File.delete(temp_schema_list_path) if File.exist?(temp_schema_list_path)
end
end

def generate_temp_pod_spec_for_codegen!(fabric_enabled)
relative_installation_root = Pod::Config.instance.installation_root.relative_path_from(Pathname.pwd)
Expand Down Expand Up @@ -243,7 +274,8 @@ def generate_temp_pod_spec_for_codegen!(fabric_enabled)
"\"$(PODS_ROOT)/boost\"",
"\"$(PODS_ROOT)/RCT-Folly\"",
"\"${PODS_ROOT}/Headers/Public/React-Codegen/react/renderer/components\"",
"\"$(PODS_ROOT)/Headers/Private/React-Fabric\""
"\"$(PODS_ROOT)/Headers/Private/React-Fabric\"",
"\"$(PODS_ROOT)/Headers/Private/React-RCTFabric\"",
].join(' ')
},
'dependencies': {
Expand Down

0 comments on commit 3d8b5a3

Please sign in to comment.