Raphael | 0e4dd61 | 2010-04-16 17:37:25 -0700 | [diff] [blame] | 1 | #!/bin/bash |
Raphael | bc16220 | 2011-09-14 21:12:15 -0700 | [diff] [blame^] | 2 | # |
| 3 | # Copyright (C) 2009 The Android Open Source Project |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | # |
Raphael | 0e4dd61 | 2010-04-16 17:37:25 -0700 | [diff] [blame] | 17 | |
Raphael Moll | 1fe58f3 | 2010-11-11 15:58:28 -0800 | [diff] [blame] | 18 | # This script takes a Linux SDK, cleans it and injects the necessary Windows |
| 19 | # binaries needed by the SDK. The script has 2 parts: |
| 20 | # - development/tools/build/path_windows_sdk.sh to process the |
| 21 | # platform-dependent folders and files. |
| 22 | # - sdk/build/patch_windows_sdk.sh to process folder and files which |
Raphael | 7a508ae | 2011-02-01 12:48:48 -0800 | [diff] [blame] | 23 | # depend on the sdk.git repo. This file is invoked by the makefile |
Raphael | 320d10e | 2011-05-26 12:16:35 -0700 | [diff] [blame] | 24 | # at development/build/tools/windows_sdk.mk. |
Raphael Moll | 1fe58f3 | 2010-11-11 15:58:28 -0800 | [diff] [blame] | 25 | # |
| 26 | # Input arguments: |
| 27 | # -q = Optional arg to make this silent. Must be given first. |
| 28 | # $1 = Temporary SDK directory, that is the Linux SDK being patched into |
| 29 | # a Windows one. |
| 30 | # $2 = The out/host/windows directory, which contains the new Windows |
| 31 | # binaries to use. |
| 32 | # $3 = An optional replacement for $TOPDIR (inherited from the Android |
| 33 | # build system), which is the top directory where Android is located. |
| 34 | |
Raphael | 7a508ae | 2011-02-01 12:48:48 -0800 | [diff] [blame] | 35 | set -e # any error stops the build |
| 36 | |
Raphael | 0e4dd61 | 2010-04-16 17:37:25 -0700 | [diff] [blame] | 37 | # Verbose by default. Use -q to make more silent. |
Raphael | 7a508ae | 2011-02-01 12:48:48 -0800 | [diff] [blame] | 38 | V="" |
Raphael Moll | 1fe58f3 | 2010-11-11 15:58:28 -0800 | [diff] [blame] | 39 | Q="" |
| 40 | if [[ "$1" == "-q" ]]; then |
| 41 | Q="$1" |
Raphael Moll | 1fe58f3 | 2010-11-11 15:58:28 -0800 | [diff] [blame] | 42 | shift |
Raphael | 7a508ae | 2011-02-01 12:48:48 -0800 | [diff] [blame] | 43 | else |
| 44 | echo "Win SDK: $0 $*" |
| 45 | set -x # show bash commands; no need for V=-v |
Raphael Moll | 1fe58f3 | 2010-11-11 15:58:28 -0800 | [diff] [blame] | 46 | fi |
Raphael | 0e4dd61 | 2010-04-16 17:37:25 -0700 | [diff] [blame] | 47 | |
| 48 | TEMP_SDK_DIR=$1 |
| 49 | WIN_OUT_DIR=$2 |
| 50 | TOPDIR=${TOPDIR:-$3} |
| 51 | |
Raphael Moll | 1fe58f3 | 2010-11-11 15:58:28 -0800 | [diff] [blame] | 52 | # The unix2dos is provided by the APT package "tofrodos". However |
Raphael | 7a508ae | 2011-02-01 12:48:48 -0800 | [diff] [blame] | 53 | # as for ubuntu lucid, the package renamed the command to "todos". |
| 54 | UNIX2DOS=$(which unix2dos || true) |
Raphael Moll | 1fe58f3 | 2010-11-11 15:58:28 -0800 | [diff] [blame] | 55 | if [[ ! -x $UNIX2DOS ]]; then |
Raphael | 7a508ae | 2011-02-01 12:48:48 -0800 | [diff] [blame] | 56 | UNIX2DOS=$(which todos || true) |
Raphael Moll | 1fe58f3 | 2010-11-11 15:58:28 -0800 | [diff] [blame] | 57 | fi |
| 58 | |
Raphael | 0e4dd61 | 2010-04-16 17:37:25 -0700 | [diff] [blame] | 59 | PLATFORMS=( $TEMP_SDK_DIR/platforms/* ) |
| 60 | if [[ ${#PLATFORMS[@]} != 1 ]]; then |
| 61 | echo "Error: Too many platforms found in $TEMP_SDK_DIR" |
Raphael | 7a508ae | 2011-02-01 12:48:48 -0800 | [diff] [blame] | 62 | echo "Expected one. Instead, found: ${PLATFORMS[@]}" |
Raphael | 0e4dd61 | 2010-04-16 17:37:25 -0700 | [diff] [blame] | 63 | exit 1 |
| 64 | fi |
Raphael | 0e4dd61 | 2010-04-16 17:37:25 -0700 | [diff] [blame] | 65 | |
| 66 | # Package USB Driver |
| 67 | if [[ -n "$USB_DRIVER_HOOK" ]]; then |
| 68 | $USB_DRIVER_HOOK $V $TEMP_SDK_DIR $TOPDIR |
| 69 | fi |
| 70 | |
Raphael | 0e4dd61 | 2010-04-16 17:37:25 -0700 | [diff] [blame] | 71 | |
Raphael | bc16220 | 2011-09-14 21:12:15 -0700 | [diff] [blame^] | 72 | # Invoke atree to copy the files |
| 73 | atree -f ${TOPDIR}development/build/sdk-windows-x86.atree \ |
| 74 | -I $WIN_OUT_DIR/host/windows-x86 \ |
| 75 | -I ${TOPDIR:-.} \ |
| 76 | -o $TEMP_SDK_DIR |
Raphael | 0e4dd61 | 2010-04-16 17:37:25 -0700 | [diff] [blame] | 77 | |
Raphael | 0e4dd61 | 2010-04-16 17:37:25 -0700 | [diff] [blame] | 78 | # 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] | 79 | # as well as all batch files including those in platform-tools/ |
Raphael Moll | 1fe58f3 | 2010-11-11 15:58:28 -0800 | [diff] [blame] | 80 | if [[ -x $UNIX2DOS ]]; then |
| 81 | find $TEMP_SDK_DIR -maxdepth 1 -name "*.[ht]*" -type f -print0 | xargs -0 $UNIX2DOS |
| 82 | find $TEMP_SDK_DIR -maxdepth 3 -name "*.bat" -type f -print0 | xargs -0 $UNIX2DOS |
| 83 | fi |
| 84 | |
Raphael | 7a508ae | 2011-02-01 12:48:48 -0800 | [diff] [blame] | 85 | # Just to make it easier on the build servers, we want fastboot and adb |
| 86 | # (and its DLLs) next to the new SDK. |
Raphael | 0e4dd61 | 2010-04-16 17:37:25 -0700 | [diff] [blame] | 87 | for i in fastboot.exe adb.exe AdbWinApi.dll AdbWinUsbApi.dll; do |
| 88 | cp -f $V $WIN_OUT_DIR/host/windows-x86/bin/$i $TEMP_SDK_DIR/../$i |
| 89 | done |
Raphael | 1adaa57 | 2011-01-27 13:26:44 -0800 | [diff] [blame] | 90 | |