Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport podspec and binary building to v0.4.1 #299

Merged
merged 10 commits into from
Jul 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 80 additions & 10 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ workflows:
- android
- linux
- macos
- build-macos-runtime
- windows
- npm:
requires:
Expand All @@ -29,6 +30,7 @@ workflows:
- windows
- test-linux
- test-macos
- test-macos-runtime-build-and-cocoapods-integration
- test-e2e:
requires:
- npm
Expand All @@ -40,6 +42,7 @@ jobs:
environment:
- HERMES_WS_DIR: /tmp/hermes
- TERM: dumb
- DEBIAN_FRONTEND: noninteractive
steps:
- checkout
- run:
Expand Down Expand Up @@ -107,6 +110,7 @@ jobs:
environment:
- HERMES_WS_DIR: /tmp/hermes
- TERM: dumb
- DEBIAN_FRONTEND: noninteractive
steps:
- run:
name: Install dependencies
Expand Down Expand Up @@ -165,6 +169,7 @@ jobs:
environment:
- HERMES_WS_DIR: /tmp/hermes
- TERM: dumb
- DEBIAN_FRONTEND: noninteractive
steps:
- run:
name: Install dependencies
Expand Down Expand Up @@ -224,7 +229,7 @@ jobs:
name: Build Hermes for macOS
command: |
cd "$HERMES_WS_DIR"
hermes/utils/build/configure.py --distribute
hermes/utils/build/configure.py --distribute --cmake-flags='-DHERMES_BUILD_APPLE_FRAMEWORK:BOOLEAN=false'
cmake --build ./build_release --target github-cli-release
- run:
name: Copy artifacts
Expand All @@ -246,6 +251,57 @@ jobs:
paths:
- .

build-macos-runtime:
macos:
xcode: "10.3.0"
environment:
- HERMES_WS_DIR: /tmp/hermes
- TERM: dumb
# Homebrew currently breaks while updating:
# https://discuss.circleci.com/t/brew-install-fails-while-updating/32992
- HOMEBREW_NO_AUTO_UPDATE: 1
steps:
- checkout
- run:
name: Install dependencies
command: |
brew install cmake ninja
- run:
name: Set up workspace
command: |
mkdir -p "$HERMES_WS_DIR" "$HERMES_WS_DIR/output" "$HERMES_WS_DIR/package-root"
ln -sf "$PWD" "$HERMES_WS_DIR/hermes"
- run:
name: Build LLVM
command: |
cd "$HERMES_WS_DIR"
hermes/utils/build/build_llvm.py --distribute llvm llvm_build
- run:
name: Build Hermes for macOS as CocoaPods pod
command: |
cd "$HERMES_WS_DIR"
hermes/utils/build/configure.py --distribute --cmake-flags="$(ruby -rcocoapods-core -e 'load %{hermes/hermes.podspec}; puts HermesHelper.cmake_configuration') -DCMAKE_INSTALL_PREFIX:PATH=../destroot"
cmake --build ./build_release --target hermes-runtime-darwin-cocoapods-release
- run:
name: Copy artifacts
command: |
cd "$HERMES_WS_DIR"
cp "build_release/github"/hermes-runtime-darwin-*.tar.gz "output"
- run:
name: Checksum artifacts
command: |
cd "$HERMES_WS_DIR/output"
for file in *
do
shasum -a 256 "$file" > "$file.sha256"
done
- store_artifacts:
path: /tmp/hermes/output/
- persist_to_workspace:
root: /tmp/hermes/output/
paths:
- .

test-macos:
# CheckedMalloc.Death fails in release mode, so build a debug version
macos:
Expand Down Expand Up @@ -279,13 +335,33 @@ jobs:
hermes/utils/build/configure.py
cmake --build ./build --target check-hermes
test-macos-runtime-build-and-cocoapods-integration:
macos:
xcode: "10.3.0"
environment:
- TERM: dumb
# Homebrew currently breaks while updating:
# https://discuss.circleci.com/t/brew-install-fails-while-updating/32992
- HOMEBREW_NO_AUTO_UPDATE: 1
steps:
- checkout
- run:
name: Install dependencies
command: |
brew install cmake ninja
- run:
name: Run CocoaPods installation and test framework
command: |
cd test/ApplePlatformsIntegrationTestApp
./run.sh
windows:
executor:
name: win/preview-default
shell: powershell.exe
environment:
- HERMES_WS_DIR: 'C:\tmp\hermes'
- ICU_URL: 'https://github.com/unicode-org/icu/releases/download/release-64-2/icu4c-64_2-Win64-MSVC2017.zip'
- ICU_URL: "https://github.com/unicode-org/icu/releases/download/release-64-2/icu4c-64_2-Win64-MSVC2017.zip"
- MSBUILD_DIR: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin'
- CMAKE_DIR: 'C:\Program Files\CMake\bin'
steps:
Expand Down Expand Up @@ -394,24 +470,18 @@ jobs:

npm:
docker:
- image: ubuntu:19.04
- image: ubuntu:rolling
environment:
- yarn: yarnpkg
- TERM: dumb
- DEBIAN_FRONTEND: noninteractive
steps:
- run:
name: Install certificates required to attach workspace
command: |
apt-get update
apt-get install -y ca-certificates
- run:
name: Temporarily work around CircleCI workspace attachment bug
command: |
# As of 2019-09-10, CircleCI fails to attach Windows workspaces without this hack
cp /usr/bin/tar /usr/bin/tar.real
printf '%s\n' '#!/bin/sh' 'exec tar.real --no-same-owner "$@"' > /usr/bin/tar
- attach_workspace:
at: /tmp/hermes/input

Expand Down
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,11 @@ buck-out

# Mac
.DS_Store

# CocoaPods testing
build
destroot
test/ApplePlatformsIntegrationTestApp/Podfile.lock
test/ApplePlatformsIntegrationTestApp/Pods
test/ApplePlatformsIntegrationTestApp/**/xcuserdata
test/ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp.xcworkspace
65 changes: 63 additions & 2 deletions API/hermes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ add_llvm_library(hermesapi
${api_sources}
LINK_LIBS jsi hermesVMRuntime)

file(GLOB api_headers ${CMAKE_CURRENT_SOURCE_DIR}/*.h)
file(GLOB api_public_headers ${PROJECT_SOURCE_DIR}/public/hermes/Public/*.h)

set(hermesapi_compile_flags "")
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" OR
"${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
Expand Down Expand Up @@ -55,7 +58,7 @@ add_llvm_library(compileJS STATIC CompileJS.cpp)
set(LLVM_REQUIRES_EH ON)
set(LLVM_REQUIRES_RTTI ON)

add_library(libhermes SHARED ${api_sources})
add_library(libhermes SHARED ${api_sources} ${api_headers} ${api_public_headers})
target_link_libraries(libhermes
jsi
hermesVMRuntime
Expand Down Expand Up @@ -85,5 +88,63 @@ set_target_properties(libhermes PROPERTIES
CXX_STANDARD_REQUIRED 14
# Avoid becoming liblibhermes (and there's already a target called 'hermes')
OUTPUT_NAME hermes
)

if(APPLE AND HERMES_BUILD_APPLE_FRAMEWORK)
set_target_properties(libhermes PROPERTIES
FRAMEWORK TRUE
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION}
FRAMEWORK_VERSION ${PROJECT_VERSION_MAJOR}
MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${PROJECT_VERSION}
MACOSX_FRAMEWORK_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_FRAMEWORK_IDENTIFIER dev.hermesengine.${CMAKE_SYSTEM_NAME}
)
# Install headers into `Headers` while keeping required directory structure
set_source_files_properties(${api_headers} PROPERTIES
MACOSX_PACKAGE_LOCATION Headers
)
set_source_files_properties(${api_public_headers} PROPERTIES
MACOSX_PACKAGE_LOCATION Headers/Public
)
endif()

install(TARGETS libhermes
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
FRAMEWORK DESTINATION Library/Frameworks
)
# Install headers into `include` while keeping required directory structure
install(DIRECTORY "${PROJECT_SOURCE_DIR}/API/hermes" DESTINATION include
FILES_MATCHING PATTERN "*.h"
PATTERN "synthtest" EXCLUDE)

# Create debug symbols (dSYM) bundle for Apple platform dylibs/frameworks
# Largely inspired by https://github.com/llvm/llvm-project/blob/6701993027f8af172d7ba697884459261b00e3c6/llvm/cmake/modules/AddLLVM.cmake#L1934-L1986
if(HERMES_BUILD_APPLE_DSYM)
if(CMAKE_CXX_FLAGS MATCHES "-flto")
set(lto_object ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/libhermes-lto.o)
set_property(TARGET libhermes APPEND_STRING PROPERTY LINK_FLAGS " -Wl,-object_path_lto,${lto_object}")
endif()

get_target_property(DSYM_PATH libhermes LOCATION)
if(HERMES_BUILD_APPLE_FRAMEWORK)
get_filename_component(DSYM_PATH ${DSYM_PATH} DIRECTORY)
endif()
set(DSYM_PATH "${DSYM_PATH}.dSYM")

if(NOT CMAKE_DSYMUTIL)
set(CMAKE_DSYMUTIL xcrun dsymutil)
endif()
add_custom_command(TARGET libhermes POST_BUILD
COMMAND ${CMAKE_DSYMUTIL} $<TARGET_FILE:libhermes> --out ${DSYM_PATH}
BYPRODUCTS ${DSYM_PATH}
)
hermes_link_icu(libhermes)

if(HERMES_BUILD_APPLE_FRAMEWORK)
install(DIRECTORY ${DSYM_PATH} DESTINATION Library/Frameworks)
else()
install(DIRECTORY ${DSYM_PATH} DESTINATION lib)
endif()
endif()
4 changes: 4 additions & 0 deletions API/jsi/jsi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC")
list(APPEND jsi_compile_flags "/EHsc")
endif()
target_compile_options(jsi PUBLIC ${jsi_compile_flags})

install(DIRECTORY "${PROJECT_SOURCE_DIR}/API/jsi/" DESTINATION include
FILES_MATCHING PATTERN "*.h"
PATTERN "test" EXCLUDE)
Loading