Skip to content

Commit 8b57768

Browse files
Riccardo Cipolleschimeta-codesync[bot]
authored andcommitted
Remove V0 nightly download path from hermes-utils.rb
Summary: Remove the legacy Hermes V0 nightly (Maven Snapshots) download path: - Remove DOWNLOAD_PREBUILT_NIGHTLY_TARBALL source type constant - Remove nightly_artifact_exists(), nightly_tarball_url(), podspec_source_download_prebuilt_nightly_tarball() - Remove net/http and rexml/document requires (only needed for nightly XML parsing) - Rename BUILD_FROM_GITHUB_MAIN -> BUILD_FROM_GITHUB_STABLE_BRANCH (was always targeting the stable V1 branch) - Rename force_build_from_main -> force_build_from_stable_branch - Rename podspec_source_build_from_github_main -> podspec_source_build_from_github_stable_branch - Extract HERMES_STABLE_BRANCH constant so the hardcoded branch is in one place Differential Revision: D104649630
1 parent eaa9d02 commit 8b57768

1 file changed

Lines changed: 17 additions & 60 deletions

File tree

packages/react-native/sdks/hermes-engine/hermes-utils.rb

Lines changed: 17 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,23 @@
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-
96
HERMES_GITHUB_URL = "https://github.com/facebook/hermes.git"
107
ENV_BUILD_FROM_SOURCE = "RCT_BUILD_HERMES_FROM_SOURCE"
118

129
module 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
2824
end
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
7467
end
7568

7669
def 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))
9083
end
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))
9487
end
9588

9689
def release_artifact_exists(version)
9790
return hermes_artifact_exists(release_tarball_url(version, :debug))
9891
end
9992

100-
def nightly_artifact_exists(version)
101-
return hermes_artifact_exists(nightly_tarball_url(version).gsub("\\", ""))
102-
end
103-
10493
def 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}
176163
end
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}
182170
end
183171

184172
def 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}
190178
end
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

200182
def artifacts_dir()
@@ -237,31 +219,6 @@ def download_hermes_tarball(react_native_path, tarball_url, version, configurati
237219
return destination_path
238220
end
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-
265222
def resolve_url_redirects(url)
266223
return (`curl -Ls -o /dev/null -w %{url_effective} \"#{url}\"`)
267224
end

0 commit comments

Comments
 (0)