Skip to content

Commit

Permalink
gogensig: add go mod init conf.Name and go get github.com/goplus/llgo
Browse files Browse the repository at this point in the history
  • Loading branch information
tsingbx committed Oct 21, 2024
1 parent c70f773 commit 731a707
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ _tinygo/
_output/
build.dir/
.vscode/
.devcontainer

*.cfg
*.json

# Test binary, built with `go test -c`
*.test
Expand Down
23 changes: 23 additions & 0 deletions chore/gogensig/gogensig.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package main
import (
"io"
"os"
"os/exec"
"path/filepath"

"github.com/goplus/llgo/chore/gogensig/config"
"github.com/goplus/llgo/chore/gogensig/convert"
Expand All @@ -27,6 +29,23 @@ import (
"github.com/goplus/llgo/chore/gogensig/visitor"
)

func runCommand(dir, cmdName string, args ...string) error {
execCmd := exec.Command(cmdName, args...)
execCmd.Stdout = os.Stdout
execCmd.Stderr = os.Stderr
execCmd.Dir = dir
return execCmd.Run()
}

func runGoCmds(pkg string) {
wd, _ := os.Getwd()
dir := filepath.Join(wd, pkg)
os.MkdirAll(dir, 0744)
os.Chdir(pkg)
runCommand(dir, "go", "mod", "init", pkg)
runCommand(dir, "go", "get", "github.com/goplus/llgo")
}

func main() {
var data []byte
var err error
Expand All @@ -45,9 +64,12 @@ func main() {
data, err = os.ReadFile(sigfetchFile)
}
check(err)

conf, err := config.GetCppgCfgFromPath("./llcppg.cfg")
check(err)

runGoCmds(conf.Name)

astConvert, err := convert.NewAstConvert(&convert.AstConvertConfig{
PkgName: conf.Name,
SymbFile: "./llcppg.symb.json",
Expand All @@ -60,6 +82,7 @@ func main() {
err = p.ProcessFileSet(inputdata)
check(err)
}

func check(err error) {
if err != nil {
panic(err)
Expand Down

0 comments on commit 731a707

Please sign in to comment.