Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node.js Windows Build #2103

Merged
merged 17 commits into from
Aug 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1225,6 +1225,31 @@ jobs:
- name: Node 15
run: ./scripts/node_build.sh 15

win-nodejs:
name: node.js Windows
runs-on: windows-latest
needs: linux-debug

strategy:
matrix:
node: [ '10', '12', '14', '15' ]

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}

- name: Node Version
run: ./scripts/node_version.sh

- name: Node
run: ./scripts/node_build_win.sh

linux-wasm-release:
name: WebAssembly Release
runs-on: ubuntu-20.04
Expand Down
13 changes: 2 additions & 11 deletions scripts/amalgamation.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,10 @@ def add_include_dir(dirpath):
# files always excluded
always_excluded = ['src/amalgamation/duckdb.cpp', 'src/amalgamation/duckdb.hpp', 'src/amalgamation/parquet-amalgamation.cpp', 'src/amalgamation/parquet-amalgamation.hpp']
# files excluded from the amalgamation
excluded_files = ['grammar.cpp', 'grammar.hpp', 'symbols.cpp', 'file_system.cpp']
excluded_files = ['grammar.cpp', 'grammar.hpp', 'symbols.cpp']
# files excluded from individual file compilation during test_compile
excluded_compilation_files = excluded_files + ['gram.hpp', 'kwlist.hpp', "duckdb-c.cpp"]

file_system_cpp = os.path.join('src', 'common', 'file_system.cpp')

linenumbers = False

def get_includes(fpath, text):
Expand Down Expand Up @@ -277,9 +275,6 @@ def generate_amalgamation(source_file, header_file):
sfile.write("#if (!defined(DEBUG) && !defined NDEBUG)\n#define NDEBUG\n#endif\n\n")
for compile_dir in compile_directories:
sfile.write(write_dir(compile_dir))
# for windows we write file_system.cpp last
# this is because it includes windows.h which contains a lot of #define statements that mess up the other code
sfile.write(write_file(file_system_cpp, True))

sfile.write('\n\n/*\n')
license_idx = 0
Expand Down Expand Up @@ -315,7 +310,7 @@ def list_sources():
file_list = []
for compile_dir in compile_directories:
list_files(compile_dir, file_list)
return file_list + [file_system_cpp]
return file_list

def list_include_files_recursive(dname, file_list):
files = os.listdir(dname)
Expand Down Expand Up @@ -399,10 +394,6 @@ def generate_amalgamation_splits(source_file, header_file, nsplits):
continue
gather_files(compile_dir, source_files, header_files)

# for windows we write file_system.cpp last
# this is because it includes windows.h which contains a lot of #define statements that mess up the other code
source_files.append(write_file(os.path.join('src', 'common', 'file_system.cpp'), True))

# write duckdb-internal.hpp
if '.hpp' in header_file:
internal_header_file = header_file.replace('.hpp', '-internal.hpp')
Expand Down
20 changes: 20 additions & 0 deletions scripts/node_build_win.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

set -e

node --version
npm --version
which node

cd tools/nodejs
make clean
./configure

npm install --build-from-source
npm test
npx node-pre-gyp package testpackage testbinary

if [[ "$GITHUB_REF" =~ ^(refs/heads/master|refs/tags/v.+)$ ]] ; then
npx node-pre-gyp publish
npx node-pre-gyp info
fi
8 changes: 1 addition & 7 deletions src/common/file_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "duckdb/common/pipe_file_system.hpp"
#include "duckdb/common/helper.hpp"
#include "duckdb/common/string_util.hpp"
#include "duckdb/common/windows.hpp"
#include "duckdb/function/scalar/string_functions.hpp"
#include "duckdb/main/client_context.hpp"
#include "duckdb/main/database.hpp"
Expand All @@ -22,19 +23,12 @@
#include <unistd.h>
#else
#include <string>
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <windows.h>

#ifdef __MINGW32__
// need to manually define this for mingw
extern "C" WINBASEAPI BOOL WINAPI GetPhysicallyInstalledSystemMemory(PULONGLONG);
#endif

#undef CreateDirectory
#undef MoveFile
#undef RemoveDirectory
#undef FILE_CREATE // woo mingw
#endif

Expand Down
4 changes: 1 addition & 3 deletions src/execution/operator/helper/physical_load.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
#include "duckdb/execution/operator/helper/physical_load.hpp"
#include "duckdb/common/file_system.hpp"
#include "duckdb/common/windows.hpp"
#include "duckdb/main/database.hpp"
#include "duckdb/main/client_context.hpp"

#ifndef _WIN32
#include <dlfcn.h>
#else
#include <windows.h>

#define RTLD_LAZY 0
#define RTLD_LOCAL 0

#endif

namespace duckdb {
Expand Down
15 changes: 15 additions & 0 deletions src/include/duckdb/common/windows.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#pragma once

#ifdef _WIN32

#ifndef NOMINMAX
#define NOMINMAX
#endif

#include <windows.h>

#undef CreateDirectory
#undef MoveFile
#undef RemoveDirectory

#endif
73 changes: 43 additions & 30 deletions tools/nodejs/binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@
{
"target_name": "<(module_name)",
"sources": [
"src/duckdb_node.cpp",
"src/database.cpp",
"src/connection.cpp",
"src/statement.cpp",
"src/utils.cpp",
"src/duckdb.cpp" # comment this out to build against existing lib
"src/duckdb_node.cpp",
"src/database.cpp",
"src/connection.cpp",
"src/statement.cpp",
"src/utils.cpp",
"src/duckdb.cpp" # comment this out to build against existing lib
],
"include_dirs": [
"<!@(node -p \"require('node-addon-api').include\")"
],
'defines': [
'NAPI_DISABLE_CPP_EXCEPTIONS=1',
"NAPI_VERSION=5"],
'NAPI_DISABLE_CPP_EXCEPTIONS=1',
"NAPI_VERSION=5"
],
"cflags_cc": [
"-frtti",
"-fexceptions"
Expand Down Expand Up @@ -43,31 +44,43 @@
},
"msvs_settings": {
"VCCLCompilerTool": {
"ExceptionHandling": 1
"ExceptionHandling": 1,
"AdditionalOptions": [
"/bigobj"
]
}
},
# uncomment this to build against existing lib
# "libraries": [
# "/Users/hannes/source/duckdb/build/release/src/libduckdb_static.a",
# "/Users/hannes/source/duckdb/build/release/third_party/fmt/libfmt.a",
# "/Users/hannes/source/duckdb/build/release/third_party/libpg_query/libpg_query.a",
# "/Users/hannes/source/duckdb/build/release/third_party/utf8proc/libutf8proc.a",
# "/Users/hannes/source/duckdb/build/release/third_party/re2/libduckdb_re2.a"
#
# ]
"conditions": [
[
'OS=="win"',
{
"defines": [
"DUCKDB_BUILD_LIBRARY"
]
},
], # OS=="win"
], # conditions
# uncomment this to build against existing lib
# "libraries": [
# "/Users/hannes/source/duckdb/build/release/src/libduckdb_static.a",
# "/Users/hannes/source/duckdb/build/release/third_party/fmt/libfmt.a",
# "/Users/hannes/source/duckdb/build/release/third_party/libpg_query/libpg_query.a",
# "/Users/hannes/source/duckdb/build/release/third_party/utf8proc/libutf8proc.a",
# "/Users/hannes/source/duckdb/build/release/third_party/re2/libduckdb_re2.a"
# ]
},
{
"target_name": "action_after_build",
"type": "none",
"dependencies": [
"<!(node -p \"require('node-addon-api').gyp\")"
],
"copies": [
{
"files": [ "<(PRODUCT_DIR)/<(module_name).node" ],
"destination": "<(module_path)"
}
]
}
"target_name": "action_after_build",
"type": "none",
"dependencies": [
"<(module_name)"
],
"copies": [
{
"files": [ "<(PRODUCT_DIR)/<(module_name).node" ],
"destination": "<(module_path)"
}
]
}
]
}