# listed. if this is the case, zero is returned (meaning success). if
# the dependency is missing, then -1 is return to indicate an error.
function existing_dep {
-#hmmm: below is not very efficient!
- for currite in ${dependency_accumulator[*]}; do
- if [ "$currite" == "$1" ]; then return 0; fi
- done
+ seek="$1"; shift
+ # efficient search of array for the string.
+ if ( IFS=$'\n'; echo "${dependency_accumulator[*]}" ) | grep -qFx "$seek"; then
+ return 0
+ fi
+
+## #hmmm: below is not very efficient!
+## for currite in ${dependency_accumulator[*]}; do
+## if [ "$currite" == "$1" ]; then return 0; fi
+## done
+
return 1
}
# reports whether a file name has already been processed.
function boring_file {
+ seek="$1"; shift
+ # efficient search of array for the string.
+ if ( IFS=$'\n'; echo "${boring_files[*]}" ) | grep -qFx "$seek"; then
+ return 0
+ fi
+
+## #hmmm: below might not be very efficient!
+## for currite in ${boring_files[*]}; do
+## if [ "$currite" == "$1" ]; then return 0; fi
+## done
-#hmmm: below might not be very efficient!
- for currite in ${boring_files[*]}; do
- if [ "$currite" == "$1" ]; then return 0; fi
- done
return 1
}
# reports whether a file name has already been found to be missing.
function bad_file {
+ seek="$1"; shift
+ # efficient search of array for the string.
+ if ( IFS=$'\n'; echo "${bad_files[*]}" ) | grep -qFx "$seek"; then
+ return 0
+ fi
+
+## #hmmm: below also is not very efficient!
+## for currite in ${bad_files[*]}; do
+## if [ "$currite" == "$seek" ]; then return 0; fi
+## done
-#hmmm: below also is not very efficient!
- for currite in ${bad_files[*]}; do
- if [ "$currite" == "$1" ]; then return 0; fi
- done
return 1
}
local dirtmp=$(dirname "$to_examine")
local basetmp=$(basename "$to_examine")
+
log_it "dependent on: $(basename "$dirtmp")/$basetmp"
#hmmm: do a better, nicer output--gather the dependencies listed in debugging
# line above into a list that will be printed out at the end.
# find all the includes in this file and save to the temp file.
while read -r spoon; do
- has_guard="$(echo "$spoon" \
- | sed -n -e 's/#ifdef __BUILD_STATIC_APPLICATION__/yep/p')"
- if [ ! -z "$has_guard" ]; then
+# has_guard="$(echo "$spoon" | sed -n -e 's/#ifdef __BUILD_STATIC_APPLICATION__/yep/p')"
+# if [ ! -z "$has_guard" ]; then
+ if [[ $spoon == *"#ifdef __BUILD_STATIC_APPLICATION__"* ]]; then
# quit reading when we've seen the start of one of our guards.
break
fi
# iterate across the dependencies we saw and add them to our list if we haven't already.
while read -r line_found; do
# process the line to see if we can get a simple filename out of the include.
+ # we are only trying for system-searched files for this one, with angle brackets.
#local chew_toy=$(echo $line_found | sed -e 's/^[ \t]*#include *<\(.*\)>.*$/\1/')
- local chew_toy="${line_found#*\#include *[\"<]}"
- chew_toy="${chew_toy/[\">]*}"
+ local chew_toy="${line_found#*\#include *<}"
+ chew_toy="${chew_toy/>*}"
if [ ! -z "$DEBUG_BUILDOR_GEN_DEPS" ]; then
log_it A: chew_toy=$chew_toy
fi
# local slash_present=$(echo $chew_toy | sed -n -e 's/.*[\\\/].*/yep/p')
local slash_present="${chew_toy/[^\/]*/}"
-#this block with the second attempt should no longer be necessary.
-# # the replacement above to get rid of #include failed. try something simpler.
# if [ ! -z "$(echo $chew_toy | sed -n -e 's/#include/crud/p')" ]; then
-# if [[ $chew_toy == *"#include"* ]]; then
-
-# if [ ! -z "$DEBUG_BUILDOR_GEN_DEPS" ]; then
-# log_it "into b-grade processing; why are we here????"
-# log_it "line with include in it still is: '$chew_toy'"
-# fi
-## # try again with a simpler pattern???
-## # chew_toy=$(echo $line_found | sed -e 's/^[ \t]*#include *[">]\(.*\)[">].*$/\1/')
-## chew_toy="${chew_toy#[[:space:]]*#include[[:space:]]*[\"<]}"
-## chew_toy="${chew_toy/[[:space:]]*[\">]}"
-## # if [ ! -z "$DEBUG_BUILDOR_GEN_DEPS" ]; then
-## log_it "B: chew_toy=$chew_toy"
-## # fi
-
- # if it still has an #include or if it's not really a file, we can't
- # use it for anything.
if [[ $chew_toy == *"#include"* ]]; then
+ # the replacement above to get rid of #include failed. try something
+ # more inclusive, so we match double quote includes also.
+# chew_toy=$(echo $line_found | sed -e 's/^[ \t]*#include *[">]\(.*\)[">].*$/\1/')
+ chew_toy="${chew_toy#*\#include *[\"<]}"
+ chew_toy="${chew_toy/[\">]*}"
+ if [ ! -z "$DEBUG_BUILDOR_GEN_DEPS" ]; then
+ echo B: chew_toy=$chew_toy
+ fi
+
+ # if it still has an #include or if it's not really a file, we can't
+ # use it for anything.
+ if [[ $chew_toy == *"#include"* ]]; then
# if [ ! -z "$(echo $chew_toy | sed -n -e 's/#include/crud/p')" ]; then
- log_it "** bad include: $chew_toy"
- continue
- fi
+ log_it "** bad include: $chew_toy"
+ continue
+ fi
- if [ -z "$slash_present" ]; then
- # we are pretty sure that this file has no path components in it.
- # we will add the surrounding directory if possible.
- if [ -z "$fp_dir" ]; then
- # well, now we have no recourse, since we don't know where to
- # say this file comes from.
- log_it "** unknown directory: $chew_toy"
- else
- # cool, we can rely on the existing directory.
- chew_toy="$fp_dir/$chew_toy"
- if [ ! -z "$DEBUG_BUILDOR_GEN_DEPS" ]; then
- log_it "patched dir: $chew_toy"
+ if [ -z "$slash_present" ]; then
+ # we are pretty sure that this file has no path components in it.
+ # we will add the surrounding directory if possible.
+ if [ -z "$fp_dir" ]; then
+ # well, now we have no recourse, since we don't know where to
+ # say this file comes from.
+ log_it "** unknown directory: $chew_toy"
+ else
+ # cool, we can rely on the existing directory.
+ chew_toy="$fp_dir/$chew_toy"
+ if [ ! -z "$DEBUG_BUILDOR_GEN_DEPS" ]; then
+ log_it "patched dir: $chew_toy"
+ fi
fi
fi
fi