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