improve desktop build targets

This commit is contained in:
c9s 2021-02-15 01:54:17 +08:00
parent 0c9ca851e5
commit 93bdb6c3eb
3 changed files with 36 additions and 22 deletions

View File

@ -4,26 +4,49 @@ BIN_DIR := $(BUILD_DIR)/bbgo
DIST_DIR ?= dist DIST_DIR ?= dist
GIT_DESC = $$(git describe --long --tags) GIT_DESC = $$(git describe --long --tags)
all: bbgo 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
all: $(BIN_DIR)
go build -o $(BIN_DIR)/$@ ./cmd/$@
$(BIN_DIR): $(BIN_DIR):
mkdir -p $@ mkdir -p $@
bin-dir: $(BIN_DIR) bbgo.linux: $(BIN_DIR)
bbgo-linux: $(BIN_DIR)
GOOS=linux GOARCH=$(TARGET_ARCH) go build -o $(BIN_DIR)/$@ ./cmd/bbgo GOOS=linux GOARCH=$(TARGET_ARCH) go build -o $(BIN_DIR)/$@ ./cmd/bbgo
bbgo-darwin: bbgo.darwin: $(BIN_DIR)
GOOS=darwin GOARCH=$(TARGET_ARCH) go build -o $(BIN_DIR)/$@ ./cmd/bbgo GOOS=darwin GOARCH=$(TARGET_ARCH) go build -o $(BIN_DIR)/$@ ./cmd/bbgo
bbgo:
go build -o $(BIN_DIR)/$@ ./cmd/$@
clean: clean:
rm -rf $(BUILD_DIR) $(DIST_DIR) rm -rf $(BUILD_DIR) $(DIST_DIR)
dist: bin-dir bbgo-linux bbgo-darwin $(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
go build -o $@ ./cmd/bbgo-desktop
desktop.osx: $(OSX_APP_CONTENTS_DIR)/MacOS/bbgo-desktop $(OSX_APP_CONTENTS_DIR)/Info.plist $(OSX_APP_RESOURCES_DIR)/icon.icns
desktop: desktop.osx
dist: bbgo.linux bbgo.darwin desktop
mkdir -p $(DIST_DIR) mkdir -p $(DIST_DIR)
tar -C $(BUILD_DIR) -cvzf $(DIST_DIR)/bbgo-$$(git describe --tags).tar.gz . tar -C $(BUILD_DIR) -cvzf $(DIST_DIR)/bbgo-$$(git describe --tags).tar.gz .
@ -37,26 +60,18 @@ docker:
docker build --build-arg GO_MOD_CACHE=_mod --tag yoanlin/bbgo . docker build --build-arg GO_MOD_CACHE=_mod --tag yoanlin/bbgo .
bash -c "[[ -n $(DOCKER_TAG) ]] && docker tag yoanlin/bbgo yoanlin/bbgo:$(DOCKER_TAG)" bash -c "[[ -n $(DOCKER_TAG) ]] && docker tag yoanlin/bbgo yoanlin/bbgo:$(DOCKER_TAG)"
docker-push: docker-push:
docker push yoanlin/bbgo docker push yoanlin/bbgo
bash -c "[[ -n $(DOCKER_TAG) ]] && docker push yoanlin/bbgo:$(DOCKER_TAG)" bash -c "[[ -n $(DOCKER_TAG) ]] && docker push yoanlin/bbgo:$(DOCKER_TAG)"
frontend/out/index.html: .FORCE frontend/out/index.html:
(cd frontend && yarn export) (cd frontend && yarn export)
pkged.go: frontend/out/index.html pkged.go: frontend/out/index.html .FORCE
pkger pkger
git commit pkged.go -m "pkger: update bundled static files" git commit pkged.go -m "pkger: update bundled static files"
static: frontend/out/index.html pkged.go static: frontend/out/index.html pkged.go .FORCE
build/BBGO.app/Contents/MacOS/bbgo-desktop: .FORCE
mkdir -p $(dir $@)
go build -o $@ ./cmd/bbgo-desktop
desktop: static build/BBGO.app/Contents/MacOS/bbgo-desktop
# bash desktop/build-darwin.sh
tools: tools:
GO111MODULES=off go get github.com/markbates/pkger/cmd/pkger GO111MODULES=off go get github.com/markbates/pkger/cmd/pkger

View File

@ -2,7 +2,6 @@
APP="BBGO.app" APP="BBGO.app"
APP_DIR=build/$APP APP_DIR=build/$APP
mkdir -p $APP_DIR/Contents/{MacOS,Resources}
go build -o $APP_DIR/Contents/MacOS/bbgo-desktop ./cmd/bbgo-desktop go build -o $APP_DIR/Contents/MacOS/bbgo-desktop ./cmd/bbgo-desktop
cat > $APP_DIR/Contents/Info.plist << EOF cat > $APP_DIR/Contents/Info.plist << EOF

File diff suppressed because one or more lines are too long