Created
September 5, 2011 11:59
-
-
Save passos/1194799 to your computer and use it in GitHub Desktop.
A script to scan Android code repo and generate source code for sdk
This file contains 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 | |
dest_dir=~/workspace/src-tree | |
if [ ! -z "$1" ]; then | |
dest_dir=$1 | |
fi | |
curr_dir=$PWD | |
dirname=$(basename $dest_dir) | |
if [ -d $dest_dir ] ; then | |
rm -rf $dest_dir | |
fi | |
mkdir -p $dest_dir | |
for d in $(find . -path .repo -prune \ | |
-or -path .git -prune \ | |
-or -path "*/src/com/*" -type d -print \ | |
-or -path "*/src/net/*" -type d -print \ | |
-or -path "*/src/org/*" -type d -print \ | |
-or -path "*/java/com/*" -type d -print \ | |
-or -path "*/java/net/*" -type d -print \ | |
-or -path "*/java/org/*" -type d -print \ | |
-or -path "*/java/android/*" -type d -print \ | |
-or -path "*/java/javax/*" -type d -print) | |
do | |
sd=$(echo $d | sed 's#.*/src/\(.*\)/#\1/#g' | sed 's#.*/java/\(.*\)/#\1/#g') | |
echo ";; $d" | |
echo "-> $sd" | |
mkdir -p $dest_dir/$sd | |
for f in $(cd $d; find . -mindepth 0 -maxdepth 1 -type f | sed 's#^\./##g'); do | |
echo " $f" | |
ln -s $curr_dir/$d/$f $dest_dir/$sd/$f | |
done | |
done | |
# package the source directory | |
$(cd $(dirname $dest_dir); rm ${dirname}.tar.gz; tar zcfh ${dirname}.tar.gz $dirname) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment