prebuilt.mk revision e2419c89cef4eeae1b6cd113ef1c92d397834841
1###########################################################
2## Standard rules for copying files that are prebuilt
3##
4## Additional inputs from base_rules.make:
5## None.
6##
7###########################################################
8
9ifneq ($(LOCAL_PREBUILT_LIBS),)
10$(error dont use LOCAL_PREBUILT_LIBS anymore LOCAL_PATH=$(LOCAL_PATH))
11endif
12ifneq ($(LOCAL_PREBUILT_EXECUTABLES),)
13$(error dont use LOCAL_PREBUILT_EXECUTABLES anymore LOCAL_PATH=$(LOCAL_PATH))
14endif
15ifneq ($(LOCAL_PREBUILT_JAVA_LIBRARIES),)
16$(error dont use LOCAL_PREBUILT_JAVA_LIBRARIES anymore LOCAL_PATH=$(LOCAL_PATH))
17endif
18
19ifneq ($(filter APPS,$(LOCAL_MODULE_CLASS)),)
20ifeq (true,$(WITH_DEXPREOPT))
21ifeq (,$(TARGET_BUILD_APPS))
22ifndef LOCAL_DEX_PREOPT
23LOCAL_DEX_PREOPT := true
24endif
25endif
26endif
27endif
28
29include $(BUILD_SYSTEM)/base_rules.mk
30
31# Deal with the OSX library timestamp issue when installing
32# a prebuilt simulator library.
33ifneq ($(filter STATIC_LIBRARIES SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)),)
34  prebuilt_module_is_a_library := true
35else
36  prebuilt_module_is_a_library :=
37endif
38
39PACKAGES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES))
40
41# Ensure that prebuilt .apks have been aligned.
42ifneq ($(filter APPS,$(LOCAL_MODULE_CLASS)),)
43ifeq ($(LOCAL_DEX_PREOPT),true)
44# Make sure the boot jars get dexpreopt-ed first
45$(LOCAL_BUILT_MODULE): $(DEXPREOPT_BOOT_ODEXS) | $(DEXPREOPT) $(DEXOPT) $(AAPT)
46endif
47$(LOCAL_BUILT_MODULE) : $(LOCAL_PATH)/$(LOCAL_SRC_FILES) | $(ZIPALIGN)
48	$(transform-prebuilt-to-target-with-zipalign)
49ifeq ($(LOCAL_DEX_PREOPT),true)
50	$(hide) rm -f $(patsubst %.apk,%.odex,$@)
51	$(call dexpreopt-one-file,$@,$(patsubst %.apk,%.odex,$@))
52	$(call dexpreopt-remove-classes.dex,$@)
53
54built_odex := $(basename $(LOCAL_BUILT_MODULE)).odex
55$(built_odex): $(LOCAL_BUILT_MODULE)
56endif
57else
58ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),)
59$(LOCAL_BUILT_MODULE) : $(LOCAL_PATH)/$(LOCAL_SRC_FILES)
60	$(transform-prebuilt-to-target-strip-comments)
61else
62$(LOCAL_BUILT_MODULE) : $(LOCAL_PATH)/$(LOCAL_SRC_FILES) | $(ACP)
63	$(transform-prebuilt-to-target)
64endif
65endif
66
67ifeq ($(LOCAL_IS_HOST_MODULE)$(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
68# for target java libraries, the LOCAL_BUILT_MODULE is in a product-specific dir,
69# while the deps should be in the common dir, so we make a copy in the common dir.
70# For nonstatic library, $(common_javalib_jar) is the dependency file,
71# while $(common_classes_jar) is used to link.
72common_classes_jar := $(call intermediates-dir-for,JAVA_LIBRARIES,$(LOCAL_MODULE),,COMMON)/classes.jar
73common_javalib_jar := $(dir $(common_classes_jar))javalib.jar
74
75$(common_classes_jar) : $(LOCAL_PATH)/$(LOCAL_SRC_FILES) | $(ACP)
76	$(transform-prebuilt-to-target)
77
78$(common_javalib_jar) : $(common_classes_jar) | $(ACP)
79	$(transform-prebuilt-to-target)
80
81# make sure the classes.jar and javalib.jar are built before $(LOCAL_BUILT_MODULE)
82$(LOCAL_BUILT_MODULE) : $(common_javalib_jar)
83endif # TARGET JAVA_LIBRARIES
84
85ifeq ($(LOCAL_CERTIFICATE),EXTERNAL)
86  # The magic string "EXTERNAL" means this package will be signed with
87  # the test key throughout the build process, but we expect the final
88  # package to be signed with a different key.
89  #
90  # This can be used for packages where we don't have access to the
91  # keys, but want the package to be predexopt'ed.
92  LOCAL_CERTIFICATE := testkey
93  PACKAGES.$(LOCAL_MODULE).EXTERNAL_KEY := 1
94endif
95ifeq ($(LOCAL_CERTIFICATE),)
96  ifneq ($(filter APPS,$(LOCAL_MODULE_CLASS)),)
97    # It is now a build error to add a prebuilt .apk without
98    # specifying a key for it.
99    $(error No LOCAL_CERTIFICATE specified for prebuilt "$(LOCAL_SRC_FILES)")
100  endif
101else ifeq ($(LOCAL_CERTIFICATE),PRESIGNED)
102  # The magic string "PRESIGNED" means this package is already checked
103  # signed with its release key.
104  #
105  # By setting .CERTIFICATE but not .PRIVATE_KEY, this package will be
106  # mentioned in apkcerts.txt (with certificate set to "PRESIGNED")
107  # but the dexpreopt process will not try to re-sign the app.
108  PACKAGES.$(LOCAL_MODULE).CERTIFICATE := PRESIGNED
109  PACKAGES := $(PACKAGES) $(LOCAL_MODULE)
110else
111  # If this is not an absolute certificate, assign it to a generic one.
112  ifeq ($(dir $(strip $(LOCAL_CERTIFICATE))),./)
113      LOCAL_CERTIFICATE := $(SRC_TARGET_DIR)/product/security/$(LOCAL_CERTIFICATE)
114  endif
115
116  PACKAGES.$(LOCAL_MODULE).PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
117  PACKAGES.$(LOCAL_MODULE).CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
118  PACKAGES := $(PACKAGES) $(LOCAL_MODULE)
119endif
120
121ifneq ($(prebuilt_module_is_a_library),)
122  ifneq ($(LOCAL_IS_HOST_MODULE),)
123	$(transform-host-ranlib-copy-hack)
124  else
125	$(transform-ranlib-copy-hack)
126  endif
127endif
128