lestnica_dvizh/Magefile.go
2024-06-29 00:59:17 +03:00

91 строка
1,6 КиБ
Go

//go:build mage
// +build mage
package main
import (
// mage:import
. "magefile/docker"
//. "magefile/docker/lib"
"github.com/magefile/mage/mg"
)
var (
GolangVolume = "golang.upstream"
MyGoImageName = "my/go"
GoPathVol = "/gopath"
GoCacheVol = "/gopath/gocache"
GoPathMount = "-v " + GoPathVol + ":/gopath:rw"
GoCacheMount = "-v " + GoCacheVol + ":/home/user/.cache/go-build:rw"
GolangMount = "-v " + GolangVolume + ":/usr/local/go:ro"
GoAll = GolangMount + ` \
` + GoPathMount + ` \
` + GoCacheMount + ` \
-e GOPATH=/gopath`
)
func init() {
AppName = "app"
ImageName = "my/qtbase.dev"
NetName = "none"
BuildFn = build
}
func Test() {
mg.Deps(TestLib)
}
func TestLib() error {
return Bash(`sudo docker run -ti --rm \
-h host \
--name=` + AppName + `.test.lib \
--net=` + NetName + ` \
-v /etc/localtime:/etc/localtime:ro \
\
` + GoAll + ` \
\
-v ${PWD}:/app \
\
-w /app/lib \
\
` + MyGoImageName + " " +
`test -gcflags=-l`)
}
func ArduinoListCores() {
Bash(`arduino-cli core list`)
}
func build() {
Generate()
BuildOnly()
}
func WatchAndGenerate() {
Bash(`reflex -g 'pkg/app/main.go' \
-- sh -c 'go-tr pkg/app/main.go \
| uncrustify -q -l CPP > main.go.h' \
`)
}
func Generate() {
Bash(` \
( : \
&& go-tr pkg/app/main.go \
) | uncrustify -q -l CPP > main.go.h \
&& cat main.go.h \
&& echo \
&& echo --------------------------------------- \
&& echo \
`)
}
func BuildOnly() {
Bash(`arduino-cli compile --fqbn esp32:esp32:esp32 .`)
}
func Upload() {
Bash(`arduino-cli upload -p /dev/ttyUSB0 --fqbn esp32:esp32:esp32 .`)
}