1
0
forked from MTSR/mapserver

use go:generate

This commit is contained in:
NatureFreshMilk 2019-02-01 11:26:57 +01:00
parent 97fb906876
commit 99ef688d16
3 changed files with 12 additions and 16 deletions

View File

@ -18,8 +18,7 @@ clean:
rm -rf $(OUT_DIR)
$(STATIC_VFS):
test -f esc || $(ENV) go get github.com/mjibson/esc
${HOME}/go/bin/esc -o $@ -prefix="static/" -pkg vfs static
go generate
build: $(STATIC_VFS) $(OUT_DIR)
# native

View File

@ -16,7 +16,7 @@ import (
"errors"
)
func Setup(p params.ParamsType, cfg *Config) (*App, error) {
func Setup(p params.ParamsType, cfg *Config) *App {
a := App{}
a.Params = p
a.Config = cfg
@ -32,16 +32,16 @@ func Setup(p params.ParamsType, cfg *Config) (*App, error) {
case worldconfig.BACKEND_SQLITE3:
a.Blockdb, err = db.NewSqliteAccessor("map.sqlite")
if err != nil {
return nil, err
panic(err)
}
default:
return nil, errors.New("map-backend not supported: " + a.Worldconfig.Backend)
panic(errors.New("map-backend not supported: " + a.Worldconfig.Backend))
}
//migrate block db
err = a.Blockdb.Migrate()
if err != nil {
return nil, err
panic(err)
}
//mapblock accessor
@ -51,7 +51,7 @@ func Setup(p params.ParamsType, cfg *Config) (*App, error) {
a.Colormapping = colormapping.NewColorMapping()
err = a.Colormapping.LoadVFSColors(false, "/colors.txt")
if err != nil {
return nil, err
panic(err)
}
//mapblock renderer
@ -67,14 +67,14 @@ func Setup(p params.ParamsType, cfg *Config) (*App, error) {
}
if err != nil {
return nil, err
panic(err)
}
//migrate tile database
err = a.Objectdb.Migrate()
if err != nil {
return nil, err
panic(err)
}
//setup tile renderer
@ -85,5 +85,5 @@ func Setup(p params.ParamsType, cfg *Config) (*App, error) {
a.Config.Layers,
)
return &a, nil
return &a
}

View File

@ -11,6 +11,8 @@ import (
"runtime"
)
//go:generate -command go run github.com/mjibson/esc -o vfs/static.go -prefix="static/" -pkg vfs static
func main() {
//Parse command line
@ -50,12 +52,7 @@ func main() {
}
//setup app context
ctx, err := app.Setup(p, cfg)
if err != nil {
//error case
panic(err)
}
ctx := app.Setup(p, cfg)
//Set up mapobject events
mapobject.Setup(ctx)