summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoakim Sindholt <opensource@zhasha.com>2019-08-17 17:09:09 +0200
committerJoakim Sindholt <opensource@zhasha.com>2019-08-17 17:09:09 +0200
commit03fa7faaf9998679a7bcc47331027bf6e2d53f52 (patch)
treeacbbd1b27651bae548a23a320211950c037afdf0
parent715b72ced54af4d7dbae13019c96ab9d6a8dfa2f (diff)
p9l: optimize dependency resolution
-rw-r--r--bin/p9l.sh27
1 files changed, 10 insertions, 17 deletions
diff --git a/bin/p9l.sh b/bin/p9l.sh
index 7d0732e..94279b6 100644
--- a/bin/p9l.sh
+++ b/bin/p9l.sh
@@ -117,7 +117,10 @@ IFS=$':\n'
SEARCH=("." "$LIBDIR" $(clang -print-search-dirs 2>/dev/null | awk 'match($0, /^libraries\s*:\s*=\s*/) { print substr($0, RSTART + RLENGTH) }'))
IFS="$saveifs"
-ALCHECKED=()
+IFS=$'\n'
+# sort out deps that are pulled in explicitly
+ALCHECKED=($(join $'\n' "$@" | sed -n 's/^\(.*\/\)\?\('"$O"'\.\)\?lib\([^ ]\+\)\.a$/\3/p'))
+IFS="$saveifs"
ALFILES=("$@")
while [[ ${#ALFILES} > 0 ]]; do
IFS=$'\n'
@@ -127,23 +130,13 @@ while [[ ${#ALFILES} > 0 ]]; do
NEWLIBS=()
for ln in "${AUTOLINKS[@]}"; do
- # sort away the global libs that are asked to be linked locally
- haslib=false
- for lib in "$@"; do
- if [[ "${lib##*/}" == "$O.lib${ln}.a" ]]; then
- haslib=true
- break
- fi
- done
- # or find the lib in the search path
- if [[ $haslib == false ]]; then
- lib=$(find "${SEARCH[@]}" -maxdepth 1 -type f -name "lib$ln.a" | sed 1q)
- if [[ "$lib" == "" ]]; then
- echo "can't find lib$ln.a" >&2
- exit 1
- fi
- NEWLIBS+=("$lib")
+ # find the lib in the search path
+ lib=$(find "${SEARCH[@]}" -maxdepth 1 -type f -name "lib$ln.a" | sed 1q)
+ if [[ "$lib" == "" ]]; then
+ echo "can't find lib$ln.a" >&2
+ exit 1
fi
+ NEWLIBS+=("$lib")
done
ALCHECKED+=("${AUTOLINKS[@]}")
ALFILES=("${NEWLIBS[@]}")