Raphael | 0e4dd61 | 2010-04-16 17:37:25 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Raphael Moll | 1fe58f3 | 2010-11-11 15:58:28 -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 |
Raphael | 7a508ae | 2011-02-01 12:48:48 -0800 | [diff] [blame] | 8 | # depend on the sdk.git repo. This file is invoked by the makefile |
Raphael | 320d10e | 2011-05-26 12:16:35 -0700 | [diff] [blame] | 9 | # at development/build/tools/windows_sdk.mk. |
Raphael Moll | 1fe58f3 | 2010-11-11 15:58:28 -0800 | [diff] [blame] | 10 | # |
| 11 | # Input arguments: |
| 12 | # -q = Optional arg to make this silent. Must be given first. |
| 13 | # $1 = Temporary SDK directory, that is the Linux SDK being patched into |
| 14 | # a Windows one. |
| 15 | # $2 = The out/host/windows directory, which contains the new Windows |
| 16 | # binaries to use. |
| 17 | # $3 = An optional replacement for $TOPDIR (inherited from the Android |
| 18 | # build system), which is the top directory where Android is located. |
| 19 | |
Raphael | 7a508ae | 2011-02-01 12:48:48 -0800 | [diff] [blame] | 20 | set -e # any error stops the build |
| 21 | |
Raphael | 0e4dd61 | 2010-04-16 17:37:25 -0700 | [diff] [blame] | 22 | # Verbose by default. Use -q to make more silent. |
Raphael | 7a508ae | 2011-02-01 12:48:48 -0800 | [diff] [blame] | 23 | V="" |
Raphael Moll | 1fe58f3 | 2010-11-11 15:58:28 -0800 | [diff] [blame] | 24 | Q="" |
| 25 | if [[ "$1" == "-q" ]]; then |
| 26 | Q="$1" |
Raphael Moll | 1fe58f3 | 2010-11-11 15:58:28 -0800 | [diff] [blame] | 27 | shift |
Raphael | 7a508ae | 2011-02-01 12:48:48 -0800 | [diff] [blame] | 28 | else |
| 29 | echo "Win SDK: $0 $*" |
| 30 | set -x # show bash commands; no need for V=-v |
Raphael Moll | 1fe58f3 | 2010-11-11 15:58:28 -0800 | [diff] [blame] | 31 | fi |
Raphael | 0e4dd61 | 2010-04-16 17:37:25 -0700 | [diff] [blame] | 32 | |
| 33 | TEMP_SDK_DIR=$1 |
| 34 | WIN_OUT_DIR=$2 |
| 35 | TOPDIR=${TOPDIR:-$3} |
| 36 | |
Raphael Moll | 1fe58f3 | 2010-11-11 15:58:28 -0800 | [diff] [blame] | 37 | # The unix2dos is provided by the APT package "tofrodos". However |
Raphael | 7a508ae | 2011-02-01 12:48:48 -0800 | [diff] [blame] | 38 | # as for ubuntu lucid, the package renamed the command to "todos". |
| 39 | UNIX2DOS=$(which unix2dos || true) |
Raphael Moll | 1fe58f3 | 2010-11-11 15:58:28 -0800 | [diff] [blame] | 40 | if [[ ! -x $UNIX2DOS ]]; then |
Raphael | 7a508ae | 2011-02-01 12:48:48 -0800 | [diff] [blame] | 41 | UNIX2DOS=$(which todos || true) |
Raphael Moll | 1fe58f3 | 2010-11-11 15:58:28 -0800 | [diff] [blame] | 42 | fi |
| 43 | |
Raphael | 0e4dd61 | 2010-04-16 17:37:25 -0700 | [diff] [blame] | 44 | PLATFORMS=( $TEMP_SDK_DIR/platforms/* ) |
| 45 | if [[ ${#PLATFORMS[@]} != 1 ]]; then |
| 46 | echo "Error: Too many platforms found in $TEMP_SDK_DIR" |
Raphael | 7a508ae | 2011-02-01 12:48:48 -0800 | [diff] [blame] | 47 | echo "Expected one. Instead, found: ${PLATFORMS[@]}" |
Raphael | 0e4dd61 | 2010-04-16 17:37:25 -0700 | [diff] [blame] | 48 | exit 1 |
| 49 | fi |
Raphael | 0e4dd61 | 2010-04-16 17:37:25 -0700 | [diff] [blame] | 50 | |
| 51 | # Package USB Driver |
| 52 | if [[ -n "$USB_DRIVER_HOOK" ]]; then |
| 53 | $USB_DRIVER_HOOK $V $TEMP_SDK_DIR $TOPDIR |
| 54 | fi |
| 55 | |
| 56 | # Remove obsolete stuff from tools & platform |
| 57 | TOOLS=$TEMP_SDK_DIR/tools |
Raphael Moll | ff779c0 | 2010-08-05 13:30:39 -0700 | [diff] [blame] | 58 | PLATFORM_TOOLS=$TEMP_SDK_DIR/platform-tools |
Raphael | 0e4dd61 | 2010-04-16 17:37:25 -0700 | [diff] [blame] | 59 | LIB=$TEMP_SDK_DIR/tools/lib |
Raphael Moll | 1fe58f3 | 2010-11-11 15:58:28 -0800 | [diff] [blame] | 60 | rm $V $TOOLS/{dmtracedump,etc1tool,hprof-conv,sqlite3,zipalign} |
Raphael | 0e4dd61 | 2010-04-16 17:37:25 -0700 | [diff] [blame] | 61 | rm $V $LIB/*/swt.jar |
Raphael | f31a96a | 2011-09-08 16:42:12 -0700 | [diff] [blame^] | 62 | rm $V $PLATFORM_TOOLS/{adb,aapt,aidl,dx,dexdump,llvm-rs-cc} |
Raphael | 0e4dd61 | 2010-04-16 17:37:25 -0700 | [diff] [blame] | 63 | |
| 64 | # Copy all the new stuff in tools |
Raphael | 320d10e | 2011-05-26 12:16:35 -0700 | [diff] [blame] | 65 | # Note: some tools are first copied here and then moved in platform-tools |
Raphael | 0e4dd61 | 2010-04-16 17:37:25 -0700 | [diff] [blame] | 66 | cp $V $WIN_OUT_DIR/host/windows-x86/bin/*.{exe,dll} $TOOLS/ |
Raphael | 32d597b | 2011-01-13 16:59:09 -0800 | [diff] [blame] | 67 | # Remove some tools we don't want to take in the SDK |
| 68 | rm $V -f $TOOLS/{fastboot.exe,rs-spec-gen.exe,tblgen.exe} |
Raphael | 0e4dd61 | 2010-04-16 17:37:25 -0700 | [diff] [blame] | 69 | mkdir -pv $LIB/x86 |
| 70 | cp $V ${TOPDIR}prebuilt/windows/swt/swt.jar $LIB/x86/ |
| 71 | mkdir -pv $LIB/x86_64 |
| 72 | cp $V ${TOPDIR}prebuilt/windows-x86_64/swt/swt.jar $LIB/x86_64/ |
| 73 | |
Raphael | 0e4dd61 | 2010-04-16 17:37:25 -0700 | [diff] [blame] | 74 | # Put the JetCreator tools, content and docs (not available in the linux SDK) |
| 75 | JET=$TOOLS/Jet |
| 76 | JETCREATOR=$JET/JetCreator |
| 77 | JETDEMOCONTENT=$JET/demo_content |
| 78 | JETLOGICTEMPLATES=$JET/logic_templates |
| 79 | JETDOC=$TEMP_SDK_DIR/docs/JetCreator |
| 80 | |
| 81 | # need to rm these folders since a Mac SDK will have them and it might create a conflict |
| 82 | rm -rf $V $JET |
| 83 | rm -rf $V $JETDOC |
| 84 | |
| 85 | # now create fresh folders for JetCreator |
| 86 | mkdir $V $JET |
| 87 | mkdir $V $JETDOC |
| 88 | |
| 89 | cp -r $V ${TOPDIR}external/sonivox/jet_tools/JetCreator $JETCREATOR/ |
| 90 | cp -r $V ${TOPDIR}external/sonivox/jet_tools/JetCreator_content $JETDEMOCONTENT/ |
| 91 | cp -r $V ${TOPDIR}external/sonivox/jet_tools/logic_templates $JETLOGICTEMPLATES/ |
| 92 | chmod $V -R u+w $JETCREATOR # fixes an issue where Cygwin might copy the above as u+rx only |
Raphael Moll | 2f61396 | 2010-09-27 16:20:07 -0700 | [diff] [blame] | 93 | cp $V ${TOPDIR}prebuilt/windows/jetcreator/EASDLL.dll $JETCREATOR/ |
Raphael | 0e4dd61 | 2010-04-16 17:37:25 -0700 | [diff] [blame] | 94 | |
| 95 | cp $V ${TOPDIR}external/sonivox/docs/JET_Authoring_Guidelines.html $JETDOC/ |
| 96 | cp -r $V ${TOPDIR}external/sonivox/docs/JET_Authoring_Guidelines_files $JETDOC/ |
| 97 | cp $V ${TOPDIR}external/sonivox/docs/JET_Creator_User_Manual.html $JETDOC/ |
| 98 | cp -r $V ${TOPDIR}external/sonivox/docs/JET_Creator_User_Manual_files $JETDOC/ |
| 99 | |
| 100 | # Copy or move platform specific tools to the default platform. |
| 101 | cp $V ${TOPDIR}dalvik/dx/etc/dx.bat $PLATFORM_TOOLS/ |
Raphael | 32d597b | 2011-01-13 16:59:09 -0800 | [diff] [blame] | 102 | mv $V $TOOLS/{adb.exe,aapt.exe,aidl.exe,dexdump.exe} $PLATFORM_TOOLS/ |
Raphael | 32d597b | 2011-01-13 16:59:09 -0800 | [diff] [blame] | 103 | mv $V $TOOLS/Adb*.dll $PLATFORM_TOOLS/ |
Raphael | f31a96a | 2011-09-08 16:42:12 -0700 | [diff] [blame^] | 104 | mv $V $TOOLS/llvm-rs-cc.exe $PLATFORM_TOOLS/llvm-rs-cc.exe |
Raphael | 0e4dd61 | 2010-04-16 17:37:25 -0700 | [diff] [blame] | 105 | |
Raphael | 0e4dd61 | 2010-04-16 17:37:25 -0700 | [diff] [blame] | 106 | # Fix EOL chars to make window users happy - fix all files at the top level |
Raphael | 320d10e | 2011-05-26 12:16:35 -0700 | [diff] [blame] | 107 | # as well as all batch files including those in platform-tools/ |
Raphael Moll | 1fe58f3 | 2010-11-11 15:58:28 -0800 | [diff] [blame] | 108 | if [[ -x $UNIX2DOS ]]; then |
| 109 | find $TEMP_SDK_DIR -maxdepth 1 -name "*.[ht]*" -type f -print0 | xargs -0 $UNIX2DOS |
| 110 | find $TEMP_SDK_DIR -maxdepth 3 -name "*.bat" -type f -print0 | xargs -0 $UNIX2DOS |
| 111 | fi |
| 112 | |
Raphael | 7a508ae | 2011-02-01 12:48:48 -0800 | [diff] [blame] | 113 | # Just to make it easier on the build servers, we want fastboot and adb |
| 114 | # (and its DLLs) next to the new SDK. |
Raphael | 0e4dd61 | 2010-04-16 17:37:25 -0700 | [diff] [blame] | 115 | for i in fastboot.exe adb.exe AdbWinApi.dll AdbWinUsbApi.dll; do |
| 116 | cp -f $V $WIN_OUT_DIR/host/windows-x86/bin/$i $TEMP_SDK_DIR/../$i |
| 117 | done |
Raphael | 1adaa57 | 2011-01-27 13:26:44 -0800 | [diff] [blame] | 118 | |