Makefile to create Windows SDK under Linux.

The makefile makes it possible to "make PRODUCT-sdk-win_sdk".
It builds the Linux SDK, mirrors it as a Windows SDK and then use the shell
script to patch in all the Windows binaries.

(Merge master Change Ie24f765b)
This commit is contained in:
Raphael
2010-04-16 17:37:25 -07:00
parent 67fa314265
commit 0e4dd61849
2 changed files with 187 additions and 0 deletions

107
build/tools/patch_windows_sdk.sh Executable file
View File

@@ -0,0 +1,107 @@
#!/bin/bash
# Verbose by default. Use -q to make more silent.
V="-v"
if [[ "$1" == "-q" ]]; then V=""; shift; fi
TEMP_SDK_DIR=$1
WIN_OUT_DIR=$2
TOPDIR=${TOPDIR:-$3}
PLATFORMS=( $TEMP_SDK_DIR/platforms/* )
if [[ ${#PLATFORMS[@]} != 1 ]]; then
echo "Error: Too many platforms found in $TEMP_SDK_DIR"
echo "Only one was expected."
echo "Instead, found: ${PLATFORMS[@]}"
exit 1
fi
THE_PLATFORM=${PLATFORMS[0]}
PLATFORM_TOOLS=$THE_PLATFORM/tools
# Package USB Driver
if [[ -n "$USB_DRIVER_HOOK" ]]; then
$USB_DRIVER_HOOK $V $TEMP_SDK_DIR $TOPDIR
fi
# Remove obsolete stuff from tools & platform
TOOLS=$TEMP_SDK_DIR/tools
LIB=$TEMP_SDK_DIR/tools/lib
rm $V $TOOLS/{adb,android,apkbuilder,ddms,dmtracedump,draw9patch,emulator,etc1tool}
rm $V $TOOLS/{hierarchyviewer,hprof-conv,layoutopt,mksdcard,sqlite3,traceview,zipalign}
rm $V $LIB/*/swt.jar
rm $V $PLATFORM_TOOLS/{aapt,aidl,dx,dexdump}
# Copy all the new stuff in tools
# Note: some tools are first copied here and then moved in platforms/<name>/tools/
cp $V $WIN_OUT_DIR/host/windows-x86/bin/*.{exe,dll} $TOOLS/
mkdir -pv $LIB/x86
cp $V ${TOPDIR}prebuilt/windows/swt/swt.jar $LIB/x86/
mkdir -pv $LIB/x86_64
cp $V ${TOPDIR}prebuilt/windows-x86_64/swt/swt.jar $LIB/x86_64/
# Copy the SDK Setup (aka sdklauncher) to the root of the SDK (it was copied in tools above)
# and move it also in SDK/tools/lib (so that tools updates can update the root one too)
cp $TOOLS/sdklauncher.exe $TEMP_SDK_DIR/"SDK Setup.exe"
mv $TOOLS/sdklauncher.exe $LIB/"SDK Setup.exe"
# Copy the emulator NOTICE in the tools dir
cp $V ${TOPDIR}external/qemu/NOTICE $TOOLS/emulator_NOTICE.txt
# aapt under cygwin needs to have mgwz.dll
[[ -n $NEED_MGWZ ]] && cp $V $CYG_MGWZ_PATH $TOOLS/
# Update a bunch of bat files
cp $V ${TOPDIR}sdk/files/post_tools_install.bat $LIB/
cp $V ${TOPDIR}sdk/files/find_java.bat $LIB/
cp $V ${TOPDIR}sdk/apkbuilder/etc/apkbuilder.bat $TOOLS/
cp $V ${TOPDIR}sdk/ddms/app/etc/ddms.bat $TOOLS/
cp $V ${TOPDIR}sdk/traceview/etc/traceview.bat $TOOLS/
cp $V ${TOPDIR}sdk/hierarchyviewer/etc/hierarchyviewer.bat $TOOLS/
cp $V ${TOPDIR}sdk/layoutopt/app/etc/layoutopt.bat $TOOLS/
cp $V ${TOPDIR}sdk/draw9patch/etc/draw9patch.bat $TOOLS/
cp $V ${TOPDIR}sdk/sdkmanager/app/etc/android.bat $TOOLS/
# Put the JetCreator tools, content and docs (not available in the linux SDK)
JET=$TOOLS/Jet
JETCREATOR=$JET/JetCreator
JETDEMOCONTENT=$JET/demo_content
JETLOGICTEMPLATES=$JET/logic_templates
JETDOC=$TEMP_SDK_DIR/docs/JetCreator
# need to rm these folders since a Mac SDK will have them and it might create a conflict
rm -rf $V $JET
rm -rf $V $JETDOC
# now create fresh folders for JetCreator
mkdir $V $JET
mkdir $V $JETDOC
cp -r $V ${TOPDIR}external/sonivox/jet_tools/JetCreator $JETCREATOR/
cp -r $V ${TOPDIR}external/sonivox/jet_tools/JetCreator_content $JETDEMOCONTENT/
cp -r $V ${TOPDIR}external/sonivox/jet_tools/logic_templates $JETLOGICTEMPLATES/
chmod $V -R u+w $JETCREATOR # fixes an issue where Cygwin might copy the above as u+rx only
cp $V ${TOPDIR}prebuilt/windows/jetcreator/EASDLL.dll $JETCREATOR/
cp $V ${TOPDIR}external/sonivox/docs/JET_Authoring_Guidelines.html $JETDOC/
cp -r $V ${TOPDIR}external/sonivox/docs/JET_Authoring_Guidelines_files $JETDOC/
cp $V ${TOPDIR}external/sonivox/docs/JET_Creator_User_Manual.html $JETDOC/
cp -r $V ${TOPDIR}external/sonivox/docs/JET_Creator_User_Manual_files $JETDOC/
# Copy or move platform specific tools to the default platform.
cp $V ${TOPDIR}dalvik/dx/etc/dx.bat $PLATFORM_TOOLS/
mv $V $TOOLS/{aapt.exe,aidl.exe,dexdump.exe} $PLATFORM_TOOLS/
# When building under cygwin, mgwz.dll must be both in SDK/tools for zipalign
# and in SDK/platform/XYZ/tools/ for aapt
[[ -n $NEED_MGWZ ]] && cp $V $TOOLS/mgwz.dll $PLATFORM_TOOLS/
# Fix EOL chars to make window users happy - fix all files at the top level
# as well as all batch files including those in platforms/<name>/tools/
find $TEMP_SDK_DIR -maxdepth 1 -name "*.[ht]*" -type f -print0 | xargs -0 unix2dos
find $TEMP_SDK_DIR -maxdepth 3 -name "*.bat" -type f -print0 | xargs -0 unix2dos
# Just to make it easier on the build servers, we want fastboot and adb (and its DLLs)
# next to the new SDK, so up one dir.
for i in fastboot.exe adb.exe AdbWinApi.dll AdbWinUsbApi.dll; do
cp -f $V $WIN_OUT_DIR/host/windows-x86/bin/$i $TEMP_SDK_DIR/../$i
done

View File

@@ -0,0 +1,80 @@
# Makefile to build the Windows SDK under linux.
#
# This file is included by build/core/Makefile when a PRODUCT-sdk-win_sdk build
# is requested.
#
# Summary of operations:
# - create a regular Linux SDK
# - build a few Windows tools
# - mirror the linux SDK directory and patch it with the Windows tools
#
# This way we avoid the headache of building a full SDK in MinGW mode, which is
# made complicated by the fact the build system does not support cross-compilation.
# We can only use this under Linux with the mingw32 package installed.
ifneq ($(shell uname),Linux)
$(error Linux is required to create a Windows SDK)
endif
ifeq ($(strip $(shell which i586-mingw32msvc-gcc 2>/dev/null)),)
$(error MinGW is required to build a Windows SDK. Please 'apt-get install mingw32')
endif
ifeq ($(strip $(shell which unix2dos 2>/dev/null)),)
$(error Need a unix2dos command. Please 'apt-get install tofrodos')
endif
WIN_TARGETS := \
aapt adb aidl \
emulator etc1tool \
dexdump dmtracedump \
fastboot \
hprof-conv \
mksdcard \
prebuilt \
sdklauncher sqlite3 \
zipalign
# LINUX_SDK_NAME/DIR is set in build/core/Makefile
WIN_SDK_NAME := $(subst $(HOST_OS)-$(HOST_ARCH),windows,$(LINUX_SDK_NAME))
WIN_SDK_DIR := $(subst $(HOST_OS)-$(HOST_ARCH),windows,$(LINUX_SDK_DIR))
WIN_SDK_ZIP := $(WIN_SDK_DIR)/$(WIN_SDK_NAME).zip
$(call dist-for-goals, win_sdk, $(WIN_SDK_ZIP))
.PHONY: win_sdk winsdk-tools
define winsdk-banner
$(info )
$(info ====== [Windows SDK] $1 ======)
$(info )
endef
define winsdk-info
$(info LINUX_SDK_NAME: $(LINUX_SDK_NAME))
$(info WIN_SDK_NAME : $(WIN_SDK_NAME))
$(info WIN_SDK_DIR : $(WIN_SDK_DIR))
$(info WIN_SDK_ZIP : $(WIN_SDK_ZIP))
endef
win_sdk: $(WIN_SDK_ZIP)
$(call winsdk-banner,Done)
winsdk-tools: acp
$(call winsdk-banner,Build Windows Tools)
$(hide) USE_MINGW=1 $(MAKE) PRODUCT-$(TARGET_PRODUCT)-$(strip $(WIN_TARGETS))
$(WIN_SDK_ZIP): winsdk-tools sdk
$(call winsdk-banner,Build $(WIN_SDK_NAME))
$(call winsdk-info)
$(hide) rm -rf $(WIN_SDK_DIR)
$(hide) mkdir -p $(WIN_SDK_DIR)
$(hide) cp -rf $(LINUX_SDK_DIR)/$(LINUX_SDK_NAME) $(WIN_SDK_DIR)/$(WIN_SDK_NAME)
$(hide) USB_DRIVER_HOOK=$(USB_DRIVER_HOOK) \
$(TOPDIR)development/build/tools/patch_windows_sdk.sh \
$(subst @,-q,$(hide)) \
$(WIN_SDK_DIR)/$(WIN_SDK_NAME) $(OUT_DIR) $(TOPDIR)
$(hide) ( \
cd $(WIN_SDK_DIR) && \
rm -f $(WIN_SDK_NAME).zip && \
zip -rq $(subst @,-q,$(hide)) $(WIN_SDK_NAME).zip $(WIN_SDK_NAME) \
)
@echo "Windows SDK generated at $(WIN_SDK_ZIP)"