From 5dd0f7327bf6ef1e2d559e6f65769dab3c84fb19 Mon Sep 17 00:00:00 2001 From: Dmitry Rykun Date: Mon, 21 Nov 2022 07:09:18 -0800 Subject: [PATCH] Various fixes for Hermes build-from-source behaviour Summary: Original title: **[RN] Do not encode path to cmake in hermes-engine Pod, build hermesc in prepare_pods** The result of `#{%x(command -v cmake | tr -d '\n')}` was being encoded into the `hermes-engine` Pod. This can lead to conflicts in the CocoaPods cache when `pod install` is run on different machines. Instead of running the command during `pod install`, we defer to the actual build scripts so they can find `cmake` when `$CMAKE_BINARY` is not set. More importantly, this fixes an issue that crept into the Sandcastle CocoaPods offline mirrors, but which would only manifest itself when people run `js1 oss prepare-pods`. RNTester would not build due to RNTesterPods.xcworkspace being configured to use cmake from an arbitrary path instead of using the cmake from $PATH. This does not affect Sandcastle due to `CMAKE_BINARY` getting overriden in Sandcastle. --- **Update** by dmytrorykun: It is impossible to address the problem described in the original title by simply adding `CMAKE_BINARY=${CMAKE_BINARY:-cmake}` to `build-hermes-xcode.sh`. This script is supposed to run from Xcode. Since Xcode doesn't have access to system `PATH` variable, it is unable to locate `cmake`, and build fails. However this diff contains other useful changes: 1. Remove trailing newline in `cmake` path in `build-hermes-xcode.sh`. 2. Fix inverted logic in `copy-hermes-xcode.sh`. 3. Fix typo in `remove xcuserdata` step in Sandcastle. 4. Remove unused `HERMES_DISABLE_HERMESC_BUILD`. Changelog: [iOS] [Fixed] - Various fixes for Hermes build-from-source behaviour. Reviewed By: cipolleschi Differential Revision: D41139384 fbshipit-source-id: 4a4a44a7ac201d279718d84cd02d60b4eaf3956b --- sdks/hermes-engine/utils/build-hermesc-xcode.sh | 2 +- sdks/hermes-engine/utils/copy-hermes-xcode.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sdks/hermes-engine/utils/build-hermesc-xcode.sh b/sdks/hermes-engine/utils/build-hermesc-xcode.sh index 59de6a74e9a3f6..6b1ea9184d76c9 100755 --- a/sdks/hermes-engine/utils/build-hermesc-xcode.sh +++ b/sdks/hermes-engine/utils/build-hermesc-xcode.sh @@ -8,7 +8,7 @@ set -x hermesc_dir_path="$1" -CMAKE_BINARY=${CMAKE_BINARY:-cmake} +CMAKE_BINARY=${CMAKE_BINARY:-$(command -v cmake | tr -d '\n')} if ! "$CMAKE_BINARY" -S . -B "$hermesc_dir_path" then diff --git a/sdks/hermes-engine/utils/copy-hermes-xcode.sh b/sdks/hermes-engine/utils/copy-hermes-xcode.sh index 62cc99c064a72f..6768d4ecb28ed0 100755 --- a/sdks/hermes-engine/utils/copy-hermes-xcode.sh +++ b/sdks/hermes-engine/utils/copy-hermes-xcode.sh @@ -8,7 +8,7 @@ set -x source="${PODS_ROOT}/hermes-engine/destroot/Library/Frameworks/${PLATFORM_NAME}/hermes.framework" -if [[ ! -f "$source" ]]; then +if [[ -f "$source" ]]; then cp -R "$source" "${PODS_XCFRAMEWORKS_BUILD_DIR}/hermes/hermes.framework" cp -R "$source" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" fi