Skip to content

Commit

Permalink
Create hermes-engine-darwin npm package (#297)
Browse files Browse the repository at this point in the history
Summary:
{emoji:26a0} _This includes the changes of #296, so I’ll have to rebase this PR once that lands. The changes that pertain to this PR are in 9da61f7a9da01b5bd49e95dca0b98a5204210790_

Adds hermes-engine-darwin to the npm CI job.

Notably the symbolic links need to be stripped from the framework bundle, as npm by design does not support symbolic links to exist in packages. However, seeing as we already package distinct versions of the framework in distinct npm packages, there isn't any need to support multiple versions of Hermes in a single framework bundle; so this should be fine.

Pull Request resolved: #297

Test Plan: TODO: I’ll need to backport all changes to Hermes v0.4.1 in order to pull it into RN macOS v0.62. In the meantime I want to see if CI is correctly cutting this package.

Reviewed By: mhorowitz

Differential Revision: D22700399

Pulled By: willholen

fbshipit-source-id: f72aefa3fd98a85c8da3e9a38dfa6be9723a0270
  • Loading branch information
alloy authored and facebook-github-bot committed Jul 27, 2020
1 parent 8fc32f4 commit d3394bc
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 4 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ workflows:
- android
- linux
- macos
- build-macos-runtime
- windows
- test-linux
- test-macos
Expand Down
15 changes: 11 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -700,16 +700,23 @@ 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_GITHUB_DIR}/package-root
mkdir -p ${HERMES_PKG_ROOT}/destroot/bin
COMMAND
cp ${CMAKE_INSTALL_PREFIX}/bin/hermesc ${HERMES_PKG_ROOT}/destroot/bin/
COMMAND
cp -R ${CMAKE_INSTALL_PREFIX}/Library ${HERMES_PKG_ROOT}/destroot/
COMMAND
cp -R -f ${CMAKE_INSTALL_PREFIX} ${HERMES_GITHUB_DIR}/package-root/destroot
cp -R ${CMAKE_INSTALL_PREFIX}/include ${HERMES_PKG_ROOT}/destroot/
COMMAND
cp ${CMAKE_CURRENT_SOURCE_DIR}/hermes.podspec ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/README.md ${HERMES_GITHUB_DIR}/package-root/
cp ${CMAKE_CURRENT_SOURCE_DIR}/hermes.podspec ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE ${HERMES_PKG_ROOT}
COMMAND
tar -C ${HERMES_GITHUB_DIR}/package-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 .
)
5 changes: 5 additions & 0 deletions npm/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
*.tar.gz
*.tgz
*.sha256
android
node_modules
osx-bin
package-lock.json
destroot
LICENSE
README.md
hermes.podspec
6 changes: 6 additions & 0 deletions npm/hermes-engine-darwin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## 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.
19 changes: 19 additions & 0 deletions npm/hermes-engine-darwin/package.json
Original file line number Diff line number Diff line change
@@ -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"
},
"scripts": {
"postinstall": "node unpack-tarball.js"
},
"files": [
"README.md",
"unpack-tarball.js",
"hermes-runtime-darwin-v*.tar.gz"
]
}
16 changes: 16 additions & 0 deletions npm/hermes-engine-darwin/unpack-tarball.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
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 /^hermes-runtime-darwin-v[\d\.]+\.tar\.gz$/.test(entry);
});
if (!tarball) {
throw new Error("Could not locate tarball");
}
child_process.execFileSync("tar", ["-xzvf", path.join(__dirname, tarball)]);
}

0 comments on commit d3394bc

Please sign in to comment.