Repos / gorts / ffc1fbef84
commit ffc1fbef8406f420848af673e85eb177aa34f170
Author: Nhân <hi@imnhan.com>
Date: Wed Jun 21 23:43:27 2023 +0700
stop embedding tcl script into go binary
diff --git a/Makefile b/Makefile
index 31971fd..9bc32b6 100644
--- a/Makefile
+++ b/Makefile
@@ -1,12 +1,18 @@
windows:
CGO_ENABLED=0 GOOS=windows \
go build -o dist/windows/gorts.exe -ldflags -H=windowsgui
+ rm -rf dist/windows/web
cp -r web dist/windows/web
+ rm -rf dist/windows/tcl
+ cp -r tcl dist/windows/tcl
cp players.sample.csv dist/windows/
linux:
CGO_ENABLED=0 GOOS=linux go build -o dist/linux/gorts
+ rm -rf dist/linux/web
cp -r web dist/linux/web
+ rm -rf dist/linux/tcl
+ cp -r tcl dist/linux/tcl
cp players.sample.csv dist/linux/
dist/GORTS-Windows.zip: windows
diff --git a/main.go b/main.go
index 2dd7465..6ee2a7b 100644
--- a/main.go
+++ b/main.go
@@ -26,9 +26,6 @@
const PlayersFile = "players.csv"
const StartggFile = "creds-start.gg"
-//go:embed tcl/main.tcl
-var mainTcl string
-
//go:embed gorts.png
var gortsPngIcon []byte
@@ -54,7 +51,7 @@ func startGUI() {
tclPath = "./tclkit.exe"
}
- cmd := exec.Command(tclPath)
+ cmd := exec.Command(tclPath, "-encoding", "utf-8")
stdout, err := cmd.StdoutPipe()
if err != nil {
panic(err)
@@ -83,7 +80,7 @@ func startGUI() {
}
}()
- fmt.Fprintln(stdin, mainTcl)
+ fmt.Fprintln(stdin, `source -encoding "utf-8" tcl/main.tcl`)
println("Loaded main tcl script.")
allplayers := players.FromFile(PlayersFile)
diff --git a/tcl/main.tcl b/tcl/main.tcl
index 9944ef1..87935b1 100644
--- a/tcl/main.tcl
+++ b/tcl/main.tcl
@@ -8,7 +8,7 @@ foreach p {stdin stdout stderr} {
fconfigure $p -translation lf
}
-source tcl/netstring.tcl
+source -encoding "utf-8" tcl/netstring.tcl
package require Tk