cgo: Add LDFlags support

This commit is contained in:
Lucas Teske
2020-05-20 13:05:25 -03:00
committed by Ayke
parent b9fd6cee6f
commit 726d735ad3
8 changed files with 46 additions and 18 deletions
+3 -1
View File
@@ -31,6 +31,7 @@ type Program struct {
Dir string // current working directory (for error reporting)
TINYGOROOT string // root of the TinyGo installation or root of the source code
CFlags []string
LDFlags []string
ClangHeaders string
}
@@ -425,11 +426,12 @@ func (p *Package) parseFiles(includeTests bool) ([]*ast.File, error) {
if p.ClangHeaders != "" {
cflags = append(cflags, "-Xclang", "-internal-isystem", "-Xclang", p.ClangHeaders)
}
generated, errs := cgo.Process(files, p.Program.Dir, p.fset, cflags)
generated, ldflags, errs := cgo.Process(files, p.Program.Dir, p.fset, cflags)
if errs != nil {
fileErrs = append(fileErrs, errs...)
}
files = append(files, generated)
p.LDFlags = append(p.LDFlags, ldflags...)
}
if len(fileErrs) != 0 {
return nil, Errors{p, fileErrs}