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
15ifneq ($(shell uname),Linux)
16$(error Linux is required to create a Windows SDK)
17endif
18ifeq ($(strip $(shell which unix2dos todos 2>/dev/null)),)
19$(error Need a unix2dos command. Please 'apt-get install tofrodos')
20endif
21
22# This is the list of targets that we want to generate as
23# Windows executables. All the targets specified here are located in
24# the topdir/development directory and are somehow platform-dependent.
25WIN_TARGETS := \
26	aapt \
27	aapt2 \
28	adb \
29	aidl \
30	aprotoc \
31	bcc_compat \
32	clang \
33	etc1tool \
34	dexdump dmtracedump \
35	fastboot \
36	hprof-conv \
37	libaapt2_jni \
38	lld \
39	llvm-rs-cc \
40	sqlite3 \
41	zipalign \
42	split-select
43
44# b/150355628 - we want the 64-bit libaapt2_jni for loading as JNI in 64-bit JVMs.
45WIN_TARGETS += \
46	libaapt2_jni_64
47
48WIN_TARGETS := $(foreach t,$(WIN_TARGETS),$(ALL_MODULES.host_cross_$(t).INSTALLED))
49
50WIN_TARGETS += prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/x86_64-w64-mingw32/bin/libwinpthread-1.dll
51WIN_TARGETS += prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/x86_64-w64-mingw32/lib32/libwinpthread-1.dll
52
53# MAIN_SDK_NAME/DIR is set in build/core/Makefile
54WIN_SDK_NAME := $(subst $(HOST_OS)-$(SDK_HOST_ARCH),windows,$(MAIN_SDK_NAME))
55WIN_SDK_DIR  := $(subst $(HOST_OS)-$(SDK_HOST_ARCH),windows,$(MAIN_SDK_DIR))
56WIN_SDK_ZIP  := $(WIN_SDK_DIR)/$(WIN_SDK_NAME).zip
57
58$(call dist-for-goals, win_sdk, $(WIN_SDK_ZIP))
59
60# b/36697262 - we want the 64-bit libaapt2_jni and its dependencies
61ifdef HOST_CROSS_2ND_ARCH
62$(call dist-for-goals,win_sdk,$(ALL_MODULES.host_cross_libaapt2_jni$(HOST_CROSS_2ND_ARCH_MODULE_SUFFIX).BUILT):lib64/libaapt2_jni.dll)
63$(call dist-for-goals, win_sdk, prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/x86_64-w64-mingw32/bin/libwinpthread-1.dll:lib64/libwinpthread-1.dll)
64endif
65
66.PHONY: win_sdk winsdk-tools
67
68win_sdk: $(WIN_SDK_ZIP)
69
70winsdk-tools: $(WIN_TARGETS)
71
72$(WIN_SDK_ZIP): $(WIN_TARGETS) $(INTERNAL_SDK_TARGET) $(SOONG_ZIP) \
73		$(HOST_OUT_EXECUTABLES)/atree \
74		development/build/tools/patch_windows_sdk.sh \
75		development/build/sdk-windows-x86.atree
76	@echo Build Windows SDK $(WIN_SDK_NAME)
77	$(hide) rm -rf $(WIN_SDK_DIR) $@
78	$(hide) mkdir -p $(WIN_SDK_DIR)
79	$(hide) cp -rf $(MAIN_SDK_DIR)/$(MAIN_SDK_NAME) $(WIN_SDK_DIR)/$(WIN_SDK_NAME)
80	$(hide) USB_DRIVER_HOOK=$(USB_DRIVER_HOOK) \
81		PLATFORM_VERSION=$(PLATFORM_VERSION) \
82		ATREE_STRIP=$(HOST_STRIP) \
83		development/build/tools/patch_windows_sdk.sh -q \
84		$(WIN_SDK_DIR)/$(WIN_SDK_NAME) $(OUT_DIR) $(TOPDIR)
85	$(hide) $(SOONG_ZIP) -d -C $(WIN_SDK_DIR) -D $(WIN_SDK_DIR)/$(WIN_SDK_NAME) -o $@
86