33# This source code is licensed under the MIT license found in the
44# LICENSE file in the root directory of this source tree.
55
6- require 'net/http'
7- require 'rexml/document'
8-
96HERMES_GITHUB_URL = "https://github.com/facebook/hermes.git"
107ENV_BUILD_FROM_SOURCE = "RCT_BUILD_HERMES_FROM_SOURCE"
118
129module HermesEngineSourceType
1310 LOCAL_PREBUILT_TARBALL = :local_prebuilt_tarball
1411 DOWNLOAD_PREBUILD_RELEASE_TARBALL = :download_prebuild_release_tarball
15- DOWNLOAD_PREBUILT_NIGHTLY_TARBALL = :download_prebuilt_nightly_tarball
1612 BUILD_FROM_GITHUB_COMMIT = :build_from_github_commit
1713 BUILD_FROM_GITHUB_TAG = :build_from_github_tag
18- BUILD_FROM_GITHUB_MAIN = :build_from_github_main
14+ BUILD_FROM_GITHUB_STABLE_BRANCH = :build_from_github_stable_branch
1915 BUILD_FROM_LOCAL_SOURCE_DIR = :build_from_local_source_dir
2016
2117 def HermesEngineSourceType . isPrebuilt ( source_type )
22- return source_type == LOCAL_PREBUILT_TARBALL || source_type == DOWNLOAD_PREBUILD_RELEASE_TARBALL || source_type == DOWNLOAD_PREBUILT_NIGHTLY_TARBALL
18+ return source_type == LOCAL_PREBUILT_TARBALL || source_type == DOWNLOAD_PREBUILD_RELEASE_TARBALL
2319 end
2420
2521 def HermesEngineSourceType . isFromSource ( source_type )
26- return source_type == BUILD_FROM_GITHUB_COMMIT || source_type == BUILD_FROM_GITHUB_TAG || source_type == BUILD_FROM_GITHUB_MAIN || source_type == BUILD_FROM_LOCAL_SOURCE_DIR
22+ return source_type == BUILD_FROM_GITHUB_COMMIT || source_type == BUILD_FROM_GITHUB_TAG || source_type == BUILD_FROM_GITHUB_STABLE_BRANCH || source_type == BUILD_FROM_LOCAL_SOURCE_DIR
2723 end
2824end
2925
@@ -32,8 +28,9 @@ def HermesEngineSourceType.isFromSource(source_type)
3228# `HERMES_ENGINE_TARBALL_PATH=<path_to_tarball> bundle exec pod install`
3329# - To force a build from source, install the dependencies with:
3430# `RCT_BUILD_HERMES_FROM_SOURCE=true bundle exec pod install`
35- # If none of the two are provided, Cocoapods will check whether there is a tarball for the current version
36- # (either release or nightly). If not, it will fall back to building from source (the latest commit on main).
31+ # If none of the two are provided, Cocoapods will check whether there is a
32+ # release tarball for the current version on Maven. If not, it will fall back
33+ # to building from the stable Hermes branch.
3734#
3835# Parameters:
3936# - version: current version of the pod
@@ -58,19 +55,15 @@ def hermes_source_type(version, react_native_path)
5855 return HermesEngineSourceType ::BUILD_FROM_GITHUB_TAG
5956 end
6057
61- if force_build_from_main ( react_native_path )
62- return HermesEngineSourceType ::BUILD_FROM_GITHUB_MAIN
58+ if force_build_from_stable_branch ( react_native_path )
59+ return HermesEngineSourceType ::BUILD_FROM_GITHUB_STABLE_BRANCH
6360 end
6461
6562 if release_artifact_exists ( version )
6663 return HermesEngineSourceType ::DOWNLOAD_PREBUILD_RELEASE_TARBALL
6764 end
6865
69- if nightly_artifact_exists ( version )
70- return HermesEngineSourceType ::DOWNLOAD_PREBUILT_NIGHTLY_TARBALL
71- end
72-
73- return HermesEngineSourceType ::BUILD_FROM_GITHUB_MAIN
66+ return HermesEngineSourceType ::BUILD_FROM_GITHUB_STABLE_BRANCH
7467end
7568
7669def override_hermes_dir_envvar_defined ( )
@@ -89,18 +82,14 @@ def force_build_from_tag(react_native_path)
8982 return ENV [ ENV_BUILD_FROM_SOURCE ] === 'true' && File . exist? ( hermestag_file ( react_native_path ) )
9083end
9184
92- def force_build_from_main ( react_native_path )
85+ def force_build_from_stable_branch ( react_native_path )
9386 return ENV [ ENV_BUILD_FROM_SOURCE ] === 'true' && !File . exist? ( hermestag_file ( react_native_path ) )
9487end
9588
9689def release_artifact_exists ( version )
9790 return hermes_artifact_exists ( release_tarball_url ( version , :debug ) )
9891end
9992
100- def nightly_artifact_exists ( version )
101- return hermes_artifact_exists ( nightly_tarball_url ( version ) . gsub ( "\\ " , "" ) )
102- end
103-
10493def podspec_source ( source_type , version , react_native_path )
10594 case source_type
10695 when HermesEngineSourceType ::BUILD_FROM_LOCAL_SOURCE_DIR
@@ -111,12 +100,10 @@ def podspec_source(source_type, version, react_native_path)
111100 return podspec_source_build_from_github_commit ( )
112101 when HermesEngineSourceType ::BUILD_FROM_GITHUB_TAG
113102 return podspec_source_build_from_github_tag ( react_native_path )
114- when HermesEngineSourceType ::BUILD_FROM_GITHUB_MAIN
115- return podspec_source_build_from_github_main ( )
103+ when HermesEngineSourceType ::BUILD_FROM_GITHUB_STABLE_BRANCH
104+ return podspec_source_build_from_github_stable_branch ( )
116105 when HermesEngineSourceType ::DOWNLOAD_PREBUILD_RELEASE_TARBALL
117106 return podspec_source_download_prebuild_release_tarball ( react_native_path , version )
118- when HermesEngineSourceType ::DOWNLOAD_PREBUILT_NIGHTLY_TARBALL
119- return podspec_source_download_prebuilt_nightly_tarball ( version )
120107 else
121108 abort "[Hermes] Unsupported or invalid source type provided: #{ source_type } "
122109 end
@@ -175,10 +162,11 @@ def podspec_source_build_from_github_tag(react_native_path)
175162 return { :git => HERMES_GITHUB_URL , :tag => tag }
176163end
177164
178- def podspec_source_build_from_github_main ( )
179- branch = "250829098.0.0-stable"
180- hermes_log ( "Using the latest commit from #{ branch } ." )
181- return { :git => HERMES_GITHUB_URL , :commit => `git ls-remote #{ HERMES_GITHUB_URL } #{ branch } | cut -f 1` . strip }
165+ HERMES_STABLE_BRANCH = "250829098.0.0-stable"
166+
167+ def podspec_source_build_from_github_stable_branch ( )
168+ hermes_log ( "Using the latest commit from #{ HERMES_STABLE_BRANCH } ." )
169+ return { :git => HERMES_GITHUB_URL , :commit => `git ls-remote #{ HERMES_GITHUB_URL } #{ HERMES_STABLE_BRANCH } | cut -f 1` . strip }
182170end
183171
184172def podspec_source_download_prebuild_release_tarball ( react_native_path , version )
@@ -189,12 +177,6 @@ def podspec_source_download_prebuild_release_tarball(react_native_path, version)
189177 return { :http => url }
190178end
191179
192- def podspec_source_download_prebuilt_nightly_tarball ( version )
193- url = nightly_tarball_url ( version )
194- hermes_log ( "Using nightly tarball from URL: #{ url } " )
195- return { :http => url }
196- end
197-
198180# HELPERS
199181
200182def artifacts_dir ( )
@@ -237,31 +219,6 @@ def download_hermes_tarball(react_native_path, tarball_url, version, configurati
237219 return destination_path
238220end
239221
240- def nightly_tarball_url ( version )
241- artifact_coordinate = "hermes-ios"
242- artifact_name = "hermes-ios-debug.tar.gz"
243- namespace = "com/facebook/hermes"
244-
245- xml_url = "https://central.sonatype.com/repository/maven-snapshots/#{ namespace } /#{ artifact_coordinate } /#{ version } -SNAPSHOT/maven-metadata.xml"
246-
247- begin
248- response = Net ::HTTP . get_response ( URI ( xml_url ) )
249- if response . is_a? ( Net ::HTTPSuccess )
250- xml = REXML ::Document . new ( response . body )
251- timestamp = xml . elements [ 'metadata/versioning/snapshot/timestamp' ] . text
252- build_number = xml . elements [ 'metadata/versioning/snapshot/buildNumber' ] . text
253- full_version = "#{ version } -#{ timestamp } -#{ build_number } "
254- final_url = "https://central.sonatype.com/repository/maven-snapshots/#{ namespace } /#{ artifact_coordinate } /#{ version } -SNAPSHOT/#{ artifact_coordinate } -#{ full_version } -#{ artifact_name } "
255-
256- return final_url
257- else
258- return ""
259- end
260- rescue => e
261- return ""
262- end
263- end
264-
265222def resolve_url_redirects ( url )
266223 return ( `curl -Ls -o /dev/null -w %{url_effective} \" #{ url } \" ` )
267224end
0 commit comments