-
-
Notifications
You must be signed in to change notification settings - Fork 225
/
Makefile
65 lines (55 loc) · 3.15 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
all: release
build: build_platypus
install_dependency:
sudo apt update
# Nodejs
node --version || (curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash && bash -c "source ${HOME}/.nvm/nvm.sh && nvm install 14.19.0 && npm install -g yarn")
# Golang
axel --version || sudo apt install -y axel
unar --version || sudo apt install -y unar
git --version || sudo apt install -y git
go-bindata --version || sudo apt install -y go-bindata
go version || (sudo axel https://go.dev/dl/go1.17.7.linux-amd64.tar.gz && sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.17.7.linux-amd64.tar.gz)
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct
# upx
sudo apt install -y upx
prepare:
bash -c "[[ -d termites ]] || mkdir termites"
bash -c "[[ -d build ]] || mkdir build"
build_frontend: prepare
echo "Building frontend"
cd web/frontend && bash -c "source ${HOME}/.nvm/nvm.sh && yarn install && NODE_OPTIONS='--max-old-space-size=1024' yarn build"
echo "Building ttyd"
cd web/ttyd && bash -c "source ${HOME}/.nvm/nvm.sh && yarn install && NODE_OPTIONS='--max-old-space-size=1024' yarn build"
build_termite: prepare
echo "Building termite"
# echo -e "Building termite_linux_amd64"
env GOOS=linux GOARCH=amd64 go build -ldflags="-s -w " -trimpath -o ./build/termite/termite_linux_amd64 cmd/termite/main.go
# echo -e "Building termite_linux_arm"
env GOOS=linux GOARCH=arm GOARM=5 go build -ldflags="-s -w " -trimpath -o ./build/termite/termite_linux_arm cmd/termite/main.go
collect_assets: build_frontend build_termite
echo "Collecting assets files"
go-bindata -pkg assets -o ./internal/util/assets/assets.go ./assets/config.example.yml ./assets/template/rsh/... ./web/ttyd/dist/... ./web/frontend/build/... ./build/termite/...
dev:
env GOOS=linux GOARCH=amd64 go build -ldflags="-s -w " -trimpath -o ./build/termite/termite_linux_amd64 cmd/termite/main.go
go-bindata -pkg assets -o ./internal/util/assets/assets.go ./assets/config.example.yml ./assets/template/rsh/... ./web/ttyd/dist/... ./web/frontend/build/... ./build/termite/...
go build -ldflags="-s -w " -trimpath -o ./build/platypus/platypus cmd/platypus/main.go
build_platypus: collect_assets
echo "Building platypus"
go build -ldflags="-s -w " -trimpath -o ./build/platypus/platypus cmd/platypus/main.go
release: install_dependency collect_assets
# Linux
env GOOS=linux GOARCH=amd64 go build -ldflags="-s -w " -trimpath -o ./build/platypus/platypus_linux_amd64 cmd/platypus/main.go
env GOOS=linux GOARCH=arm64 go build -ldflags="-s -w " -trimpath -o ./build/platypus/platypus_linux_arm64 cmd/platypus/main.go
# MacOS
env GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w " -trimpath -o ./build/platypus/platypus_darwin_amd64 cmd/platypus/main.go
env GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w " -trimpath -o ./build/platypus/platypus_darwin_arm64 cmd/platypus/main.go
# Windows
env GOOS=windows GOARCH=amd64 go build -ldflags="-s -w " -trimpath -o ./build/platypus/platypus_windows_amd64.exe cmd/platypus/main.go
find build -type f -executable | xargs upx
clean:
rm -rf build
rm -rf internal/util/assets/assets.go
rm -rf web/frontend/build
rm -rf web/ttyd/build