prebuilt.mk revision 08d79c12de87674e006c9b3e8e68f9a52d6e180b
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
57ifeq ($(LOCAL_CERTIFICATE),EXTERNAL)
58  # The magic string "EXTERNAL" means this package will be signed with
59  # the default dev key throughout the build process, but we expect
60  # the final package to be signed with a different key.
61  #
62  # This can be used for packages where we don't have access to the
63  # keys, but want the package to be predexopt'ed.
64  LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
65  PACKAGES.$(LOCAL_MODULE).EXTERNAL_KEY := 1
66
67  $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
68  $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
69endif
70ifeq ($(LOCAL_CERTIFICATE),)
71  ifneq ($(filter APPS,$(LOCAL_MODULE_CLASS)),)
72    # It is now a build error to add a prebuilt .apk without
73    # specifying a key for it.
74    $(error No LOCAL_CERTIFICATE specified for prebuilt "$(LOCAL_SRC_FILES)")
75  endif
76else ifeq ($(LOCAL_CERTIFICATE),PRESIGNED)
77  # The magic string "PRESIGNED" means this package is already checked
78  # signed with its release key.
79  #
80  # By setting .CERTIFICATE but not .PRIVATE_KEY, this package will be
81  # mentioned in apkcerts.txt (with certificate set to "PRESIGNED")
82  # but the dexpreopt process will not try to re-sign the app.
83  PACKAGES.$(LOCAL_MODULE).CERTIFICATE := PRESIGNED
84  PACKAGES := $(PACKAGES) $(LOCAL_MODULE)
85else
86  # If this is not an absolute certificate, assign it to a generic one.
87  ifeq ($(dir $(strip $(LOCAL_CERTIFICATE))),./)
88      LOCAL_CERTIFICATE := $(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))$(LOCAL_CERTIFICATE)
89  endif
90
91  PACKAGES.$(LOCAL_MODULE).PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
92  PACKAGES.$(LOCAL_MODULE).CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
93  PACKAGES := $(PACKAGES) $(LOCAL_MODULE)
94
95  $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
96  $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
97endif
98
99ifneq ($(filter APPS,$(LOCAL_MODULE_CLASS)),)
100ifeq ($(LOCAL_CERTIFICATE),PRESIGNED)
101# Ensure that presigned .apks have been aligned.
102$(built_module) : $(LOCAL_PATH)/$(LOCAL_SRC_FILES) | $(ZIPALIGN)
103	$(transform-prebuilt-to-target-with-zipalign)
104else
105# Sign and align non-presigned .apks.
106$(built_module) : $(LOCAL_PATH)/$(LOCAL_SRC_FILES) | $(ACP) $(ZIPALIGN) $(SIGNAPK_JAR)
107	$(transform-prebuilt-to-target)
108	$(sign-package)
109	$(align-package)
110endif
111else
112ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),)
113$(built_module) : $(LOCAL_PATH)/$(LOCAL_SRC_FILES)
114	$(transform-prebuilt-to-target-strip-comments)
115else
116$(built_module) : $(LOCAL_PATH)/$(LOCAL_SRC_FILES) | $(ACP)
117	$(transform-prebuilt-to-target)
118endif
119endif
120
121ifeq ($(LOCAL_IS_HOST_MODULE)$(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
122# for target java libraries, the LOCAL_BUILT_MODULE is in a product-specific dir,
123# while the deps should be in the common dir, so we make a copy in the common dir.
124# For nonstatic library, $(common_javalib_jar) is the dependency file,
125# while $(common_classes_jar) is used to link.
126common_classes_jar := $(call intermediates-dir-for,JAVA_LIBRARIES,$(LOCAL_MODULE),,COMMON)/classes.jar
127common_javalib_jar := $(dir $(common_classes_jar))javalib.jar
128
129$(common_classes_jar) : $(LOCAL_PATH)/$(LOCAL_SRC_FILES) | $(ACP)
130	$(transform-prebuilt-to-target)
131
132$(common_javalib_jar) : $(common_classes_jar) | $(ACP)
133	$(transform-prebuilt-to-target)
134
135# make sure the classes.jar and javalib.jar are built before $(LOCAL_BUILT_MODULE)
136$(built_module) : $(common_javalib_jar)
137endif # TARGET JAVA_LIBRARIES
138
139ifneq ($(prebuilt_module_is_a_library),)
140  ifneq ($(LOCAL_IS_HOST_MODULE),)
141	$(transform-host-ranlib-copy-hack)
142  else
143	$(transform-ranlib-copy-hack)
144  endif
145endif
146