Skip to content

Commit

Permalink
Revendor zig-sqlite
Browse files Browse the repository at this point in the history
  • Loading branch information
malcolmstill committed Jun 16, 2024
1 parent a78be84 commit 5b99b2d
Show file tree
Hide file tree
Showing 37 changed files with 288,783 additions and 1 deletion.
17 changes: 16 additions & 1 deletion build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@ pub fn build(b: *std.Build) void {
.optimize = optimize,
});

const lib_sqlite = b.addStaticLibrary(.{
.name = "sqlite",
.target = target,
.optimize = optimize,
});
lib_sqlite.addCSourceFile(.{
.file = b.path("lib/zig-sqlite/c/sqlite3.c"),
.flags = &[_][]const u8{
"-std=c99",
"-DSQLITE_ENABLE_FTS5",
},
});
lib_sqlite.addIncludePath(b.path("lib/zig-sqlite/c"));
lib_sqlite.linkLibC();

const @"ansi-term" = b.dependency("ansi-term", .{
.target = target,
.optimize = optimize,
Expand All @@ -24,7 +39,7 @@ pub fn build(b: *std.Build) void {
exe.root_module.addImport("ansi-term", @"ansi-term".module("ansi-term"));

// links the bundled sqlite3, so leave this out if you link the system one
exe.linkLibrary(sqlite.artifact("sqlite"));
exe.linkLibrary(lib_sqlite);

// This declares intent for the executable to be installed into the
// standard location when the user invokes the "install" step (the default
Expand Down
1 change: 1 addition & 0 deletions lib/zig-sqlite/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/zig-cache
4 changes: 4 additions & 0 deletions lib/zig-sqlite/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
c/sqlite3.c linguist-vendored
c/sqlite3.h linguist-vendored
zig.mod linguist-vendored
*.zig text=auto eol=lf
44 changes: 44 additions & 0 deletions lib/zig-sqlite/.github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Bug report
description: Create a bug report
labels:
- bug

body:
- type: markdown
attributes:
value: |
# A bug means something doesn't work as expected
Remember to include as much detail as possible.
- type: input
id: commit
attributes:
label: zig-sqlite commit
description: "The git commit of zig-sqlite"
validations:
required: true

- type: input
id: zig_version
attributes:
label: Zig version
description: "The output of `zig version`"
placeholder: "0.11.0-dev.3335+3085e2af4"
validations:
required: true

- type: textarea
id: repro
attributes:
label: Steps to reproduce
description: How can someone reproduce the problem you encountered ? Include a self-contained reproducer if possible
validations:
required: true

- type: textarea
id: expected
attributes:
label: Expected behaviour
description: What did you expect to happen?
validations:
required: true
6 changes: 6 additions & 0 deletions lib/zig-sqlite/.github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Description

Please describe the changes you want to make and why. Please also provide an explanation of the implementation.
As a rule of thumb, give as much detail as you would want to see if you were to review this PR.

If this PR closes an issue, please reference it with something like "Closes #issue".
78 changes: 78 additions & 0 deletions lib/zig-sqlite/.github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: CI

on:
create:
push:
branches: master
paths:
- '**.zig'
pull_request:
schedule:
- cron: "0 13 * * *"
workflow_dispatch:

concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: goto-bus-stop/setup-zig@v2
with:
version: master
- run: zig fmt --check *.zig

test-in-memory:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup zig
uses: goto-bus-stop/setup-zig@v2
with:
version: master

- name: Install qemu
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
sudo apt-get update -y && sudo apt-get install -y qemu-user-binfmt
- name: Restore cache
uses: actions/cache@v4
with:
path: |
zig-cache
~/.cache/zig
key: ${{ runner.os }}-${{ matrix.os }}-zig-${{ github.sha }}
restore-keys: ${{ runner.os }}-${{ matrix.os }}-zig-

- name: Run Tests in memory
if: ${{ matrix.os == 'ubuntu-latest' }}
run: zig build test -Dci=true -Din_memory=true --summary all -fqemu -fwine
- name: Run Tests in memory
if: ${{ matrix.os != 'ubuntu-latest' }}
run: zig build test -Dci=true -Din_memory=true --summary all

test-loadable-extension:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup zig
uses: goto-bus-stop/setup-zig@v2
with:
version: master

- name: Build the example zigcrypto loadable extension
run: zig build zigcrypto
- name: Test the zigcrypto loadable extension
run: ./zig-out/bin/zigcrypto-test
8 changes: 8 additions & 0 deletions lib/zig-sqlite/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/build_runner.zig
/.zig-cache
zig-out
.zigmod
deps.zig
core.*
/qemu*.core
/fuzz/outputs
21 changes: 21 additions & 0 deletions lib/zig-sqlite/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Vincent Rischmann <vincent@rischmann.fr>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading

0 comments on commit 5b99b2d

Please sign in to comment.