Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions newt/builder/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"os"
"path/filepath"
"runtime"
"strings"

log "github.com/sirupsen/logrus"

Expand Down Expand Up @@ -416,18 +417,32 @@ func (b *Builder) link(elfName string, linkerScripts []string,
if err != nil {
return err
}
c.AddInfo(&toolchain.CompilerInfo{Lflags: ci.Lflags})
c.AddInfo(&toolchain.CompilerInfo{
Lflags: ci.Lflags, IgnorePkgs: ci.IgnorePkgs})
}
dirs = append(dirs, extraADirs...)

// Find all .a files in the input directories.
// Find all .a files in the input directories for all non-ignored packages
ignorePkgs := c.GetCompilerInfo().IgnorePkgs
trimmedANames := []string{}
for _, dir := range dirs {
fullANames, _ := filepath.Glob(dir + "/*.a")
for i, archiveName := range fullANames {
fullANames[i] = filepath.ToSlash(archiveName)
ignoreThisPkg := false
for i, ignorePkg := range ignorePkgs {
if strings.HasSuffix(dir, ignorePkg.String()) {
// Pop the ignore package to speed up subsequent checks.
// Assumes no duplicate packages.
ignorePkgs[i] = ignorePkgs[len(ignorePkgs)-1]
ignorePkgs = ignorePkgs[:len(ignorePkgs)-1]
ignoreThisPkg = true
}
}
if !ignoreThisPkg {
fullANames, _ := filepath.Glob(dir + "/*.a")
for i, archiveName := range fullANames {
fullANames[i] = filepath.ToSlash(archiveName)
}
trimmedANames = append(trimmedANames, fullANames...)
}
trimmedANames = append(trimmedANames, fullANames...)
}

c.LinkerScripts = linkerScripts
Expand Down
15 changes: 15 additions & 0 deletions newt/builder/buildpackage.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,21 @@ func (bpkg *BuildPackage) CompilerInfo(
ci.IgnoreDirs = append(ci.IgnoreDirs, re)
}

ci.IgnorePkgs = []*regexp.Regexp{}

ignPkgs, err := bpkg.rpkg.Lpkg.PkgY.GetValStringSlice(
"pkg.ign_pkgs", settings)
util.OneTimeWarningError(err)

for _, str := range ignPkgs {
re, err := regexp.Compile(str)
if err != nil {
return nil, util.NewNewtError(
"Ignore pkgs, unable to compile re: " + err.Error())
}
ci.IgnorePkgs = append(ci.IgnorePkgs, re)
}

bpkg.SourceDirectories, err = bpkg.rpkg.Lpkg.PkgY.GetValStringSlice(
"pkg.src_dirs", settings)
util.OneTimeWarningError(err)
Expand Down
3 changes: 3 additions & 0 deletions newt/toolchain/compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ type CompilerInfo struct {
Aflags []string
IgnoreFiles []*regexp.Regexp
IgnoreDirs []*regexp.Regexp
IgnorePkgs []*regexp.Regexp
}

type CompileCommand struct {
Expand Down Expand Up @@ -166,6 +167,7 @@ func NewCompilerInfo() *CompilerInfo {
ci.Aflags = []string{}
ci.IgnoreFiles = []*regexp.Regexp{}
ci.IgnoreDirs = []*regexp.Regexp{}
ci.IgnorePkgs = []*regexp.Regexp{}

return ci
}
Expand Down Expand Up @@ -246,6 +248,7 @@ func (ci *CompilerInfo) AddCompilerInfo(newCi *CompilerInfo) {
ci.Aflags = addFlags("aflag", ci.Aflags, newCi.Aflags)
ci.IgnoreFiles = append(ci.IgnoreFiles, newCi.IgnoreFiles...)
ci.IgnoreDirs = append(ci.IgnoreDirs, newCi.IgnoreDirs...)
ci.IgnorePkgs = append(ci.IgnorePkgs, newCi.IgnorePkgs...)
}

func NewCompiler(compilerDir string, dstDir string,
Expand Down