Skip to content

Commit

Permalink
Build a universal binary to support M1 (Apple silicon)
Browse files Browse the repository at this point in the history
Analogous to Level/leveldown#781
  • Loading branch information
Nazgolze committed Sep 24, 2021
1 parent a54ad1e commit 84c3315
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 12 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ jobs:
include:
- os: ubuntu-latest
build-group: linux-x64
- os: macos-latest
build-group: darwin-x64
# At the time of writing macos-latest is mac 10; we need 11 to build a universal binary.
- os: macos-11
build-group: darwin-x64+arm64
- os: windows-latest
build-group: win32-x64
runs-on: ${{ matrix.os }}
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ jobs:
test:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
# At the time of writing macos-latest is mac 10; we need 11 to build a universal binary.
os: [ubuntu-latest, macos-11, windows-latest]
node: [10, 12, 14]
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} / Node ${{ matrix.node }}
Expand Down
12 changes: 9 additions & 3 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,20 @@
, '-Wno-ignored-qualifiers'
]
, 'OTHER_CPLUSPLUSFLAGS': [
'-mmacosx-version-min=10.8'
'-mmacosx-version-min=10.12'
, '-std=c++11'
, '-stdlib=libc++'
, '-arch x86_64'
, '-arch arm64'
]
, 'OTHER_LDFLAGS': [
'-stdlib=libc++'
, '-arch x86_64'
, '-arch arm64'
]
, 'OTHER_LDFLAGS': ['-stdlib=libc++']
, 'GCC_ENABLE_CPP_RTTI': 'YES'
, 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES'
, 'MACOSX_DEPLOYMENT_TARGET': '10.8'
, 'MACOSX_DEPLOYMENT_TARGET': '10.12'
}
}]
, ['OS == "linux"', {
Expand Down
11 changes: 8 additions & 3 deletions deps/rocksdb/rocksdb.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@
]
}]
, ['OS == "mac"', {
'defines': [
'sources': [
'rocksdb/util/crc32c_arm64.cc'
]
, 'defines': [
'OS_MACOSX=1',
'ROCKSDB_LIB_IO_POSIX=1',
'ROCKSDB_BACKTRACE=1'
Expand All @@ -161,16 +164,18 @@
, '-Wno-unused-function'
]
, 'OTHER_CPLUSPLUSFLAGS': [
'-mmacosx-version-min=10.8'
'-mmacosx-version-min=10.12'
, '-std=c++11'
, '-stdlib=libc++'
, '-fno-omit-frame-pointer'
, '-momit-leaf-frame-pointer'
, '-arch x86_64'
, '-arch arm64'
]
# , 'OTHER_LDFLAGS': ['-stdlib=libc++']
, 'GCC_ENABLE_CPP_RTTI': 'YES'
, 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES'
, 'MACOSX_DEPLOYMENT_TARGET': '10.8'
, 'MACOSX_DEPLOYMENT_TARGET': '10.12'
}
}]
, ['target_arch == "arm64" or target_arch == "aarch64"', {
Expand Down
4 changes: 4 additions & 0 deletions deps/snappy/snappy.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@
'-Wno-sign-compare'
, '-Wno-unused-function'
]
, 'OTHER_CFLAGS': [
'-arch x86_64'
, '-arch arm64'
]
}
}]
]
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"rebuild": "npm run install --build-from-source",
"prebuild": "prebuildify -t 8.14.0 --napi --strip",
"prebuild-linux-x64": "prebuildify-cross -i centos7-devtoolset7 -i alpine -t 8.14.0 --napi --strip",
"prebuild-darwin-x64": "prebuildify -t 8.14.0 --napi --strip",
"prebuild-darwin-x64+arm64": "prebuildify -t 8.14.0 --napi --strip --arch x64+arm64",
"prebuild-win32-x64": "prebuildify -t 8.14.0 --napi --strip",
"download-prebuilds": "prebuildify-ci download",
"hallmark": "hallmark --fix",
Expand All @@ -24,7 +24,7 @@
"dependencies": {
"abstract-leveldown": "^7.0.0",
"napi-macros": "^2.0.0",
"node-gyp-build": "^4.2.3"
"node-gyp-build": "^4.3.0"
},
"devDependencies": {
"async-each": "^1.0.3",
Expand All @@ -40,7 +40,7 @@
"mkfiletree": "^2.0.0",
"node-gyp": "^7.1.2",
"nyc": "^15.0.0",
"prebuildify": "^4.1.1",
"prebuildify": "^4.2.1",
"prebuildify-ci": "^1.0.4",
"prebuildify-cross": "^4.0.1",
"readfiletree": "^1.0.0",
Expand Down

0 comments on commit 84c3315

Please sign in to comment.