1#!/bin/bash 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# 17 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 23# depend on the sdk.git repo. This file is invoked by the makefile 24# at development/build/tools/windows_sdk.mk. 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 35set -e # any error stops the build 36 37# Verbose by default. Use -q to make more silent. 38V="" 39Q="" 40if [[ "$1" == "-q" ]]; then 41 Q="$1" 42 shift 43else 44 echo "Win SDK: $0 $*" 45 set -x # show bash commands; no need for V=-v 46fi 47 48TEMP_SDK_DIR=$1 49WIN_OUT_DIR=$2 50TOPDIR=${TOPDIR:-$3} 51 52# The unix2dos is provided by the APT package "tofrodos". However 53# as for ubuntu lucid, the package renamed the command to "todos". 54UNIX2DOS=$(which unix2dos || true) 55if [[ ! -x $UNIX2DOS ]]; then 56 UNIX2DOS=$(which todos || true) 57fi 58 59PLATFORMS=( $TEMP_SDK_DIR/platforms/* ) 60if [[ ${#PLATFORMS[@]} != 1 ]]; then 61 echo "Error: Too many platforms found in $TEMP_SDK_DIR" 62 echo "Expected one. Instead, found: ${PLATFORMS[@]}" 63 exit 1 64fi 65 66# Package USB Driver 67if [[ -n "$USB_DRIVER_HOOK" ]]; then 68 $USB_DRIVER_HOOK $V $TEMP_SDK_DIR $TOPDIR 69fi 70 71 72# Invoke atree to copy the files 73# TODO: pass down OUT_HOST_EXECUTABLE to get the right bin/atree directory 74${TOPDIR}out/host/linux-x86/bin/atree -f ${TOPDIR}development/build/sdk-windows-x86.atree \ 75 -I $WIN_OUT_DIR/host/windows-x86 \ 76 -I ${TOPDIR:-.} \ 77 -v "PLATFORM_NAME=android-$PLATFORM_VERSION" \ 78 -o $TEMP_SDK_DIR 79 80# Fix EOL chars to make window users happy - fix all files at the top level 81# as well as all batch files including those in platform-tools/ 82if [[ -x $UNIX2DOS ]]; then 83 find $TEMP_SDK_DIR -maxdepth 1 -name "*.[ht]*" -type f -print0 | xargs -0 $UNIX2DOS 84 find $TEMP_SDK_DIR -maxdepth 3 -name "*.bat" -type f -print0 | xargs -0 $UNIX2DOS 85fi 86 87# Just to make it easier on the build servers, we want fastboot and adb 88# (and its DLLs) next to the new SDK. 89for i in fastboot.exe adb.exe; do 90 cp -f $V $WIN_OUT_DIR/host/windows-x86/bin/$i $TEMP_SDK_DIR/../$i 91done 92 93for i in AdbWinApi.dll AdbWinUsbApi.dll; do 94 cp -f $V $WIN_OUT_DIR/host/windows-x86/lib/$i $TEMP_SDK_DIR/../$i 95done 96