|
| 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 | + |
0 commit comments