Compare commits
3 Commits
ad7c149baf
...
a139b87d58
Author | SHA1 | Date | |
---|---|---|---|
a139b87d58 | |||
093cef549c | |||
b68107b74a |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
.vscode/launch.json
|
.vscode/launch.json
|
||||||
|
|
||||||
cmd/tins2020/*rice-box.*
|
cmd/tins2020/*rice-box.*
|
||||||
|
scripts/build
|
||||||
|
37
cmd/tins2020/extract.go
Normal file
37
cmd/tins2020/extract.go
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
rice "github.com/GeertJohan/go.rice"
|
||||||
|
)
|
||||||
|
|
||||||
|
func copyFile(path string, file *rice.File) error {
|
||||||
|
dir := filepath.Dir(path)
|
||||||
|
os.MkdirAll(dir, 0777)
|
||||||
|
dst, err := os.Create(path)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer dst.Close()
|
||||||
|
_, err = io.Copy(dst, file)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func copyBoxToDisk(box *rice.Box) error {
|
||||||
|
return box.Walk("", func(path string, info os.FileInfo, err error) error {
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if info.IsDir() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
src, err := box.Open(path)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return copyFile(filepath.Join(box.Name(), path), src)
|
||||||
|
})
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"flag"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
rice "github.com/GeertJohan/go.rice"
|
rice "github.com/GeertJohan/go.rice"
|
||||||
@ -26,6 +27,20 @@ func logSDLVersion() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func run() error {
|
func run() error {
|
||||||
|
var extract bool
|
||||||
|
flag.BoolVar(&extract, "extract-resources", false, "extracts all resources to the current working directory")
|
||||||
|
flag.Parse()
|
||||||
|
|
||||||
|
ctx, err := tins2020.NewContext(rice.MustFindBox("res"))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer ctx.Destroy()
|
||||||
|
|
||||||
|
if extract {
|
||||||
|
return copyBoxToDisk(ctx.Resources.Box())
|
||||||
|
}
|
||||||
|
|
||||||
if err := sdl.Init(sdl.INIT_EVERYTHING); err != nil {
|
if err := sdl.Init(sdl.INIT_EVERYTHING); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -38,12 +53,6 @@ func run() error {
|
|||||||
}
|
}
|
||||||
defer ttf.Quit()
|
defer ttf.Quit()
|
||||||
|
|
||||||
ctx, err := tins2020.NewContext(rice.MustFindBox("res"))
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer ctx.Destroy()
|
|
||||||
|
|
||||||
if ctx.Settings.Window.Location == nil {
|
if ctx.Settings.Window.Location == nil {
|
||||||
ctx.Settings.Window.Location = tins2020.PtPtr(sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED)
|
ctx.Settings.Window.Location = tins2020.PtPtr(sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED)
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,10 @@ type Resources struct {
|
|||||||
copy vfs.CopyDir
|
copy vfs.CopyDir
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *Resources) Box() *rice.Box {
|
||||||
|
return r.box
|
||||||
|
}
|
||||||
|
|
||||||
func (r *Resources) Destroy() {
|
func (r *Resources) Destroy() {
|
||||||
r.copy.Destroy()
|
r.copy.Destroy()
|
||||||
}
|
}
|
||||||
|
39
scripts/release.sh
Executable file
39
scripts/release.sh
Executable file
@ -0,0 +1,39 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ -z "$1" ]
|
||||||
|
then
|
||||||
|
version="0.0.0"
|
||||||
|
else
|
||||||
|
version="$1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Creating ${version} release"
|
||||||
|
|
||||||
|
rm -rf build/linux*
|
||||||
|
rm -rf build/windows*
|
||||||
|
|
||||||
|
mkdir -p build/linux
|
||||||
|
mkdir -p build/windows
|
||||||
|
|
||||||
|
go generate ../cmd/tins2020
|
||||||
|
|
||||||
|
go build -tags static -ldflags "-s -w" -o build/linux/botanim ../cmd/tins2020
|
||||||
|
cp ../README.md build/linux
|
||||||
|
|
||||||
|
CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc GOOS=windows GOARCH=amd64 go build -tags static -ldflags "-s -w" -o build/windows/botanim.exe ../cmd/tins2020
|
||||||
|
cp ../README.md build/windows
|
||||||
|
|
||||||
|
|
||||||
|
mkdir -p build/release
|
||||||
|
|
||||||
|
cd build
|
||||||
|
|
||||||
|
cd linux
|
||||||
|
zip -9 -q ../release/botanim_${version}_linux_amd64.zip *
|
||||||
|
echo "Created Linux release: build/release/botanim_${version}_linux_amd64.zip"
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
cd windows
|
||||||
|
zip -9 -q ../release/botanim_${version}_windows_amd64.zip *
|
||||||
|
echo "Created Windows release: build/release/botanim_${version}_windows_amd64.zip"
|
||||||
|
cd ..
|
Loading…
Reference in New Issue
Block a user