Skip to content

Commit

Permalink
Support both SQLite and SQLeet using build tags
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamSLevy committed Jun 21, 2020
1 parent 9e31135 commit dbc35d1
Show file tree
Hide file tree
Showing 32 changed files with 255,739 additions and 12,896 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
sqlite3.o
sqleet.o
37 changes: 17 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,33 @@
# is imported, Go will build the ./c/sqlite.c file that is included directly by
# static.go. However this is pretty slow ~30s. When developing this is very
# annoying. Use this Makefile to pre-build the sqlite3.o object and then build
# the package with the build tag linksqlite3, which will ignore static.go and
# the package with the build tag link, which will ignore static.go and
# use link.go instead to link against sqlite.o. This reduces compilation times
# down to <3 sec!
# down to < 3 sec!
#
# If you are using an editor that builds the project as you work on it, you'll
# want to build the sqlite3.o object and tell your editor to use the
# linksqlite3 go build tag when working on this project.
# For vim-go, use the command `GoBuildTags linksqlite3` or
# `let g:go_build_tags = # 'linksqlite3'`
# link go build tag when working on this project.
# For vim-go, use the command `GoBuildTags link` or
# `let g:go_build_tags = # 'link'`

export GOFLAGS=-tags=linksqlite3

.PHONY: clean all env test release
.PHONY: clean all env test sqleet test-all
all: sqlite3.o
go build ./...
go build -tags=link ./...

test-all: test test-sqleet

test: sqlite3.o
go test ./...
go test -tags=link ./...

env:
go env
sqleet: sqleet.o
go build -tags=link,sqleet ./...

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

VPATH = ./c # Look in ./c for source files
# Paths to look for source files
VPATH = ./c/sqlite ./c/sqleet

# !!! THESE DEFINES SHOULD MATCH sqlite.go for linux !!!
CFLAGS += -std=c99
Expand All @@ -65,8 +65,5 @@ CFLAGS += -DSQLITE_ENABLE_GEOPOLY
LDFLAGS = -ldl -lm
# !!! THESE DEFINES SHOULD MATCH sqlite.go !!!

sqlite3.o: sqlite3.c sqlite3.h sqlite3ext.h


clean:
rm -f sqlite3.o
rm -f sqlite3.o sqleet.o
14 changes: 14 additions & 0 deletions auth.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright (c) 2018 David Crawshaw <[email protected]>
//
// Permission to use, copy, modify, and distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

package sqlite

// #include <stdint.h>
Expand Down
14 changes: 14 additions & 0 deletions auth_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright (c) 2018 David Crawshaw <[email protected]>
//
// Permission to use, copy, modify, and distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

package sqlite_test

import (
Expand Down
14 changes: 14 additions & 0 deletions blocking_step.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright (c) 2018 David Crawshaw <[email protected]>
//
// Permission to use, copy, modify, and distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

// This file declares the wait_for_unlock_notify function.
// See the documentation on Stmt.Step.

Expand Down
7 changes: 4 additions & 3 deletions static.go → build.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

// +build !linksqlite3

package sqlite

// #include "./c/sqlite3.c"
// #cgo link,!sqleet LDFLAGS: sqlite3.o
// #cgo link,sqleet LDFLAGS: sqleet.o
// #cgo !link CFLAGS: -DCGO
// #cgo sqleet CFLAGS: -DCGO_SQLEET
import "C"
7 changes: 0 additions & 7 deletions c/dummy.go

This file was deleted.

File renamed without changes.
Loading

0 comments on commit dbc35d1

Please sign in to comment.