Skip to content

Commit 922ee89

Browse files
author
Raphael
committed
Merge 2ff496b: 'Build SDK repository.' Do not merge.
When the build is invoked with the fake target "sdk_repo" and a main target of sdk, win_sdk or sdk_addon, we now create packages in DIST_DIR that can directly be used to populate the SDK Repository. This is quite close to how we actually distribute the SDK. Change-Id: I671e8ff1bc2a6e9f5c097241d65da1cfdde21154
1 parent 1a6a849 commit 922ee89

File tree

2 files changed

+115
-9
lines changed

2 files changed

+115
-9
lines changed

build/tools/sdk_repo.mk

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Makefile to build the SDK repository packages.
2+
3+
.PHONY: sdk_repo
4+
5+
# Define the name of a package zip file to generate
6+
# $1=OS (e.g. linux-x86, windows, etc)
7+
# $2=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
8+
# $3=package to create (e.g. tools, docs, etc.)
9+
#
10+
define sdk-repo-pkg-zip
11+
$(dir $(2))/sdk-repo-$(1)-$(3).zip
12+
endef
13+
14+
# Defines the rule to build an SDK repository package by zipping all
15+
# the content of the given directory.
16+
# E.g. given a folder out/host/linux.../sdk/android-eng-sdk/tools
17+
# this generates an sdk-repo-linux-tools that contains tools/*
18+
#
19+
# $1=OS (e.g. linux-x86, windows, etc)
20+
# $2=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
21+
# $3=package to create (e.g. tools, docs, etc.)
22+
#
23+
# The rule depends on the SDK zip file, which is defined by $2.
24+
#
25+
define mk-sdk-repo-pkg-1
26+
$(call sdk-repo-pkg-zip,$(1),$(2),$(3)): $(2)
27+
@echo "Building SDK repository package $(3) from $(notdir $(2))"
28+
$(hide) cd $(dir $(2)) && \
29+
zip -9rq ../$(notdir $(call sdk-repo-pkg-zip,$(1),$(2),$(3))) \
30+
$(basename $(2))/*
31+
$(call dist-for-goals, sdk_repo, $(call sdk-repo-pkg-zip,$(1),$(2),$(3)))
32+
endef
33+
34+
# Defines the rule to build an SDK repository package when the
35+
# package directory contains a single platform-related inner directory.
36+
# E.g. given a folder out/host/linux.../sdk/android-eng-sdk/samples/android-N
37+
# this generates an sdk-repo-linux-samples that contains android-N/*
38+
#
39+
# $1=OS (e.g. linux-x86, windows, etc)
40+
# $2=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
41+
# $3=package to create (e.g. platforms, samples, etc.)
42+
#
43+
# The rule depends on the SDK zip file, which is defined by $2.
44+
#
45+
define mk-sdk-repo-pkg-2
46+
$(call sdk-repo-pkg-zip,$(1),$(2),$(3)): $(2)
47+
@echo "Building SDK repository package $(3) from $(notdir $(2))"
48+
$(hide) cd $(dir $(2))/$(3) && \
49+
zip -9rq ../../$(notdir $(call sdk-repo-pkg-zip,$(1),$(2),$(3))) \
50+
$(basename $(2))/*
51+
$(call dist-for-goals, sdk_repo, $(call sdk-repo-pkg-zip,$(1),$(2),$(3)))
52+
endef
53+
54+
55+
SDK_REPO_DEPS :=
56+
57+
# Rules for win_sdk
58+
59+
ifneq ($(WIN_SDK_ZIP),)
60+
61+
# docs, platforms and samples have nothing OS-dependent right now.
62+
$(eval $(call mk-sdk-repo-pkg-1,windows,$(WIN_SDK_ZIP),tools))
63+
$(eval $(call mk-sdk-repo-pkg-1,windows,$(WIN_SDK_ZIP),platform-tools))
64+
65+
SDK_REPO_DEPS += \
66+
$(call sdk-repo-pkg-zip,windows,$(WIN_SDK_ZIP),tools) \
67+
$(call sdk-repo-pkg-zip,windows,$(WIN_SDK_ZIP),platform-tools)
68+
69+
endif
70+
71+
# Rules for main host sdk
72+
73+
ifneq ($(filter sdk win_sdk,$(MAKECMDGOALS)),)
74+
75+
$(eval $(call mk-sdk-repo-pkg-1,$(HOST_OS),$(MAIN_SDK_ZIP),tools))
76+
$(eval $(call mk-sdk-repo-pkg-1,$(HOST_OS),$(MAIN_SDK_ZIP),platform-tools))
77+
$(eval $(call mk-sdk-repo-pkg-1,$(HOST_OS),$(MAIN_SDK_ZIP),docs))
78+
$(eval $(call mk-sdk-repo-pkg-2,$(HOST_OS),$(MAIN_SDK_ZIP),platforms))
79+
$(eval $(call mk-sdk-repo-pkg-2,$(HOST_OS),$(MAIN_SDK_ZIP),samples))
80+
81+
SDK_REPO_DEPS += \
82+
$(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),tools) \
83+
$(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),platform-tools) \
84+
$(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),docs) \
85+
$(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),platforms) \
86+
$(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),samples) \
87+
88+
endif
89+
90+
# Rules for sdk addon
91+
92+
ifneq ($(ADDON_SDK_ZIP),)
93+
94+
# ADDON_SDK_ZIP is defined in build/core/tasks/sdk-addon.sh and is
95+
# already packaged correctly. All we have to do is dist it with
96+
# a different destination name.
97+
98+
$(call dist-for-goals, sdk_repo, \
99+
$(ADDON_SDK_ZIP):$(notdir $(call sdk-repo-pkg-zip,$(HOST_OS),$(ADDON_SDK_ZIP),addon)))
100+
101+
endif
102+
103+
104+
sdk_repo: $(SDK_REPO_DEPS)
105+
@echo "Packing of SDK repository done"
106+

build/tools/windows_sdk.mk

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ WIN_TARGETS := \
3333
sdklauncher sqlite3 \
3434
zipalign
3535

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
36+
# MAIN_SDK_NAME/DIR is set in build/core/Makefile
37+
WIN_SDK_NAME := $(subst $(HOST_OS)-$(HOST_ARCH),windows,$(MAIN_SDK_NAME))
38+
WIN_SDK_DIR := $(subst $(HOST_OS)-$(HOST_ARCH),windows,$(MAIN_SDK_DIR))
39+
WIN_SDK_ZIP := $(WIN_SDK_DIR)/$(WIN_SDK_NAME).zip
4040

4141
$(call dist-for-goals, win_sdk, $(WIN_SDK_ZIP))
4242

@@ -49,10 +49,10 @@ $(info )
4949
endef
5050

5151
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))
52+
$(info MAIN_SDK_NAME: $(MAIN_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))
5656
endef
5757

5858
win_sdk: $(WIN_SDK_ZIP)
@@ -67,7 +67,7 @@ $(WIN_SDK_ZIP): winsdk-tools sdk
6767
$(call winsdk-info)
6868
$(hide) rm -rf $(WIN_SDK_DIR)
6969
$(hide) mkdir -p $(WIN_SDK_DIR)
70-
$(hide) cp -rf $(LINUX_SDK_DIR)/$(LINUX_SDK_NAME) $(WIN_SDK_DIR)/$(WIN_SDK_NAME)
70+
$(hide) cp -rf $(MAIN_SDK_DIR)/$(MAIN_SDK_NAME) $(WIN_SDK_DIR)/$(WIN_SDK_NAME)
7171
$(hide) USB_DRIVER_HOOK=$(USB_DRIVER_HOOK) \
7272
$(TOPDIR)development/build/tools/patch_windows_sdk.sh \
7373
$(subst @,-q,$(hide)) \

0 commit comments

Comments
 (0)