-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
163 lines (134 loc) · 4.43 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
.PHONY: usage
usage:
@echo "make [TASK]"
@echo " format reformat code"
@echo " build build release"
@echo " clean remove build files"
@echo " test run all tests"
@echo " dev-check watch for changes and run cargo check"
@echo " dev-test watch for changes and run tests"
@echo " dev-serve watch for changes and run server"
.PHONY: deps
deps:
sudo apt-get update
sudo apt-get install -y rustc cargo
sudo apt-get install -y nodejs npm
sudo apt-get install -y python3-pip
sudo pip install tesh
npm install -g [email protected]
cd .. && git clone https://github.com/ontodev/tree-sitter-sqlrest.git
cd ../tree-sitter-sqlrest && tree-sitter generate
.PHONY: format
format:
cargo fmt
.PHONY: build
build: src/javascript/build/main.js
cargo build --release
clean:
rm -rf build/ src/javascript/build/
build/ build/penguins/:
mkdir -p $@
build/penguins/%/:
mkdir -p $@
target/debug/nanobot: Cargo.* src/** src/javascript/build/main.js
cargo build
target/release/nanobot: Cargo.* src/** src/javascript/build/main.js
cargo build --release
src/javascript/build/main.js: src/javascript/package.* src/javascript/src/* src/javascript/public/*
cd src/javascript/ \
&& npm install \
&& npm run build \
&& cp build/static/js/main.*.js build/main.js \
&& cp build/static/css/main.*.css build/main.css
TEST_TABLES = ldtab prefix statement
TEST_TSVS = $(foreach T,$(TEST_TABLES),src/resources/test_data/$(T).tsv)
src/resources/test_data/zfa_excerpt.db: $(TEST_TSVS)
rm -f $@
sqlite3 $@ ".mode tabs" \
$(foreach T,$(TEST_TABLES),".import src/resources/test_data/$(T).tsv $(T)")
EXAMPLES := table tables
EXAMPLE_DBS := $(foreach EXAMPLE,$(EXAMPLES),build/penguins/$(EXAMPLE)/.nanobot.db)
.PHONY: test-examples
test-examples: $(EXAMPLE_DBS)
.PHONY: test-code
test-code: src/javascript/build/main.js
cargo fmt --check
cargo test
.PHONY: test-docs
test-docs:
PATH="$${PATH}:$$(pwd)/target/debug"; tesh --debug false ./doc
.PHONY: test
test: test-code test-examples test-docs
.PHONY: dev-check
dev-check:
find src/ tests/ | entr -rs 'cargo check --release'
.PHONY: dev-test
dev-test:
find src/ tests/ | entr make test
.PHONY: dev-serve
dev-serve:
find src/ | entr -rs 'cargo build --release && target/release/nanobot serve'
build/penguins/%/.nanobot.db: target/debug/nanobot examples/penguins/% | build/penguins/%/
rm -rf $|
mkdir -p $|
cp -r $(word 2,$^) build/penguins/
cd $| \
&& rm -f .nanobot.db \
&& python3 ../../../examples/penguins/generate.py src/data/penguin.tsv \
&& ../../../$< init
.PHONY: penguins
penguins: target/debug/nanobot build/penguins/tables/.nanobot.db
cd $(dir $(word 2,$^)) && ../../../$< serve
build/synthea.zip: | build
curl -L -o build/synthea.zip "https://synthetichealth.github.io/synthea-sample-data/downloads/synthea_sample_data_csv_apr2020.zip"
build/synthea/: build/synthea.zip examples/synthea/
mkdir -p build/synthea/src/data
cp -r examples/synthea/* build/synthea/
unzip $< -d build/synthea/
sed 's/,/ /g' build/synthea/csv/patients.csv > build/synthea/src/data/patients.tsv
sed 's/,/ /g' build/synthea/csv/observations.csv > build/synthea/src/data/observations.tsv
# && ~/valve.rs/target/release/ontodev_valve src/schema/table.tsv .nanobot.db
.PHONY: synthea
synthea: target/release/nanobot
rm -rf build/synthea/
make build/synthea/
cd build/synthea/ \
&& time ../../$< init \
&& ../../$< serve
TODAY := $(shell date +%Y-%m-%d)
YYYYMMDD := $(shell date +%Y%m%d)
ifeq ($(shell uname -m),arm64)
ARCH := aarch64
else
ARCH := x86_64
endif
ifeq ($(shell uname -s),Darwin)
TARGET := target/release/nanobot
BINARY := nanobot-v$(YYYYMMDD)-$(ARCH)-macos
else
TARGET := target/$(ARCH)-unknown-linux-musl/release/nanobot
BINARY := nanobot-v$(YYYYMMDD)-$(ARCH)-linux
endif
BINARY_PATH := build/$(BINARY)
# Build a Linux binary using Musl instead of GCC.
target/x86_64-unknown-linux-musl/release/nanobot: src/*.rs
docker pull clux/muslrust:stable
docker run \
-v cargo-cache:/root/.cargo/registry \
-v $$PWD:/volume \
--rm -t clux/muslrust:stable \
cargo build --release
.PHONY: musl
musl: target/x86_64-unknown-linux-musl/release/nanobot | build/
.PHONY: upload
upload: $(TARGET) | build/
cp $< $(BINARY_PATH)
gh release upload --clobber v$(TODAY) $(BINARY_PATH)
.PHONY: release
release: $(TARGET) | build/
cp $< $(BINARY_PATH)
gh release create --draft --prerelease \
--title "$(TODAY) Alpha Release" \
--generate-notes \
v$(TODAY) $(BINARY_PATH)
@echo "Please publish GitHub release v$(TODAY)"