Commit 982fc5eb authored by Hugo Moreau's avatar Hugo Moreau

blackbox import structs only if global var

The blackbox package now import structs only if the blackboxed contains
global variables, it was importing it everytime before.

 * main.go,
   transform/blackbox.go : Here.
parent 57546050
Pipeline #26463 passed with stage
in 2 minutes and 24 seconds
......@@ -482,7 +482,12 @@ func treatGlobal(src []byte) ([]byte, bool) {
fmt.Println(err)
os.Exit(1)
}
return src, true
for _, val := range toIgnore {
if global.GlobalBlackbox[val] {
return src, true
}
}
return src, false
}
func insertGlobalInBlackbox(meta *transform.Meta, filename string) {
......
......@@ -140,7 +140,9 @@ func RewriteBlackbox(inputfile string, funs []string, global bool, outputdir str
bb_ast.Name.Name = "blackbox"
bb_ast.Decls = toBB
astutil.AddImport(fset, bb_ast, path.Join(outputdir, "structs"))
if global {
astutil.AddImport(fset, bb_ast, path.Join(outputdir, "structs"))
}
printer.Fprint(&buf, fset, bb_ast)
bb := buf.String()
......
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