-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
126 lines (93 loc) · 2.6 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
VERSION=$(shell cat VERSION)
ifeq ($(shell uname -s),Darwin)
CONFIG_DARWIN=y
else ifeq ($(OS),Windows_NT)
CONFIG_WINDOWS=y
else
CONFIG_LINUX=y
endif
ifdef CONFIG_DARWIN
LOADABLE_EXTENSION=dylib
endif
ifdef CONFIG_LINUX
LOADABLE_EXTENSION=so
endif
ifdef CONFIG_WINDOWS
LOADABLE_EXTENSION=dll
endif
ifdef python
PYTHON=$(python)
else
PYTHON=python3
endif
ifdef IS_MACOS_ARM
RENAME_WHEELS_ARGS=--is-macos-arm
else
RENAME_WHEELS_ARGS=
endif
prefix=dist
$(prefix):
mkdir -p $(prefix)
DEFINE_HELLO=-DSQLITE_HELLO_VERSION="\"v$(VERSION)\""
TARGET_LOADABLE_HELLO=$(prefix)/hello0.$(LOADABLE_EXTENSION)
TARGET_LOADABLE_HOLA=$(prefix)/hola0.$(LOADABLE_EXTENSION)
TARGET_LOADABLE=$(TARGET_LOADABLE_HELLO) $(TARGET_LOADABLE_HOLA)
TARGET_STATIC_HELLO=$(prefix)/libsqlite_hello0.a
TARGET_STATIC_HELLO_H=$(prefix)/sqlite-hello.h
TARGET_STATIC_HOLA=$(prefix)/libsqlite_hola0.a
TARGET_STATIC_HOLA_H=$(prefix)/sqlite-hola.h
TARGET_STATIC=$(TARGET_STATIC_HELLO) $(TARGET_STATIC_HELLO_H) $(TARGET_STATIC_HOLA) $(TARGET_STATIC_HOLA_H)
loadable: $(TARGET_LOADABLE)
static: $(TARGET_STATIC)
$(TARGET_LOADABLE_HELLO): sqlite-hello.c $(prefix)
gcc -fPIC -shared \
-Ivendor \
-O3 \
$(DEFINE_HELLO) $(CFLAGS) \
$< -o $@
$(TARGET_STATIC_HELLO): sqlite-hello.c $(prefix)
gcc -Ivendor $(DEFINE_HELLO) $(CFLAGS) -DSQLITE_CORE \
-O3 -c $< -o $(prefix)/hello.o
ar rcs $@ $(prefix)/hello.o
$(TARGET_STATIC_HELLO_H): sqlite-hello.h $(prefix)
cp $< $@
$(TARGET_LOADABLE_HOLA): sqlite-hola.c $(prefix)
gcc -fPIC -shared \
-Ivendor \
-O3 \
$(DEFINE_HELLO) $(CFLAGS) \
$< -o $@
$(TARGET_STATIC_HOLA): sqlite-hola.c $(prefix)
gcc -Ivendor $(DEFINE_HELLO) $(CFLAGS) -DSQLITE_CORE \
-O3 -c $< -o $(prefix)/hola.o
ar rcs $@ $(prefix)/hola.o
$(TARGET_STATIC_HOLA_H): sqlite-hola.h $(prefix)
cp $< $@
clean:
rm -rf dist/*
test:
sqlite3 :memory: '.read test.sql'
.PHONY: version loadable static test clean gh-release \
ruby
gh-release:
make version
git add --all
git commit -m "v$(VERSION)"
git tag v$(VERSION)
git push origin main v$(VERSION)
gh release create v$(VERSION) --prerelease --notes="" --title=v$(VERSION)
TARGET_WHEELS=$(prefix)/wheels
INTERMEDIATE_PYPACKAGE_EXTENSION=bindings/python/sqlite_hello/
$(TARGET_WHEELS): $(prefix)
mkdir -p $(TARGET_WHEELS)
bindings/rust/Cargo.toml: bindings/rust/Cargo.toml.tmpl VERSION
VERSION=$(VERSION) envsubst < $< > $@
bindings/rust/Cargo.lock: bindings/rust/Cargo.toml
cargo update --manifest-path=$<
bindings/go/hello/sqlite-hello.h: sqlite-hello.h
cp $< $@
bindings/go/hola/sqlite-hola.h: sqlite-hola.h
cp $< $@
rust: bindings/rust/Cargo.toml bindings/rust/Cargo.lock
version:
make rust