1#!/bin/bash 2 3GdkRoot="" 4AndroidRoot="" 5 6function echoHelp { 7 echo "Build tools into <GDK>/toolchins/llvm/prebuilt/" 8 echo "$0" 9 echo " --gdk-root= GDK root absolute path" 10 echo " --android-root= Android source tree root absolute path" 11 echo 12} 13 14# Parse --Name=Value 15function parseArgs { 16 Name=$(echo $1 | awk -F '--' '{print $2}' | awk -F '=' '{print $1}') 17 Value=$(echo $1 | awk -F '--' '{print $2}' | awk -F '=' '{print $2}') 18 if [ $Name = "gdk-root" ]; then 19 GdkRoot=$Value 20 elif [ $Name = "android-root" ]; then 21 AndroidRoot=$Value 22 fi 23} 24 25function assertVar { 26 if [ -z $2 ]; then 27 echo "You must define --$1 in command line." 28 exit 1 29 fi 30} 31 32function main { 33 assertVar gdk-root $1 34 assertVar android-root $2 35 36 if [ -z `echo $GdkRoot | awk -F $AndroidRoot '{print $2}'` ]; then 37 echo "Please put <GDK> under <AndroidSrcRoot>." 38 echo "Since building <GDK>/sources/llvm-ndk-cc/ needs Android source building system." 39 echo 40 exit 1 41 fi 42 43 cd $1/sources/llvm-ndk-cc/ && \ 44 . $2/build/envsetup.sh && \ 45 mm && \ 46 mkdir -p $1/toolchains/llvm/prebuilt/bin && \ 47 cp -f -p $2/out/host/linux-x86/bin/llvm-ndk-cc $1/toolchains/llvm/prebuilt/bin/ && \ 48 cp -f -p $2/out/host/linux-x86/bin/llvm-ndk-link $1/toolchains/llvm/prebuilt/bin/ 49 50 if [ $? -eq 0 ]; then 51 echo 52 echo "====================================================================" 53 echo "Congradulation! You can check $1/toolchains/llvm/prebuilt/ now." 54 echo "====================================================================" 55 echo 56 fi 57} 58 59 60# Entry 61if [ $# -eq 0 ]; then 62 echoHelp $0 63 exit 1 64fi 65 66while [ $# -gt 0 ]; do 67 parseArgs $1 68 shift 1 69done 70 71main $GdkRoot $AndroidRoot 72