bbgo_origin/Makefile

264 lines
8.9 KiB
Makefile
Raw Permalink Normal View History

2020-11-11 08:34:20 +00:00
TARGET_ARCH ?= amd64
BUILD_DIR ?= build
BIN_DIR := $(BUILD_DIR)/bbgo
DIST_DIR ?= dist
2021-05-07 10:15:00 +00:00
GIT_DESC := $(shell git describe --tags)
2020-11-11 08:34:20 +00:00
2021-05-07 10:15:00 +00:00
VERSION ?= $(shell git describe --tags)
2021-05-07 06:10:22 +00:00
2021-02-14 17:54:17 +00:00
OSX_APP_NAME = BBGO.app
OSX_APP_DIR = build/$(OSX_APP_NAME)
OSX_APP_CONTENTS_DIR = $(OSX_APP_DIR)/Contents
OSX_APP_RESOURCES_DIR = $(OSX_APP_CONTENTS_DIR)/Resources
2021-02-17 11:06:35 +00:00
OSX_APP_CODESIGN_IDENTITY ?=
2021-02-18 07:32:41 +00:00
# OSX_APP_GUI ?= lorca
OSX_APP_GUI ?= webview
2021-02-17 09:54:26 +00:00
2021-02-15 08:21:08 +00:00
FRONTEND_EXPORT_DIR = frontend/out
2021-02-19 02:18:03 +00:00
all: bbgo-linux bbgo-darwin
2021-02-15 08:25:49 +00:00
2020-11-11 08:34:20 +00:00
$(BIN_DIR):
mkdir -p $@
# build native bbgo
bbgo: static
2021-12-08 09:33:47 +00:00
go build -tags web,release -o $(BIN_DIR)/bbgo ./cmd/bbgo
# build native bbgo (slim version)
bbgo-slim:
go build -tags release -o $(BIN_DIR)/$@ ./cmd/bbgo
# build cross-compile linux bbgo
2021-05-07 11:22:02 +00:00
bbgo-linux: bbgo-linux-amd64 bbgo-linux-arm64
2021-05-07 09:58:28 +00:00
2021-05-07 11:22:02 +00:00
bbgo-linux-amd64: $(BIN_DIR) pkg/server/assets.go
2021-05-07 09:58:28 +00:00
GOOS=linux GOARCH=amd64 go build -tags web,release -o $(BIN_DIR)/$@ ./cmd/bbgo
2021-05-07 11:22:02 +00:00
bbgo-linux-arm64: $(BIN_DIR) pkg/server/assets.go
2021-05-07 09:58:28 +00:00
GOOS=linux GOARCH=arm64 go build -tags web,release -o $(BIN_DIR)/$@ ./cmd/bbgo
2020-11-11 08:34:20 +00:00
# build cross-compile linux bbgo (slim version)
bbgo-slim-linux: bbgo-slim-linux-amd64 bbgo-slim-linux-arm64
bbgo-slim-linux-amd64: $(BIN_DIR)
GOOS=linux GOARCH=amd64 go build -tags release -o $(BIN_DIR)/$@ ./cmd/bbgo
bbgo-slim-linux-arm64: $(BIN_DIR)
GOOS=linux GOARCH=arm64 go build -tags release -o $(BIN_DIR)/$@ ./cmd/bbgo
bbgo-darwin: bbgo-darwin-arm64 bbgo-darwin-amd64
2021-05-07 11:22:02 +00:00
bbgo-darwin-arm64: $(BIN_DIR) pkg/server/assets.go
GOOS=darwin GOARCH=arm64 go build -tags web,release -o $(BIN_DIR)/$@ ./cmd/bbgo
2021-05-07 11:22:02 +00:00
bbgo-darwin-amd64: $(BIN_DIR) pkg/server/assets.go
GOOS=darwin GOARCH=amd64 go build -tags web,release -o $(BIN_DIR)/$@ ./cmd/bbgo
bbgo-slim-darwin-arm64: $(BIN_DIR)
GOOS=darwin GOARCH=arm64 go build -tags release -o $(BIN_DIR)/$@ ./cmd/bbgo
bbgo-slim-darwin-amd64: $(BIN_DIR)
GOOS=darwin GOARCH=amd64 go build -tags release -o $(BIN_DIR)/$@ ./cmd/bbgo
bbgo-slim-darwin: bbgo-slim-darwin-amd64 bbgo-slim-darwin-arm64
2020-11-11 08:34:20 +00:00
# build native bbgo
bbgo-dnum: static
go build -tags web,release,dnum -o $(BIN_DIR)/bbgo ./cmd/bbgo
# build native bbgo (slim version)
bbgo-slim-dnum:
go build -tags release,dnum -o $(BIN_DIR)/$@ ./cmd/bbgo
# build cross-compile linux bbgo
bbgo-dnum-linux: bbgo-dnum-linux-amd64 bbgo-dnum-linux-arm64
bbgo-dnum-linux-amd64: $(BIN_DIR) pkg/server/assets.go
GOOS=linux GOARCH=amd64 go build -tags web,release,dnum -o $(BIN_DIR)/$@ ./cmd/bbgo
bbgo-dnum-linux-arm64: $(BIN_DIR) pkg/server/assets.go
GOOS=linux GOARCH=arm64 go build -tags web,release,dnum -o $(BIN_DIR)/$@ ./cmd/bbgo
# build cross-compile linux bbgo (slim version)
bbgo-slim-dnum-linux: bbgo-slim-dnum-linux-amd64 bbgo-slim-dnum-linux-arm64
bbgo-slim-dnum-linux-amd64: $(BIN_DIR)
GOOS=linux GOARCH=amd64 go build -tags release,dnum -o $(BIN_DIR)/$@ ./cmd/bbgo
bbgo-slim-dnum-linux-arm64: $(BIN_DIR)
GOOS=linux GOARCH=arm64 go build -tags release,dnum -o $(BIN_DIR)/$@ ./cmd/bbgo
bbgo-dnum-darwin: bbgo-dnum-darwin-arm64 bbgo-dnum-darwin-amd64
bbgo-dnum-darwin-arm64: $(BIN_DIR) pkg/server/assets.go
GOOS=darwin GOARCH=arm64 go build -tags web,release,dnum -o $(BIN_DIR)/$@ ./cmd/bbgo
bbgo-dnum-darwin-amd64: $(BIN_DIR) pkg/server/assets.go
GOOS=darwin GOARCH=amd64 go build -tags web,release,dnum -o $(BIN_DIR)/$@ ./cmd/bbgo
bbgo-slim-dnum-darwin-arm64: $(BIN_DIR)
GOOS=darwin GOARCH=arm64 go build -tags release,dnum -o $(BIN_DIR)/$@ ./cmd/bbgo
bbgo-slim-dnum-darwin-amd64: $(BIN_DIR)
GOOS=darwin GOARCH=amd64 go build -tags release,dnum -o $(BIN_DIR)/$@ ./cmd/bbgo
bbgo-slim-dnum-darwin: bbgo-slim-dnum-darwin-amd64 bbgo-slim-dnum-darwin-arm64
2021-02-15 08:27:38 +00:00
2020-11-11 08:34:20 +00:00
2021-02-14 17:54:17 +00:00
$(OSX_APP_CONTENTS_DIR):
mkdir -p $@
$(OSX_APP_CONTENTS_DIR)/MacOS: $(OSX_APP_CONTENTS_DIR)
mkdir -p $@
$(OSX_APP_RESOURCES_DIR): $(OSX_APP_CONTENTS_DIR)
mkdir -p $@
$(OSX_APP_RESOURCES_DIR)/icon.icns: $(OSX_APP_RESOURCES_DIR)
cp -v desktop/icons/icon.icns $@
$(OSX_APP_CONTENTS_DIR)/Info.plist: $(OSX_APP_CONTENTS_DIR)
bash desktop/build-osx-info-plist.sh > $@
$(OSX_APP_CONTENTS_DIR)/MacOS/bbgo-desktop: $(OSX_APP_CONTENTS_DIR)/MacOS .FORCE
2021-02-18 00:51:15 +00:00
go build -tags web -o $@ ./cmd/bbgo-$(OSX_APP_GUI)
2021-02-14 17:54:17 +00:00
2021-02-15 08:21:08 +00:00
desktop-osx: $(OSX_APP_CONTENTS_DIR)/MacOS/bbgo-desktop $(OSX_APP_CONTENTS_DIR)/Info.plist $(OSX_APP_RESOURCES_DIR)/icon.icns
2021-02-18 07:32:41 +00:00
if [[ -n "$(OSX_APP_CODESIGN_IDENTITY)" ]] ; then codesign --deep --force --verbose --sign "$(OSX_APP_CODESIGN_IDENTITY)" $(OSX_APP_DIR) \
&& codesign --verify -vvvv $(OSX_APP_DIR) ; fi
2021-02-14 17:54:17 +00:00
2021-02-15 08:21:08 +00:00
desktop: desktop-osx
2021-02-14 17:54:17 +00:00
2021-05-07 10:15:00 +00:00
$(DIST_DIR)/$(VERSION):
mkdir -p $(DIST_DIR)/$(VERSION)
2021-03-01 04:07:00 +00:00
$(DIST_DIR)/$(VERSION)/bbgo-slim-$(VERSION)-%.tar.gz: bbgo-slim-% $(DIST_DIR)/$(VERSION)
tar -C $(BIN_DIR) -cvzf $@ $<
ifeq ($(SIGN),1)
gpg --yes --detach-sign --armor $@
endif
$(DIST_DIR)/$(VERSION)/bbgo-$(VERSION)-%.tar.gz: bbgo-% $(DIST_DIR)/$(VERSION)
tar -C $(BIN_DIR) -cvzf $@ $<
2021-05-07 11:16:02 +00:00
ifeq ($(SIGN),1)
2021-05-07 10:49:36 +00:00
gpg --yes --detach-sign --armor $@
2021-05-07 11:16:02 +00:00
endif
2021-05-07 10:15:00 +00:00
$(DIST_DIR)/$(VERSION)/bbgo-slim-dnum-$(VERSION)-%.tar.gz: bbgo-slim-dnum-% $(DIST_DIR)/$(VERSION)
tar -C $(BIN_DIR) -cvzf $@ $<
ifeq ($(SIGN),1)
gpg --yes --detach-sign --armor $@
endif
$(DIST_DIR)/$(VERSION)/bbgo-dnum-$(VERSION)-%.tar.gz: bbgo-dnum-% $(DIST_DIR)/$(VERSION)
tar -C $(BIN_DIR) -cvzf $@ $<
ifeq ($(SIGN),1)
gpg --yes --detach-sign --armor $@
endif
2021-05-07 17:16:36 +00:00
dist-bbgo-linux: \
$(DIST_DIR)/$(VERSION)/bbgo-$(VERSION)-linux-arm64.tar.gz \
$(DIST_DIR)/$(VERSION)/bbgo-$(VERSION)-linux-amd64.tar.gz \
$(DIST_DIR)/$(VERSION)/bbgo-slim-$(VERSION)-linux-arm64.tar.gz \
$(DIST_DIR)/$(VERSION)/bbgo-slim-$(VERSION)-linux-amd64.tar.gz \
$(DIST_DIR)/$(VERSION)/bbgo-dnum-$(VERSION)-linux-arm64.tar.gz \
$(DIST_DIR)/$(VERSION)/bbgo-dnum-$(VERSION)-linux-amd64.tar.gz \
$(DIST_DIR)/$(VERSION)/bbgo-slim-dnum-$(VERSION)-linux-arm64.tar.gz \
$(DIST_DIR)/$(VERSION)/bbgo-slim-dnum-$(VERSION)-linux-amd64.tar.gz
2021-05-07 17:16:36 +00:00
dist-bbgo-darwin: \
$(DIST_DIR)/$(VERSION)/bbgo-$(VERSION)-darwin-arm64.tar.gz \
$(DIST_DIR)/$(VERSION)/bbgo-$(VERSION)-darwin-amd64.tar.gz \
$(DIST_DIR)/$(VERSION)/bbgo-slim-$(VERSION)-darwin-arm64.tar.gz \
$(DIST_DIR)/$(VERSION)/bbgo-slim-$(VERSION)-darwin-amd64.tar.gz \
$(DIST_DIR)/$(VERSION)/bbgo-dnum-$(VERSION)-darwin-arm64.tar.gz \
$(DIST_DIR)/$(VERSION)/bbgo-dnum-$(VERSION)-darwin-amd64.tar.gz \
$(DIST_DIR)/$(VERSION)/bbgo-slim-dnum-$(VERSION)-darwin-arm64.tar.gz \
$(DIST_DIR)/$(VERSION)/bbgo-slim-dnum-$(VERSION)-darwin-amd64.tar.gz
2021-05-07 11:22:02 +00:00
dist: static dist-bbgo-linux dist-bbgo-darwin desktop
2021-05-07 06:44:42 +00:00
2021-03-21 02:16:27 +00:00
pkg/version/version.go: .FORCE
2021-12-27 15:10:29 +00:00
BUILD_FLAGS="release" bash utils/generate-version-file.sh > $@
2021-02-22 07:16:12 +00:00
pkg/version/dev.go: .FORCE
2021-12-27 15:10:29 +00:00
BUILD_FLAGS="!release" VERSION_SUFFIX="-dev" bash utils/generate-version-file.sh > $@
dev-version: pkg/version/dev.go
2022-03-15 13:54:18 +00:00
git add $<
2021-12-27 15:10:29 +00:00
git commit $< -m "update dev build version"
cmd-doc: .FORCE
go run ./cmd/update-doc
git add -v doc/commands
2022-03-15 13:54:18 +00:00
git commit -m "update command doc files" doc/commands || true
version: pkg/version/version.go pkg/version/dev.go migrations cmd-doc
2022-03-15 13:54:18 +00:00
git add $< $(word 2,$^)
git commit $< $(word 2,$^) -m "bump version to $(VERSION)" || true
2021-12-07 08:16:34 +00:00
[[ -e doc/release/$(VERSION).md ]] || (echo "file doc/release/$(VERSION).md does not exist" ; exit 1)
git add -v doc/release/$(VERSION).md && git commit doc/release/$(VERSION).md -m "add $(VERSION) release note" || true
2021-05-07 06:10:22 +00:00
git tag -f $(VERSION)
git push origin HEAD
2021-12-30 08:17:02 +00:00
git push -f origin $(VERSION)
2021-02-22 07:16:12 +00:00
2021-01-15 02:31:37 +00:00
migrations:
2021-02-06 01:51:11 +00:00
rockhopper compile --config rockhopper_mysql.yaml --output pkg/migrations/mysql
rockhopper compile --config rockhopper_sqlite.yaml --output pkg/migrations/sqlite3
2021-12-07 08:10:49 +00:00
git add -v pkg/migrations && git commit -m "compile and update migration package" pkg/migrations || true
2021-01-15 02:31:37 +00:00
docker:
GOPATH=$(PWD)/_mod go mod download
docker build --build-arg GO_MOD_CACHE=_mod --tag yoanlin/bbgo .
2020-12-17 08:19:31 +00:00
bash -c "[[ -n $(DOCKER_TAG) ]] && docker tag yoanlin/bbgo yoanlin/bbgo:$(DOCKER_TAG)"
2020-12-17 08:32:16 +00:00
docker-push:
docker push yoanlin/bbgo
bash -c "[[ -n $(DOCKER_TAG) ]] && docker push yoanlin/bbgo:$(DOCKER_TAG)"
frontend/node_modules:
2021-12-08 11:43:05 +00:00
cd frontend && yarn install
frontend/out/index.html: frontend/node_modules
2021-12-08 11:43:05 +00:00
cd frontend && yarn export
2021-02-04 12:30:51 +00:00
2021-05-07 11:22:02 +00:00
pkg/server/assets.go: frontend/out/index.html
2021-02-15 08:21:08 +00:00
go run ./util/embed -package server -output $@ $(FRONTEND_EXPORT_DIR)
2021-02-15 08:21:08 +00:00
embed: pkg/server/assets.go
2021-02-04 10:22:47 +00:00
2021-02-15 08:21:08 +00:00
static: frontend/out/index.html pkg/server/assets.go
2022-02-18 06:22:05 +00:00
PROTOS := \
$(wildcard pkg/pb/*.proto)
GRPC_GO_DEPS := $(subst .proto,.pb.go,$(PROTOS))
%.pb.go: %.proto .FORCE
2022-04-08 09:34:26 +00:00
protoc --go-grpc_out=. --go-grpc_opt=paths=source_relative --go_out=paths=source_relative:. --proto_path=. $<
2022-04-07 11:28:05 +00:00
grpc-go: $(GRPC_GO_DEPS)
grpc: grpc-go grpc-py
2022-03-07 03:59:02 +00:00
install-grpc-tools:
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.26
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.1
pip install grpcio-tools
grpc-py:
python -m grpc_tools.protoc -I$(PWD)/pkg/pb \
--python_out=$(PWD)/python/bbgo \
--grpc_python_out=$(PWD)/python/bbgo \
$(PWD)/pkg/pb/bbgo.proto
2022-04-08 09:34:26 +00:00
clean:
rm -rf $(BUILD_DIR) $(DIST_DIR) $(FRONTEND_EXPORT_DIR) $(GRPC_GO_DEPS) pkg/pb/*.pb.go
2022-04-07 11:28:05 +00:00
.PHONY: bbgo bbgo-slim-darwin bbgo-slim-darwin-amd64 bbgo-slim-darwin-arm64 bbgo-darwin version dist pack migrations static embed desktop grpc grpc-go grpc-py .FORCE