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

introduce first iteration of the zig build #1543

Open
wants to merge 40 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
37e5f7b
add nix flake, only devShell for now
levydsa Jun 22, 2024
6616400
fix(flake): add missing dependencies
levydsa Jun 25, 2024
ac4193d
add: introduce zig build
levydsa Jun 25, 2024
77169c4
fix(sqlite3): include vdbeInt.h (#1501)
levydsa Jun 25, 2024
0d3c464
build(libsql-sqlite3): first iteration of build.zig
levydsa Jun 25, 2024
118e6b0
fix(libsql-sqlite3): add parsing functions to internal API
levydsa Jun 28, 2024
6385aae
bump wasmtime-bindings rust-toolchain to lastest stable
levydsa Jun 28, 2024
f5ecc9a
temporary solution for build.crab current limitations
levydsa Jun 28, 2024
4594f32
flake: add icu and pkg-config
levydsa Jun 28, 2024
04e71ac
WIP
levydsa Jun 28, 2024
2eb6d56
add(flake): zlib dev dependency
levydsa Jun 29, 2024
ee33ce3
fix(libsql-sqlite3): definition seems to not match
levydsa Jul 2, 2024
5573d70
fix(build.zig): mostly working, needs some refactor
levydsa Jul 2, 2024
9e737d5
refactor(libsql-sqlite3): remove unnecessary includes with inline def…
levydsa Jul 2, 2024
50203bc
Merge branch 'main' into better-build
levydsa Jul 2, 2024
ffa65d3
Merge remote-tracking branch 'turso/main' into better-build
levydsa Jul 2, 2024
a642418
fix(sqlite3): does not compile without this header
levydsa Jul 2, 2024
a19ee60
fix(mksqlite3h): substitute new version patterns
levydsa Jul 5, 2024
1b947f9
Revert "temporary solution for build.crab current limitations"
levydsa Jul 9, 2024
21f35f5
fix(flake): enable bindgenHook
levydsa Jul 9, 2024
ceaa00e
update .gitignore
levydsa Jul 9, 2024
63af3e1
add(libsql-ffi): introduce zig-build
levydsa Jul 9, 2024
f363f60
minor zig build tweaks
levydsa Jul 9, 2024
b4f6fe4
bump to latest rust stable
levydsa Jul 9, 2024
c80a27f
fix(libsql): make tests pass
levydsa Jul 9, 2024
5873b8c
Merge remote-tracking branch 'turso/main' into better-build
levydsa Jul 9, 2024
a456f78
fix(build): prevent race condition with block
levydsa Jul 9, 2024
77e6a56
add libsql_vector tests to veryquick
levydsa Jul 9, 2024
04baef8
feat(build): add vector and rust_suite
levydsa Jul 9, 2024
534aed2
feat(libsql-sys): introduce zig build
levydsa Jul 9, 2024
778e252
Revert 1 commits
levydsa Jul 11, 2024
af4e81f
refactor: large refactor of the build and minor changes
levydsa Jul 12, 2024
4095ccc
Merge branch 'tursodatabase:main' into better-build
levydsa Jul 12, 2024
1cbbd25
refactor(build): more options and fixes
levydsa Jul 15, 2024
3870310
fix(build): add SQLITE_DEBUG on .Debug optimze
levydsa Jul 15, 2024
2b3cc21
revert test8.c bug fix
levydsa Jul 15, 2024
db7847a
revert main.c changes
levydsa Jul 15, 2024
ede336e
Merge branch 'main' into better-build
levydsa Aug 29, 2024
0d6c5a1
chore: cargo fmt
levydsa Aug 29, 2024
3c88ee9
chore: update bundle
levydsa Aug 29, 2024
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
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/target
.vscode/
.idea/
.direnv/
*.sqld
tags

libsql-server/testrollbackrestore/**
libsql-server/testbackuprestore/**
Expand All @@ -12,4 +14,4 @@ libsql-sqlite3/**.o.tmp

/bindings/c/generated
/bindings/c/**.xcframework
/bindings/**/.DS_Store
/bindings/**/.DS_Store
61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
description = "A very basic flake";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
flake-utils = {
url = "github:numtide/flake-utils";
};
};

outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
};
in {
devShells.default =
with pkgs;
mkShell {
nativeBuildInputs = with pkgs; [
pkg-config
zig
tcl
cmake
gnumake
clang
rustPlatform.bindgenHook
wasmtime
];
buildInputs = with pkgs; [
icu.dev
zlib.dev
];
};
}
);
}
1 change: 1 addition & 0 deletions libsql-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ bindgen = "0.66.1"
cc = "1.0"

[features]
zig-build = []
session = []
wasmtime-bindings = ["dep:libsql-wasmtime-bindings"]
multiple-ciphers = []
Expand Down
47 changes: 47 additions & 0 deletions libsql-ffi/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,53 @@ const BUNDLED_DIR: &str = "bundled";
const SQLITE_DIR: &str = "../libsql-sqlite3";

fn main() {
if cfg!(feature = "zig-build") && !cfg!(feature = "multiple-ciphers") {
println!("cargo:rerun-if-changed=../libsql-sqlite3/");

let out_dir_str = env::var("OUT_DIR").unwrap();
let out_dir = Path::new(out_dir_str.as_str());

Command::new("zig")
.arg("build")
.args([
"--build-file",
PathBuf::from("../libsql-sqlite3/build.zig")
.canonicalize()
.unwrap()
.to_str()
.unwrap(),
])
.args([
"--cache-dir",
out_dir.join(".zig-cache").to_str().unwrap().as_ref(),
])
.args(["--prefix", out_dir.to_str().unwrap().as_ref()])
.spawn()
.unwrap()
.wait()
.unwrap();

bindings::write_to_out_dir(
HeaderLocation::FromPath(
out_dir
.join("include/sqlite3.h")
.to_str()
.unwrap()
.to_string(),
),
out_dir.join("bindgen.rs").as_path(),
);

println!("cargo:rerun-if-changed=../libsql-sqlite3/");
println!(
"cargo:rustc-link-search={}",
out_dir.join("lib/").to_str().unwrap()
);
println!("cargo:rustc-link-lib=static=sqlite3");

return;
}

let target = env::var("TARGET").unwrap();
let host = env::var("HOST").unwrap();

Expand Down
14 changes: 10 additions & 4 deletions libsql-ffi/bundled/src/sqlite3.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
** configure
** configure.ac
** ext/fts5/fts5_tokenize.c
** ext/fts5/fts5_unicode2.c
** ext/jni/src/org/sqlite/jni/capi/CollationNeededCallback.java
** ext/jni/src/org/sqlite/jni/capi/CommitHookCallback.java
** ext/jni/src/org/sqlite/jni/capi/PreupdateHookCallback.java
Expand Down Expand Up @@ -538,11 +539,11 @@ extern "C" {
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()].
*/
#define SQLITE_VERSION "3.45.1"
#define SQLITE_VERSION "3.45.1"
#define SQLITE_VERSION_NUMBER 3045001
#define SQLITE_SOURCE_ID "2024-01-30 16:01:20 e876e51a0ed5c5b3126f52e532044363a014bc594cfefa87ffb5b82257ccalt1"
#define SQLITE_SOURCE_ID "2024-01-30 16:01:20 e876e51a0ed5c5b3126f52e532044363a014bc594cfefa87ffb5b82257ccalt1"

#define LIBSQL_VERSION "0.2.3"
#define LIBSQL_VERSION "0.2.3"

/*
** CAPI3REF: Run-Time Library Version Numbers
Expand Down Expand Up @@ -21616,6 +21617,10 @@ SQLITE_PRIVATE int sqlite3SafetyCheckSickOrOk(sqlite3*);
SQLITE_PRIVATE void sqlite3ChangeCookie(Parse*, int);
SQLITE_PRIVATE With *sqlite3WithDup(sqlite3 *db, With *p);

/* libsql parse functions */
void libsql_create_function(Parse *pParse, Token *pName, Token *pLang, Token *pBody, int isBlob, int noErr);
void libsql_drop_function(Parse *pParse, Token *pName, int noErr);

#if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER)
SQLITE_PRIVATE void sqlite3MaterializeView(Parse*, Table*, Expr*, ExprList*,Expr*,int);
#endif
Expand Down Expand Up @@ -116950,6 +116955,7 @@ SQLITE_PRIVATE int sqlite3NoTempsInRange(Parse *pParse, int iFirst, int iLast){
** that implements the ALTER TABLE command.
*/
/* #include "sqliteInt.h" */
/* #include "vdbeInt.h" */

/*
** The code in this file only exists if we are not omitting the
Expand Down Expand Up @@ -261386,7 +261392,7 @@ static int sqlite3Fts5TokenizerInit(fts5_api *pApi){
** DO NOT EDIT THIS MACHINE GENERATED FILE.
*/


/* #include "fts5Int.h" */
/* #include <assert.h> */


Expand Down
6 changes: 3 additions & 3 deletions libsql-ffi/bundled/src/sqlite3.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,11 @@ extern "C" {
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()].
*/
#define SQLITE_VERSION "3.45.1"
#define SQLITE_VERSION "3.45.1"
#define SQLITE_VERSION_NUMBER 3045001
#define SQLITE_SOURCE_ID "2024-01-30 16:01:20 e876e51a0ed5c5b3126f52e532044363a014bc594cfefa87ffb5b82257ccalt1"
#define SQLITE_SOURCE_ID "2024-01-30 16:01:20 e876e51a0ed5c5b3126f52e532044363a014bc594cfefa87ffb5b82257ccalt1"

#define LIBSQL_VERSION "0.2.3"
#define LIBSQL_VERSION "0.2.3"

/*
** CAPI3REF: Run-Time Library Version Numbers
Expand Down
5 changes: 5 additions & 0 deletions libsql-sqlite3/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,10 @@ libsql
/crates/target/
/has_tclsh*
/libsql.wasm
zig-out/
.zig-cache
testdir*/
testrunner.db
testrunner.log
test_libsql_f16_table.h
test_libsql_f16
Loading
Loading