fix: minor fixes for hermes scripts (#45841)

Summary:
This PR fixes few issues with Hermes scripts:

- Set visionOS vendored frameworks
- Fail if env variables are not set

## Changelog:

[INTERNAL] [FIXED] - Hermes script should fail when no deployment target is set

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

Test Plan: Try to build Hermes

Reviewed By: blakef

Differential Revision: D60901886

Pulled By: cipolleschi

fbshipit-source-id: b9ff470ac6c07e1bd5abc7410ac0c366d66016c5
This commit is contained in:
Oskar Kwaśniewski
2024-08-07 06:53:37 -07:00
committed by Facebook GitHub Bot
parent e9e5fb0141
commit c17da4e811
3 changed files with 13 additions and 5 deletions
@@ -36,6 +36,7 @@ Pod::Spec.new do |spec|
spec.ios.vendored_frameworks = "destroot/Library/Frameworks/ios/hermes.framework"
spec.osx.vendored_frameworks = "destroot/Library/Frameworks/macosx/hermes.framework"
spec.visionos.vendored_frameworks = "destroot/Library/Frameworks/xros/hermes.framework"
if HermesEngineSourceType::isPrebuilt(source_type) then
@@ -31,20 +31,29 @@ function use_env_var_or_ruby_prop {
fi
}
function use_env_var {
if [[ -n "$1" ]]; then
echo "$1"
else
echo "error: Missing $2 environment variable"
exit 1
fi
}
function get_release_version {
use_env_var_or_ruby_prop "${RELEASE_VERSION}" "version"
}
function get_ios_deployment_target {
use_env_var_or_ruby_prop "${IOS_DEPLOYMENT_TARGET}" "deployment_target('ios')"
use_env_var "${IOS_DEPLOYMENT_TARGET}" "IOS_DEPLOYMENT_TARGET"
}
function get_visionos_deployment_target {
use_env_var_or_ruby_prop "${XROS_DEPLOYMENT_TARGET}" "deployment_target('visionos')"
use_env_var "${XROS_DEPLOYMENT_TARGET}" "XROS_DEPLOYMENT_TARGET"
}
function get_mac_deployment_target {
use_env_var_or_ruby_prop "${MAC_DEPLOYMENT_TARGET}" "deployment_target('osx')"
use_env_var "${MAC_DEPLOYMENT_TARGET}" "MAC_DEPLOYMENT_TARGET"
}
# Build host hermes compiler for internal bytecode
@@ -59,8 +59,6 @@ function build_universal_framework {
# this is used to preserve backward compatibility
function create_framework {
if [ ! -d destroot/Library/Frameworks/universal/hermes.xcframework ]; then
ios_deployment_target=$(get_ios_deployment_target)
build_framework "iphoneos"
build_framework "iphonesimulator"
build_framework "catalyst"