This repository has been archived by the owner on Feb 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Makefile
71 lines (60 loc) · 2.96 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
all: build
backend:
go build -o out/liwasc-backend/liwasc-backend cmd/liwasc-backend/main.go
frontend:
rm -f web/app.wasm
GOOS=js GOARCH=wasm go build -o web/app.wasm cmd/liwasc-frontend/main.go
go build -o /tmp/liwasc-frontend-build cmd/liwasc-frontend/main.go
rm -rf out/liwasc-frontend
/tmp/liwasc-frontend-build -build
cp -r web/* out/liwasc-frontend/web
build: backend frontend
release-backend:
CGO_ENABLED=1 go build -ldflags="-extldflags=-static" -tags sqlite_omit_load_extension,netgo -o out/release/liwasc-backend/liwasc-backend.linux-$$(uname -m) cmd/liwasc-backend/main.go
release-frontend: frontend
rm -rf out/release/liwasc-frontend
mkdir -p out/release/liwasc-frontend
cd out/liwasc-frontend && tar -czvf ../release/liwasc-frontend/liwasc-frontend.tar.gz .
release-frontend-github-pages: frontend
rm -rf out/release/liwasc-frontend-github-pages
mkdir -p out/release/liwasc-frontend-github-pages
/tmp/liwasc-frontend-build -build -path liwasc -out out/release/liwasc-frontend-github-pages
cp -r web/* out/release/liwasc-frontend-github-pages/web
release: release-backend release-frontend release-frontend-github-pages
install: release-backend
sudo install out/release/liwasc-backend/liwasc-backend.linux-$$(uname -m) /usr/local/bin/liwasc-backend
sudo setcap cap_net_raw+ep /usr/local/bin/liwasc-backend
dev:
while [ -z "$$BACKEND_PID" ] || [ -n "$$(inotifywait -q -r -e modify pkg cmd web/*.css)" ]; do\
$(MAKE);\
kill -9 $$BACKEND_PID 2>/dev/null 1>&2;\
kill -9 $$FRONTEND_PID 2>/dev/null 1>&2;\
wait $$BACKEND_PID $$FRONTEND_PID;\
sudo setcap cap_net_raw+ep out/liwasc-backend/liwasc-backend;\
out/liwasc-backend/liwasc-backend & export BACKEND_PID="$$!";\
/tmp/liwasc-frontend-build -serve & export FRONTEND_PID="$$!";\
done
clean:
rm -rf out
rm -rf pkg/api/proto/v1
rm -rf pkg/db
rm -rf ~/.local/share/liwasc
depend:
# Setup working directories
mkdir -p out/tmp/etc/liwasc out/tmp/var/lib/liwasc
# Setup external databases
curl -L -o out/tmp/etc/liwasc/oui-database.sqlite https://mac2vendor.com/download/oui-database.sqlite
curl -L -o out/tmp/etc/liwasc/service-names-port-numbers.csv https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.csv
curl -L -o out/tmp/etc/liwasc/ports2packets.csv https://github.com/pojntfx/ports2packets/releases/download/weekly-csv/ports2packets.csv
# Setup CLIs
GO111MODULE=on go get github.com/volatiletech/sqlboiler/v4@latest
GO111MODULE=on go get github.com/volatiletech/sqlboiler-sqlite3@latest
GO111MODULE=on go get github.com/golang/protobuf/protoc-gen-go@latest
GO111MODULE=on go get github.com/rubenv/sql-migrate/...
GO111MODULE=on go get github.com/fullstorydev/grpcurl/cmd/grpcurl@latest
GO111MODULE=on go get github.com/shuLhan/go-bindata/...
# Setup persistence databases
sql-migrate up -env="production" -config configs/sql-migrate/node_and_port_scan.yaml
sql-migrate up -env="production" -config configs/sql-migrate/node_wake.yaml
# Generate bindings
go generate ./...