update to also embed toolkit plugins in the binary

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-11-07 13:30:17 -06:00
parent bc01313a04
commit 161f3934ce
7 changed files with 77 additions and 24 deletions

14
.gitignore vendored
View File

@ -1,5 +1,9 @@
*
!.gitignore
!Makefile
!*.go
!LICENSE
*.swp
go.mod
go.sum
/files/*
/*.deb
/resources/*
gadgetwindow

View File

@ -1,5 +1,19 @@
VERSION = $(shell git describe --tags)
all: build
reset
./gadgetwindow
build:
-rm -f gadgetwindow
-rm resources/*.so
touch resources/blank.so
-cp -a ~/go/src/go.wit.com/toolkits/*.so resources/ # embed the toolkit plugins in the binary
GO111MODULE=off go build -v -x \
-ldflags "-X main.VERSION=${VERSION}"
install:
GO111MODULE=off go install -v -x \
-ldflags "-X main.VERSION=${VERSION}"
./gadgetwindow
nocui: build
@ -18,17 +32,6 @@ debugger: build
reset
./gadgetwindow --debugger
build:
ifeq ($(GO111MODULE),)
@echo
@echo In GO, to build here you must export GO111MODULE=off
@echo
@false
else
-rm -f gadgetwindow
go build -v -x
endif
goimports:
goimports -w *.go

6
README.md Normal file
View File

@ -0,0 +1,6 @@
# gadgetwindow
This simple 'gui' demo also embedds the plugins into the binary
## Install go-glone
go build go.wit.com/apps/gadgetwindow@latest

38
argv.go Normal file
View File

@ -0,0 +1,38 @@
package main
import (
"os"
"github.com/alexflint/go-arg"
)
/*
this parses the command line arguements
this enables command line options from other packages like 'gui' and 'log'
*/
var argv args
type args struct {
Demo string `arg:"positional" help:"this is just a demo"`
}
func (a args) Description() string {
return `
This basicwindow example demonstrates multiple windows
`
}
func init() {
pp := arg.MustParse(&argv)
// for very new users or users unfamilar with the command line, this may help them
if argv.Demo == "version" || argv.Demo == "help" || argv.Demo == "?" {
pp.WriteHelp(os.Stdout)
os.Exit(0)
}
}
func (args) Version() string {
return "basicwindow " + VERSION
}

View File

@ -5,17 +5,11 @@ package main
*/
import (
"go.wit.com/dev/alexflint/arg"
"go.wit.com/lib/debugger"
"go.wit.com/log"
)
var args struct {
}
func init() {
arg.MustParse(&args)
if debugger.ArgDebug() {
log.Info("cmd line --debugger == true")
go func() {

10
main.go
View File

@ -1,7 +1,8 @@
// This creates a simple hello world window
package main
import (
"embed"
"go.wit.com/gui"
"go.wit.com/lib/debugger"
"go.wit.com/lib/gadgets"
@ -9,9 +10,15 @@ import (
"go.wit.com/log"
)
// sent via -ldflags
var VERSION string
// This is the beginning of the binary tree of widgets
var myGui *gui.Node
//go:embed resources/*
var resources embed.FS
// this is the primary window. If you close it, the program will exit
var mainWindow *gui.Node
@ -28,6 +35,7 @@ func main() {
log.ShowFlags()
}
myGui = gui.New()
myGui.InitEmbed(resources)
myGui.Default()
helloworld()

0
resources/blank.so Normal file
View File