The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1 | # |
| 2 | # Copyright (C) 2008 The Android Open Source Project |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | # |
| 16 | |
| 17 | ## |
| 18 | ## Common build system definitions. Mostly standard |
| 19 | ## commands for building various types of targets, which |
| 20 | ## are used by others to construct the final targets. |
| 21 | ## |
| 22 | |
| 23 | # These are variables we use to collect overall lists |
| 24 | # of things being processed. |
| 25 | |
| 26 | # Full paths to all of the documentation |
| 27 | ALL_DOCS:= |
| 28 | |
| 29 | # The short names of all of the targets in the system. |
| 30 | # For each element of ALL_MODULES, two other variables |
| 31 | # are defined: |
| 32 | # $(ALL_MODULES.$(target)).BUILT |
| 33 | # $(ALL_MODULES.$(target)).INSTALLED |
| 34 | # The BUILT variable contains LOCAL_BUILT_MODULE for that |
| 35 | # target, and the INSTALLED variable contains the LOCAL_INSTALLED_MODULE. |
| 36 | # Some targets may have multiple files listed in the BUILT and INSTALLED |
| 37 | # sub-variables. |
| 38 | ALL_MODULES:= |
| 39 | |
| 40 | # Full paths to targets that should be added to the "make droid" |
| 41 | # set of installed targets. |
| 42 | ALL_DEFAULT_INSTALLED_MODULES:= |
| 43 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 44 | # The list of tags that have been defined by |
| 45 | # LOCAL_MODULE_TAGS. Each word in this variable maps |
| 46 | # to a corresponding ALL_MODULE_TAGS.<tagname> variable |
| 47 | # that contains all of the INSTALLED_MODULEs with that tag. |
| 48 | ALL_MODULE_TAGS:= |
| 49 | |
| 50 | # Similar to ALL_MODULE_TAGS, but contains the short names |
| 51 | # of all targets for a particular tag. The top-level variable |
| 52 | # won't have the list of tags; ust ALL_MODULE_TAGS to get |
| 53 | # the list of all known tags. (This means that this variable |
| 54 | # will always be empty; it's just here as a placeholder for |
| 55 | # its sub-variables.) |
| 56 | ALL_MODULE_NAME_TAGS:= |
| 57 | |
| 58 | # Full paths to all prebuilt files that will be copied |
| 59 | # (used to make the dependency on acp) |
| 60 | ALL_PREBUILT:= |
| 61 | |
| 62 | # Full path to all files that are made by some tool |
| 63 | ALL_GENERATED_SOURCES:= |
| 64 | |
| 65 | # Full path to all asm, C, C++, lex and yacc generated C files. |
| 66 | # These all have an order-only dependency on the copied headers |
| 67 | ALL_C_CPP_ETC_OBJECTS:= |
| 68 | |
Iliyan Malchev | b375e71 | 2011-03-08 16:19:48 -0800 | [diff] [blame] | 69 | # The list of dynamic binaries that haven't been stripped/compressed/etc. |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 70 | ALL_ORIGINAL_DYNAMIC_BINARIES:= |
| 71 | |
| 72 | # These files go into the SDK |
| 73 | ALL_SDK_FILES:= |
| 74 | |
| 75 | # Files for dalvik. This is often build without building the rest of the OS. |
| 76 | INTERNAL_DALVIK_MODULES:= |
| 77 | |
| 78 | # All findbugs xml files |
| 79 | ALL_FINDBUGS_FILES:= |
| 80 | |
Ying Wang | fd626f2 | 2011-12-12 12:57:38 -0800 | [diff] [blame] | 81 | # GPL module license files |
| 82 | ALL_GPL_MODULE_LICENSE_FILES:= |
| 83 | |
Ying Wang | 9485a57 | 2013-02-22 14:32:30 -0800 | [diff] [blame] | 84 | # Target and host installed module's dependencies on shared libraries. |
Ying Wang | d6b1d61 | 2013-04-15 17:32:21 -0700 | [diff] [blame] | 85 | # They are list of "<module_name>:<installed_file>:lib1,lib2...". |
Ying Wang | 9485a57 | 2013-02-22 14:32:30 -0800 | [diff] [blame] | 86 | TARGET_DEPENDENCIES_ON_SHARED_LIBRARIES := |
Ying Wang | 966c1e0 | 2014-05-20 14:43:51 -0700 | [diff] [blame] | 87 | $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_DEPENDENCIES_ON_SHARED_LIBRARIES := |
Ying Wang | 9485a57 | 2013-02-22 14:32:30 -0800 | [diff] [blame] | 88 | HOST_DEPENDENCIES_ON_SHARED_LIBRARIES := |
Ying Wang | 966c1e0 | 2014-05-20 14:43:51 -0700 | [diff] [blame] | 89 | $(HOST_2ND_ARCH_VAR_PREFIX)HOST_DEPENDENCIES_ON_SHARED_LIBRARIES := |
Dan Willemsen | 057aaea | 2015-08-14 12:59:50 -0700 | [diff] [blame] | 90 | HOST_CROSS_DEPENDENCIES_ON_SHARED_LIBRARIES := |
Ying Wang | 9485a57 | 2013-02-22 14:32:30 -0800 | [diff] [blame] | 91 | |
Ying Wang | ae25ec1 | 2012-06-19 10:40:37 -0700 | [diff] [blame] | 92 | # Generated class file names for Android resource. |
| 93 | # They are escaped and quoted so can be passed safely to a bash command. |
| 94 | ANDROID_RESOURCE_GENERATED_CLASSES := 'R.class' 'R$$*.class' 'Manifest.class' 'Manifest$$*.class' |
| 95 | |
Dan Willemsen | 057aaea | 2015-08-14 12:59:50 -0700 | [diff] [blame] | 96 | # Display names for various build targets |
| 97 | TARGET_DISPLAY := target |
| 98 | HOST_DISPLAY := host |
| 99 | HOST_CROSS_DISPLAY := host cross |
| 100 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 101 | ########################################################### |
| 102 | ## Debugging; prints a variable list to stdout |
| 103 | ########################################################### |
| 104 | |
| 105 | # $(1): variable name list, not variable values |
| 106 | define print-vars |
| 107 | $(foreach var,$(1), \ |
| 108 | $(info $(var):) \ |
| 109 | $(foreach word,$($(var)), \ |
| 110 | $(info $(space)$(space)$(word)) \ |
| 111 | ) \ |
| 112 | ) |
| 113 | endef |
| 114 | |
| 115 | ########################################################### |
Joe Onorato | 64d85d0 | 2009-04-09 19:31:12 -0700 | [diff] [blame] | 116 | ## Evaluates to true if the string contains the word true, |
| 117 | ## and empty otherwise |
| 118 | ## $(1): a var to test |
| 119 | ########################################################### |
| 120 | |
| 121 | define true-or-empty |
| 122 | $(filter true, $(1)) |
| 123 | endef |
| 124 | |
| 125 | |
| 126 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 127 | ## Retrieve the directory of the current makefile |
Ying Wang | 3bbfddd | 2014-03-01 15:32:04 -0800 | [diff] [blame] | 128 | ## Must be called before including any other makefile!! |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 129 | ########################################################### |
| 130 | |
| 131 | # Figure out where we are. |
| 132 | define my-dir |
Dave Bort | b392641 | 2009-05-19 16:12:22 -0700 | [diff] [blame] | 133 | $(strip \ |
Ying Wang | 68f1c77 | 2012-04-23 21:29:18 -0700 | [diff] [blame] | 134 | $(eval LOCAL_MODULE_MAKEFILE := $$(lastword $$(MAKEFILE_LIST))) \ |
Colin Cross | a4447e8 | 2015-09-28 16:26:00 -0700 | [diff] [blame] | 135 | $(eval LOCAL_MODULE_MAKEFILE_DEP := $(if $(BUILDING_WITH_NINJA),,$$(LOCAL_MODULE_MAKEFILE))) \ |
Ying Wang | 3bbfddd | 2014-03-01 15:32:04 -0800 | [diff] [blame] | 136 | $(if $(filter $(BUILD_SYSTEM)/% $(OUT_DIR)/%,$(LOCAL_MODULE_MAKEFILE)), \ |
| 137 | $(error my-dir must be called before including any other makefile.) \ |
Dave Bort | b392641 | 2009-05-19 16:12:22 -0700 | [diff] [blame] | 138 | , \ |
Ying Wang | 68f1c77 | 2012-04-23 21:29:18 -0700 | [diff] [blame] | 139 | $(patsubst %/,%,$(dir $(LOCAL_MODULE_MAKEFILE))) \ |
Dave Bort | b392641 | 2009-05-19 16:12:22 -0700 | [diff] [blame] | 140 | ) \ |
| 141 | ) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 142 | endef |
| 143 | |
| 144 | ########################################################### |
| 145 | ## Retrieve a list of all makefiles immediately below some directory |
| 146 | ########################################################### |
| 147 | |
| 148 | define all-makefiles-under |
Dan Willemsen | ec224d5 | 2015-08-06 15:01:24 -0700 | [diff] [blame] | 149 | $(sort $(wildcard $(1)/*/Android.mk)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 150 | endef |
| 151 | |
| 152 | ########################################################### |
| 153 | ## Look under a directory for makefiles that don't have parent |
| 154 | ## makefiles. |
| 155 | ########################################################### |
| 156 | |
| 157 | # $(1): directory to search under |
| 158 | # Ignores $(1)/Android.mk |
| 159 | define first-makefiles-under |
C. Sean Young | cf46998 | 2015-06-09 12:35:45 -0500 | [diff] [blame] | 160 | $(shell build/tools/findleaves.py $(FIND_LEAVES_EXCLUDES) \ |
Joe Onorato | dc1a728 | 2009-08-04 15:58:26 -0400 | [diff] [blame] | 161 | --mindepth=2 $(1) Android.mk) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 162 | endef |
| 163 | |
| 164 | ########################################################### |
| 165 | ## Retrieve a list of all makefiles immediately below your directory |
Ying Wang | 3bbfddd | 2014-03-01 15:32:04 -0800 | [diff] [blame] | 166 | ## Must be called before including any other makefile!! |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 167 | ########################################################### |
| 168 | |
| 169 | define all-subdir-makefiles |
| 170 | $(call all-makefiles-under,$(call my-dir)) |
| 171 | endef |
| 172 | |
| 173 | ########################################################### |
| 174 | ## Look in the named list of directories for makefiles, |
| 175 | ## relative to the current directory. |
Ying Wang | 3bbfddd | 2014-03-01 15:32:04 -0800 | [diff] [blame] | 176 | ## Must be called before including any other makefile!! |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 177 | ########################################################### |
| 178 | |
| 179 | # $(1): List of directories to look for under this directory |
| 180 | define all-named-subdir-makefiles |
Dan Willemsen | ec224d5 | 2015-08-06 15:01:24 -0700 | [diff] [blame] | 181 | $(sort $(wildcard $(addsuffix /Android.mk, $(addprefix $(call my-dir)/,$(1))))) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 182 | endef |
| 183 | |
| 184 | ########################################################### |
Dan Willemsen | 92f5fcc | 2015-10-12 15:26:52 -0700 | [diff] [blame] | 185 | ## Find all of the directories under the named directories with |
| 186 | ## the specified name. |
| 187 | ## Meant to be used like: |
| 188 | ## INC_DIRS := $(call all-named-dirs-under,inc,.) |
| 189 | ########################################################### |
| 190 | |
| 191 | define all-named-dirs-under |
| 192 | $(call find-subdir-files,$(2) -type d -name "$(1)") |
| 193 | endef |
| 194 | |
| 195 | ########################################################### |
| 196 | ## Find all the directories under the current directory that |
| 197 | ## haves name that match $(1) |
| 198 | ########################################################### |
| 199 | |
| 200 | define all-subdir-named-dirs |
| 201 | $(call all-named-dirs-under,$(1),.) |
| 202 | endef |
| 203 | |
| 204 | ########################################################### |
| 205 | ## Find all of the files under the named directories with |
| 206 | ## the specified name. |
| 207 | ## Meant to be used like: |
| 208 | ## SRC_FILES := $(call all-named-files-under,*.h,src tests) |
| 209 | ########################################################### |
| 210 | |
| 211 | define all-named-files-under |
| 212 | $(call find-files-in-subdirs,$(LOCAL_PATH),"$(1)",$(2)) |
| 213 | endef |
| 214 | |
| 215 | ########################################################### |
| 216 | ## Find all of the files under the current directory with |
| 217 | ## the specified name. |
| 218 | ########################################################### |
| 219 | |
| 220 | define all-subdir-named-files |
| 221 | $(call all-named-files-under,$(1),.) |
| 222 | endef |
| 223 | |
| 224 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 225 | ## Find all of the java files under the named directories. |
| 226 | ## Meant to be used like: |
| 227 | ## SRC_FILES := $(call all-java-files-under,src tests) |
| 228 | ########################################################### |
| 229 | |
| 230 | define all-java-files-under |
Dan Willemsen | 92f5fcc | 2015-10-12 15:26:52 -0700 | [diff] [blame] | 231 | $(call all-named-files-under,*.java,$(1)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 232 | endef |
| 233 | |
| 234 | ########################################################### |
| 235 | ## Find all of the java files from here. Meant to be used like: |
| 236 | ## SRC_FILES := $(call all-subdir-java-files) |
| 237 | ########################################################### |
| 238 | |
| 239 | define all-subdir-java-files |
| 240 | $(call all-java-files-under,.) |
| 241 | endef |
| 242 | |
| 243 | ########################################################### |
| 244 | ## Find all of the c files under the named directories. |
| 245 | ## Meant to be used like: |
| 246 | ## SRC_FILES := $(call all-c-files-under,src tests) |
| 247 | ########################################################### |
| 248 | |
| 249 | define all-c-files-under |
Dan Willemsen | 92f5fcc | 2015-10-12 15:26:52 -0700 | [diff] [blame] | 250 | $(call all-named-files-under,*.c,$(1)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 251 | endef |
| 252 | |
| 253 | ########################################################### |
| 254 | ## Find all of the c files from here. Meant to be used like: |
| 255 | ## SRC_FILES := $(call all-subdir-c-files) |
| 256 | ########################################################### |
| 257 | |
| 258 | define all-subdir-c-files |
| 259 | $(call all-c-files-under,.) |
| 260 | endef |
| 261 | |
| 262 | ########################################################### |
Dan Willemsen | 379f9f9 | 2015-09-29 16:26:28 -0700 | [diff] [blame] | 263 | ## Find all of the cpp files under the named directories. |
| 264 | ## LOCAL_CPP_EXTENSION is respected if set. |
| 265 | ## Meant to be used like: |
| 266 | ## SRC_FILES := $(call all-cpp-files-under,src tests) |
| 267 | ########################################################### |
| 268 | |
| 269 | define all-cpp-files-under |
| 270 | $(sort $(patsubst ./%,%, \ |
| 271 | $(shell cd $(LOCAL_PATH) ; \ |
| 272 | find -L $(1) -name "*$(or $(LOCAL_CPP_EXTENSION),.cpp)" -and -not -name ".*") \ |
| 273 | )) |
| 274 | endef |
| 275 | |
| 276 | ########################################################### |
| 277 | ## Find all of the cpp files from here. Meant to be used like: |
| 278 | ## SRC_FILES := $(call all-subdir-cpp-files) |
| 279 | ########################################################### |
| 280 | |
| 281 | define all-subdir-cpp-files |
| 282 | $(call all-cpp-files-under,.) |
| 283 | endef |
| 284 | |
| 285 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 286 | ## Find all files named "I*.aidl" under the named directories, |
| 287 | ## which must be relative to $(LOCAL_PATH). The returned list |
| 288 | ## is relative to $(LOCAL_PATH). |
| 289 | ########################################################### |
| 290 | |
| 291 | define all-Iaidl-files-under |
Dan Willemsen | 92f5fcc | 2015-10-12 15:26:52 -0700 | [diff] [blame] | 292 | $(call all-named-files-under,I*.aidl,$(1)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 293 | endef |
| 294 | |
| 295 | ########################################################### |
| 296 | ## Find all of the "I*.aidl" files under $(LOCAL_PATH). |
| 297 | ########################################################### |
| 298 | |
| 299 | define all-subdir-Iaidl-files |
| 300 | $(call all-Iaidl-files-under,.) |
| 301 | endef |
| 302 | |
| 303 | ########################################################### |
Bjorn Bringert | a89c990 | 2010-02-02 17:36:20 +0000 | [diff] [blame] | 304 | ## Find all of the logtags files under the named directories. |
| 305 | ## Meant to be used like: |
| 306 | ## SRC_FILES := $(call all-logtags-files-under,src) |
| 307 | ########################################################### |
| 308 | |
| 309 | define all-logtags-files-under |
Dan Willemsen | 92f5fcc | 2015-10-12 15:26:52 -0700 | [diff] [blame] | 310 | $(call all-named-files-under,*.logtags,$(1)) |
Bjorn Bringert | a89c990 | 2010-02-02 17:36:20 +0000 | [diff] [blame] | 311 | endef |
| 312 | |
| 313 | ########################################################### |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 314 | ## Find all of the .proto files under the named directories. |
| 315 | ## Meant to be used like: |
| 316 | ## SRC_FILES := $(call all-proto-files-under,src) |
| 317 | ########################################################### |
| 318 | |
| 319 | define all-proto-files-under |
Dan Willemsen | 92f5fcc | 2015-10-12 15:26:52 -0700 | [diff] [blame] | 320 | $(call all-named-files-under,*.proto,$(1)) |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 321 | endef |
| 322 | |
| 323 | ########################################################### |
Ying Wang | 0bd59a0 | 2010-07-15 17:17:52 -0700 | [diff] [blame] | 324 | ## Find all of the RenderScript files under the named directories. |
| 325 | ## Meant to be used like: |
| 326 | ## SRC_FILES := $(call all-renderscript-files-under,src) |
| 327 | ########################################################### |
| 328 | |
| 329 | define all-renderscript-files-under |
Dan Willemsen | 92f5fcc | 2015-10-12 15:26:52 -0700 | [diff] [blame] | 330 | $(call find-subdir-files,$(1) \( -name "*.rs" -or -name "*.fs" \) -and -not -name ".*") |
Ying Wang | 0bd59a0 | 2010-07-15 17:17:52 -0700 | [diff] [blame] | 331 | endef |
| 332 | |
| 333 | ########################################################### |
Elliott Hughes | e3b044a | 2014-02-11 13:48:35 -0800 | [diff] [blame] | 334 | ## Find all of the S files under the named directories. |
| 335 | ## Meant to be used like: |
| 336 | ## SRC_FILES := $(call all-c-files-under,src tests) |
| 337 | ########################################################### |
| 338 | |
| 339 | define all-S-files-under |
Dan Willemsen | 92f5fcc | 2015-10-12 15:26:52 -0700 | [diff] [blame] | 340 | $(call all-named-files-under,*.S,$(1)) |
Elliott Hughes | e3b044a | 2014-02-11 13:48:35 -0800 | [diff] [blame] | 341 | endef |
| 342 | |
| 343 | ########################################################### |
Jean-Baptiste Queru | 0a3cfdc | 2009-12-17 17:47:28 -0800 | [diff] [blame] | 344 | ## Find all of the html files under the named directories. |
| 345 | ## Meant to be used like: |
| 346 | ## SRC_FILES := $(call all-html-files-under,src tests) |
| 347 | ########################################################### |
| 348 | |
| 349 | define all-html-files-under |
Dan Willemsen | 92f5fcc | 2015-10-12 15:26:52 -0700 | [diff] [blame] | 350 | $(call all-named-files-under,*.html,$(1)) |
Jean-Baptiste Queru | 0a3cfdc | 2009-12-17 17:47:28 -0800 | [diff] [blame] | 351 | endef |
| 352 | |
| 353 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 354 | ## Find all of the html files from here. Meant to be used like: |
| 355 | ## SRC_FILES := $(call all-subdir-html-files) |
| 356 | ########################################################### |
| 357 | |
| 358 | define all-subdir-html-files |
Jean-Baptiste Queru | 0a3cfdc | 2009-12-17 17:47:28 -0800 | [diff] [blame] | 359 | $(call all-html-files-under,.) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 360 | endef |
| 361 | |
| 362 | ########################################################### |
| 363 | ## Find all of the files matching pattern |
| 364 | ## SRC_FILES := $(call find-subdir-files, <pattern>) |
| 365 | ########################################################### |
| 366 | |
| 367 | define find-subdir-files |
Dan Willemsen | 4d66adf | 2015-09-22 16:54:12 -0700 | [diff] [blame] | 368 | $(sort $(patsubst ./%,%,$(shell cd $(LOCAL_PATH) ; find -L $(1)))) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 369 | endef |
| 370 | |
| 371 | ########################################################### |
| 372 | # find the files in the subdirectory $1 of LOCAL_DIR |
| 373 | # matching pattern $2, filtering out files $3 |
| 374 | # e.g. |
| 375 | # SRC_FILES += $(call find-subdir-subdir-files, \ |
| 376 | # css, *.cpp, DontWantThis.cpp) |
| 377 | ########################################################### |
| 378 | |
| 379 | define find-subdir-subdir-files |
Dan Willemsen | 4d66adf | 2015-09-22 16:54:12 -0700 | [diff] [blame] | 380 | $(sort $(filter-out $(patsubst %,$(1)/%,$(3)),$(patsubst ./%,%,$(shell cd \ |
| 381 | $(LOCAL_PATH) ; find -L $(1) -maxdepth 1 -name $(2))))) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 382 | endef |
| 383 | |
| 384 | ########################################################### |
| 385 | ## Find all of the files matching pattern |
| 386 | ## SRC_FILES := $(call all-subdir-java-files) |
| 387 | ########################################################### |
| 388 | |
| 389 | define find-subdir-assets |
Dan Willemsen | 4d66adf | 2015-09-22 16:54:12 -0700 | [diff] [blame] | 390 | $(sort $(if $(1),$(patsubst ./%,%, \ |
Ying Wang | 6ab5d6a | 2011-08-10 16:05:51 -0700 | [diff] [blame] | 391 | $(shell if [ -d $(1) ] ; then cd $(1) ; find ./ -not -name '.*' -and -type f -and -not -type l ; fi)), \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 392 | $(warning Empty argument supplied to find-subdir-assets) \ |
Dan Willemsen | 4d66adf | 2015-09-22 16:54:12 -0700 | [diff] [blame] | 393 | )) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 394 | endef |
| 395 | |
| 396 | ########################################################### |
| 397 | ## Find various file types in a list of directories relative to $(LOCAL_PATH) |
| 398 | ########################################################### |
| 399 | |
| 400 | define find-other-java-files |
Dan Willemsen | 92f5fcc | 2015-10-12 15:26:52 -0700 | [diff] [blame] | 401 | $(call all-java-files-under,$(1)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 402 | endef |
| 403 | |
| 404 | define find-other-html-files |
Dan Willemsen | 92f5fcc | 2015-10-12 15:26:52 -0700 | [diff] [blame] | 405 | $(call all-html-files-under,$(1)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 406 | endef |
| 407 | |
| 408 | ########################################################### |
Ying Wang | 85898bc | 2013-12-04 16:04:49 -0800 | [diff] [blame] | 409 | # Use utility find to find given files in the given subdirs. |
| 410 | # This function uses $(1), instead of LOCAL_PATH as the base. |
| 411 | # $(1): the base dir, relative to the root of the source tree. |
| 412 | # $(2): the file name pattern to be passed to find as "-name". |
| 413 | # $(3): a list of subdirs of the base dir. |
| 414 | # Returns: a list of paths relative to the base dir. |
| 415 | ########################################################### |
| 416 | |
| 417 | define find-files-in-subdirs |
Dan Willemsen | 4d66adf | 2015-09-22 16:54:12 -0700 | [diff] [blame] | 418 | $(sort $(patsubst ./%,%, \ |
Ying Wang | 85898bc | 2013-12-04 16:04:49 -0800 | [diff] [blame] | 419 | $(shell cd $(1) ; \ |
| 420 | find -L $(3) -name $(2) -and -not -name ".*") \ |
Dan Willemsen | 4d66adf | 2015-09-22 16:54:12 -0700 | [diff] [blame] | 421 | )) |
Ying Wang | 85898bc | 2013-12-04 16:04:49 -0800 | [diff] [blame] | 422 | endef |
| 423 | |
| 424 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 425 | ## Scan through each directory of $(1) looking for files |
| 426 | ## that match $(2) using $(wildcard). Useful for seeing if |
| 427 | ## a given directory or one of its parents contains |
| 428 | ## a particular file. Returns the first match found, |
| 429 | ## starting furthest from the root. |
| 430 | ########################################################### |
| 431 | |
| 432 | define find-parent-file |
| 433 | $(strip \ |
Dan Willemsen | 7c3e3f8 | 2015-09-29 16:30:21 -0700 | [diff] [blame] | 434 | $(eval _fpf := $(sort $(wildcard $(foreach f, $(2), $(strip $(1))/$(f))))) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 435 | $(if $(_fpf),$(_fpf), \ |
| 436 | $(if $(filter-out ./ .,$(1)), \ |
| 437 | $(call find-parent-file,$(patsubst %/,%,$(dir $(1))),$(2)) \ |
| 438 | ) \ |
| 439 | ) \ |
| 440 | ) |
| 441 | endef |
| 442 | |
| 443 | ########################################################### |
| 444 | ## Function we can evaluate to introduce a dynamic dependency |
| 445 | ########################################################### |
| 446 | |
| 447 | define add-dependency |
| 448 | $(1): $(2) |
| 449 | endef |
| 450 | |
| 451 | ########################################################### |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 452 | ## Reverse order of a list |
| 453 | ########################################################### |
| 454 | |
| 455 | define reverse-list |
| 456 | $(if $(1),$(call reverse-list,$(wordlist 2,$(words $(1)),$(1)))) $(firstword $(1)) |
| 457 | endef |
| 458 | |
| 459 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 460 | ## The intermediates directory. Where object files go for |
| 461 | ## a given target. We could technically get away without |
| 462 | ## the "_intermediates" suffix on the directory, but it's |
| 463 | ## nice to be able to grep for that string to find out if |
| 464 | ## anyone's abusing the system. |
| 465 | ########################################################### |
| 466 | |
| 467 | # $(1): target class, like "APPS" |
| 468 | # $(2): target name, like "NotePad" |
| 469 | # $(3): if non-empty, this is a HOST target. |
| 470 | # $(4): if non-empty, force the intermediates to be COMMON |
Dan Willemsen | 057aaea | 2015-08-14 12:59:50 -0700 | [diff] [blame] | 471 | # $(5): if non-empty, force the intermediates to be for the 2nd arch |
| 472 | # $(6): if non-empty, force the intermediates to be for the host cross os |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 473 | define intermediates-dir-for |
| 474 | $(strip \ |
| 475 | $(eval _idfClass := $(strip $(1))) \ |
| 476 | $(if $(_idfClass),, \ |
| 477 | $(error $(LOCAL_PATH): Class not defined in call to intermediates-dir-for)) \ |
| 478 | $(eval _idfName := $(strip $(2))) \ |
| 479 | $(if $(_idfName),, \ |
| 480 | $(error $(LOCAL_PATH): Name not defined in call to intermediates-dir-for)) \ |
Dan Willemsen | 057aaea | 2015-08-14 12:59:50 -0700 | [diff] [blame] | 481 | $(eval _idfPrefix := $(if $(strip $(3)),$(if $(strip $(6)),HOST_CROSS,HOST),TARGET)) \ |
Colin Cross | ae2986e | 2014-06-17 21:35:44 -0700 | [diff] [blame] | 482 | $(eval _idf2ndArchPrefix := $(if $(strip $(5)),$(TARGET_2ND_ARCH_VAR_PREFIX))) \ |
Ying Wang | a83940f | 2010-09-24 18:09:04 -0700 | [diff] [blame] | 483 | $(if $(filter $(_idfPrefix)-$(_idfClass),$(COMMON_MODULE_CLASSES))$(4), \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 484 | $(eval _idfIntBase := $($(_idfPrefix)_OUT_COMMON_INTERMEDIATES)) \ |
Dan Willemsen | c12ad5c | 2016-02-13 00:19:40 -0800 | [diff] [blame] | 485 | ,$(if $(filter $(_idfClass),$(PER_ARCH_MODULE_CLASSES)),\ |
Colin Cross | 02e31d2 | 2014-01-24 13:38:08 -0800 | [diff] [blame] | 486 | $(eval _idfIntBase := $($(_idf2ndArchPrefix)$(_idfPrefix)_OUT_INTERMEDIATES)) \ |
| 487 | ,$(eval _idfIntBase := $($(_idfPrefix)_OUT_INTERMEDIATES)) \ |
| 488 | ) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 489 | ) \ |
| 490 | $(_idfIntBase)/$(_idfClass)/$(_idfName)_intermediates \ |
| 491 | ) |
| 492 | endef |
| 493 | |
| 494 | # Uses LOCAL_MODULE_CLASS, LOCAL_MODULE, and LOCAL_IS_HOST_MODULE |
| 495 | # to determine the intermediates directory. |
| 496 | # |
| 497 | # $(1): if non-empty, force the intermediates to be COMMON |
Ying Wang | 61d499b | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 498 | # $(2): if non-empty, force the intermediates to be for the 2nd arch |
Dan Willemsen | 057aaea | 2015-08-14 12:59:50 -0700 | [diff] [blame] | 499 | # $(3): if non-empty, force the intermediates to be for the host cross os |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 500 | define local-intermediates-dir |
| 501 | $(strip \ |
| 502 | $(if $(strip $(LOCAL_MODULE_CLASS)),, \ |
| 503 | $(error $(LOCAL_PATH): LOCAL_MODULE_CLASS not defined before call to local-intermediates-dir)) \ |
| 504 | $(if $(strip $(LOCAL_MODULE)),, \ |
| 505 | $(error $(LOCAL_PATH): LOCAL_MODULE not defined before call to local-intermediates-dir)) \ |
Dan Willemsen | 057aaea | 2015-08-14 12:59:50 -0700 | [diff] [blame] | 506 | $(call intermediates-dir-for,$(LOCAL_MODULE_CLASS),$(LOCAL_MODULE),$(LOCAL_IS_HOST_MODULE),$(1),$(2),$(3)) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 507 | ) |
| 508 | endef |
| 509 | |
| 510 | ########################################################### |
Colin Cross | d826264 | 2014-01-24 23:17:21 -0800 | [diff] [blame] | 511 | ## The generated sources directory. Placing generated |
| 512 | ## source files directly in the intermediates directory |
| 513 | ## causes problems for multiarch builds, where there are |
| 514 | ## two intermediates directories for a single target. Put |
| 515 | ## them in a separate directory, and they will be copied to |
| 516 | ## each intermediates directory automatically. |
| 517 | ########################################################### |
| 518 | |
| 519 | # $(1): target class, like "APPS" |
| 520 | # $(2): target name, like "NotePad" |
| 521 | # $(3): if non-empty, this is a HOST target. |
| 522 | # $(4): if non-empty, force the generated sources to be COMMON |
| 523 | define generated-sources-dir-for |
| 524 | $(strip \ |
| 525 | $(eval _idfClass := $(strip $(1))) \ |
| 526 | $(if $(_idfClass),, \ |
| 527 | $(error $(LOCAL_PATH): Class not defined in call to generated-sources-dir-for)) \ |
| 528 | $(eval _idfName := $(strip $(2))) \ |
| 529 | $(if $(_idfName),, \ |
| 530 | $(error $(LOCAL_PATH): Name not defined in call to generated-sources-dir-for)) \ |
| 531 | $(eval _idfPrefix := $(if $(strip $(3)),HOST,TARGET)) \ |
| 532 | $(if $(filter $(_idfPrefix)-$(_idfClass),$(COMMON_MODULE_CLASSES))$(4), \ |
Paul Duffin | 699a322 | 2015-11-25 13:14:23 +0000 | [diff] [blame] | 533 | $(eval _idfIntBase := $($(_idfPrefix)_OUT_COMMON_GEN)) \ |
Colin Cross | d826264 | 2014-01-24 23:17:21 -0800 | [diff] [blame] | 534 | , \ |
| 535 | $(eval _idfIntBase := $($(_idfPrefix)_OUT_GEN)) \ |
| 536 | ) \ |
| 537 | $(_idfIntBase)/$(_idfClass)/$(_idfName)_intermediates \ |
| 538 | ) |
| 539 | endef |
| 540 | |
| 541 | # Uses LOCAL_MODULE_CLASS, LOCAL_MODULE, and LOCAL_IS_HOST_MODULE |
| 542 | # to determine the generated sources directory. |
| 543 | # |
| 544 | # $(1): if non-empty, force the intermediates to be COMMON |
| 545 | define local-generated-sources-dir |
| 546 | $(strip \ |
| 547 | $(if $(strip $(LOCAL_MODULE_CLASS)),, \ |
| 548 | $(error $(LOCAL_PATH): LOCAL_MODULE_CLASS not defined before call to local-generated-sources-dir)) \ |
| 549 | $(if $(strip $(LOCAL_MODULE)),, \ |
| 550 | $(error $(LOCAL_PATH): LOCAL_MODULE not defined before call to local-generated-sources-dir)) \ |
| 551 | $(call generated-sources-dir-for,$(LOCAL_MODULE_CLASS),$(LOCAL_MODULE),$(LOCAL_IS_HOST_MODULE),$(1)) \ |
| 552 | ) |
| 553 | endef |
| 554 | |
| 555 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 556 | ## Convert "path/to/libXXX.so" to "-lXXX". |
| 557 | ## Any "path/to/libXXX.a" elements pass through unchanged. |
| 558 | ########################################################### |
| 559 | |
| 560 | define normalize-libraries |
| 561 | $(foreach so,$(filter %.so,$(1)),-l$(patsubst lib%.so,%,$(notdir $(so))))\ |
| 562 | $(filter-out %.so,$(1)) |
| 563 | endef |
| 564 | |
| 565 | # TODO: change users to call the common version. |
| 566 | define normalize-host-libraries |
| 567 | $(call normalize-libraries,$(1)) |
| 568 | endef |
| 569 | |
| 570 | define normalize-target-libraries |
| 571 | $(call normalize-libraries,$(1)) |
| 572 | endef |
| 573 | |
| 574 | ########################################################### |
| 575 | ## Convert a list of short module names (e.g., "framework", "Browser") |
| 576 | ## into the list of files that are built for those modules. |
| 577 | ## NOTE: this won't return reliable results until after all |
| 578 | ## sub-makefiles have been included. |
| 579 | ## $(1): target list |
| 580 | ########################################################### |
| 581 | |
| 582 | define module-built-files |
| 583 | $(foreach module,$(1),$(ALL_MODULES.$(module).BUILT)) |
| 584 | endef |
| 585 | |
| 586 | ########################################################### |
| 587 | ## Convert a list of short modules names (e.g., "framework", "Browser") |
| 588 | ## into the list of files that are installed for those modules. |
| 589 | ## NOTE: this won't return reliable results until after all |
| 590 | ## sub-makefiles have been included. |
| 591 | ## $(1): target list |
| 592 | ########################################################### |
| 593 | |
| 594 | define module-installed-files |
| 595 | $(foreach module,$(1),$(ALL_MODULES.$(module).INSTALLED)) |
| 596 | endef |
| 597 | |
| 598 | ########################################################### |
Joe Onorato | 64d85d0 | 2009-04-09 19:31:12 -0700 | [diff] [blame] | 599 | ## Convert a list of short modules names (e.g., "framework", "Browser") |
| 600 | ## into the list of files that should be used when linking |
| 601 | ## against that module as a public API. |
| 602 | ## TODO: Allow this for more than JAVA_LIBRARIES modules |
| 603 | ## NOTE: this won't return reliable results until after all |
| 604 | ## sub-makefiles have been included. |
| 605 | ## $(1): target list |
| 606 | ########################################################### |
| 607 | |
| 608 | define module-stubs-files |
| 609 | $(foreach module,$(1),$(ALL_MODULES.$(module).STUBS)) |
| 610 | endef |
| 611 | |
| 612 | ########################################################### |
| 613 | ## Evaluates to the timestamp file for a doc module, which |
| 614 | ## is the dependency that should be used. |
| 615 | ## $(1): doc module |
| 616 | ########################################################### |
| 617 | |
| 618 | define doc-timestamp-for |
| 619 | $(OUT_DOCS)/$(strip $(1))-timestamp |
| 620 | endef |
| 621 | |
| 622 | |
| 623 | ########################################################### |
Ying Wang | 912f828 | 2010-09-28 17:27:56 -0700 | [diff] [blame] | 624 | ## Convert "core ext framework" to "out/.../javalib.jar ..." |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 625 | ## $(1): library list |
| 626 | ## $(2): Non-empty if IS_HOST_MODULE |
| 627 | ########################################################### |
| 628 | |
| 629 | # $(1): library name |
| 630 | # $(2): Non-empty if IS_HOST_MODULE |
| 631 | define _java-lib-dir |
| 632 | $(call intermediates-dir-for, \ |
Ying Wang | 912f828 | 2010-09-28 17:27:56 -0700 | [diff] [blame] | 633 | JAVA_LIBRARIES,$(1),$(2),COMMON) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 634 | endef |
| 635 | |
| 636 | # $(1): library name |
| 637 | # $(2): Non-empty if IS_HOST_MODULE |
| 638 | define _java-lib-full-classes.jar |
Ying Wang | 912f828 | 2010-09-28 17:27:56 -0700 | [diff] [blame] | 639 | $(call _java-lib-dir,$(1),$(2))/classes$(COMMON_JAVA_PACKAGE_SUFFIX) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 640 | endef |
| 641 | |
| 642 | # $(1): library name list |
| 643 | # $(2): Non-empty if IS_HOST_MODULE |
| 644 | define java-lib-files |
| 645 | $(foreach lib,$(1),$(call _java-lib-full-classes.jar,$(lib),$(2))) |
| 646 | endef |
| 647 | |
| 648 | # $(1): library name |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 649 | # $(2): Non-empty if IS_HOST_MODULE |
| 650 | define _java-lib-full-dep |
Ying Wang | 833b427 | 2015-01-21 17:30:21 -0800 | [diff] [blame] | 651 | $(call _java-lib-dir,$(1),$(2))/$(if $(2),javalib,classes)$(COMMON_JAVA_PACKAGE_SUFFIX) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 652 | endef |
| 653 | |
| 654 | # $(1): library name list |
| 655 | # $(2): Non-empty if IS_HOST_MODULE |
| 656 | define java-lib-deps |
| 657 | $(foreach lib,$(1),$(call _java-lib-full-dep,$(lib),$(2))) |
| 658 | endef |
| 659 | |
| 660 | ########################################################### |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 661 | ## Convert "core ext framework" to "out/.../classes.jack ..." |
| 662 | ## $(1): library list |
| 663 | ## $(2): Non-empty if IS_HOST_MODULE |
| 664 | ########################################################### |
| 665 | |
| 666 | # $(1): library name |
| 667 | # $(2): Non-empty if IS_HOST_MODULE |
| 668 | define _jack-lib-full-classes |
| 669 | $(call _java-lib-dir,$(1),$(2))/classes.jack |
| 670 | endef |
| 671 | |
| 672 | # $(1): library name list |
| 673 | # $(2): Non-empty if IS_HOST_MODULE |
| 674 | define jack-lib-files |
| 675 | $(foreach lib,$(1),$(call _jack-lib-full-classes,$(lib),$(2))) |
| 676 | endef |
| 677 | |
| 678 | # $(1): library name |
| 679 | # $(2): Non-empty if IS_HOST_MODULE |
| 680 | define _jack-lib-full-dep |
| 681 | $(call _jack-lib-full-classes,$(1),$(2)) |
| 682 | endef |
| 683 | |
| 684 | # $(1): library name list |
| 685 | # $(2): Non-empty if IS_HOST_MODULE |
| 686 | define jack-lib-deps |
| 687 | $(foreach lib,$(1),$(call _jack-lib-full-dep,$(lib),$(2))) |
| 688 | endef |
| 689 | |
| 690 | ########################################################### |
Joe Onorato | 8dc8faa | 2010-09-14 13:09:48 -0400 | [diff] [blame] | 691 | ## Run rot13 on a string |
| 692 | ## $(1): the string. Must be one line. |
| 693 | ########################################################### |
| 694 | define rot13 |
| 695 | $(shell echo $(1) | tr 'a-zA-Z' 'n-za-mN-ZA-M') |
| 696 | endef |
| 697 | |
| 698 | |
| 699 | ########################################################### |
| 700 | ## Returns true if $(1) and $(2) are equal. Returns |
| 701 | ## the empty string if they are not equal. |
| 702 | ########################################################### |
| 703 | define streq |
| 704 | $(strip $(if $(strip $(1)),\ |
| 705 | $(if $(strip $(2)),\ |
| 706 | $(if $(filter-out __,_$(subst $(strip $(1)),,$(strip $(2)))$(subst $(strip $(2)),,$(strip $(1)))_),,true), \ |
| 707 | ),\ |
| 708 | $(if $(strip $(2)),\ |
| 709 | ,\ |
| 710 | true)\ |
| 711 | )) |
| 712 | endef |
| 713 | |
| 714 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 715 | ## Convert "a b c" into "a:b:c" |
| 716 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 717 | define normalize-path-list |
| 718 | $(subst $(space),:,$(strip $(1))) |
| 719 | endef |
| 720 | |
| 721 | ########################################################### |
Joe Onorato | 64d85d0 | 2009-04-09 19:31:12 -0700 | [diff] [blame] | 722 | ## Read the word out of a colon-separated list of words. |
| 723 | ## This has the same behavior as the built-in function |
| 724 | ## $(word n,str). |
| 725 | ## |
| 726 | ## The individual words may not contain spaces. |
| 727 | ## |
| 728 | ## $(1): 1 based index |
| 729 | ## $(2): value of the form a:b:c... |
| 730 | ########################################################### |
| 731 | |
| 732 | define word-colon |
| 733 | $(word $(1),$(subst :,$(space),$(2))) |
| 734 | endef |
| 735 | |
| 736 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 737 | ## Convert "a=b c= d e = f" into "a=b c=d e=f" |
| 738 | ## |
| 739 | ## $(1): list to collapse |
| 740 | ## $(2): if set, separator word; usually "=", ":", or ":=" |
| 741 | ## Defaults to "=" if not set. |
| 742 | ########################################################### |
| 743 | |
| 744 | define collapse-pairs |
| 745 | $(eval _cpSEP := $(strip $(if $(2),$(2),=)))\ |
| 746 | $(subst $(space)$(_cpSEP)$(space),$(_cpSEP),$(strip \ |
| 747 | $(subst $(_cpSEP), $(_cpSEP) ,$(1)))) |
| 748 | endef |
| 749 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 750 | ########################################################### |
Ying Wang | 7e8d442 | 2011-06-17 17:05:35 -0700 | [diff] [blame] | 751 | ## Given a list of pairs, if multiple pairs have the same |
| 752 | ## first components, keep only the first pair. |
| 753 | ## |
| 754 | ## $(1): list of pairs |
| 755 | ## $(2): the separator word, such as ":", "=", etc. |
| 756 | define uniq-pairs-by-first-component |
| 757 | $(eval _upbfc_fc_set :=)\ |
| 758 | $(strip $(foreach w,$(1), $(eval _first := $(word 1,$(subst $(2),$(space),$(w))))\ |
| 759 | $(if $(filter $(_upbfc_fc_set),$(_first)),,$(w)\ |
| 760 | $(eval _upbfc_fc_set += $(_first)))))\ |
| 761 | $(eval _upbfc_fc_set :=)\ |
| 762 | $(eval _first:=) |
| 763 | endef |
| 764 | |
| 765 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 766 | ## MODULE_TAG set operations |
| 767 | ########################################################### |
| 768 | |
| 769 | # Given a list of tags, return the targets that specify |
| 770 | # any of those tags. |
| 771 | # $(1): tag list |
| 772 | define modules-for-tag-list |
Ying Wang | 634f799 | 2014-11-18 12:41:53 -0800 | [diff] [blame] | 773 | $(sort $(foreach tag,$(1),$(foreach m,$(ALL_MODULE_NAME_TAGS.$(tag)),$(ALL_MODULES.$(m).INSTALLED)))) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 774 | endef |
| 775 | |
| 776 | # Same as modules-for-tag-list, but operates on |
| 777 | # ALL_MODULE_NAME_TAGS. |
| 778 | # $(1): tag list |
| 779 | define module-names-for-tag-list |
| 780 | $(sort $(foreach tag,$(1),$(ALL_MODULE_NAME_TAGS.$(tag)))) |
| 781 | endef |
| 782 | |
| 783 | # Given an accept and reject list, find the matching |
| 784 | # set of targets. If a target has multiple tags and |
| 785 | # any of them are rejected, the target is rejected. |
| 786 | # Reject overrides accept. |
| 787 | # $(1): list of tags to accept |
| 788 | # $(2): list of tags to reject |
| 789 | #TODO(dbort): do $(if $(strip $(1)),$(1),$(ALL_MODULE_TAGS)) |
Jean-Baptiste Queru | 75127b7 | 2010-01-07 11:44:22 -0800 | [diff] [blame] | 790 | #TODO(jbq): as of 20100106 nobody uses the second parameter |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 791 | define get-tagged-modules |
| 792 | $(filter-out \ |
| 793 | $(call modules-for-tag-list,$(2)), \ |
| 794 | $(call modules-for-tag-list,$(1))) |
| 795 | endef |
| 796 | |
Joe Onorato | 64d85d0 | 2009-04-09 19:31:12 -0700 | [diff] [blame] | 797 | ########################################################### |
| 798 | ## Append a leaf to a base path. Properly deals with |
| 799 | ## base paths ending in /. |
| 800 | ## |
| 801 | ## $(1): base path |
| 802 | ## $(2): leaf path |
| 803 | ########################################################### |
| 804 | |
| 805 | define append-path |
| 806 | $(subst //,/,$(1)/$(2)) |
| 807 | endef |
| 808 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 809 | |
| 810 | ########################################################### |
| 811 | ## Package filtering |
| 812 | ########################################################### |
| 813 | |
| 814 | # Given a list of installed modules (short or long names) |
| 815 | # return a list of the packages (yes, .apk packages, not |
| 816 | # modules in general) that are overridden by this list and, |
| 817 | # therefore, should not be installed. |
| 818 | # $(1): mixed list of installed modules |
| 819 | # TODO: This is fragile; find a reliable way to get this information. |
| 820 | define _get-package-overrides |
| 821 | $(eval ### Discard any words containing slashes, unless they end in .apk, \ |
| 822 | ### in which case trim off the directory component and the suffix. \ |
| 823 | ### If there are no slashes, keep the entire word.) |
| 824 | $(eval _gpo_names := $(subst /,@@@ @@@,$(1))) |
| 825 | $(eval _gpo_names := \ |
| 826 | $(filter %.apk,$(_gpo_names)) \ |
| 827 | $(filter-out %@@@ @@@%,$(_gpo_names))) |
| 828 | $(eval _gpo_names := $(patsubst %.apk,%,$(_gpo_names))) |
| 829 | $(eval _gpo_names := $(patsubst @@@%,%,$(_gpo_names))) |
| 830 | |
| 831 | $(eval ### Remove any remaining words that contain dots.) |
| 832 | $(eval _gpo_names := $(subst .,@@@ @@@,$(_gpo_names))) |
| 833 | $(eval _gpo_names := $(filter-out %@@@ @@@%,$(_gpo_names))) |
| 834 | |
| 835 | $(eval ### Now we have a list of any words that could possibly refer to \ |
| 836 | ### packages, although there may be words that do not. Only \ |
| 837 | ### real packages will be present under PACKAGES.*, though.) |
| 838 | $(foreach _gpo_name,$(_gpo_names),$(PACKAGES.$(_gpo_name).OVERRIDES)) |
| 839 | endef |
| 840 | |
| 841 | define get-package-overrides |
Conley Owens | d7a1a9b | 2011-12-22 09:46:19 -0800 | [diff] [blame] | 842 | $(sort $(strip $(call _get-package-overrides,$(1)))) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 843 | endef |
| 844 | |
| 845 | ########################################################### |
| 846 | ## Output the command lines, or not |
| 847 | ########################################################### |
| 848 | |
| 849 | ifeq ($(strip $(SHOW_COMMANDS)),) |
| 850 | define pretty |
| 851 | @echo $1 |
| 852 | endef |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 853 | else |
| 854 | define pretty |
| 855 | endef |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 856 | endif |
| 857 | |
| 858 | ########################################################### |
Shinichiro Hamaji | 2e45fd0 | 2016-01-25 18:59:43 +0900 | [diff] [blame] | 859 | ## Commands for munging the dependency files the compiler generates |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 860 | ########################################################### |
Ying Wang | c23f4ef | 2012-09-07 17:04:06 -0700 | [diff] [blame] | 861 | # $(1): the input .d file |
| 862 | # $(2): the output .P file |
| 863 | define transform-d-to-p-args |
| 864 | $(hide) cp $(1) $(2); \ |
| 865 | sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ |
| 866 | -e '/^$$/ d' -e 's/$$/ :/' < $(1) >> $(2); \ |
| 867 | rm -f $(1) |
| 868 | endef |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 869 | |
| 870 | define transform-d-to-p |
Ying Wang | c23f4ef | 2012-09-07 17:04:06 -0700 | [diff] [blame] | 871 | $(call transform-d-to-p-args,$(@:%.o=%.d),$(@:%.o=%.P)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 872 | endef |
| 873 | |
| 874 | ########################################################### |
Shinichiro Hamaji | 2e45fd0 | 2016-01-25 18:59:43 +0900 | [diff] [blame] | 875 | ## Commands for including the dependency files the compiler generates |
| 876 | ########################################################### |
| 877 | # $(1): the .P file |
| 878 | # $(2): the main build target |
| 879 | ifeq ($(BUILDING_WITH_NINJA),true) |
| 880 | define include-depfile |
| 881 | $(eval $(2) : .KATI_DEPFILE := $1) |
| 882 | endef |
| 883 | else |
| 884 | define include-depfile |
| 885 | $(eval -include $1) |
| 886 | endef |
| 887 | endif |
| 888 | |
| 889 | ########################################################### |
Dan Willemsen | 3bb168f | 2016-01-19 20:07:08 -0800 | [diff] [blame] | 890 | ## Track source files compiled to objects |
| 891 | ########################################################### |
| 892 | # $(1): list of sources |
| 893 | # $(2): list of matching objects |
| 894 | define track-src-file-obj |
| 895 | $(eval $(call _track-src-file-obj,$(1))) |
| 896 | endef |
| 897 | define _track-src-file-obj |
| 898 | i := w |
| 899 | $(foreach s,$(1), |
| 900 | my_tracked_src_files += $(s) |
| 901 | my_src_file_obj_$(s) := $$(word $$(words $$(i)),$$(2)) |
| 902 | i += w) |
| 903 | endef |
| 904 | |
| 905 | # $(1): list of sources |
| 906 | # $(2): list of matching generated sources |
| 907 | define track-src-file-gen |
| 908 | $(eval $(call _track-src-file-gen,$(2))) |
| 909 | endef |
| 910 | define _track-src-file-gen |
| 911 | i := w |
| 912 | $(foreach s,$(1), |
| 913 | my_tracked_gen_files += $(s) |
| 914 | my_src_file_gen_$(s) := $$(word $$(words $$(i)),$$(1)) |
| 915 | i += w) |
| 916 | endef |
| 917 | |
| 918 | # $(1): list of generated sources |
| 919 | # $(2): list of matching objects |
| 920 | define track-gen-file-obj |
| 921 | $(call track-src-file-obj,$(foreach f,$(1),\ |
| 922 | $(or $(my_src_file_gen_$(f)),$(f))),$(2)) |
| 923 | endef |
| 924 | |
| 925 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 926 | ## Commands for running lex |
| 927 | ########################################################### |
| 928 | |
Ying Wang | f0ebe16 | 2016-01-11 16:28:45 -0800 | [diff] [blame] | 929 | define transform-l-to-c-or-cpp |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 930 | @echo "Lex: $(PRIVATE_MODULE) <= $<" |
Colin Cross | b6da589 | 2015-07-16 17:14:27 -0700 | [diff] [blame] | 931 | @mkdir -p $(dir $@) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 932 | $(hide) $(LEX) -o$@ $< |
| 933 | endef |
| 934 | |
| 935 | ########################################################### |
| 936 | ## Commands for running yacc |
| 937 | ## |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 938 | ########################################################### |
| 939 | |
Ying Wang | f0ebe16 | 2016-01-11 16:28:45 -0800 | [diff] [blame] | 940 | define transform-y-to-c-or-cpp |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 941 | @echo "Yacc: $(PRIVATE_MODULE) <= $<" |
Colin Cross | b6da589 | 2015-07-16 17:14:27 -0700 | [diff] [blame] | 942 | @mkdir -p $(dir $@) |
Ying Wang | f0ebe16 | 2016-01-11 16:28:45 -0800 | [diff] [blame] | 943 | $(YACC) $(PRIVATE_YACCFLAGS) \ |
| 944 | --defines=$(basename $@).h \ |
| 945 | -o $@ $< |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 946 | endef |
| 947 | |
Ying Wang | 0bd59a0 | 2010-07-15 17:17:52 -0700 | [diff] [blame] | 948 | ########################################################### |
Tim Murray | a7aa800 | 2012-10-29 16:06:00 -0700 | [diff] [blame] | 949 | ## Commands to compile RenderScript to Java |
Ying Wang | 0bd59a0 | 2010-07-15 17:17:52 -0700 | [diff] [blame] | 950 | ########################################################### |
Ying Wang | 0bd59a0 | 2010-07-15 17:17:52 -0700 | [diff] [blame] | 951 | |
Shinichiro Hamaji | 52a1d6c | 2016-02-01 17:59:01 +0900 | [diff] [blame] | 952 | ## Merge multiple .d files generated by llvm-rs-cc. This is necessary |
| 953 | ## because ninja can handle only a single depfile per build target. |
| 954 | ## .d files generated by llvm-rs-cc define .stamp, .bc, and optionally |
| 955 | ## .java as build targets. However, there's no way to let ninja know |
| 956 | ## dependencies to .bc files and .java files, so we give up build |
| 957 | ## targets for them. As we write the .stamp file as the target by |
| 958 | ## ourselves, the awk script removes the first lines before the colon |
| 959 | ## and append a backslash to the last line to concatenate contents of |
| 960 | ## multiple files. |
| 961 | # $(1): .d files to be merged |
| 962 | # $(2): merged .d file |
| 963 | define _merge-renderscript-d |
| 964 | $(hide) echo '$@: $(backslash)' > $2 |
| 965 | $(foreach d,$1, \ |
| 966 | $(hide) awk 'start { sub(/( \\)?$$/, " \\"); print } /:/ { start=1 }' < $d >> $2$(newline)) |
| 967 | $(hide) echo >> $2 |
| 968 | endef |
| 969 | |
Ying Wang | 0bd59a0 | 2010-07-15 17:17:52 -0700 | [diff] [blame] | 970 | define transform-renderscripts-to-java-and-bc |
| 971 | @echo "RenderScript: $(PRIVATE_MODULE) <= $(PRIVATE_RS_SOURCE_FILES)" |
| 972 | $(hide) rm -rf $(PRIVATE_RS_OUTPUT_DIR) |
| 973 | $(hide) mkdir -p $(PRIVATE_RS_OUTPUT_DIR)/res/raw |
| 974 | $(hide) mkdir -p $(PRIVATE_RS_OUTPUT_DIR)/src |
Ying Wang | 7d83ef8 | 2011-05-25 17:16:22 -0700 | [diff] [blame] | 975 | $(hide) $(PRIVATE_RS_CC) \ |
Ying Wang | ebfddaa | 2010-07-30 18:37:29 -0700 | [diff] [blame] | 976 | -o $(PRIVATE_RS_OUTPUT_DIR)/res/raw \ |
| 977 | -p $(PRIVATE_RS_OUTPUT_DIR)/src \ |
Ying Wang | 24e1c01 | 2010-10-07 18:57:57 -0700 | [diff] [blame] | 978 | -d $(PRIVATE_RS_OUTPUT_DIR) \ |
| 979 | -a $@ -MD \ |
Stephen Hines | c963eae | 2011-08-10 13:53:05 -0700 | [diff] [blame] | 980 | $(addprefix -target-api , $(PRIVATE_RS_TARGET_API)) \ |
Stephen Hines | 914f7a2 | 2011-12-06 18:43:24 -0800 | [diff] [blame] | 981 | $(PRIVATE_RS_FLAGS) \ |
Ying Wang | 5128027 | 2010-09-01 13:28:52 -0700 | [diff] [blame] | 982 | $(foreach inc,$(PRIVATE_RS_INCLUDES),$(addprefix -I , $(inc))) \ |
Ying Wang | ebfddaa | 2010-07-30 18:37:29 -0700 | [diff] [blame] | 983 | $(PRIVATE_RS_SOURCE_FILES) |
Shinichiro Hamaji | 52a1d6c | 2016-02-01 17:59:01 +0900 | [diff] [blame] | 984 | $(call _merge-renderscript-d,$(PRIVATE_DEP_FILES),$@.d) |
| 985 | $(call transform-d-to-p-args,$@.d,$@.P) |
Ying Wang | 0bd59a0 | 2010-07-15 17:17:52 -0700 | [diff] [blame] | 986 | $(hide) mkdir -p $(dir $@) |
| 987 | $(hide) touch $@ |
| 988 | endef |
| 989 | |
Stephen Hines | e719f28 | 2012-11-28 16:52:41 -0800 | [diff] [blame] | 990 | define transform-bc-to-so |
Stephen Hines | 9ac9b53 | 2013-02-27 00:51:08 -0800 | [diff] [blame] | 991 | @echo "Renderscript compatibility: $(notdir $@) <= $(notdir $<)" |
Stephen Hines | e719f28 | 2012-11-28 16:52:41 -0800 | [diff] [blame] | 992 | $(hide) mkdir -p $(dir $@) |
Stephen Hines | f692513 | 2012-12-17 14:23:14 -0800 | [diff] [blame] | 993 | $(hide) $(BCC_COMPAT) -O3 -o $(dir $@)/$(notdir $(<:.bc=.o)) -fPIC -shared \ |
Stephen Hines | 52626d2 | 2014-09-02 19:09:35 -0700 | [diff] [blame] | 994 | -rt-path $(RS_PREBUILT_CLCORE) -mtriple $(RS_COMPAT_TRIPLE) $< |
Stephen Hines | 7d6ec71 | 2012-12-13 19:24:50 -0800 | [diff] [blame] | 995 | $(hide) $(PRIVATE_CXX) -shared -Wl,-soname,$(notdir $@) -nostdlib \ |
Stephen Hines | f692513 | 2012-12-17 14:23:14 -0800 | [diff] [blame] | 996 | -Wl,-rpath,\$$ORIGIN/../lib \ |
Stephen Hines | 9541f58 | 2013-01-18 16:27:23 -0800 | [diff] [blame] | 997 | $(dir $@)/$(notdir $(<:.bc=.o)) \ |
Tim Murray | 1a6f09a | 2013-03-05 11:07:15 -0800 | [diff] [blame] | 998 | $(RS_PREBUILT_COMPILER_RT) \ |
Miao Wang | e23e808 | 2014-11-15 14:25:33 -0800 | [diff] [blame] | 999 | -o $@ $(TARGET_GLOBAL_LDFLAGS) -Wl,--hash-style=sysv -L prebuilts/gcc/ \ |
Ying Wang | bfc4369 | 2015-03-05 11:29:30 -0800 | [diff] [blame] | 1000 | $(RS_PREBUILT_LIBPATH) -L $(TARGET_OUT_INTERMEDIATE_LIBRARIES) \ |
Stephen Hines | 8db4cce | 2013-03-27 16:51:38 -0700 | [diff] [blame] | 1001 | -lRSSupport -lm -lc |
Stephen Hines | e719f28 | 2012-11-28 16:52:41 -0800 | [diff] [blame] | 1002 | endef |
| 1003 | |
Tim Murray | a7aa800 | 2012-10-29 16:06:00 -0700 | [diff] [blame] | 1004 | ########################################################### |
| 1005 | ## Commands to compile RenderScript to C++ |
| 1006 | ########################################################### |
| 1007 | |
| 1008 | define transform-renderscripts-to-cpp-and-bc |
| 1009 | @echo "RenderScript: $(PRIVATE_MODULE) <= $(PRIVATE_RS_SOURCE_FILES)" |
| 1010 | $(hide) rm -rf $(PRIVATE_RS_OUTPUT_DIR) |
| 1011 | $(hide) mkdir -p $(PRIVATE_RS_OUTPUT_DIR)/ |
| 1012 | $(hide) $(PRIVATE_RS_CC) \ |
| 1013 | -o $(PRIVATE_RS_OUTPUT_DIR)/ \ |
| 1014 | -d $(PRIVATE_RS_OUTPUT_DIR) \ |
| 1015 | -a $@ -MD \ |
| 1016 | -reflect-c++ \ |
Noah Presler | 4796a8c | 2015-08-13 17:04:10 -0700 | [diff] [blame] | 1017 | $(addprefix -target-api , $(PRIVATE_RS_TARGET_API)) \ |
Tim Murray | a7aa800 | 2012-10-29 16:06:00 -0700 | [diff] [blame] | 1018 | $(PRIVATE_RS_FLAGS) \ |
Ying Wang | 81ab833 | 2014-05-28 16:17:09 -0700 | [diff] [blame] | 1019 | $(addprefix -I , $(PRIVATE_RS_INCLUDES)) \ |
Tim Murray | a7aa800 | 2012-10-29 16:06:00 -0700 | [diff] [blame] | 1020 | $(PRIVATE_RS_SOURCE_FILES) |
Shinichiro Hamaji | 2e45fd0 | 2016-01-25 18:59:43 +0900 | [diff] [blame] | 1021 | $(call _merge-renderscript-d,$(PRIVATE_DEP_FILES),$@.d) |
| 1022 | $(call transform-d-to-p-args,$@.d,$@.P) |
Tim Murray | a7aa800 | 2012-10-29 16:06:00 -0700 | [diff] [blame] | 1023 | $(hide) mkdir -p $(dir $@) |
| 1024 | $(hide) touch $@ |
| 1025 | endef |
| 1026 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1027 | |
| 1028 | ########################################################### |
| 1029 | ## Commands for running aidl |
| 1030 | ########################################################### |
| 1031 | |
| 1032 | define transform-aidl-to-java |
| 1033 | @mkdir -p $(dir $@) |
| 1034 | @echo "Aidl: $(PRIVATE_MODULE) <= $<" |
| 1035 | $(hide) $(AIDL) -d$(patsubst %.java,%.P,$@) $(PRIVATE_AIDL_FLAGS) $< $@ |
| 1036 | endef |
| 1037 | #$(AIDL) $(PRIVATE_AIDL_FLAGS) $< - | indent -nut -br -npcs -l1000 > $@ |
| 1038 | |
Christopher Wiley | 2df75d1 | 2015-10-14 17:27:24 -0700 | [diff] [blame] | 1039 | define transform-aidl-to-cpp |
| 1040 | @mkdir -p $(dir $@) |
| 1041 | @mkdir -p $(PRIVATE_HEADER_OUTPUT_DIR) |
| 1042 | @echo "Generating C++ from AIDL: $(PRIVATE_MODULE) <= $<" |
Christopher Wiley | 087f327 | 2016-01-19 09:26:10 -0800 | [diff] [blame] | 1043 | $(hide) $(AIDL_CPP) -d$(basename $@).aidl.P $(PRIVATE_AIDL_FLAGS) \ |
Christopher Wiley | 2df75d1 | 2015-10-14 17:27:24 -0700 | [diff] [blame] | 1044 | $< $(PRIVATE_HEADER_OUTPUT_DIR) $@ |
| 1045 | endef |
| 1046 | |
Christopher Wiley | 257796c | 2016-01-19 08:58:35 -0800 | [diff] [blame] | 1047 | ## Given a .aidl file path generate the rule to compile it a .cpp file. |
| 1048 | # $(1): a .aidl source file |
| 1049 | # $(2): a directory to place the generated .cpp files in |
| 1050 | # $(3): name of a variable to add the path to the generated source file to |
| 1051 | # |
| 1052 | # You must call this with $(eval). |
| 1053 | define define-aidl-cpp-rule |
| 1054 | define-aidl-cpp-rule-src := $(patsubst %.aidl,%$(LOCAL_CPP_EXTENSION),$(subst ../,dotdot/,$(addprefix $(2)/,$(1)))) |
| 1055 | $$(define-aidl-cpp-rule-src) : $(LOCAL_PATH)/$(1) $(AIDL_CPP) |
| 1056 | $$(transform-aidl-to-cpp) |
| 1057 | $(3) += $$(define-aidl-cpp-rule-src) |
| 1058 | endef |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1059 | |
Doug Zongker | 9bd4962 | 2009-11-30 14:28:59 -0800 | [diff] [blame] | 1060 | ########################################################### |
| 1061 | ## Commands for running java-event-log-tags.py |
| 1062 | ########################################################### |
| 1063 | |
| 1064 | define transform-logtags-to-java |
| 1065 | @mkdir -p $(dir $@) |
| 1066 | @echo "logtags: $@ <= $<" |
Doug Zongker | abfbbe2 | 2010-02-16 14:32:08 -0800 | [diff] [blame] | 1067 | $(hide) $(JAVATAGS) -o $@ $^ |
Doug Zongker | 9bd4962 | 2009-11-30 14:28:59 -0800 | [diff] [blame] | 1068 | endef |
| 1069 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1070 | |
| 1071 | ########################################################### |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 1072 | ## Commands for running protoc to compile .proto into .java |
| 1073 | ########################################################### |
| 1074 | |
| 1075 | define transform-proto-to-java |
| 1076 | @mkdir -p $(dir $@) |
| 1077 | @echo "Protoc: $@ <= $(PRIVATE_PROTO_SRC_FILES)" |
| 1078 | @rm -rf $(PRIVATE_PROTO_JAVA_OUTPUT_DIR) |
| 1079 | @mkdir -p $(PRIVATE_PROTO_JAVA_OUTPUT_DIR) |
Ben Murdoch | fc2bad5 | 2013-07-25 11:44:53 +0100 | [diff] [blame] | 1080 | $(hide) for f in $(PRIVATE_PROTO_SRC_FILES); do \ |
| 1081 | $(PROTOC) \ |
Ulas Kirazci | 28b46fc | 2013-07-24 14:32:14 -0700 | [diff] [blame] | 1082 | $(addprefix --proto_path=, $(PRIVATE_PROTO_INCLUDES)) \ |
Ulas Kirazci | 6e485b5 | 2013-07-25 12:28:19 -0700 | [diff] [blame] | 1083 | $(PRIVATE_PROTO_JAVA_OUTPUT_OPTION)="$(PRIVATE_PROTO_JAVA_OUTPUT_PARAMS):$(PRIVATE_PROTO_JAVA_OUTPUT_DIR)" \ |
Ben Murdoch | fc2bad5 | 2013-07-25 11:44:53 +0100 | [diff] [blame] | 1084 | $(PRIVATE_PROTOC_FLAGS) \ |
| 1085 | $$f || exit 33; \ |
| 1086 | done |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 1087 | $(hide) touch $@ |
| 1088 | endef |
| 1089 | |
| 1090 | ###################################################################### |
Ying Wang | faeb693 | 2015-04-07 11:59:34 -0700 | [diff] [blame] | 1091 | ## Commands for running protoc to compile .proto into .pb.cc (or.pb.c) and .pb.h |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 1092 | ###################################################################### |
| 1093 | define transform-proto-to-cc |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 1094 | @echo "Protoc: $@ <= $<" |
Colin Cross | b6da589 | 2015-07-16 17:14:27 -0700 | [diff] [blame] | 1095 | @mkdir -p $(dir $@) |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 1096 | $(hide) $(PROTOC) \ |
| 1097 | $(addprefix --proto_path=, $(PRIVATE_PROTO_INCLUDES)) \ |
Ying Wang | 33c0d95 | 2010-11-05 11:30:58 -0700 | [diff] [blame] | 1098 | $(PRIVATE_PROTOC_FLAGS) \ |
Ying Wang | faeb693 | 2015-04-07 11:59:34 -0700 | [diff] [blame] | 1099 | $< |
Wink Saville | 042d4dc | 2014-05-06 15:45:57 -0700 | [diff] [blame] | 1100 | endef |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 1101 | |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 1102 | |
Christopher Wiley | bc2be46 | 2015-07-29 17:14:24 -0700 | [diff] [blame] | 1103 | ###################################################################### |
Christopher Wiley | 9b17dea | 2015-08-20 09:08:17 -0700 | [diff] [blame] | 1104 | ## Commands for generating DBus adaptors from .dbus-xml files. |
Christopher Wiley | bc2be46 | 2015-07-29 17:14:24 -0700 | [diff] [blame] | 1105 | ###################################################################### |
Christopher Wiley | 529f176 | 2015-08-14 14:55:32 -0700 | [diff] [blame] | 1106 | define generate-dbus-adaptors |
| 1107 | @echo "Generating DBus adaptors for $(PRIVATE_MODULE)" |
| 1108 | @mkdir -p $(dir $@) |
Christopher Wiley | bc2be46 | 2015-07-29 17:14:24 -0700 | [diff] [blame] | 1109 | $(hide) $(DBUS_GENERATOR) \ |
| 1110 | --service-config=$(PRIVATE_DBUS_SERVICE_CONFIG) \ |
Christopher Wiley | 529f176 | 2015-08-14 14:55:32 -0700 | [diff] [blame] | 1111 | --adaptor=$@ \ |
| 1112 | $< |
| 1113 | endef |
| 1114 | |
| 1115 | ###################################################################### |
Christopher Wiley | 9b17dea | 2015-08-20 09:08:17 -0700 | [diff] [blame] | 1116 | ## Commands for generating DBus proxies from .dbus-xml files. |
Christopher Wiley | 529f176 | 2015-08-14 14:55:32 -0700 | [diff] [blame] | 1117 | ###################################################################### |
| 1118 | define generate-dbus-proxies |
| 1119 | @echo "Generating DBus proxies for $(PRIVATE_MODULE)" |
| 1120 | @mkdir -p $(dir $@) |
| 1121 | $(hide) $(DBUS_GENERATOR) \ |
| 1122 | --service-config=$(PRIVATE_DBUS_SERVICE_CONFIG) \ |
| 1123 | --proxy=$@ \ |
Christopher Wiley | 9b17dea | 2015-08-20 09:08:17 -0700 | [diff] [blame] | 1124 | $(filter %.dbus-xml,$^) |
Christopher Wiley | bc2be46 | 2015-07-29 17:14:24 -0700 | [diff] [blame] | 1125 | endef |
| 1126 | |
| 1127 | |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 1128 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1129 | ## Commands for running gcc to compile a C++ file |
| 1130 | ########################################################### |
| 1131 | |
| 1132 | define transform-cpp-to-o |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1133 | @echo "target $(PRIVATE_ARM_MODE) C++: $(PRIVATE_MODULE) <= $<" |
Colin Cross | b6da589 | 2015-07-16 17:14:27 -0700 | [diff] [blame] | 1134 | @mkdir -p $(dir $@) |
Dan Willemsen | 6a66a88 | 2015-10-14 16:44:53 -0700 | [diff] [blame] | 1135 | $(hide) $(RELATIVE_PWD) $(PRIVATE_CXX) \ |
Ying Wang | ddbcad8 | 2011-04-18 11:45:44 -0700 | [diff] [blame] | 1136 | $(addprefix -I , $(PRIVATE_C_INCLUDES)) \ |
Andrew Boie | 85f3b21 | 2012-07-11 12:14:56 -0700 | [diff] [blame] | 1137 | $(shell cat $(PRIVATE_IMPORT_INCLUDES)) \ |
Ying Wang | 4761e56 | 2011-04-12 11:06:35 -0700 | [diff] [blame] | 1138 | $(addprefix -isystem ,\ |
| 1139 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
| 1140 | $(filter-out $(PRIVATE_C_INCLUDES), \ |
Ying Wang | ddbcad8 | 2011-04-18 11:45:44 -0700 | [diff] [blame] | 1141 | $(PRIVATE_TARGET_PROJECT_INCLUDES) \ |
Ying Wang | 4761e56 | 2011-04-12 11:06:35 -0700 | [diff] [blame] | 1142 | $(PRIVATE_TARGET_C_INCLUDES)))) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1143 | -c \ |
| 1144 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 1145 | $(PRIVATE_TARGET_GLOBAL_CFLAGS) \ |
| 1146 | $(PRIVATE_TARGET_GLOBAL_CPPFLAGS) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1147 | $(PRIVATE_ARM_CFLAGS) \ |
| 1148 | ) \ |
Doug Kwan | 9a8ecf9 | 2011-05-10 21:50:58 -0700 | [diff] [blame] | 1149 | $(PRIVATE_RTTI_FLAG) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1150 | $(PRIVATE_CFLAGS) \ |
| 1151 | $(PRIVATE_CPPFLAGS) \ |
| 1152 | $(PRIVATE_DEBUG_CFLAGS) \ |
Dan Albert | d160041 | 2015-06-10 16:33:43 -0700 | [diff] [blame] | 1153 | $(PRIVATE_CFLAGS_NO_OVERRIDE) \ |
| 1154 | $(PRIVATE_CPPFLAGS_NO_OVERRIDE) \ |
Atte Peltomaki | 60fe963 | 2011-12-21 09:24:09 -0800 | [diff] [blame] | 1155 | -MD -MF $(patsubst %.o,%.d,$@) -o $@ $< |
Ying Wang | 3a7e4cc | 2011-01-28 14:14:47 -0800 | [diff] [blame] | 1156 | $(transform-d-to-p) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1157 | endef |
| 1158 | |
| 1159 | |
| 1160 | ########################################################### |
| 1161 | ## Commands for running gcc to compile a C file |
| 1162 | ########################################################### |
| 1163 | |
| 1164 | # $(1): extra flags |
| 1165 | define transform-c-or-s-to-o-no-deps |
| 1166 | @mkdir -p $(dir $@) |
Dan Willemsen | 6a66a88 | 2015-10-14 16:44:53 -0700 | [diff] [blame] | 1167 | $(hide) $(RELATIVE_PWD) $(PRIVATE_CC) \ |
Ying Wang | ddbcad8 | 2011-04-18 11:45:44 -0700 | [diff] [blame] | 1168 | $(addprefix -I , $(PRIVATE_C_INCLUDES)) \ |
Andrew Boie | 85f3b21 | 2012-07-11 12:14:56 -0700 | [diff] [blame] | 1169 | $(shell cat $(PRIVATE_IMPORT_INCLUDES)) \ |
Ying Wang | 4761e56 | 2011-04-12 11:06:35 -0700 | [diff] [blame] | 1170 | $(addprefix -isystem ,\ |
| 1171 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
| 1172 | $(filter-out $(PRIVATE_C_INCLUDES), \ |
Ying Wang | ddbcad8 | 2011-04-18 11:45:44 -0700 | [diff] [blame] | 1173 | $(PRIVATE_TARGET_PROJECT_INCLUDES) \ |
Ying Wang | 4761e56 | 2011-04-12 11:06:35 -0700 | [diff] [blame] | 1174 | $(PRIVATE_TARGET_C_INCLUDES)))) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1175 | -c \ |
| 1176 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 1177 | $(PRIVATE_TARGET_GLOBAL_CFLAGS) \ |
Stephen Hines | 1568029 | 2014-11-26 00:53:46 -0800 | [diff] [blame] | 1178 | $(PRIVATE_TARGET_GLOBAL_CONLYFLAGS) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1179 | $(PRIVATE_ARM_CFLAGS) \ |
| 1180 | ) \ |
Ying Wang | 65d7852 | 2012-08-10 16:30:42 -0700 | [diff] [blame] | 1181 | $(1) \ |
Atte Peltomaki | 60fe963 | 2011-12-21 09:24:09 -0800 | [diff] [blame] | 1182 | -MD -MF $(patsubst %.o,%.d,$@) -o $@ $< |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1183 | endef |
| 1184 | |
| 1185 | define transform-c-to-o-no-deps |
| 1186 | @echo "target $(PRIVATE_ARM_MODE) C: $(PRIVATE_MODULE) <= $<" |
Dan Albert | 0c91fa8 | 2015-02-21 12:45:26 -0800 | [diff] [blame] | 1187 | $(call transform-c-or-s-to-o-no-deps, \ |
| 1188 | $(PRIVATE_CFLAGS) \ |
| 1189 | $(PRIVATE_CONLYFLAGS) \ |
| 1190 | $(PRIVATE_DEBUG_CFLAGS) \ |
Dan Albert | d160041 | 2015-06-10 16:33:43 -0700 | [diff] [blame] | 1191 | $(PRIVATE_CFLAGS_NO_OVERRIDE)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1192 | endef |
| 1193 | |
| 1194 | define transform-s-to-o-no-deps |
| 1195 | @echo "target asm: $(PRIVATE_MODULE) <= $<" |
| 1196 | $(call transform-c-or-s-to-o-no-deps, $(PRIVATE_ASFLAGS)) |
| 1197 | endef |
| 1198 | |
| 1199 | define transform-c-to-o |
| 1200 | $(transform-c-to-o-no-deps) |
Ying Wang | 3a7e4cc | 2011-01-28 14:14:47 -0800 | [diff] [blame] | 1201 | $(transform-d-to-p) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1202 | endef |
| 1203 | |
| 1204 | define transform-s-to-o |
| 1205 | $(transform-s-to-o-no-deps) |
Ying Wang | 3a7e4cc | 2011-01-28 14:14:47 -0800 | [diff] [blame] | 1206 | $(transform-d-to-p) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1207 | endef |
| 1208 | |
Ying Wang | 7b913ce | 2014-06-05 19:05:47 -0700 | [diff] [blame] | 1209 | # YASM compilation |
| 1210 | define transform-asm-to-o |
| 1211 | @mkdir -p $(dir $@) |
| 1212 | $(hide) $(YASM) \ |
| 1213 | $(addprefix -I , $(PRIVATE_C_INCLUDES)) \ |
Ying Wang | fe1e5c3 | 2015-03-09 18:57:40 -0700 | [diff] [blame] | 1214 | $($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_YASM_FLAGS) \ |
Ying Wang | 7b913ce | 2014-06-05 19:05:47 -0700 | [diff] [blame] | 1215 | $(PRIVATE_ASFLAGS) \ |
| 1216 | -o $@ $< |
| 1217 | endef |
| 1218 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1219 | ########################################################### |
David 'Digit' Turner | 5dbb529 | 2009-05-14 16:00:09 +0200 | [diff] [blame] | 1220 | ## Commands for running gcc to compile an Objective-C file |
| 1221 | ## This should never happen for target builds but this |
| 1222 | ## will error at build time. |
| 1223 | ########################################################### |
| 1224 | |
| 1225 | define transform-m-to-o-no-deps |
| 1226 | @echo "target ObjC: $(PRIVATE_MODULE) <= $<" |
Ying Wang | 65d7852 | 2012-08-10 16:30:42 -0700 | [diff] [blame] | 1227 | $(call transform-c-or-s-to-o-no-deps, $(PRIVATE_CFLAGS) $(PRIVATE_DEBUG_CFLAGS)) |
David 'Digit' Turner | 5dbb529 | 2009-05-14 16:00:09 +0200 | [diff] [blame] | 1228 | endef |
| 1229 | |
| 1230 | define transform-m-to-o |
| 1231 | $(transform-m-to-o-no-deps) |
Ying Wang | 3a7e4cc | 2011-01-28 14:14:47 -0800 | [diff] [blame] | 1232 | $(transform-d-to-p) |
David 'Digit' Turner | 5dbb529 | 2009-05-14 16:00:09 +0200 | [diff] [blame] | 1233 | endef |
| 1234 | |
| 1235 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1236 | ## Commands for running gcc to compile a host C++ file |
| 1237 | ########################################################### |
| 1238 | |
| 1239 | define transform-host-cpp-to-o |
Dan Willemsen | 057aaea | 2015-08-14 12:59:50 -0700 | [diff] [blame] | 1240 | @echo "$($(PRIVATE_PREFIX)DISPLAY) C++: $(PRIVATE_MODULE) <= $<" |
Colin Cross | b6da589 | 2015-07-16 17:14:27 -0700 | [diff] [blame] | 1241 | @mkdir -p $(dir $@) |
Dan Willemsen | 6a66a88 | 2015-10-14 16:44:53 -0700 | [diff] [blame] | 1242 | $(hide) $(RELATIVE_PWD) $(PRIVATE_CXX) \ |
Ying Wang | ddbcad8 | 2011-04-18 11:45:44 -0700 | [diff] [blame] | 1243 | $(addprefix -I , $(PRIVATE_C_INCLUDES)) \ |
Andrew Boie | 85f3b21 | 2012-07-11 12:14:56 -0700 | [diff] [blame] | 1244 | $(shell cat $(PRIVATE_IMPORT_INCLUDES)) \ |
Ying Wang | ddbcad8 | 2011-04-18 11:45:44 -0700 | [diff] [blame] | 1245 | $(addprefix -isystem ,\ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1246 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
Ying Wang | ddbcad8 | 2011-04-18 11:45:44 -0700 | [diff] [blame] | 1247 | $(filter-out $(PRIVATE_C_INCLUDES), \ |
Dan Willemsen | 057aaea | 2015-08-14 12:59:50 -0700 | [diff] [blame] | 1248 | $($(PRIVATE_PREFIX)PROJECT_INCLUDES) \ |
Logan Chien | e6f6543 | 2013-12-10 19:07:41 +0800 | [diff] [blame] | 1249 | $(PRIVATE_HOST_C_INCLUDES)))) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1250 | -c \ |
| 1251 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
Logan Chien | e6f6543 | 2013-12-10 19:07:41 +0800 | [diff] [blame] | 1252 | $(PRIVATE_HOST_GLOBAL_CFLAGS) \ |
| 1253 | $(PRIVATE_HOST_GLOBAL_CPPFLAGS) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1254 | ) \ |
| 1255 | $(PRIVATE_CFLAGS) \ |
| 1256 | $(PRIVATE_CPPFLAGS) \ |
| 1257 | $(PRIVATE_DEBUG_CFLAGS) \ |
Dan Albert | d160041 | 2015-06-10 16:33:43 -0700 | [diff] [blame] | 1258 | $(PRIVATE_CFLAGS_NO_OVERRIDE) \ |
| 1259 | $(PRIVATE_CPPFLAGS_NO_OVERRIDE) \ |
Atte Peltomaki | 60fe963 | 2011-12-21 09:24:09 -0800 | [diff] [blame] | 1260 | -MD -MF $(patsubst %.o,%.d,$@) -o $@ $< |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1261 | $(transform-d-to-p) |
| 1262 | endef |
| 1263 | |
| 1264 | |
| 1265 | ########################################################### |
| 1266 | ## Commands for running gcc to compile a host C file |
| 1267 | ########################################################### |
| 1268 | |
| 1269 | # $(1): extra flags |
| 1270 | define transform-host-c-or-s-to-o-no-deps |
| 1271 | @mkdir -p $(dir $@) |
Dan Willemsen | 6a66a88 | 2015-10-14 16:44:53 -0700 | [diff] [blame] | 1272 | $(hide) $(RELATIVE_PWD) $(PRIVATE_CC) \ |
Ying Wang | ddbcad8 | 2011-04-18 11:45:44 -0700 | [diff] [blame] | 1273 | $(addprefix -I , $(PRIVATE_C_INCLUDES)) \ |
Andrew Boie | 85f3b21 | 2012-07-11 12:14:56 -0700 | [diff] [blame] | 1274 | $(shell cat $(PRIVATE_IMPORT_INCLUDES)) \ |
Ying Wang | ddbcad8 | 2011-04-18 11:45:44 -0700 | [diff] [blame] | 1275 | $(addprefix -isystem ,\ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1276 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
Ying Wang | ddbcad8 | 2011-04-18 11:45:44 -0700 | [diff] [blame] | 1277 | $(filter-out $(PRIVATE_C_INCLUDES), \ |
Dan Willemsen | 057aaea | 2015-08-14 12:59:50 -0700 | [diff] [blame] | 1278 | $($(PRIVATE_PREFIX)PROJECT_INCLUDES) \ |
Logan Chien | e6f6543 | 2013-12-10 19:07:41 +0800 | [diff] [blame] | 1279 | $(PRIVATE_HOST_C_INCLUDES)))) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1280 | -c \ |
| 1281 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
Logan Chien | e6f6543 | 2013-12-10 19:07:41 +0800 | [diff] [blame] | 1282 | $(PRIVATE_HOST_GLOBAL_CFLAGS) \ |
Stephen Hines | 1568029 | 2014-11-26 00:53:46 -0800 | [diff] [blame] | 1283 | $(PRIVATE_HOST_GLOBAL_CONLYFLAGS) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1284 | ) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1285 | $(1) \ |
Dan Albert | d160041 | 2015-06-10 16:33:43 -0700 | [diff] [blame] | 1286 | $(PRIVATE_CFLAGS_NO_OVERRIDE) \ |
Atte Peltomaki | 60fe963 | 2011-12-21 09:24:09 -0800 | [diff] [blame] | 1287 | -MD -MF $(patsubst %.o,%.d,$@) -o $@ $< |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1288 | endef |
| 1289 | |
| 1290 | define transform-host-c-to-o-no-deps |
Dan Willemsen | 057aaea | 2015-08-14 12:59:50 -0700 | [diff] [blame] | 1291 | @echo "$($(PRIVATE_PREFIX)DISPLAY) C: $(PRIVATE_MODULE) <= $<" |
Ying Wang | 7429e21 | 2012-08-15 10:59:10 -0700 | [diff] [blame] | 1292 | $(call transform-host-c-or-s-to-o-no-deps, $(PRIVATE_CFLAGS) $(PRIVATE_CONLYFLAGS) $(PRIVATE_DEBUG_CFLAGS)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1293 | endef |
| 1294 | |
| 1295 | define transform-host-s-to-o-no-deps |
Dan Willemsen | 057aaea | 2015-08-14 12:59:50 -0700 | [diff] [blame] | 1296 | @echo "$($(PRIVATE_PREFIX)DISPLAY) asm: $(PRIVATE_MODULE) <= $<" |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1297 | $(call transform-host-c-or-s-to-o-no-deps, $(PRIVATE_ASFLAGS)) |
| 1298 | endef |
| 1299 | |
| 1300 | define transform-host-c-to-o |
| 1301 | $(transform-host-c-to-o-no-deps) |
| 1302 | $(transform-d-to-p) |
| 1303 | endef |
| 1304 | |
| 1305 | define transform-host-s-to-o |
| 1306 | $(transform-host-s-to-o-no-deps) |
| 1307 | $(transform-d-to-p) |
| 1308 | endef |
| 1309 | |
| 1310 | ########################################################### |
David 'Digit' Turner | 5dbb529 | 2009-05-14 16:00:09 +0200 | [diff] [blame] | 1311 | ## Commands for running gcc to compile a host Objective-C file |
| 1312 | ########################################################### |
| 1313 | |
| 1314 | define transform-host-m-to-o-no-deps |
Dan Willemsen | 057aaea | 2015-08-14 12:59:50 -0700 | [diff] [blame] | 1315 | @echo "$($(PRIVATE_PREFIX)DISPLAY) ObjC: $(PRIVATE_MODULE) <= $<" |
Ying Wang | 65d7852 | 2012-08-10 16:30:42 -0700 | [diff] [blame] | 1316 | $(call transform-host-c-or-s-to-o-no-deps, $(PRIVATE_CFLAGS) $(PRIVATE_DEBUG_CFLAGS)) |
David 'Digit' Turner | 5dbb529 | 2009-05-14 16:00:09 +0200 | [diff] [blame] | 1317 | endef |
| 1318 | |
David 'Digit' Turner | 5ca286d | 2011-02-11 16:19:31 +0100 | [diff] [blame] | 1319 | define transform-host-m-to-o |
David 'Digit' Turner | 5dbb529 | 2009-05-14 16:00:09 +0200 | [diff] [blame] | 1320 | $(transform-host-m-to-o-no-deps) |
| 1321 | $(transform-d-to-p) |
| 1322 | endef |
| 1323 | |
Scott James Remnant | dd86e5a | 2015-09-17 15:40:49 -0700 | [diff] [blame] | 1324 | ########################################################### |
| 1325 | ## Commands for running gcc to compile a host Objective-C++ file |
| 1326 | ########################################################### |
| 1327 | |
| 1328 | define transform-host-mm-to-o |
| 1329 | $(transform-host-cpp-to-o) |
| 1330 | endef |
| 1331 | |
Ying Wang | fb22a42 | 2015-03-10 18:03:11 -0700 | [diff] [blame] | 1332 | |
| 1333 | ########################################################### |
| 1334 | ## Rules to compile a single C/C++ source with ../ in the path |
| 1335 | ########################################################### |
| 1336 | # Replace "../" in object paths with $(DOTDOT_REPLACEMENT). |
| 1337 | DOTDOT_REPLACEMENT := dotdot/ |
| 1338 | |
| 1339 | ## Rule to compile a C++ source file with ../ in the path. |
| 1340 | ## Must be called with $(eval). |
| 1341 | # $(1): the C++ source file in LOCAL_SRC_FILES. |
| 1342 | # $(2): the additional dependencies. |
| 1343 | # $(3): the variable name to collect the output object file. |
| 1344 | define compile-dotdot-cpp-file |
| 1345 | o := $(intermediates)/$(patsubst %$(LOCAL_CPP_EXTENSION),%.o,$(subst ../,$(DOTDOT_REPLACEMENT),$(1))) |
| 1346 | $$(o) : $(TOPDIR)$(LOCAL_PATH)/$(1) $(2) |
| 1347 | $$(transform-$$(PRIVATE_HOST)cpp-to-o) |
| 1348 | -include $$(o:%.o=%.P) |
| 1349 | $(3) += $$(o) |
| 1350 | endef |
| 1351 | |
| 1352 | ## Rule to compile a C source file with ../ in the path. |
| 1353 | ## Must be called with $(eval). |
| 1354 | # $(1): the C source file in LOCAL_SRC_FILES. |
| 1355 | # $(2): the additional dependencies. |
| 1356 | # $(3): the variable name to collect the output object file. |
| 1357 | define compile-dotdot-c-file |
| 1358 | o := $(intermediates)/$(patsubst %.c,%.o,$(subst ../,$(DOTDOT_REPLACEMENT),$(1))) |
| 1359 | $$(o) : $(TOPDIR)$(LOCAL_PATH)/$(1) $(2) |
| 1360 | $$(transform-$$(PRIVATE_HOST)c-to-o) |
| 1361 | -include $$(o:%.o=%.P) |
| 1362 | $(3) += $$(o) |
| 1363 | endef |
| 1364 | |
| 1365 | ## Rule to compile a .S source file with ../ in the path. |
| 1366 | ## Must be called with $(eval). |
| 1367 | # $(1): the .S source file in LOCAL_SRC_FILES. |
| 1368 | # $(2): the additional dependencies. |
| 1369 | # $(3): the variable name to collect the output object file. |
| 1370 | define compile-dotdot-s-file |
| 1371 | o := $(intermediates)/$(patsubst %.S,%.o,$(subst ../,$(DOTDOT_REPLACEMENT),$(1))) |
| 1372 | $$(o) : $(TOPDIR)$(LOCAL_PATH)/$(1) $(2) |
| 1373 | $$(transform-$$(PRIVATE_HOST)s-to-o) |
| 1374 | -include $$(o:%.o=%.P) |
| 1375 | $(3) += $$(o) |
| 1376 | endef |
| 1377 | |
| 1378 | ## Rule to compile a .s source file with ../ in the path. |
| 1379 | ## Must be called with $(eval). |
| 1380 | # $(1): the .s source file in LOCAL_SRC_FILES. |
| 1381 | # $(2): the additional dependencies. |
| 1382 | # $(3): the variable name to collect the output object file. |
| 1383 | define compile-dotdot-s-file-no-deps |
| 1384 | o := $(intermediates)/$(patsubst %.s,%.o,$(subst ../,$(DOTDOT_REPLACEMENT),$(1))) |
| 1385 | $$(o) : $(TOPDIR)$(LOCAL_PATH)/$(1) $(2) |
| 1386 | $$(transform-$$(PRIVATE_HOST)s-to-o-no-deps) |
| 1387 | $(3) += $$(o) |
| 1388 | endef |
| 1389 | |
David 'Digit' Turner | 5dbb529 | 2009-05-14 16:00:09 +0200 | [diff] [blame] | 1390 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1391 | ## Commands for running ar |
| 1392 | ########################################################### |
| 1393 | |
Ying Wang | e4b24eb | 2010-05-27 11:55:39 -0700 | [diff] [blame] | 1394 | define _concat-if-arg2-not-empty |
| 1395 | $(if $(2),$(hide) $(1) $(2)) |
| 1396 | endef |
| 1397 | |
| 1398 | # Split long argument list into smaller groups and call the command repeatedly |
Torne (Richard Coles) | bffaef2 | 2012-06-15 16:03:52 +0100 | [diff] [blame] | 1399 | # Call the command at least once even if there are no arguments, as otherwise |
| 1400 | # the output file won't be created. |
Ying Wang | e4b24eb | 2010-05-27 11:55:39 -0700 | [diff] [blame] | 1401 | # |
| 1402 | # $(1): the command without arguments |
| 1403 | # $(2): the arguments |
| 1404 | define split-long-arguments |
Torne (Richard Coles) | bffaef2 | 2012-06-15 16:03:52 +0100 | [diff] [blame] | 1405 | $(hide) $(1) $(wordlist 1,500,$(2)) |
Ying Wang | e4b24eb | 2010-05-27 11:55:39 -0700 | [diff] [blame] | 1406 | $(call _concat-if-arg2-not-empty,$(1),$(wordlist 501,1000,$(2))) |
| 1407 | $(call _concat-if-arg2-not-empty,$(1),$(wordlist 1001,1500,$(2))) |
| 1408 | $(call _concat-if-arg2-not-empty,$(1),$(wordlist 1501,2000,$(2))) |
| 1409 | $(call _concat-if-arg2-not-empty,$(1),$(wordlist 2001,2500,$(2))) |
| 1410 | $(call _concat-if-arg2-not-empty,$(1),$(wordlist 2501,3000,$(2))) |
| 1411 | $(call _concat-if-arg2-not-empty,$(1),$(wordlist 3001,99999,$(2))) |
| 1412 | endef |
| 1413 | |
Ying Wang | a02d3d9 | 2011-01-27 18:48:00 -0800 | [diff] [blame] | 1414 | # $(1): the full path of the source static library. |
| 1415 | define _extract-and-include-single-target-whole-static-lib |
Ying Wang | a02d3d9 | 2011-01-27 18:48:00 -0800 | [diff] [blame] | 1416 | $(hide) ldir=$(PRIVATE_INTERMEDIATES_DIR)/WHOLE/$(basename $(notdir $(1)))_objs;\ |
| 1417 | rm -rf $$ldir; \ |
| 1418 | mkdir -p $$ldir; \ |
Christopher Ferris | 44203f3 | 2015-01-07 17:14:03 -0800 | [diff] [blame] | 1419 | cp $(1) $$ldir; \ |
| 1420 | lib_to_include=$$ldir/$(notdir $(1)); \ |
Ying Wang | a02d3d9 | 2011-01-27 18:48:00 -0800 | [diff] [blame] | 1421 | filelist=; \ |
Christopher Ferris | 44203f3 | 2015-01-07 17:14:03 -0800 | [diff] [blame] | 1422 | subdir=0; \ |
Ying Wang | 6feb6d5 | 2014-04-17 10:03:35 -0700 | [diff] [blame] | 1423 | for f in `$($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) t $(1)`; do \ |
Christopher Ferris | 44203f3 | 2015-01-07 17:14:03 -0800 | [diff] [blame] | 1424 | if [ -e $$ldir/$$f ]; then \ |
| 1425 | mkdir $$ldir/$$subdir; \ |
| 1426 | ext=$$subdir/; \ |
| 1427 | subdir=$$((subdir+1)); \ |
| 1428 | $($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) m $$lib_to_include $$f; \ |
| 1429 | else \ |
| 1430 | ext=; \ |
| 1431 | fi; \ |
| 1432 | $($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) p $$lib_to_include $$f > $$ldir/$$ext$$f; \ |
| 1433 | filelist="$$filelist $$ldir/$$ext$$f"; \ |
Ying Wang | a02d3d9 | 2011-01-27 18:48:00 -0800 | [diff] [blame] | 1434 | done ; \ |
Ying Wang | 61d499b | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 1435 | $($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_ARFLAGS) \ |
| 1436 | $(PRIVATE_ARFLAGS) $@ $$filelist |
Ying Wang | a02d3d9 | 2011-01-27 18:48:00 -0800 | [diff] [blame] | 1437 | |
| 1438 | endef |
| 1439 | |
Dan Albert | e0f44ac | 2014-05-23 12:26:51 -0700 | [diff] [blame] | 1440 | # $(1): the full path of the source static library. |
| 1441 | define extract-and-include-whole-static-libs-first |
| 1442 | $(if $(strip $(1)), |
Dan Albert | e0f44ac | 2014-05-23 12:26:51 -0700 | [diff] [blame] | 1443 | $(hide) cp $(1) $@) |
| 1444 | endef |
| 1445 | |
Dan Bornstein | 3d02eac | 2009-10-21 11:12:56 -0700 | [diff] [blame] | 1446 | define extract-and-include-target-whole-static-libs |
Dan Albert | e0f44ac | 2014-05-23 12:26:51 -0700 | [diff] [blame] | 1447 | $(call extract-and-include-whole-static-libs-first, $(firstword $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES))) |
| 1448 | $(foreach lib,$(wordlist 2,999,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)), \ |
Ying Wang | a02d3d9 | 2011-01-27 18:48:00 -0800 | [diff] [blame] | 1449 | $(call _extract-and-include-single-target-whole-static-lib, $(lib))) |
Dima Zavin | 46e9bec | 2009-05-27 19:41:07 -0700 | [diff] [blame] | 1450 | endef |
| 1451 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1452 | # Explicitly delete the archive first so that ar doesn't |
| 1453 | # try to add to an existing archive. |
| 1454 | define transform-o-to-static-lib |
Colin Cross | b6da589 | 2015-07-16 17:14:27 -0700 | [diff] [blame] | 1455 | @echo "target StaticLib: $(PRIVATE_MODULE) ($@)" |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1456 | @mkdir -p $(dir $@) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1457 | @rm -f $@ |
Dan Bornstein | 3d02eac | 2009-10-21 11:12:56 -0700 | [diff] [blame] | 1458 | $(extract-and-include-target-whole-static-libs) |
Ying Wang | 6feb6d5 | 2014-04-17 10:03:35 -0700 | [diff] [blame] | 1459 | $(call split-long-arguments,$($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) \ |
| 1460 | $($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_ARFLAGS) \ |
Ying Wang | 854607e | 2015-04-02 18:02:33 -0700 | [diff] [blame] | 1461 | $(PRIVATE_ARFLAGS) $@,$(PRIVATE_ALL_OBJECTS)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1462 | endef |
| 1463 | |
| 1464 | ########################################################### |
| 1465 | ## Commands for running host ar |
| 1466 | ########################################################### |
| 1467 | |
Ying Wang | a02d3d9 | 2011-01-27 18:48:00 -0800 | [diff] [blame] | 1468 | # $(1): the full path of the source static library. |
| 1469 | define _extract-and-include-single-host-whole-static-lib |
Ying Wang | a02d3d9 | 2011-01-27 18:48:00 -0800 | [diff] [blame] | 1470 | $(hide) ldir=$(PRIVATE_INTERMEDIATES_DIR)/WHOLE/$(basename $(notdir $(1)))_objs;\ |
| 1471 | rm -rf $$ldir; \ |
| 1472 | mkdir -p $$ldir; \ |
Christopher Ferris | 44203f3 | 2015-01-07 17:14:03 -0800 | [diff] [blame] | 1473 | cp $(1) $$ldir; \ |
| 1474 | lib_to_include=$$ldir/$(notdir $(1)); \ |
Ying Wang | a02d3d9 | 2011-01-27 18:48:00 -0800 | [diff] [blame] | 1475 | filelist=; \ |
Christopher Ferris | 44203f3 | 2015-01-07 17:14:03 -0800 | [diff] [blame] | 1476 | subdir=0; \ |
Dan Willemsen | 057aaea | 2015-08-14 12:59:50 -0700 | [diff] [blame] | 1477 | for f in `$($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)AR) t $(1) | \grep '\.o$$'`; do \ |
Christopher Ferris | 44203f3 | 2015-01-07 17:14:03 -0800 | [diff] [blame] | 1478 | if [ -e $$ldir/$$f ]; then \ |
| 1479 | mkdir $$ldir/$$subdir; \ |
| 1480 | ext=$$subdir/; \ |
| 1481 | subdir=$$((subdir+1)); \ |
Dan Willemsen | 057aaea | 2015-08-14 12:59:50 -0700 | [diff] [blame] | 1482 | $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)AR) m $$lib_to_include $$f; \ |
Christopher Ferris | 44203f3 | 2015-01-07 17:14:03 -0800 | [diff] [blame] | 1483 | else \ |
| 1484 | ext=; \ |
| 1485 | fi; \ |
Dan Willemsen | 057aaea | 2015-08-14 12:59:50 -0700 | [diff] [blame] | 1486 | $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)AR) p $$lib_to_include $$f > $$ldir/$$ext$$f; \ |
Christopher Ferris | 44203f3 | 2015-01-07 17:14:03 -0800 | [diff] [blame] | 1487 | filelist="$$filelist $$ldir/$$ext$$f"; \ |
Ying Wang | a02d3d9 | 2011-01-27 18:48:00 -0800 | [diff] [blame] | 1488 | done ; \ |
Dan Willemsen | 057aaea | 2015-08-14 12:59:50 -0700 | [diff] [blame] | 1489 | $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)AR) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)GLOBAL_ARFLAGS) \ |
Ying Wang | 6feb6d5 | 2014-04-17 10:03:35 -0700 | [diff] [blame] | 1490 | $(PRIVATE_ARFLAGS) $@ $$filelist |
Ying Wang | a02d3d9 | 2011-01-27 18:48:00 -0800 | [diff] [blame] | 1491 | |
| 1492 | endef |
| 1493 | |
Dan Bornstein | 3d02eac | 2009-10-21 11:12:56 -0700 | [diff] [blame] | 1494 | define extract-and-include-host-whole-static-libs |
Dan Albert | e0f44ac | 2014-05-23 12:26:51 -0700 | [diff] [blame] | 1495 | $(call extract-and-include-whole-static-libs-first, $(firstword $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES))) |
| 1496 | $(foreach lib,$(wordlist 2,999,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)), \ |
Ying Wang | a02d3d9 | 2011-01-27 18:48:00 -0800 | [diff] [blame] | 1497 | $(call _extract-and-include-single-host-whole-static-lib, $(lib))) |
Dan Bornstein | 3d02eac | 2009-10-21 11:12:56 -0700 | [diff] [blame] | 1498 | endef |
| 1499 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1500 | # Explicitly delete the archive first so that ar doesn't |
| 1501 | # try to add to an existing archive. |
| 1502 | define transform-host-o-to-static-lib |
Dan Willemsen | 057aaea | 2015-08-14 12:59:50 -0700 | [diff] [blame] | 1503 | @echo "$($(PRIVATE_PREFIX)DISPLAY) StaticLib: $(PRIVATE_MODULE) ($@)" |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1504 | @mkdir -p $(dir $@) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1505 | @rm -f $@ |
Dan Bornstein | 3d02eac | 2009-10-21 11:12:56 -0700 | [diff] [blame] | 1506 | $(extract-and-include-host-whole-static-libs) |
Dan Willemsen | 057aaea | 2015-08-14 12:59:50 -0700 | [diff] [blame] | 1507 | $(call split-long-arguments,$($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)AR) \ |
| 1508 | $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)GLOBAL_ARFLAGS) \ |
Ying Wang | 854607e | 2015-04-02 18:02:33 -0700 | [diff] [blame] | 1509 | $(PRIVATE_ARFLAGS) $@,$(PRIVATE_ALL_OBJECTS)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1510 | endef |
| 1511 | |
| 1512 | |
| 1513 | ########################################################### |
| 1514 | ## Commands for running gcc to link a shared library or package |
| 1515 | ########################################################### |
| 1516 | |
| 1517 | # ld just seems to be so finicky with command order that we allow |
| 1518 | # it to be overriden en-masse see combo/linux-arm.make for an example. |
| 1519 | ifneq ($(HOST_CUSTOM_LD_COMMAND),true) |
| 1520 | define transform-host-o-to-shared-lib-inner |
Ying Wang | 3a7e4cc | 2011-01-28 14:14:47 -0800 | [diff] [blame] | 1521 | $(hide) $(PRIVATE_CXX) \ |
Dan Willemsen | 057aaea | 2015-08-14 12:59:50 -0700 | [diff] [blame] | 1522 | -Wl,-rpath-link=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)OUT_INTERMEDIATE_LIBRARIES) \ |
| 1523 | -Wl,-rpath,\$$ORIGIN/../$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)OUT_SHARED_LIBRARIES)) \ |
| 1524 | -Wl,-rpath,\$$ORIGIN/$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)OUT_SHARED_LIBRARIES)) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1525 | -shared -Wl,-soname,$(notdir $@) \ |
Dan Willemsen | 057aaea | 2015-08-14 12:59:50 -0700 | [diff] [blame] | 1526 | $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)GLOBAL_LD_DIRS) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1527 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
Logan Chien | e6f6543 | 2013-12-10 19:07:41 +0800 | [diff] [blame] | 1528 | $(PRIVATE_HOST_GLOBAL_LDFLAGS) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1529 | ) \ |
Torne (Richard Coles) | a424bf7 | 2014-02-12 14:24:41 +0000 | [diff] [blame] | 1530 | $(PRIVATE_LDFLAGS) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1531 | $(PRIVATE_ALL_OBJECTS) \ |
| 1532 | -Wl,--whole-archive \ |
| 1533 | $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ |
| 1534 | -Wl,--no-whole-archive \ |
Ying Wang | fcdabd4 | 2011-04-25 14:22:41 -0700 | [diff] [blame] | 1535 | $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1536 | $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ |
Ying Wang | fcdabd4 | 2011-04-25 14:22:41 -0700 | [diff] [blame] | 1537 | $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \ |
Dan Albert | 43e128a | 2015-01-23 16:12:57 -0800 | [diff] [blame] | 1538 | $(if $(filter true,$(NATIVE_COVERAGE)),-lgcov) \ |
Dan Albert | 343ed67 | 2015-01-25 16:20:57 -0800 | [diff] [blame] | 1539 | $(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_HOST_LIBPROFILE_RT)) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1540 | $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ |
| 1541 | -o $@ \ |
| 1542 | $(PRIVATE_LDLIBS) |
| 1543 | endef |
| 1544 | endif |
| 1545 | |
| 1546 | define transform-host-o-to-shared-lib |
Dan Willemsen | 057aaea | 2015-08-14 12:59:50 -0700 | [diff] [blame] | 1547 | @echo "$($(PRIVATE_PREFIX)DISPLAY) SharedLib: $(PRIVATE_MODULE) ($@)" |
Colin Cross | b6da589 | 2015-07-16 17:14:27 -0700 | [diff] [blame] | 1548 | @mkdir -p $(dir $@) |
Ying Wang | 3a7e4cc | 2011-01-28 14:14:47 -0800 | [diff] [blame] | 1549 | $(transform-host-o-to-shared-lib-inner) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1550 | endef |
| 1551 | |
| 1552 | define transform-host-o-to-package |
Dan Willemsen | 057aaea | 2015-08-14 12:59:50 -0700 | [diff] [blame] | 1553 | @echo "$($(PRIVATE_PREFIX)DISPLAY) Package: $(PRIVATE_MODULE) ($@)" |
Colin Cross | b6da589 | 2015-07-16 17:14:27 -0700 | [diff] [blame] | 1554 | @mkdir -p $(dir $@) |
Ying Wang | 3a7e4cc | 2011-01-28 14:14:47 -0800 | [diff] [blame] | 1555 | $(transform-host-o-to-shared-lib-inner) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1556 | endef |
| 1557 | |
| 1558 | |
| 1559 | ########################################################### |
| 1560 | ## Commands for running gcc to link a shared library or package |
| 1561 | ########################################################### |
| 1562 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1563 | define transform-o-to-shared-lib-inner |
Ying Wang | 3a7e4cc | 2011-01-28 14:14:47 -0800 | [diff] [blame] | 1564 | $(hide) $(PRIVATE_CXX) \ |
Dan Albert | e088c0d | 2014-11-13 10:15:46 -0800 | [diff] [blame] | 1565 | -nostdlib -Wl,-soname,$(notdir $@) \ |
| 1566 | -Wl,--gc-sections \ |
Logan Chien | e481e7d | 2015-01-25 21:15:12 +0800 | [diff] [blame] | 1567 | $(if $(filter true,$(PRIVATE_CLANG)),-shared,-Wl$(comma)-shared) \ |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 1568 | $(PRIVATE_TARGET_GLOBAL_LD_DIRS) \ |
Ying Wang | 491fca9 | 2015-07-02 15:57:45 -0700 | [diff] [blame] | 1569 | $(PRIVATE_TARGET_CRTBEGIN_SO_O) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1570 | $(PRIVATE_ALL_OBJECTS) \ |
| 1571 | -Wl,--whole-archive \ |
Ying Wang | 80e6cce | 2011-01-24 23:25:36 -0800 | [diff] [blame] | 1572 | $(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1573 | -Wl,--no-whole-archive \ |
Ying Wang | fcdabd4 | 2011-04-25 14:22:41 -0700 | [diff] [blame] | 1574 | $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1575 | $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ |
Ying Wang | fcdabd4 | 2011-04-25 14:22:41 -0700 | [diff] [blame] | 1576 | $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \ |
Dan Albert | 7fbbc5d | 2015-10-08 14:16:39 -0700 | [diff] [blame] | 1577 | $(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_COVERAGE_LIB)) \ |
Dan Albert | 91f713a | 2015-03-31 15:21:30 -0700 | [diff] [blame] | 1578 | $(PRIVATE_TARGET_LIBATOMIC) \ |
| 1579 | $(PRIVATE_TARGET_LIBGCC) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1580 | $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ |
| 1581 | -o $@ \ |
Dan Albert | e088c0d | 2014-11-13 10:15:46 -0800 | [diff] [blame] | 1582 | $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \ |
| 1583 | $(PRIVATE_LDFLAGS) \ |
Ying Wang | 491fca9 | 2015-07-02 15:57:45 -0700 | [diff] [blame] | 1584 | $(PRIVATE_TARGET_CRTEND_SO_O) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1585 | $(PRIVATE_LDLIBS) |
| 1586 | endef |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1587 | |
| 1588 | define transform-o-to-shared-lib |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1589 | @echo "target SharedLib: $(PRIVATE_MODULE) ($@)" |
Colin Cross | b6da589 | 2015-07-16 17:14:27 -0700 | [diff] [blame] | 1590 | @mkdir -p $(dir $@) |
Dan Albert | e088c0d | 2014-11-13 10:15:46 -0800 | [diff] [blame] | 1591 | $(transform-o-to-shared-lib-inner) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1592 | endef |
| 1593 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1594 | ########################################################### |
| 1595 | ## Commands for filtering a target executable or library |
| 1596 | ########################################################### |
| 1597 | |
Ying Wang | ce1c596 | 2014-03-28 17:24:39 -0700 | [diff] [blame] | 1598 | ifneq ($(TARGET_BUILD_VARIANT),user) |
| 1599 | TARGET_STRIP_EXTRA = && $(PRIVATE_OBJCOPY) --add-gnu-debuglink=$< $@ |
| 1600 | TARGET_STRIP_KEEP_SYMBOLS_EXTRA = --add-gnu-debuglink=$< |
| 1601 | endif |
| 1602 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1603 | define transform-to-stripped |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1604 | @echo "target Strip: $(PRIVATE_MODULE) ($@)" |
Colin Cross | b6da589 | 2015-07-16 17:14:27 -0700 | [diff] [blame] | 1605 | @mkdir -p $(dir $@) |
Ying Wang | bfb52a2 | 2014-08-20 17:12:32 -0700 | [diff] [blame] | 1606 | $(hide) $(PRIVATE_STRIP) --strip-all $< -o $@ \ |
| 1607 | $(if $(PRIVATE_NO_DEBUGLINK),,$(TARGET_STRIP_EXTRA)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1608 | endef |
| 1609 | |
Christopher Ferris | a6e2f93 | 2014-03-18 14:50:09 -0700 | [diff] [blame] | 1610 | define transform-to-stripped-keep-symbols |
Christopher Ferris | a6e2f93 | 2014-03-18 14:50:09 -0700 | [diff] [blame] | 1611 | @echo "target Strip (keep symbols): $(PRIVATE_MODULE) ($@)" |
Colin Cross | b6da589 | 2015-07-16 17:14:27 -0700 | [diff] [blame] | 1612 | @mkdir -p $(dir $@) |
Ying Wang | ce1c596 | 2014-03-28 17:24:39 -0700 | [diff] [blame] | 1613 | $(hide) $(PRIVATE_OBJCOPY) \ |
| 1614 | `$(PRIVATE_READELF) -S $< | awk '/.debug_/ {print "-R " $$2}' | xargs` \ |
| 1615 | $(TARGET_STRIP_KEEP_SYMBOLS_EXTRA) $< $@ |
Christopher Ferris | a6e2f93 | 2014-03-18 14:50:09 -0700 | [diff] [blame] | 1616 | endef |
| 1617 | |
Dmitriy Ivanov | 4c2d1a6 | 2015-04-20 16:59:05 -0700 | [diff] [blame] | 1618 | ########################################################### |
| 1619 | ## Commands for packing a target executable or library |
| 1620 | ########################################################### |
| 1621 | |
| 1622 | define pack-elf-relocations |
Dmitriy Ivanov | 4c2d1a6 | 2015-04-20 16:59:05 -0700 | [diff] [blame] | 1623 | @echo "target Pack Relocations: $(PRIVATE_MODULE) ($@)" |
Colin Cross | b6da589 | 2015-07-16 17:14:27 -0700 | [diff] [blame] | 1624 | $(copy-file-to-target) |
Dmitriy Ivanov | 4c2d1a6 | 2015-04-20 16:59:05 -0700 | [diff] [blame] | 1625 | $(hide) $(RELOCATION_PACKER) $@ |
| 1626 | endef |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1627 | |
| 1628 | ########################################################### |
| 1629 | ## Commands for running gcc to link an executable |
| 1630 | ########################################################### |
| 1631 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1632 | define transform-o-to-executable-inner |
Dan Albert | e088c0d | 2014-11-13 10:15:46 -0800 | [diff] [blame] | 1633 | $(hide) $(PRIVATE_CXX) -pie \ |
| 1634 | -nostdlib -Bdynamic \ |
Evgenii Stepanov | 8f5e67a | 2015-07-10 18:06:51 -0700 | [diff] [blame] | 1635 | -Wl,-dynamic-linker,$(PRIVATE_LINKER) \ |
Dan Albert | e088c0d | 2014-11-13 10:15:46 -0800 | [diff] [blame] | 1636 | -Wl,--gc-sections \ |
| 1637 | -Wl,-z,nocopyreloc \ |
Ying Wang | c6ffc00 | 2012-09-25 17:52:10 -0700 | [diff] [blame] | 1638 | $(PRIVATE_TARGET_GLOBAL_LD_DIRS) \ |
Ying Wang | 9fb3526 | 2014-02-21 16:17:05 -0800 | [diff] [blame] | 1639 | -Wl,-rpath-link=$(PRIVATE_TARGET_OUT_INTERMEDIATE_LIBRARIES) \ |
Ying Wang | 491fca9 | 2015-07-02 15:57:45 -0700 | [diff] [blame] | 1640 | $(PRIVATE_TARGET_CRTBEGIN_DYNAMIC_O) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1641 | $(PRIVATE_ALL_OBJECTS) \ |
| 1642 | -Wl,--whole-archive \ |
| 1643 | $(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ |
| 1644 | -Wl,--no-whole-archive \ |
Ying Wang | fcdabd4 | 2011-04-25 14:22:41 -0700 | [diff] [blame] | 1645 | $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1646 | $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ |
Ying Wang | fcdabd4 | 2011-04-25 14:22:41 -0700 | [diff] [blame] | 1647 | $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \ |
Dan Albert | 7fbbc5d | 2015-10-08 14:16:39 -0700 | [diff] [blame] | 1648 | $(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_COVERAGE_LIB)) \ |
Dan Albert | 91f713a | 2015-03-31 15:21:30 -0700 | [diff] [blame] | 1649 | $(PRIVATE_TARGET_LIBATOMIC) \ |
| 1650 | $(PRIVATE_TARGET_LIBGCC) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1651 | $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ |
| 1652 | -o $@ \ |
Dan Albert | e088c0d | 2014-11-13 10:15:46 -0800 | [diff] [blame] | 1653 | $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \ |
| 1654 | $(PRIVATE_LDFLAGS) \ |
Ying Wang | 491fca9 | 2015-07-02 15:57:45 -0700 | [diff] [blame] | 1655 | $(PRIVATE_TARGET_CRTEND_O) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1656 | $(PRIVATE_LDLIBS) |
| 1657 | endef |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1658 | |
| 1659 | define transform-o-to-executable |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1660 | @echo "target Executable: $(PRIVATE_MODULE) ($@)" |
Colin Cross | b6da589 | 2015-07-16 17:14:27 -0700 | [diff] [blame] | 1661 | @mkdir -p $(dir $@) |
Dan Albert | e088c0d | 2014-11-13 10:15:46 -0800 | [diff] [blame] | 1662 | $(transform-o-to-executable-inner) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1663 | endef |
| 1664 | |
| 1665 | |
| 1666 | ########################################################### |
Dan Albert | e088c0d | 2014-11-13 10:15:46 -0800 | [diff] [blame] | 1667 | ## Commands for linking a static executable. In practice, |
| 1668 | ## we only use this on arm, so the other platforms don't |
| 1669 | ## have transform-o-to-static-executable defined. |
Chih-Hung Hsieh | 69b1fe6 | 2015-01-20 11:00:20 -0800 | [diff] [blame] | 1670 | ## Clang driver needs -static to create static executable. |
| 1671 | ## However, bionic/linker uses -shared to overwrite. |
| 1672 | ## Linker for x86 targets does not allow coexistance of -static and -shared, |
| 1673 | ## so we add -static only if -shared is not used. |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1674 | ########################################################### |
| 1675 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1676 | define transform-o-to-static-executable-inner |
Dan Albert | e088c0d | 2014-11-13 10:15:46 -0800 | [diff] [blame] | 1677 | $(hide) $(PRIVATE_CXX) \ |
| 1678 | -nostdlib -Bstatic \ |
Chih-Hung Hsieh | 69b1fe6 | 2015-01-20 11:00:20 -0800 | [diff] [blame] | 1679 | $(if $(filter $(PRIVATE_LDFLAGS),-shared),,-static) \ |
Dan Albert | e088c0d | 2014-11-13 10:15:46 -0800 | [diff] [blame] | 1680 | -Wl,--gc-sections \ |
| 1681 | -o $@ \ |
| 1682 | $(PRIVATE_TARGET_GLOBAL_LD_DIRS) \ |
Ying Wang | 491fca9 | 2015-07-02 15:57:45 -0700 | [diff] [blame] | 1683 | $(PRIVATE_TARGET_CRTBEGIN_STATIC_O) \ |
Dan Albert | e088c0d | 2014-11-13 10:15:46 -0800 | [diff] [blame] | 1684 | $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \ |
| 1685 | $(PRIVATE_LDFLAGS) \ |
| 1686 | $(PRIVATE_ALL_OBJECTS) \ |
| 1687 | -Wl,--whole-archive \ |
| 1688 | $(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ |
| 1689 | -Wl,--no-whole-archive \ |
| 1690 | $(call normalize-target-libraries,$(filter-out %libcompiler_rt.a,$(filter-out %libc_nomalloc.a,$(filter-out %libc.a,$(PRIVATE_ALL_STATIC_LIBRARIES))))) \ |
| 1691 | -Wl,--start-group \ |
| 1692 | $(call normalize-target-libraries,$(filter %libc.a,$(PRIVATE_ALL_STATIC_LIBRARIES))) \ |
| 1693 | $(call normalize-target-libraries,$(filter %libc_nomalloc.a,$(PRIVATE_ALL_STATIC_LIBRARIES))) \ |
Dan Albert | 7fbbc5d | 2015-10-08 14:16:39 -0700 | [diff] [blame] | 1694 | $(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_COVERAGE_LIB)) \ |
Dan Albert | 343ed67 | 2015-01-25 16:20:57 -0800 | [diff] [blame] | 1695 | $(PRIVATE_TARGET_LIBATOMIC) \ |
Dan Albert | e088c0d | 2014-11-13 10:15:46 -0800 | [diff] [blame] | 1696 | $(call normalize-target-libraries,$(filter %libcompiler_rt.a,$(PRIVATE_ALL_STATIC_LIBRARIES))) \ |
Dan Albert | 741b36e | 2014-11-13 21:24:04 -0800 | [diff] [blame] | 1697 | $(PRIVATE_TARGET_LIBGCC) \ |
Dan Albert | e088c0d | 2014-11-13 10:15:46 -0800 | [diff] [blame] | 1698 | -Wl,--end-group \ |
Ying Wang | 491fca9 | 2015-07-02 15:57:45 -0700 | [diff] [blame] | 1699 | $(PRIVATE_TARGET_CRTEND_O) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1700 | endef |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1701 | |
| 1702 | define transform-o-to-static-executable |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1703 | @echo "target StaticExecutable: $(PRIVATE_MODULE) ($@)" |
Colin Cross | b6da589 | 2015-07-16 17:14:27 -0700 | [diff] [blame] | 1704 | @mkdir -p $(dir $@) |
Dan Albert | e088c0d | 2014-11-13 10:15:46 -0800 | [diff] [blame] | 1705 | $(transform-o-to-static-executable-inner) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1706 | endef |
| 1707 | |
| 1708 | |
| 1709 | ########################################################### |
| 1710 | ## Commands for running gcc to link a host executable |
| 1711 | ########################################################### |
Ying Wang | faf3d5e | 2014-04-04 14:37:33 -0700 | [diff] [blame] | 1712 | ifdef BUILD_HOST_static |
| 1713 | HOST_FPIE_FLAGS := |
| 1714 | else |
Dan Albert | 4803ce2 | 2014-08-06 12:36:46 -0700 | [diff] [blame] | 1715 | HOST_FPIE_FLAGS := -pie |
Stephen Hines | a503fb3 | 2014-10-02 00:51:11 -0700 | [diff] [blame] | 1716 | # Force the correct entry point to workaround a bug in binutils that manifests with -pie |
Dan Willemsen | 057aaea | 2015-08-14 12:59:50 -0700 | [diff] [blame] | 1717 | ifeq ($(HOST_CROSS_OS),windows) |
| 1718 | HOST_CROSS_FPIE_FLAGS += -Wl,-e_mainCRTStartup |
Stephen Hines | a503fb3 | 2014-10-02 00:51:11 -0700 | [diff] [blame] | 1719 | endif |
Ying Wang | faf3d5e | 2014-04-04 14:37:33 -0700 | [diff] [blame] | 1720 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1721 | |
| 1722 | ifneq ($(HOST_CUSTOM_LD_COMMAND),true) |
| 1723 | define transform-host-o-to-executable-inner |
Ying Wang | 3a7e4cc | 2011-01-28 14:14:47 -0800 | [diff] [blame] | 1724 | $(hide) $(PRIVATE_CXX) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1725 | $(PRIVATE_ALL_OBJECTS) \ |
| 1726 | -Wl,--whole-archive \ |
| 1727 | $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ |
| 1728 | -Wl,--no-whole-archive \ |
Ying Wang | fcdabd4 | 2011-04-25 14:22:41 -0700 | [diff] [blame] | 1729 | $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1730 | $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ |
Ying Wang | fcdabd4 | 2011-04-25 14:22:41 -0700 | [diff] [blame] | 1731 | $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \ |
Dan Albert | 43e128a | 2015-01-23 16:12:57 -0800 | [diff] [blame] | 1732 | $(if $(filter true,$(NATIVE_COVERAGE)),-lgcov) \ |
Dan Albert | 343ed67 | 2015-01-25 16:20:57 -0800 | [diff] [blame] | 1733 | $(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_HOST_LIBPROFILE_RT)) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1734 | $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ |
Dan Willemsen | 057aaea | 2015-08-14 12:59:50 -0700 | [diff] [blame] | 1735 | -Wl,-rpath-link=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)OUT_INTERMEDIATE_LIBRARIES) \ |
| 1736 | -Wl,-rpath,\$$ORIGIN/../$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)OUT_SHARED_LIBRARIES)) \ |
| 1737 | -Wl,-rpath,\$$ORIGIN/$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)OUT_SHARED_LIBRARIES)) \ |
| 1738 | $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)GLOBAL_LD_DIRS) \ |
Conley Owens | d9e7d25 | 2011-11-10 09:57:40 -0800 | [diff] [blame] | 1739 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
Logan Chien | e6f6543 | 2013-12-10 19:07:41 +0800 | [diff] [blame] | 1740 | $(PRIVATE_HOST_GLOBAL_LDFLAGS) \ |
Conley Owens | d9e7d25 | 2011-11-10 09:57:40 -0800 | [diff] [blame] | 1741 | ) \ |
Torne (Richard Coles) | a424bf7 | 2014-02-12 14:24:41 +0000 | [diff] [blame] | 1742 | $(PRIVATE_LDFLAGS) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1743 | -o $@ \ |
| 1744 | $(PRIVATE_LDLIBS) |
| 1745 | endef |
| 1746 | endif |
| 1747 | |
| 1748 | define transform-host-o-to-executable |
Dan Willemsen | 057aaea | 2015-08-14 12:59:50 -0700 | [diff] [blame] | 1749 | @echo "$($(PRIVATE_PREFIX)DISPLAY) Executable: $(PRIVATE_MODULE) ($@)" |
Colin Cross | b6da589 | 2015-07-16 17:14:27 -0700 | [diff] [blame] | 1750 | @mkdir -p $(dir $@) |
Ying Wang | 3a7e4cc | 2011-01-28 14:14:47 -0800 | [diff] [blame] | 1751 | $(transform-host-o-to-executable-inner) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1752 | endef |
| 1753 | |
| 1754 | |
| 1755 | ########################################################### |
| 1756 | ## Commands for running javac to make .class files |
| 1757 | ########################################################### |
| 1758 | |
Ying Wang | d75d893 | 2015-09-19 10:56:35 -0700 | [diff] [blame] | 1759 | # Add BUILD_NUMBER to apps default version name if it's unbundled build. |
| 1760 | ifdef TARGET_BUILD_APPS |
| 1761 | APPS_DEFAULT_VERSION_NAME := $(PLATFORM_VERSION)-$(BUILD_NUMBER_FROM_FILE) |
| 1762 | else |
| 1763 | APPS_DEFAULT_VERSION_NAME := $(PLATFORM_VERSION) |
| 1764 | endif |
| 1765 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1766 | # TODO: Right now we generate the asset resources twice, first as part |
| 1767 | # of generating the Java classes, then at the end when packaging the final |
| 1768 | # assets. This should be changed to do one of two things: (1) Don't generate |
| 1769 | # any resource files the first time, only create classes during that stage; |
| 1770 | # or (2) Don't use the -c flag with the second stage, instead taking the |
| 1771 | # resource files from the first stage as additional input. My original intent |
| 1772 | # was to use approach (2), but this requires a little more work in the tool. |
| 1773 | # Maybe we should just use approach (1). |
| 1774 | |
| 1775 | # This rule creates the R.java and Manifest.java files, both of which |
Ying Wang | 4f1ab92 | 2011-03-15 13:19:30 -0700 | [diff] [blame] | 1776 | # are PRODUCT-neutral. Don't pass PRIVATE_PRODUCT_AAPT_CONFIG to this invocation. |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1777 | define create-resource-java-files |
| 1778 | @mkdir -p $(PRIVATE_SOURCE_INTERMEDIATES_DIR) |
| 1779 | @mkdir -p $(dir $(PRIVATE_RESOURCE_PUBLICS_OUTPUT)) |
Ying Wang | c61d593 | 2010-03-10 16:02:42 -0800 | [diff] [blame] | 1780 | $(hide) $(AAPT) package $(PRIVATE_AAPT_FLAGS) -m \ |
Ying Wang | 4f1ab92 | 2011-03-15 13:19:30 -0700 | [diff] [blame] | 1781 | $(eval # PRIVATE_PRODUCT_AAPT_CONFIG is intentionally missing-- see comment.) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1782 | $(addprefix -J , $(PRIVATE_SOURCE_INTERMEDIATES_DIR)) \ |
| 1783 | $(addprefix -M , $(PRIVATE_ANDROID_MANIFEST)) \ |
| 1784 | $(addprefix -P , $(PRIVATE_RESOURCE_PUBLICS_OUTPUT)) \ |
| 1785 | $(addprefix -S , $(PRIVATE_RESOURCE_DIR)) \ |
| 1786 | $(addprefix -A , $(PRIVATE_ASSET_DIR)) \ |
Dianne Hackborn | 9bd5404 | 2009-05-15 18:01:20 -0700 | [diff] [blame] | 1787 | $(addprefix -I , $(PRIVATE_AAPT_INCLUDES)) \ |
Joe Onorato | 2daa2b3 | 2009-08-30 13:39:24 -0700 | [diff] [blame] | 1788 | $(addprefix -G , $(PRIVATE_PROGUARD_OPTIONS_FILE)) \ |
Ying Wang | bb9c230 | 2011-04-08 17:27:35 -0700 | [diff] [blame] | 1789 | $(addprefix --min-sdk-version , $(PRIVATE_DEFAULT_APP_TARGET_SDK)) \ |
| 1790 | $(addprefix --target-sdk-version , $(PRIVATE_DEFAULT_APP_TARGET_SDK)) \ |
Colin Cross | f37b455 | 2015-07-16 17:15:19 -0700 | [diff] [blame] | 1791 | $(if $(filter --version-code,$(PRIVATE_AAPT_FLAGS)),,--version-code $(PLATFORM_SDK_VERSION)) \ |
Ying Wang | d75d893 | 2015-09-19 10:56:35 -0700 | [diff] [blame] | 1792 | $(if $(filter --version-name,$(PRIVATE_AAPT_FLAGS)),,--version-name $(APPS_DEFAULT_VERSION_NAME)) \ |
Ying Wang | 8c25482 | 2010-03-16 16:13:56 -0700 | [diff] [blame] | 1793 | $(addprefix --rename-manifest-package , $(PRIVATE_MANIFEST_PACKAGE_NAME)) \ |
Adrian Roos | 6784cae | 2015-06-01 18:24:41 -0700 | [diff] [blame] | 1794 | $(addprefix --rename-instrumentation-target-package , $(PRIVATE_MANIFEST_INSTRUMENTATION_FOR)) \ |
| 1795 | --skip-symbols-without-default-localization |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1796 | endef |
| 1797 | |
Ying Wang | dd71c85 | 2015-12-04 13:59:18 -0800 | [diff] [blame] | 1798 | # Search for generated R.java/Manifest.java, copy the found R.java as $@. |
| 1799 | # Also copy them to a central 'R' directory to make it easier to add the files to an IDE. |
| 1800 | define find-generated-R.java |
| 1801 | $(hide) for GENERATED_MANIFEST_FILE in `find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) \ |
| 1802 | -name Manifest.java 2> /dev/null`; do \ |
| 1803 | dir=`awk '/package/{gsub(/\./,"/",$$2);gsub(/;/,"",$$2);print $$2;exit}' $$GENERATED_MANIFEST_FILE`; \ |
| 1804 | mkdir -p $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \ |
| 1805 | $(ACP) -fp $$GENERATED_MANIFEST_FILE $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \ |
| 1806 | done; |
| 1807 | $(hide) for GENERATED_R_FILE in `find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) \ |
| 1808 | -name R.java 2> /dev/null`; do \ |
| 1809 | dir=`awk '/package/{gsub(/\./,"/",$$2);gsub(/;/,"",$$2);print $$2;exit}' $$GENERATED_R_FILE`; \ |
| 1810 | mkdir -p $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \ |
| 1811 | $(ACP) -fp $$GENERATED_R_FILE $(TARGET_COMMON_OUT_ROOT)/R/$$dir \ |
| 1812 | || exit 31; \ |
| 1813 | $(ACP) -fp $$GENERATED_R_FILE $@ || exit 32; \ |
| 1814 | done; |
| 1815 | @# Ensure that the target file is always created, i.e. also in case we did not |
| 1816 | @# enter the GENERATED_R_FILE-loop above. This avoids unnecessary rebuilding. |
| 1817 | $(hide) touch $@ |
| 1818 | endef |
| 1819 | |
| 1820 | ########################################################### |
| 1821 | # AAPT2 compilation and link |
| 1822 | ########################################################### |
| 1823 | define aapt2-compile-one-resource-file |
| 1824 | @mkdir -p $(dir $@) |
| 1825 | $(hide) $(AAPT2) compile -o $(dir $@) $(PRIVATE_AAPT2_CFLAGS) --legacy $< |
| 1826 | endef |
| 1827 | |
Ying Wang | e295c3d | 2016-02-24 14:11:55 -0800 | [diff] [blame] | 1828 | define aapt2-compile-resource-dirs |
Ying Wang | dd71c85 | 2015-12-04 13:59:18 -0800 | [diff] [blame] | 1829 | @mkdir -p $(dir $@) |
Ying Wang | e295c3d | 2016-02-24 14:11:55 -0800 | [diff] [blame] | 1830 | $(hide) $(AAPT2) compile -o $@ $(addprefix --dir ,$(PRIVATE_SOURCE_RES_DIRS)) \ |
Ying Wang | dd71c85 | 2015-12-04 13:59:18 -0800 | [diff] [blame] | 1831 | $(PRIVATE_AAPT2_CFLAGS) --legacy |
| 1832 | endef |
| 1833 | |
| 1834 | # Set up rule to compile one resource file with aapt2. |
| 1835 | # Must be called with $(eval). |
| 1836 | # $(1): the source file |
| 1837 | # $(2): the output file |
| 1838 | define aapt2-compile-one-resource-file-rule |
| 1839 | $(2) : $(1) $(AAPT2) |
| 1840 | @echo "AAPT2 compile $$@ <- $$<" |
| 1841 | $$(call aapt2-compile-one-resource-file) |
| 1842 | endef |
| 1843 | |
| 1844 | # Convert input resource file path to output file path. |
| 1845 | # values-[config]/<file>.xml -> values-[config]_<file>.arsc.flat; |
| 1846 | # For other resource file, just replace the last "/" with "_" and |
| 1847 | # add .flat extension. |
| 1848 | # |
| 1849 | # $(1): the input resource file path |
| 1850 | # $(2): the base dir of the output file path |
| 1851 | # Returns: the compiled output file path |
| 1852 | define aapt2-compiled-resource-out-file |
| 1853 | $(eval _p_w := $(strip $(subst /,$(space),$(dir $(1)))))$(2)/$(subst $(space),/,$(_p_w))_$(if $(filter values%,$(lastword $(_p_w))),$(patsubst %.xml,%.arsc,$(notdir $(1))),$(notdir $(1))).flat |
| 1854 | endef |
| 1855 | |
| 1856 | define aapt2-link |
| 1857 | $(hide) $(AAPT2) link -o $@ \ |
| 1858 | $(PRIVATE_AAPT_FLAGS) \ |
| 1859 | $(addprefix --manifest ,$(PRIVATE_ANDROID_MANIFEST)) \ |
| 1860 | $(addprefix -I ,$(PRIVATE_AAPT_INCLUDES)) \ |
Ying Wang | e295c3d | 2016-02-24 14:11:55 -0800 | [diff] [blame] | 1861 | $(addprefix -I ,$(PRIVATE_SHARED_ANDROID_LIBRARIES)) \ |
Ying Wang | dd71c85 | 2015-12-04 13:59:18 -0800 | [diff] [blame] | 1862 | $(addprefix --java ,$(PRIVATE_SOURCE_INTERMEDIATES_DIR)) \ |
| 1863 | $(addprefix --proguard ,$(PRIVATE_PROGUARD_OPTIONS_FILE)) \ |
| 1864 | $(addprefix --min-sdk-version ,$(PRIVATE_DEFAULT_APP_TARGET_SDK)) \ |
| 1865 | $(addprefix --target-sdk-version ,$(PRIVATE_DEFAULT_APP_TARGET_SDK)) \ |
Adam Lesinski | e758f93 | 2016-02-26 11:13:43 -0800 | [diff] [blame^] | 1866 | $(if $(filter --product,$(PRIVATE_AAPT_FLAGS)),,$(addprefix --product ,$(PRIVATE_TARGET_AAPT_CHARACTERISTICS))) \ |
| 1867 | $(addprefix -c ,$(PRIVATE_PRODUCT_AAPT_CONFIG)) \ |
| 1868 | $(addprefix --preferred-density ,$(PRIVATE_PRODUCT_AAPT_PREF_CONFIG)) \ |
| 1869 | $(if $(filter --version-code,$(PRIVATE_AAPT_FLAGS)),,--version-code $(PLATFORM_SDK_VERSION)) \ |
| 1870 | $(if $(filter --version-name,$(PRIVATE_AAPT_FLAGS)),,--version-name $(APPS_DEFAULT_VERSION_NAME)) \ |
| 1871 | $(addprefix --rename-manifest-package ,$(PRIVATE_MANIFEST_PACKAGE_NAME)) \ |
| 1872 | $(addprefix --rename-instrumentation-target-package ,$(PRIVATE_MANIFEST_INSTRUMENTATION_FOR)) \ |
Ying Wang | dd71c85 | 2015-12-04 13:59:18 -0800 | [diff] [blame] | 1873 | $(addprefix -R , $(PRIVATE_OVERLAY_FLAT)) \ |
| 1874 | $(PRIVATE_RES_FLAT) |
| 1875 | endef |
| 1876 | |
| 1877 | ########################################################### |
Jeffrey Chyan | 7adbf97 | 2010-07-07 13:42:19 -0500 | [diff] [blame] | 1878 | xlint_unchecked := -Xlint:unchecked |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1879 | |
| 1880 | # emit-line, <word list>, <output file> |
| 1881 | define emit-line |
| 1882 | $(if $(1),echo -n '$(strip $(1)) ' >> $(2)) |
| 1883 | endef |
| 1884 | |
| 1885 | # dump-words-to-file, <word list>, <output file> |
| 1886 | define dump-words-to-file |
| 1887 | @rm -f $(2) |
Yohann Roussel | f8c63cb | 2015-10-06 15:28:38 +0200 | [diff] [blame] | 1888 | @touch $(2) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1889 | @$(call emit-line,$(wordlist 1,200,$(1)),$(2)) |
| 1890 | @$(call emit-line,$(wordlist 201,400,$(1)),$(2)) |
| 1891 | @$(call emit-line,$(wordlist 401,600,$(1)),$(2)) |
| 1892 | @$(call emit-line,$(wordlist 601,800,$(1)),$(2)) |
| 1893 | @$(call emit-line,$(wordlist 801,1000,$(1)),$(2)) |
| 1894 | @$(call emit-line,$(wordlist 1001,1200,$(1)),$(2)) |
| 1895 | @$(call emit-line,$(wordlist 1201,1400,$(1)),$(2)) |
| 1896 | @$(call emit-line,$(wordlist 1401,1600,$(1)),$(2)) |
| 1897 | @$(call emit-line,$(wordlist 1601,1800,$(1)),$(2)) |
| 1898 | @$(call emit-line,$(wordlist 1801,2000,$(1)),$(2)) |
| 1899 | @$(call emit-line,$(wordlist 2001,2200,$(1)),$(2)) |
| 1900 | @$(call emit-line,$(wordlist 2201,2400,$(1)),$(2)) |
| 1901 | @$(call emit-line,$(wordlist 2401,2600,$(1)),$(2)) |
| 1902 | @$(call emit-line,$(wordlist 2601,2800,$(1)),$(2)) |
| 1903 | @$(call emit-line,$(wordlist 2801,3000,$(1)),$(2)) |
| 1904 | @$(call emit-line,$(wordlist 3001,3200,$(1)),$(2)) |
| 1905 | @$(call emit-line,$(wordlist 3201,3400,$(1)),$(2)) |
| 1906 | @$(call emit-line,$(wordlist 3401,3600,$(1)),$(2)) |
| 1907 | @$(call emit-line,$(wordlist 3601,3800,$(1)),$(2)) |
| 1908 | @$(call emit-line,$(wordlist 3801,4000,$(1)),$(2)) |
Jesse Wilson | 72c941a | 2010-05-04 16:33:49 -0700 | [diff] [blame] | 1909 | @$(call emit-line,$(wordlist 4001,4200,$(1)),$(2)) |
| 1910 | @$(call emit-line,$(wordlist 4201,4400,$(1)),$(2)) |
| 1911 | @$(call emit-line,$(wordlist 4401,4600,$(1)),$(2)) |
| 1912 | @$(call emit-line,$(wordlist 4601,4800,$(1)),$(2)) |
| 1913 | @$(call emit-line,$(wordlist 4801,5000,$(1)),$(2)) |
Przemyslaw Szczepaniak | 972a268 | 2015-11-20 15:05:03 +0000 | [diff] [blame] | 1914 | @$(call emit-line,$(wordlist 5001,5200,$(1)),$(2)) |
| 1915 | @$(if $(wordlist 5201,5202,$(1)),$(error Too many words ($(words $(1))))) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1916 | endef |
| 1917 | |
| 1918 | # For a list of jar files, unzip them to a specified directory, |
Ying Wang | 996ae38 | 2015-11-24 11:44:20 -0800 | [diff] [blame] | 1919 | # but make sure that no META-INF files come along for the ride, |
| 1920 | # unless PRIVATE_DONT_DELETE_JAR_META_INF is set. |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1921 | # |
| 1922 | # $(1): files to unzip |
| 1923 | # $(2): destination directory |
| 1924 | define unzip-jar-files |
| 1925 | $(hide) for f in $(1); \ |
| 1926 | do \ |
| 1927 | if [ ! -f $$f ]; then \ |
| 1928 | echo Missing file $$f; \ |
| 1929 | exit 1; \ |
| 1930 | fi; \ |
Sriram Raman | f1a55f8 | 2009-06-09 15:08:29 -0700 | [diff] [blame] | 1931 | unzip -qo $$f -d $(2); \ |
Ying Wang | 996ae38 | 2015-11-24 11:44:20 -0800 | [diff] [blame] | 1932 | done |
| 1933 | $(if $(PRIVATE_DONT_DELETE_JAR_META_INF),,$(hide) rm -rf $(2)/META-INF) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1934 | endef |
| 1935 | |
Yohann Roussel | 8998d57 | 2015-07-03 15:46:51 +0200 | [diff] [blame] | 1936 | # Call jack |
| 1937 | # |
Yohann Roussel | 8998d57 | 2015-07-03 15:46:51 +0200 | [diff] [blame] | 1938 | define call-jack |
Yohann Roussel | 6528ea3 | 2015-10-12 18:02:51 +0200 | [diff] [blame] | 1939 | JACK_VERSION=$(PRIVATE_JACK_VERSION) $(JACK) $(DEFAULT_JACK_EXTRA_ARGS) |
Yohann Roussel | 8998d57 | 2015-07-03 15:46:51 +0200 | [diff] [blame] | 1940 | endef |
| 1941 | |
Brian Carlstrom | 7826951 | 2010-12-10 12:10:24 -0800 | [diff] [blame] | 1942 | # Common definition to invoke javac on the host and target. |
| 1943 | # |
| 1944 | # Some historical notes: |
| 1945 | # - below we write the list of java files to java-source-list to avoid argument |
| 1946 | # list length problems with Cygwin |
| 1947 | # - we filter out duplicate java file names because eclipse's compiler |
| 1948 | # doesn't like them. |
| 1949 | # |
| 1950 | # $(1): javac |
| 1951 | # $(2): bootclasspath |
| 1952 | define compile-java |
Joe Onorato | 64d85d0 | 2009-04-09 19:31:12 -0700 | [diff] [blame] | 1953 | $(hide) rm -f $@ |
| 1954 | $(hide) rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) |
Brian Carlstrom | 7826951 | 2010-12-10 12:10:24 -0800 | [diff] [blame] | 1955 | $(hide) mkdir -p $(dir $@) |
Joe Onorato | 64d85d0 | 2009-04-09 19:31:12 -0700 | [diff] [blame] | 1956 | $(hide) mkdir -p $(PRIVATE_CLASS_INTERMEDIATES_DIR) |
Brian Carlstrom | 7826951 | 2010-12-10 12:10:24 -0800 | [diff] [blame] | 1957 | $(call unzip-jar-files,$(PRIVATE_STATIC_JAVA_LIBRARIES),$(PRIVATE_CLASS_INTERMEDIATES_DIR)) |
Ying Wang | 015edd2 | 2011-01-20 15:01:56 -0800 | [diff] [blame] | 1958 | $(call dump-words-to-file,$(PRIVATE_JAVA_SOURCES),$(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list) |
Joe Onorato | 64d85d0 | 2009-04-09 19:31:12 -0700 | [diff] [blame] | 1959 | $(hide) if [ -d "$(PRIVATE_SOURCE_INTERMEDIATES_DIR)" ]; then \ |
Ying Wang | 4aedea9 | 2015-08-04 12:44:38 -0700 | [diff] [blame] | 1960 | find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name '*.java' -and -not -name '.*' >> $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list; \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1961 | fi |
Ying Wang | 884738e | 2015-05-08 18:51:00 +0000 | [diff] [blame] | 1962 | $(hide) tr ' ' '\n' < $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list \ |
Ying Wang | 4d68879 | 2015-10-22 16:30:00 -0700 | [diff] [blame] | 1963 | | $(NORMALIZE_PATH) | sort -u > $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq |
Ying Wang | 884738e | 2015-05-08 18:51:00 +0000 | [diff] [blame] | 1964 | $(hide) if [ -s $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq ] ; then \ |
Ying Wang | e109a1d | 2011-12-12 17:52:03 -0800 | [diff] [blame] | 1965 | $(1) -encoding UTF-8 \ |
Ying Wang | 057eba0 | 2012-10-18 10:54:49 -0700 | [diff] [blame] | 1966 | $(if $(findstring true,$(PRIVATE_WARNINGS_ENABLE)),$(xlint_unchecked),) \ |
Brian Carlstrom | 7826951 | 2010-12-10 12:10:24 -0800 | [diff] [blame] | 1967 | $(2) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1968 | $(addprefix -classpath ,$(strip \ |
| 1969 | $(call normalize-path-list,$(PRIVATE_ALL_JAVA_LIBRARIES)))) \ |
Ying Wang | 057eba0 | 2012-10-18 10:54:49 -0700 | [diff] [blame] | 1970 | $(if $(findstring true,$(PRIVATE_WARNINGS_ENABLE)),$(xlint_unchecked),) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1971 | -extdirs "" -d $(PRIVATE_CLASS_INTERMEDIATES_DIR) \ |
Brian Carlstrom | 7826951 | 2010-12-10 12:10:24 -0800 | [diff] [blame] | 1972 | $(PRIVATE_JAVACFLAGS) \ |
Ying Wang | 015edd2 | 2011-01-20 15:01:56 -0800 | [diff] [blame] | 1973 | \@$(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq \ |
Ying Wang | e109a1d | 2011-12-12 17:52:03 -0800 | [diff] [blame] | 1974 | || ( rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) ; exit 41 ) \ |
| 1975 | fi |
Joe Onorato | 0eccce9 | 2011-10-30 21:37:35 -0700 | [diff] [blame] | 1976 | $(if $(PRIVATE_JAVA_LAYERS_FILE), $(hide) build/tools/java-layers.py \ |
| 1977 | $(PRIVATE_JAVA_LAYERS_FILE) \@$(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq,) |
Ying Wang | 015edd2 | 2011-01-20 15:01:56 -0800 | [diff] [blame] | 1978 | $(hide) rm -f $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list |
| 1979 | $(hide) rm -f $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq |
Ying Wang | 5758b8e | 2011-12-15 16:36:55 -0800 | [diff] [blame] | 1980 | $(if $(PRIVATE_JAR_EXCLUDE_FILES), $(hide) find $(PRIVATE_CLASS_INTERMEDIATES_DIR) \ |
| 1981 | -name $(word 1, $(PRIVATE_JAR_EXCLUDE_FILES)) \ |
| 1982 | $(addprefix -o -name , $(wordlist 2, 999, $(PRIVATE_JAR_EXCLUDE_FILES))) \ |
| 1983 | | xargs rm -rf) |
Jeff Brown | 4c4aa99 | 2014-05-23 18:41:19 -0700 | [diff] [blame] | 1984 | $(if $(PRIVATE_JAR_PACKAGES), \ |
| 1985 | $(hide) find $(PRIVATE_CLASS_INTERMEDIATES_DIR) -mindepth 1 -type f \ |
| 1986 | $(foreach pkg, $(PRIVATE_JAR_PACKAGES), \ |
| 1987 | -not -path $(PRIVATE_CLASS_INTERMEDIATES_DIR)/$(subst .,/,$(pkg))/\*) -delete ; \ |
| 1988 | find $(PRIVATE_CLASS_INTERMEDIATES_DIR) -empty -delete) |
| 1989 | $(if $(PRIVATE_JAR_EXCLUDE_PACKAGES), $(hide) rm -rf \ |
| 1990 | $(foreach pkg, $(PRIVATE_JAR_EXCLUDE_PACKAGES), \ |
| 1991 | $(PRIVATE_CLASS_INTERMEDIATES_DIR)/$(subst .,/,$(pkg)))) |
Ying Wang | a3b7593 | 2013-08-14 16:59:00 -0700 | [diff] [blame] | 1992 | $(if $(PRIVATE_RMTYPEDEFS), $(hide) $(RMTYPEDEFS) -v $(PRIVATE_CLASS_INTERMEDIATES_DIR)) |
Guang Zhu | 5c9a1a4 | 2013-09-24 19:05:52 -0700 | [diff] [blame] | 1993 | $(if $(PRIVATE_JAR_MANIFEST), \ |
Colin Cross | f37b455 | 2015-07-16 17:15:19 -0700 | [diff] [blame] | 1994 | $(hide) sed -e "s/%BUILD_NUMBER%/$(BUILD_NUMBER_FROM_FILE)/" \ |
Guang Zhu | 5c9a1a4 | 2013-09-24 19:05:52 -0700 | [diff] [blame] | 1995 | $(PRIVATE_JAR_MANIFEST) > $(dir $@)/manifest.mf && \ |
| 1996 | jar -cfm $@ $(dir $@)/manifest.mf \ |
| 1997 | -C $(PRIVATE_CLASS_INTERMEDIATES_DIR) ., \ |
| 1998 | $(hide) jar -cf $@ -C $(PRIVATE_CLASS_INTERMEDIATES_DIR) .) |
Ying Wang | 33360dd | 2015-01-14 14:23:56 -0800 | [diff] [blame] | 1999 | $(if $(PRIVATE_EXTRA_JAR_ARGS),$(call add-java-resources-to,$@)) |
Brian Carlstrom | 7826951 | 2010-12-10 12:10:24 -0800 | [diff] [blame] | 2000 | endef |
| 2001 | |
| 2002 | define transform-java-to-classes.jar |
| 2003 | @echo "target Java: $(PRIVATE_MODULE) ($(PRIVATE_CLASS_INTERMEDIATES_DIR))" |
| 2004 | $(call compile-java,$(TARGET_JAVAC),$(PRIVATE_BOOTCLASSPATH)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 2005 | endef |
| 2006 | |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 2007 | # Invoke Jack to compile java from source to dex and jack files. |
| 2008 | # |
| 2009 | # Some historical notes: |
| 2010 | # - below we write the list of java files to java-source-list to avoid argument |
| 2011 | # list length problems with Cygwin |
| 2012 | # - we filter out duplicate java file names because Jack doesn't like them. |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 2013 | define jack-java-to-dex |
| 2014 | $(hide) rm -f $@ |
| 2015 | $(hide) rm -f $(PRIVATE_CLASSES_JACK) |
| 2016 | $(hide) rm -rf $(PRIVATE_JACK_INTERMEDIATES_DIR) |
| 2017 | $(hide) mkdir -p $(dir $@) |
| 2018 | $(hide) mkdir -p $(dir $(PRIVATE_CLASSES_JACK)) |
| 2019 | $(hide) mkdir -p $(PRIVATE_JACK_INTERMEDIATES_DIR) |
Yohann Roussel | 37822c4 | 2015-01-09 10:36:40 +0100 | [diff] [blame] | 2020 | $(if $(PRIVATE_JACK_INCREMENTAL_DIR),$(hide) mkdir -p $(PRIVATE_JACK_INCREMENTAL_DIR)) |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 2021 | $(call dump-words-to-file,$(PRIVATE_JAVA_SOURCES),$(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list) |
| 2022 | $(hide) if [ -d "$(PRIVATE_SOURCE_INTERMEDIATES_DIR)" ]; then \ |
| 2023 | find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name '*.java' >> $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list; \ |
| 2024 | fi |
Ying Wang | 884738e | 2015-05-08 18:51:00 +0000 | [diff] [blame] | 2025 | $(hide) tr ' ' '\n' < $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list \ |
Ying Wang | 4d68879 | 2015-10-22 16:30:00 -0700 | [diff] [blame] | 2026 | | $(NORMALIZE_PATH) | sort -u > $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list-uniq |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 2027 | $(if $(PRIVATE_JACK_PROGUARD_FLAGS), \ |
| 2028 | $(hide) echo -basedirectory $(CURDIR) > $@.flags; \ |
| 2029 | echo $(PRIVATE_JACK_PROGUARD_FLAGS) >> $@.flags; \ |
| 2030 | ) |
Ying Wang | 33360dd | 2015-01-14 14:23:56 -0800 | [diff] [blame] | 2031 | $(if $(PRIVATE_EXTRA_JAR_ARGS), |
| 2032 | $(hide) mkdir -p $@.res.tmp |
| 2033 | $(hide) $(call create-empty-package-at,$@.res.tmp.zip) |
| 2034 | $(hide) $(call add-java-resources-to,$@.res.tmp.zip) |
Ying Wang | 996ae38 | 2015-11-24 11:44:20 -0800 | [diff] [blame] | 2035 | $(hide) unzip -qo $@.res.tmp.zip -d $@.res.tmp |
Ying Wang | 33360dd | 2015-01-14 14:23:56 -0800 | [diff] [blame] | 2036 | $(hide) rm $@.res.tmp.zip) |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 2037 | $(hide) if [ -s $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list-uniq ] ; then \ |
| 2038 | export tmpEcjArg="@$(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list-uniq"; \ |
| 2039 | else \ |
| 2040 | export tmpEcjArg=""; \ |
| 2041 | fi; \ |
Yohann Roussel | 6528ea3 | 2015-10-12 18:02:51 +0200 | [diff] [blame] | 2042 | $(call call-jack) \ |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 2043 | $(strip $(PRIVATE_JACK_FLAGS)) \ |
Sebastien Hertz | dfce8ad | 2015-11-19 17:53:00 +0100 | [diff] [blame] | 2044 | $(strip $(PRIVATE_JACK_COVERAGE_OPTIONS)) \ |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 2045 | $(if $(NO_OPTIMIZE_DX), \ |
| 2046 | -D jack.dex.optimize="false") \ |
Yohann Roussel | 5b2c6e2 | 2015-05-20 17:52:15 +0200 | [diff] [blame] | 2047 | $(if $(PRIVATE_RMTYPEDEFS), \ |
| 2048 | -D jack.android.remove-typedef="true") \ |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 2049 | $(addprefix --classpath ,$(strip \ |
| 2050 | $(call normalize-path-list,$(PRIVATE_BOOTCLASSPATH_JAVA_LIBRARIES) $(PRIVATE_ALL_JACK_LIBRARIES)))) \ |
| 2051 | $(addprefix --import ,$(call reverse-list,$(PRIVATE_STATIC_JACK_LIBRARIES))) \ |
Ying Wang | 33360dd | 2015-01-14 14:23:56 -0800 | [diff] [blame] | 2052 | $(if $(PRIVATE_EXTRA_JAR_ARGS),--import-resource $@.res.tmp) \ |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 2053 | -D jack.import.resource.policy=keep-first \ |
Yohann Roussel | 22c3fa6 | 2014-11-19 14:01:06 +0100 | [diff] [blame] | 2054 | -D jack.import.type.policy=keep-first \ |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 2055 | --output-jack $(PRIVATE_CLASSES_JACK) \ |
Yohann Roussel | 37822c4 | 2015-01-09 10:36:40 +0100 | [diff] [blame] | 2056 | $(if $(PRIVATE_JACK_INCREMENTAL_DIR),--incremental-folder $(PRIVATE_JACK_INCREMENTAL_DIR)) \ |
Yohann Roussel | 22c3fa6 | 2014-11-19 14:01:06 +0100 | [diff] [blame] | 2057 | --output-dex $(PRIVATE_JACK_INTERMEDIATES_DIR) \ |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 2058 | $(addprefix --config-jarjar ,$(strip $(PRIVATE_JARJAR_RULES))) \ |
| 2059 | $(if $(PRIVATE_JACK_PROGUARD_FLAGS),--config-proguard $@.flags) \ |
| 2060 | $$tmpEcjArg \ |
Yohann Roussel | b2c5558 | 2015-07-02 12:10:17 +0200 | [diff] [blame] | 2061 | || ( rm -rf $(PRIVATE_CLASSES_JACK); exit 41 ) |
Yohann Roussel | 22c3fa6 | 2014-11-19 14:01:06 +0100 | [diff] [blame] | 2062 | $(hide) mv $(PRIVATE_JACK_INTERMEDIATES_DIR)/classes*.dex $(dir $@) |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 2063 | $(hide) rm -f $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list |
Ying Wang | 33360dd | 2015-01-14 14:23:56 -0800 | [diff] [blame] | 2064 | $(if $(PRIVATE_EXTRA_JAR_ARGS),$(hide) rm -rf $@.res.tmp) |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 2065 | $(hide) mv $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list-uniq $(PRIVATE_JACK_INTERMEDIATES_DIR).java-source-list |
| 2066 | $(if $(PRIVATE_JAR_PACKAGES), $(hide) echo unsupported options PRIVATE_JAR_PACKAGES in $@; exit 53) |
| 2067 | $(if $(PRIVATE_JAR_EXCLUDE_PACKAGES), $(hide) echo unsupported options JAR_EXCLUDE_PACKAGES in $@; exit 53) |
Yohann Roussel | 22c3fa6 | 2014-11-19 14:01:06 +0100 | [diff] [blame] | 2068 | $(if $(PRIVATE_JAR_MANIFEST), $(hide) echo unsupported options JAR_MANIFEST in $@; exit 53) |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 2069 | endef |
| 2070 | |
| 2071 | define transform-jar-to-jack |
| 2072 | $(hide) mkdir -p $(dir $@) |
Yohann Roussel | 22c3fa6 | 2014-11-19 14:01:06 +0100 | [diff] [blame] | 2073 | $(hide) mkdir -p $@.tmpjill.res |
Ying Wang | 8cffb30 | 2015-11-24 14:09:11 -0800 | [diff] [blame] | 2074 | $(hide) unzip -qo $< -d $@.tmpjill.res |
Yohann Roussel | 22c3fa6 | 2014-11-19 14:01:06 +0100 | [diff] [blame] | 2075 | $(hide) find $@.tmpjill.res -iname "*.class" -delete |
Yohann Roussel | 6528ea3 | 2015-10-12 18:02:51 +0200 | [diff] [blame] | 2076 | $(hide) $(call call-jack) \ |
Yohann Roussel | d87cc99 | 2016-01-19 16:08:34 +0100 | [diff] [blame] | 2077 | $(PRIVATE_JACK_FLAGS) \ |
Yohann Roussel | 22c3fa6 | 2014-11-19 14:01:06 +0100 | [diff] [blame] | 2078 | -D jack.import.resource.policy=keep-first \ |
| 2079 | -D jack.import.type.policy=keep-first \ |
Yohann Roussel | d87cc99 | 2016-01-19 16:08:34 +0100 | [diff] [blame] | 2080 | --import $< \ |
Yohann Roussel | 22c3fa6 | 2014-11-19 14:01:06 +0100 | [diff] [blame] | 2081 | --import-resource $@.tmpjill.res \ |
| 2082 | --output-jack $@ |
| 2083 | $(hide) rm -rf $@.tmpjill.res |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 2084 | endef |
| 2085 | |
Shinichiro Hamaji | 89b255a | 2015-11-09 16:47:42 +0900 | [diff] [blame] | 2086 | # Moves $1.tmp to $1 if necessary. This is designed to be used with |
| 2087 | # .KATI_RESTAT. For kati, this function doesn't update the timestamp |
| 2088 | # of $1 when $1.tmp is identical to $1 so that ninja won't rebuild |
| 2089 | # targets which depend on $1. For GNU make, this function simply |
| 2090 | # copies $1.tmp to $1. |
| 2091 | ifeq ($(BUILDING_WITH_NINJA),true) |
| 2092 | define commit-change-for-toc |
| 2093 | $(hide) if cmp -s $1.tmp $1 ; then \ |
| 2094 | rm $1.tmp ; \ |
| 2095 | else \ |
| 2096 | mv $1.tmp $1 ; \ |
| 2097 | fi |
| 2098 | endef |
| 2099 | else |
| 2100 | define commit-change-for-toc |
| 2101 | @# make doesn't support restat. We always update .toc files so the dependents will always be updated too. |
| 2102 | $(hide) mv $1.tmp $1 |
| 2103 | endef |
| 2104 | endif |
| 2105 | |
Shinichiro Hamaji | f972a4a | 2015-12-09 18:06:20 +0900 | [diff] [blame] | 2106 | ## Rule to create a table of contents from a .jar file. |
Shinichiro Hamaji | 89b255a | 2015-11-09 16:47:42 +0900 | [diff] [blame] | 2107 | ## Must be called with $(eval). |
Shinichiro Hamaji | f972a4a | 2015-12-09 18:06:20 +0900 | [diff] [blame] | 2108 | # $(1): A .jar file |
Shinichiro Hamaji | 89b255a | 2015-11-09 16:47:42 +0900 | [diff] [blame] | 2109 | define _transform-jar-to-toc |
| 2110 | $1.toc: $1 | $(IJAR) |
| 2111 | @echo Generating TOC: $$@ |
| 2112 | $(hide) $(IJAR) $$< $$@.tmp |
| 2113 | $$(call commit-change-for-toc,$$@) |
| 2114 | endef |
| 2115 | |
| 2116 | ## Define a rule which generates .jar.toc and mark it as .KATI_RESTAT. |
Shinichiro Hamaji | f972a4a | 2015-12-09 18:06:20 +0900 | [diff] [blame] | 2117 | # $(1): A .jar file |
Shinichiro Hamaji | 89b255a | 2015-11-09 16:47:42 +0900 | [diff] [blame] | 2118 | define define-jar-to-toc-rule |
Ying Wang | 427f8c4 | 2015-12-04 16:44:03 -0800 | [diff] [blame] | 2119 | $(eval $(call _transform-jar-to-toc,$1))\ |
Shinichiro Hamaji | 89b255a | 2015-11-09 16:47:42 +0900 | [diff] [blame] | 2120 | $(eval .KATI_RESTAT: $1.toc) |
| 2121 | endef |
| 2122 | |
Shinichiro Hamaji | f972a4a | 2015-12-09 18:06:20 +0900 | [diff] [blame] | 2123 | ifeq (,$(TARGET_BUILD_APPS)) |
| 2124 | |
| 2125 | ## Rule to create a table of contents from a .dex file. |
| 2126 | ## Must be called with $(eval). |
| 2127 | # $(1): The directory which contains classes*.dex files |
| 2128 | define _transform-dex-to-toc |
| 2129 | $1/classes.dex.toc: PRIVATE_INPUT_DEX_FILES := $1/classes*.dex |
| 2130 | $1/classes.dex.toc: $1/classes.dex $(DEXDUMP) |
| 2131 | @echo Generating TOC: $$@ |
| 2132 | $(hide) $(DEXDUMP) -l xml $$(PRIVATE_INPUT_DEX_FILES) > $$@.tmp |
| 2133 | $$(call commit-change-for-toc,$$@) |
| 2134 | endef |
| 2135 | |
| 2136 | ## Define a rule which generates .dex.toc and mark it as .KATI_RESTAT. |
| 2137 | # $(1): The directory which contains classes*.dex files |
| 2138 | define define-dex-to-toc-rule |
| 2139 | $(eval $(call _transform-dex-to-toc,$1))\ |
| 2140 | $(eval .KATI_RESTAT: $1/classes.dex.toc) |
| 2141 | endef |
| 2142 | |
| 2143 | else |
| 2144 | |
| 2145 | # Turn off .toc optimization for apps build as we cannot build dexdump. |
| 2146 | define define-dex-to-toc-rule |
| 2147 | endef |
| 2148 | |
| 2149 | endif # TARGET_BUILD_APPS |
| 2150 | |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 2151 | |
| 2152 | # Invoke Jack to compile java from source to jack files without shrink or obfuscation. |
| 2153 | # |
| 2154 | # Some historical notes: |
| 2155 | # - below we write the list of java files to java-source-list to avoid argument |
| 2156 | # list length problems with Cygwin |
| 2157 | # - we filter out duplicate java file names because Jack doesn't like them. |
| 2158 | define java-to-jack |
| 2159 | $(hide) rm -f $@ |
| 2160 | $(hide) rm -rf $(PRIVATE_JACK_INTERMEDIATES_DIR) |
| 2161 | $(hide) mkdir -p $(dir $@) |
| 2162 | $(hide) mkdir -p $(PRIVATE_JACK_INTERMEDIATES_DIR) |
Yohann Roussel | 37822c4 | 2015-01-09 10:36:40 +0100 | [diff] [blame] | 2163 | $(if $(PRIVATE_JACK_INCREMENTAL_DIR),$(hide) mkdir -p $(PRIVATE_JACK_INCREMENTAL_DIR)) |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 2164 | $(call dump-words-to-file,$(PRIVATE_JAVA_SOURCES),$(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list) |
| 2165 | $(hide) if [ -d "$(PRIVATE_SOURCE_INTERMEDIATES_DIR)" ]; then \ |
| 2166 | find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name '*.java' >> $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list; \ |
| 2167 | fi |
Ying Wang | 884738e | 2015-05-08 18:51:00 +0000 | [diff] [blame] | 2168 | $(hide) tr ' ' '\n' < $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list \ |
Ying Wang | 4d68879 | 2015-10-22 16:30:00 -0700 | [diff] [blame] | 2169 | | $(NORMALIZE_PATH) | sort -u > $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list-uniq |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 2170 | $(if $(PRIVATE_JACK_PROGUARD_FLAGS), \ |
| 2171 | $(hide) echo -basedirectory $(CURDIR) > $@.flags; \ |
| 2172 | echo $(PRIVATE_JACK_PROGUARD_FLAGS) >> $@.flags; \ |
| 2173 | ) |
Yohann Roussel | 22c3fa6 | 2014-11-19 14:01:06 +0100 | [diff] [blame] | 2174 | $(if $(PRIVATE_EXTRA_JAR_ARGS), |
| 2175 | $(hide) mkdir -p $@.res.tmp |
| 2176 | $(hide) $(call create-empty-package-at,$@.res.tmp.zip) |
| 2177 | $(hide) $(call add-java-resources-to,$@.res.tmp.zip) |
Yohann Roussel | 5dd3e1d | 2015-01-14 16:21:39 +0100 | [diff] [blame] | 2178 | $(hide) unzip -qo $@.res.tmp.zip -d $@.res.tmp |
Yohann Roussel | 22c3fa6 | 2014-11-19 14:01:06 +0100 | [diff] [blame] | 2179 | $(hide) rm $@.res.tmp.zip) |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 2180 | $(hide) if [ -s $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list-uniq ] ; then \ |
| 2181 | export tmpEcjArg="@$(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list-uniq"; \ |
| 2182 | else \ |
| 2183 | export tmpEcjArg=""; \ |
| 2184 | fi; \ |
Yohann Roussel | 6528ea3 | 2015-10-12 18:02:51 +0200 | [diff] [blame] | 2185 | $(call call-jack) \ |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 2186 | $(strip $(PRIVATE_JACK_FLAGS)) \ |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 2187 | $(if $(NO_OPTIMIZE_DX), \ |
| 2188 | -D jack.dex.optimize="false") \ |
| 2189 | $(addprefix --classpath ,$(strip \ |
| 2190 | $(call normalize-path-list,$(PRIVATE_BOOTCLASSPATH_JAVA_LIBRARIES) $(PRIVATE_ALL_JACK_LIBRARIES)))) \ |
| 2191 | $(addprefix --import ,$(call reverse-list,$(PRIVATE_STATIC_JACK_LIBRARIES))) \ |
Yohann Roussel | 22c3fa6 | 2014-11-19 14:01:06 +0100 | [diff] [blame] | 2192 | $(if $(PRIVATE_EXTRA_JAR_ARGS),--import-resource $@.res.tmp) \ |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 2193 | -D jack.import.resource.policy=keep-first \ |
Yohann Roussel | 22c3fa6 | 2014-11-19 14:01:06 +0100 | [diff] [blame] | 2194 | -D jack.import.type.policy=keep-first \ |
Yohann Roussel | 37822c4 | 2015-01-09 10:36:40 +0100 | [diff] [blame] | 2195 | $(if $(PRIVATE_JACK_INCREMENTAL_DIR),--incremental-folder $(PRIVATE_JACK_INCREMENTAL_DIR)) \ |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 2196 | --output-jack $@ \ |
| 2197 | $(addprefix --config-jarjar ,$(strip $(PRIVATE_JARJAR_RULES))) \ |
| 2198 | $(if $(PRIVATE_JACK_PROGUARD_FLAGS),--config-proguard $@.flags) \ |
| 2199 | $$tmpEcjArg \ |
Yohann Roussel | 22c3fa6 | 2014-11-19 14:01:06 +0100 | [diff] [blame] | 2200 | || ( rm -f $@ ; exit 41 ) |
| 2201 | $(hide) rm -f $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list |
| 2202 | $(if $(PRIVATE_EXTRA_JAR_ARGS),$(hide) rm -rf $@.res.tmp) |
| 2203 | $(hide) mv $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list-uniq $(PRIVATE_JACK_INTERMEDIATES_DIR).java-source-list |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 2204 | $(if $(PRIVATE_JAR_PACKAGES), $(hide) echo unsupported options PRIVATE_JAR_PACKAGES in $@; exit 53) |
| 2205 | $(if $(PRIVATE_JAR_EXCLUDE_PACKAGES), $(hide) echo unsupported options JAR_EXCLUDE_PACKAGES in $@; exit 53) |
Yohann Roussel | 22c3fa6 | 2014-11-19 14:01:06 +0100 | [diff] [blame] | 2206 | $(if $(PRIVATE_JAR_MANIFEST), $(hide) echo unsupported options JAR_MANIFEST in $@; exit 53) |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 2207 | endef |
| 2208 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 2209 | define transform-classes.jar-to-emma |
| 2210 | $(hide) java -classpath $(EMMA_JAR) emma instr -outmode fullcopy -outfile \ |
Guang Zhu | 155afe3 | 2010-03-10 15:48:03 -0800 | [diff] [blame] | 2211 | $(PRIVATE_EMMA_COVERAGE_FILE) -ip $< -d $(PRIVATE_EMMA_INTERMEDIATES_DIR) \ |
Guang Zhu | 9cd3d8c | 2010-06-15 13:31:25 -0700 | [diff] [blame] | 2212 | $(addprefix -ix , $(PRIVATE_EMMA_COVERAGE_FILTER)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 2213 | endef |
| 2214 | |
| 2215 | #TODO: use a smaller -Xmx value for most libraries; |
| 2216 | # only core.jar and framework.jar need a heap this big. |
| 2217 | define transform-classes.jar-to-dex |
| 2218 | @echo "target Dex: $(PRIVATE_MODULE)" |
| 2219 | @mkdir -p $(dir $@) |
Ying Wang | af9757e | 2014-07-17 21:24:42 -0700 | [diff] [blame] | 2220 | $(hide) rm -f $(dir $@)classes*.dex |
Raphael | f6ff4c5 | 2009-08-18 14:43:32 -0700 | [diff] [blame] | 2221 | $(hide) $(DX) \ |
Dan Willemsen | 145ae32 | 2015-08-13 14:31:36 -0700 | [diff] [blame] | 2222 | -JXms16M -JXmx2048M \ |
Yohann Roussel | 8ffe9c3 | 2013-08-20 17:05:27 +0200 | [diff] [blame] | 2223 | --dex --output=$(dir $@) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 2224 | $(if $(NO_OPTIMIZE_DX), \ |
| 2225 | --no-optimize) \ |
| 2226 | $(if $(GENERATE_DEX_DEBUG), \ |
| 2227 | --debug --verbose \ |
| 2228 | --dump-to=$(@:.dex=.lst) \ |
| 2229 | --dump-width=1000) \ |
| 2230 | $(PRIVATE_DX_FLAGS) \ |
| 2231 | $< |
| 2232 | endef |
| 2233 | |
| 2234 | # Create a mostly-empty .jar file that we'll add to later. |
| 2235 | # The MacOS jar tool doesn't like creating empty jar files, |
| 2236 | # so we need to give it something. |
Yohann Roussel | 22c3fa6 | 2014-11-19 14:01:06 +0100 | [diff] [blame] | 2237 | # $(1) package to create |
| 2238 | define create-empty-package-at |
| 2239 | @mkdir -p $(dir $(1)) |
Ying Wang | c894e09 | 2015-02-26 10:34:33 -0800 | [diff] [blame] | 2240 | $(hide) touch $(dir $(1))zipdummy |
| 2241 | $(hide) (cd $(dir $(1)) && jar cf $(notdir $(1)) zipdummy) |
| 2242 | $(hide) zip -qd $(1) zipdummy |
| 2243 | $(hide) rm $(dir $(1))zipdummy |
Yohann Roussel | 22c3fa6 | 2014-11-19 14:01:06 +0100 | [diff] [blame] | 2244 | endef |
| 2245 | |
| 2246 | # Create a mostly-empty .jar file that we'll add to later. |
| 2247 | # The MacOS jar tool doesn't like creating empty jar files, |
| 2248 | # so we need to give it something. |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 2249 | define create-empty-package |
Yohann Roussel | 22c3fa6 | 2014-11-19 14:01:06 +0100 | [diff] [blame] | 2250 | $(call create-empty-package-at,$@) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 2251 | endef |
| 2252 | |
Ying Wang | 33360dd | 2015-01-14 14:23:56 -0800 | [diff] [blame] | 2253 | # Copy an arhchive file and delete any class files and empty folders inside. |
| 2254 | # $(1): the source archive file. |
| 2255 | # $(2): the destination archive file. |
| 2256 | define initialize-package-file |
| 2257 | @mkdir -p $(dir $(2)) |
| 2258 | $(hide) cp -f $(1) $(2) |
Fredrik Roubert | cc93f0c | 2015-01-28 21:29:38 +0100 | [diff] [blame] | 2259 | $(hide) zip -qd $(2) "*.class" \ |
| 2260 | $(if $(strip $(PRIVATE_DONT_DELETE_JAR_DIRS)),,"*/") \ |
| 2261 | || true # Ignore the error when nothing to delete. |
Ying Wang | 33360dd | 2015-01-14 14:23:56 -0800 | [diff] [blame] | 2262 | endef |
| 2263 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 2264 | #TODO: we kinda want to build different asset packages for |
| 2265 | # different configurations, then combine them later (or something). |
| 2266 | # Per-locale, etc. |
| 2267 | # A list of dynamic and static parameters; build layers for |
| 2268 | # dynamic params that lay over the static ones. |
| 2269 | #TODO: update the manifest to point to the package file |
Dianne Hackborn | 9bd5404 | 2009-05-15 18:01:20 -0700 | [diff] [blame] | 2270 | #Note that the version numbers are given to aapt as simple default |
| 2271 | #values; applications can override these by explicitly stating |
| 2272 | #them in their manifest. |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 2273 | define add-assets-to-package |
Ying Wang | c61d593 | 2010-03-10 16:02:42 -0800 | [diff] [blame] | 2274 | $(hide) $(AAPT) package -u $(PRIVATE_AAPT_FLAGS) \ |
Ying Wang | 4f1ab92 | 2011-03-15 13:19:30 -0700 | [diff] [blame] | 2275 | $(addprefix -c , $(PRIVATE_PRODUCT_AAPT_CONFIG)) \ |
Adam Lesinski | 2d1718a | 2014-05-09 10:57:48 -0700 | [diff] [blame] | 2276 | $(addprefix --preferred-density , $(PRIVATE_PRODUCT_AAPT_PREF_CONFIG)) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 2277 | $(addprefix -M , $(PRIVATE_ANDROID_MANIFEST)) \ |
| 2278 | $(addprefix -S , $(PRIVATE_RESOURCE_DIR)) \ |
| 2279 | $(addprefix -A , $(PRIVATE_ASSET_DIR)) \ |
| 2280 | $(addprefix -I , $(PRIVATE_AAPT_INCLUDES)) \ |
Ying Wang | bb9c230 | 2011-04-08 17:27:35 -0700 | [diff] [blame] | 2281 | $(addprefix --min-sdk-version , $(PRIVATE_DEFAULT_APP_TARGET_SDK)) \ |
| 2282 | $(addprefix --target-sdk-version , $(PRIVATE_DEFAULT_APP_TARGET_SDK)) \ |
Adam Lesinski | e758f93 | 2016-02-26 11:13:43 -0800 | [diff] [blame^] | 2283 | $(if $(filter --product,$(PRIVATE_AAPT_FLAGS)),,$(addprefix --product , $(PRIVATE_TARGET_AAPT_CHARACTERISTICS))) \ |
Colin Cross | f37b455 | 2015-07-16 17:15:19 -0700 | [diff] [blame] | 2284 | $(if $(filter --version-code,$(PRIVATE_AAPT_FLAGS)),,--version-code $(PLATFORM_SDK_VERSION)) \ |
Ying Wang | d75d893 | 2015-09-19 10:56:35 -0700 | [diff] [blame] | 2285 | $(if $(filter --version-name,$(PRIVATE_AAPT_FLAGS)),,--version-name $(APPS_DEFAULT_VERSION_NAME)) \ |
Jeff Hamilton | bb67d21 | 2010-02-05 22:36:42 -0600 | [diff] [blame] | 2286 | $(addprefix --rename-manifest-package , $(PRIVATE_MANIFEST_PACKAGE_NAME)) \ |
Ying Wang | 3dae0ee | 2010-09-02 15:41:01 -0700 | [diff] [blame] | 2287 | $(addprefix --rename-instrumentation-target-package , $(PRIVATE_MANIFEST_INSTRUMENTATION_FOR)) \ |
Adrian Roos | 6784cae | 2015-06-01 18:24:41 -0700 | [diff] [blame] | 2288 | --skip-symbols-without-default-localization \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 2289 | -F $@ |
| 2290 | endef |
| 2291 | |
Ying Wang | 8e20ef6 | 2014-06-24 20:01:52 -0700 | [diff] [blame] | 2292 | # We need the extra blank line, so that the command will be on a separate line. |
| 2293 | # $(1): the ABI name |
| 2294 | # $(2): the list of shared libraies |
| 2295 | define _add-jni-shared-libs-to-package-per-abi |
| 2296 | $(hide) cp $(2) $(dir $@)lib/$(1) |
| 2297 | |
| 2298 | endef |
| 2299 | |
Ying Wang | 1f8964d | 2015-07-15 18:33:24 -0700 | [diff] [blame] | 2300 | # For apps_only build, don't uncompress/page-align the jni libraries, |
| 2301 | # because the apk may be run on older platforms that don't support loading jni directly from apk. |
| 2302 | ifdef TARGET_BUILD_APPS |
| 2303 | JNI_COMPRESS_FLAGS := |
| 2304 | ZIPALIGN_PAGE_ALIGN_FLAGS := |
| 2305 | else |
| 2306 | JNI_COMPRESS_FLAGS := -0 |
| 2307 | ZIPALIGN_PAGE_ALIGN_FLAGS := -p |
| 2308 | endif |
| 2309 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 2310 | define add-jni-shared-libs-to-package |
| 2311 | $(hide) rm -rf $(dir $@)lib |
Ying Wang | 8e20ef6 | 2014-06-24 20:01:52 -0700 | [diff] [blame] | 2312 | $(hide) mkdir -p $(addprefix $(dir $@)lib/,$(PRIVATE_JNI_SHARED_LIBRARIES_ABI)) |
| 2313 | $(foreach abi,$(PRIVATE_JNI_SHARED_LIBRARIES_ABI),\ |
| 2314 | $(call _add-jni-shared-libs-to-package-per-abi,$(abi),\ |
| 2315 | $(patsubst $(abi):%,%,$(filter $(abi):%,$(PRIVATE_JNI_SHARED_LIBRARIES))))) |
Dan Willemsen | 48a621c | 2015-10-29 16:33:05 -0700 | [diff] [blame] | 2316 | $(hide) (cd $(dir $@) && zip -qrX $(JNI_COMPRESS_FLAGS) $(notdir $@) lib) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 2317 | $(hide) rm -rf $(dir $@)lib |
| 2318 | endef |
| 2319 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 2320 | #TODO: update the manifest to point to the dex file |
| 2321 | define add-dex-to-package |
Yohann Roussel | 94f86f8 | 2015-11-12 12:21:42 +0100 | [diff] [blame] | 2322 | $(hide) find $(dir $(PRIVATE_DEX_FILE)) -maxdepth 1 -name "classes*.dex" | sort | xargs zip -qjX $@ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 2323 | endef |
| 2324 | |
Ying Wang | 8548062 | 2012-08-09 15:20:50 -0700 | [diff] [blame] | 2325 | # Add java resources added by the current module. |
Yohann Roussel | 22c3fa6 | 2014-11-19 14:01:06 +0100 | [diff] [blame] | 2326 | # $(1) destination package |
| 2327 | # |
| 2328 | define add-java-resources-to |
| 2329 | $(call dump-words-to-file, $(PRIVATE_EXTRA_JAR_ARGS), $(1).jar-arg-list) |
| 2330 | $(hide) jar uf $(1) @$(1).jar-arg-list |
| 2331 | @rm -f $(1).jar-arg-list |
| 2332 | endef |
| 2333 | |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 2334 | # Add resources carried by static Jack libraries. |
| 2335 | # |
| 2336 | define add-carried-jack-resources |
| 2337 | $(hide) if [ -d $(PRIVATE_JACK_INTERMEDIATES_DIR) ] ; then \ |
Yohann Roussel | 94f86f8 | 2015-11-12 12:21:42 +0100 | [diff] [blame] | 2338 | find $(PRIVATE_JACK_INTERMEDIATES_DIR) -type f | sort \ |
Ying Wang | 3a562a9 | 2015-10-13 18:40:37 -0700 | [diff] [blame] | 2339 | | sed -e "s?^$(PRIVATE_JACK_INTERMEDIATES_DIR)/? -C \"$(PRIVATE_JACK_INTERMEDIATES_DIR)\" \"?" -e "s/$$/\"/" \ |
| 2340 | > $(dir $@)jack_res_jar_flags; \ |
| 2341 | if [ -s $(dir $@)jack_res_jar_flags ] ; then \ |
| 2342 | jar uf $@ @$(dir $@)jack_res_jar_flags; \ |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 2343 | fi; \ |
| 2344 | fi |
| 2345 | endef |
| 2346 | |
Alex Klyubin | b05b62d | 2016-01-13 10:32:47 -0800 | [diff] [blame] | 2347 | # Returns the minSdkVersion of the specified APK as a decimal number. If the |
| 2348 | # version is a codename, returns the current platform SDK version (always a |
| 2349 | # decimal number) instead. If the APK does not specify a minSdkVersion, returns |
| 2350 | # 0 to match how the Android platform interprets this situation at runtime. |
| 2351 | # |
| 2352 | define get-package-min-sdk-version-int |
| 2353 | $$(($(AAPT) dump badging $(1) 2>&1 | grep '^sdkVersion' || echo "sdkVersion:'0'") \ |
| 2354 | | cut -d"'" -f2 | \ |
| 2355 | sed -e s/^$(PLATFORM_VERSION_CODENAME)$$/$(PLATFORM_SDK_VERSION)/) |
| 2356 | endef |
| 2357 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 2358 | # Sign a package using the specified key/cert. |
| 2359 | # |
| 2360 | define sign-package |
| 2361 | $(hide) mv $@ $@.unsigned |
Alex Klyubin | 9667b18 | 2015-12-10 13:38:50 -0800 | [diff] [blame] | 2362 | $(hide) java -Djava.library.path=$(SIGNAPK_JNI_LIBRARY_PATH) -jar $(SIGNAPK_JAR) \ |
Alex Klyubin | b05b62d | 2016-01-13 10:32:47 -0800 | [diff] [blame] | 2363 | --min-sdk-version $(call get-package-min-sdk-version-int,$@.unsigned) \ |
Ying Wang | 31df068 | 2012-11-13 10:55:28 -0800 | [diff] [blame] | 2364 | $(PRIVATE_CERTIFICATE) $(PRIVATE_PRIVATE_KEY) \ |
| 2365 | $(PRIVATE_ADDITIONAL_CERTIFICATES) $@.unsigned $@.signed |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 2366 | $(hide) mv $@.signed $@ |
| 2367 | endef |
| 2368 | |
Dmitriy Ivanov | 13e5965 | 2014-07-23 15:27:21 -0700 | [diff] [blame] | 2369 | # Align STORED entries of a package on 4-byte boundaries to make them easier to mmap. |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 2370 | # |
| 2371 | define align-package |
| 2372 | $(hide) mv $@ $@.unaligned |
Dmitriy Ivanov | 13e5965 | 2014-07-23 15:27:21 -0700 | [diff] [blame] | 2373 | $(hide) $(ZIPALIGN) \ |
Ying Wang | 1f8964d | 2015-07-15 18:33:24 -0700 | [diff] [blame] | 2374 | -f \ |
| 2375 | $(ZIPALIGN_PAGE_ALIGN_FLAGS) \ |
Dmitriy Ivanov | 13e5965 | 2014-07-23 15:27:21 -0700 | [diff] [blame] | 2376 | 4 \ |
| 2377 | $@.unaligned $@.aligned |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 2378 | $(hide) mv $@.aligned $@ |
| 2379 | endef |
| 2380 | |
Dan Willemsen | 48a621c | 2015-10-29 16:33:05 -0700 | [diff] [blame] | 2381 | # Remove dynamic timestamps from packages |
| 2382 | # |
Dan Willemsen | a25ddad | 2015-11-03 16:09:49 -0800 | [diff] [blame] | 2383 | ifndef TARGET_BUILD_APPS |
Dan Willemsen | 48a621c | 2015-10-29 16:33:05 -0700 | [diff] [blame] | 2384 | define remove-timestamps-from-package |
| 2385 | $(hide) $(ZIPTIME) $@ |
| 2386 | endef |
Dan Willemsen | a25ddad | 2015-11-03 16:09:49 -0800 | [diff] [blame] | 2387 | endif |
Dan Willemsen | 48a621c | 2015-10-29 16:33:05 -0700 | [diff] [blame] | 2388 | |
Ying Wang | 1fb0152 | 2015-05-01 14:02:26 -0700 | [diff] [blame] | 2389 | # Uncompress shared libraries embedded in an apk. |
| 2390 | # |
Nick Kralevich | 5aa0223 | 2015-04-17 16:53:15 -0700 | [diff] [blame] | 2391 | define uncompress-shared-libs |
Ying Wang | 1fb0152 | 2015-05-01 14:02:26 -0700 | [diff] [blame] | 2392 | $(hide) if unzip -l $@ $(PRIVATE_EMBEDDED_JNI_LIBS) >/dev/null ; then \ |
| 2393 | rm -rf $(dir $@)uncompressedlibs && mkdir $(dir $@)uncompressedlibs; \ |
| 2394 | unzip $@ $(PRIVATE_EMBEDDED_JNI_LIBS) -d $(dir $@)uncompressedlibs && \ |
| 2395 | zip -d $@ 'lib/*.so' && \ |
Dan Willemsen | 5c64b4e | 2015-11-11 18:20:37 -0800 | [diff] [blame] | 2396 | ( cd $(dir $@)uncompressedlibs && find lib -type f | sort | zip -D -X -0 ../$(notdir $@) -@ ) && \ |
Ying Wang | 1fb0152 | 2015-05-01 14:02:26 -0700 | [diff] [blame] | 2397 | rm -rf $(dir $@)uncompressedlibs; \ |
| 2398 | fi |
Nick Kralevich | 5aa0223 | 2015-04-17 16:53:15 -0700 | [diff] [blame] | 2399 | endef |
| 2400 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 2401 | define install-dex-debug |
| 2402 | $(hide) if [ -f "$(PRIVATE_INTERMEDIATES_DIR)/classes.dex" ]; then \ |
| 2403 | mkdir -p $(TOP)/dalvik/DEBUG-FILES; \ |
| 2404 | $(ACP) $(PRIVATE_INTERMEDIATES_DIR)/classes.dex \ |
| 2405 | $(TOP)/dalvik/DEBUG-FILES/$(PRIVATE_MODULE).dex; \ |
| 2406 | fi |
| 2407 | $(hide) if [ -f "$(PRIVATE_INTERMEDIATES_DIR)/classes.lst" ]; then \ |
| 2408 | mkdir -p $(TOP)/dalvik/DEBUG-FILES; \ |
| 2409 | $(ACP) $(PRIVATE_INTERMEDIATES_DIR)/classes.lst \ |
| 2410 | $(TOP)/dalvik/DEBUG-FILES/$(PRIVATE_MODULE).lst; \ |
| 2411 | fi |
| 2412 | endef |
| 2413 | |
| 2414 | # TODO(joeo): If we can ever upgrade to post 3.81 make and get the |
| 2415 | # new prebuilt rules to work, we should change this to copy the |
| 2416 | # resources to the out directory and then copy the resources. |
| 2417 | |
Brian Carlstrom | 7826951 | 2010-12-10 12:10:24 -0800 | [diff] [blame] | 2418 | # Note: we intentionally don't clean PRIVATE_CLASS_INTERMEDIATES_DIR |
| 2419 | # in transform-java-to-classes for the sake of vm-tests. |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 2420 | define transform-host-java-to-package |
Dan Willemsen | 057aaea | 2015-08-14 12:59:50 -0700 | [diff] [blame] | 2421 | @echo "$($(PRIVATE_PREFIX)DISPLAY) Java: $(PRIVATE_MODULE) ($(PRIVATE_CLASS_INTERMEDIATES_DIR))" |
Ying Wang | 015edd2 | 2011-01-20 15:01:56 -0800 | [diff] [blame] | 2422 | $(call compile-java,$(HOST_JAVAC),$(PRIVATE_BOOTCLASSPATH)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 2423 | endef |
| 2424 | |
| 2425 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 2426 | ## Commands for copying files |
| 2427 | ########################################################### |
| 2428 | |
| 2429 | # Define a rule to copy a header. Used via $(eval) by copy_headers.make. |
| 2430 | # $(1): source header |
| 2431 | # $(2): destination header |
| 2432 | define copy-one-header |
| 2433 | $(2): $(1) |
| 2434 | @echo "Header: $$@" |
| 2435 | $$(copy-file-to-new-target-with-cp) |
| 2436 | endef |
| 2437 | |
| 2438 | # Define a rule to copy a file. For use via $(eval). |
| 2439 | # $(1): source file |
| 2440 | # $(2): destination file |
| 2441 | define copy-one-file |
| 2442 | $(2): $(1) | $(ACP) |
| 2443 | @echo "Copy: $$@" |
| 2444 | $$(copy-file-to-target) |
| 2445 | endef |
| 2446 | |
Joe Onorato | e44705a | 2012-05-17 17:12:04 -0700 | [diff] [blame] | 2447 | # Copies many files. |
| 2448 | # $(1): The files to copy. Each entry is a ':' separated src:dst pair |
| 2449 | # Evaluates to the list of the dst files (ie suitable for a dependency list) |
| 2450 | define copy-many-files |
| 2451 | $(foreach f, $(1), $(strip \ |
| 2452 | $(eval _cmf_tuple := $(subst :, ,$(f))) \ |
| 2453 | $(eval _cmf_src := $(word 1,$(_cmf_tuple))) \ |
| 2454 | $(eval _cmf_dest := $(word 2,$(_cmf_tuple))) \ |
| 2455 | $(eval $(call copy-one-file,$(_cmf_src),$(_cmf_dest))) \ |
| 2456 | $(_cmf_dest))) |
| 2457 | endef |
| 2458 | |
Ying Wang | 3ceecfa | 2012-05-14 14:39:00 -0700 | [diff] [blame] | 2459 | # Copy the file only if it's a well-formed xml file. For use via $(eval). |
| 2460 | # $(1): source file |
| 2461 | # $(2): destination file, must end with .xml. |
| 2462 | define copy-xml-file-checked |
| 2463 | $(2): $(1) | $(ACP) |
| 2464 | @echo "Copy xml: $$@" |
| 2465 | $(hide) xmllint $$< >/dev/null # Don't print the xml file to stdout. |
| 2466 | $$(copy-file-to-target) |
| 2467 | endef |
| 2468 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 2469 | # The -t option to acp and the -p option to cp is |
| 2470 | # required for OSX. OSX has a ridiculous restriction |
| 2471 | # where it's an error for a .a file's modification time |
| 2472 | # to disagree with an internal timestamp, and this |
| 2473 | # macro is used to install .a files (among other things). |
| 2474 | |
| 2475 | # Copy a single file from one place to another, |
| 2476 | # preserving permissions and overwriting any existing |
| 2477 | # file. |
Ian Rogers | 76a6dc3 | 2012-10-01 16:36:23 -0700 | [diff] [blame] | 2478 | # We disable the "-t" option for acp cannot handle |
Ying Wang | 84ed6fa | 2011-01-18 17:21:20 -0800 | [diff] [blame] | 2479 | # high resolution timestamp correctly on file systems like ext4. |
| 2480 | # Therefore copy-file-to-target is the same as copy-file-to-new-target. |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 2481 | define copy-file-to-target |
| 2482 | @mkdir -p $(dir $@) |
Ying Wang | 84ed6fa | 2011-01-18 17:21:20 -0800 | [diff] [blame] | 2483 | $(hide) $(ACP) -fp $< $@ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 2484 | endef |
| 2485 | |
| 2486 | # The same as copy-file-to-target, but use the local |
| 2487 | # cp command instead of acp. |
| 2488 | define copy-file-to-target-with-cp |
| 2489 | @mkdir -p $(dir $@) |
| 2490 | $(hide) cp -fp $< $@ |
| 2491 | endef |
| 2492 | |
Dianne Hackborn | 9c0c4b7 | 2009-08-11 19:16:46 -0700 | [diff] [blame] | 2493 | # The same as copy-file-to-target, but use the zipalign tool to do so. |
| 2494 | define copy-file-to-target-with-zipalign |
| 2495 | @mkdir -p $(dir $@) |
| 2496 | $(hide) $(ZIPALIGN) -f 4 $< $@ |
| 2497 | endef |
| 2498 | |
Doug Zongker | 1046d20 | 2009-08-06 13:02:19 -0700 | [diff] [blame] | 2499 | # The same as copy-file-to-target, but strip out "# comment"-style |
| 2500 | # comments (for config files and such). |
| 2501 | define copy-file-to-target-strip-comments |
| 2502 | @mkdir -p $(dir $@) |
| 2503 | $(hide) sed -e 's/#.*$$//' -e 's/[ \t]*$$//' -e '/^$$/d' < $< > $@ |
| 2504 | endef |
| 2505 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 2506 | # The same as copy-file-to-target, but don't preserve |
| 2507 | # the old modification time. |
| 2508 | define copy-file-to-new-target |
| 2509 | @mkdir -p $(dir $@) |
| 2510 | $(hide) $(ACP) -fp $< $@ |
| 2511 | endef |
| 2512 | |
| 2513 | # The same as copy-file-to-new-target, but use the local |
| 2514 | # cp command instead of acp. |
| 2515 | define copy-file-to-new-target-with-cp |
| 2516 | @mkdir -p $(dir $@) |
| 2517 | $(hide) cp -f $< $@ |
| 2518 | endef |
| 2519 | |
| 2520 | # Copy a prebuilt file to a target location. |
| 2521 | define transform-prebuilt-to-target |
| 2522 | @echo "$(if $(PRIVATE_IS_HOST_MODULE),host,target) Prebuilt: $(PRIVATE_MODULE) ($@)" |
| 2523 | $(copy-file-to-target) |
| 2524 | endef |
| 2525 | |
Dianne Hackborn | 9c0c4b7 | 2009-08-11 19:16:46 -0700 | [diff] [blame] | 2526 | # Copy a prebuilt file to a target location, using zipalign on it. |
| 2527 | define transform-prebuilt-to-target-with-zipalign |
| 2528 | @echo "$(if $(PRIVATE_IS_HOST_MODULE),host,target) Prebuilt APK: $(PRIVATE_MODULE) ($@)" |
| 2529 | $(copy-file-to-target-with-zipalign) |
| 2530 | endef |
| 2531 | |
Doug Zongker | 1046d20 | 2009-08-06 13:02:19 -0700 | [diff] [blame] | 2532 | # Copy a prebuilt file to a target location, stripping "# comment" comments. |
| 2533 | define transform-prebuilt-to-target-strip-comments |
| 2534 | @echo "$(if $(PRIVATE_IS_HOST_MODULE),host,target) Prebuilt: $(PRIVATE_MODULE) ($@)" |
| 2535 | $(copy-file-to-target-strip-comments) |
| 2536 | endef |
| 2537 | |
Ying Wang | c45a47b | 2015-04-08 12:24:37 -0700 | [diff] [blame] | 2538 | # Copy a list of files/directories to target location, with sub dir structure preserved. |
| 2539 | # For example $(HOST_OUT_EXECUTABLES)/aapt -> $(staging)/bin/aapt . |
| 2540 | # $(1): the source list of files/directories. |
| 2541 | # $(2): the path prefix to strip. In the above example it would be $(HOST_OUT). |
| 2542 | # $(3): the target location. |
| 2543 | define copy-files-with-structure |
| 2544 | $(foreach t,$(1),\ |
| 2545 | $(eval s := $(patsubst $(2)%,%,$(t)))\ |
| 2546 | $(hide) mkdir -p $(dir $(3)/$(s)); cp -Rf $(t) $(3)/$(s)$(newline)) |
| 2547 | endef |
| 2548 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 2549 | |
| 2550 | ########################################################### |
Ying Wang | 3b2bdf1 | 2010-02-01 09:51:23 -0800 | [diff] [blame] | 2551 | ## Commands to call Proguard |
| 2552 | ########################################################### |
Ying Wang | 3b2bdf1 | 2010-02-01 09:51:23 -0800 | [diff] [blame] | 2553 | define transform-jar-to-proguard |
Ying Wang | 7311a34 | 2013-08-21 18:32:49 -0700 | [diff] [blame] | 2554 | @echo Proguard: $@ |
Mihail Dumitrescu | 4df82b3 | 2014-02-07 15:18:59 +0000 | [diff] [blame] | 2555 | $(hide) $(PROGUARD) -injars $< -outjars $@ $(PRIVATE_PROGUARD_FLAGS) \ |
| 2556 | $(addprefix -injars , $(PRIVATE_EXTRA_INPUT_JAR)) |
Ying Wang | 3b2bdf1 | 2010-02-01 09:51:23 -0800 | [diff] [blame] | 2557 | endef |
| 2558 | |
Ying Wang | 3b2bdf1 | 2010-02-01 09:51:23 -0800 | [diff] [blame] | 2559 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 2560 | ## Stuff source generated from one-off tools |
| 2561 | ########################################################### |
| 2562 | |
| 2563 | define transform-generated-source |
| 2564 | @echo "target Generated: $(PRIVATE_MODULE) <= $<" |
| 2565 | @mkdir -p $(dir $@) |
| 2566 | $(hide) $(PRIVATE_CUSTOM_TOOL) |
| 2567 | endef |
| 2568 | |
| 2569 | |
| 2570 | ########################################################### |
| 2571 | ## Assertions about attributes of the target |
| 2572 | ########################################################### |
| 2573 | |
| 2574 | # $(1): The file to check |
| 2575 | ifndef get-file-size |
| 2576 | $(error HOST_OS must define get-file-size) |
| 2577 | endif |
| 2578 | |
Doug Zongker | 4647f12 | 2009-07-02 09:00:54 -0700 | [diff] [blame] | 2579 | # Convert a partition data size (eg, as reported in /proc/mtd) to the |
| 2580 | # size of the image used to flash that partition (which includes a |
Lars Svensson | 9cb8c28 | 2010-12-06 15:24:58 +0100 | [diff] [blame] | 2581 | # spare area for each page). |
Doug Zongker | 4647f12 | 2009-07-02 09:00:54 -0700 | [diff] [blame] | 2582 | # $(1): the partition data size |
| 2583 | define image-size-from-data-size |
Ying Wang | 4a2ecaf | 2011-02-09 17:24:27 -0800 | [diff] [blame] | 2584 | $(strip $(eval _isfds_value := $$(shell echo $$$$(($(1) / $(BOARD_NAND_PAGE_SIZE) * \ |
| 2585 | ($(BOARD_NAND_PAGE_SIZE)+$(BOARD_NAND_SPARE_SIZE))))))\ |
| 2586 | $(if $(filter 0, $(_isfds_value)),$(shell echo $$(($(BOARD_NAND_PAGE_SIZE)+$(BOARD_NAND_SPARE_SIZE)))),$(_isfds_value))\ |
| 2587 | $(eval _isfds_value :=)) |
Doug Zongker | 4647f12 | 2009-07-02 09:00:54 -0700 | [diff] [blame] | 2588 | endef |
| 2589 | |
| 2590 | # $(1): The file(s) to check (often $@) |
JP Abgrall | 0ed7cec | 2014-06-16 14:19:36 -0700 | [diff] [blame] | 2591 | # $(2): The maximum total image size, in decimal bytes. |
| 2592 | # Make sure to take into account any reserved space needed for the FS. |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 2593 | # |
| 2594 | # If $(2) is empty, evaluates to "true" |
| 2595 | # |
| 2596 | # Reserve bad blocks. Make sure that MAX(1% of partition size, 2 blocks) |
| 2597 | # is left over after the image has been flashed. Round the 1% up to the |
| 2598 | # next whole flash block size. |
| 2599 | define assert-max-file-size |
| 2600 | $(if $(2), \ |
Doug Zongker | 742fa57 | 2009-07-08 12:09:04 -0700 | [diff] [blame] | 2601 | size=$$(for i in $(1); do $(call get-file-size,$$i); echo +; done; echo 0); \ |
| 2602 | total=$$(( $$( echo "$$size" ) )); \ |
Doug Zongker | 4647f12 | 2009-07-02 09:00:54 -0700 | [diff] [blame] | 2603 | printname=$$(echo -n "$(1)" | tr " " +); \ |
Doug Zongker | 4647f12 | 2009-07-02 09:00:54 -0700 | [diff] [blame] | 2604 | img_blocksize=$(call image-size-from-data-size,$(BOARD_FLASH_BLOCK_SIZE)); \ |
| 2605 | twoblocks=$$((img_blocksize * 2)); \ |
| 2606 | onepct=$$((((($(2) / 100) - 1) / img_blocksize + 1) * img_blocksize)); \ |
JP Abgrall | 0ed7cec | 2014-06-16 14:19:36 -0700 | [diff] [blame] | 2607 | reserve=$$((twoblocks > onepct ? twoblocks : onepct)); \ |
Doug Zongker | 4647f12 | 2009-07-02 09:00:54 -0700 | [diff] [blame] | 2608 | maxsize=$$(($(2) - reserve)); \ |
Ying Wang | 99bcbeb | 2011-12-02 10:34:45 -0800 | [diff] [blame] | 2609 | echo "$$printname maxsize=$$maxsize blocksize=$$img_blocksize total=$$total reserve=$$reserve"; \ |
Doug Zongker | 4647f12 | 2009-07-02 09:00:54 -0700 | [diff] [blame] | 2610 | if [ "$$total" -gt "$$maxsize" ]; then \ |
| 2611 | echo "error: $$printname too large ($$total > [$(2) - $$reserve])"; \ |
| 2612 | false; \ |
Doug Zongker | 742fa57 | 2009-07-08 12:09:04 -0700 | [diff] [blame] | 2613 | elif [ "$$total" -gt $$((maxsize - 32768)) ]; then \ |
Doug Zongker | 4647f12 | 2009-07-02 09:00:54 -0700 | [diff] [blame] | 2614 | echo "WARNING: $$printname approaching size limit ($$total now; limit $$maxsize)"; \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 2615 | fi \ |
| 2616 | , \ |
| 2617 | true \ |
| 2618 | ) |
| 2619 | endef |
| 2620 | |
Doug Zongker | 8510a1e | 2009-08-07 16:38:08 -0700 | [diff] [blame] | 2621 | # Like assert-max-file-size, but the second argument is a partition |
| 2622 | # size, which we'll convert to a max image size before checking it |
| 2623 | # against the files. |
| 2624 | # |
| 2625 | # $(1): The file(s) to check (often $@) |
| 2626 | # $(2): The partition size. |
| 2627 | define assert-max-image-size |
| 2628 | $(if $(2), \ |
JP Abgrall | 0ed7cec | 2014-06-16 14:19:36 -0700 | [diff] [blame] | 2629 | $(call assert-max-file-size,$(1),$(call image-size-from-data-size,$(2)))) |
Doug Zongker | 8510a1e | 2009-08-07 16:38:08 -0700 | [diff] [blame] | 2630 | endef |
| 2631 | |
Doug Zongker | e01100c | 2009-06-19 17:12:18 -0700 | [diff] [blame] | 2632 | |
| 2633 | ########################################################### |
| 2634 | ## Define device-specific radio files |
| 2635 | ########################################################### |
Ying Wang | 94de1eb | 2013-07-26 12:19:20 -0700 | [diff] [blame] | 2636 | INSTALLED_RADIOIMAGE_TARGET := |
Doug Zongker | e01100c | 2009-06-19 17:12:18 -0700 | [diff] [blame] | 2637 | |
| 2638 | # Copy a radio image file to the output location, and add it to |
| 2639 | # INSTALLED_RADIOIMAGE_TARGET. |
| 2640 | # $(1): filename |
| 2641 | define add-radio-file |
Doug Zongker | 1483360 | 2010-02-02 13:12:04 -0800 | [diff] [blame] | 2642 | $(eval $(call add-radio-file-internal,$(1),$(notdir $(1)))) |
Doug Zongker | e01100c | 2009-06-19 17:12:18 -0700 | [diff] [blame] | 2643 | endef |
| 2644 | define add-radio-file-internal |
Doug Zongker | 1483360 | 2010-02-02 13:12:04 -0800 | [diff] [blame] | 2645 | INSTALLED_RADIOIMAGE_TARGET += $$(PRODUCT_OUT)/$(2) |
Doug Zongker | 1483360 | 2010-02-02 13:12:04 -0800 | [diff] [blame] | 2646 | $$(PRODUCT_OUT)/$(2) : $$(LOCAL_PATH)/$(1) | $$(ACP) |
Doug Zongker | e01100c | 2009-06-19 17:12:18 -0700 | [diff] [blame] | 2647 | $$(transform-prebuilt-to-target) |
| 2648 | endef |
| 2649 | |
Doug Zongker | 9296f09 | 2012-03-20 16:42:22 -0700 | [diff] [blame] | 2650 | # Version of add-radio-file that also arranges for the version of the |
| 2651 | # file to be checked against the contents of |
| 2652 | # $(TARGET_BOARD_INFO_FILE). |
| 2653 | # $(1): filename |
| 2654 | # $(2): name of version variable in board-info (eg, "version-baseband") |
| 2655 | define add-radio-file-checked |
| 2656 | $(eval $(call add-radio-file-checked-internal,$(1),$(notdir $(1)),$(2))) |
| 2657 | endef |
| 2658 | define add-radio-file-checked-internal |
| 2659 | INSTALLED_RADIOIMAGE_TARGET += $$(PRODUCT_OUT)/$(2) |
| 2660 | BOARD_INFO_CHECK += $(3):$(LOCAL_PATH)/$(1) |
| 2661 | $$(PRODUCT_OUT)/$(2) : $$(LOCAL_PATH)/$(1) | $$(ACP) |
| 2662 | $$(transform-prebuilt-to-target) |
| 2663 | endef |
| 2664 | |
Doug Zongker | e01100c | 2009-06-19 17:12:18 -0700 | [diff] [blame] | 2665 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 2666 | ########################################################### |
Joe Onorato | 899e62a | 2010-02-04 17:37:21 -0800 | [diff] [blame] | 2667 | # Override the package defined in $(1), setting the |
| 2668 | # variables listed below differently. |
| 2669 | # |
| 2670 | # $(1): The makefile to override (relative to the source |
| 2671 | # tree root) |
| 2672 | # $(2): Old LOCAL_PACKAGE_NAME value. |
| 2673 | # $(3): New LOCAL_PACKAGE_NAME value. |
Ying Wang | 3dae0ee | 2010-09-02 15:41:01 -0700 | [diff] [blame] | 2674 | # $(4): New LOCAL_MANIFEST_PACKAGE_NAME value. |
| 2675 | # $(5): New LOCAL_CERTIFICATE value. |
| 2676 | # $(6): New LOCAL_INSTRUMENTATION_FOR value. |
| 2677 | # $(7): New LOCAL_MANIFEST_INSTRUMENTATION_FOR value. |
Joe Onorato | 899e62a | 2010-02-04 17:37:21 -0800 | [diff] [blame] | 2678 | # |
| 2679 | # Note that LOCAL_PACKAGE_OVERRIDES is NOT cleared in |
| 2680 | # clear_vars.mk. |
| 2681 | ########################################################### |
| 2682 | define inherit-package |
Ying Wang | 3dae0ee | 2010-09-02 15:41:01 -0700 | [diff] [blame] | 2683 | $(eval $(call inherit-package-internal,$(1),$(2),$(3),$(4),$(5),$(6),$(7))) |
Joe Onorato | 899e62a | 2010-02-04 17:37:21 -0800 | [diff] [blame] | 2684 | endef |
| 2685 | |
| 2686 | define inherit-package-internal |
| 2687 | LOCAL_PACKAGE_OVERRIDES \ |
Ying Wang | 3dae0ee | 2010-09-02 15:41:01 -0700 | [diff] [blame] | 2688 | := $(strip $(1))||$(strip $(2))||$(strip $(3))||$(strip $(4))||&&$(strip $(5))||&&$(strip $(6))||&&$(strip $(7)) $(LOCAL_PACKAGE_OVERRIDES) |
Joe Onorato | 899e62a | 2010-02-04 17:37:21 -0800 | [diff] [blame] | 2689 | include $(1) |
| 2690 | LOCAL_PACKAGE_OVERRIDES \ |
| 2691 | := $(wordlist 1,$(words $(LOCAL_PACKAGE_OVERRIDES)), $(LOCAL_PACKAGE_OVERRIDES)) |
| 2692 | endef |
| 2693 | |
| 2694 | # To be used with inherit-package above |
| 2695 | # Evalutes to true if the package was overridden |
| 2696 | define set-inherited-package-variables |
| 2697 | $(strip $(call set-inherited-package-variables-internal)) |
| 2698 | endef |
| 2699 | |
| 2700 | define keep-or-override |
| 2701 | $(eval $(1) := $(if $(2),$(2),$($(1)))) |
| 2702 | endef |
| 2703 | |
| 2704 | define set-inherited-package-variables-internal |
| 2705 | $(eval _o := $(subst ||, ,$(lastword $(LOCAL_PACKAGE_OVERRIDES)))) |
| 2706 | $(eval _n := $(subst ||, ,$(firstword $(LOCAL_PACKAGE_OVERRIDES)))) |
| 2707 | $(if $(filter $(word 2,$(_n)),$(LOCAL_PACKAGE_NAME)), \ |
| 2708 | $(eval LOCAL_PACKAGE_NAME := $(word 3,$(_o))) \ |
| 2709 | $(eval LOCAL_MANIFEST_PACKAGE_NAME := $(word 4,$(_o))) \ |
Ying Wang | 3dae0ee | 2010-09-02 15:41:01 -0700 | [diff] [blame] | 2710 | $(call keep-or-override,LOCAL_CERTIFICATE,$(patsubst &&%,%,$(word 5,$(_o)))) \ |
| 2711 | $(call keep-or-override,LOCAL_INSTRUMENTATION_FOR,$(patsubst &&%,%,$(word 6,$(_o)))) \ |
| 2712 | $(call keep-or-override,LOCAL_MANIFEST_INSTRUMENTATION_FOR,$(patsubst &&%,%,$(word 7,$(_o)))) \ |
Joe Onorato | 899e62a | 2010-02-04 17:37:21 -0800 | [diff] [blame] | 2713 | $(eval LOCAL_OVERRIDES_PACKAGES := $(sort $(LOCAL_OVERRIDES_PACKAGES) $(word 2,$(_o)))) \ |
| 2714 | true \ |
| 2715 | ,) |
| 2716 | endef |
| 2717 | |
Ying Wang | 000e89a | 2012-04-30 15:48:27 -0700 | [diff] [blame] | 2718 | ########################################################### |
Ying Wang | c065da2 | 2012-11-14 15:57:07 -0800 | [diff] [blame] | 2719 | ## API Check |
| 2720 | ########################################################### |
| 2721 | |
| 2722 | # eval this to define a rule that runs apicheck. |
| 2723 | # |
| 2724 | # Args: |
| 2725 | # $(1) target |
| 2726 | # $(2) stable api file |
| 2727 | # $(3) api file to be tested |
Hui Shu | ec21c58 | 2014-03-13 16:21:08 -0700 | [diff] [blame] | 2728 | # $(4) stable removed api file |
Hui Shu | e8af17e | 2014-02-21 14:18:19 -0800 | [diff] [blame] | 2729 | # $(5) removed api file to be tested |
| 2730 | # $(6) arguments for apicheck |
| 2731 | # $(7) command to run if apicheck failed |
| 2732 | # $(8) target dependent on this api check |
| 2733 | # $(9) additional dependencies |
Ying Wang | c065da2 | 2012-11-14 15:57:07 -0800 | [diff] [blame] | 2734 | define check-api |
Hui Shu | ec21c58 | 2014-03-13 16:21:08 -0700 | [diff] [blame] | 2735 | $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(strip $(1))-timestamp: $(2) $(3) $(4) $(APICHECK) $(9) |
Ying Wang | c065da2 | 2012-11-14 15:57:07 -0800 | [diff] [blame] | 2736 | @echo "Checking API:" $(1) |
Hui Shu | e8af17e | 2014-02-21 14:18:19 -0800 | [diff] [blame] | 2737 | $(hide) ( $(APICHECK_COMMAND) $(6) $(2) $(3) $(4) $(5) || ( $(7) ; exit 38 ) ) |
Ying Wang | c065da2 | 2012-11-14 15:57:07 -0800 | [diff] [blame] | 2738 | $(hide) mkdir -p $$(dir $$@) |
| 2739 | $(hide) touch $$@ |
Hui Shu | e8af17e | 2014-02-21 14:18:19 -0800 | [diff] [blame] | 2740 | $(8): $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(strip $(1))-timestamp |
Ying Wang | c065da2 | 2012-11-14 15:57:07 -0800 | [diff] [blame] | 2741 | endef |
| 2742 | |
Ying Wang | 63d94fa | 2012-12-13 18:23:01 -0800 | [diff] [blame] | 2743 | ## Whether to build from source if prebuilt alternative exists |
| 2744 | ########################################################### |
| 2745 | # $(1): module name |
| 2746 | # $(2): LOCAL_PATH |
| 2747 | # Expands to empty string if not from source. |
| 2748 | ifeq (true,$(ANDROID_BUILD_FROM_SOURCE)) |
| 2749 | define if-build-from-source |
| 2750 | true |
| 2751 | endef |
| 2752 | else |
| 2753 | define if-build-from-source |
| 2754 | $(if $(filter $(ANDROID_NO_PREBUILT_MODULES),$(1))$(filter \ |
| 2755 | $(addsuffix %,$(ANDROID_NO_PREBUILT_PATHS)),$(2)),true) |
| 2756 | endef |
| 2757 | endif |
| 2758 | |
| 2759 | # Include makefile $(1) if build from source for module $(2) |
| 2760 | # $(1): the makefile to include |
| 2761 | # $(2): module name |
| 2762 | # $(3): LOCAL_PATH |
| 2763 | define include-if-build-from-source |
| 2764 | $(if $(call if-build-from-source,$(2),$(3)),$(eval include $(1))) |
| 2765 | endef |
| 2766 | |
Ying Wang | a6a6c35 | 2014-09-26 10:41:27 -0700 | [diff] [blame] | 2767 | # Return the arch for the source file of a prebuilt |
Chih-Wei Huang | 74ccefb | 2015-10-05 00:28:47 +0800 | [diff] [blame] | 2768 | # Return "none" if no matching arch found and return empty |
| 2769 | # if the input is empty, so the result can be passed to |
Ying Wang | a6a6c35 | 2014-09-26 10:41:27 -0700 | [diff] [blame] | 2770 | # LOCAL_MODULE_TARGET_ARCH. |
Ying Wang | c0adfb7 | 2014-02-27 14:10:53 -0800 | [diff] [blame] | 2771 | # $(1) the list of archs supported by the prebuilt |
| 2772 | define get-prebuilt-src-arch |
| 2773 | $(strip $(if $(filter $(TARGET_ARCH),$(1)),$(TARGET_ARCH),\ |
Chih-Wei Huang | 74ccefb | 2015-10-05 00:28:47 +0800 | [diff] [blame] | 2774 | $(if $(filter $(TARGET_2ND_ARCH),$(1)),$(TARGET_2ND_ARCH),$(if $(1),none)))) |
Ying Wang | c0adfb7 | 2014-02-27 14:10:53 -0800 | [diff] [blame] | 2775 | endef |
| 2776 | |
Ying Wang | c065da2 | 2012-11-14 15:57:07 -0800 | [diff] [blame] | 2777 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 2778 | ## Other includes |
| 2779 | ########################################################### |
| 2780 | |
| 2781 | # ----------------------------------------------------------------- |
| 2782 | # Rules and functions to help copy important files to DIST_DIR |
| 2783 | # when requested. |
| 2784 | include $(BUILD_SYSTEM)/distdir.mk |
| 2785 | |
Marie Lennerhagen | 9e5efce | 2010-10-20 13:41:59 +0200 | [diff] [blame] | 2786 | # Include any vendor specific definitions.mk file |
| 2787 | -include $(TOPDIR)vendor/*/build/core/definitions.mk |
Andrew Boie | 388c04d | 2014-10-28 08:32:11 -0700 | [diff] [blame] | 2788 | -include $(TOPDIR)device/*/build/core/definitions.mk |
Lee Campbell | 04ba312 | 2015-08-20 15:39:56 -0700 | [diff] [blame] | 2789 | -include $(TOPDIR)product/*/build/core/definitions.mk |
Marie Lennerhagen | 9e5efce | 2010-10-20 13:41:59 +0200 | [diff] [blame] | 2790 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 2791 | # broken: |
| 2792 | # $(foreach file,$^,$(if $(findstring,.a,$(suffix $file)),-l$(file),$(file))) |
| 2793 | |
| 2794 | ########################################################### |
| 2795 | ## Misc notes |
| 2796 | ########################################################### |
| 2797 | |
| 2798 | #DEPDIR = .deps |
| 2799 | #df = $(DEPDIR)/$(*F) |
| 2800 | |
| 2801 | #SRCS = foo.c bar.c ... |
| 2802 | |
| 2803 | #%.o : %.c |
| 2804 | # @$(MAKEDEPEND); \ |
| 2805 | # cp $(df).d $(df).P; \ |
| 2806 | # sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ |
| 2807 | # -e '/^$$/ d' -e 's/$$/ :/' < $(df).d >> $(df).P; \ |
| 2808 | # rm -f $(df).d |
| 2809 | # $(COMPILE.c) -o $@ $< |
| 2810 | |
| 2811 | #-include $(SRCS:%.c=$(DEPDIR)/%.P) |
| 2812 | |
| 2813 | |
| 2814 | #%.o : %.c |
| 2815 | # $(COMPILE.c) -MD -o $@ $< |
| 2816 | # @cp $*.d $*.P; \ |
| 2817 | # sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ |
| 2818 | # -e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $*.P; \ |
| 2819 | # rm -f $*.d |