Skip to content

Commit 9403ac2

Browse files
committed
Support both SQLite and SQLeet using build tags
1 parent 9e31135 commit 9403ac2

32 files changed

Lines changed: 255739 additions & 12896 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
sqlite3.o
2+
sqleet.o

Makefile

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,33 @@
1616
# is imported, Go will build the ./c/sqlite.c file that is included directly by
1717
# static.go. However this is pretty slow ~30s. When developing this is very
1818
# annoying. Use this Makefile to pre-build the sqlite3.o object and then build
19-
# the package with the build tag linksqlite3, which will ignore static.go and
19+
# the package with the build tag link, which will ignore static.go and
2020
# use link.go instead to link against sqlite.o. This reduces compilation times
21-
# down to <3 sec!
21+
# down to < 3 sec!
2222
#
2323
# If you are using an editor that builds the project as you work on it, you'll
2424
# want to build the sqlite3.o object and tell your editor to use the
25-
# linksqlite3 go build tag when working on this project.
26-
# For vim-go, use the command `GoBuildTags linksqlite3` or
27-
# `let g:go_build_tags = # 'linksqlite3'`
25+
# link go build tag when working on this project.
26+
# For vim-go, use the command `GoBuildTags link` or
27+
# `let g:go_build_tags = # 'link'`
2828

29-
export GOFLAGS=-tags=linksqlite3
30-
31-
.PHONY: clean all env test release
29+
.PHONY: clean all env test sqleet test-all
3230
all: sqlite3.o
33-
go build ./...
31+
go build -tags=link ./...
32+
33+
test-all: test test-sqleet
3434

3535
test: sqlite3.o
36-
go test ./...
36+
go test -tags=link ./...
3737

38-
env:
39-
go env
38+
sqleet: sqleet.o
39+
go build -tags=link,sqleet ./...
4040

41-
## This builds the package statically.
42-
release:
43-
go build -tags=!linksqlite3
41+
test-sqleet: sqleet.o
42+
go test -tags=link,sqleet ./
4443

45-
VPATH = ./c # Look in ./c for source files
44+
# Paths to look for source files
45+
VPATH = ./c/sqlite ./c/sqleet
4646

4747
# !!! THESE DEFINES SHOULD MATCH sqlite.go for linux !!!
4848
CFLAGS += -std=c99
@@ -65,8 +65,5 @@ CFLAGS += -DSQLITE_ENABLE_GEOPOLY
6565
LDFLAGS = -ldl -lm
6666
# !!! THESE DEFINES SHOULD MATCH sqlite.go !!!
6767

68-
sqlite3.o: sqlite3.c sqlite3.h sqlite3ext.h
69-
70-
7168
clean:
72-
rm -f sqlite3.o
69+
rm -f sqlite3.o sqleet.o

auth.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright (c) 2018 David Crawshaw <david@zentus.com>
2+
//
3+
// Permission to use, copy, modify, and distribute this software for any
4+
// purpose with or without fee is hereby granted, provided that the above
5+
// copyright notice and this permission notice appear in all copies.
6+
//
7+
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8+
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9+
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10+
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11+
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12+
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13+
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14+
115
package sqlite
216

317
// #include <stdint.h>

auth_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright (c) 2018 David Crawshaw <david@zentus.com>
2+
//
3+
// Permission to use, copy, modify, and distribute this software for any
4+
// purpose with or without fee is hereby granted, provided that the above
5+
// copyright notice and this permission notice appear in all copies.
6+
//
7+
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8+
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9+
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10+
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11+
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12+
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13+
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14+
115
package sqlite_test
216

317
import (

blocking_step.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright (c) 2018 David Crawshaw <david@zentus.com>
2+
//
3+
// Permission to use, copy, modify, and distribute this software for any
4+
// purpose with or without fee is hereby granted, provided that the above
5+
// copyright notice and this permission notice appear in all copies.
6+
//
7+
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8+
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9+
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10+
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11+
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12+
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13+
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14+
115
// This file declares the wait_for_unlock_notify function.
216
// See the documentation on Stmt.Step.
317

static.go renamed to build.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1313
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1414

15-
// +build !linksqlite3
16-
1715
package sqlite
1816

19-
// #include "./c/sqlite3.c"
17+
// #cgo link,!sqleet LDFLAGS: sqlite3.o
18+
// #cgo link,sqleet LDFLAGS: sqleet.o
19+
// #cgo !link CFLAGS: -DCGO
20+
// #cgo sqleet CFLAGS: -DCGO_SQLEET
2021
import "C"

c/dummy.go

Lines changed: 0 additions & 7 deletions
This file was deleted.
File renamed without changes.

0 commit comments

Comments
 (0)