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()
|
fname := d.Name()
|
||||||
switch filepath.Ext(fname) {
|
switch filepath.Ext(fname) {
|
||||||
case ".a", ".dylib", ".so", ".dll", ".lib":
|
case ".a", ".dylib", ".tbd", ".so", ".dll", ".lib":
|
||||||
progress(path)
|
progress(path)
|
||||||
hash := md5.Sum([]byte(path))
|
hash := md5.Sum([]byte(path))
|
||||||
hashStr := base64.RawURLEncoding.EncodeToString(hash[:])
|
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.
|
// List lists symbols in an archive file.
|
||||||
func (p *Cmd) List(arfile string) (items []*ObjectFile, err error) {
|
func (p *Cmd) List(arfile string) (items []*ObjectFile, err error) {
|
||||||
var stdout bytes.Buffer
|
var stdout bytes.Buffer
|
||||||
|
var stderr bytes.Buffer
|
||||||
cmd := exec.Command(p.app, arfile)
|
cmd := exec.Command(p.app, arfile)
|
||||||
cmd.Stdout = &stdout
|
cmd.Stdout = &stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = &stderr
|
||||||
if err = cmd.Run(); err != nil {
|
err = cmd.Run()
|
||||||
|
if stderr.Len() > 0 {
|
||||||
|
listError(stderr.Bytes())
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
return listOutput(stdout.Bytes())
|
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) {
|
func listOutput(data []byte) (items []*ObjectFile, err error) {
|
||||||
sep := []byte{'\n'}
|
sep := []byte{'\n'}
|
||||||
item := &ObjectFile{}
|
item := &ObjectFile{}
|
||||||
|
|||||||
Reference in New Issue
Block a user