blob: 9bf58b9b07acd96b8acf800eda9ddfba067c9288 [file] [log] [blame]
Raphael0e4dd612010-04-16 17:37:25 -07001#!/bin/bash
Raphaelbc162202011-09-14 21:12:15 -07002#
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#
Raphael0e4dd612010-04-16 17:37:25 -070017
Raphael Moll1fe58f32010-11-11 15:58:28 -080018# 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
Raphael7a508ae2011-02-01 12:48:48 -080023# depend on the sdk.git repo. This file is invoked by the makefile
Raphael320d10e2011-05-26 12:16:35 -070024# at development/build/tools/windows_sdk.mk.
Raphael Moll1fe58f32010-11-11 15:58:28 -080025#
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
Raphael7a508ae2011-02-01 12:48:48 -080035set -e # any error stops the build
36
Raphael0e4dd612010-04-16 17:37:25 -070037# Verbose by default. Use -q to make more silent.
Raphael7a508ae2011-02-01 12:48:48 -080038V=""
Raphael Moll1fe58f32010-11-11 15:58:28 -080039Q=""
40if [[ "$1" == "-q" ]]; then
41 Q="$1"
Raphael Moll1fe58f32010-11-11 15:58:28 -080042 shift
Raphael7a508ae2011-02-01 12:48:48 -080043else
44 echo "Win SDK: $0 $*"
45 set -x # show bash commands; no need for V=-v
Raphael Moll1fe58f32010-11-11 15:58:28 -080046fi
Raphael0e4dd612010-04-16 17:37:25 -070047
48TEMP_SDK_DIR=$1
49WIN_OUT_DIR=$2
50TOPDIR=${TOPDIR:-$3}
51
Raphael Moll1fe58f32010-11-11 15:58:28 -080052# The unix2dos is provided by the APT package "tofrodos". However
Raphael7a508ae2011-02-01 12:48:48 -080053# as for ubuntu lucid, the package renamed the command to "todos".
54UNIX2DOS=$(which unix2dos || true)
Raphael Moll1fe58f32010-11-11 15:58:28 -080055if [[ ! -x $UNIX2DOS ]]; then
Raphael7a508ae2011-02-01 12:48:48 -080056 UNIX2DOS=$(which todos || true)
Raphael Moll1fe58f32010-11-11 15:58:28 -080057fi
58
Raphael0e4dd612010-04-16 17:37:25 -070059PLATFORMS=( $TEMP_SDK_DIR/platforms/* )
60if [[ ${#PLATFORMS[@]} != 1 ]]; then
61 echo "Error: Too many platforms found in $TEMP_SDK_DIR"
Raphael7a508ae2011-02-01 12:48:48 -080062 echo "Expected one. Instead, found: ${PLATFORMS[@]}"
Raphael0e4dd612010-04-16 17:37:25 -070063 exit 1
64fi
Raphael0e4dd612010-04-16 17:37:25 -070065
66# Package USB Driver
67if [[ -n "$USB_DRIVER_HOOK" ]]; then
68 $USB_DRIVER_HOOK $V $TEMP_SDK_DIR $TOPDIR
69fi
70
Raphael0e4dd612010-04-16 17:37:25 -070071
Raphaelbc162202011-09-14 21:12:15 -070072# Invoke atree to copy the files
73atree -f ${TOPDIR}development/build/sdk-windows-x86.atree \
74 -I $WIN_OUT_DIR/host/windows-x86 \
75 -I ${TOPDIR:-.} \
76 -o $TEMP_SDK_DIR
Raphael0e4dd612010-04-16 17:37:25 -070077
Raphael0e4dd612010-04-16 17:37:25 -070078# Fix EOL chars to make window users happy - fix all files at the top level
Raphael320d10e2011-05-26 12:16:35 -070079# as well as all batch files including those in platform-tools/
Raphael Moll1fe58f32010-11-11 15:58:28 -080080if [[ -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
83fi
84
Raphael7a508ae2011-02-01 12:48:48 -080085# Just to make it easier on the build servers, we want fastboot and adb
86# (and its DLLs) next to the new SDK.
Raphael0e4dd612010-04-16 17:37:25 -070087for 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
89done
Raphael1adaa572011-01-27 13:26:44 -080090