Добавлен Magefile
Этот коммит содержится в:
родитель
f89c87170d
коммит
7bf9010674
1 изменённых файлов: 91 добавлений и 0 удалений
91
Magefile.go
Обычный файл
91
Magefile.go
Обычный файл
|
@ -0,0 +1,91 @@
|
||||||
|
//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 .`)
|
||||||
|
}
|
Загрузка…
Создание таблицы
Сослаться в новой задаче