Commit 1869a859 authored by Hugo Moreau's avatar Hugo Moreau
Browse files

Go2Pins can be invoked everywhere

 * boilerplate/Makefile,
   main.go, tools/blackbox.go : Here.
parent 380f320f
Pipeline #27075 passed with stage
in 2 minutes and 14 seconds
......@@ -29,14 +29,17 @@ endif
all: main.dve2C main
main:
main: go.mod
env CGO_LDFLAGS=-no-pie go build -o go2pins-mc *.go
main.dve2C: libgo2pins.a
main.dve2C: libgo2pins.a go.mod
go build -o $@ -buildmode=c-shared
libgo2pins.a: go2pins.o
$(AR) cru $@ $^
go.mod:
go mod init {{.Output}}
clean:
$(RM) main.dve2C main.a main.h go2pins.o main
......@@ -420,6 +420,7 @@ func duplicateGoroutines(filepath string) (string, []*cspinfo.Goroutine) {
type packageTemplate struct {
PackagePath string
PackageName string
Output string
}
var toIgnore []string
......@@ -472,6 +473,7 @@ func main() {
basePackagePath := path.Base(relPackagePath)
// Check whether the output/ directory already exists.
*output = path.Clean(*output)
if _, err := os.Stat(*output); err == nil {
if !*forceOverwrite {
fmt.Fprintln(os.Stderr, *output+" already exists")
......@@ -571,7 +573,7 @@ func main() {
"go2pins.h",
"main.go",
}
data := packageTemplate{basePackagePath, packageName}
data := packageTemplate{basePackagePath, packageName, *output}
for _, filename := range boilerplateFiles {
from := path.Join(go2pinsDir, "boilerplate/"+filename)
to := path.Join(*output, filename)
......
......@@ -25,7 +25,7 @@ import (
"go/printer"
"go/token"
"log"
"os"
"path"
"strconv"
"strings"
)
......@@ -53,31 +53,7 @@ func RewriteBlackbox(inputfile string, funs []string, outputdir string) (string,
var newOrig []ast.Decl // Keep only function that should not be BB
var toBB []ast.Decl // Keep all other functions
//--------------------------------------------------------------------
// FIXME For now blackboxes are only supported in the go2pins
// repository We should investigate a more elegant solution
// that takes in account GOPATH, etc. Looking to goyacc and
// go generate (https://blog.golang.org/generate) seems
// promising.
dirname, _ := os.Getwd()
idx := strings.Index(dirname, "go2pins") // FIXME if multiple go2pins
if idx == -1 {
// FIXME this is a very weak test
panic("Blackbox is only supported in go2pins source directory")
}
import_name := ""
if dirname[idx:] != "go2pins" {
dirname = string(dirname[idx+8:]) + "/"
import_name = "gitlab.lrde.epita.fr/spot/go2pins/" +
dirname + outputdir + "/blackbox"
} else {
import_name = "gitlab.lrde.epita.fr/spot/go2pins/" +
outputdir + "/blackbox"
}
//--------------------------------------------------------------------
import_name := path.Join(outputdir, "blackbox")
already_bb := false
for _, d := range node.Decls {
......
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