Last active
April 11, 2017 22:00
-
-
Save andrewseidl/5b659e852a549a53630a3a051485924c to your computer and use it in GitHub Desktop.
Given one header, recursively find all other files it #includes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
START="folly/SharedMutex.h" | |
ALL=$START | |
NEW="" | |
# could simplyify with `sort -t' ' -u` | |
while ! diff -q <(echo $ALL | tr ' ' '\n' | sort -u) <(echo $NEW | tr ' ' '\n' | sort -u) >/dev/null ; do | |
ALL=$(echo "$NEW $ALL" | tr ' ' '\n' | sort -u | tr '\n' ' ') | |
NEW=$(grep \#include ${ALL} | grep -o "<folly/[^>]*" | sed 's/<//g' | sort -u | tr '\n' ' ') | |
NEW=$(echo "$START $NEW" | tr ' ' '\n' | sort -u | tr '\n' ' ') | |
done | |
echo $ALL | |
echo | |
BASE=slimfolly | |
for i in $ALL ; do | |
mkdir -p $BASE/$(dirname $i) | |
CPP=$(echo $i | sed 's/.h$/.cpp/') | |
cp $i $BASE/$i | |
if [ -e $CPP ] ; then | |
cp $CPP $BASE/$CPP | |
echo $CPP | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment