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) rm -rf $(OUT_DIR)
$(STATIC_VFS): $(STATIC_VFS):
test -f esc || $(ENV) go get github.com/mjibson/esc go generate
${HOME}/go/bin/esc -o $@ -prefix="static/" -pkg vfs static
build: $(STATIC_VFS) $(OUT_DIR) build: $(STATIC_VFS) $(OUT_DIR)
# native # native

View File

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

View File

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