blob: 089cc6300feeb070041ed6d80597b01f0a4ae7f6 [file] [log] [blame]
Colin Crosse18cb932014-02-13 15:04:18 -08001###########################################################
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
19# Not much sense to check build prebuilts
20LOCAL_DONT_CHECK_MODULE := true
21
22ifdef LOCAL_PREBUILT_MODULE_FILE
Ying Wang6c930fc2014-02-27 14:10:53 -080023 my_prebuilt_src_file := $(LOCAL_PREBUILT_MODULE_FILE)
Colin Crosse18cb932014-02-13 15:04:18 -080024else
Ying Wang6feb6d52014-04-17 10:03:35 -070025 ifdef LOCAL_SRC_FILES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
26 my_prebuilt_src_file := $(LOCAL_PATH)/$(LOCAL_SRC_FILES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
Ying Wang6c930fc2014-02-27 14:10:53 -080027 else
28 my_prebuilt_src_file := $(LOCAL_PATH)/$(LOCAL_SRC_FILES)
29 endif
Colin Crosse18cb932014-02-13 15:04:18 -080030endif
31
Colin Crosse18cb932014-02-13 15:04:18 -080032ifeq (SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS))
33 # Put the built targets of all shared libraries in a common directory
34 # to simplify the link line.
35 OVERRIDE_BUILT_MODULE_PATH := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)
36endif
37
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
44# Don't install static libraries by default.
45ifndef LOCAL_UNINSTALLABLE_MODULE
46ifeq (STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS))
47 LOCAL_UNINSTALLABLE_MODULE := true
48endif
49endif
50
51ifeq ($(LOCAL_STRIP_MODULE),true)
52 ifdef LOCAL_IS_HOST_MODULE
53 $(error Cannot strip host module LOCAL_PATH=$(LOCAL_PATH))
54 endif
55 ifeq ($(filter SHARED_LIBRARIES EXECUTABLES,$(LOCAL_MODULE_CLASS)),)
56 $(error Can strip only shared libraries or executables LOCAL_PATH=$(LOCAL_PATH))
57 endif
58 ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),)
59 $(error Cannot strip scripts LOCAL_PATH=$(LOCAL_PATH))
60 endif
61 include $(BUILD_SYSTEM)/dynamic_binary.mk
62 built_module := $(linked_module)
63else # LOCAL_STRIP_MODULE not true
64 include $(BUILD_SYSTEM)/base_rules.mk
65 built_module := $(LOCAL_BUILT_MODULE)
66
67ifdef prebuilt_module_is_a_library
68export_includes := $(intermediates)/export_includes
69$(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(LOCAL_EXPORT_C_INCLUDE_DIRS)
70$(export_includes) : $(LOCAL_MODULE_MAKEFILE)
71 @echo Export includes file: $< -- $@
72 $(hide) mkdir -p $(dir $@) && rm -f $@
73ifdef LOCAL_EXPORT_C_INCLUDE_DIRS
74 $(hide) for d in $(PRIVATE_EXPORT_C_INCLUDE_DIRS); do \
75 echo "-I $$d" >> $@; \
76 done
77else
78 $(hide) touch $@
79endif
80
81$(LOCAL_BUILT_MODULE) : | $(intermediates)/export_includes
82endif # prebuilt_module_is_a_library
83
84# The real dependency will be added after all Android.mks are loaded and the install paths
85# of the shared libraries are determined.
86ifdef LOCAL_INSTALLED_MODULE
87ifdef LOCAL_SHARED_LIBRARIES
Ying Wang58f462f2014-02-25 18:26:29 -080088$(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \
89 $(LOCAL_MODULE):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(LOCAL_SHARED_LIBRARIES))
Colin Crosse18cb932014-02-13 15:04:18 -080090
91# We also need the LOCAL_BUILT_MODULE dependency,
92# since we use -rpath-link which points to the built module's path.
93built_shared_libraries := \
Ying Wang58f462f2014-02-25 18:26:29 -080094 $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
Colin Crosse18cb932014-02-13 15:04:18 -080095 $(addsuffix $($(my_prefix)SHLIB_SUFFIX), \
96 $(LOCAL_SHARED_LIBRARIES)))
97$(LOCAL_BUILT_MODULE) : $(built_shared_libraries)
98endif
99endif
100
101endif # LOCAL_STRIP_MODULE not true
102
103PACKAGES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES))
104
Ying Wang695e8262014-04-17 13:38:04 -0700105rs_compatibility_jni_libs :=
106include $(BUILD_SYSTEM)/install_jni_libs.mk
107
Colin Crosse18cb932014-02-13 15:04:18 -0800108ifeq ($(LOCAL_CERTIFICATE),EXTERNAL)
109 # The magic string "EXTERNAL" means this package will be signed with
110 # the default dev key throughout the build process, but we expect
111 # the final package to be signed with a different key.
112 #
113 # This can be used for packages where we don't have access to the
114 # keys, but want the package to be predexopt'ed.
115 LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
116 PACKAGES.$(LOCAL_MODULE).EXTERNAL_KEY := 1
117
118 $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
119 $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
120endif
121ifeq ($(LOCAL_CERTIFICATE),)
122 ifneq ($(filter APPS,$(LOCAL_MODULE_CLASS)),)
123 # It is now a build error to add a prebuilt .apk without
124 # specifying a key for it.
125 $(error No LOCAL_CERTIFICATE specified for prebuilt "$(my_prebuilt_src_file)")
126 endif
127else ifeq ($(LOCAL_CERTIFICATE),PRESIGNED)
128 # The magic string "PRESIGNED" means this package is already checked
129 # signed with its release key.
130 #
131 # By setting .CERTIFICATE but not .PRIVATE_KEY, this package will be
132 # mentioned in apkcerts.txt (with certificate set to "PRESIGNED")
133 # but the dexpreopt process will not try to re-sign the app.
134 PACKAGES.$(LOCAL_MODULE).CERTIFICATE := PRESIGNED
135 PACKAGES := $(PACKAGES) $(LOCAL_MODULE)
136else
137 # If this is not an absolute certificate, assign it to a generic one.
138 ifeq ($(dir $(strip $(LOCAL_CERTIFICATE))),./)
139 LOCAL_CERTIFICATE := $(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))$(LOCAL_CERTIFICATE)
140 endif
141
142 PACKAGES.$(LOCAL_MODULE).PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
143 PACKAGES.$(LOCAL_MODULE).CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
144 PACKAGES := $(PACKAGES) $(LOCAL_MODULE)
145
146 $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
147 $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
148endif
149
150ifneq ($(filter APPS,$(LOCAL_MODULE_CLASS)),)
151
152# Disable dex-preopt of prebuilts to save space
153LOCAL_DEX_PREOPT := false
154
155#######################################
156# defines built_odex along with rule to install odex
157include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk
158#######################################
159ifdef LOCAL_DEX_PREOPT
160$(built_module): PRIVATE_DEX_PREOPT_IMAGE := $(LOCAL_DEX_PREOPT_IMAGE)
161$(built_module): PRIVATE_DEX_LOCATION := $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE))
162$(built_module): PRIVATE_BUILT_ODEX := $(built_odex)
163# Make sure the boot jars get dexpreopt-ed first
164$(built_module) : $(DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT)
165$(built_module) : $(DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS)
166(built_module) : $(LOCAL_DEX_PREOPT_IMAGE)
167# built_odex is byproduct of LOCAL_BUILT_MODULE without its own build recipe.
168$(built_odex) : $(LOCAL_BUILT_MODULE)
169endif # LOCAL_DEX_PREOPT
170# Sign and align non-presigned .apks.
171$(built_module) : $(my_prebuilt_src_file) | $(ACP) $(ZIPALIGN) $(SIGNAPK_JAR)
172 $(transform-prebuilt-to-target)
173ifneq ($(LOCAL_CERTIFICATE),PRESIGNED)
174 $(sign-package)
175endif
176ifdef LOCAL_DEX_PREOPT
177 $(call dexpreopt-one-file,$(PRIVATE_DEX_PREOPT_IMAGE),$@,$(PRIVATE_DEX_LOCATION),$(PRIVATE_BUILT_ODEX))
178endif
179 $(align-package)
180
181else # LOCAL_MODULE_CLASS != APPS
182ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),)
183$(built_module) : $(my_prebuilt_src_file)
184 $(transform-prebuilt-to-target-strip-comments)
185else
186$(built_module) : $(my_prebuilt_src_file) | $(ACP)
187 $(transform-prebuilt-to-target)
188ifneq ($(prebuilt_module_is_a_library),)
189 ifneq ($(LOCAL_IS_HOST_MODULE),)
190 $(transform-host-ranlib-copy-hack)
191 else
192 $(transform-ranlib-copy-hack)
193 endif
194endif
195endif
196endif # LOCAL_MODULE_CLASS != APPS
197
198ifeq ($(LOCAL_IS_HOST_MODULE)$(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
199# for target java libraries, the LOCAL_BUILT_MODULE is in a product-specific dir,
200# while the deps should be in the common dir, so we make a copy in the common dir.
201# For nonstatic library, $(common_javalib_jar) is the dependency file,
202# while $(common_classes_jar) is used to link.
203common_classes_jar := $(call intermediates-dir-for,JAVA_LIBRARIES,$(LOCAL_MODULE),,COMMON)/classes.jar
204common_javalib_jar := $(dir $(common_classes_jar))javalib.jar
205
206$(common_classes_jar) : $(my_prebuilt_src_file) | $(ACP)
207 $(transform-prebuilt-to-target)
208
209$(common_javalib_jar) : $(common_classes_jar) | $(ACP)
210 $(transform-prebuilt-to-target)
211
212# make sure the classes.jar and javalib.jar are built before $(LOCAL_BUILT_MODULE)
213$(built_module) : $(common_javalib_jar)
214endif # TARGET JAVA_LIBRARIES
215
216$(built_module) : $(LOCAL_ADDITIONAL_DEPENDENCIES)
217
218my_prebuilt_src_file :=