Commit b311322e authored by Hugo Moreau's avatar Hugo Moreau

boilerplate: new tool displaying list of variables

For a simplier use of go2pins, a new user tool has been created in order
to help.
For now it can display list of variable names.

* boilerplate/Makefile,
  boilerplate/main.go: Here.
parent 3c571258
Pipeline #14669 passed with stage
in 1 minute
......@@ -11,7 +11,10 @@ ifneq ($(UNAME_S),Darwin)
LD_AFTER=-Wl,--no-whole-archive
endif
all: main.dve2C
all: main.dve2C main
main:
go build -o main *.go
main.dve2C: libgo2pins.a
go build -o $@ -buildmode=c-shared
......@@ -20,4 +23,4 @@ libgo2pins.a: go2pins.o
$(AR) cru $@ $^
clean:
$(RM) main.dve2C main.a main.h go2pins.o
$(RM) main.dve2C main.a main.h go2pins.o main
......@@ -7,6 +7,9 @@ package {{.PackageName}}
*/
import "C"
import (
"flag"
"fmt"
"os"
"unsafe"
)
......@@ -115,5 +118,29 @@ func get_state_variable_type_value(tC C.int, vC C.int) *C.char {
return unknownTypeValueName
}
var (
display = flag.Bool("displaylist", false, "Display the list of variable names.")
help = flag.Bool("help", false, "Show usages.")
)
func init() {
flag.Usage = func() {
fmt.Fprintln(os.Stderr, "Usage: "+os.Args[0]+" [options]\n")
flag.PrintDefaults()
}
}
func main() {
flag.Parse()
if len(os.Args) == 1 || *help {
flag.Usage()
os.Exit(1)
}
if *display {
fmt.Println("State size:", G2PStateSize)
fmt.Println("List of variable names:")
for i := 0; i < G2PStateSize; i++ {
fmt.Println(" - " + C.GoString(G2PVariableNames[i]))
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment