2020-11-11 08:34:20 +00:00
|
|
|
TARGET_ARCH ?= amd64
|
|
|
|
BUILD_DIR ?= build
|
|
|
|
BIN_DIR := $(BUILD_DIR)/bbgo
|
|
|
|
DIST_DIR ?= dist
|
2021-03-01 04:17:49 +00:00
|
|
|
GIT_DESC := $$(git describe --tags)
|
2020-11-11 08:34:20 +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 $@
|
|
|
|
|
2021-02-14 18:16:00 +00:00
|
|
|
bbgo-linux: $(BIN_DIR)
|
2021-02-22 07:16:12 +00:00
|
|
|
GOOS=linux GOARCH=$(TARGET_ARCH) go build -tags web,release -o $(BIN_DIR)/$@ ./cmd/bbgo
|
2020-11-11 08:34:20 +00:00
|
|
|
|
2021-02-14 18:16:00 +00:00
|
|
|
bbgo-darwin: $(BIN_DIR)
|
2021-02-22 07:16:12 +00:00
|
|
|
GOOS=darwin GOARCH=$(TARGET_ARCH) go build -tags web,release -o $(BIN_DIR)/$@ ./cmd/bbgo
|
2021-02-15 08:27:38 +00:00
|
|
|
|
2021-03-01 04:07:00 +00:00
|
|
|
bbgo-slim-darwin: $(BIN_DIR)
|
2021-02-22 07:16:12 +00:00
|
|
|
GOOS=darwin GOARCH=$(TARGET_ARCH) go build -tags release -o $(BIN_DIR)/$@ ./cmd/bbgo
|
2020-11-11 08:34:20 +00:00
|
|
|
|
2021-03-01 04:07:00 +00:00
|
|
|
bbgo-slim-linux: $(BIN_DIR)
|
2021-02-22 07:16:12 +00:00
|
|
|
GOOS=linux GOARCH=$(TARGET_ARCH) go build -tags release -o $(BIN_DIR)/$@ ./cmd/bbgo
|
2021-02-15 08:27:38 +00:00
|
|
|
|
2020-11-11 08:34:20 +00:00
|
|
|
clean:
|
2021-02-15 08:21:08 +00:00
|
|
|
rm -rf $(BUILD_DIR) $(DIST_DIR) $(FRONTEND_EXPORT_DIR)
|
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-03-01 04:07:00 +00:00
|
|
|
dist-linux: bbgo-linux bbgo-slim-linux
|
|
|
|
|
|
|
|
dist-darwin: bbgo-darwin bbgo-slim-darwin
|
|
|
|
|
|
|
|
dist: version static migrations bbgo-linux bbgo-slim-linux bbgo-darwin bbgo-slim-darwin desktop
|
2021-03-01 04:17:49 +00:00
|
|
|
mkdir -p $(DIST_DIR)/$(GIT_DESC)
|
|
|
|
for arch in amd64 ; do \
|
|
|
|
for platform in linux darwin ; do \
|
|
|
|
echo $$platform ; \
|
|
|
|
tar -C $(BIN_DIR) -cvzf $(DIST_DIR)/$(GIT_DESC)/bbgo-$(GIT_DESC)-$$platform-$$arch.tar.gz bbgo-$$platform ; \
|
|
|
|
gpg --sign --armor $(DIST_DIR)/$(GIT_DESC)/bbgo-$(GIT_DESC)-$$platform-$$arch.tar.gz ; \
|
|
|
|
tar -C $(BIN_DIR) -cvzf $(DIST_DIR)/$(GIT_DESC)/bbgo-slim-$(GIT_DESC)-$$platform-$$arch.tar.gz bbgo-slim-$$platform ; \
|
|
|
|
gpg --sign --armor $(DIST_DIR)/$(GIT_DESC)/bbgo-slim-$(GIT_DESC)-$$platform-$$arch.tar.gz ; \
|
|
|
|
done ; \
|
2021-03-01 04:07:00 +00:00
|
|
|
done
|
2020-11-11 08:34:20 +00:00
|
|
|
|
2021-02-22 07:16:12 +00:00
|
|
|
pkg/version/version.go: .git/HEAD
|
|
|
|
bash utils/generate-version-file.sh > $@
|
|
|
|
|
|
|
|
version: pkg/version/version.go
|
|
|
|
|
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
|
|
|
|
git add -v pkg/migrations && git commit -m "compile and update migration package" pkg/migrations || true
|
2021-01-15 02:31:37 +00:00
|
|
|
|
2020-12-15 09:53:11 +00:00
|
|
|
docker:
|
2021-01-29 03:19:21 +00:00
|
|
|
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-15 09:53:11 +00:00
|
|
|
|
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)"
|
|
|
|
|
2021-02-14 18:16:00 +00:00
|
|
|
frontend/out/index.html: .FORCE
|
2021-01-29 03:19:21 +00:00
|
|
|
(cd frontend && yarn export)
|
2021-02-04 12:30:51 +00:00
|
|
|
|
2021-02-15 08:21:08 +00:00
|
|
|
pkg/server/assets.go: frontend/out/index.html .FORCE
|
|
|
|
go run ./util/embed -package server -output $@ $(FRONTEND_EXPORT_DIR)
|
2021-01-29 03:19:21 +00:00
|
|
|
|
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
|
2021-01-29 03:19:21 +00:00
|
|
|
|
2021-02-22 07:16:12 +00:00
|
|
|
.PHONY: bbgo version dist migrations static embed desktop .FORCE
|