Skip to content

Instantly share code, notes, and snippets.

@passos
Created September 5, 2011 11:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save passos/1194799 to your computer and use it in GitHub Desktop.
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
#!/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