1
0
forked from MTSR/mapserver

proper version number for builds

This commit is contained in:
NatureFreshMilk 2019-03-29 10:18:23 +01:00
parent 73256aa5fb
commit d112bf4be7
5 changed files with 18 additions and 11 deletions

View File

@ -1,6 +1,7 @@
OUT_DIR=output OUT_DIR=output
MOD_ZIP=$(OUT_DIR)/mapserver-mod.zip MOD_ZIP=$(OUT_DIR)/mapserver-mod.zip
VERSION=git-$(shell git rev-parse HEAD)
all: $(OUT_DIR) $(MOD_ZIP) all: $(OUT_DIR) $(MOD_ZIP)
# build the docker image with all dependencies # build the docker image with all dependencies
@ -11,7 +12,7 @@ all: $(OUT_DIR) $(MOD_ZIP)
-v mapserver-volume:/root/go\ -v mapserver-volume:/root/go\
-w /app\ -w /app\
mapserver-builder\ mapserver-builder\
make test all make test all VERSION=$(VERSION)
# copy generated files to output dir # copy generated files to output dir
cp server/output/* $(OUT_DIR)/ cp server/output/* $(OUT_DIR)/

View File

@ -1,8 +1,13 @@
STATIC_VFS=vfs/static.go STATIC_VFS=vfs/static.go
OUT_DIR=output OUT_DIR=output
ENV=GO111MODULE=on ENV=GO111MODULE=on
VERSION=git-$(shell git rev-parse HEAD)
GO_LDFLAGS=-ldflags "-linkmode external -extldflags -static"
# -ldflags="-X mapserver/app.Version=1.0"
GO_LDFLAGS=-ldflags "-linkmode external -extldflags -static -X mapserver/app.Version=$(VERSION)"
GO_LDFLAGS_WIN=-ldflags "-X mapserver/app.Version=$(VERSION)"
GO_BUILD=CGO_ENABLED=1 go build
BINARIES = $(OUT_DIR)/mapserver-linux-x86_64 BINARIES = $(OUT_DIR)/mapserver-linux-x86_64
BINARIES += $(OUT_DIR)/mapserver-linux-x86 BINARIES += $(OUT_DIR)/mapserver-linux-x86
@ -30,21 +35,21 @@ $(STATIC_VFS):
$(OUT_DIR)/mapserver-linux-x86_64: $(OUT_DIR) $(OUT_DIR)/mapserver-linux-x86_64: $(OUT_DIR)
# native (linux x86_64) # native (linux x86_64)
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 CC=x86_64-linux-gnu-gcc go build $(GO_LDFLAGS) -o $@ GOOS=linux GOARCH=amd64 CC=x86_64-linux-gnu-gcc $(GO_BUILD) $(GO_LDFLAGS) -o $@
$(OUT_DIR)/mapserver-linux-x86: $(OUT_DIR) $(OUT_DIR)/mapserver-linux-x86: $(OUT_DIR)
# apt install gcc-8-i686-linux-gnu # apt install gcc-8-i686-linux-gnu
CGO_ENABLED=1 GOOS=linux GOARCH=386 CC=i686-linux-gnu-gcc-7 go build $(GO_LDFLAGS) -o $@ GOOS=linux GOARCH=386 CC=i686-linux-gnu-gcc-7 $(GO_BUILD) $(GO_LDFLAGS) -o $@
$(OUT_DIR)/mapserver-windows-x86.exe: $(OUT_DIR) $(OUT_DIR)/mapserver-windows-x86.exe: $(OUT_DIR)
# apt install gcc-mingw-w64 # apt install gcc-mingw-w64
GOARCH=386 GOOS=windows CC=i686-w64-mingw32-gcc CGO_ENABLED=1 go build -o $@ GOARCH=386 GOOS=windows CC=i686-w64-mingw32-gcc $(GO_BUILD) $(GO_LDFLAGS_WIN) -o $@
$(OUT_DIR)/mapserver-windows-x86-64.exe: $(OUT_DIR) $(OUT_DIR)/mapserver-windows-x86-64.exe: $(OUT_DIR)
GOARCH=amd64 GOOS=windows CC=x86_64-w64-mingw32-gcc CGO_ENABLED=1 go build -o $@ GOARCH=amd64 GOOS=windows CC=x86_64-w64-mingw32-gcc $(GO_BUILD) $(GO_LDFLAGS_WIN) -o $@
$(OUT_DIR)/mapserver-linux-arm: $(OUT_DIR) $(OUT_DIR)/mapserver-linux-arm: $(OUT_DIR)
# apt install gcc-5-arm-linux-gnueabihf # apt install gcc-5-arm-linux-gnueabihf
GOARCH=arm GOARM=7 CC=arm-linux-gnueabihf-gcc-5 CGO_ENABLED=1 go build $(GO_LDFLAGS) -o $@ GOARCH=arm GOARM=7 CC=arm-linux-gnueabihf-gcc-5 $(GO_BUILD) $(GO_LDFLAGS) -o $@
all: $(STATIC_VFS) $(BINARIES) all: $(STATIC_VFS) $(BINARIES)

View File

@ -13,10 +13,6 @@ import (
"mapserver/tilerenderer" "mapserver/tilerenderer"
) )
const (
Version = "1.0.1"
)
type App struct { type App struct {
Params params.ParamsType Params params.ParamsType
Config *Config Config *Config

3
server/app/version.go Normal file
View File

@ -0,0 +1,3 @@
package app
var Version = "dev"

View File

@ -9,6 +9,7 @@ import (
//Public facing config //Public facing config
type PublicConfig struct { type PublicConfig struct {
Version string `json:"version"`
Layers []*layer.Layer `json:"layers"` Layers []*layer.Layer `json:"layers"`
MapObjects *app.MapObjectConfig `json:"mapobjects"` MapObjects *app.MapObjectConfig `json:"mapobjects"`
} }
@ -23,6 +24,7 @@ func (h *ConfigHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
webcfg := PublicConfig{} webcfg := PublicConfig{}
webcfg.Layers = h.ctx.Config.Layers webcfg.Layers = h.ctx.Config.Layers
webcfg.MapObjects = h.ctx.Config.MapObjects webcfg.MapObjects = h.ctx.Config.MapObjects
webcfg.Version = app.Version
json.NewEncoder(resp).Encode(webcfg) json.NewEncoder(resp).Encode(webcfg)
} }