Home | History | Annotate | Download | only in core
      1 ###########################################################
      2 ## Standard rules for copying files that are prebuilt
      3 ##
      4 ## Additional inputs from base_rules.make:
      5 ## None.
      6 ##
      7 ###########################################################
      8 
      9 ifneq ($(LOCAL_PREBUILT_LIBS),)
     10 $(error dont use LOCAL_PREBUILT_LIBS anymore LOCAL_PATH=$(LOCAL_PATH))
     11 endif
     12 ifneq ($(LOCAL_PREBUILT_EXECUTABLES),)
     13 $(error dont use LOCAL_PREBUILT_EXECUTABLES anymore LOCAL_PATH=$(LOCAL_PATH))
     14 endif
     15 ifneq ($(LOCAL_PREBUILT_JAVA_LIBRARIES),)
     16 $(error dont use LOCAL_PREBUILT_JAVA_LIBRARIES anymore LOCAL_PATH=$(LOCAL_PATH))
     17 endif
     18 
     19 # Not much sense to check build prebuilts
     20 LOCAL_DONT_CHECK_MODULE := true
     21 
     22 my_32_64_bit_suffix := $(if $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)IS_64_BIT),64,32)
     23 
     24 ifdef LOCAL_PREBUILT_MODULE_FILE
     25   my_prebuilt_src_file := $(LOCAL_PREBUILT_MODULE_FILE)
     26 else
     27   ifdef LOCAL_SRC_FILES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
     28     my_prebuilt_src_file := $(LOCAL_PATH)/$(LOCAL_SRC_FILES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
     29   else
     30     ifdef LOCAL_SRC_FILES_$(my_32_64_bit_suffix)
     31       my_prebuilt_src_file := $(LOCAL_PATH)/$(LOCAL_SRC_FILES_$(my_32_64_bit_suffix))
     32     else
     33       my_prebuilt_src_file := $(LOCAL_PATH)/$(LOCAL_SRC_FILES)
     34     endif
     35   endif
     36 endif
     37 
     38 ifeq (SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS))
     39   # Put the built targets of all shared libraries in a common directory
     40   # to simplify the link line.
     41   OVERRIDE_BUILT_MODULE_PATH := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)
     42 endif
     43 
     44 ifneq ($(filter STATIC_LIBRARIES SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)),)
     45   prebuilt_module_is_a_library := true
     46 else
     47   prebuilt_module_is_a_library :=
     48 endif
     49 
     50 # Don't install static libraries by default.
     51 ifndef LOCAL_UNINSTALLABLE_MODULE
     52 ifeq (STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS))
     53   LOCAL_UNINSTALLABLE_MODULE := true
     54 endif
     55 endif
     56 
     57 ifeq ($(LOCAL_MODULE_CLASS),APPS)
     58 LOCAL_BUILT_MODULE_STEM := package.apk
     59 LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE).apk
     60 endif
     61 
     62 ifeq ($(LOCAL_STRIP_MODULE),true)
     63   ifdef LOCAL_IS_HOST_MODULE
     64     $(error Cannot strip host module LOCAL_PATH=$(LOCAL_PATH))
     65   endif
     66   ifeq ($(filter SHARED_LIBRARIES EXECUTABLES,$(LOCAL_MODULE_CLASS)),)
     67     $(error Can strip only shared libraries or executables LOCAL_PATH=$(LOCAL_PATH))
     68   endif
     69   ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),)
     70     $(error Cannot strip scripts LOCAL_PATH=$(LOCAL_PATH))
     71   endif
     72   include $(BUILD_SYSTEM)/dynamic_binary.mk
     73   built_module := $(linked_module)
     74 else  # LOCAL_STRIP_MODULE not true
     75   include $(BUILD_SYSTEM)/base_rules.mk
     76   built_module := $(LOCAL_BUILT_MODULE)
     77 
     78 ifdef prebuilt_module_is_a_library
     79 export_includes := $(intermediates)/export_includes
     80 $(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(LOCAL_EXPORT_C_INCLUDE_DIRS)
     81 $(export_includes) : $(LOCAL_MODULE_MAKEFILE)
     82 	@echo Export includes file: $< -- $@
     83 	$(hide) mkdir -p $(dir $@) && rm -f $@
     84 ifdef LOCAL_EXPORT_C_INCLUDE_DIRS
     85 	$(hide) for d in $(PRIVATE_EXPORT_C_INCLUDE_DIRS); do \
     86 	        echo "-I $$d" >> $@; \
     87 	        done
     88 else
     89 	$(hide) touch $@
     90 endif
     91 
     92 $(LOCAL_BUILT_MODULE) : | $(intermediates)/export_includes
     93 endif  # prebuilt_module_is_a_library
     94 
     95 # The real dependency will be added after all Android.mks are loaded and the install paths
     96 # of the shared libraries are determined.
     97 ifdef LOCAL_INSTALLED_MODULE
     98 ifdef LOCAL_SHARED_LIBRARIES
     99 $(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \
    100   $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(LOCAL_SHARED_LIBRARIES))
    101 
    102 # We also need the LOCAL_BUILT_MODULE dependency,
    103 # since we use -rpath-link which points to the built module's path.
    104 built_shared_libraries := \
    105     $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
    106     $(addsuffix $($(my_prefix)SHLIB_SUFFIX), \
    107         $(LOCAL_SHARED_LIBRARIES)))
    108 $(LOCAL_BUILT_MODULE) : $(built_shared_libraries)
    109 endif
    110 endif
    111 
    112 endif  # LOCAL_STRIP_MODULE not true
    113 
    114 ifeq ($(LOCAL_MODULE_CLASS),APPS)
    115 PACKAGES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES))
    116 
    117 # Select dpi-specific source
    118 ifdef LOCAL_DPI_VARIANTS
    119 my_dpi := $(firstword $(filter $(LOCAL_DPI_VARIANTS),$(PRODUCT_AAPT_PREF_CONFIG) $(PRODUCT_AAPT_PREBUILT_DPI)))
    120 ifdef my_dpi
    121 ifdef LOCAL_DPI_FILE_STEM
    122 my_prebuilt_dpi_file_stem := $(LOCAL_DPI_FILE_STEM)
    123 else
    124 my_prebuilt_dpi_file_stem := $(LOCAL_MODULE)_%.apk
    125 endif
    126 my_prebuilt_src_file := $(dir $(my_prebuilt_src_file))$(subst %,$(my_dpi),$(my_prebuilt_dpi_file_stem))
    127 endif  # my_dpi
    128 endif  # LOCAL_DPI_VARIANTS
    129 
    130 rs_compatibility_jni_libs :=
    131 include $(BUILD_SYSTEM)/install_jni_libs.mk
    132 
    133 ifeq ($(LOCAL_CERTIFICATE),EXTERNAL)
    134   # The magic string "EXTERNAL" means this package will be signed with
    135   # the default dev key throughout the build process, but we expect
    136   # the final package to be signed with a different key.
    137   #
    138   # This can be used for packages where we don't have access to the
    139   # keys, but want the package to be predexopt'ed.
    140   LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
    141   PACKAGES.$(LOCAL_MODULE).EXTERNAL_KEY := 1
    142 
    143   $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
    144   $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
    145 endif
    146 ifeq ($(LOCAL_CERTIFICATE),)
    147   # It is now a build error to add a prebuilt .apk without
    148   # specifying a key for it.
    149   $(error No LOCAL_CERTIFICATE specified for prebuilt "$(my_prebuilt_src_file)")
    150 else ifeq ($(LOCAL_CERTIFICATE),PRESIGNED)
    151   # The magic string "PRESIGNED" means this package is already checked
    152   # signed with its release key.
    153   #
    154   # By setting .CERTIFICATE but not .PRIVATE_KEY, this package will be
    155   # mentioned in apkcerts.txt (with certificate set to "PRESIGNED")
    156   # but the dexpreopt process will not try to re-sign the app.
    157   PACKAGES.$(LOCAL_MODULE).CERTIFICATE := PRESIGNED
    158   PACKAGES := $(PACKAGES) $(LOCAL_MODULE)
    159 else
    160   # If this is not an absolute certificate, assign it to a generic one.
    161   ifeq ($(dir $(strip $(LOCAL_CERTIFICATE))),./)
    162       LOCAL_CERTIFICATE := $(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))$(LOCAL_CERTIFICATE)
    163   endif
    164 
    165   PACKAGES.$(LOCAL_MODULE).PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
    166   PACKAGES.$(LOCAL_MODULE).CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
    167   PACKAGES := $(PACKAGES) $(LOCAL_MODULE)
    168 
    169   $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
    170   $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
    171 endif
    172 
    173 # Disable dex-preopt of prebuilts to save space, if requested.
    174 ifeq ($(DONT_DEXPREOPT_PREBUILTS),true)
    175 LOCAL_DEX_PREOPT := false
    176 endif
    177 
    178 #######################################
    179 # defines built_odex along with rule to install odex
    180 include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk
    181 #######################################
    182 # Sign and align non-presigned .apks.
    183 $(built_module) : $(my_prebuilt_src_file) | $(ACP) $(ZIPALIGN) $(SIGNAPK_JAR)
    184 	$(transform-prebuilt-to-target)
    185 ifdef extracted_jni_libs
    186 	$(hide) zip -d $@ 'lib/*.so'  # strip embedded JNI libraries.
    187 endif
    188 ifneq ($(LOCAL_CERTIFICATE),PRESIGNED)
    189 	$(sign-package)
    190 endif
    191 ifdef LOCAL_DEX_PREOPT
    192 ifneq (nostripping,$(LOCAL_DEX_PREOPT))
    193 	$(call dexpreopt-remove-classes.dex,$@)
    194 endif
    195 endif
    196 	$(align-package)
    197 
    198 ###############################
    199 ## Rule to build the odex file
    200 ifdef LOCAL_DEX_PREOPT
    201 $(built_odex) : $(my_prebuilt_src_file)
    202 	$(call dexpreopt-one-file,$<,$@)
    203 endif
    204 
    205 ###############################
    206 ## Install split apks.
    207 ifdef LOCAL_PACKAGE_SPLITS
    208 # LOCAL_PACKAGE_SPLITS is a list of apks to be installed.
    209 built_apk_splits := $(addprefix $(built_module_path)/,$(notdir $(LOCAL_PACKAGE_SPLITS)))
    210 installed_apk_splits := $(addprefix $(my_module_path)/,$(notdir $(LOCAL_PACKAGE_SPLITS)))
    211 
    212 # Rules to sign and zipalign the split apks.
    213 my_src_dir := $(sort $(dir $(LOCAL_PACKAGE_SPLITS)))
    214 ifneq (1,$(words $(my_src_dir)))
    215 $(error You must put all the split source apks in the same folder: $(LOCAL_PACKAGE_SPLITS))
    216 endif
    217 my_src_dir := $(LOCAL_PATH)/$(my_src_dir)
    218 
    219 $(built_apk_splits) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
    220 $(built_apk_splits) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
    221 $(built_apk_splits) : $(built_module_path)/%.apk : $(my_src_dir)/%.apk | $(ACP)
    222 	$(copy-file-to-new-target)
    223 	$(sign-package)
    224 	$(align-package)
    225 
    226 # Rules to install the split apks.
    227 $(installed_apk_splits) : $(my_module_path)/%.apk : $(built_module_path)/%.apk | $(ACP)
    228 	@echo "Install: $@"
    229 	$(copy-file-to-new-target)
    230 
    231 # Register the additional built and installed files.
    232 ALL_MODULES.$(my_register_name).INSTALLED += $(installed_apk_splits)
    233 ALL_MODULES.$(my_register_name).BUILT_INSTALLED += \
    234   $(foreach s,$(LOCAL_PACKAGE_SPLITS),$(built_module_path)/$(notdir $(s)):$(my_module_path)/$(notdir $(s)))
    235 
    236 # Make sure to install the splits when you run "make <module_name>".
    237 $(my_register_name): $(installed_apk_splits)
    238 
    239 endif # LOCAL_PACKAGE_SPLITS
    240 
    241 else # LOCAL_MODULE_CLASS != APPS
    242 ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),)
    243 $(built_module) : $(my_prebuilt_src_file)
    244 	$(transform-prebuilt-to-target-strip-comments)
    245 else
    246 $(built_module) : $(my_prebuilt_src_file) | $(ACP)
    247 	$(transform-prebuilt-to-target)
    248 ifneq ($(prebuilt_module_is_a_library),)
    249   ifneq ($(LOCAL_IS_HOST_MODULE),)
    250 	$(transform-host-ranlib-copy-hack)
    251   else
    252 	$(transform-ranlib-copy-hack)
    253   endif
    254 endif
    255 endif
    256 endif # LOCAL_MODULE_CLASS != APPS
    257 
    258 ifeq ($(LOCAL_IS_HOST_MODULE)$(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
    259 # for target java libraries, the LOCAL_BUILT_MODULE is in a product-specific dir,
    260 # while the deps should be in the common dir, so we make a copy in the common dir.
    261 # For nonstatic library, $(common_javalib_jar) is the dependency file,
    262 # while $(common_classes_jar) is used to link.
    263 common_classes_jar := $(intermediates.COMMON)/classes.jar
    264 common_javalib_jar := $(intermediates.COMMON)/javalib.jar
    265 
    266 $(common_classes_jar) $(common_javalib_jar): PRIVATE_MODULE := $(LOCAL_MODULE)
    267 
    268 ifneq ($(filter %.aar, $(my_prebuilt_src_file)),)
    269 # This is .aar file, archive of classes.jar and Android resources.
    270 my_src_jar := $(intermediates.COMMON)/aar/classes.jar
    271 
    272 $(my_src_jar) : $(my_prebuilt_src_file)
    273 	$(hide) rm -rf $(dir $@) && mkdir -p $(dir $@)
    274 	$(hide) unzip -qo -d $(dir $@) $<
    275 	# Make sure the extracted classes.jar has a new timestamp.
    276 	$(hide) touch $@
    277 
    278 else
    279 # This is jar file.
    280 my_src_jar := $(my_prebuilt_src_file)
    281 endif
    282 $(common_classes_jar) : $(my_src_jar) | $(ACP)
    283 	$(transform-prebuilt-to-target)
    284 
    285 $(common_javalib_jar) : $(common_classes_jar) | $(ACP)
    286 	$(transform-prebuilt-to-target)
    287 
    288 # make sure the classes.jar and javalib.jar are built before $(LOCAL_BUILT_MODULE)
    289 $(built_module) : $(common_javalib_jar)
    290 endif # TARGET JAVA_LIBRARIES
    291 
    292 $(built_module) : $(LOCAL_ADDITIONAL_DEPENDENCIES)
    293 
    294 my_prebuilt_src_file :=
    295