Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
19 changes: 6 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ env:
NO_V18_NODE_BUILD_CMD: npx --no-install prebuild -r node -t 20.0.0 -t 22.0.0 -t 23.0.0 --include-regex 'better_sqlite3.node$'
# See https://www.electronjs.org/docs/latest/tutorial/electron-timelines#version-support-policy
# Electron v25 EOL = 2023-12-05. v26 EOL = 2024-02-20. v27 EOL = 2024-04-16. v28 EOL = 2024-06-11. v29 EOL = 2024-08-20.
ELECTRON_BUILD_CMD: npx --no-install prebuild -r electron -t 26.0.0 -t 27.0.0 -t 28.0.0 -t 29.0.0 -t 30.0.0 -t 31.0.0 -t 32.0.0 -t 33.0.0 --include-regex 'better_sqlite3.node$'


jobs:
test:
Expand All @@ -44,25 +44,21 @@ jobs:
with:
node-version: ${{ matrix.node }}
- if: ${{ startsWith(matrix.os, 'windows') }}
run: pip.exe install setuptools
run: |
pip.exe install setuptools
vcpkg install icu:x64-windows
- if: ${{ startsWith(matrix.os, 'macos') }}
run: brew install python-setuptools
run: brew install python-setuptools icu4c
- if: ${{ !startsWith(matrix.os, 'windows') && !startsWith(matrix.os, 'macos') }}
run: python3 -m pip install setuptools
- if: ${{ startsWith(matrix.os, 'ubuntu') }}
run: |
sudo apt update
sudo apt install gcc-10 g++-10 -y
sudo apt install gcc-10 g++-10 libicu-dev -y
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10 --slave /usr/bin/gcov gcov /usr/bin/gcov-10
- run: npm install --ignore-scripts
- run: npm run build-debug
- run: npm test
- name: Test SpatiaLite extension
if: ${{ startsWith(matrix.os, 'ubuntu') }}
run: |
sudo apt update
sudo apt install libsqlite3-mod-spatialite -y
node -e "require('./lib/index.js')(':memory:').loadExtension('mod_spatialite').exec('SELECT InitSpatialMetaData();')"

publish:
if: ${{ github.event_name == 'release' }}
Expand Down Expand Up @@ -114,13 +110,10 @@ jobs:
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10 --slave /usr/bin/gcov gcov /usr/bin/gcov-10
- run: npm install --ignore-scripts
- run: ${{ env.NODE_BUILD_CMD }} -u ${{ secrets.GITHUB_TOKEN }}
- run: ${{ env.ELECTRON_BUILD_CMD }} -u ${{ secrets.GITHUB_TOKEN }}
- if: matrix.os == 'windows-2019'
run: |
${{ env.NODE_BUILD_CMD }} --arch ia32 -u ${{ secrets.GITHUB_TOKEN }}
${{ env.NO_V18_NODE_BUILD_CMD }} --arch arm64 -u ${{ secrets.GITHUB_TOKEN }}
${{ env.ELECTRON_BUILD_CMD }} --arch ia32 -u ${{ secrets.GITHUB_TOKEN }}
${{ env.ELECTRON_BUILD_CMD }} --arch arm64 -u ${{ secrets.GITHUB_TOKEN }}

prebuild-alpine:
if: ${{ github.event_name == 'release' }}
Expand Down
33 changes: 33 additions & 0 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,39 @@
}],
],
},
{
'target_name': 'shell',
'type': 'executable',
'dependencies': ['deps/sqlite3.gyp:locate_sqlite3'],
'sources': ['<(SHARED_INTERMEDIATE_DIR)/sqlite3/sqlite3.c', '<(SHARED_INTERMEDIATE_DIR)/sqlite3/shell.c'],
'include_dirs': ['<(SHARED_INTERMEDIATE_DIR)/sqlite3/'],
'direct_dependent_settings': {
'include_dirs': ['<(SHARED_INTERMEDIATE_DIR)/sqlite3/'],
},
'cflags': ['-std=c99', '-w'],
'xcode_settings': {
'OTHER_CFLAGS': ['-std=c99'],
'WARNING_CFLAGS': ['-w'],
},
'conditions': [
['sqlite3 == ""', {
'includes': ['deps/defines.gypi'],
}, {
'defines': [
# This is currently required by better-sqlite3.
'SQLITE_ENABLE_COLUMN_METADATA',
],
}]
],
'configurations': {
'Debug': {
'msvs_settings': { 'VCCLCompilerTool': { 'RuntimeLibrary': 1 } }, # static debug
},
'Release': {
'msvs_settings': { 'VCCLCompilerTool': { 'RuntimeLibrary': 0 } }, # static release
},
},
},
{
'target_name': 'test_extension',
'dependencies': ['deps/sqlite3.gyp:sqlite3'],
Expand Down
52 changes: 51 additions & 1 deletion deps/common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
# ===

{
'variables': { 'sqlite3%': '' },
'variables': {
'sqlite3%': '',
'lib_prefix': '',
'lib_suffix': '',
},
'target_defaults': {
'default_configuration': 'Release',
'msvs_settings': {
Expand All @@ -15,7 +19,23 @@
'conditions': [
['OS == "win"', {
'defines': ['WIN32'],
}, {
'libraries': [
'-licui18n',
'-licuuc',
'-licudata',
],
}],
['OS == "mac"', {
'include_dirs': [
'/usr/local/opt/icu4c/include',
'/opt/homebrew/opt/icu4c/include'
],
'library_dirs': [
'/usr/local/opt/icu4c/lib',
'/opt/homebrew/opt/icu4c/lib'
],
}]
],
'configurations': {
'Debug': {
Expand All @@ -41,6 +61,19 @@
'msvs_settings': {
'VCLinkerTool': {
'GenerateDebugInformation': 'true',
'AdditionalDependencies': [
'icuin.lib',
'icuuc.lib',
'icudt.lib',
],
'AdditionalLibraryDirectories': [
'$(VCPKG_ROOT)/installed/x64-windows/lib',
],
},
'VCCLCompilerTool': {
'AdditionalIncludeDirectories': [
'$(VCPKG_ROOT)/installed/x64-windows/include',
],
},
},
},
Expand All @@ -62,6 +95,23 @@
'DEAD_CODE_STRIPPING': 'YES',
'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES',
},
'msvs_settings': {
'VCLinkerTool': {
'AdditionalDependencies': [
'icuin.lib',
'icuuc.lib',
'icudt.lib',
],
'AdditionalLibraryDirectories': [
'$(VCPKG_ROOT)/installed/x64-windows/lib',
],
},
'VCCLCompilerTool': {
'AdditionalIncludeDirectories': [
'$(VCPKG_ROOT)/installed/x64-windows/include',
],
},
},
},
},
},
Expand Down
1 change: 1 addition & 0 deletions deps/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const fs = require('fs');
const dest = process.argv[2];
const source = path.resolve(path.sep, process.argv[3] || path.join(__dirname, 'sqlite3'));
const files = [
{ filename: 'shell.c', optional: false },
{ filename: 'sqlite3.c', optional: false },
{ filename: 'sqlite3.h', optional: false },
];
Expand Down
2 changes: 2 additions & 0 deletions deps/defines.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,7 @@
'SQLITE_THREADSAFE=2',
'SQLITE_TRACE_SIZE_LIMIT=32',
'SQLITE_USE_URI=0',
'SQLITE_OMIT_LOAD_EXTENSION',
'SQLITE_ENABLE_ICU',
],
}
11 changes: 6 additions & 5 deletions deps/download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
# 4. node-gyp links the two resulting binaries to generate better_sqlite3.node.
# ===

YEAR="2024"
VERSION="3470000"
CHECKIN="d2d954d4"

# Defines below are sorted alphabetically
DEFINES="
Expand Down Expand Up @@ -58,6 +57,8 @@ SQLITE_SOUNDEX
SQLITE_THREADSAFE=2
SQLITE_TRACE_SIZE_LIMIT=32
SQLITE_USE_URI=0
SQLITE_OMIT_LOAD_EXTENSION
SQLITE_ENABLE_ICU
"

# ========== START SCRIPT ========== #
Expand All @@ -73,11 +74,11 @@ mkdir -p "$OUTPUT"
export CFLAGS=`echo $(echo "$DEFINES" | sed -e "/^\s*$/d" -e "s/^/-D/")`

echo "downloading source..."
curl -#f "https://www.sqlite.org/$YEAR/sqlite-src-$VERSION.zip" > "$TEMP/source.zip" || exit 1
curl -#f "https://sqlite.org/src/zip/$CHECKIN/SQLite-$CHECKIN.zip" > "$TEMP/source.zip" || exit 1

echo "extracting source..."
unzip "$TEMP/source.zip" -d "$TEMP" > /dev/null || exit 1
cd "$TEMP/sqlite-src-$VERSION" || exit 1
cd "$TEMP/SQLite-$CHECKIN" || exit 1

echo "configuring amalgamation..."
sh configure > /dev/null || exit 1
Expand All @@ -86,7 +87,7 @@ echo "building amalgamation..."
make sqlite3.c > /dev/null || exit 1

echo "copying amalgamation..."
cp sqlite3.c sqlite3.h sqlite3ext.h "$OUTPUT/" || exit 1
cp sqlite3.c sqlite3.h sqlite3ext.h shell.c "$OUTPUT/" || exit 1

echo "applying patches..."
cd "$DEPS" || exit 1
Expand Down
48 changes: 35 additions & 13 deletions deps/sqlite3.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,18 @@
'action_name': 'copy_builtin_sqlite3',
'inputs': [
'sqlite3/sqlite3.c',
'sqlite3/shell.c',
'sqlite3/sqlite3.h',
'sqlite3/sqlite3ext.h',
],
'outputs': [
'<(SHARED_INTERMEDIATE_DIR)/sqlite3/sqlite3.c',
'<(SHARED_INTERMEDIATE_DIR)/sqlite3/shell.c',
'<(SHARED_INTERMEDIATE_DIR)/sqlite3/sqlite3.h',
'<(SHARED_INTERMEDIATE_DIR)/sqlite3/sqlite3ext.h',
],
'action': ['node', 'copy.js', '<(SHARED_INTERMEDIATE_DIR)/sqlite3', ''],
}],
}, {
'actions': [{
'action_name': 'copy_custom_sqlite3',
'inputs': [
'<(sqlite3)/sqlite3.c',
'<(sqlite3)/sqlite3.h',
],
'outputs': [
'<(SHARED_INTERMEDIATE_DIR)/sqlite3/sqlite3.c',
'<(SHARED_INTERMEDIATE_DIR)/sqlite3/sqlite3.h',
],
'action': ['node', 'copy.js', '<(SHARED_INTERMEDIATE_DIR)/sqlite3', '<(sqlite3)'],
}],
}],
],
},
Expand Down Expand Up @@ -76,5 +65,38 @@
},
},
},
{
'target_name': 'shell',
'type': 'executable',
'dependencies': ['sqlite3'],
'sources': ['<(SHARED_INTERMEDIATE_DIR)/sqlite3/sqlite3.c', '<(SHARED_INTERMEDIATE_DIR)/sqlite3/shell.c'],
'include_dirs': ['<(SHARED_INTERMEDIATE_DIR)/sqlite3/'],
'direct_dependent_settings': {
'include_dirs': ['<(SHARED_INTERMEDIATE_DIR)/sqlite3/'],
},
'cflags': ['-std=c99', '-w'],
'xcode_settings': {
'OTHER_CFLAGS': ['-std=c99'],
'WARNING_CFLAGS': ['-w'],
},
'conditions': [
['sqlite3 == ""', {
'includes': ['defines.gypi'],
}, {
'defines': [
# This is currently required by better-sqlite3.
'SQLITE_ENABLE_COLUMN_METADATA',
],
}]
],
'configurations': {
'Debug': {
'msvs_settings': { 'VCCLCompilerTool': { 'RuntimeLibrary': 1 } }, # static debug
},
'Release': {
'msvs_settings': { 'VCCLCompilerTool': { 'RuntimeLibrary': 0 } }, # static release
},
},
},
],
}
Loading