Raphael | 0e4dd61 | 2010-04-16 17:37:25 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Raphael | 1adaa57 | 2011-01-27 13:26:44 -0800 | [diff] [blame^] | 3 | # This script takes a Linux SDK, cleans it and injects the necessary Windows |
| 4 | # binaries needed by the SDK. The script has 2 parts: |
| 5 | # - development/tools/build/path_windows_sdk.sh to process the |
| 6 | # platform-dependent folders and files. |
| 7 | # - sdk/build/patch_windows_sdk.sh to process folder and files which |
| 8 | # depend on the sdk.git repo. This file will be invoked by this one. |
| 9 | # |
| 10 | # Input arguments: |
| 11 | # -q = Optional arg to make this silent. Must be given first. |
| 12 | # $1 = Temporary SDK directory, that is the Linux SDK being patched into |
| 13 | # a Windows one. |
| 14 | # $2 = The out/host/windows directory, which contains the new Windows |
| 15 | # binaries to use. |
| 16 | # $3 = An optional replacement for $TOPDIR (inherited from the Android |
| 17 | # build system), which is the top directory where Android is located. |
| 18 | |
Raphael | 0e4dd61 | 2010-04-16 17:37:25 -0700 | [diff] [blame] | 19 | # Verbose by default. Use -q to make more silent. |
| 20 | V="-v" |
| 21 | if [[ "$1" == "-q" ]]; then V=""; shift; fi |
| 22 | |
| 23 | TEMP_SDK_DIR=$1 |
| 24 | WIN_OUT_DIR=$2 |
| 25 | TOPDIR=${TOPDIR:-$3} |
| 26 | |
Raphael | 1adaa57 | 2011-01-27 13:26:44 -0800 | [diff] [blame^] | 27 | # The unix2dos is provided by the APT package "tofrodos". However |
| 28 | # as of ubuntu lucid, the package renamed the command to "todos". |
| 29 | UNIX2DOS=`which unix2dos` |
| 30 | if [[ ! -x $UNIX2DOS ]]; then |
| 31 | UNIX2DOS=`which todos` |
| 32 | fi |
| 33 | |
Raphael | 0e4dd61 | 2010-04-16 17:37:25 -0700 | [diff] [blame] | 34 | PLATFORMS=( $TEMP_SDK_DIR/platforms/* ) |
| 35 | if [[ ${#PLATFORMS[@]} != 1 ]]; then |
| 36 | echo "Error: Too many platforms found in $TEMP_SDK_DIR" |
| 37 | echo "Only one was expected." |
| 38 | echo "Instead, found: ${PLATFORMS[@]}" |
| 39 | exit 1 |
| 40 | fi |
Raphael | 0e4dd61 | 2010-04-16 17:37:25 -0700 | [diff] [blame] | 41 | |
| 42 | # Package USB Driver |
| 43 | if [[ -n "$USB_DRIVER_HOOK" ]]; then |
| 44 | $USB_DRIVER_HOOK $V $TEMP_SDK_DIR $TOPDIR |
| 45 | fi |
| 46 | |
| 47 | # Remove obsolete stuff from tools & platform |
| 48 | TOOLS=$TEMP_SDK_DIR/tools |
Raphael | 59b02d0 | 2010-10-08 15:41:01 -0700 | [diff] [blame] | 49 | PLATFORM_TOOLS=$TEMP_SDK_DIR/platform-tools |
Raphael | 0e4dd61 | 2010-04-16 17:37:25 -0700 | [diff] [blame] | 50 | LIB=$TEMP_SDK_DIR/tools/lib |
Xavier Ducrohet | 76afc00 | 2010-09-27 13:58:45 -0700 | [diff] [blame] | 51 | rm $V $TOOLS/{android,apkbuilder,ddms,dmtracedump,draw9patch,emulator,etc1tool} |
Raphael | 0e4dd61 | 2010-04-16 17:37:25 -0700 | [diff] [blame] | 52 | rm $V $TOOLS/{hierarchyviewer,hprof-conv,layoutopt,mksdcard,sqlite3,traceview,zipalign} |
| 53 | rm $V $LIB/*/swt.jar |
Xavier Ducrohet | 76afc00 | 2010-09-27 13:58:45 -0700 | [diff] [blame] | 54 | rm $V $PLATFORM_TOOLS/{adb,aapt,aidl,dx,dexdump} |
Raphael | 0e4dd61 | 2010-04-16 17:37:25 -0700 | [diff] [blame] | 55 | |
| 56 | # Copy all the new stuff in tools |
| 57 | # Note: some tools are first copied here and then moved in platforms/<name>/tools/ |
| 58 | cp $V $WIN_OUT_DIR/host/windows-x86/bin/*.{exe,dll} $TOOLS/ |
| 59 | mkdir -pv $LIB/x86 |
| 60 | cp $V ${TOPDIR}prebuilt/windows/swt/swt.jar $LIB/x86/ |
| 61 | mkdir -pv $LIB/x86_64 |
| 62 | cp $V ${TOPDIR}prebuilt/windows-x86_64/swt/swt.jar $LIB/x86_64/ |
| 63 | |
Raphael | 59b02d0 | 2010-10-08 15:41:01 -0700 | [diff] [blame] | 64 | # Copy the SDK Manager (aka sdklauncher) to the root of the SDK (it was copied in tools above) |
Raphael | 0e4dd61 | 2010-04-16 17:37:25 -0700 | [diff] [blame] | 65 | # and move it also in SDK/tools/lib (so that tools updates can update the root one too) |
Raphael | 59b02d0 | 2010-10-08 15:41:01 -0700 | [diff] [blame] | 66 | cp $TOOLS/sdklauncher.exe $TEMP_SDK_DIR/"SDK Manager.exe" |
| 67 | mv $TOOLS/sdklauncher.exe $LIB/"SDK Manager.exe" |
Raphael | 0e4dd61 | 2010-04-16 17:37:25 -0700 | [diff] [blame] | 68 | |
| 69 | # Copy the emulator NOTICE in the tools dir |
| 70 | cp $V ${TOPDIR}external/qemu/NOTICE $TOOLS/emulator_NOTICE.txt |
| 71 | |
| 72 | # aapt under cygwin needs to have mgwz.dll |
| 73 | [[ -n $NEED_MGWZ ]] && cp $V $CYG_MGWZ_PATH $TOOLS/ |
| 74 | |
| 75 | # Update a bunch of bat files |
Raphael | 59b02d0 | 2010-10-08 15:41:01 -0700 | [diff] [blame] | 76 | cp $V ${TOPDIR}sdk/files/post_tools_install.bat $LIB/ |
| 77 | cp $V ${TOPDIR}sdk/files/find_java.bat $LIB/ |
| 78 | cp $V ${TOPDIR}sdk/apkbuilder/etc/apkbuilder.bat $TOOLS/ |
| 79 | cp $V ${TOPDIR}sdk/ddms/app/etc/ddms.bat $TOOLS/ |
| 80 | cp $V ${TOPDIR}sdk/traceview/etc/traceview.bat $TOOLS/ |
Raphael | cca5d18 | 2010-10-14 11:25:01 -0700 | [diff] [blame] | 81 | if [ -f ${TOPDIR}sdk/hierarchyviewer2/app/etc/hierarchyviewer.bat ]; then |
| 82 | cp $V ${TOPDIR}sdk/hierarchyviewer2/app/etc/hierarchyviewer.bat $TOOLS/ |
| 83 | else |
| 84 | # That's ok because currently GB uses Tools_r7 but we'll ship Tools_r8 from master-open. |
| 85 | echo "WARNING: Ignoring ${TOPDIR}sdk/hierarchyviewer2/app/etc/hierarchyviewer.bat [ok for GB+Tools r8]" |
| 86 | fi |
Raphael | 59b02d0 | 2010-10-08 15:41:01 -0700 | [diff] [blame] | 87 | cp $V ${TOPDIR}sdk/layoutopt/app/etc/layoutopt.bat $TOOLS/ |
| 88 | cp $V ${TOPDIR}sdk/draw9patch/etc/draw9patch.bat $TOOLS/ |
| 89 | cp $V ${TOPDIR}sdk/sdkmanager/app/etc/android.bat $TOOLS/ |
Raphael | 0e4dd61 | 2010-04-16 17:37:25 -0700 | [diff] [blame] | 90 | |
| 91 | # Put the JetCreator tools, content and docs (not available in the linux SDK) |
| 92 | JET=$TOOLS/Jet |
| 93 | JETCREATOR=$JET/JetCreator |
| 94 | JETDEMOCONTENT=$JET/demo_content |
| 95 | JETLOGICTEMPLATES=$JET/logic_templates |
| 96 | JETDOC=$TEMP_SDK_DIR/docs/JetCreator |
| 97 | |
| 98 | # need to rm these folders since a Mac SDK will have them and it might create a conflict |
| 99 | rm -rf $V $JET |
| 100 | rm -rf $V $JETDOC |
| 101 | |
| 102 | # now create fresh folders for JetCreator |
| 103 | mkdir $V $JET |
| 104 | mkdir $V $JETDOC |
| 105 | |
| 106 | cp -r $V ${TOPDIR}external/sonivox/jet_tools/JetCreator $JETCREATOR/ |
| 107 | cp -r $V ${TOPDIR}external/sonivox/jet_tools/JetCreator_content $JETDEMOCONTENT/ |
| 108 | cp -r $V ${TOPDIR}external/sonivox/jet_tools/logic_templates $JETLOGICTEMPLATES/ |
| 109 | chmod $V -R u+w $JETCREATOR # fixes an issue where Cygwin might copy the above as u+rx only |
Xavier Ducrohet | 76afc00 | 2010-09-27 13:58:45 -0700 | [diff] [blame] | 110 | cp $V ${TOPDIR}prebuilt/windows/jetcreator/EASDLL.dll $JETCREATOR/ |
Raphael | 0e4dd61 | 2010-04-16 17:37:25 -0700 | [diff] [blame] | 111 | |
| 112 | cp $V ${TOPDIR}external/sonivox/docs/JET_Authoring_Guidelines.html $JETDOC/ |
| 113 | cp -r $V ${TOPDIR}external/sonivox/docs/JET_Authoring_Guidelines_files $JETDOC/ |
| 114 | cp $V ${TOPDIR}external/sonivox/docs/JET_Creator_User_Manual.html $JETDOC/ |
| 115 | cp -r $V ${TOPDIR}external/sonivox/docs/JET_Creator_User_Manual_files $JETDOC/ |
| 116 | |
| 117 | # Copy or move platform specific tools to the default platform. |
| 118 | cp $V ${TOPDIR}dalvik/dx/etc/dx.bat $PLATFORM_TOOLS/ |
Xavier Ducrohet | 76afc00 | 2010-09-27 13:58:45 -0700 | [diff] [blame] | 119 | mv $V $TOOLS/{adb.exe,aapt.exe,aidl.exe,dexdump.exe} $TOOLS/Adb*.dll $PLATFORM_TOOLS/ |
Raphael | 0e4dd61 | 2010-04-16 17:37:25 -0700 | [diff] [blame] | 120 | |
| 121 | # When building under cygwin, mgwz.dll must be both in SDK/tools for zipalign |
| 122 | # and in SDK/platform/XYZ/tools/ for aapt |
| 123 | [[ -n $NEED_MGWZ ]] && cp $V $TOOLS/mgwz.dll $PLATFORM_TOOLS/ |
| 124 | |
| 125 | # Fix EOL chars to make window users happy - fix all files at the top level |
| 126 | # as well as all batch files including those in platforms/<name>/tools/ |
Raphael | 1adaa57 | 2011-01-27 13:26:44 -0800 | [diff] [blame^] | 127 | if [[ -x $UNIX2DOS ]]; then |
| 128 | find $TEMP_SDK_DIR -maxdepth 1 -name "*.[ht]*" -type f -print0 | xargs -0 $UNIX2DOS |
| 129 | find $TEMP_SDK_DIR -maxdepth 3 -name "*.bat" -type f -print0 | xargs -0 $UNIX2DOS |
| 130 | fi |
Raphael | 0e4dd61 | 2010-04-16 17:37:25 -0700 | [diff] [blame] | 131 | |
| 132 | # Just to make it easier on the build servers, we want fastboot and adb (and its DLLs) |
| 133 | # next to the new SDK, so up one dir. |
| 134 | for i in fastboot.exe adb.exe AdbWinApi.dll AdbWinUsbApi.dll; do |
| 135 | cp -f $V $WIN_OUT_DIR/host/windows-x86/bin/$i $TEMP_SDK_DIR/../$i |
| 136 | done |
Raphael | 1adaa57 | 2011-01-27 13:26:44 -0800 | [diff] [blame^] | 137 | |