Skip to content

Conversation

Mytherin
Copy link
Collaborator

This PR switches the NodeJS clients' build system to use the package_build script, similar to how the R and Python clients are setup. The advantages to this are as follows:

  • Lower memory requirements, because we can avoid the amalgamation
  • We can easily toggle which extensions we want to package from a single script
  • Allow for more parallelism in the build process
  • Allow for easily linking to existing compiled versions of DuckDB using the BUILD_NODE command - speeding up CI significantly

The way this works is that the binding.gyp file is moved to a binding.gyp.in file. A new script, configure.py, is added that uses the shared package_build library to add source files, include directories, and defines. By default all required source files are copied into a directory (tools/nodejs/src/duckdb) and compiled from there. There is an option to link to an existing build instead. This is used when compiling using the BUILD_NODE command, e.g.:

BUILD_NODE=1 make

The CMake will then set up a number of environment variables (DUCKDB_NODE_BINDIR, DUCKDB_NODE_CFLAGS, DUCKDB_NODE_LIBS) that are used to link to an existing build.

The BUILD_NODE command is also used in the CI to greatly speed up the MacOS and Linux CI runs. By linking to an existing DuckDB build the builds can be cached using ccache and re-used between different node versions. This allows all node versions to be build in a minute each, instead of taking 20-30 minutes for each node version.

@Mytherin Mytherin requested a review from Mause December 13, 2022 21:38
Copy link
Member

@Mause Mause left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly minor nitpicks, otherwise looks good!

@@ -5,10 +5,4 @@ set -x

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably just kill this file, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept it around for backwards compatibility purposes - but I suppose we could replace it with the configure.py as well

@@ -9,15 +9,16 @@
"src/connection.cpp",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it the template version of this file that we're shipping? Have we checked that the built tar works as expected?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suspect the tar build works fine as long as we are copying over the source files, but it will not work when doing an incremental build. Does this happen as part of the node-pre-gyp package command? Or is the tar file uploaded elsewhere separately?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested out npm pack followed by npm install <tarball> locally and it works - but if the tarball is built and uploaded as part of the CI we need to ensure the tarball is created from a fresh configure, and not from a configure that is linked to an existing build.

@Mytherin Mytherin merged commit 3f750da into duckdb:master Dec 16, 2022
@Mause
Copy link
Member

Mause commented Dec 18, 2022

@Mytherin it looks like the dev source tarballs that are being uploaded to npm are missing the duckdb source code? Are you able to have a look at this?

@Mause
Copy link
Member

Mause commented Dec 18, 2022

It also looks like the paths on the agent have been hardcoded as well: https://www.npmjs.com/package/duckdb/v/0.6.2-dev670.0?activeTab=explore

@Mytherin Mytherin deleted the begoneamalgamation branch January 7, 2023 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants