|
| 1 | +# Copyright (c) Facebook, Inc. and its affiliates. |
| 2 | +# |
| 3 | +# This source code is licensed under the MIT license found in the |
| 4 | +# LICENSE file in the root directory of this source tree. |
| 5 | + |
| 6 | +module HermesHelper |
| 7 | + # BUILD_TYPE = :debug |
| 8 | + BUILD_TYPE = :release |
| 9 | + |
| 10 | + OSX_DEPLOYMENT_TARGET = "10.13" |
| 11 | + IOS_DEPLOYMENT_TARGET = "10.0" |
| 12 | +end |
| 13 | + |
| 14 | +Pod::Spec.new do |spec| |
| 15 | + spec.name = "hermes-engine" |
| 16 | + spec.version = "0.7.1" |
| 17 | + spec.summary = "Hermes is a small and lightweight JavaScript engine optimized for running React Native." |
| 18 | + 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." |
| 19 | + spec.homepage = "https://hermesengine.dev" |
| 20 | + spec.license = { type: "MIT", file: "LICENSE" } |
| 21 | + spec.author = "Facebook" |
| 22 | + # This env var should be supplied with a CDN URL for hermes-engine-darwin.tgz on the Github releases before pod push. |
| 23 | + # The podspec would be serialized to JSON and people will download prebuilt binaries instead of the source. |
| 24 | + spec.source = ENV['hermes-artifact-url'] ? ENV['hermes-artifact-url'] : { git: "https://github.com/facebook/hermes.git", tag: "v#{spec.version}" } |
| 25 | + spec.platforms = { :osx => HermesHelper::OSX_DEPLOYMENT_TARGET, :ios => HermesHelper::IOS_DEPLOYMENT_TARGET } |
| 26 | + |
| 27 | + spec.preserve_paths = ["destroot/bin/*"].concat(HermesHelper::BUILD_TYPE == :debug ? ["**/*.{h,c,cpp}"] : []) |
| 28 | + spec.source_files = "destroot/include/**/*.h" |
| 29 | + spec.header_mappings_dir = "destroot/include" |
| 30 | + |
| 31 | + spec.ios.vendored_frameworks = "destroot/Library/Frameworks/iphoneos/hermes.framework" |
| 32 | + spec.osx.vendored_frameworks = "destroot/Library/Frameworks/macosx/hermes.framework" |
| 33 | + |
| 34 | + spec.xcconfig = { "CLANG_CXX_LANGUAGE_STANDARD" => "c++14", "CLANG_CXX_LIBRARY" => "compiler-default", "GCC_PREPROCESSOR_DEFINITIONS" => "HERMES_ENABLE_DEBUGGER=1" } |
| 35 | + |
| 36 | + unless ENV['hermes-artifact-url'] |
| 37 | + spec.prepare_command = <<-EOS |
| 38 | + # When true, debug build will be used. |
| 39 | + # See `build-apple-framework.sh` for details |
| 40 | + DEBUG=#{HermesHelper::BUILD_TYPE == :debug} |
| 41 | +
|
| 42 | + # In a release package, there are no utilities and source files, we exit |
| 43 | + # early as there is nothing to build |
| 44 | + if [ ! -f ./utils/build-apple-framework.sh ]; then |
| 45 | + exit 0; |
| 46 | + fi |
| 47 | +
|
| 48 | + # Source utilities into the scope |
| 49 | + . ./utils/build-apple-framework.sh |
| 50 | +
|
| 51 | + # If universal framework for iOS does not exist, build one |
| 52 | + if [ ! -d destroot/Library/Frameworks/iphoneos/hermes.framework ]; then |
| 53 | + build_apple_framework "iphoneos" "armv7;armv7s;arm64" "#{HermesHelper::IOS_DEPLOYMENT_TARGET}" |
| 54 | + build_apple_framework "iphonesimulator" "x86_64;i386" "#{HermesHelper::IOS_DEPLOYMENT_TARGET}" |
| 55 | +
|
| 56 | + create_universal_framework "iphoneos" "iphonesimulator" |
| 57 | + fi |
| 58 | +
|
| 59 | + # If MacOS framework does not exist, build one |
| 60 | + if [ ! -d destroot/Library/Frameworks/macosx/hermes.framework ]; then |
| 61 | + build_apple_framework "macosx" "x86_64;arm64" "#{HermesHelper::OSX_DEPLOYMENT_TARGET}" |
| 62 | + fi |
| 63 | + EOS |
| 64 | + end |
| 65 | +end |
0 commit comments