nmindex: listError
This commit is contained in:
@@ -61,7 +61,7 @@ func (p *IndexBuilder) IndexDir(fromDir, toDir string, progress func(path string
|
||||
}
|
||||
fname := d.Name()
|
||||
switch filepath.Ext(fname) {
|
||||
case ".a", ".dylib", ".so", ".dll", ".lib":
|
||||
case ".a", ".dylib", ".tbd", ".so", ".dll", ".lib":
|
||||
progress(path)
|
||||
hash := md5.Sum([]byte(path))
|
||||
hashStr := base64.RawURLEncoding.EncodeToString(hash[:])
|
||||
|
||||
22
x/nm/nm.go
22
x/nm/nm.go
@@ -79,15 +79,33 @@ type ObjectFile struct {
|
||||
// List lists symbols in an archive file.
|
||||
func (p *Cmd) List(arfile string) (items []*ObjectFile, err error) {
|
||||
var stdout bytes.Buffer
|
||||
var stderr bytes.Buffer
|
||||
cmd := exec.Command(p.app, arfile)
|
||||
cmd.Stdout = &stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
if err = cmd.Run(); err != nil {
|
||||
cmd.Stderr = &stderr
|
||||
err = cmd.Run()
|
||||
if stderr.Len() > 0 {
|
||||
listError(stderr.Bytes())
|
||||
}
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return listOutput(stdout.Bytes())
|
||||
}
|
||||
|
||||
func listError(data []byte) {
|
||||
sep := []byte{'\n'}
|
||||
nosym := []byte(": no symbols")
|
||||
lines := bytes.Split(data, sep)
|
||||
for _, line := range lines {
|
||||
if len(line) == 0 || bytes.HasSuffix(line, nosym) {
|
||||
continue
|
||||
}
|
||||
os.Stderr.Write(line)
|
||||
os.Stderr.Write(sep)
|
||||
}
|
||||
}
|
||||
|
||||
func listOutput(data []byte) (items []*ObjectFile, err error) {
|
||||
sep := []byte{'\n'}
|
||||
item := &ObjectFile{}
|
||||
|
||||
Reference in New Issue
Block a user