mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
6b1e193f15
Summary: Update `hermes-engine.podspec` to use pre-built Hermes artifacts from the corresponding React Native GitHub Release when targeting a specific React Native release. Otherwise, fallback to building Hermes from source. Changelog: [Internal] Reviewed By: cortinico, cipolleschi Differential Revision: D36609257 fbshipit-source-id: 6179c9e255558c7eaf1417ff46a2e7db120295f0
70 lines
2.8 KiB
Ruby
70 lines
2.8 KiB
Ruby
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
#
|
|
# This source code is licensed under the MIT license found in the
|
|
# LICENSE file in the root directory of this source tree.
|
|
|
|
require "json"
|
|
|
|
# sdks/hermesc/osx-bin/ImportHermesc.cmake
|
|
import_hermesc_file=File.join(__dir__, "..", "hermesc", "osx-bin", "ImportHermesc.cmake")
|
|
|
|
# package.json
|
|
package_file = File.join(__dir__, "..", "..", "package.json")
|
|
package = JSON.parse(File.read(package_file))
|
|
version = package['version']
|
|
|
|
source = {}
|
|
git = "https://github.com/facebook/hermes.git"
|
|
|
|
if version == '1000.0.0'
|
|
Pod::UI.puts '[Hermes] Hermes needs to be compiled, installing hermes-engine may take a while...'.yellow if Object.const_defined?("Pod::UI")
|
|
source[:git] = git
|
|
source[:commit] = `git ls-remote https://github.com/facebook/hermes main | cut -f 1`.strip
|
|
else
|
|
source[:http] = `https://github.com/facebook/react-native/releases/download/v#{version}/hermes-runtime-darwin-v#{version}.tar.gz`
|
|
end
|
|
|
|
module HermesHelper
|
|
# BUILD_TYPE = :debug
|
|
BUILD_TYPE = :release
|
|
end
|
|
|
|
Pod::Spec.new do |spec|
|
|
spec.name = "hermes-engine"
|
|
spec.version = version
|
|
spec.summary = "Hermes is a small and lightweight JavaScript engine optimized for running React Native."
|
|
spec.description = "Hermes is a JavaScript engine optimized for fast start-up of React Native apps. It features ahead-of-time static optimization and compact bytecode."
|
|
spec.homepage = "https://hermesengine.dev"
|
|
spec.license = package["license"]
|
|
spec.author = "Facebook"
|
|
spec.source = source
|
|
spec.platforms = { :osx => "10.13", :ios => "11.0" }
|
|
|
|
spec.preserve_paths = ["destroot/bin/*"].concat(HermesHelper::BUILD_TYPE == :debug ? ["**/*.{h,c,cpp}"] : [])
|
|
spec.source_files = "destroot/include/**/*.h"
|
|
spec.header_mappings_dir = "destroot/include"
|
|
|
|
spec.ios.vendored_frameworks = "destroot/Library/Frameworks/universal/hermes.xcframework"
|
|
spec.osx.vendored_frameworks = "destroot/Library/Frameworks/macosx/hermes.framework"
|
|
|
|
spec.xcconfig = { "CLANG_CXX_LANGUAGE_STANDARD" => "c++17", "CLANG_CXX_LIBRARY" => "compiler-default", "GCC_PREPROCESSOR_DEFINITIONS" => "HERMES_ENABLE_DEBUGGER=1" }
|
|
|
|
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}
|
|
|
|
# Set HERMES_OVERRIDE_HERMESC_PATH if pre-built HermesC is available
|
|
#{File.exist?(import_hermesc_path) ? "export HERMES_OVERRIDE_HERMESC_PATH=#{import_hermesc_path}" : ""}
|
|
#{File.exist?(import_hermesc_path) ? "echo \"Overriding HermesC path...\"" : ""}
|
|
|
|
# Build iOS framework
|
|
./utils/build-ios-framework.sh
|
|
|
|
# Build Mac framework
|
|
./utils/build-mac-framework.sh
|
|
EOS
|
|
end
|
|
end
|