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