prebuilt.mk revision 17a27047bb4d5f255b1c1c55864dae4425e9d6ee
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
19ifeq ($(LOCAL_STRIP_MODULE),true)
20  ifdef LOCAL_IS_HOST_MODULE
21    $(error Cannot strip host module LOCAL_PATH=$(LOCAL_PATH))
22  endif
23  ifeq ($(filter SHARED_LIBRARIES EXECUTABLES,$(LOCAL_MODULE_CLASS)),)
24    $(error Can strip only shared libraries or executables LOCAL_PATH=$(LOCAL_PATH))
25  endif
26  ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),)
27    $(error Cannot strip scripts LOCAL_PATH=$(LOCAL_PATH))
28  endif
29  include $(BUILD_SYSTEM)/dynamic_binary.mk
30  built_module := $(linked_module)
31else
32  include $(BUILD_SYSTEM)/base_rules.mk
33  built_module := $(LOCAL_BUILT_MODULE)
34endif
35
36# Deal with the OSX library timestamp issue when installing
37# a prebuilt simulator library.
38ifneq ($(filter STATIC_LIBRARIES SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)),)
39  prebuilt_module_is_a_library := true
40else
41  prebuilt_module_is_a_library :=
42endif
43
44PACKAGES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES))
45
46# Ensure that prebuilt .apks have been aligned.
47ifneq ($(filter APPS,$(LOCAL_MODULE_CLASS)),)
48$(built_module) : $(LOCAL_PATH)/$(LOCAL_SRC_FILES) | $(ZIPALIGN)
49	$(transform-prebuilt-to-target-with-zipalign)
50else
51ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),)
52$(built_module) : $(LOCAL_PATH)/$(LOCAL_SRC_FILES)
53	$(transform-prebuilt-to-target-strip-comments)
54else
55$(built_module) : $(LOCAL_PATH)/$(LOCAL_SRC_FILES) | $(ACP)
56	$(transform-prebuilt-to-target)
57endif
58endif
59
60ifeq ($(LOCAL_IS_HOST_MODULE)$(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
61# for target java libraries, the LOCAL_BUILT_MODULE is in a product-specific dir,
62# while the deps should be in the common dir, so we make a copy in the common dir.
63# For nonstatic library, $(common_javalib_jar) is the dependency file,
64# while $(common_classes_jar) is used to link.
65common_classes_jar := $(call intermediates-dir-for,JAVA_LIBRARIES,$(LOCAL_MODULE),,COMMON)/classes.jar
66common_javalib_jar := $(dir $(common_classes_jar))javalib.jar
67
68$(common_classes_jar) : $(LOCAL_PATH)/$(LOCAL_SRC_FILES) | $(ACP)
69	$(transform-prebuilt-to-target)
70
71$(common_javalib_jar) : $(common_classes_jar) | $(ACP)
72	$(transform-prebuilt-to-target)
73
74# make sure the classes.jar and javalib.jar are built before $(LOCAL_BUILT_MODULE)
75$(built_module) : $(common_javalib_jar)
76endif # TARGET JAVA_LIBRARIES
77
78ifeq ($(LOCAL_CERTIFICATE),EXTERNAL)
79  # The magic string "EXTERNAL" means this package will be signed with
80  # the test key throughout the build process, but we expect the final
81  # package to be signed with a different key.
82  #
83  # This can be used for packages where we don't have access to the
84  # keys, but want the package to be predexopt'ed.
85  LOCAL_CERTIFICATE := testkey
86  PACKAGES.$(LOCAL_MODULE).EXTERNAL_KEY := 1
87endif
88ifeq ($(LOCAL_CERTIFICATE),)
89  ifneq ($(filter APPS,$(LOCAL_MODULE_CLASS)),)
90    # It is now a build error to add a prebuilt .apk without
91    # specifying a key for it.
92    $(error No LOCAL_CERTIFICATE specified for prebuilt "$(LOCAL_SRC_FILES)")
93  endif
94else ifeq ($(LOCAL_CERTIFICATE),PRESIGNED)
95  # The magic string "PRESIGNED" means this package is already checked
96  # signed with its release key.
97  #
98  # By setting .CERTIFICATE but not .PRIVATE_KEY, this package will be
99  # mentioned in apkcerts.txt (with certificate set to "PRESIGNED")
100  # but the dexpreopt process will not try to re-sign the app.
101  PACKAGES.$(LOCAL_MODULE).CERTIFICATE := PRESIGNED
102  PACKAGES := $(PACKAGES) $(LOCAL_MODULE)
103else
104  # If this is not an absolute certificate, assign it to a generic one.
105  ifeq ($(dir $(strip $(LOCAL_CERTIFICATE))),./)
106      LOCAL_CERTIFICATE := $(SRC_TARGET_DIR)/product/security/$(LOCAL_CERTIFICATE)
107  endif
108
109  PACKAGES.$(LOCAL_MODULE).PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
110  PACKAGES.$(LOCAL_MODULE).CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
111  PACKAGES := $(PACKAGES) $(LOCAL_MODULE)
112endif
113
114ifneq ($(prebuilt_module_is_a_library),)
115  ifneq ($(LOCAL_IS_HOST_MODULE),)
116	$(transform-host-ranlib-copy-hack)
117  else
118	$(transform-ranlib-copy-hack)
119  endif
120endif
121