Skip to content

Commit

Permalink
Backports fixes on the 0.69 release branch to main (#33938)
Browse files Browse the repository at this point in the history
Summary:
This PR includes a set of changes that landed only on the 0.69-stable release branch and need to be backported to main:

- a72d196
- 659b693
- 2a6832a
- 0ca6e41
- f50936b

Most of the fixes are working around the assumption that
`version != 1000.0.0 => Build Hermes From Source`.

That is not true in the release branch as the version is named (e.g. 0.69.0-rc4) and we need to build Hermes there.

## Changelog

[Internal] - Backports fixes on the 0.69 release branch to main

Pull Request resolved: #33938

Test Plan: Tested that those commits are working fine on the release branch.

Reviewed By: hramos

Differential Revision: D36776291

Pulled By: cortinico

fbshipit-source-id: 66e28232d80054fab4a2a97c8d2de12e3c1cf392
  • Loading branch information
cortinico authored and facebook-github-bot committed May 31, 2022
1 parent f56d701 commit bffad43
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
38 changes: 37 additions & 1 deletion scripts/hermes/hermes-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,45 @@ function copyPodSpec() {
);
}

function isOnAReleaseBranch() {
try {
let currentBranch = execSync('git rev-parse --abbrev-ref HEAD')
.toString()
.trim();
let currentRemote = execSync('git config --get remote.origin.url')
.toString()
.trim();
return (
currentBranch.endsWith('-stable') &&
currentRemote.endsWith('facebook/react-native.git')
);
} catch (error) {
// If not inside a git repo, we're going to fail here and return.
return false;
}
}

function isOnAReleaseTag() {
try {
// If on a named tag, this method will return the tag name.
// If not, it will throw as the return code is not 0.
execSync('git describe --exact-match HEAD', {stdio: 'ignore'});
} catch (error) {
return false;
}
let currentRemote = execSync('git config --get remote.origin.url')
.toString()
.trim();
return currentRemote.endsWith('facebook/react-native.git');
}

function shouldBuildHermesFromSource() {
const hermesTag = readHermesTag();
return hermesTag === DEFAULT_HERMES_TAG;
return (
isOnAReleaseBranch() ||
isOnAReleaseTag() ||
hermesTag === DEFAULT_HERMES_TAG
);
}

function shouldUsePrebuiltHermesC(os) {
Expand Down
10 changes: 10 additions & 0 deletions sdks/hermes-engine/hermes-engine.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# LICENSE file in the root directory of this source tree.

require "json"
require "open3"

# sdks/hermesc/osx-bin/ImportHermesc.cmake
import_hermesc_file=File.join(__dir__, "..", "hermesc", "osx-bin", "ImportHermesc.cmake")
Expand All @@ -13,13 +14,22 @@ package_file = File.join(__dir__, "..", "..", "package.json")
package = JSON.parse(File.read(package_file))
version = package['version']

# We need to check the current git branch/remote to verify if
# we're on a React Native release branch to actually build Hermes.
currentbranch, err = Open3.capture3("git rev-parse --abbrev-ref HEAD")
currentremote, err = Open3.capture3("git config --get remote.origin.url")

source = {}
git = "https://github.com/facebook/hermes.git"

if version == '1000.0.0'
Pod::UI.puts '[Hermes] Hermes needs to be compiled, installing hermes-engine may take a while...'.yellow if Object.const_defined?("Pod::UI")
source[:git] = git
source[:commit] = `git ls-remote https://github.com/facebook/hermes main | cut -f 1`.strip
elsif currentremote.strip.end_with?("facebook/react-native.git") and currentbranch.strip.end_with?("-stable")
Pod::UI.puts '[Hermes] Detected that you are on a React Native release branch, building Hermes from source...'.yellow if Object.const_defined?("Pod::UI")
source[:git] = git
source[:commit] = `git ls-remote https://github.com/facebook/hermes main | cut -f 1`.strip
else
source[:http] = "https://github.com/facebook/react-native/releases/download/v#{version}/hermes-runtime-darwin-v#{version}.tar.gz"
end
Expand Down

0 comments on commit bffad43

Please sign in to comment.