Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 63 additions & 19 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ aliases:
if [[ "${ELECTRON_VERSION}" ]]; then
GYP_ARGS="--runtime=electron --target=${ELECTRON_VERSION} --dist-url=https://electronjs.org/headers"
fi
if [[ "${BUILD_ARM64}" == "true" ]]; then
GYP_ARGS="${GYP_ARGS} --target_arch=arm64"
fi
./node_modules/.bin/node-pre-gyp rebuild package testpackage $GYP_ARGS

- &build-command-windows
Expand All @@ -34,6 +37,9 @@ aliases:
if [[ "${ELECTRON_VERSION}" ]]; then
GYP_ARGS="--runtime=electron --target=${ELECTRON_VERSION} --dist-url=https://electronjs.org/headers"
fi
if [[ "${BUILD_ARM64}" == "true" ]]; then
GYP_ARGS="${GYP_ARGS} --target_arch=arm64"
fi
COMMIT_MESSAGE=`git log --format=%s -n 1 $CIRCLE_SHA1`
if [[ ${COMMIT_MESSAGE} =~ "[publish binary]" ]] && [[ "$PUBLISH" == "true" ]]; then
./node_modules/.bin/node-pre-gyp publish $GYP_ARGS
Expand Down Expand Up @@ -88,7 +94,7 @@ aliases:
- run: curl -sSL https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
- run: sudo apt-get update && sudo apt-get install -y git-lfs && git-lfs install --force && git-lfs pull
# These are required for electron(-mocha)
- run: sudo apt-get install -y libgtk2.0-0 libgtk-3-dev libxtst6 libxss1 libgconf2-4 libnss3 libasound2
- run: sudo apt-get install -y libgtk2.0-0 libgtk-3-dev libxtst6 libxss1 libgconf2-dev libnss3 libasound2
- run:
name: Install
command: |
Expand All @@ -102,7 +108,7 @@ aliases:

- &common-macos
macos:
xcode: "10.2.1"
xcode: "13.1.0"
steps:
- checkout
- run: |
Expand Down Expand Up @@ -130,12 +136,17 @@ aliases:
node -v
npm install --build-from-source
- run: *build-command
- run: npm run test
- run:
name: Run Tests
command: |
if [[ "${SKIP_TEST}" != "true" ]]; then
npm run test
fi
- run: *publish-command

- &common-electron-macos
macos:
xcode: "10.2.1"
xcode: "13.1.0"
steps:
- checkout
- run: |
Expand Down Expand Up @@ -214,11 +225,16 @@ aliases:
# ./node_modules/.bin/electron "test/support/createdb-electron.js"
# ./node_modules/.bin/electron-mocha --timeout 480000
jobs:
build-14:
build-16:
<<: *common-build
environment:
PUBLISH: true
ELECTRON_VERSION: "11.2.3"
ELECTRON_VERSION: "16.0.2"
docker:
- image: circleci/node:16.9.1

build-14:
<<: *common-build
docker:
- image: circleci/node:14.11.0

Expand All @@ -234,6 +250,13 @@ jobs:

# Node version should match electron's node version.
# See https://github.com/mapbox/node-sqlite3/pull/1367
build-electron-16:
<<: *common-electron-linux
docker:
- image: circleci/node:16.9.1
environment:
ELECTRON_VERSION: "16.0.2"

build-electron-11:
<<: *common-electron-linux
docker:
Expand Down Expand Up @@ -276,10 +299,26 @@ jobs:
environment:
ELECTRON_VERSION: "6.1.9"

build-macos-14:

build-macos-16:
<<: *common-macos
environment:
PUBLISH: true
NODE_VERSION: "16.9.1"
ELECTRON_VERSION: "16.0.2"

build-macos-16-arm64:
<<: *common-macos
environment:
PUBLISH: true
NODE_VERSION: "16.9.1"
ELECTRON_VERSION: "16.0.2"
BUILD_ARM64: true
SKIP_TEST: true

build-macos-14:
<<: *common-macos
environment:
NODE_VERSION: "14.11.0"
ELECTRON_VERSION: "11.2.3"

Expand All @@ -295,6 +334,7 @@ jobs:

# NODE_VERSION should match electron's node version.
# See https://github.com/mapbox/node-sqlite3/pull/1367

build-macos-electron-11:
<<: *common-electron-macos
environment:
Expand Down Expand Up @@ -333,47 +373,51 @@ jobs:
NODE_VERSION: "12.6.0"

# Node 14 - build NAPI 3 and 6
windows-14_x86:
windows-16_x86:
<<: *common-windows
environment:
NODE_VERSION: "14.11.0"
NODE_VERSION: "16.9.1"
NODE_ARCH: x86
PUBLISH: true
ELECTRON_VERSION: "11.2.3"
ELECTRON_VERSION: "16.0.2"
BUILD_ARM64: false

windows-14_x64:
windows-16_x64:
<<: *common-windows
environment:
NODE_VERSION: "14.11.0"
NODE_VERSION: "16.9.1"
NODE_ARCH: x64
PUBLISH: true
ELECTRON_VERSION: "11.2.3"
ELECTRON_VERSION: "16.0.2"
BUILD_ARM64: false

windows-14_arm64:
windows-16_arm64:
<<: *common-windows
environment:
NODE_VERSION: "14.11.0"
NODE_VERSION: "16.9.1"
NODE_ARCH: x64
PUBLISH: true
ELECTRON_VERSION: "11.2.3"
ELECTRON_VERSION: "16.0.2"
BUILD_ARM64: true
SKIP_TEST: true # We can build for arm64, but can't run arm64.

workflows:
version: 2
build_all:
jobs:
- build-16
- build-14
- build-12
- build-10
- build-electron-16
- build-electron-11
# - build-electron-10 # Segfaults on electron-mocha
- build-electron-9
- build-electron-8
- build-electron-7
- build-electron-6
- build-macos-16-arm64
- build-macos-16
- build-macos-14
- build-macos-12
- build-macos-10
Expand All @@ -383,6 +427,6 @@ workflows:
- build-macos-electron-8
- build-macos-electron-7
- build-macos-electron-6
- windows-14_x86
- windows-14_x64
- windows-14_arm64
- windows-16_x86
- windows-16_x64
- windows-16_arm64
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
deps/sqlcipher-*.tar.gz filter=lfs diff=lfs merge=lfs -text
deps/**/*.lib filter=lfs diff=lfs merge=lfs -text
deps/**/*.pdb filter=lfs diff=lfs merge=lfs -text
deps/**/*.a filter=lfs diff=lfs merge=lfs -text
23 changes: 9 additions & 14 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# Contributing

General guidelines for contributing to node-sqlite3
General guidelines for contributing to node-sqlcipher.

## Install Help
# Testing

If you've landed here due to a failed install of `node-sqlite3` then feel free to create a [new issue](https://github.com/mapbox/node-sqlite3/issues/new) to ask for help. The most likely problem is that we do not yet provide pre-built binaries for your particular platform and so the `node-sqlite3` install attempted a source compile but failed because you are missing the [dependencies for node-gyp](https://github.com/TooTallNate/node-gyp#installation). But please provide as much detail on your problem as possible and we'll try to help. Please include:
- terminal logs of failed install (preferably from running `npm install sqlite3 --loglevel=info`)
- `node-sqlite3` version you tried to install
- node version you are running
- operating system and architecture you are running, e.g. `Windows 7 64 bit`.
[mocha](https://github.com/visionmedia/mocha) is required to run unit tests.

In sqlite3's directory (where its `package.json` resides) run the following:

npm install --build-from-source
npm test

## Developing / Pre-release

Expand Down Expand Up @@ -36,13 +37,7 @@ git commit --allow-empty -m "[publish binary]"

**3)** Ensure binaries built

Check the travis and appveyor pages to ensure they are all green as an indication that the `[publish binary]` command worked.

If you need to republish binaries you can do this with the command below, however this should not be a common thing for you to do!

```sh
git commit --allow-empty -m "[republish binary]"
```
Check the CircleCI pages to ensure they are all green as an indication that the `[publish binary]` command worked.

Note: NEVER republish binaries for an existing released version.

Expand Down
37 changes: 4 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,10 @@ A copy of the source for SQLCipher 4.4.2 is bundled, which is based on SQLite 3.

## Building from source.

This is done automatically by node-pre-gyp when installing on a platform without pre-built binaries. This should generally
not be required with later versions, since two pre-built versions (N-API 3 and N-API 6) cover all electron and node versions.
Building from source when installing the package is only supported up to version 5.2.0.

However, this does require some additional setup, and is likely to run against obscure errors when installing.

Requirements:

### Mac

* `brew install openssl@1.1`

### Windows

* Visual Studio 2015
* Python 2.7
The two pre-built versions (N-API 3 and N-API 6) cover all electron and node versions, so building from source should
not be required.

## Usage with electron-forge / electron-rebuild

Expand Down Expand Up @@ -97,7 +86,7 @@ SQLCipher depends on OpenSSL.

For Windows, we bundle OpenSSL 1.1.1i. Binaries are generated using [vckpg](https://github.com/microsoft/vcpkg) (e.g., `.\vcpkg\vcpkg install openssl:x64-windows-static`).

On Mac we build against OpenSSL installed via brew, but statically link it so that end-users do not need to install it.
On Mac we bundle OpenSSL 1.1.1l.

On Linux we dynamically link against the system OpenSSL.

Expand All @@ -107,24 +96,6 @@ See the [API documentation](https://github.com/mapbox/node-sqlite3/wiki) in the

Documentation for the SQLCipher extension is available [here](https://www.zetetic.net/sqlcipher/sqlcipher-api/).

# Testing

[mocha](https://github.com/visionmedia/mocha) is required to run unit tests.

In sqlite3's directory (where its `package.json` resides) run the following:

npm install --build-from-source
npm test

# Publishing

To publish a new version, run:

npm version minor -m "%s [publish binary]"
npm publish

Publishing of the prebuilt binaries is performed on CircleCI.

# Acknowledgments

Most of the work in this library is from the [node-sqlite3](https://github.com/mapbox/node-sqlite3) library by [MapBox](https://mapbox.com/).
Expand Down
26 changes: 8 additions & 18 deletions SQLCipher.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ The above produces 4 files of interest:
```
sqlite3.c
sqlite3.h
shell.c # optional
sqlite3ext.h # optional
VERSION # optional
shell.c
sqlite3ext.h
VERSION # rename to VERSION.txt
```

The files are copied to: `sqlcipher-amalgamation-<version>`.
Copy these files to: `deps/sqlcipher-amalgamation`.

## Step 2: Get OpenSSL libraries

NodeJS typically includes OpenSSL. However, for Electron on Windows, we need to bundle a copy.
NodeJS typically includes OpenSSL. However, to support Electron, we statically link against libcrypto from OpenSSL.

Run the following commands to generate the latest OpenSSL libs for Windows:

Expand All @@ -40,25 +40,15 @@ cd deps
.\openssl-windows.bat
```

... this will output the libs in `deps/openssl-windows` (OpenSSL-WinXX), including the header files in `deps/openssl-windows/openssl-include`. Every arch-specific folder includes these binaries:
... this will output the libs in `deps/` (OpenSSL-WinXX), including the header files in `deps/openssl-include`. Every arch-specific folder includes these binaries:

```
libcrypto.lib
libssl.lib
ossl_static.pdb
```

Copy all folders under `deps/openssl-windows` to `sqlcipher-amalgamation-<version>`.

## Step 3: Build the archive

Archive the folder as `deps/sqlcipher-amalgamation-<version>.tar.gz`, and update the version number in `common-sqlite.gypi` (must be the same).

```
tar czf sqlcipher-amalgamation-$VERSION.tar.gz sqlcipher-amalgamation-$VERSION
```

## Step 4: Test the build
## Step 3: Test the build

Run:

Expand All @@ -78,7 +68,7 @@ npm run test
The OpenSSL files are specifically required for Electron, which doesn't bundle OpenSSL like NodeJS does. The header and .lib files are required at compile-time. We bundle a statically-linked version of OpenSSL with the library, so the user does not need to manually install OpenSSL.

`deps/sqlite3.gyp` has been modified from the original node-sqlite3 one to:
* Use the bundled OpenSSL on Windows.
* Use the bundled OpenSSL on Windows and MacOS.
* Add additional define statements required by SQLCipher.


3 changes: 3 additions & 0 deletions deps/OpenSSL-Win32/libcrypto.lib
Git LFS file not shown
3 changes: 3 additions & 0 deletions deps/OpenSSL-Win32/libssl.lib
Git LFS file not shown
3 changes: 3 additions & 0 deletions deps/OpenSSL-Win32/ossl_static.pdb
Git LFS file not shown
3 changes: 3 additions & 0 deletions deps/OpenSSL-Win64-ARM/libcrypto.lib
Git LFS file not shown
3 changes: 3 additions & 0 deletions deps/OpenSSL-Win64-ARM/libssl.lib
Git LFS file not shown
3 changes: 3 additions & 0 deletions deps/OpenSSL-Win64-ARM/ossl_static.pdb
Git LFS file not shown
3 changes: 3 additions & 0 deletions deps/OpenSSL-Win64/libcrypto.lib
Git LFS file not shown
3 changes: 3 additions & 0 deletions deps/OpenSSL-Win64/libssl.lib
Git LFS file not shown
3 changes: 3 additions & 0 deletions deps/OpenSSL-Win64/ossl_static.pdb
Git LFS file not shown
Loading