llcppsymg:libs,cflags parse
This commit is contained in:
@@ -2,9 +2,6 @@ package parse
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -189,37 +186,3 @@ func ParseHeaderFile(files []string, Prefixes []string, isCpp bool, isTemp bool)
|
||||
index.Dispose()
|
||||
return processer.SymbolMap, nil
|
||||
}
|
||||
|
||||
func GenHeaderFilePath(cflags string, files []string) ([]string, error) {
|
||||
prefixPath := strings.TrimPrefix(cflags, "-I")
|
||||
|
||||
var validPaths []string
|
||||
var errs []string
|
||||
|
||||
for _, file := range files {
|
||||
if file == "" {
|
||||
continue
|
||||
}
|
||||
fullPath := filepath.Join(prefixPath, file)
|
||||
if f, err := os.Open(fullPath); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
errs = append(errs, fmt.Sprintf("file not found: %s", file))
|
||||
} else {
|
||||
errs = append(errs, fmt.Sprintf("error accessing file %s: %v", file, err))
|
||||
}
|
||||
} else {
|
||||
f.Close()
|
||||
validPaths = append(validPaths, fullPath)
|
||||
}
|
||||
}
|
||||
|
||||
if len(validPaths) == 0 && len(errs) == 0 {
|
||||
return nil, fmt.Errorf("no valid header files")
|
||||
}
|
||||
|
||||
if len(errs) > 0 {
|
||||
return validPaths, fmt.Errorf("some files not found or inaccessible: %v", errs)
|
||||
}
|
||||
|
||||
return validPaths, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user