mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-21 22:43:52 +00:00
fix build tags
This commit is contained in:
parent
1e3de95be4
commit
8224447985
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -18,6 +18,7 @@
|
||||||
# Dependency directories (remove the comment below to include it)
|
# Dependency directories (remove the comment below to include it)
|
||||||
# vendor/
|
# vendor/
|
||||||
/.mod
|
/.mod
|
||||||
|
/_mod
|
||||||
|
|
||||||
/.env.local
|
/.env.local
|
||||||
/.env.*.local
|
/.env.*.local
|
||||||
|
@ -30,4 +31,4 @@
|
||||||
|
|
||||||
/config/bbgo.yaml
|
/config/bbgo.yaml
|
||||||
|
|
||||||
/.mod
|
/pkg/server/assets.go
|
||||||
|
|
25
Makefile
25
Makefile
|
@ -9,6 +9,8 @@ OSX_APP_DIR = build/$(OSX_APP_NAME)
|
||||||
OSX_APP_CONTENTS_DIR = $(OSX_APP_DIR)/Contents
|
OSX_APP_CONTENTS_DIR = $(OSX_APP_DIR)/Contents
|
||||||
OSX_APP_RESOURCES_DIR = $(OSX_APP_CONTENTS_DIR)/Resources
|
OSX_APP_RESOURCES_DIR = $(OSX_APP_CONTENTS_DIR)/Resources
|
||||||
|
|
||||||
|
FRONTEND_EXPORT_DIR = frontend/out
|
||||||
|
|
||||||
all: $(BIN_DIR)
|
all: $(BIN_DIR)
|
||||||
go build -o $(BIN_DIR)/$@ ./cmd/$@
|
go build -o $(BIN_DIR)/$@ ./cmd/$@
|
||||||
|
|
||||||
|
@ -22,7 +24,7 @@ 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
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(BUILD_DIR) $(DIST_DIR)
|
rm -rf $(BUILD_DIR) $(DIST_DIR) $(FRONTEND_EXPORT_DIR)
|
||||||
|
|
||||||
$(OSX_APP_CONTENTS_DIR):
|
$(OSX_APP_CONTENTS_DIR):
|
||||||
mkdir -p $@
|
mkdir -p $@
|
||||||
|
@ -40,11 +42,11 @@ $(OSX_APP_CONTENTS_DIR)/Info.plist: $(OSX_APP_CONTENTS_DIR)
|
||||||
bash desktop/build-osx-info-plist.sh > $@
|
bash desktop/build-osx-info-plist.sh > $@
|
||||||
|
|
||||||
$(OSX_APP_CONTENTS_DIR)/MacOS/bbgo-desktop: $(OSX_APP_CONTENTS_DIR)/MacOS .FORCE
|
$(OSX_APP_CONTENTS_DIR)/MacOS/bbgo-desktop: $(OSX_APP_CONTENTS_DIR)/MacOS .FORCE
|
||||||
go build -o $@ ./cmd/bbgo-desktop
|
go build -tags web -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-osx: $(OSX_APP_CONTENTS_DIR)/MacOS/bbgo-desktop $(OSX_APP_CONTENTS_DIR)/Info.plist $(OSX_APP_RESOURCES_DIR)/icon.icns
|
||||||
|
|
||||||
desktop: desktop.osx
|
desktop: desktop-osx
|
||||||
|
|
||||||
dist: static bbgo-linux bbgo-darwin desktop
|
dist: static bbgo-linux bbgo-darwin desktop
|
||||||
mkdir -p $(DIST_DIR)
|
mkdir -p $(DIST_DIR)
|
||||||
|
@ -67,13 +69,14 @@ docker-push:
|
||||||
frontend/out/index.html: .FORCE
|
frontend/out/index.html: .FORCE
|
||||||
(cd frontend && yarn export)
|
(cd frontend && yarn export)
|
||||||
|
|
||||||
pkged.go: frontend/out/index.html .FORCE
|
pkg/server/assets.go: frontend/out/index.html .FORCE
|
||||||
pkger
|
go run ./util/embed -package server -output $@ $(FRONTEND_EXPORT_DIR)
|
||||||
git commit pkged.go -m "pkger: update bundled static files"
|
gofmt -w pkg/server/assets.go
|
||||||
|
git add -v $@
|
||||||
|
git commit $@ -m "assets: update embedded static files"
|
||||||
|
|
||||||
static: frontend/out/index.html pkged.go
|
embed: pkg/server/assets.go
|
||||||
|
|
||||||
tools:
|
static: frontend/out/index.html pkg/server/assets.go
|
||||||
GO111MODULES=off go get github.com/markbates/pkger/cmd/pkger
|
|
||||||
|
|
||||||
.PHONY: bbgo dist migrations static desktop .FORCE
|
.PHONY: bbgo dist migrations static embed desktop .FORCE
|
||||||
|
|
1
go.mod
1
go.mod
|
@ -28,7 +28,6 @@ require (
|
||||||
github.com/lestrrat-go/file-rotatelogs v2.2.0+incompatible
|
github.com/lestrrat-go/file-rotatelogs v2.2.0+incompatible
|
||||||
github.com/lestrrat-go/strftime v1.0.0 // indirect
|
github.com/lestrrat-go/strftime v1.0.0 // indirect
|
||||||
github.com/magiconair/properties v1.8.4 // indirect
|
github.com/magiconair/properties v1.8.4 // indirect
|
||||||
github.com/markbates/pkger v0.17.1
|
|
||||||
github.com/mattn/go-colorable v0.1.2 // indirect
|
github.com/mattn/go-colorable v0.1.2 // indirect
|
||||||
github.com/mattn/go-sqlite3 v2.0.3+incompatible // indirect
|
github.com/mattn/go-sqlite3 v2.0.3+incompatible // indirect
|
||||||
github.com/mitchellh/mapstructure v1.4.1 // indirect
|
github.com/mitchellh/mapstructure v1.4.1 // indirect
|
||||||
|
|
5
go.sum
5
go.sum
|
@ -104,8 +104,6 @@ github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/me
|
||||||
github.com/go-test/deep v1.0.4/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
|
github.com/go-test/deep v1.0.4/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
|
||||||
github.com/go-test/deep v1.0.6 h1:UHSEyLZUwX9Qoi99vVwvewiMC8mM2bf7XEM2nqvzEn8=
|
github.com/go-test/deep v1.0.6 h1:UHSEyLZUwX9Qoi99vVwvewiMC8mM2bf7XEM2nqvzEn8=
|
||||||
github.com/go-test/deep v1.0.6/go.mod h1:QV8Hv/iy04NyLBxAdO9njL0iVPN1S4d/A3NVv1V36o8=
|
github.com/go-test/deep v1.0.6/go.mod h1:QV8Hv/iy04NyLBxAdO9njL0iVPN1S4d/A3NVv1V36o8=
|
||||||
github.com/gobuffalo/here v0.6.0 h1:hYrd0a6gDmWxBM4TnrGw8mQg24iSVoIkHEk7FodQcBI=
|
|
||||||
github.com/gobuffalo/here v0.6.0/go.mod h1:wAG085dHOYqUpf+Ap+WOdrPTp5IYcDAs/x7PLa8Y5fM=
|
|
||||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||||
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
||||||
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY=
|
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY=
|
||||||
|
@ -229,8 +227,6 @@ github.com/lib/pq v1.9.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||||
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||||
github.com/magiconair/properties v1.8.4 h1:8KGKTcQQGm0Kv7vEbKFErAoAOFyyacLStRtQSeYtvkY=
|
github.com/magiconair/properties v1.8.4 h1:8KGKTcQQGm0Kv7vEbKFErAoAOFyyacLStRtQSeYtvkY=
|
||||||
github.com/magiconair/properties v1.8.4/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
|
github.com/magiconair/properties v1.8.4/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
|
||||||
github.com/markbates/pkger v0.17.1 h1:/MKEtWqtc0mZvu9OinB9UzVN9iYCwLWuyUv4Bw+PCno=
|
|
||||||
github.com/markbates/pkger v0.17.1/go.mod h1:0JoVlrol20BSywW79rN3kdFFsE5xYM+rSCQDXbLhiuI=
|
|
||||||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||||
github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU=
|
github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU=
|
||||||
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||||
|
@ -565,7 +561,6 @@ gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bl
|
||||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|
||||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||||
|
|
22
pkg/server/asset_fs.go
Normal file
22
pkg/server/asset_fs.go
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
// +build web
|
||||||
|
|
||||||
|
package server
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (s *Server) assetsHandler(c *gin.Context) {
|
||||||
|
// redirect to .html page if the page exists
|
||||||
|
if pageRoutePattern.MatchString(c.Request.URL.Path) {
|
||||||
|
_, err := FS.Open(c.Request.URL.Path + ".html")
|
||||||
|
if err == nil {
|
||||||
|
c.Request.URL.Path += ".html"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fs := http.FileServer(FS)
|
||||||
|
fs.ServeHTTP(c.Writer, c.Request)
|
||||||
|
}
|
9
pkg/server/assets_dummy.go
Normal file
9
pkg/server/assets_dummy.go
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
// +build !web
|
||||||
|
|
||||||
|
package server
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (s *Server) assetsHandler(c *gin.Context) {}
|
|
@ -1,23 +0,0 @@
|
||||||
package server
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
"github.com/markbates/pkger"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (s *Server) pkgerHandler(c *gin.Context) {
|
|
||||||
fs := pkger.Dir("/frontend/out")
|
|
||||||
|
|
||||||
// redirect to .html page if the page exists
|
|
||||||
if pageRoutePattern.MatchString(c.Request.URL.Path) {
|
|
||||||
|
|
||||||
_, err := pkger.Stat("/frontend/out/" + c.Request.URL.Path + ".html")
|
|
||||||
if err == nil {
|
|
||||||
c.Request.URL.Path += ".html"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
http.FileServer(fs).ServeHTTP(c.Writer, c.Request)
|
|
||||||
}
|
|
|
@ -214,8 +214,7 @@ func (s *Server) newEngine() *gin.Engine {
|
||||||
})
|
})
|
||||||
|
|
||||||
r.GET("/api/strategies/single", s.listStrategies)
|
r.GET("/api/strategies/single", s.listStrategies)
|
||||||
r.NoRoute(s.pkgerHandler)
|
r.NoRoute(s.assetsHandler)
|
||||||
|
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user