Skip to content

Instantly share code, notes, and snippets.

@sambatyon
Created February 21, 2014 13:37
Show Gist options
  • Save sambatyon/9134348 to your computer and use it in GitHub Desktop.
Save sambatyon/9134348 to your computer and use it in GitHub Desktop.
Extracts headers from a source tree.
#!/bin/bash
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: extractheaders src dest"
exit
fi
orig_dir=`pwd`
origin=$1
if [[ "$2" = /* ]]; then
destination=$2
else
destination=`pwd`/$2
fi
rsync -a -f"+ */" -f"- *" "$origin/" "$destination"
cd "$destination"
for vcd in $(find -type d -a \( -name ".svn" -o -name ".git" \)); do
rm -rf "$vcd"
done
cd "$origin"
for f in $(find -name "*.h" -o -name "*.hpp" -o -name "*.hxx" -o -name "*.hh" -o -name "*.ixx" -o -name "*.ipp" -o -name "*.inc"); do
cp "$f" "$destination/$f"
done
cd "$destination"
find . -type d -empty -delete
cd "$orig_dir"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment