Makefile Love and Windows Bugfixes

* Fixed a bad filepath separator check that failed on Windows.
* Disable ANSI colors in logger for Windows console.
This commit is contained in:
Noah 2019-06-27 20:24:13 -07:00
parent 35a89e5dbe
commit 54776ec9e1
4 changed files with 23 additions and 4 deletions

View File

@ -22,7 +22,12 @@ cp /usr/share/fonts/dejavu/{DejaVuSans.ttf,DejaVuSans-Bold.ttf,DejaVuSansMono.tt
Makefile commands for Linux: Makefile commands for Linux:
* `make setup`: install Go dependencies and set up the build environment * `make setup`: install Go dependencies and set up the build environment
* `make doodads`: build the default Doodads from sources in `dev-assets/`
* `make bindata`: embed the default doodads, levels and other assets into the
Go program. `make bindata-dev` for lightweight dev versions that will read
from the filesystem at runtime instead.
* `make build`: build the Doodle and Doodad binaries to the `bin/` folder. * `make build`: build the Doodle and Doodad binaries to the `bin/` folder.
* `make buildall`: runs all build steps: doodads, bindata, build.
* `make build-free`: build the shareware binaries to the `bin/` folder. See * `make build-free`: build the shareware binaries to the `bin/` folder. See
Build Tags below. Build Tags below.
* `make build-debug`: build a debug binary (not release-mode) to the `bin/` * `make build-debug`: build a debug binary (not release-mode) to the `bin/`

View File

@ -11,6 +11,7 @@ LDFLAGS := -ldflags "-X main.Build=$(BUILD) -X main.BuildDate=$(BUILD_DATE)"
# `make setup` to set up a new environment, pull dependencies, etc. # `make setup` to set up a new environment, pull dependencies, etc.
.PHONY: setup .PHONY: setup
setup: clean setup: clean
go get -u github.com/go-bindata/go-bindata/...
go get ./... go get ./...
# `make build` to build the binary. # `make build` to build the binary.
@ -20,6 +21,10 @@ build:
go build $(LDFLAGS) -i -o bin/doodle cmd/doodle/main.go go build $(LDFLAGS) -i -o bin/doodle cmd/doodle/main.go
go build $(LDFLAGS) -i -o bin/doodad cmd/doodad/main.go go build $(LDFLAGS) -i -o bin/doodad cmd/doodad/main.go
# `make buildall` to run all build steps including doodads and bindata.
.PHONY: buildall
buildall: doodads bindata build
# `make build-free` to build the binary in free mode. # `make build-free` to build the binary in free mode.
.PHONY: build-free .PHONY: build-free
build-free: build-free:
@ -67,7 +72,7 @@ doodads:
# `make mingw` to cross-compile a Windows binary with mingw. # `make mingw` to cross-compile a Windows binary with mingw.
.PHONY: mingw .PHONY: mingw
mingw: mingw: doodads bindata
env CGO_ENABLED="1" CC="/usr/bin/x86_64-w64-mingw32-gcc" \ env CGO_ENABLED="1" CC="/usr/bin/x86_64-w64-mingw32-gcc" \
GOOS="windows" CGO_LDFLAGS="-lmingw32 -lSDL2" CGO_CFLAGS="-D_REENTRANT" \ GOOS="windows" CGO_LDFLAGS="-lmingw32 -lSDL2" CGO_CFLAGS="-D_REENTRANT" \
go build $(LDFLAGS) -i -o bin/doodle.exe cmd/doodle/main.go go build $(LDFLAGS) -i -o bin/doodle.exe cmd/doodle/main.go
@ -94,7 +99,7 @@ test:
# `make dist` builds and tars up a release. # `make dist` builds and tars up a release.
.PHONY: dist .PHONY: dist
dist: build dist: doodads bindata build
mkdir -p dist/doodle-$(VERSION) mkdir -p dist/doodle-$(VERSION)
cp bin/* dist/doodle-$(VERSION)/ cp bin/* dist/doodle-$(VERSION)/
cp -r assets fonts README.md dist/doodle-$(VERSION)/ cp -r assets fonts README.md dist/doodle-$(VERSION)/

View File

@ -1,6 +1,10 @@
package log package log
import "github.com/kirsle/golog" import (
"runtime"
"github.com/kirsle/golog"
)
// Logger is the public golog.Logger object. // Logger is the public golog.Logger object.
var Logger *golog.Logger var Logger *golog.Logger
@ -13,6 +17,11 @@ func init() {
Colors: golog.ExtendedColor, Colors: golog.ExtendedColor,
TimeFormat: "2006-01-02 15:04:05.000000", TimeFormat: "2006-01-02 15:04:05.000000",
}) })
// TODO: Disable ANSI colors in logs on Windows.
if runtime.GOOS == "windows" {
Logger.Config.Colors = golog.NoColor
}
} }
// Debug logger function. // Debug logger function.

View File

@ -123,7 +123,7 @@ func ListLevels() ([]string, error) {
// resolvePath is the inner logic for LevelPath and DoodadPath. // resolvePath is the inner logic for LevelPath and DoodadPath.
func resolvePath(directory, filename, extension string) string { func resolvePath(directory, filename, extension string) string {
if strings.Contains(filename, "/") { if strings.Contains(filename, string(filepath.Separator)) {
return filename return filename
} }