From 83f474147cb7ad459bd95a3d75c2e8f41903ec24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ramos?= Date: Wed, 11 May 2022 15:49:48 -0700 Subject: [PATCH] Hermes: Always use Unix Makefiles for Apple build, and use all available cores Summary: Hermes' build scripts use the Ninja build utility if available, otherwise they default to Unix Makefiles. When Unix Makefiles were used, builds would take far too long due to the use of a single core. To reduce the surface area of issues that may arise as we switch to building Hermes from source, we will now focus on a single build system using Unix Makefiles. We will also ensure all available cores are used when building on macOS. Changelog: [Internal] Reviewed By: cortinico, neildhar Differential Revision: D36296838 fbshipit-source-id: 4be23739fb022e3ae8e974ad3c2c70e7011abb5a --- .circleci/config.yml | 8 +++--- .../utils/build-apple-framework.sh | 26 +++---------------- 2 files changed, 8 insertions(+), 26 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 520f0da0af1..c6a46b8ef56 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -417,7 +417,7 @@ jobs: - with_brew_cache_span: steps: - brew_install: - package: cmake ninja + package: cmake - run: name: Setup the CocoaPods environment @@ -474,7 +474,7 @@ jobs: - with_brew_cache_span: steps: - brew_install: - package: watchman cmake ninja + package: watchman cmake - run: name: "Brew: Tap wix/brew" command: brew tap wix/brew >/dev/null @@ -745,7 +745,7 @@ jobs: - with_brew_cache_span: steps: - brew_install: - package: cmake ninja + package: cmake - run: name: Install CocoaPods dependencies @@ -999,7 +999,7 @@ jobs: - run: name: Install dependencies command: | - brew install cmake ninja + brew install cmake - run: name: Build HermesC for macOS command: | diff --git a/sdks/hermes-engine/utils/build-apple-framework.sh b/sdks/hermes-engine/utils/build-apple-framework.sh index 26faf2627fa..82ad18f1e9f 100755 --- a/sdks/hermes-engine/utils/build-apple-framework.sh +++ b/sdks/hermes-engine/utils/build-apple-framework.sh @@ -10,20 +10,7 @@ else BUILD_TYPE="Release" fi -function command_exists { - command -v "${1}" > /dev/null 2>&1 -} - -if command_exists "cmake"; then - if command_exists "ninja"; then - BUILD_SYSTEM="Ninja" - else - BUILD_SYSTEM="Unix Makefiles" - fi -else - echo >&2 'CMake is required to install Hermes, install it with: brew install cmake' - exit 1 -fi +NUM_CORES=$(sysctl -n hw.ncpu) function get_release_version { ruby -rcocoapods-core -rjson -e "puts Pod::Specification.from_file('hermes-engine.podspec').version" @@ -40,7 +27,7 @@ function get_mac_deployment_target { # Build host hermes compiler for internal bytecode function build_host_hermesc { cmake -S . -B build_host_hermesc - cmake --build ./build_host_hermesc --target hermesc + cmake --build ./build_host_hermesc --target hermesc -j ${NUM_CORES} } # Utility function to configure an Apple framework @@ -58,7 +45,7 @@ function configure_apple_framework { build_cli_tools="false" fi - cmake -S . -B "build_$1" -G "$BUILD_SYSTEM" \ + cmake -S . -B "build_$1" \ -DHERMES_APPLE_TARGET_PLATFORM:STRING="$1" \ -DCMAKE_OSX_ARCHITECTURES:STRING="$2" \ -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING="$3" \ @@ -84,12 +71,7 @@ function build_apple_framework { echo "Host hermesc is required to build apple frameworks!" configure_apple_framework "$1" "$2" "$3" - - if [[ "$BUILD_SYSTEM" == "Ninja" ]]; then - (cd "./build_$1" && ninja install/strip) - else - (cd "./build_$1" && make install/strip) - fi + cmake --build "./build_$1" --target install/strip -j ${NUM_CORES} } # Accepts an array of frameworks and will place all of