parent
10cf601ea0
commit
dc356e9d0f
14
Makefile
14
Makefile
|
@ -1,12 +1,11 @@
|
|||
VERSION = $(shell git describe --tags)
|
||||
BUILDTIME = $(shell date +%Y.%m.%d)
|
||||
|
||||
run: clean build
|
||||
make -C testautogen/ all
|
||||
make -C testSort/
|
||||
run: build
|
||||
|
||||
test:
|
||||
./autogenpb --dry-run --proto test.proto --lobase gitTag --upbase GitTag --sort "ByPath,Refname"
|
||||
test: build
|
||||
@# make -C testautogen/ all
|
||||
cd testautogen; pwd; ../autogenpb --proto test.proto
|
||||
|
||||
vet:
|
||||
@GO111MODULE=off go vet
|
||||
|
@ -22,7 +21,6 @@ install:
|
|||
|
||||
goimports:
|
||||
goimports -w *.go
|
||||
make -C testSort/ goimports
|
||||
|
||||
redomod:
|
||||
rm -f go.*
|
||||
|
@ -35,6 +33,6 @@ reset:
|
|||
reset
|
||||
|
||||
clean:
|
||||
-rm -f go.*
|
||||
-rm -f autogenpb
|
||||
make -C testautogen/ clean
|
||||
make -C testSort/ clean
|
||||
@#make -C testautogen/ clean
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package main
|
||||
|
||||
// eh, screw it, just add the damned mutex to the pb.go file
|
||||
// will this help things?
|
||||
// this is a hack for testing for now
|
||||
// cram a mutex in the pb.go file
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
|
15
main.go
15
main.go
|
@ -1,4 +1,6 @@
|
|||
//go:build go1.20
|
||||
// +build go1.20
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
|
@ -7,6 +9,7 @@ import (
|
|||
|
||||
"github.com/alexflint/go-arg"
|
||||
"go.wit.com/lib/gui/shell"
|
||||
"go.wit.com/lib/protobuf/forgepb"
|
||||
"go.wit.com/log"
|
||||
"golang.org/x/text/cases"
|
||||
"golang.org/x/text/language"
|
||||
|
@ -17,6 +20,7 @@ var VERSION string
|
|||
var BUILDTIME string
|
||||
|
||||
var sortmap map[string]string
|
||||
var forge *forgepb.Forge // forgepb figures out how to run protoc correctly if it's needed
|
||||
|
||||
func main() {
|
||||
pp := arg.MustParse(&argv)
|
||||
|
@ -48,7 +52,6 @@ func main() {
|
|||
if !shell.Exists("go.sum") {
|
||||
shell.Run([]string{"go", "mod", "init"})
|
||||
shell.Run([]string{"go", "mod", "tidy"})
|
||||
shell.Run([]string{"go", "mod", "edit", "-go=1.20"})
|
||||
}
|
||||
|
||||
cmd := []string{"go", "list", "-f", "'{{.Name}}'"}
|
||||
|
@ -86,6 +89,16 @@ func main() {
|
|||
os.Exit(0)
|
||||
}
|
||||
|
||||
sortmap["protoc"] = protobase + ".pb.go"
|
||||
if !shell.Exists(sortmap["protoc"]) {
|
||||
if err := protocBuild(sortmap); err != nil {
|
||||
log.Info("protoc build error:", err)
|
||||
os.Exit(-1)
|
||||
}
|
||||
os.Exit(0)
|
||||
}
|
||||
os.Exit(0)
|
||||
|
||||
// add mutex
|
||||
if err := addMutex(sortmap); err == nil {
|
||||
log.Info("adding mutex to existing protoc-gen-go file worked")
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
package main
|
||||
|
||||
// auto run protoc with the correct args
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
|
||||
"go.wit.com/lib/gui/shell"
|
||||
"go.wit.com/lib/protobuf/forgepb"
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
// test.pb.go: test.proto
|
||||
// cd ~/go/src && protoc --go_out=. --proto_path=go.wit.com/apps/autogenpb/testautogen \
|
||||
// --go_opt=Mtest.proto=go.wit.com/apps/autogenpb/testautogen \
|
||||
// test.proto
|
||||
|
||||
// forgeConfig.pb.go: forgeConfig.proto
|
||||
// cd ~/go/src && protoc --go_out=. --proto_path=go.wit.com/apps/autogenpb/testautogen \
|
||||
// --go_opt=MforgeConfig.proto=go.wit.com/apps/autogenpb/testautogen \
|
||||
// forgeConfig.proto
|
||||
|
||||
func protocBuild(names map[string]string) error {
|
||||
// have to figure out how to run protoc so initialize forge
|
||||
forge = forgepb.Init()
|
||||
// forge.ConfigPrintTable()
|
||||
os.Setenv("REPO_WORK_PATH", forge.GetGoSrc())
|
||||
|
||||
log.Info("")
|
||||
if shell.Exists(names["protoc"]) {
|
||||
log.Info("protoc file already created", names["protoc"])
|
||||
return nil
|
||||
}
|
||||
log.Info("make protoc file:", names["protoc"])
|
||||
log.Info("go src", forge.GetGoSrc())
|
||||
return errors.New("make protoc here")
|
||||
}
|
||||
/*
|
||||
data, err := os.ReadFile(fullname)
|
||||
if err != nil {
|
||||
// log.Info("open config file :", err)
|
||||
return err
|
||||
}
|
||||
|
||||
w, _ := os.OpenFile(names["protobase"]+".pb.go", os.O_WRONLY|os.O_CREATE, 0600)
|
||||
|
||||
var found bool
|
||||
|
||||
lines := strings.Split(string(data), "\n")
|
||||
for _, line := range lines {
|
||||
// log.Info("line:", line)
|
||||
start := "type " + names["Bases"] + " struct {"
|
||||
if strings.HasSuffix(line, start) {
|
||||
found = true
|
||||
log.Info("FOUND line:", line)
|
||||
fmt.Fprintln(w, line)
|
||||
fmt.Fprintln(w, "\tsync.RWMutex // auto-added by go.wit.com/apps/autogenpb")
|
||||
fmt.Fprintln(w, "")
|
||||
} else {
|
||||
fmt.Fprintln(w, line)
|
||||
}
|
||||
}
|
||||
// os.Exit(-1)
|
||||
if found {
|
||||
return nil
|
||||
}
|
||||
*/
|
2
sort.go
2
sort.go
|
@ -8,7 +8,7 @@ import (
|
|||
)
|
||||
|
||||
func makeSortfile() {
|
||||
f, _ := os.OpenFile(sortmap["protobase"] + ".sort.pb.go", os.O_WRONLY|os.O_CREATE, 0600)
|
||||
f, _ := os.OpenFile(sortmap["protobase"]+".sort.pb.go", os.O_WRONLY|os.O_CREATE, 0600)
|
||||
|
||||
header(f, sortmap)
|
||||
syncLock(f, sortmap)
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
VERSION = $(shell git describe --tags)
|
||||
BUILDTIME = $(shell date +%Y.%m.%d)
|
||||
|
||||
run: clean build
|
||||
./testSort
|
||||
|
||||
vet:
|
||||
@GO111MODULE=off go vet
|
||||
@echo this go library package builds okay
|
||||
|
||||
build:
|
||||
GO111MODULE=off go build \
|
||||
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
||||
|
||||
install:
|
||||
GO111MODULE=off go install \
|
||||
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
||||
|
||||
goimports:
|
||||
goimports -w *.go
|
||||
# // to globally reset paths:
|
||||
# // gofmt -w -r "go.wit.com/gui -> go.wit.com/gui/gui" .
|
||||
|
||||
redomod:
|
||||
rm -f go.*
|
||||
GO111MODULE= go mod init
|
||||
GO111MODULE= go mod tidy
|
||||
|
||||
reset:
|
||||
# clear your terminal
|
||||
reset
|
||||
|
||||
clean:
|
||||
-rm -f *.pb.go testSort
|
|
@ -1,37 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
// "go.wit.com/apps/autogenpb/testautogen"
|
||||
)
|
||||
|
||||
func main() {
|
||||
log.Println("empty because go mod tidy failed")
|
||||
log.Println("why does go mod tidy fail when this is here?")
|
||||
// go: go.wit.com/apps/autogenpb/testSort imports
|
||||
// go.wit.com/apps/autogenpb/testautogen: cannot find module providing package go.wit.com/apps/autogenpb/testautogen: unrecognized import path "go.wit.com/apps/autogenpb/testautogen": parse https://go.wit.com/apps/autogenpb/testautogen?go-get=1: no go-import meta tags ()
|
||||
|
||||
/*
|
||||
all := new(testautogen.GitTags)
|
||||
// newt := new(testautogen.GitTag)
|
||||
|
||||
new1 := testautogen.GitTag{
|
||||
Refname: "master",
|
||||
Objectname: "blah",
|
||||
}
|
||||
all.Append(&new1)
|
||||
|
||||
new2 := testautogen.GitTag{
|
||||
Refname: "devel",
|
||||
Objectname: "j23jljalse",
|
||||
}
|
||||
all.Append(&new2)
|
||||
|
||||
loop := all.SortByPath()
|
||||
for loop.Scan() {
|
||||
t := loop.Next()
|
||||
log.Println("hello testSort t.Refname =", t.Refname, t.Objectname)
|
||||
}
|
||||
*/
|
||||
}
|
Loading…
Reference in New Issue