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 SDK_EXTRAS_DEPS     :=
      8 SDK_EXTRAS_XML_ARGS :=
      9 SDK_SYSIMG_DEPS     :=
     10 SDK_SYSIMG_XML_ARGS :=
     11 
     12 # Define the name of a package zip file to generate
     13 # $1=OS (e.g. linux-x86, windows, etc)
     14 # $2=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
     15 # $3=package to create (e.g. tools, docs, etc.)
     16 #
     17 define sdk-repo-pkg-zip
     18 $(dir $(2))/sdk-repo-$(1)-$(3)-$(FILE_NAME_TAG).zip
     19 endef
     20 
     21 # Defines the rule to build an SDK repository package by zipping all
     22 # the content of the given directory.
     23 # E.g. given a folder out/host/linux.../sdk/android-eng-sdk/tools
     24 # this generates an sdk-repo-linux-tools that contains tools/*
     25 #
     26 # $1=variable where to accumulate args for mk_sdk_repo_xml.
     27 # $2=OS (e.g. linux-x86, windows, etc)
     28 # $3=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
     29 # $4=package to create (e.g. tools, docs, etc.)
     30 #
     31 # The rule depends on the SDK zip file, which is defined by $2.
     32 #
     33 define mk-sdk-repo-pkg-1
     34 $(call sdk-repo-pkg-zip,$(2),$(3),$(4)): $(3)
     35 	@echo "Building SDK repository package $(4) from $(notdir $(3))"
     36 	$(hide) cd $(basename $(3)) && \
     37 	        rm  -f   ../$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4))) && \
     38 	        zip -9rq ../$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4))) $(4)/*
     39 $(call dist-for-goals, sdk_repo, $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
     40 $(1) += $(4) $(2) \
     41     $(call sdk-repo-pkg-zip,$(2),$(3),$(4)):$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
     42 endef
     43 
     44 # Defines the rule to build an SDK repository package when the
     45 # package directory contains a single platform-related inner directory.
     46 # E.g. given a folder out/host/linux.../sdk/android-eng-sdk/samples/android-N
     47 # this generates an sdk-repo-linux-samples that contains android-N/*
     48 #
     49 # $1=variable where to accumulate args for mk_sdk_repo_xml.
     50 # $2=OS (e.g. linux-x86, windows, etc)
     51 # $3=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
     52 # $4=package to create (e.g. platforms, samples, etc.)
     53 #
     54 # The rule depends on the SDK zip file, which is defined by $2.
     55 #
     56 define mk-sdk-repo-pkg-2
     57 $(call sdk-repo-pkg-zip,$(2),$(3),$(4)): $(3)
     58 	@echo "Building SDK repository package $(4) from $(notdir $(3))"
     59 	$(hide) cd $(basename $(3))/$(4) && \
     60 	        rm  -f   ../../$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4))) && \
     61 	        zip -9rq ../../$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4))) *
     62 $(call dist-for-goals, sdk_repo, $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
     63 $(1) += $(4) $(2) \
     64     $(call sdk-repo-pkg-zip,$(2),$(3),$(4)):$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
     65 endef
     66 
     67 # Defines the rule to build an SDK repository package when the
     68 # package directory contains 3 levels from the sdk dir, for example
     69 # to package SDK/extra/android/support or SDK/system-images/android-N/armeabi.
     70 # Because we do not know the intermediary directory name, this only works
     71 # if each directory contains a single sub-directory (e.g. sdk/$4/*/* must be
     72 # unique.)
     73 #
     74 # $1=variable where to accumulate args for mk_sdk_repo_xml.
     75 # $2=OS (e.g. linux-x86, windows, etc)
     76 # $3=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
     77 # $4=package to create (e.g. system-images, support, etc.)
     78 # $5=the root of directory to package in the sdk (e.g. extra/android).
     79 #    this must be a 2-segment path, the last one can be *.
     80 #
     81 # The rule depends on the SDK zip file, which is defined by $2.
     82 #
     83 define mk-sdk-repo-pkg-3
     84 $(call sdk-repo-pkg-zip,$(2),$(3),$(4)): $(3)
     85 	@echo "Building SDK repository package $(4) from $(notdir $(3))"
     86 	$(hide) cd $(basename $(3))/$(5) && \
     87 	        rm  -f   ../../../$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4))) && \
     88 	        zip -9rq ../../../$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4))) *
     89 $(call dist-for-goals, sdk_repo, $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
     90 $(1) += $(4) $(2) \
     91     $(call sdk-repo-pkg-zip,$(2),$(3),$(4)):$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
     92 endef
     93 
     94 # Defines the rule to build an SDK sources package.
     95 #
     96 # $1=variable where to accumulate args for mk_sdk_repo_xml.
     97 # $2=OS (e.g. linux-x86, windows, etc)
     98 # $3=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
     99 # $4=package to create, must be "sources"
    100 #
    101 define mk-sdk-repo-sources
    102 $(call sdk-repo-pkg-zip,$(2),$(3),$(4)): $(3) development/build/tools/mk_sources_zip.py $(HOST_OUT)/development/sdk/source_source.properties
    103 	@echo "Building SDK sources package"
    104 	development/build/tools/mk_sources_zip.py --exec-zip \
    105 	            $(HOST_OUT)/development/sdk/source_source.properties \
    106 	            $$@ .
    107 $(call dist-for-goals, sdk_repo, $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
    108 $(1) += $(4) $(2) \
    109     $(call sdk-repo-pkg-zip,$(2),$(3),$(4)):$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
    110 endef
    111 
    112 # Defines the rule to build an XML file for a package.
    113 #
    114 # $1=output file
    115 # $2=schema file
    116 # $3=deps
    117 # $4=args
    118 define mk-sdk-repo-xml
    119 $(1): $$(XMLLINT) development/build/tools/mk_sdk_repo_xml.sh $(2) $(3)
    120 	XMLLINT=$$(XMLLINT) development/build/tools/mk_sdk_repo_xml.sh $$@ $(2) $(4)
    121 
    122 $$(call dist-for-goals,sdk_repo,$(1))
    123 endef
    124 
    125 # -----------------------------------------------------------------
    126 # Rules for main host sdk
    127 
    128 ifneq ($(filter sdk win_sdk,$(MAKECMDGOALS)),)
    129 
    130 # Similarly capture all sys-img.xml that are now split out of repository.xml
    131 $(eval $(call mk-sdk-repo-pkg-3,SDK_SYSIMG_XML_ARGS,$(HOST_OS),$(MAIN_SDK_ZIP),system-images,system-images/*))
    132 
    133 SDK_SYSIMG_DEPS += \
    134     $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),system-images) \
    135 
    136 # All these go in the main repository.xml
    137 $(eval $(call mk-sdk-repo-pkg-2,SDK_REPO_XML_ARGS,$(HOST_OS),$(MAIN_SDK_ZIP),build-tools))
    138 $(eval $(call mk-sdk-repo-pkg-1,SDK_REPO_XML_ARGS,$(HOST_OS),$(MAIN_SDK_ZIP),platform-tools))
    139 $(eval $(call mk-sdk-repo-pkg-1,SDK_REPO_XML_ARGS,$(HOST_OS),$(MAIN_SDK_ZIP),docs))
    140 $(eval $(call mk-sdk-repo-pkg-2,SDK_REPO_XML_ARGS,$(HOST_OS),$(MAIN_SDK_ZIP),platforms))
    141 $(eval $(call mk-sdk-repo-pkg-2,SDK_REPO_XML_ARGS,$(HOST_OS),$(MAIN_SDK_ZIP),samples))
    142 $(eval $(call mk-sdk-repo-sources,SDK_REPO_XML_ARGS,$(HOST_OS),$(MAIN_SDK_ZIP),sources))
    143 
    144 SDK_REPO_DEPS += \
    145     $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),build-tools) \
    146     $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),platform-tools) \
    147     $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),docs) \
    148     $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),platforms) \
    149     $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),samples) \
    150     $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),sources)
    151 
    152 endif
    153 
    154 # -----------------------------------------------------------------
    155 # Rules for win_sdk
    156 
    157 ifneq ($(WIN_SDK_ZIP),)
    158 
    159 # docs, platforms and samples have nothing OS-dependent right now.
    160 $(eval $(call mk-sdk-repo-pkg-2,SDK_REPO_XML_ARGS,windows,$(WIN_SDK_ZIP),build-tools))
    161 $(eval $(call mk-sdk-repo-pkg-1,SDK_REPO_XML_ARGS,windows,$(WIN_SDK_ZIP),platform-tools))
    162 
    163 SDK_REPO_DEPS += \
    164     $(call sdk-repo-pkg-zip,windows,$(WIN_SDK_ZIP),build-tools) \
    165     $(call sdk-repo-pkg-zip,windows,$(WIN_SDK_ZIP),platform-tools)
    166 
    167 endif
    168 
    169 # -----------------------------------------------------------------
    170 # Pickup the most recent xml schema for repository and add-on
    171 
    172 SDK_REPO_XSD := \
    173     $(lastword \
    174       $(wildcard \
    175         prebuilts/devtools/repository/sdk-repository-*.xsd \
    176     ))
    177 
    178 SDK_ADDON_XSD := \
    179     $(lastword \
    180       $(wildcard \
    181         prebuilts/devtools/repository/sdk-addon-*.xsd \
    182     ))
    183 
    184 SDK_SYSIMG_XSD := \
    185     $(lastword \
    186       $(wildcard \
    187         prebuilts/devtools/repository/sdk-sys-img-*.xsd \
    188     ))
    189 
    190 
    191 # -----------------------------------------------------------------
    192 # Rules for sdk addon
    193 
    194 ifneq ($(filter sdk_addon,$(MAKECMDGOALS)),)
    195 ifneq ($(ADDON_SDK_ZIP),)
    196 
    197 # ADDON_SDK_ZIP is defined in build/core/tasks/sdk-addon.sh and is
    198 # already packaged correctly. All we have to do is dist it with
    199 # a different destination name.
    200 
    201 RENAMED_ADDON_ZIP := $(ADDON_SDK_ZIP):$(notdir $(call sdk-repo-pkg-zip,$(HOST_OS),$(ADDON_SDK_ZIP),addon))
    202 
    203 $(call dist-for-goals, sdk_repo, $(RENAMED_ADDON_ZIP))
    204 
    205 # Also generate the addon.xml using the latest schema and the renamed addon zip
    206 
    207 SDK_ADDON_XML := $(dir $(ADDON_SDK_ZIP))/addon.xml
    208 
    209 $(eval $(call mk-sdk-repo-xml,$(SDK_ADDON_XML),$(SDK_ADDON_XSD),$(ADDON_SDK_ZIP),add-on $(HOST_OS) $(RENAMED_ADDON_ZIP)))
    210 
    211 SDK_ADDON_XML :=
    212 RENAMED_ADDON_ZIP :=
    213 
    214 endif
    215 
    216 ifneq ($(ADDON_SDK_IMG_ZIP),)
    217 
    218 # Copy/rename the ADDON_SDK_IMG_ZIP file as an sdk-repo zip in the dist dir
    219 
    220 RENAMED_ADDON_IMG_ZIP := $(ADDON_SDK_IMG_ZIP):$(notdir $(call sdk-repo-pkg-zip,$(HOST_OS),$(ADDON_SDK_IMG_ZIP),system-images))
    221 
    222 $(call dist-for-goals, sdk_repo, $(RENAMED_ADDON_IMG_ZIP))
    223 
    224 # Generate the system-image XML for the addon sys-img
    225 
    226 SDK_ADDON_IMG_XML := $(dir $(ADDON_SDK_ZIP))/addon-sys-img.xml
    227 
    228 $(eval $(call mk-sdk-repo-xml,$(SDK_ADDON_IMG_XML),$(SDK_SYSIMG_XSD),$(ADDON_SDK_IMG_ZIP),system-image $(HOST_OS) $(RENAMED_ADDON_IMG_ZIP)))
    229 
    230 SDK_ADDON_IMG_XML :=
    231 RENAMED_ADDON_IMG_ZIP :=
    232 
    233 endif
    234 endif
    235 
    236 # -----------------------------------------------------------------
    237 # Rules for the SDK Repository XML
    238 
    239 SDK_REPO_XML   := $(MAIN_SDK_DIR)/repository.xml
    240 SDK_EXTRAS_XML := $(MAIN_SDK_DIR)/repo-extras.xml
    241 SDK_SYSIMG_XML := $(MAIN_SDK_DIR)/repo-sys-img.xml
    242 
    243 ifneq ($(SDK_REPO_XML_ARGS),)
    244 $(eval $(call mk-sdk-repo-xml,$(SDK_REPO_XML),$(SDK_REPO_XSD),$(SDK_REPO_DEPS),$(SDK_REPO_XML_ARGS)))
    245 else
    246 SDK_REPO_XML :=
    247 endif
    248 
    249 
    250 ifneq ($(SDK_EXTRAS_XML_ARGS),)
    251 $(eval $(call mk-sdk-repo-xml,$(SDK_EXTRAS_XML),$(SDK_ADDON_XSD),$(SDK_EXTRAS_DEPS),$(SDK_EXTRAS_XML_ARGS)))
    252 else
    253 SDK_EXTRAS_XML :=
    254 endif
    255 
    256 
    257 ifneq ($(SDK_SYSIMG_XML_ARGS),)
    258 $(eval $(call mk-sdk-repo-xml,$(SDK_SYSIMG_XML),$(SDK_SYSIMG_XSD),$(SDK_SYSIMG_DEPS),$(SDK_SYSIMG_XML_ARGS)))
    259 else
    260 SDK_SYSIMG_XML :=
    261 endif
    262 
    263 # -----------------------------------------------------------------
    264 
    265 sdk_repo: $(SDK_REPO_DEPS) $(SDK_REPO_XML) $(SDK_EXTRAS_XML) $(SDK_SYSIMG_XML)
    266 
    267 SDK_REPO_DEPS :=
    268 SDK_REPO_XML :=
    269 SDK_REPO_XML_ARGS :=
    270 SDK_EXTRAS_DEPS :=
    271 SDK_EXTRAS_XML :=
    272 SDK_EXTRAS_XML_ARGS :=
    273 SDK_SYSIMG_DEPS :=
    274 SDK_SYSIMG_XML :=
    275 SDK_SYSIMG_XML_ARGS :=
    276 
    277 mk-sdk-repo-pkg-1 :=
    278 mk-sdk-repo-pkg-2 :=
    279 mk-sdk-repo-pkg-3 :=
    280 mk-sdk-repo-sources :=
    281 mk-sdk-repo-xml :=
    282 sdk-repo-pkg-zip :=
    283