Skip to content

Commit

Permalink
initial pass
Browse files Browse the repository at this point in the history
  • Loading branch information
asg017 committed Aug 1, 2022
0 parents commit 01cd767
Show file tree
Hide file tree
Showing 13 changed files with 277,267 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sqlite/* linguist-vendored
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.vscode
a.out
dist/
cwalk
64 changes: 64 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
COMMIT=$(shell git rev-parse HEAD)
VERSION=$(shell cat VERSION)
DATE=$(shell date +'%FT%TZ%z')

CWALK_VERSION=$(shell jq '.version' cwalk/clib.json)

LOADABLE_CFLAGS=-fPIC -shared

ifeq ($(shell uname -s),Darwin)
CONFIG_DARWIN=y
else
CONFIG_LINUX=y
endif

ifdef CONFIG_DARWIN
LOADABLE_EXTENSION=dylib
endif

ifdef CONFIG_LINUX
LOADABLE_EXTENSION=so
endif
TARGET_LOADABLE=dist/path0.$(LOADABLE_EXTENSION)

DEFINE_SQLITE_PATH_DATE=-DSQLITE_PATH_DATE="\"$(DATE)\""
DEFINE_SQLITE_PATH_VERSION=-DSQLITE_PATH_VERSION="\"$(VERSION)\""
DEFINE_SQLITE_PATH_SOURCE=-DSQLITE_PATH_SOURCE="\"$(COMMIT)\""
DEFINE_SQLITE_PATH_CWALK_VERSION=-DSQLITE_PATH_CWALK_VERSION="\"$(CWALK_VERSION)\""
DEFINE_SQLITE_PATH=$(DEFINE_SQLITE_PATH_DATE) $(DEFINE_SQLITE_PATH_VERSION) $(DEFINE_SQLITE_PATH_SOURCE) $(DEFINE_SQLITE_PATH_CWALK_VERSION)

clean:
rm dist/*

FORMAT_FILES=sqlite-path.h sqlite-path.c core_init.c
format: $(FORMAT_FILES)
clang-format -i $(FORMAT_FILES)

loadable: $(TARGET_LOADABLE) $(TARGET_LOADABLE_NOFS)

$(TARGET_LOADABLE): sqlite-path.c
gcc -Isqlite -Icwalk/include \
$(LOADABLE_CFLAGS) \
$(DEFINE_SQLITE_PATH) \
$< -o $@ cwalk/src/cwalk.c

dist/sqlite3-extra.c: sqlite/sqlite3.c core_init.c
cat sqlite/sqlite3.c core_init.c > $@

test:
make test-format
make test-loadable

test-format: SHELL:=/bin/bash
test-format:
diff -u <(cat $(FORMAT_FILES)) <(clang-format $(FORMAT_FILES))

test-loadable: $(TARGET_LOADABLE)
python3 tests/test-loadable.py

test-loadable-watch: $(TARGET_LOADABLE)
watchexec -w sqlite-path.c -w $(TARGET_LOADABLE) -w tests/test-loadable.py --clear -- make test-loadable

.PHONY: all clean format \
test test-watch test-format \
loadable test-loadable test-loadable-watch
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## TODO

- [ ] lib
- [ ] `path_join(...args)`
- [ ] `path_join(segment)` aggregate function
- [ ] windows/unix?
- [ ] test loadable
- [ ] sqlite3 build
- [ ] wasm build
- [ ] debug w/ cwalk version
- [ ] usecases
- [ ] local fs, pair with `fsdir`
- [ ] zipfile names
- [ ] URLs
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v0.0.0
9 changes: 9 additions & 0 deletions core_init.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
This file is appended to the end of a sqlite3.c amalgammation
file to include sqlite3_lines functions/tables statically in
a build. This is used for the demo CLI and WASM implementations.
*/
#include "sqlite-path.h"
int core_init(const char *dummy) {
return sqlite3_auto_extension((void *)sqlite3_path_init);
}
Loading

0 comments on commit 01cd767

Please sign in to comment.