Skip to content

Commit 2f2a2fd

Browse files
authored
Merge pull request #2 from fourieraudio/electron-20
TF-255: Update build for Electron 20
2 parents 8ac7c46 + 2f6770a commit 2f2a2fd

File tree

10 files changed

+246
-133
lines changed

10 files changed

+246
-133
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: CI - Test Build
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
7+
jobs:
8+
BuildLinux:
9+
runs-on: ubuntu-20.04
10+
steps:
11+
- uses: actions/checkout@v3
12+
13+
- name: Install dependencies
14+
run: sudo ./install-deps.sh
15+
16+
- name: Test build module (linux-x64)
17+
run: npm i && file bin/linux-x64/capnp.node
18+
19+
- name: Run tests
20+
run: npm test
21+
22+
# vim: set nospell:

README-FOURIER.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
This is our clone of the github capnproto/node-capnproto repository, modified for
2+
use in an electron environment;
3+
4+
- Modifications to build scripts to build against electron headers
5+
- Modifications to build scripts to allow cross-compile for darwin
6+
- Bumping dependencies / merging PRs to resolve V8-compatibility issues to support Electron 20.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ you must have development headers for Cap'n Proto and Node.js installed, along
4747
with the `node-gyp` tool and a GCC new enough for Cap'n Proto (at least 4.7).
4848
On Debian/Ubuntu, you can install these like so:
4949

50-
sudo apt-get install nodejs-dev nodejs-legacy capnproto-dev g++
50+
sudo apt-get install nodejs-dev nodejs-legacy libcapnp-dev g++
5151

5252
### From source
5353

binding.gyp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
'target_name': 'capnp',
55
'sources': ['src/node-capnp/capnp.cc'],
66
'libraries': ['-lkj', '-lkj-async', '-lcapnp', '-lcapnpc', '-lcapnp-rpc'],
7-
'cflags_cc': ['-std=c++14'],
7+
'cflags_cc': ['-std=c++17'],
88
'cflags_cc!': ['-fno-rtti', '-fno-exceptions'],
99
'include_dirs': [
1010
'src',

build.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ var force = false, debug = false;
3131
var
3232
arch = process.arch,
3333
platform = process.platform,
34-
v8 = /[0-9]+\.[0-9]+/.exec(process.versions.v8)[0],
3534
environment = { ...process.env };
3635

3736
var patchLibPath = false, patchTool = null;
@@ -77,8 +76,10 @@ if (!{ia32: true, x64: true, arm: true}.hasOwnProperty(arch)) {
7776
process.exit(1);
7877
}
7978

80-
// Test for pre-built library
81-
var modPath = platform+ '-'+ arch+ '-v8-'+ v8;
79+
// Test for pre-built library. We do not use the v8 version in the target dir
80+
// as the v8 version we are running with currently may not be the same as that
81+
// we are building for.
82+
var modPath = platform + '-' + arch;
8283
var command = process.platform === 'win32' ? 'node-gyp.cmd' : 'node-gyp';
8384

8485
if (!force) {

install-deps.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
3+
set -euf
4+
5+
apt-get update
6+
apt-get install -y --no-install-recommends \
7+
libcapnp-dev
8+

package.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "capnp",
3-
"version": "0.5.5",
3+
"version": "0.5.6",
44
"description": "A wrapper for the C++ Cap'n Proto library",
55
"keywords": [
66
"capnproto",
@@ -21,16 +21,20 @@
2121
"main": "src/node-capnp/capnp.js",
2222
"types": "src/node-capnp/capnp.d.ts",
2323
"scripts": {
24-
"install": "node ./build.js --dist-url=https://electronjs.org/headers --target=12.0.2",
25-
"test": "node src/node-capnp/capnp-test.js",
24+
"install": "node ./build.js --dist-url=https://electronjs.org/headers --target=20.3.3",
25+
"test": "electron src/node-capnp/capnp-test.js",
2626
"build:darwin": "npm run install -- --target_plat=darwin --patch_path=.libs"
2727
},
2828
"dependencies": {
29-
"nan": "^2.7.0"
29+
"nan": "^2.17.0"
30+
},
31+
"devDependencies": {
32+
"electron": "^20.3.3",
33+
"node-gyp": "^9.1.0"
3034
},
3135
"repository": {
3236
"type": "git",
33-
"url": "git://github.com/kentonv/node-capnp.git"
37+
"url": "git://github.com/fourieraudio/node-capnp.git"
3438
},
3539
"engines": {
3640
"node": ">=10.0"

src/node-capnp/capnp-test.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ try {
4242
goldenPackedFlatBinary = fs.readFileSync("src/node-capnp/testdata/packedflat");
4343
}
4444

45-
var test = require("./test.capnp");
46-
assert(test === capnp.import(__dirname + "/test.capnp"));
47-
assert(test === require("./test"));
45+
let test = capnp.importFile(__dirname + "/test.capnp");
4846

4947
assert("namespace" in capnp.importSystem("capnp/c++.capnp"));
5048

0 commit comments

Comments
 (0)