Skip to content

Commit 0e4dd61

Browse files
author
Raphael
committed
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)
1 parent 67fa314 commit 0e4dd61

File tree

2 files changed

+187
-0
lines changed

2 files changed

+187
-0
lines changed

build/tools/patch_windows_sdk.sh

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
#!/bin/bash
2+
3+
# Verbose by default. Use -q to make more silent.
4+
V="-v"
5+
if [[ "$1" == "-q" ]]; then V=""; shift; fi
6+
7+
TEMP_SDK_DIR=$1
8+
WIN_OUT_DIR=$2
9+
TOPDIR=${TOPDIR:-$3}
10+
11+
PLATFORMS=( $TEMP_SDK_DIR/platforms/* )
12+
if [[ ${#PLATFORMS[@]} != 1 ]]; then
13+
echo "Error: Too many platforms found in $TEMP_SDK_DIR"
14+
echo "Only one was expected."
15+
echo "Instead, found: ${PLATFORMS[@]}"
16+
exit 1
17+
fi
18+
THE_PLATFORM=${PLATFORMS[0]}
19+
PLATFORM_TOOLS=$THE_PLATFORM/tools
20+
21+
# Package USB Driver
22+
if [[ -n "$USB_DRIVER_HOOK" ]]; then
23+
$USB_DRIVER_HOOK $V $TEMP_SDK_DIR $TOPDIR
24+
fi
25+
26+
# Remove obsolete stuff from tools & platform
27+
TOOLS=$TEMP_SDK_DIR/tools
28+
LIB=$TEMP_SDK_DIR/tools/lib
29+
rm $V $TOOLS/{adb,android,apkbuilder,ddms,dmtracedump,draw9patch,emulator,etc1tool}
30+
rm $V $TOOLS/{hierarchyviewer,hprof-conv,layoutopt,mksdcard,sqlite3,traceview,zipalign}
31+
rm $V $LIB/*/swt.jar
32+
rm $V $PLATFORM_TOOLS/{aapt,aidl,dx,dexdump}
33+
34+
# Copy all the new stuff in tools
35+
# Note: some tools are first copied here and then moved in platforms/<name>/tools/
36+
cp $V $WIN_OUT_DIR/host/windows-x86/bin/*.{exe,dll} $TOOLS/
37+
mkdir -pv $LIB/x86
38+
cp $V ${TOPDIR}prebuilt/windows/swt/swt.jar $LIB/x86/
39+
mkdir -pv $LIB/x86_64
40+
cp $V ${TOPDIR}prebuilt/windows-x86_64/swt/swt.jar $LIB/x86_64/
41+
42+
# Copy the SDK Setup (aka sdklauncher) to the root of the SDK (it was copied in tools above)
43+
# and move it also in SDK/tools/lib (so that tools updates can update the root one too)
44+
cp $TOOLS/sdklauncher.exe $TEMP_SDK_DIR/"SDK Setup.exe"
45+
mv $TOOLS/sdklauncher.exe $LIB/"SDK Setup.exe"
46+
47+
# Copy the emulator NOTICE in the tools dir
48+
cp $V ${TOPDIR}external/qemu/NOTICE $TOOLS/emulator_NOTICE.txt
49+
50+
# aapt under cygwin needs to have mgwz.dll
51+
[[ -n $NEED_MGWZ ]] && cp $V $CYG_MGWZ_PATH $TOOLS/
52+
53+
# Update a bunch of bat files
54+
cp $V ${TOPDIR}sdk/files/post_tools_install.bat $LIB/
55+
cp $V ${TOPDIR}sdk/files/find_java.bat $LIB/
56+
cp $V ${TOPDIR}sdk/apkbuilder/etc/apkbuilder.bat $TOOLS/
57+
cp $V ${TOPDIR}sdk/ddms/app/etc/ddms.bat $TOOLS/
58+
cp $V ${TOPDIR}sdk/traceview/etc/traceview.bat $TOOLS/
59+
cp $V ${TOPDIR}sdk/hierarchyviewer/etc/hierarchyviewer.bat $TOOLS/
60+
cp $V ${TOPDIR}sdk/layoutopt/app/etc/layoutopt.bat $TOOLS/
61+
cp $V ${TOPDIR}sdk/draw9patch/etc/draw9patch.bat $TOOLS/
62+
cp $V ${TOPDIR}sdk/sdkmanager/app/etc/android.bat $TOOLS/
63+
64+
# Put the JetCreator tools, content and docs (not available in the linux SDK)
65+
JET=$TOOLS/Jet
66+
JETCREATOR=$JET/JetCreator
67+
JETDEMOCONTENT=$JET/demo_content
68+
JETLOGICTEMPLATES=$JET/logic_templates
69+
JETDOC=$TEMP_SDK_DIR/docs/JetCreator
70+
71+
# need to rm these folders since a Mac SDK will have them and it might create a conflict
72+
rm -rf $V $JET
73+
rm -rf $V $JETDOC
74+
75+
# now create fresh folders for JetCreator
76+
mkdir $V $JET
77+
mkdir $V $JETDOC
78+
79+
cp -r $V ${TOPDIR}external/sonivox/jet_tools/JetCreator $JETCREATOR/
80+
cp -r $V ${TOPDIR}external/sonivox/jet_tools/JetCreator_content $JETDEMOCONTENT/
81+
cp -r $V ${TOPDIR}external/sonivox/jet_tools/logic_templates $JETLOGICTEMPLATES/
82+
chmod $V -R u+w $JETCREATOR # fixes an issue where Cygwin might copy the above as u+rx only
83+
cp $V ${TOPDIR}prebuilt/windows/jetcreator/EASDLL.dll $JETCREATOR/
84+
85+
cp $V ${TOPDIR}external/sonivox/docs/JET_Authoring_Guidelines.html $JETDOC/
86+
cp -r $V ${TOPDIR}external/sonivox/docs/JET_Authoring_Guidelines_files $JETDOC/
87+
cp $V ${TOPDIR}external/sonivox/docs/JET_Creator_User_Manual.html $JETDOC/
88+
cp -r $V ${TOPDIR}external/sonivox/docs/JET_Creator_User_Manual_files $JETDOC/
89+
90+
# Copy or move platform specific tools to the default platform.
91+
cp $V ${TOPDIR}dalvik/dx/etc/dx.bat $PLATFORM_TOOLS/
92+
mv $V $TOOLS/{aapt.exe,aidl.exe,dexdump.exe} $PLATFORM_TOOLS/
93+
94+
# When building under cygwin, mgwz.dll must be both in SDK/tools for zipalign
95+
# and in SDK/platform/XYZ/tools/ for aapt
96+
[[ -n $NEED_MGWZ ]] && cp $V $TOOLS/mgwz.dll $PLATFORM_TOOLS/
97+
98+
# Fix EOL chars to make window users happy - fix all files at the top level
99+
# as well as all batch files including those in platforms/<name>/tools/
100+
find $TEMP_SDK_DIR -maxdepth 1 -name "*.[ht]*" -type f -print0 | xargs -0 unix2dos
101+
find $TEMP_SDK_DIR -maxdepth 3 -name "*.bat" -type f -print0 | xargs -0 unix2dos
102+
103+
# Just to make it easier on the build servers, we want fastboot and adb (and its DLLs)
104+
# next to the new SDK, so up one dir.
105+
for i in fastboot.exe adb.exe AdbWinApi.dll AdbWinUsbApi.dll; do
106+
cp -f $V $WIN_OUT_DIR/host/windows-x86/bin/$i $TEMP_SDK_DIR/../$i
107+
done

build/tools/windows_sdk.mk

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Makefile to build the Windows SDK under linux.
2+
#
3+
# This file is included by build/core/Makefile when a PRODUCT-sdk-win_sdk build
4+
# is requested.
5+
#
6+
# Summary of operations:
7+
# - create a regular Linux SDK
8+
# - build a few Windows tools
9+
# - mirror the linux SDK directory and patch it with the Windows tools
10+
#
11+
# This way we avoid the headache of building a full SDK in MinGW mode, which is
12+
# made complicated by the fact the build system does not support cross-compilation.
13+
14+
# We can only use this under Linux with the mingw32 package installed.
15+
ifneq ($(shell uname),Linux)
16+
$(error Linux is required to create a Windows SDK)
17+
endif
18+
ifeq ($(strip $(shell which i586-mingw32msvc-gcc 2>/dev/null)),)
19+
$(error MinGW is required to build a Windows SDK. Please 'apt-get install mingw32')
20+
endif
21+
ifeq ($(strip $(shell which unix2dos 2>/dev/null)),)
22+
$(error Need a unix2dos command. Please 'apt-get install tofrodos')
23+
endif
24+
25+
WIN_TARGETS := \
26+
aapt adb aidl \
27+
emulator etc1tool \
28+
dexdump dmtracedump \
29+
fastboot \
30+
hprof-conv \
31+
mksdcard \
32+
prebuilt \
33+
sdklauncher sqlite3 \
34+
zipalign
35+
36+
# LINUX_SDK_NAME/DIR is set in build/core/Makefile
37+
WIN_SDK_NAME := $(subst $(HOST_OS)-$(HOST_ARCH),windows,$(LINUX_SDK_NAME))
38+
WIN_SDK_DIR := $(subst $(HOST_OS)-$(HOST_ARCH),windows,$(LINUX_SDK_DIR))
39+
WIN_SDK_ZIP := $(WIN_SDK_DIR)/$(WIN_SDK_NAME).zip
40+
41+
$(call dist-for-goals, win_sdk, $(WIN_SDK_ZIP))
42+
43+
.PHONY: win_sdk winsdk-tools
44+
45+
define winsdk-banner
46+
$(info )
47+
$(info ====== [Windows SDK] $1 ======)
48+
$(info )
49+
endef
50+
51+
define winsdk-info
52+
$(info LINUX_SDK_NAME: $(LINUX_SDK_NAME))
53+
$(info WIN_SDK_NAME : $(WIN_SDK_NAME))
54+
$(info WIN_SDK_DIR : $(WIN_SDK_DIR))
55+
$(info WIN_SDK_ZIP : $(WIN_SDK_ZIP))
56+
endef
57+
58+
win_sdk: $(WIN_SDK_ZIP)
59+
$(call winsdk-banner,Done)
60+
61+
winsdk-tools: acp
62+
$(call winsdk-banner,Build Windows Tools)
63+
$(hide) USE_MINGW=1 $(MAKE) PRODUCT-$(TARGET_PRODUCT)-$(strip $(WIN_TARGETS))
64+
65+
$(WIN_SDK_ZIP): winsdk-tools sdk
66+
$(call winsdk-banner,Build $(WIN_SDK_NAME))
67+
$(call winsdk-info)
68+
$(hide) rm -rf $(WIN_SDK_DIR)
69+
$(hide) mkdir -p $(WIN_SDK_DIR)
70+
$(hide) cp -rf $(LINUX_SDK_DIR)/$(LINUX_SDK_NAME) $(WIN_SDK_DIR)/$(WIN_SDK_NAME)
71+
$(hide) USB_DRIVER_HOOK=$(USB_DRIVER_HOOK) \
72+
$(TOPDIR)development/build/tools/patch_windows_sdk.sh \
73+
$(subst @,-q,$(hide)) \
74+
$(WIN_SDK_DIR)/$(WIN_SDK_NAME) $(OUT_DIR) $(TOPDIR)
75+
$(hide) ( \
76+
cd $(WIN_SDK_DIR) && \
77+
rm -f $(WIN_SDK_NAME).zip && \
78+
zip -rq $(subst @,-q,$(hide)) $(WIN_SDK_NAME).zip $(WIN_SDK_NAME) \
79+
)
80+
@echo "Windows SDK generated at $(WIN_SDK_ZIP)"

0 commit comments

Comments
 (0)