Skip to content

Commit

Permalink
Backport podspec and binary building to v0.4.1 (#299)
Browse files Browse the repository at this point in the history
* Revert "Forcefully enable Proxy" & "Bump release to v0.4.2-rc1"

This reverts commit 0ef03d9.
This reverts commit 16fb3d7.

* Backport podspec and binary building to v0.4.1

* Update CircleCI npm job to use latest Ubuntu image (#215)

Summary:
The build is currently failing (possibly because 19.04 is EOL). This updates it to just use the latest Ubuntu.
Pull Request resolved: #215

Reviewed By: willholen

Differential Revision: D21026727

Pulled By: neildhar

fbshipit-source-id: 3b0bd7e286e8d2b21d3b7122e495c3fa31f9e41a

* Use non-interactive option with apt-get (#229)

Summary:
Builds are currently failing because the tzdata package requires user
input while being installed via apt-get. Setting the environment
variable `DEBIAN_FRONTEND` to `noninteractive` forces apt-get to
bypass the requirement.
Pull Request resolved: #229

Reviewed By: tmikov

Differential Revision: D21242342

Pulled By: neildhar

fbshipit-source-id: 8f393ff785ec1f67e7ca9628dbb0cd85f2fff095

* Use apt-get in non-interactive mode for all jobs (#230)

Summary:
This change avoids future build failures due to user input
requirements when installing packages via apt-get.
Pull Request resolved: #230

Reviewed By: tmikov

Differential Revision: D21244023

Pulled By: neildhar

fbshipit-source-id: ce694c6e9b7de42a9459afe9fe2479386bbeb51c

* [ci] Fix dSYM loading by preserving symlinks

Instead packge the binaries in an extra layer of tarball, which also
saves some bytes on-disk on platforms that don't need it.

* [npm] Leave instructions for how to manually build

* [ci] The npm job doesn't require macOS artifact

* Address PR feedback.

* Pickup tar from user env

Co-authored-by: Neil Dhar <neildhar@users.noreply.github.com>
  • Loading branch information
alloy and neildhar authored Jul 29, 2020
1 parent 0ef03d9 commit ffecb5a
Show file tree
Hide file tree
Showing 33 changed files with 1,671 additions and 81 deletions.
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

0 comments on commit ffecb5a

Please sign in to comment.