-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathMakefile
78 lines (65 loc) · 2.06 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
#
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright (c) 2023, daeuniverse Organization <team@v2raya.org>
#
SHELL := /bin/bash
OUTPUT ?= ./dae-wing
APPNAME ?= dae-wing
DESCRIPTION ?= $(APPNAME) is a integration solution of dae, API and UI.
VERSION ?= 0.0.0.unknown
GO_LDFLAGS := '-s -w -X github.com/daeuniverse/dae-wing/db.AppVersion=$(VERSION) -X github.com/daeuniverse/dae-wing/db.AppName=$(APPNAME) -X "github.com/daeuniverse/dae-wing/db.AppDescription=$(DESCRIPTION)" $(GO_LDFLAGS)'
include functions.mk
# Get version from .git.
date=$(shell git log -1 --format="%cd" --date=short | sed s/-//g)
count=$(shell git rev-list --count HEAD)
commit=$(shell git rev-parse --short HEAD)
ifeq ($(wildcard .git/.),)
VERSION ?= unstable-0.nogit
else
VERSION ?= unstable-$(date).r$(count).$(commit)
endif
BUILD_ARGS := -trimpath -ldflags=$(GO_LDFLAGS) $(BUILD_ARGS)
# Do NOT remove the line below. This line is for CI.
#export GOMODCACHE=$(PWD)/go-mod
all: dae-wing
.PHONY: all
deps: schema-resolver $(DAE_READY)
.PHONY: deps
DAE_READY = dae-core/control/bpf_bpfeb.o
DAE_EBPF_SRC = dae-core/control/kern/tproxy.c
schema-resolver: $(DAE_READY)
@unset GOOS && \
unset GOARCH && \
unset GOARM && \
unset CC && \
go generate ./...
.PHONY: schema-resolver
$(DAE_EBPF_SRC):
@git submodule update --init --recursive dae-core
$(DAE_READY): .gitmodules $(DAE_EBPF_SRC)
cd dae-core && \
make ebpf && \
cd ../ && \
touch $@
dae-wing: deps
go build -o $(OUTPUT) $(BUILD_ARGS) .
.PHONY: dae-wing
bundle: deps
$(call check_defined, WEB_DIST)
@if [ $$(realpath -m "$(WEB_DIST)") != $$(realpath -m "webrender/web") ]; then \
rm -r webrender/web 2>/dev/null; \
cp -r $(WEB_DIST) webrender/web; \
find webrender/web -type f -size +4k ! -name "*.gz" ! -name "*.woff" ! -name "*.woff2" -exec sh -c '\
echo "{}"; \
gzip -9 -k "{}"; \
if [ $$(stat -c %s "{}") \< $$(stat -c %s "{}".gz) ]; then \
rm "{}".gz; \
else \
rm "{}"; \
fi' ';' ; \
fi && \
go build -tags=embedallowed -o $(OUTPUT) -trimpath -ldflags=$(GO_LDFLAGS) .
.PHONY: bundle
fmt:
go fmt ./...
.PHONY: fmt