1
0
Fork 0

Handle user-defined sets of files

This commit is contained in:
krcroft 2020-03-15 10:13:46 -07:00 committed by Patryk Obara
parent 6fcc453d50
commit 01f5ca4365
2 changed files with 41 additions and 14 deletions

View file

@ -23,11 +23,16 @@ gcc_includes="$(gcc -xc++ -E -v - < /dev/null 2>&1 | grep '^ ' | tail -n +2 | se
sdl_includes="$(sdl2-config --cflags)"
# Round up our source files
sources=( "$(find . -name '*.cpp' -o -name '*.c')" )
if [[ "$#" == "0" ]]; then
sources=( "$(find . -name '*.cpp' -o -name '*.c')" )
else
sources=( "$@" )
fi
# Run it
parallel \
"g++ -std=gnu++11 \
parallel "\
[[ ! -f {}.defines || {} -nt {}.defines ]] \
&& g++ -std=gnu++11 \
$gcc_includes \
$sdl_includes \
-I$root_dir \
@ -35,5 +40,6 @@ parallel \
-I{//} \
-DHAVE_CONFIG_H \
-E -dM -include '{}' - < /dev/null 2> /dev/null \
| grep '^#define' > '{.}.defines' \
; echo '{} to {.}.defines'" ::: "${sources[@]}"
| grep '^#define' > '{}.defines' \
&& echo '{} to {}.defines' \
|| true" ::: "${sources[@]}"

View file

@ -21,16 +21,37 @@ declare -gr green="\\e[32m"
declare -gr cyan="\\e[36m"
declare -gr reset="\\e[0m"
# Round up defines files
# shellcheck disable=SC2207
defines=( $(find . -name '*.defines') )
# Path to our define script
write_defines="./scripts/dump-preprocessor-defines.sh"
# Ensure we have the expected quantity
actual="${#defines[@]}"
expected="$(find . -name '*.cpp' -o -name '*.c' | wc -l)"
if (( "$actual" != "$expected" )); then
echo "We should have $expected .defines files but $actual were found"
exit 1
# Round up defines files
if [[ "$#" == "0" ]]; then
"$write_defines"
# shellcheck disable=SC2207
defines=( $(find . -name '*.defines') )
# Ensure we have as many as we have source files
actual="${#defines[@]}"
expected="$(find . -name '*.cpp' -o -name '*.c' | wc -l)"
if (( "$actual" != "$expected" )); then
echo "We should have $expected .defines files but $actual were found"
exit 1
fi
# Otherwise verify only those files specified
else
defines=( )
for f in "$@"; do
extension="${f##*.}"
if [[ "$extension" == "defines" ]]; then
"$write_defines" "${f%.*}"
defines+=( "$f" )
else
"$write_defines" "$f"
defines+=( "${f}.defines" )
fi
done
fi
# The header strings that we're looking for