blob: 14acdac62a75d4d12980fc32742ec6554e90bb44 [file] [log] [blame]
Raphael0e4dd612010-04-16 17:37:25 -07001#!/bin/bash
2
Raphael1adaa572011-01-27 13:26:44 -08003# 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
Raphael0e4dd612010-04-16 17:37:25 -070019# Verbose by default. Use -q to make more silent.
20V="-v"
21if [[ "$1" == "-q" ]]; then V=""; shift; fi
22
23TEMP_SDK_DIR=$1
24WIN_OUT_DIR=$2
25TOPDIR=${TOPDIR:-$3}
26
Raphael1adaa572011-01-27 13:26:44 -080027# The unix2dos is provided by the APT package "tofrodos". However
28# as of ubuntu lucid, the package renamed the command to "todos".
29UNIX2DOS=`which unix2dos`
30if [[ ! -x $UNIX2DOS ]]; then
31 UNIX2DOS=`which todos`
32fi
33
Raphael0e4dd612010-04-16 17:37:25 -070034PLATFORMS=( $TEMP_SDK_DIR/platforms/* )
35if [[ ${#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
40fi
Raphael0e4dd612010-04-16 17:37:25 -070041
42# Package USB Driver
43if [[ -n "$USB_DRIVER_HOOK" ]]; then
44 $USB_DRIVER_HOOK $V $TEMP_SDK_DIR $TOPDIR
45fi
46
47# Remove obsolete stuff from tools & platform
48TOOLS=$TEMP_SDK_DIR/tools
Raphael59b02d02010-10-08 15:41:01 -070049PLATFORM_TOOLS=$TEMP_SDK_DIR/platform-tools
Raphael0e4dd612010-04-16 17:37:25 -070050LIB=$TEMP_SDK_DIR/tools/lib
Xavier Ducrohet76afc002010-09-27 13:58:45 -070051rm $V $TOOLS/{android,apkbuilder,ddms,dmtracedump,draw9patch,emulator,etc1tool}
Raphael0e4dd612010-04-16 17:37:25 -070052rm $V $TOOLS/{hierarchyviewer,hprof-conv,layoutopt,mksdcard,sqlite3,traceview,zipalign}
53rm $V $LIB/*/swt.jar
Xavier Ducrohet76afc002010-09-27 13:58:45 -070054rm $V $PLATFORM_TOOLS/{adb,aapt,aidl,dx,dexdump}
Raphael0e4dd612010-04-16 17:37:25 -070055
56# Copy all the new stuff in tools
57# Note: some tools are first copied here and then moved in platforms/<name>/tools/
58cp $V $WIN_OUT_DIR/host/windows-x86/bin/*.{exe,dll} $TOOLS/
59mkdir -pv $LIB/x86
60cp $V ${TOPDIR}prebuilt/windows/swt/swt.jar $LIB/x86/
61mkdir -pv $LIB/x86_64
62cp $V ${TOPDIR}prebuilt/windows-x86_64/swt/swt.jar $LIB/x86_64/
63
Raphael59b02d02010-10-08 15:41:01 -070064# Copy the SDK Manager (aka sdklauncher) to the root of the SDK (it was copied in tools above)
Raphael0e4dd612010-04-16 17:37:25 -070065# and move it also in SDK/tools/lib (so that tools updates can update the root one too)
Raphael59b02d02010-10-08 15:41:01 -070066cp $TOOLS/sdklauncher.exe $TEMP_SDK_DIR/"SDK Manager.exe"
67mv $TOOLS/sdklauncher.exe $LIB/"SDK Manager.exe"
Raphael0e4dd612010-04-16 17:37:25 -070068
69# Copy the emulator NOTICE in the tools dir
70cp $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
Raphael59b02d02010-10-08 15:41:01 -070076cp $V ${TOPDIR}sdk/files/post_tools_install.bat $LIB/
77cp $V ${TOPDIR}sdk/files/find_java.bat $LIB/
78cp $V ${TOPDIR}sdk/apkbuilder/etc/apkbuilder.bat $TOOLS/
79cp $V ${TOPDIR}sdk/ddms/app/etc/ddms.bat $TOOLS/
80cp $V ${TOPDIR}sdk/traceview/etc/traceview.bat $TOOLS/
Raphaelcca5d182010-10-14 11:25:01 -070081if [ -f ${TOPDIR}sdk/hierarchyviewer2/app/etc/hierarchyviewer.bat ]; then
82 cp $V ${TOPDIR}sdk/hierarchyviewer2/app/etc/hierarchyviewer.bat $TOOLS/
83else
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]"
86fi
Raphael59b02d02010-10-08 15:41:01 -070087cp $V ${TOPDIR}sdk/layoutopt/app/etc/layoutopt.bat $TOOLS/
88cp $V ${TOPDIR}sdk/draw9patch/etc/draw9patch.bat $TOOLS/
89cp $V ${TOPDIR}sdk/sdkmanager/app/etc/android.bat $TOOLS/
Raphael0e4dd612010-04-16 17:37:25 -070090
91# Put the JetCreator tools, content and docs (not available in the linux SDK)
92JET=$TOOLS/Jet
93JETCREATOR=$JET/JetCreator
94JETDEMOCONTENT=$JET/demo_content
95JETLOGICTEMPLATES=$JET/logic_templates
96JETDOC=$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
99rm -rf $V $JET
100rm -rf $V $JETDOC
101
102# now create fresh folders for JetCreator
103mkdir $V $JET
104mkdir $V $JETDOC
105
106cp -r $V ${TOPDIR}external/sonivox/jet_tools/JetCreator $JETCREATOR/
107cp -r $V ${TOPDIR}external/sonivox/jet_tools/JetCreator_content $JETDEMOCONTENT/
108cp -r $V ${TOPDIR}external/sonivox/jet_tools/logic_templates $JETLOGICTEMPLATES/
109chmod $V -R u+w $JETCREATOR # fixes an issue where Cygwin might copy the above as u+rx only
Xavier Ducrohet76afc002010-09-27 13:58:45 -0700110cp $V ${TOPDIR}prebuilt/windows/jetcreator/EASDLL.dll $JETCREATOR/
Raphael0e4dd612010-04-16 17:37:25 -0700111
112cp $V ${TOPDIR}external/sonivox/docs/JET_Authoring_Guidelines.html $JETDOC/
113cp -r $V ${TOPDIR}external/sonivox/docs/JET_Authoring_Guidelines_files $JETDOC/
114cp $V ${TOPDIR}external/sonivox/docs/JET_Creator_User_Manual.html $JETDOC/
115cp -r $V ${TOPDIR}external/sonivox/docs/JET_Creator_User_Manual_files $JETDOC/
116
117# Copy or move platform specific tools to the default platform.
118cp $V ${TOPDIR}dalvik/dx/etc/dx.bat $PLATFORM_TOOLS/
Xavier Ducrohet76afc002010-09-27 13:58:45 -0700119mv $V $TOOLS/{adb.exe,aapt.exe,aidl.exe,dexdump.exe} $TOOLS/Adb*.dll $PLATFORM_TOOLS/
Raphael0e4dd612010-04-16 17:37:25 -0700120
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/
Raphael1adaa572011-01-27 13:26:44 -0800127if [[ -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
130fi
Raphael0e4dd612010-04-16 17:37:25 -0700131
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.
134for 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
136done
Raphael1adaa572011-01-27 13:26:44 -0800137