12 files changed, 49 insertions(+), 47 deletions(-)
M .build.yml
M Makefile
M README.md
M cmd/vendortclkit/main.go
M main.go
R tk/{scripts/choose-action.tcl => choose-action.tcl}
M tk/tk.go
D tk/tk_linux.go
D tk/tk_windows.go
D tk/vendored/tclkit-linux-amd64
R tk/vendored/README.md => vendored/tclkit/README.md
R tk/vendored/tclkit-windows-amd64.exe => vendored/tclkit/tclkit.exe
M .build.yml => .build.yml +2 -2
@@ 11,13 11,13 @@ tasks:
curl -L 'https://go.dev/dl/go1.19.3.linux-amd64.tar.gz' > go.tar.gz
tar -xf go.tar.gz && rm go.tar.gz
cd bloghead
- PATH=$PATH:~/go/bin make linux
+ PATH=$PATH:~/go/bin make dist-linux
cd dist
zip -r bloghead-linux.zip linux
- make-windows: |
cd bloghead
- PATH=$PATH:~/go/bin make windows
+ PATH=$PATH:~/go/bin make dist-windows
cd dist
zip -r bloghead-windows.zip windows
M Makefile => Makefile +14 -13
@@ 1,19 1,8 @@
-.PHONY : build linux windows run watch watch-build init-db clean watch-tk
+.PHONY : build dist-linux dist-windows run watch watch-build init-db clean watch-tk
build:
go build -o dist/
-linux:
- CGO_ENABLED=1 GOOS=linux go build -o dist/linux/bloghead
- cp vendored/djot.lua dist/linux/djot.lua
-
-windows:
- CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc GOOS=windows \
- go build -o dist/windows/bloghead.exe -ldflags -H=windowsgui
- cp vendored/lua-5.4.2_Win64_bin/lua54.dll dist/windows/lua54.dll
- cp vendored/lua-5.4.2_Win64_bin/wlua54.exe dist/windows/wlua54.exe
- cp vendored/djot.lua dist/windows/djot.lua
-
run:
go build -o dist/ && ./dist/bloghead
@@ 28,13 17,25 @@ watch-build:
watch-tk:
find . -name '*.tcl' | entr -rc -s \
- "tclsh tk/scripts/choose-action.tcl"
+ "tclsh tk/choose-action.tcl"
init-db:
rm -f Site1.bloghead
sqlite3 Site1.bloghead < models/schema.sql
go run ./cmd/seed
+dist-linux:
+ CGO_ENABLED=1 GOOS=linux go build -o dist/linux/bloghead
+ cp vendored/djot.lua dist/linux/djot.lua
+
+dist-windows:
+ CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc GOOS=windows \
+ go build -o dist/windows/bloghead.exe -ldflags -H=windowsgui
+ cp vendored/lua-5.4.2_Win64_bin/lua54.dll dist/windows/
+ cp vendored/lua-5.4.2_Win64_bin/wlua54.exe dist/windows/
+ cp vendored/djot.lua dist/windows/
+ cp vendored/tclkit/tclkit.exe dist/windows/
+
clean:
rm -rf dist/* www *.bloghead bloghead bloghead.exe vendordjot seed
M README.md => README.md +9 -0
@@ 24,6 24,7 @@ Current dev dependencies:
- [go](https://go.dev/)
- [lua](https://www.lua.org/): to run the djot-to-html script
+- [tcl/tk](https://archlinux.org/packages/extra/x86_64/tk/): for startup dialog/filepicker
- (optional) [entr](https://eradman.com/entrproject/): for `make watch`
- (optional) [mingw-w64](https://archlinux.org/groups/x86_64/mingw-w64/): to
cross-compile from Linux to Windows.
@@ 38,6 39,14 @@ ln -s "$PWD/vendored/djot.lua" /usr/bin/djot.lua # or anywhere in your $PATH
make watch
```
+Runtime dependencies:
+
+- For Windows: everything is included in the zip. Just extract and run `bloghead.exe`.
+- For Linux: `bloghead` assumes these executables are available from your $PATH:
+ + `tclsh` - must include `tk` too.
+ + `lua`
+ + `djot.lua` - this is included in the zip, just put it somewhere in your $PATH.
+
Things are especially messy right now. Proper desktop-friendly distribution
will be done once core features are in place.
M cmd/vendortclkit/main.go => cmd/vendortclkit/main.go +2 -2
@@ 19,12 19,12 @@ type remoteFile struct {
var remoteFiles = map[string]remoteFile{
"linux": {
url: "https://tclkits.rkeene.org/fossil/raw/tclkit-8.6.3-rhel5-x86_64?name=36b5cb68899cfcb79417a29f9c6d8176ebae0d24",
- destPath: "tk/vendored/tclkit-linux-amd64",
+ destPath: "vendored/tclkit/tclkit-linux-amd64",
sha256sum: "dba225a4a3e1c2bfbae68d98b95f564fe14619eda83d1903116465a047bb2ca0",
},
"windows": {
url: "https://tclkits.rkeene.org/fossil/raw/tclkit-8.6.3-win32-x86_64.exe?name=403c507437d0b10035c7839f22f5bb806ec1f491",
- destPath: "tk/vendored/tclkit-windows-amd64.exe",
+ destPath: "vendored/tclkit/tclkit.exe",
sha256sum: "5292399891398ce13af0e32fa98dab02e6f0134ea9738515649d7e649eff0942",
},
}
M main.go => main.go +0 -2
@@ 820,8 820,6 @@ func main() {
// If bloghead was called without a filename argument, open a
// tk window letting user choose between opening and creating a site.
if Paths.InputFile == "" {
- tk.EnsureTclBin()
-
action, filePath := tk.ChooseAction()
println("Action:", action, filePath)
R tk/scripts/choose-action.tcl => tk/choose-action.tcl +0 -0
M tk/tk.go => tk/tk.go +20 -10
@@ 1,18 1,32 @@
-// Must run CreateTclBin() before doing anything with this package.
package tk
import (
_ "embed"
"io"
"log"
+ "os"
"os/exec"
+ "path/filepath"
"runtime"
"strings"
-
- "go.imnhan.com/bloghead/common"
)
-var tmpTclPath string
+var tclPath string
+
+func init() {
+ if runtime.GOOS == "windows" {
+ executablePath, err := os.Executable()
+ if err != nil {
+ panic(err)
+ }
+
+ dir := filepath.Dir(executablePath)
+ tclPath = filepath.Join(dir, "tclkit.exe")
+ return
+ }
+
+ tclPath = "tclsh"
+}
type Action string
@@ 37,7 51,7 @@ func stringToAction(s string) Action {
}
}
-//go:embed scripts/choose-action.tcl
+//go:embed choose-action.tcl
var chooseActionScript string
// Shows a window asking user to create new or open existing .bloghead file.
@@ 62,7 76,7 @@ func ChooseAction() (action Action, filePath string) {
// Executes tcl script, returns stdout
func execTcl(script string) string {
- cmd := exec.Command(tmpTclPath)
+ cmd := exec.Command(tclPath)
stdin, err := cmd.StdinPipe()
if err != nil {
@@ 90,7 104,3 @@ func execTcl(script string) string {
return strings.TrimSpace(string(out))
}
-
-func EnsureTclBin() {
- tmpTclPath = common.EnsureExecutable(tclbin, "tcl")
-}
D tk/tk_linux.go => tk/tk_linux.go +0 -8
@@ 1,8 0,0 @@
-//go:build linux
-
-package tk
-
-import _ "embed"
-
-//go:embed vendored/tclkit-linux-amd64
-var tclbin []byte
D tk/tk_windows.go => tk/tk_windows.go +0 -8
@@ 1,8 0,0 @@
-//go:build windows
-
-package tk
-
-import _ "embed"
-
-//go:embed vendored/tclkit-windows-amd64.exe
-var tclbin []byte
D tk/vendored/tclkit-linux-amd64 => tk/vendored/tclkit-linux-amd64 +0 -0
R tk/vendored/README.md => vendored/tclkit/README.md +2 -2
@@ 1,5 1,5 @@
-Tclkit binaries generated from <https://kitcreator.rkeene.org/kitcreator>,
-including only `Tk` option.
+Tclkit binaries downloaded from
+<https://tclkits.rkeene.org/fossil/wiki/Downloads>
# License
R tk/vendored/tclkit-windows-amd64.exe => vendored/tclkit/tclkit.exe +0 -0