Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions build-capnp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ here=$(cd "$(dirname "$BASH_SOURCE")"; \
# We store all of our build artefacts in a subdirectory. If that directory already exists, remove
# it so that we can cleanly restart from scratch. Preserve the capnproto source distribution if
# it's present, so that we don't need to redownload it.
capnp_filename="capnproto-c++-0.10.3.tar.gz"
capnp_filename="capnproto-c++-1.1.0.tar.gz"
build_dir="${here}/build-capnp"

if [[ -f "${build_dir}/${capnp_filename}" ]]; then
Expand All @@ -51,7 +51,7 @@ pushd ${build_dir}
# Download the capnproto source, if we don't already have it, and then unpack it. It's pretty small
# (1.6 MiB), so the download should be fast.
if [[ ! -f "${capnp_filename}" ]]; then
curl -O https://capnproto.org/capnproto-c++-0.10.3.tar.gz
curl -O https://capnproto.org/capnproto-c++-1.1.0.tar.gz
fi

tar --strip-components=1 -zxf "${capnp_filename}"
Expand All @@ -63,7 +63,7 @@ if [[ $1 == "linux" ]]; then
CC="clang" \
CXX="clang++" \
CFLAGS="-fPIC" \
CXXFLAGS="-std=c++17 -fPIC" \
CXXFLAGS="-std=c++20 -fPIC" \
./configure --disable-shared
make -j
make install-data DESTDIR=capnp-root
Expand Down
2 changes: 1 addition & 1 deletion build.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ if (process.platform === "linux" && args.targetPlatform === "linux") {
buildEnvironment.CC = "clang";
buildEnvironment.CXX = "clang++";
buildEnvironment.CFLAGS = "-I" + capnpIncPath;
buildEnvironment.CXXFLAGS = buildEnvironment.CFLAGS;
buildEnvironment.CXXFLAGS = buildEnvironment.CFLAGS + " -std=c++20";
buildEnvironment.LDFLAGS = "-L" + capnpLibPath;
}

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@
"main": "src/node-capnp/capnp.js",
"types": "src/node-capnp/capnp.d.ts",
"scripts": {
"install": "node ./build.js --dist-url=https://electronjs.org/headers --target=20.3.3",
"install": "node ./build.js --dist-url=https://electronjs.org/headers --target=35.1.2",
"test": "electron src/node-capnp/capnp-test.js"
},
"dependencies": {
"nan": "^2.17.0",
"yargs": "^17.6.2"
},
"devDependencies": {
"electron": "^20.3.3",
"node-gyp": "^9.1.0"
"electron": "^35.1.2",
"node-gyp": "^11.2.0"
},
"repository": {
"type": "git",
Expand Down
13 changes: 6 additions & 7 deletions src/node-capnp/capnp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1271,17 +1271,16 @@ kj::Maybe<kj::ArrayPtr<const byte>> unwrapBuffer(v8::Local<v8::Value> value) {
if (name##_maybe == nullptr) KJV8_TYPE_ERROR(name, kj::Array<byte>); \
kj::ArrayPtr<const byte>& name = KJ_ASSERT_NONNULL(name##_maybe)

template <typename T>
void deleteArray(char*, void* hint) {
delete reinterpret_cast<kj::Array<T>*>(hint);
}

template <typename T>
v8::Local<v8::Value> wrapBuffer(kj::Array<T>&& array) {
char* data = reinterpret_cast<char*>(array.begin());
size_t size = array.size() * sizeof(T);
return check(node::Buffer::New(v8::Isolate::GetCurrent(), data, size, &deleteArray<T>,
new kj::Array<T>(kj::mv(array))));
// We need to copy the data into a V8 ArrayBuffer as since version 21 Electron
// does not allow externally allocated pointers to be passed to JavaScript.
// See https://www.electronjs.org/blog/v8-memory-cage
v8::Local<v8::ArrayBuffer> ab = v8::ArrayBuffer::New(v8::Isolate::GetCurrent(), size);
memcpy(ab->Data(), data, size);
return check(node::Buffer::New(v8::Isolate::GetCurrent(), ab, 0, size));
}

// =======================================================================================
Expand Down