Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions .github/workflows/build-apple-slices-hermes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,10 @@ jobs:
# HermesC is used to build hermes, so it has to be executable
chmod +x ./build_host_hermesc/bin/hermesc

if [[ "$SLICE" == "macosx" ]]; then
echo "[HERMES] Building Hermes for MacOS"
echo "[HERMES] Building Hermes for $SLICE"

chmod +x ./utils/build-mac-framework.sh
BUILD_TYPE="${{ matrix.flavor }}" ./utils/build-mac-framework.sh
else
echo "[HERMES] Building Hermes for iOS: $SLICE"

chmod +x ./utils/build-ios-framework.sh
BUILD_TYPE="${{ matrix.flavor }}" ./utils/build-ios-framework.sh "$SLICE"
fi
chmod +x ./utils/build-apple-framework.sh
BUILD_TYPE="${{ matrix.flavor }}" ./utils/build-apple-framework.sh "$SLICE"

echo "Moving from build_$SLICE to $FINAL_PATH"
mv build_"$SLICE" "$FINAL_PATH"
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/build-hermes-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ jobs:
chmod +x ./utils/build-apple-framework.sh
source ./utils/build-apple-framework.sh
prepare_dest_root_for_ci
- name: Create fat framework for iOS
- name: Create universal xcframework
shell: bash
run: |
echo "[HERMES] Creating the universal framework"
chmod +x ./utils/build-ios-framework.sh
./utils/build-ios-framework.sh build_framework
echo "[HERMES] Creating the universal framework (including macOS)"
chmod +x ./utils/build-apple-framework.sh
./utils/build-apple-framework.sh build_framework

chmod +x ./destroot/bin/hermesc
- name: Package the Hermes Apple frameworks
Expand Down
9 changes: 3 additions & 6 deletions hermes-engine.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Pod::Spec.new do |spec|
spec.ios.vendored_frameworks = "destroot/Library/Frameworks/universal/hermesvm.xcframework"
spec.visionos.vendored_frameworks = "destroot/Library/Frameworks/universal/hermesvm.xcframework"
spec.tvos.vendored_frameworks = "destroot/Library/Frameworks/universal/hermesvm.xcframework"
spec.osx.vendored_frameworks = "destroot/Library/Frameworks/macosx/hermesvm.framework"
spec.osx.vendored_frameworks = "destroot/Library/Frameworks/universal/hermesvm.xcframework"

spec.xcconfig = { "CLANG_CXX_LANGUAGE_STANDARD" => "c++17", "CLANG_CXX_LIBRARY" => "compiler-default", "GCC_PREPROCESSOR_DEFINITIONS" => "HERMES_ENABLE_DEBUGGER=1" }

Expand All @@ -43,11 +43,8 @@ Pod::Spec.new do |spec|
# See `build-apple-framework.sh` for details
DEBUG=#{HermesHelper::BUILD_TYPE == :debug}

# Build iOS framework
./utils/build-ios-framework.sh

# Build Mac framework
./utils/build-mac-framework.sh
# Build all Apple frameworks (iOS, macOS, tvOS, visionOS, Catalyst)
./utils/build-apple-framework.sh
EOS
end
end
107 changes: 94 additions & 13 deletions utils/build-apple-framework.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,18 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# Defines functions for building various Hermes frameworks.
# See build-ios-framework.sh and build-mac-framework.sh for usage examples.
# Builds Hermes Apple frameworks for all platforms (iOS, macOS, tvOS, visionOS,
# Mac Catalyst) and combines them into a single universal xcframework.
#
# Usage:
# ./build-apple-framework.sh # build all platforms + universal xcframework
# ./build-apple-framework.sh <platform> # build a single platform (e.g. macosx, iphoneos)
# ./build-apple-framework.sh build_framework # combine already-built slices into xcframework

if [ "$CI" ]; then
set -x
fi
set -e

CURR_SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"

Expand Down Expand Up @@ -62,6 +72,35 @@ function get_release_version {
fi
}

# Given a specific target, retrieve the right architecture for it
# $1 the target you want to build. Allowed values: iphoneos, iphonesimulator, catalyst, macosx, xros, xrsimulator, appletvos, appletvsimulator
function get_architecture {
if [[ $1 == "iphoneos" || $1 == "xros" ]]; then
echo "arm64"
elif [[ $1 == "iphonesimulator" || $1 == "xrsimulator" ]]; then
echo "x86_64;arm64"
elif [[ $1 == "appletvos" ]]; then
echo "arm64"
elif [[ $1 == "appletvsimulator" ]]; then
echo "x86_64;arm64"
elif [[ $1 == "catalyst" || $1 == "macosx" ]]; then
echo "x86_64;arm64"
else
Comment thread
Saadnajmi marked this conversation as resolved.
Outdated
echo "Error: unknown architecture passed $1"
exit 1
fi
}

function get_deployment_target {
if [[ $1 == "xros" || $1 == "xrsimulator" ]]; then
echo "$(get_visionos_deployment_target)"
elif [[ $1 == "macosx" ]]; then
echo "$(get_mac_deployment_target)"
else # tvOS and iOS use the same deployment target
echo "$(get_ios_deployment_target)"
fi
}

# Build host hermes compiler for internal bytecode
function build_host_hermesc {
echo "Building hermesc"
Expand All @@ -71,6 +110,14 @@ function build_host_hermesc {
popd > /dev/null || exit 1
}

function build_host_hermesc_if_needed {
if [[ ! -f "$IMPORT_HERMESC_PATH" ]]; then
build_host_hermesc
else
echo "[HermesC] Skipping! Found an existent hermesc already at: $IMPORT_HERMESC_PATH"
fi
}

# Utility function to configure an Apple framework
function configure_apple_framework {
local enable_debugger cmake_build_type xcode_15_flags xcode_major_version
Expand Down Expand Up @@ -138,15 +185,8 @@ function generate_dSYM {
cp -R "$DSYM_PATH" "$PWD/destroot/Library/Frameworks/$TARGET_PLATFORM"
}

function build_host_hermesc_if_needed {
if [[ ! -f "$IMPORT_HERMESC_PATH" ]]; then
build_host_hermesc
else
echo "[HermesC] Skipping! Found an existent hermesc already at: $IMPORT_HERMESC_PATH"
fi
}

# Utility function to build an Apple framework
# Utility function to build an Apple framework for a single platform
# $1: platform, $2: architectures, $3: deployment target
function build_apple_framework {
# Only build host HermesC if no file found at $IMPORT_HERMESC_PATH
build_host_hermesc_if_needed
Expand All @@ -155,7 +195,6 @@ function build_apple_framework {
[ ! -f "$IMPORT_HERMESC_PATH" ] &&
echo "Host hermesc is required to build apple frameworks!"

# $1: platform, $2: architectures, $3: deployment target
echo "Building $BUILD_TYPE framework for $1 with architectures: $2"
configure_apple_framework "$1" "$2" "$3"

Expand Down Expand Up @@ -231,7 +270,7 @@ function create_universal_framework {
# shellcheck disable=SC2086
if xcodebuild -create-xcframework $args -output "universal/hermesvm.xcframework"
then
# # Remove the thin iOS hermesvm.frameworks that are now part of the universal
# # Remove the thin hermesvm.frameworks that are now part of the universal
# XCFramework
for platform in "${platforms[@]}"; do
rm -r "$platform"
Expand All @@ -240,3 +279,45 @@ function create_universal_framework {

popd > /dev/null || exit 1
}

# Build a single framework for a given platform
# $1 is the target to build (e.g. iphoneos, macosx, etc.)
function build_framework {
if [ ! -d destroot/Library/Frameworks/universal/hermesvm.xcframework ]; then
deployment_target=$(get_deployment_target "$1")
architecture=$(get_architecture "$1")
build_apple_framework "$1" "$architecture" "$deployment_target"
else
echo "Skipping; Clean \"destroot\" to rebuild".
fi
}

# Combine already-built slices into a universal xcframework
function build_universal_framework {
if [ ! -d destroot/Library/Frameworks/universal/hermesvm.xcframework ]; then
create_universal_framework "${PLATFORMS[@]}"
else
echo "Skipping; Clean \"destroot\" to rebuild".
fi
}

# Build all platforms sequentially then combine into a universal xcframework
function create_framework {
if [ ! -d destroot/Library/Frameworks/universal/hermesvm.xcframework ]; then
for platform in "${PLATFORMS[@]}"; do
build_framework "$platform"
done
build_universal_framework
else
echo "Skipping; Clean \"destroot\" to rebuild".
fi
}

# --- Entry point ---
if [[ -z $1 ]]; then
create_framework
elif [[ $1 == "build_framework" ]]; then
build_universal_framework
else
build_framework "$1"
fi
90 changes: 0 additions & 90 deletions utils/build-ios-framework.sh

This file was deleted.

22 changes: 0 additions & 22 deletions utils/build-mac-framework.sh

This file was deleted.

11 changes: 1 addition & 10 deletions utils/scripts/hermes/hermes-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,6 @@ function createHermesPrebuiltArtifactsTarball(
}

function validateHermesFrameworksExist(destrootDir /*: string */) {
if (
!fs.existsSync(
path.join(destrootDir, "Library/Frameworks/macosx/hermesvm.framework")
)
) {
throw new Error(
"Error: Hermes macOS Framework not found. Are you sure Hermes has been built?"
);
}
if (
!fs.existsSync(
path.join(
Expand All @@ -121,7 +112,7 @@ function validateHermesFrameworksExist(destrootDir /*: string */) {
)
) {
throw new Error(
"Error: Hermes iOS XCFramework not found. Are you sure Hermes has been built?"
"Error: Hermes universal XCFramework not found. Are you sure Hermes has been built?"
);
}
}
Expand Down
Loading