Skip to content

Commit

Permalink
Build separate tarballs for Hermes with and without debugger (faceboo…
Browse files Browse the repository at this point in the history
…k#34704)

Summary:
Pull Request resolved: facebook#34704

Create a separate hermes-engine tarball that explicitly includes the Hermes debugger, and switch the original tarball to exclude the debugger for use in release builds.

Changelog:
[iOS][Changed] - Remove debugger from Hermes pre-builts

Differential Revision: D39326467

fbshipit-source-id: b9d6a190f73eae7e2d8451853886a753e274c297
  • Loading branch information
hramos authored and facebook-github-bot committed Sep 16, 2022
1 parent dc56eb9 commit a464438
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 16 deletions.
41 changes: 36 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ commands:
set_tarball_path:
type: boolean
default: False
flavor:
type: string
default: "Debug"
steps:
- restore_cache:
keys:
Expand All @@ -260,15 +263,21 @@ commands:
condition: << parameters.set_tarball_path >>
steps:
- run:
name: Set HERMES_TARBALL_PATH if present
name: Set HERMES_ENGINE_TARBALL_PATH if present
command: |
BASE_PATH=/tmp/hermes/hermes-runtime-darwin/
if [ ! -d $BASE_PATH ]; then
echo "Hermes tarball base path not present ($BASE_PATH). Build it from source."
exit 0
fi
TARBALL=$(ls /tmp/hermes/hermes-runtime-darwin/)
TARBALL_PATH=$BASE_PATH$TARBALL
if [[ << parameters.flavor >> == "Release" ]]; then
TARBALL_FILENAME=hermes-runtime-darwin-release-*.tar.gz
else
TARBALL_FILENAME=hermes-runtime-darwin-debug-*.tar.gz
fi
# /tmp/hermes/hermes-runtime-darwin/hermes-runtime-darwin-debug-v0.70.0.tar.gz
# /tmp/hermes/hermes-runtime-darwin/hermes-runtime-darwin-release-v0.70.0.tar.gz
TARBALL_PATH=$(ls $BASE_PATH$TARBALL_FILENAME)
if [ ! -f $TARBALL_PATH ]; then
echo "Hermes tarball not present ($TARBALL_PATH). Build it from source."
exit 0
Expand Down Expand Up @@ -1042,6 +1051,10 @@ jobs:
- linux64-bin

build_hermes_macos:
parameters:
flavor:
type: string
default: "Release"
executor: reactnativeios
environment:
- HERMES_WS_DIR: *hermes_workspace_root
Expand All @@ -1061,7 +1074,12 @@ jobs:
command: |
brew install cmake
- with_hermes_tarball_cache_span:
flavor: << parameters.flavor >>
steps:
- run:
name: Configure Environment Variables
command: |
export BUILD_TYPE="<< parameters.flavor >>"
- run:
name: Build the Hermes iOS frameworks
command: |
Expand All @@ -1084,10 +1102,20 @@ jobs:
cp -R ./destroot /tmp/cocoapods-package-root
cp LICENSE /tmp/cocoapods-package-root
tar -C /tmp/cocoapods-package-root/ -czvf /tmp/hermes/output/hermes-runtime-darwin-v$(get_release_version).tar.gz .
if [[ $BUILD_TYPE == "Release" ]]; then
TARBALL_FILENAME=hermes-runtime-darwin-release-v$(get_release_version).tar.gz
else
TARBALL_FILENAME=hermes-runtime-darwin-debug-v$(get_release_version).tar.gz
fi
tar -C /tmp/cocoapods-package-root/ -czvf /tmp/hermes/output/$TARBALL_FILENAME .
mkdir -p /tmp/hermes/hermes-runtime-darwin
cp /tmp/hermes/output/hermes-runtime-darwin-v$(get_release_version).tar.gz /tmp/hermes/hermes-runtime-darwin/.
cp /tmp/hermes/output/$TARBALL_FILENAME /tmp/hermes/hermes-runtime-darwin/.
# TODO: Remove this once the client side is aware of -release and -debug tarballs
if [[ $BUILD_TYPE == "Release" ]]; then
cp /tmp/hermes/hermes-runtime-darwin/hermes-runtime-darwin-release-v$(get_release_version).tar.gz /tmp/hermes/hermes-runtime-darwin/hermes-runtime-darwin-v$(get_release_version).tar.gz
fi
- save_cache:
key: *hermes_cache_key
paths:
Expand Down Expand Up @@ -1435,6 +1463,9 @@ workflows:
filters: *only_release_tags
requires:
- prepare_hermes_workspace
matrix:
parameters:
flavor: ["Debug", "Release"]
- build_hermesc_windows:
filters: *only_release_tags
requires:
Expand Down
4 changes: 1 addition & 3 deletions sdks/hermes-engine/hermes-engine.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ Pod::Spec.new do |spec|

if source[:git] then
spec.prepare_command = <<-EOS
# When true, debug build will be used.
# See `build-apple-framework.sh` for details
DEBUG=#{HermesHelper::BUILD_TYPE == :debug}
BUILD_TYPE=#{HermesHelper::BUILD_TYPE == :release ? "Release" : "Debug"}
# Set HERMES_OVERRIDE_HERMESC_PATH if pre-built HermesC is available
#{File.exist?(import_hermesc_file) ? "export HERMES_OVERRIDE_HERMESC_PATH=#{import_hermesc_file}" : ""}
Expand Down
15 changes: 7 additions & 8 deletions sdks/hermes-engine/utils/build-apple-framework.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

if [ "$DEBUG" = true ]; then
BUILD_TYPE="Debug"
else
BUILD_TYPE="Release"
fi

NUM_CORES=$(sysctl -n hw.ncpu)
IMPORT_HERMESC_PATH=${HERMES_OVERRIDE_HERMESC_PATH:-$PWD/build_host_hermesc/ImportHermesc.cmake}
REACT_NATIVE_PATH=${REACT_NATIVE_PATH:-$PWD/../..}
Expand All @@ -35,7 +29,7 @@ function build_host_hermesc {

# Utility function to configure an Apple framework
function configure_apple_framework {
local build_cli_tools enable_bitcode
local build_cli_tools enable_bitcode enable_debugger

if [[ $1 == iphoneos || $1 == catalyst ]]; then
enable_bitcode="true"
Expand All @@ -47,12 +41,17 @@ function configure_apple_framework {
else
build_cli_tools="false"
fi
if [[ $BUILD_TYPE == "Debug" ]]; then
enable_debugger="true"
else
enable_debugger="false"
fi

cmake -S . -B "build_$1" \
-DHERMES_APPLE_TARGET_PLATFORM:STRING="$1" \
-DCMAKE_OSX_ARCHITECTURES:STRING="$2" \
-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING="$3" \
-DHERMES_ENABLE_DEBUGGER:BOOLEAN=true \
-DHERMES_ENABLE_DEBUGGER:BOOLEAN="$enable_debugger" \
-DHERMES_ENABLE_INTL:BOOLEAN=true \
-DHERMES_ENABLE_LIBFUZZER:BOOLEAN=false \
-DHERMES_ENABLE_FUZZILLI:BOOLEAN=false \
Expand Down

0 comments on commit a464438

Please sign in to comment.