From 791ca1bb715afb38e0930cc418e23caac40a9fcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eloy=20Dur=C3=A1n?= Date: Thu, 16 Jul 2020 20:37:40 +0200 Subject: [PATCH 01/10] Revert "Forcefully enable Proxy" & "Bump release to v0.4.2-rc1" This reverts commit 0ef03d9a07f1deff6ec486f3b845bd5bc8d423c8. This reverts commit 16fb3d7aca52f345ff3f20f1d008a1c4423c389f. --- CMakeLists.txt | 6 ++---- android/build.gradle | 2 +- lib/VM/Runtime.cpp | 2 +- npm/package.json | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bff4d5bf2d2..14d0ec61435 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,15 +25,13 @@ endif() # This must be consistent with the release_version in # android/build.gradle and npm/package.json project(Hermes - VERSION 0.4.2 + VERSION 0.4.1 LANGUAGES C CXX) -# Optional suffix like "-rc3" -set(VERSION_SUFFIX "-rc1") include(CheckCXXCompilerFlag) include(CheckCXXSourceCompiles) -set(HERMES_RELEASE_VERSION ${PROJECT_VERSION}${VERSION_SUFFIX}) +set(HERMES_RELEASE_VERSION ${PROJECT_VERSION}) # Project options. set(HERMESVM_GCKIND NONCONTIG_GENERATIONAL diff --git a/android/build.gradle b/android/build.gradle index 469680c1393..0fc57650cf1 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -7,7 +7,7 @@ // This must be consistent with the release_version in npm/package.json // and the HERMES_RELEASE_VERSION in CMakeLists.txt -def release_version = "0.4.2-rc1" +def release_version = "0.4.1" buildscript { ext { diff --git a/lib/VM/Runtime.cpp b/lib/VM/Runtime.cpp index d57763d292e..9e2ee777c69 100644 --- a/lib/VM/Runtime.cpp +++ b/lib/VM/Runtime.cpp @@ -172,7 +172,7 @@ Runtime::Runtime(StorageProvider *provider, const RuntimeConfig &runtimeConfig) runtimeConfig.getCrashMgr(), provider), jitContext_(runtimeConfig.getEnableJIT(), (1 << 20) * 8, (1 << 20) * 32), - hasES6Proxy_(true), + hasES6Proxy_(runtimeConfig.getES6Proxy()), hasES6Symbol_(runtimeConfig.getES6Symbol()), shouldRandomizeMemoryLayout_(runtimeConfig.getRandomizeMemoryLayout()), bytecodeWarmupPercent_(runtimeConfig.getBytecodeWarmupPercent()), diff --git a/npm/package.json b/npm/package.json index 3ccd6cafb4d..ded6a4c944b 100644 --- a/npm/package.json +++ b/npm/package.json @@ -1,6 +1,6 @@ { "name": "hermes-engine", - "version": "0.4.2-rc1", + "version": "0.4.1", "private": false, "description": "A JavaScript engine optimized for running React Native on Android", "license": "MIT", From 44a3fddab6a6f9c6e6af8182e2e38eb8a518ce88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eloy=20Dur=C3=A1n?= Date: Wed, 8 Jul 2020 17:13:30 -0700 Subject: [PATCH 02/10] Backport podspec and binary building to v0.4.1 --- .circleci/config.yml | 78 +- .gitignore | 8 + API/hermes/CMakeLists.txt | 65 +- API/jsi/jsi/CMakeLists.txt | 4 + CMakeLists.txt | 170 +++-- hermes.podspec | 63 ++ npm/.gitignore | 5 + npm/fetch.js | 4 + npm/hermes-engine-darwin/README.md | 12 + npm/hermes-engine-darwin/package.json | 19 + public/CMakeLists.txt | 2 +- public/hermes/Public/CMakeLists.txt | 7 + .../project.pbxproj | 391 ++++++++++ .../contents.xcworkspacedata | 7 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + .../AppDelegate.h | 11 + .../AppDelegate.mm | 27 + ...lePlatformsIntegrationTestApp.entitlements | 10 + .../Base.lproj/Main.storyboard | 701 ++++++++++++++++++ .../Info.plist | 34 + .../ApplePlatformsIntegrationTestApp/main.m | 12 + test/ApplePlatformsIntegrationTestApp/Podfile | 7 + test/ApplePlatformsIntegrationTestApp/run.sh | 26 + tools/hbcdump/CMakeLists.txt | 4 + tools/hdb/CMakeLists.txt | 6 + tools/hermes/CMakeLists.txt | 4 + tools/hermesc/CMakeLists.txt | 4 + tools/hvm/CMakeLists.txt | 3 + tools/jsi/CMakeLists.txt | 1 + 29 files changed, 1627 insertions(+), 66 deletions(-) create mode 100644 hermes.podspec create mode 100644 npm/hermes-engine-darwin/README.md create mode 100644 npm/hermes-engine-darwin/package.json create mode 100644 public/hermes/Public/CMakeLists.txt create mode 100644 test/ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp.xcodeproj/project.pbxproj create mode 100644 test/ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 test/ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 test/ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp/AppDelegate.h create mode 100644 test/ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp/AppDelegate.mm create mode 100644 test/ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp.entitlements create mode 100644 test/ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp/Base.lproj/Main.storyboard create mode 100644 test/ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp/Info.plist create mode 100644 test/ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp/main.m create mode 100644 test/ApplePlatformsIntegrationTestApp/Podfile create mode 100755 test/ApplePlatformsIntegrationTestApp/run.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index 16191aff7c2..ade06351686 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -20,15 +20,18 @@ workflows: - android - linux - macos + - build-macos-runtime - windows - npm: requires: - android - linux - macos + - build-macos-runtime - windows - test-linux - test-macos + - test-macos-runtime-build-and-cocoapods-integration - test-e2e: requires: - npm @@ -224,7 +227,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 @@ -246,6 +249,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: @@ -279,13 +333,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: diff --git a/.gitignore b/.gitignore index 6da96a9cffa..22065d8d27f 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/API/hermes/CMakeLists.txt b/API/hermes/CMakeLists.txt index 33f88215ff0..1f3806b8559 100644 --- a/API/hermes/CMakeLists.txt +++ b/API/hermes/CMakeLists.txt @@ -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") @@ -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 @@ -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} $ --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() diff --git a/API/jsi/jsi/CMakeLists.txt b/API/jsi/jsi/CMakeLists.txt index 6a2db94383d..510346a8c5a 100644 --- a/API/jsi/jsi/CMakeLists.txt +++ b/API/jsi/jsi/CMakeLists.txt @@ -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) diff --git a/CMakeLists.txt b/CMakeLists.txt index 14d0ec61435..6be47211cfc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,8 +22,17 @@ if (POLICY CMP0075) cmake_policy(SET CMP0075 NEW) endif() -# This must be consistent with the release_version in -# android/build.gradle and npm/package.json +# Allow reading the LOCATION property of a target to determine the eventual +# location of build targets. This is needed when building the debugging symbols +# bundles for Apple platforms. +if (POLICY CMP0026) + cmake_policy(SET CMP0026 OLD) +endif() + +# This must be consistent with the release_version in: +# - android/build.gradle +# - npm/package.json +# - hermes.podspec project(Hermes VERSION 0.4.1 LANGUAGES C CXX) @@ -126,11 +135,21 @@ set(ANDROID_LINUX_PERF_PATH "" set(HERMES_MSVC_MP ON CACHE STRING "Enable /MP in MSVC for parallel builds") -# On Android we need an ABI specific version of LLVM. -# Unfortunately, the build system doesn't allow setting the -# LLVM_BUILD_DIR per ABI, so we do it here instead. +set(HERMES_ENABLE_TEST_SUITE ON CACHE BOOL + "Enable the test suite") + +set(HERMES_BUILD_APPLE_FRAMEWORK ON CACHE BOOL + "Whether to build the libhermes target as a framework bundle or dylib on Apple platforms") + +set(HERMES_BUILD_APPLE_DSYM OFF CACHE BOOL + "Whether to build a DWARF debugging symbols bundle") + if (HERMES_IS_ANDROID) + # On Android we need an ABI specific version of LLVM. + # Unfortunately, the build system doesn't allow setting the + # LLVM_BUILD_DIR per ABI, so we do it here instead. set(LLVM_BUILD_DIR "${LLVM_BUILD_BASE}-${ANDROID_ABI}") + add_definitions(-DHERMES_PLATFORM_UNICODE=HERMES_PLATFORM_UNICODE_JAVA) # The toolchain passes -Wa,--noexecstack which is valid for compiling @@ -151,6 +170,10 @@ if (HERMES_IS_ANDROID) endif() endif() +if(HERMES_BUILD_APPLE_DSYM) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -gdwarf") +endif() + # The hermes project is built using CMake and the LLVM's build system. # It expects LLVM_SRC_DIR and LLVM_BUILD_DIR to be set. For example: # @@ -346,6 +369,8 @@ endif() set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(LLVM_MAIN_SRC_DIR ${LLVM_SRC_DIR}) +# Do not install llvm artefacts. +set(LLVM_INSTALL_TOOLCHAIN_ONLY ON) include(LLVMConfig) include(AddLLVM) include(HandleLLVMOptions) @@ -499,68 +524,72 @@ endif() add_subdirectory(tools) add_subdirectory(include) add_subdirectory(lib) +add_subdirectory(public) add_subdirectory(external) -add_subdirectory(unittests) add_subdirectory(${HERMES_JSI_DIR}/jsi ${CMAKE_CURRENT_BINARY_DIR}/jsi) add_subdirectory(API) # Configure the test suites # -list(APPEND HERMES_TEST_DEPS - HermesUnitTests - hermes - hermesc - hvm - interp-dispatch-bench - hdb - hbcdump - hermes-repl - hbc-attribute - hbc-deltaprep - hbc-diff - llvm-config - ) - -set(HERMES_LIT_TEST_PARAMS - test_exec_root=${HERMES_BINARY_DIR}/test - unittests_dir=${HERMES_BINARY_DIR}/unittests - debugger_enabled=${HERMES_ENABLE_DEBUGGER} - use_flowparser=${HERMES_USE_FLOWPARSER} - jit_enabled=${HERMESVM_JIT} - jit_disassembler_enabled=${HERMESVM_JIT_DISASSEMBLER} - hbc_deltaprep=${HERMES_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/hbc-deltaprep - FileCheck=${LLVM_BUILD_DIR}/${CMAKE_CFG_INTDIR}/bin/FileCheck - hermes=${HERMES_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/hermes - hermesc=${HERMES_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/hermesc - hdb=${HERMES_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/hdb - hbcdump=${HERMES_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/hbcdump - repl=${HERMES_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/hermes-repl - hbc-deltaprep=${HERMES_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/hbc-deltaprep - hbc_diff=${HERMES_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/hbc-diff - build_mode=${HERMES_ASSUMED_BUILD_MODE_IN_LIT_TEST} - exception_on_oom_enabled=${HERMESVM_EXCEPTION_ON_OOM} - serialize_enabled=${HERMESVM_SERIALIZE} - profiler=${HERMES_PROFILER_MODE_IN_LIT_TEST} - use_js_library_implementation=${HERMESVM_USE_JS_LIBRARY_IMPLEMENTATION} - gc=${HERMESVM_GCKIND} - # TODO: Figure out how to tell if CMake is doing a UBSAN build. - ubsan=OFF - ) - -set(LLVM_LIT_ARGS "-sv") - -# This is a hack to help LLVM find its own llvm-lit tool, since we had to set -# LLVM_RUNTIME_OUTPUT_INTDIR to our own build dir. -set(LLVM_LIT_OUTPUT_DIR ${LLVM_BUILD_DIR}/${CMAKE_CFG_INTDIR}/bin) - -add_lit_testsuite(check-hermes "Running the Hermes regression tests" - ${HERMES_SOURCE_DIR}/test - ${HERMES_SOURCE_DIR}/unittests - PARAMS ${HERMES_LIT_TEST_PARAMS} - DEPENDS ${HERMES_TEST_DEPS} - ARGS ${HERMES_TEST_EXTRA_ARGS} - ) -set_target_properties(check-hermes PROPERTIES FOLDER "Hermes regression tests") +if(HERMES_ENABLE_TEST_SUITE) + add_subdirectory(unittests) + + list(APPEND HERMES_TEST_DEPS + HermesUnitTests + hermes + hermesc + hvm + interp-dispatch-bench + hdb + hbcdump + hermes-repl + hbc-attribute + hbc-deltaprep + hbc-diff + llvm-config + ) + + set(HERMES_LIT_TEST_PARAMS + test_exec_root=${HERMES_BINARY_DIR}/test + unittests_dir=${HERMES_BINARY_DIR}/unittests + debugger_enabled=${HERMES_ENABLE_DEBUGGER} + use_flowparser=${HERMES_USE_FLOWPARSER} + jit_enabled=${HERMESVM_JIT} + jit_disassembler_enabled=${HERMESVM_JIT_DISASSEMBLER} + hbc_deltaprep=${HERMES_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/hbc-deltaprep + FileCheck=${LLVM_BUILD_DIR}/${CMAKE_CFG_INTDIR}/bin/FileCheck + hermes=${HERMES_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/hermes + hermesc=${HERMES_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/hermesc + hdb=${HERMES_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/hdb + hbcdump=${HERMES_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/hbcdump + repl=${HERMES_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/hermes-repl + hbc-deltaprep=${HERMES_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/hbc-deltaprep + hbc_diff=${HERMES_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/hbc-diff + build_mode=${HERMES_ASSUMED_BUILD_MODE_IN_LIT_TEST} + exception_on_oom_enabled=${HERMESVM_EXCEPTION_ON_OOM} + serialize_enabled=${HERMESVM_SERIALIZE} + profiler=${HERMES_PROFILER_MODE_IN_LIT_TEST} + use_js_library_implementation=${HERMESVM_USE_JS_LIBRARY_IMPLEMENTATION} + gc=${HERMESVM_GCKIND} + # TODO: Figure out how to tell if CMake is doing a UBSAN build. + ubsan=OFF + ) + + set(LLVM_LIT_ARGS "-sv") + + # This is a hack to help LLVM find its own llvm-lit tool, since we had to set + # LLVM_RUNTIME_OUTPUT_INTDIR to our own build dir. + set(LLVM_LIT_OUTPUT_DIR ${LLVM_BUILD_DIR}/${CMAKE_CFG_INTDIR}/bin) + + add_lit_testsuite(check-hermes "Running the Hermes regression tests" + ${HERMES_SOURCE_DIR}/test + ${HERMES_SOURCE_DIR}/unittests + PARAMS ${HERMES_LIT_TEST_PARAMS} + DEPENDS ${HERMES_TEST_DEPS} + ARGS ${HERMES_TEST_EXTRA_ARGS} + ) + set_target_properties(check-hermes PROPERTIES FOLDER "Hermes regression tests") +endif() # This is how github release files are built. @@ -601,3 +630,22 @@ add_custom_command( add_custom_target( github-cli-release DEPENDS ${HERMES_GITHUB_DIR}/${HERMES_CLI_GITHUB_FILE}) + +set(HERMES_PKG_ROOT ${HERMES_GITHUB_DIR}/package-root) +set(HERMES_PKG_FRAMEWORK ${HERMES_PKG_ROOT}/destroot/Library/Frameworks/hermes.framework) + +add_custom_target( + hermes-runtime-darwin-cocoapods-release + COMMAND + ${CMAKE_COMMAND} --build . --target install/strip + COMMAND + mkdir -p ${HERMES_PKG_ROOT} + COMMAND + cp -R -f ${CMAKE_INSTALL_PREFIX} ${HERMES_PKG_ROOT}/destroot + COMMAND + rm -r ${HERMES_PKG_FRAMEWORK}/{Headers,Resources,hermes} && mv ${HERMES_PKG_FRAMEWORK}/Versions/0/* ${HERMES_PKG_FRAMEWORK}/ && rm -r ${HERMES_PKG_FRAMEWORK}/Versions && install_name_tool -id @rpath/hermes.framework/hermes ${HERMES_PKG_FRAMEWORK}/hermes + COMMAND + cp ${CMAKE_CURRENT_SOURCE_DIR}/hermes.podspec ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/README.md ${HERMES_PKG_ROOT} + COMMAND + tar -C ${HERMES_PKG_ROOT}/ -czhf ${HERMES_GITHUB_DIR}/hermes-runtime-${HERMES_GITHUB_SYSTEM_NAME}-v${HERMES_RELEASE_VERSION}.tar.gz . +) diff --git a/hermes.podspec b/hermes.podspec new file mode 100644 index 00000000000..c69dab8805e --- /dev/null +++ b/hermes.podspec @@ -0,0 +1,63 @@ +# 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 + + def self.command_exists?(bin) + "command -v #{bin} > /dev/null 2>&1" + end + + def self.llvm_configure_command + "./utils/build/build_llvm.py #{"--distribute" if BUILD_TYPE == :release}" + end + + def self.cmake_configuration + "-DHERMES_ENABLE_DEBUGGER:BOOLEAN=true -DHERMES_ENABLE_TEST_SUITE:BOOLEAN=false -DHERMES_BUILD_APPLE_FRAMEWORK:BOOLEAN=true -DHERMES_BUILD_APPLE_DSYM:BOOLEAN=true" + end + + def self.configure_command + "./utils/build/configure.py #{BUILD_TYPE == :release ? "--distribute" : "--build-type=Debug"} --cmake-flags='#{HermesHelper.cmake_configuration} -DCMAKE_INSTALL_PREFIX:PATH=../destroot' build" + end + + def self.build_dir + BUILD_TYPE == :release ? "build_release" : "build" + end +end + +Pod::Spec.new do |spec| + spec.name = "hermes" + spec.version = "0.4.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" + spec.source = { git: "https://github.com/facebook/hermes.git", tag: "v#{spec.version}" } + spec.platforms = { :osx => "10.14" } + + 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.vendored_frameworks = "destroot/Library/Frameworks/hermes.framework" + spec.xcconfig = { "CLANG_CXX_LANGUAGE_STANDARD" => "c++14", "CLANG_CXX_LIBRARY" => "compiler-default", "GCC_PREPROCESSOR_DEFINITIONS" => "HERMES_ENABLE_DEBUGGER=1" } + + spec.prepare_command = <<-EOS + if [ ! -d destroot/Library/Frameworks/hermes.framework ]; then + #{HermesHelper.llvm_configure_command} + if #{HermesHelper.command_exists?("cmake")}; then + if #{HermesHelper.command_exists?("ninja")}; then + #{HermesHelper.configure_command} --build-system='Ninja' && cd #{HermesHelper.build_dir} && ninja install/strip + else + #{HermesHelper.configure_command} --build-system='Unix Makefiles' && cd #{HermesHelper.build_dir} && make install/strip + fi + else + echo >&2 'CMake is required to install Hermes, install it with: brew install cmake' + exit 1 + fi + fi + EOS +end diff --git a/npm/.gitignore b/npm/.gitignore index 3ec2afa4d63..77569eeb113 100644 --- a/npm/.gitignore +++ b/npm/.gitignore @@ -1,6 +1,11 @@ *.tar.gz *.tgz +*.sha256 android node_modules osx-bin package-lock.json +destroot +LICENSE +README.md +hermes.podspec diff --git a/npm/fetch.js b/npm/fetch.js index 5c123459774..fb8c41f986e 100644 --- a/npm/fetch.js +++ b/npm/fetch.js @@ -148,6 +148,10 @@ var inputs = [ { name: "hermes-cli-darwin-v" + releaseVersion + ".tar.gz", dest: "osx-bin" + }, + { + name: "hermes-runtime-darwin-v" + releaseVersion + ".tar.gz", + dest: ".", } ] diff --git a/npm/hermes-engine-darwin/README.md b/npm/hermes-engine-darwin/README.md new file mode 100644 index 00000000000..79b2aff6765 --- /dev/null +++ b/npm/hermes-engine-darwin/README.md @@ -0,0 +1,12 @@ +## Hermes + +Hermes is a small and lightweight JavaScript VM optimized for running React +Native apps on macOS. + +See [hermesengine.dev](https://hermesengine.dev) for more information. + +This package contains a Hermes bytecode compiler for macOS, plus macOS runtime +framework. + +Additional tools are available in +[hermes-engine-cli](https://www.npmjs.com/package/hermes-engine-cli). diff --git a/npm/hermes-engine-darwin/package.json b/npm/hermes-engine-darwin/package.json new file mode 100644 index 00000000000..cc7087f1802 --- /dev/null +++ b/npm/hermes-engine-darwin/package.json @@ -0,0 +1,19 @@ +{ + "name": "hermes-engine-darwin", + "version": "%VERSION%", + "private": false, + "description": "A JavaScript engine optimized for running React Native on macOS", + "license": "MIT", + "repository": { + "type": "git", + "url": "git@github.com:facebook/hermes.git" + }, + "files": [ + "LICENSE", + "README.md", + "hermes.podspec", + "destroot/bin/hermesc", + "destroot/include/**/*", + "destroot/Library/**/*" + ] +} diff --git a/public/CMakeLists.txt b/public/CMakeLists.txt index 9e00cf90616..f274fe5f229 100644 --- a/public/CMakeLists.txt +++ b/public/CMakeLists.txt @@ -3,4 +3,4 @@ # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. -add_subdirectory(hermes) +add_subdirectory(hermes/Public) diff --git a/public/hermes/Public/CMakeLists.txt b/public/hermes/Public/CMakeLists.txt new file mode 100644 index 00000000000..0f04f40a1b3 --- /dev/null +++ b/public/hermes/Public/CMakeLists.txt @@ -0,0 +1,7 @@ +# 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. + +install(DIRECTORY "${PROJECT_SOURCE_DIR}/public/hermes/Public" DESTINATION include/hermes + FILES_MATCHING PATTERN "*.h") diff --git a/test/ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp.xcodeproj/project.pbxproj b/test/ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp.xcodeproj/project.pbxproj new file mode 100644 index 00000000000..1c8ec892181 --- /dev/null +++ b/test/ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp.xcodeproj/project.pbxproj @@ -0,0 +1,391 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 51; + objects = { + +/* Begin PBXBuildFile section */ + 13FD1E23BAD24B7D00FF22CB /* Pods_ApplePlatformsIntegrationTestApp.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C07B9F4D127D4B52FF9015AB /* Pods_ApplePlatformsIntegrationTestApp.framework */; }; + 51387F3D24B4D93100BDA32A /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51387F3C24B4D93100BDA32A /* AppDelegate.mm */; }; + 51387F4824B4D93300BDA32A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 51387F4724B4D93300BDA32A /* main.m */; }; + 51387F5124B4E4B900BDA32A /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 51387F4F24B4E4B900BDA32A /* Main.storyboard */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 51387F3824B4D93100BDA32A /* ApplePlatformsIntegrationTestApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ApplePlatformsIntegrationTestApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 51387F3B24B4D93100BDA32A /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 51387F3C24B4D93100BDA32A /* AppDelegate.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = AppDelegate.mm; sourceTree = ""; }; + 51387F4624B4D93300BDA32A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 51387F4724B4D93300BDA32A /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 51387F4924B4D93300BDA32A /* ApplePlatformsIntegrationTestApp.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = ApplePlatformsIntegrationTestApp.entitlements; sourceTree = ""; }; + 51387F5024B4E4B900BDA32A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 7185E82510338F98E6D5ABAE /* Pods-ApplePlatformsIntegrationTestApp.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ApplePlatformsIntegrationTestApp.release.xcconfig"; path = "Target Support Files/Pods-ApplePlatformsIntegrationTestApp/Pods-ApplePlatformsIntegrationTestApp.release.xcconfig"; sourceTree = ""; }; + A1B2AE6857A1A970726F1351 /* Pods-ApplePlatformsIntegrationTestApp.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ApplePlatformsIntegrationTestApp.debug.xcconfig"; path = "Target Support Files/Pods-ApplePlatformsIntegrationTestApp/Pods-ApplePlatformsIntegrationTestApp.debug.xcconfig"; sourceTree = ""; }; + C07B9F4D127D4B52FF9015AB /* Pods_ApplePlatformsIntegrationTestApp.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ApplePlatformsIntegrationTestApp.framework; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 51387F3524B4D93100BDA32A /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 13FD1E23BAD24B7D00FF22CB /* Pods_ApplePlatformsIntegrationTestApp.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 51387F2F24B4D93100BDA32A = { + isa = PBXGroup; + children = ( + 51387F3A24B4D93100BDA32A /* ApplePlatformsIntegrationTestApp */, + 51387F3924B4D93100BDA32A /* Products */, + 5B15161F422A44367877CB3E /* Pods */, + 95D715CE5183719D082A4A7B /* Frameworks */, + ); + sourceTree = ""; + }; + 51387F3924B4D93100BDA32A /* Products */ = { + isa = PBXGroup; + children = ( + 51387F3824B4D93100BDA32A /* ApplePlatformsIntegrationTestApp.app */, + ); + name = Products; + sourceTree = ""; + }; + 51387F3A24B4D93100BDA32A /* ApplePlatformsIntegrationTestApp */ = { + isa = PBXGroup; + children = ( + 51387F3B24B4D93100BDA32A /* AppDelegate.h */, + 51387F3C24B4D93100BDA32A /* AppDelegate.mm */, + 51387F4624B4D93300BDA32A /* Info.plist */, + 51387F4724B4D93300BDA32A /* main.m */, + 51387F4924B4D93300BDA32A /* ApplePlatformsIntegrationTestApp.entitlements */, + 51387F4F24B4E4B900BDA32A /* Main.storyboard */, + ); + path = ApplePlatformsIntegrationTestApp; + sourceTree = ""; + }; + 5B15161F422A44367877CB3E /* Pods */ = { + isa = PBXGroup; + children = ( + A1B2AE6857A1A970726F1351 /* Pods-ApplePlatformsIntegrationTestApp.debug.xcconfig */, + 7185E82510338F98E6D5ABAE /* Pods-ApplePlatformsIntegrationTestApp.release.xcconfig */, + ); + path = Pods; + sourceTree = ""; + }; + 95D715CE5183719D082A4A7B /* Frameworks */ = { + isa = PBXGroup; + children = ( + C07B9F4D127D4B52FF9015AB /* Pods_ApplePlatformsIntegrationTestApp.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 51387F3724B4D93100BDA32A /* ApplePlatformsIntegrationTestApp */ = { + isa = PBXNativeTarget; + buildConfigurationList = 51387F4C24B4D93300BDA32A /* Build configuration list for PBXNativeTarget "ApplePlatformsIntegrationTestApp" */; + buildPhases = ( + 54731B4A78B0349CFCF73729 /* [CP] Check Pods Manifest.lock */, + 51387F3424B4D93100BDA32A /* Sources */, + 51387F3524B4D93100BDA32A /* Frameworks */, + 51387F3624B4D93100BDA32A /* Resources */, + 23A2AA98BD411224E4C9BBCA /* [CP] Embed Pods Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = ApplePlatformsIntegrationTestApp; + productName = ApplePlatformsIntegrationTestApp; + productReference = 51387F3824B4D93100BDA32A /* ApplePlatformsIntegrationTestApp.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 51387F3024B4D93100BDA32A /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1150; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 51387F3724B4D93100BDA32A = { + CreatedOnToolsVersion = 11.5; + }; + }; + }; + buildConfigurationList = 51387F3324B4D93100BDA32A /* Build configuration list for PBXProject "ApplePlatformsIntegrationTestApp" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 51387F2F24B4D93100BDA32A; + productRefGroup = 51387F3924B4D93100BDA32A /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 51387F3724B4D93100BDA32A /* ApplePlatformsIntegrationTestApp */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 51387F3624B4D93100BDA32A /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 51387F5124B4E4B900BDA32A /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 23A2AA98BD411224E4C9BBCA /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-ApplePlatformsIntegrationTestApp/Pods-ApplePlatformsIntegrationTestApp-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-ApplePlatformsIntegrationTestApp/Pods-ApplePlatformsIntegrationTestApp-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-ApplePlatformsIntegrationTestApp/Pods-ApplePlatformsIntegrationTestApp-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + 54731B4A78B0349CFCF73729 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-ApplePlatformsIntegrationTestApp-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 51387F3424B4D93100BDA32A /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 51387F4824B4D93300BDA32A /* main.m in Sources */, + 51387F3D24B4D93100BDA32A /* AppDelegate.mm in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 51387F4F24B4E4B900BDA32A /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 51387F5024B4E4B900BDA32A /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 51387F4A24B4D93300BDA32A /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.15; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + 51387F4B24B4D93300BDA32A /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.15; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = macosx; + }; + name = Release; + }; + 51387F4D24B4D93300BDA32A /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = A1B2AE6857A1A970726F1351 /* Pods-ApplePlatformsIntegrationTestApp.debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_ENTITLEMENTS = ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = ApplePlatformsIntegrationTestApp/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = 10.14; + PRODUCT_BUNDLE_IDENTIFIER = dev.hermesengine.ApplePlatformsIntegrationTestApp; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 51387F4E24B4D93300BDA32A /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7185E82510338F98E6D5ABAE /* Pods-ApplePlatformsIntegrationTestApp.release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_ENTITLEMENTS = ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = ApplePlatformsIntegrationTestApp/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = 10.14; + PRODUCT_BUNDLE_IDENTIFIER = dev.hermesengine.ApplePlatformsIntegrationTestApp; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 51387F3324B4D93100BDA32A /* Build configuration list for PBXProject "ApplePlatformsIntegrationTestApp" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 51387F4A24B4D93300BDA32A /* Debug */, + 51387F4B24B4D93300BDA32A /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 51387F4C24B4D93300BDA32A /* Build configuration list for PBXNativeTarget "ApplePlatformsIntegrationTestApp" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 51387F4D24B4D93300BDA32A /* Debug */, + 51387F4E24B4D93300BDA32A /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 51387F3024B4D93100BDA32A /* Project object */; +} diff --git a/test/ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/test/ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000000..960f3fd899a --- /dev/null +++ b/test/ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/test/ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/test/ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000000..18d981003d6 --- /dev/null +++ b/test/ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/test/ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp/AppDelegate.h b/test/ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp/AppDelegate.h new file mode 100644 index 00000000000..a2cfe310d72 --- /dev/null +++ b/test/ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp/AppDelegate.h @@ -0,0 +1,11 @@ +/* + * 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. + */ + +#import + +@interface AppDelegate : NSObject +@end diff --git a/test/ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp/AppDelegate.mm b/test/ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp/AppDelegate.mm new file mode 100644 index 00000000000..8f6f574df70 --- /dev/null +++ b/test/ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp/AppDelegate.mm @@ -0,0 +1,27 @@ +/* + * 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. + */ + +#import "AppDelegate.h" + +#import +#import + +@interface AppDelegate () +@end + +@implementation AppDelegate + +- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { + std::string s = "print('Hello world -- son of Maia and Zeus');"; + std::string url = "http://example/js"; + facebook::hermes::HermesRuntime::DebugFlags flags; + auto runtime = facebook::hermes::makeHermesRuntime(); + runtime->debugJavaScript(s, url, flags); + exit(0); +} + +@end diff --git a/test/ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp.entitlements b/test/ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp.entitlements new file mode 100644 index 00000000000..f2ef3ae0265 --- /dev/null +++ b/test/ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.files.user-selected.read-only + + + diff --git a/test/ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp/Base.lproj/Main.storyboard b/test/ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp/Base.lproj/Main.storyboard new file mode 100644 index 00000000000..04f96e03037 --- /dev/null +++ b/test/ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp/Base.lproj/Main.storyboard @@ -0,0 +1,701 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Default + + + + + + + Left to Right + + + + + + + Right to Left + + + + + + + + + + + Default + + + + + + + Left to Right + + + + + + + Right to Left + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp/Info.plist b/test/ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp/Info.plist new file mode 100644 index 00000000000..e87993de178 --- /dev/null +++ b/test/ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp/Info.plist @@ -0,0 +1,34 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSMainStoryboardFile + Main + NSPrincipalClass + NSApplication + NSSupportsAutomaticTermination + + NSSupportsSuddenTermination + + + diff --git a/test/ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp/main.m b/test/ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp/main.m new file mode 100644 index 00000000000..0a358452bf8 --- /dev/null +++ b/test/ApplePlatformsIntegrationTestApp/ApplePlatformsIntegrationTestApp/main.m @@ -0,0 +1,12 @@ +/* + * 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. + */ + +#import + +int main(int argc, const char *argv[]) { + return NSApplicationMain(argc, argv); +} diff --git a/test/ApplePlatformsIntegrationTestApp/Podfile b/test/ApplePlatformsIntegrationTestApp/Podfile new file mode 100644 index 00000000000..6480cd03499 --- /dev/null +++ b/test/ApplePlatformsIntegrationTestApp/Podfile @@ -0,0 +1,7 @@ +source 'https://cdn.cocoapods.org/' + +target 'ApplePlatformsIntegrationTestApp' do + use_frameworks! + platform :osx, '10.14' + pod 'hermes', :path => '../../' +end diff --git a/test/ApplePlatformsIntegrationTestApp/run.sh b/test/ApplePlatformsIntegrationTestApp/run.sh new file mode 100755 index 00000000000..f84f2e2adc8 --- /dev/null +++ b/test/ApplePlatformsIntegrationTestApp/run.sh @@ -0,0 +1,26 @@ +#!/bin/sh +# 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. + +XCODEBUILD="xcodebuild -workspace ApplePlatformsIntegrationTestApp.xcworkspace -configuration Debug -scheme ApplePlatformsIntegrationTestApp" + +# Build +pod install +$XCODEBUILD +# Get path to product +PRODUCT=$($XCODEBUILD -showBuildSettings | grep -m 1 "BUILT_PRODUCTS_DIR" | grep -oEi "\/.*") +# Launch +OUTPUT=$($PRODUCT/ApplePlatformsIntegrationTestApp.app/Contents/MacOS/ApplePlatformsIntegrationTestApp) +# Test +EXPECTED_OUTPUT="Hello world -- son of Maia and Zeus" +if [[ $OUTPUT != $EXPECTED_OUTPUT ]]; then + echo "Expected output to be '$EXPECTED_OUTPUT', but got '$OUTPUT'" + echo "** TEST FAILED **" + exit 1 +else + echo $OUTPUT + echo "** TEST SUCCEEDED **" + exit 0 +fi diff --git a/tools/hbcdump/CMakeLists.txt b/tools/hbcdump/CMakeLists.txt index 266ba0cf6f3..f367d68b15e 100644 --- a/tools/hbcdump/CMakeLists.txt +++ b/tools/hbcdump/CMakeLists.txt @@ -23,3 +23,7 @@ target_link_libraries(hbcdump ) hermes_link_icu(hbcdump) + +install(TARGETS hbcdump + RUNTIME DESTINATION bin +) diff --git a/tools/hdb/CMakeLists.txt b/tools/hdb/CMakeLists.txt index e94e414aa4a..ba45a8424f4 100644 --- a/tools/hdb/CMakeLists.txt +++ b/tools/hdb/CMakeLists.txt @@ -20,3 +20,9 @@ set_target_properties(hdb PROPERTIES target_link_libraries(hdb hermesapi ) + +hermes_link_icu(hdb) + +install(TARGETS hdb + RUNTIME DESTINATION bin +) diff --git a/tools/hermes/CMakeLists.txt b/tools/hermes/CMakeLists.txt index bf872aeb89b..7bbb0731b91 100644 --- a/tools/hermes/CMakeLists.txt +++ b/tools/hermes/CMakeLists.txt @@ -32,3 +32,7 @@ target_link_libraries(hermes ) hermes_link_icu(hermes) + +install(TARGETS hermes + RUNTIME DESTINATION bin +) diff --git a/tools/hermesc/CMakeLists.txt b/tools/hermesc/CMakeLists.txt index 9c069220016..9f3365da748 100644 --- a/tools/hermesc/CMakeLists.txt +++ b/tools/hermesc/CMakeLists.txt @@ -35,3 +35,7 @@ if(NOT CMAKE_CROSSCOMPILING) # Namespace added to avoid clashing the host binary with the target binary. export(TARGETS hermesc FILE ${CMAKE_BINARY_DIR}/ImportHermesc.cmake NAMESPACE native-) endif() + +install(TARGETS hermesc + RUNTIME DESTINATION bin +) diff --git a/tools/hvm/CMakeLists.txt b/tools/hvm/CMakeLists.txt index 7c6f1babf8a..23ce09e69b7 100644 --- a/tools/hvm/CMakeLists.txt +++ b/tools/hvm/CMakeLists.txt @@ -30,3 +30,6 @@ target_link_libraries(hvm hermes_link_icu(hvm) +install(TARGETS hvm + RUNTIME DESTINATION bin +) diff --git a/tools/jsi/CMakeLists.txt b/tools/jsi/CMakeLists.txt index d523e7aa024..5e313e9c05e 100644 --- a/tools/jsi/CMakeLists.txt +++ b/tools/jsi/CMakeLists.txt @@ -23,3 +23,4 @@ set_property(TARGET hermes-jsi APPEND_STRING PROPERTY target_link_libraries(hermes-jsi hermesapi ) + From 60ba9d86002c669946e296329aa967e75f3d2b9e Mon Sep 17 00:00:00 2001 From: Neil Dhar Date: Wed, 15 Apr 2020 11:49:20 -0700 Subject: [PATCH 03/10] 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: https://github.com/facebook/hermes/pull/215 Reviewed By: willholen Differential Revision: D21026727 Pulled By: neildhar fbshipit-source-id: 3b0bd7e286e8d2b21d3b7122e495c3fa31f9e41a --- .circleci/config.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ade06351686..cd14abc9c5a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -468,7 +468,7 @@ jobs: npm: docker: - - image: ubuntu:19.04 + - image: ubuntu:rolling environment: - yarn: yarnpkg - TERM: dumb @@ -479,13 +479,6 @@ jobs: 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 From 82fac121cbfe2d62a6ff1de7566fa51950aa4c19 Mon Sep 17 00:00:00 2001 From: Neil Dhar Date: Fri, 24 Apr 2020 19:59:38 -0700 Subject: [PATCH 04/10] 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: https://github.com/facebook/hermes/pull/229 Reviewed By: tmikov Differential Revision: D21242342 Pulled By: neildhar fbshipit-source-id: 8f393ff785ec1f67e7ca9628dbb0cd85f2fff095 --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index cd14abc9c5a..bf682bd24fb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -472,6 +472,7 @@ jobs: environment: - yarn: yarnpkg - TERM: dumb + - DEBIAN_FRONTEND: noninteractive steps: - run: name: Install certificates required to attach workspace From fbd3aaabd32c606f6c071a54ff08cc4d0b6ae0e7 Mon Sep 17 00:00:00 2001 From: Neil Dhar Date: Sat, 25 Apr 2020 17:36:54 -0700 Subject: [PATCH 05/10] 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: https://github.com/facebook/hermes/pull/230 Reviewed By: tmikov Differential Revision: D21244023 Pulled By: neildhar fbshipit-source-id: ce694c6e9b7de42a9459afe9fe2479386bbeb51c --- .circleci/config.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index bf682bd24fb..bb1273c2076 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -43,6 +43,7 @@ jobs: environment: - HERMES_WS_DIR: /tmp/hermes - TERM: dumb + - DEBIAN_FRONTEND: noninteractive steps: - checkout - run: @@ -110,6 +111,7 @@ jobs: environment: - HERMES_WS_DIR: /tmp/hermes - TERM: dumb + - DEBIAN_FRONTEND: noninteractive steps: - run: name: Install dependencies @@ -168,6 +170,7 @@ jobs: environment: - HERMES_WS_DIR: /tmp/hermes - TERM: dumb + - DEBIAN_FRONTEND: noninteractive steps: - run: name: Install dependencies From 6f0dde91ba20fea3afa4528432a0042c229d6f5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eloy=20Dur=C3=A1n?= Date: Tue, 21 Jul 2020 17:22:01 +0200 Subject: [PATCH 06/10] [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. --- CMakeLists.txt | 6 +++--- npm/fetch.js | 4 ---- npm/hermes-engine-darwin/README.md | 10 ++-------- npm/hermes-engine-darwin/package.json | 12 ++++++------ npm/hermes-engine-darwin/unpack-tarball.js | 19 +++++++++++++++++++ 5 files changed, 30 insertions(+), 21 deletions(-) create mode 100644 npm/hermes-engine-darwin/unpack-tarball.js diff --git a/CMakeLists.txt b/CMakeLists.txt index 6be47211cfc..ddf29d2e28f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -643,9 +643,9 @@ add_custom_target( COMMAND cp -R -f ${CMAKE_INSTALL_PREFIX} ${HERMES_PKG_ROOT}/destroot COMMAND - rm -r ${HERMES_PKG_FRAMEWORK}/{Headers,Resources,hermes} && mv ${HERMES_PKG_FRAMEWORK}/Versions/0/* ${HERMES_PKG_FRAMEWORK}/ && rm -r ${HERMES_PKG_FRAMEWORK}/Versions && install_name_tool -id @rpath/hermes.framework/hermes ${HERMES_PKG_FRAMEWORK}/hermes + find ${HERMES_PKG_ROOT}/destroot/bin -type f ! -name 'hermesc' -delete COMMAND - cp ${CMAKE_CURRENT_SOURCE_DIR}/hermes.podspec ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/README.md ${HERMES_PKG_ROOT} + cp ${CMAKE_CURRENT_SOURCE_DIR}/hermes.podspec ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE ${HERMES_PKG_ROOT} COMMAND - tar -C ${HERMES_PKG_ROOT}/ -czhf ${HERMES_GITHUB_DIR}/hermes-runtime-${HERMES_GITHUB_SYSTEM_NAME}-v${HERMES_RELEASE_VERSION}.tar.gz . + tar -C ${HERMES_PKG_ROOT}/ -czvf ${HERMES_GITHUB_DIR}/hermes-runtime-${HERMES_GITHUB_SYSTEM_NAME}-v${HERMES_RELEASE_VERSION}.tar.gz . ) diff --git a/npm/fetch.js b/npm/fetch.js index fb8c41f986e..5c123459774 100644 --- a/npm/fetch.js +++ b/npm/fetch.js @@ -148,10 +148,6 @@ var inputs = [ { name: "hermes-cli-darwin-v" + releaseVersion + ".tar.gz", dest: "osx-bin" - }, - { - name: "hermes-runtime-darwin-v" + releaseVersion + ".tar.gz", - dest: ".", } ] diff --git a/npm/hermes-engine-darwin/README.md b/npm/hermes-engine-darwin/README.md index 79b2aff6765..0243f54aa9f 100644 --- a/npm/hermes-engine-darwin/README.md +++ b/npm/hermes-engine-darwin/README.md @@ -1,12 +1,6 @@ ## Hermes -Hermes is a small and lightweight JavaScript VM optimized for running React -Native apps on macOS. +Hermes is a small and lightweight JavaScript VM optimized for running +React Native apps on macOS. See [hermesengine.dev](https://hermesengine.dev) for more information. - -This package contains a Hermes bytecode compiler for macOS, plus macOS runtime -framework. - -Additional tools are available in -[hermes-engine-cli](https://www.npmjs.com/package/hermes-engine-cli). diff --git a/npm/hermes-engine-darwin/package.json b/npm/hermes-engine-darwin/package.json index cc7087f1802..9a9f2fb2ac9 100644 --- a/npm/hermes-engine-darwin/package.json +++ b/npm/hermes-engine-darwin/package.json @@ -1,6 +1,6 @@ { "name": "hermes-engine-darwin", - "version": "%VERSION%", + "version": "0.4.1", "private": false, "description": "A JavaScript engine optimized for running React Native on macOS", "license": "MIT", @@ -8,12 +8,12 @@ "type": "git", "url": "git@github.com:facebook/hermes.git" }, + "scripts": { + "postinstall": "node unpack-tarball.js" + }, "files": [ - "LICENSE", "README.md", - "hermes.podspec", - "destroot/bin/hermesc", - "destroot/include/**/*", - "destroot/Library/**/*" + "unpack-tarball.js", + "hermes-runtime-darwin-v*.tar.gz" ] } diff --git a/npm/hermes-engine-darwin/unpack-tarball.js b/npm/hermes-engine-darwin/unpack-tarball.js new file mode 100644 index 00000000000..c90a7725d77 --- /dev/null +++ b/npm/hermes-engine-darwin/unpack-tarball.js @@ -0,0 +1,19 @@ +const path = require("path"); +const fs = require("fs"); +const child_process = require("child_process"); + +if ( + process.platform === "darwin" && + !fs.existsSync(path.join(__dirname, "destroot")) +) { + const tarball = fs.readdirSync(__dirname).find(function (entry) { + return entry.endsWith(".tar.gz"); + }); + if (!tarball) { + throw new Error("Could not locate tarball"); + } + child_process.execFileSync("/usr/bin/tar", [ + "-xzvf", + path.join(__dirname, tarball), + ]); +} From 7502285e6fd101881291a83e25138e563763aa36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eloy=20Dur=C3=A1n?= Date: Tue, 21 Jul 2020 18:15:36 +0200 Subject: [PATCH 07/10] [npm] Leave instructions for how to manually build --- npm/hermes-engine-darwin/BUILD.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 npm/hermes-engine-darwin/BUILD.md diff --git a/npm/hermes-engine-darwin/BUILD.md b/npm/hermes-engine-darwin/BUILD.md new file mode 100644 index 00000000000..af5c9cd357d --- /dev/null +++ b/npm/hermes-engine-darwin/BUILD.md @@ -0,0 +1,27 @@ +# NPM instructions + +## When building artefacts locally + +```bash +./src/utils/build/build_llvm.py --distribute +./src/utils/build/configure.py --distribute --cmake-flags='-DHERMES_ENABLE_DEBUGGER:BOOLEAN=true -DHERMES_ENABLE_FUZZING:BOOLEAN=false -DHERMES_ENABLE_TEST_SUITE:BOOLEAN=false -DHERMES_BUILD_APPLE_FRAMEWORK:BOOLEAN=true -DHERMES_BUILD_APPLE_DSYM:BOOLEAN=true -DCMAKE_INSTALL_PREFIX:PATH=../destroot' build +cd build_release +ninja hermes-runtime-darwin-cocoapods-release +mv github/hermes-runtime-darwin-v*.tar.gz ../src/npm/hermes-engine-darwin/ +``` + +## Or when fetching artefacts from CI + +Get the URL of the `hermes-runtime-darwin-v*.tar.gz` tarball from the `build-macos-runtime` CI job. + +```bash +curl -L -O [ARTEFACT_URL] +mv hermes-runtime-darwin-v*.tar.gz /path/to/src/npm/hermes-engine-darwin/ +``` + +## Pack package + +```bash +cd npm/hermes-engine-darwin +yarn pack +``` From 45177faae0252da470ca49d67499b4c913806adf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eloy=20Dur=C3=A1n?= Date: Tue, 21 Jul 2020 21:04:26 +0200 Subject: [PATCH 08/10] [ci] The npm job doesn't require macOS artifact --- .circleci/config.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index bb1273c2076..b190140b7cb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -27,7 +27,6 @@ workflows: - android - linux - macos - - build-macos-runtime - windows - test-linux - test-macos From b4026b32f1748471061fb37c8d2a34aac4604cd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eloy=20Dur=C3=A1n?= Date: Fri, 24 Jul 2020 17:46:51 +0200 Subject: [PATCH 09/10] Address PR feedback. --- CMakeLists.txt | 8 +++++--- npm/hermes-engine-darwin/unpack-tarball.js | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ddf29d2e28f..89be71bccb7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -639,11 +639,13 @@ add_custom_target( COMMAND ${CMAKE_COMMAND} --build . --target install/strip COMMAND - mkdir -p ${HERMES_PKG_ROOT} + mkdir -p ${HERMES_PKG_ROOT}/destroot/bin COMMAND - cp -R -f ${CMAKE_INSTALL_PREFIX} ${HERMES_PKG_ROOT}/destroot + cp ${CMAKE_INSTALL_PREFIX}/bin/hermesc ${HERMES_PKG_ROOT}/destroot/bin/ COMMAND - find ${HERMES_PKG_ROOT}/destroot/bin -type f ! -name 'hermesc' -delete + cp -R ${CMAKE_INSTALL_PREFIX}/Library ${HERMES_PKG_ROOT}/destroot/ + 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} COMMAND diff --git a/npm/hermes-engine-darwin/unpack-tarball.js b/npm/hermes-engine-darwin/unpack-tarball.js index c90a7725d77..6852d45d4ab 100644 --- a/npm/hermes-engine-darwin/unpack-tarball.js +++ b/npm/hermes-engine-darwin/unpack-tarball.js @@ -7,7 +7,7 @@ if ( !fs.existsSync(path.join(__dirname, "destroot")) ) { const tarball = fs.readdirSync(__dirname).find(function (entry) { - return entry.endsWith(".tar.gz"); + return /^hermes-runtime-darwin-v[\d\.]+\.tar\.gz$/.test(entry); }); if (!tarball) { throw new Error("Could not locate tarball"); From 2bb8c1ea6f6a8150698b02b7004f0af9035749e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eloy=20Dur=C3=A1n?= Date: Mon, 27 Jul 2020 14:03:17 +0200 Subject: [PATCH 10/10] Pickup tar from user env --- npm/hermes-engine-darwin/unpack-tarball.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/npm/hermes-engine-darwin/unpack-tarball.js b/npm/hermes-engine-darwin/unpack-tarball.js index 6852d45d4ab..cb4554ddb70 100644 --- a/npm/hermes-engine-darwin/unpack-tarball.js +++ b/npm/hermes-engine-darwin/unpack-tarball.js @@ -12,8 +12,5 @@ if ( if (!tarball) { throw new Error("Could not locate tarball"); } - child_process.execFileSync("/usr/bin/tar", [ - "-xzvf", - path.join(__dirname, tarball), - ]); + child_process.execFileSync("tar", ["-xzvf", path.join(__dirname, tarball)]); }