Home | History | Annotate | Download | only in tools
      1 # Makefile to build the SDK repository packages.
      2 
      3 .PHONY: sdk_repo
      4 
      5 SDK_REPO_DEPS :=
      6 SDK_REPO_XML_ARGS :=
      7 
      8 # Define the name of a package zip file to generate
      9 # $1=OS (e.g. linux-x86, windows, etc)
     10 # $2=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
     11 # $3=package to create (e.g. tools, docs, etc.)
     12 #
     13 define sdk-repo-pkg-zip
     14 $(dir $(2))/sdk-repo-$(1)-$(3)-$(FILE_NAME_TAG).zip
     15 endef
     16 
     17 # Defines the rule to build an SDK repository package by zipping all
     18 # the content of the given directory.
     19 # E.g. given a folder out/host/linux.../sdk/android-eng-sdk/tools
     20 # this generates an sdk-repo-linux-tools that contains tools/*
     21 #
     22 # $1=OS (e.g. linux-x86, windows, etc)
     23 # $2=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
     24 # $3=package to create (e.g. tools, docs, etc.)
     25 #
     26 # The rule depends on the SDK zip file, which is defined by $2.
     27 #
     28 define mk-sdk-repo-pkg-1
     29 $(call sdk-repo-pkg-zip,$(1),$(2),$(3)): $(2)
     30 	@echo "Building SDK repository package $(3) from $(notdir $(2))"
     31 	$(hide) cd $(basename $(2)) && \
     32 			zip -9rq ../$(notdir $(call sdk-repo-pkg-zip,$(1),$(2),$(3))) $(3)/*
     33 $(call dist-for-goals, sdk_repo, $(call sdk-repo-pkg-zip,$(1),$(2),$(3)))
     34 SDK_REPO_XML_ARGS += $(3) $(1) \
     35 	$(call sdk-repo-pkg-zip,$(1),$(2),$(3)):$(notdir $(call sdk-repo-pkg-zip,$(1),$(2),$(3)))
     36 endef
     37 
     38 # Defines the rule to build an SDK repository package when the
     39 # package directory contains a single platform-related inner directory.
     40 # E.g. given a folder out/host/linux.../sdk/android-eng-sdk/samples/android-N
     41 # this generates an sdk-repo-linux-samples that contains android-N/*
     42 #
     43 # $1=OS (e.g. linux-x86, windows, etc)
     44 # $2=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
     45 # $3=package to create (e.g. platforms, samples, etc.)
     46 #
     47 # The rule depends on the SDK zip file, which is defined by $2.
     48 #
     49 define mk-sdk-repo-pkg-2
     50 $(call sdk-repo-pkg-zip,$(1),$(2),$(3)): $(2)
     51 	@echo "Building SDK repository package $(3) from $(notdir $(2))"
     52 	$(hide) cd $(basename $(2))/$(3) && \
     53 			zip -9rq ../../$(notdir $(call sdk-repo-pkg-zip,$(1),$(2),$(3))) *
     54 $(call dist-for-goals, sdk_repo, $(call sdk-repo-pkg-zip,$(1),$(2),$(3)))
     55 SDK_REPO_XML_ARGS += $(3) $(1) \
     56 	$(call sdk-repo-pkg-zip,$(1),$(2),$(3)):$(notdir $(call sdk-repo-pkg-zip,$(1),$(2),$(3)))
     57 endef
     58 
     59 # Defines the rule to build an SDK repository package when the
     60 # package directory contains 3 levels from the sdk dir, for example
     61 # to package SDK/extra/android/support or SDK/system-images/android-N/armeabi.
     62 # Because we do not know the intermediary directory name, this only works
     63 # if each directory contains a single sub-directory (e.g. sdk/$4/*/* must be
     64 # unique.)
     65 #
     66 # $1=OS (e.g. linux-x86, windows, etc)
     67 # $2=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
     68 # $3=package to create (e.g. system-images, support, etc.)
     69 # $4=the root of directory to package in the sdk (e.g. extra/android).
     70 #    this must be a 2-segment path, the last one can be *.
     71 #
     72 # The rule depends on the SDK zip file, which is defined by $2.
     73 #
     74 define mk-sdk-repo-pkg-3
     75 $(call sdk-repo-pkg-zip,$(1),$(2),$(3)): $(2)
     76 	@echo "Building SDK repository package $(3) from $(notdir $(2))"
     77 	$(hide) cd $(basename $(2))/$(4) && \
     78 			zip -9rq ../../../$(notdir $(call sdk-repo-pkg-zip,$(1),$(2),$(3))) *
     79 $(call dist-for-goals, sdk_repo, $(call sdk-repo-pkg-zip,$(1),$(2),$(3)))
     80 SDK_REPO_XML_ARGS += $(3) $(1) \
     81 	$(call sdk-repo-pkg-zip,$(1),$(2),$(3)):$(notdir $(call sdk-repo-pkg-zip,$(1),$(2),$(3)))
     82 endef
     83 
     84 # Defines the rule to build an SDK sources package.
     85 #
     86 # $1=OS (e.g. linux-x86, windows, etc)
     87 # $2=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
     88 # $3=package to create, must be "sources"
     89 #
     90 define mk-sdk-repo-sources
     91 $(call sdk-repo-pkg-zip,$(1),$(2),$(3)): $(2) $(TOPDIR)development/sdk/source_source.properties
     92 	@echo "Building SDK sources package"
     93 	$(hide) $(TOPDIR)development/build/tools/mk_sources_zip.py \
     94 			$(TOPDIR)development/sdk/source_source.properties \
     95 			$(call sdk-repo-pkg-zip,$(1),$(2),$(3)) \
     96 			$(TOPDIR).
     97 $(call dist-for-goals, sdk_repo, $(call sdk-repo-pkg-zip,$(1),$(2),$(3)))
     98 SDK_REPO_XML_ARGS += $(3) $(1) \
     99 	$(call sdk-repo-pkg-zip,$(1),$(2),$(3)):$(notdir $(call sdk-repo-pkg-zip,$(1),$(2),$(3)))
    100 endef
    101 
    102 # -----------------------------------------------------------------
    103 # Rules for win_sdk
    104 
    105 ifneq ($(WIN_SDK_ZIP),)
    106 
    107 # docs, platforms and samples have nothing OS-dependent right now.
    108 $(eval $(call mk-sdk-repo-pkg-1,windows,$(WIN_SDK_ZIP),tools))
    109 $(eval $(call mk-sdk-repo-pkg-1,windows,$(WIN_SDK_ZIP),platform-tools))
    110 
    111 SDK_REPO_DEPS += \
    112 	$(call sdk-repo-pkg-zip,windows,$(WIN_SDK_ZIP),tools) \
    113         $(call sdk-repo-pkg-zip,windows,$(WIN_SDK_ZIP),platform-tools)
    114 
    115 endif
    116 
    117 # -----------------------------------------------------------------
    118 # Rules for main host sdk
    119 
    120 ifneq ($(filter sdk win_sdk,$(MAKECMDGOALS)),)
    121 
    122 $(eval $(call mk-sdk-repo-pkg-1,$(HOST_OS),$(MAIN_SDK_ZIP),tools))
    123 $(eval $(call mk-sdk-repo-pkg-1,$(HOST_OS),$(MAIN_SDK_ZIP),platform-tools))
    124 $(eval $(call mk-sdk-repo-pkg-1,$(HOST_OS),$(MAIN_SDK_ZIP),docs))
    125 $(eval $(call mk-sdk-repo-pkg-2,$(HOST_OS),$(MAIN_SDK_ZIP),platforms))
    126 $(eval $(call mk-sdk-repo-pkg-2,$(HOST_OS),$(MAIN_SDK_ZIP),samples))
    127 $(eval $(call mk-sdk-repo-pkg-3,$(HOST_OS),$(MAIN_SDK_ZIP),system-images,system-images/*))
    128 $(eval $(call mk-sdk-repo-pkg-3,$(HOST_OS),$(MAIN_SDK_ZIP),support,extras/android))
    129 $(eval $(call mk-sdk-repo-sources,$(HOST_OS),$(MAIN_SDK_ZIP),sources))
    130 
    131 SDK_REPO_DEPS += \
    132 		$(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),tools) \
    133 		$(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),platform-tools) \
    134 		$(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),docs) \
    135 		$(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),platforms) \
    136 		$(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),samples) \
    137 		$(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),system-images) \
    138 		$(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),support) \
    139 		$(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),sources)
    140 
    141 endif
    142 
    143 # -----------------------------------------------------------------
    144 # Rules for sdk addon
    145 
    146 ifneq ($(ADDON_SDK_ZIP),)
    147 
    148 # ADDON_SDK_ZIP is defined in build/core/tasks/sdk-addon.sh and is
    149 # already packaged correctly. All we have to do is dist it with
    150 # a different destination name.
    151 
    152 RENAMED_ADDON_ZIP := $(ADDON_SDK_ZIP):$(notdir $(call sdk-repo-pkg-zip,$(HOST_OS),$(ADDON_SDK_ZIP),addon))
    153 
    154 $(call dist-for-goals, sdk_repo, $(RENAMED_ADDON_ZIP))
    155 
    156 # Also generate the addon.xml using the latest schema and the renamed addon zip
    157 
    158 SDK_ADDON_XML := $(dir $(ADDON_SDK_ZIP))/addon.xml
    159 
    160 SDK_ADDON_XSD := \
    161 	$(lastword \
    162 	  $(wildcard \
    163 	    $(TOPDIR)sdk/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-addon-*.xsd \
    164 	))
    165 
    166 $(SDK_ADDON_XML): $(ADDON_SDK_ZIP)
    167 	$(hide) $(TOPDIR)development/build/tools/mk_sdk_repo_xml.sh \
    168 		$(SDK_ADDON_XML) $(SDK_ADDON_XSD) add-on $(HOST_OS) $(RENAMED_ADDON_ZIP)
    169 
    170 $(call dist-for-goals, sdk_repo, $(SDK_ADDON_XML))
    171 
    172 endif
    173 
    174 # -----------------------------------------------------------------
    175 # Rules for the SDK Repository XML
    176 
    177 SDK_REPO_XML := $(HOST_OUT)/sdk/repository.xml
    178 
    179 ifneq ($(SDK_REPO_XML_ARGS),)
    180 
    181 # Pickup the most recent xml schema
    182 SDK_REPO_XSD := \
    183 	$(lastword \
    184 	  $(wildcard \
    185 	    $(TOPDIR)sdk/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-repository-*.xsd \
    186 	))
    187 
    188 $(SDK_REPO_XML): $(SDK_REPO_DEPS)
    189 	$(hide) $(TOPDIR)development/build/tools/mk_sdk_repo_xml.sh \
    190 		$(SDK_REPO_XML) $(SDK_REPO_XSD) $(SDK_REPO_XML_ARGS)
    191 
    192 $(call dist-for-goals, sdk_repo, $(SDK_REPO_XML))
    193 
    194 else
    195 
    196 $(SDK_REPO_XML): ;
    197 
    198 endif
    199 
    200 # -----------------------------------------------------------------
    201 
    202 sdk_repo: $(SDK_REPO_DEPS) $(SDK_REPO_XML)
    203 	@echo "Packing of SDK repository done"
    204 
    205