Skip to content

Commit

Permalink
Rename and conditionalize source for podspec (#385)
Browse files Browse the repository at this point in the history
Summary:
I cherry-picked this PR which:

1. rename everything to `hermes-engine` since <https://cocoapods.org/pods/Hermes> already exists
2. conditionalize `spec.source` so it can distribute prebuilt binaries as alloy suggested at #368 (comment)

Noted that the version in the `podspec` had been updated to 0.7.1
correctly.

Pull Request resolved: #385

Test Plan: CircleCI doing fine

Reviewed By: tmikov

Differential Revision: D24206180

Pulled By: Huxpro

fbshipit-source-id: ec46350e00099c61a7de8cc9eb99991af72abdb4
  • Loading branch information
Huxpro committed Oct 9, 2020
1 parent 49c2875 commit 88add0f
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 65 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ set(CMAKE_OSX_SYSROOT ${HERMES_APPLE_TARGET_PLATFORM})
# This must be consistent with the release_version in:
# - android/build.gradle
# - npm/package.json
# - hermes.podspec
# - hermes-engine.podspec
project(Hermes
VERSION 0.7.1
LANGUAGES C CXX)
Expand Down Expand Up @@ -737,7 +737,7 @@ add_custom_target(
COMMAND
cp -R ${CMAKE_INSTALL_PREFIX}/include ${HERMES_PKG_ROOT}/destroot/
COMMAND
cp ${CMAKE_CURRENT_SOURCE_DIR}/hermes.podspec ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE ${HERMES_PKG_ROOT}
cp ${CMAKE_CURRENT_SOURCE_DIR}/hermes-engine.podspec ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE ${HERMES_PKG_ROOT}
COMMAND
tar -C ${HERMES_PKG_ROOT}/ -czvf ${HERMES_GITHUB_DIR}/hermes-runtime-${HERMES_GITHUB_SYSTEM_NAME}-v${HERMES_RELEASE_VERSION}.tar.gz .
)
65 changes: 65 additions & 0 deletions hermes-engine.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

module HermesHelper
# BUILD_TYPE = :debug
BUILD_TYPE = :release

OSX_DEPLOYMENT_TARGET = "10.13"
IOS_DEPLOYMENT_TARGET = "10.0"
end

Pod::Spec.new do |spec|
spec.name = "hermes-engine"
spec.version = "0.7.1"
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 = { type: "MIT", file: "LICENSE" }
spec.author = "Facebook"
# This env var should be supplied with a CDN URL for hermes-engine-darwin.tgz on the Github releases before pod push.
# The podspec would be serialized to JSON and people will download prebuilt binaries instead of the source.
spec.source = ENV['hermes-artifact-url'] ? ENV['hermes-artifact-url'] : { git: "https://github.com/facebook/hermes.git", tag: "v#{spec.version}" }
spec.platforms = { :osx => HermesHelper::OSX_DEPLOYMENT_TARGET, :ios => HermesHelper::IOS_DEPLOYMENT_TARGET }

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/iphoneos/hermes.framework"
spec.osx.vendored_frameworks = "destroot/Library/Frameworks/macosx/hermes.framework"

spec.xcconfig = { "CLANG_CXX_LANGUAGE_STANDARD" => "c++14", "CLANG_CXX_LIBRARY" => "compiler-default", "GCC_PREPROCESSOR_DEFINITIONS" => "HERMES_ENABLE_DEBUGGER=1" }

unless ENV['hermes-artifact-url']
spec.prepare_command = <<-EOS
# When true, debug build will be used.
# See `build-apple-framework.sh` for details
DEBUG=#{HermesHelper::BUILD_TYPE == :debug}
# In a release package, there are no utilities and source files, we exit
# early as there is nothing to build
if [ ! -f ./utils/build-apple-framework.sh ]; then
exit 0;
fi
# Source utilities into the scope
. ./utils/build-apple-framework.sh
# If universal framework for iOS does not exist, build one
if [ ! -d destroot/Library/Frameworks/iphoneos/hermes.framework ]; then
build_apple_framework "iphoneos" "armv7;armv7s;arm64" "#{HermesHelper::IOS_DEPLOYMENT_TARGET}"
build_apple_framework "iphonesimulator" "x86_64;i386" "#{HermesHelper::IOS_DEPLOYMENT_TARGET}"
create_universal_framework "iphoneos" "iphonesimulator"
fi
# If MacOS framework does not exist, build one
if [ ! -d destroot/Library/Frameworks/macosx/hermes.framework ]; then
build_apple_framework "macosx" "x86_64;arm64" "#{HermesHelper::OSX_DEPLOYMENT_TARGET}"
fi
EOS
end
end
61 changes: 0 additions & 61 deletions hermes.podspec

This file was deleted.

4 changes: 2 additions & 2 deletions test/ApplePlatformsIntegrationTestApp/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ source 'https://cdn.cocoapods.org/'
target 'ApplePlatformsIntegrationMobileTests' do
use_frameworks!
platform :ios, '10'
pod 'hermes', :path => '../../'
pod 'hermes-engine', :path => '../../'
end

target 'ApplePlatformsIntegrationMacTests' do
use_frameworks!
platform :osx, '10.14'
pod 'hermes', :path => '../../'
pod 'hermes-engine', :path => '../../'
end

0 comments on commit 88add0f

Please sign in to comment.