Lines Matching +full:ninja +full:- +full:linux

8 #      http://www.apache.org/licenses/LICENSE-2.0
37 # sub-variables.
51 # of all targets for a particular tag. The top-level variable
55 # its sub-variables.)
62 # These all have an order-only dependency on the copied headers
133 define print-vars
148 define true-or-empty
155 define gcno-touch-rule
157 touch -c $$@
168 define my-dir
172 $(error my-dir must be called before including any other makefile.) \
184 define all-makefiles-under
195 define first-makefiles-under
197 --mindepth=2 $(addprefix --dir=,$(1)) Android.mk)
205 define all-subdir-makefiles
206 $(call all-makefiles-under,$(call my-dir))
216 define all-named-subdir-makefiles
217 $(wildcard $(addsuffix /Android.mk, $(addprefix $(call my-dir)/,$(1))))
224 ## INC_DIRS := $(call all-named-dirs-under,inc,.)
227 define all-named-dirs-under
228 $(call find-subdir-files,$(2) -type d -name "$(1)")
236 define all-subdir-named-dirs
237 $(call all-named-dirs-under,$(1),.)
244 ## SRC_FILES := $(call all-named-files-under,*.h,src tests)
247 define all-named-files-under
248 $(call find-files-in-subdirs,$(LOCAL_PATH),"$(1)",$(2))
256 define all-subdir-named-files
257 $(call all-named-files-under,$(1),.)
263 ## SRC_FILES := $(call all-java-files-under,src tests)
266 define all-java-files-under
267 $(call all-named-files-under,*.java,$(1))
272 ## SRC_FILES := $(call all-subdir-java-files)
275 define all-subdir-java-files
276 $(call all-java-files-under,.)
282 ## SRC_FILES := $(call all-c-files-under,src tests)
285 define all-c-files-under
286 $(call all-named-files-under,*.c,$(1))
291 ## SRC_FILES := $(call all-subdir-c-files)
294 define all-subdir-c-files
295 $(call all-c-files-under,.)
302 ## SRC_FILES := $(call all-cpp-files-under,src tests)
305 define all-cpp-files-under
308 find -L $(1) -name "*$(or $(LOCAL_CPP_EXTENSION),.cpp)" -and -not -name ".*") \
314 ## SRC_FILES := $(call all-subdir-cpp-files)
317 define all-subdir-cpp-files
318 $(call all-cpp-files-under,.)
327 define all-Iaidl-files-under
328 $(call all-named-files-under,I*.aidl,$(1))
335 define all-subdir-Iaidl-files
336 $(call all-Iaidl-files-under,.)
345 define all-vts-files-under
346 $(call all-named-files-under,*.vts,$(1))
353 define all-subdir-vts-files
354 $(call all-vts-files-under,.)
360 ## SRC_FILES := $(call all-logtags-files-under,src)
363 define all-logtags-files-under
364 $(call all-named-files-under,*.logtags,$(1))
370 ## SRC_FILES := $(call all-proto-files-under,src)
373 define all-proto-files-under
374 $(call all-named-files-under,*.proto,$(1))
380 ## SRC_FILES := $(call all-renderscript-files-under,src)
383 define all-renderscript-files-under
384 $(call find-subdir-files,$(1) \( -name "*.rscript" -or -name "*.fs" \) -and -not -name ".*")
390 ## SRC_FILES := $(call all-c-files-under,src tests)
393 define all-S-files-under
394 $(call all-named-files-under,*.S,$(1))
400 ## SRC_FILES := $(call all-html-files-under,src tests)
403 define all-html-files-under
404 $(call all-named-files-under,*.html,$(1))
409 ## SRC_FILES := $(call all-subdir-html-files)
412 define all-subdir-html-files
413 $(call all-html-files-under,.)
418 ## SRC_FILES := $(call find-subdir-files, <pattern>)
421 define find-subdir-files
422 $(sort $(patsubst ./%,%,$(shell cd $(LOCAL_PATH) ; find -L $(1))))
429 # SRC_FILES += $(call find-subdir-subdir-files, \
433 define find-subdir-subdir-files
434 $(sort $(filter-out $(patsubst %,$(1)/%,$(3)),$(patsubst ./%,%,$(shell cd \
435 $(LOCAL_PATH) ; find -L $(1) -maxdepth 1 -name $(2)))))
440 ## SRC_FILES := $(call all-subdir-java-files)
443 define find-subdir-assets
445 $(shell if [ -d $(1) ] ; then cd $(1) ; find -L ./ -not -name '.*' -and -type f ; fi)), \
446 $(warning Empty argument supplied to find-subdir-assets in $(LOCAL_PATH)) \
454 define find-other-java-files
455 $(call all-java-files-under,$(1))
458 define find-other-html-files
459 $(call all-html-files-under,$(1))
466 # $(2): the file name pattern to be passed to find as "-name".
471 define find-files-in-subdirs
474 find -L $(3) -name $(2) -and -not -name ".*") \
486 define find-parent-file
490 $(if $(filter-out ./ .,$(1)), \
491 $(call find-parent-file,$(patsubst %/,%,$(dir $(1))),$(2)) \
500 ## $(2): the file name pattern to be passed to find as "-name"
504 define find-test-data-in-subdirs
507 find -L $(3) -type f -and -name $(2) -and -not -name ".*") \
515 define add-dependency
523 define reverse-list
524 $(if $(1),$(call reverse-list,$(wordlist 2,$(words $(1)),$(1)))) $(firstword $(1))
537 define fix-notice-deps
571 define license-metadata-dir
572 $(call generated-sources-dir-for,META,lic,)
578 define license-metadata-rule
579 $(strip $(eval _dir := $(call license-metadata-dir)))
580 $(strip $(eval _deps := $(sort $(filter-out $(_dir)/$(1).meta_lic,$(foreach d,$(ALL_MODULES.$(1).NO…
585 mkdir -p $$(dir $$@)
587 sort -u $$@ -o $$@
598 …notices) $(foreach b,$(_tgts), $(_dir)/$(b).meta_module) build/make/tools/build-license-metadata.sh
599 rm -f $$@
600 mkdir -p $$(dir $$@)
601-license-metadata.sh -k $$(PRIVATE_KINDS) -c $$(PRIVATE_CONDITIONS) -n $$(PRIVATE_NOTICES) -d $$(P…
619 @echo Notice file: $$< -- $$@
620 mkdir -p $$(dir $$@)
630 define build-license-metadata
631 $(foreach m,$(sort $(ALL_MODULES)),$(eval $(call license-metadata-rule,$(m))))
643 define find-idf-prefix
661 # $(3): { HOST, HOST_CROSS, <empty (TARGET)>, <other non-empty (HOST)> }
662 # $(4): if non-empty, force the intermediates to be COMMON
663 # $(5): if non-empty, force the intermediates to be for the 2nd arch
664 # $(6): if non-empty, force the intermediates to be for the host cross os
665 define intermediates-dir-for
669 $(error $(LOCAL_PATH): Class not defined in call to intermediates-dir-for)) \
672 $(error $(LOCAL_PATH): Name not defined in call to intermediates-dir-for)) \
673 $(eval _idfPrefix := $(call find-idf-prefix,$(3),$(6))) \
689 # $(1): if non-empty, force the intermediates to be COMMON
690 # $(2): if non-empty, force the intermediates to be for the 2nd arch
691 # $(3): if non-empty, force the intermediates to be for the host cross os
692 define local-intermediates-dir
695 … $(error $(LOCAL_PATH): LOCAL_MODULE_CLASS not defined before call to local-intermediates-dir)) \
697 $(error $(LOCAL_PATH): LOCAL_MODULE not defined before call to local-intermediates-dir)) \
698 …$(call intermediates-dir-for,$(LOCAL_MODULE_CLASS),$(LOCAL_MODULE),$(if $(strip $(LOCAL_IS_HOST_MO…
713 # $(3): { HOST, HOST_CROSS, <empty (TARGET)>, <other non-empty (HOST)> }
714 # $(4): if non-empty, force the generated sources to be COMMON
715 define generated-sources-dir-for
719 $(error $(LOCAL_PATH): Class not defined in call to generated-sources-dir-for)) \
722 $(error $(LOCAL_PATH): Name not defined in call to generated-sources-dir-for)) \
723 $(eval _idfPrefix := $(call find-idf-prefix,$(3),)) \
736 # $(1): if non-empty, force the intermediates to be COMMON
737 define local-generated-sources-dir
740 …(error $(LOCAL_PATH): LOCAL_MODULE_CLASS not defined before call to local-generated-sources-dir)) \
742 … $(error $(LOCAL_PATH): LOCAL_MODULE not defined before call to local-generated-sources-dir)) \
743 …$(call generated-sources-dir-for,$(LOCAL_MODULE_CLASS),$(LOCAL_MODULE),$(if $(strip $(LOCAL_IS_HOS…
755 # $(4): { HOST, HOST_CROSS, <empty (TARGET)>, <other non-empty (HOST)> }
756 define packaging-dir-for
760 $(error $(LOCAL_PATH): Class not defined in call to generated-sources-dir-for)) \
763 $(error $(LOCAL_PATH): Name not defined in call to generated-sources-dir-for)) \
764 $(call intermediates-dir-for,PACKAGING,$(1),$(4))/$(_pdfClass)/$(_pdfName)_intermediates \
772 define local-packaging-dir
775 …(error $(LOCAL_PATH): LOCAL_MODULE_CLASS not defined before call to local-generated-sources-dir)) \
777 … $(error $(LOCAL_PATH): LOCAL_MODULE not defined before call to local-generated-sources-dir)) \
778 …$(call packaging-dir-for,$(1),$(LOCAL_MODULE_CLASS),$(LOCAL_MODULE),$(if $(strip $(LOCAL_IS_HOST_M…
787 ## sub-makefiles have been included.
791 define module-built-files
799 ## sub-makefiles have been included.
803 define module-installed-files
811 ## sub-makefiles have been included.
815 define module-target-built-files
825 ## sub-makefiles have been included.
829 define module-stubs-files
831 $(call java-lib-files,$(module).stubs),$(ALL_MODULES.$(module).STUBS)))
840 define doc-timestamp-for
841 $(OUT_DOCS)/$(strip $(1))-timestamp
848 ## $(2): Non-empty if IS_HOST_MODULE
851 # Get the jar files (you can pass to "javac -classpath") of static or shared
854 # $(2): Non-empty if IS_HOST_MODULE
855 define java-lib-files
856 $(foreach lib,$(1),$(call intermediates-dir-for,JAVA_LIBRARIES,$(lib),$(2),COMMON)/classes.jar)
859 # Get the header jar files (you can pass to "javac -classpath") of static or shared
862 # $(2): Non-empty if IS_HOST_MODULE
864 define java-lib-header-files
865 $(foreach lib,$(1),$(call intermediates-dir-for,JAVA_LIBRARIES,$(lib),$(2),COMMON)/classes-header.j…
868 define java-lib-header-files
869 $(call java-lib-files,$(1),$(2))
876 # $(2): Non-empty if IS_HOST_MODULE
879 # Now we can use classes.jar as dependency, so java-lib-deps is the same
880 # as java-lib-files.
881 define java-lib-deps
882 $(call java-lib-files,$(1),$(2))
885 # Get the jar files (you can pass to "javac -classpath") of static or shared
888 define app-lib-files
889 $(foreach lib,$(1),$(call intermediates-dir-for,APPS,$(lib),,COMMON)/classes.jar)
892 # Get the header jar files (you can pass to "javac -classpath") of static or shared
896 define app-lib-header-files
897 $(foreach lib,$(1),$(call intermediates-dir-for,APPS,$(lib),,COMMON)/classes-header.jar)
900 define app-lib-header-files
901 $(call app-lib-files,$(1))
905 # Get the exported-sdk-libs files which collectively give you the list of exported java sdk
908 define exported-sdk-libs-files
909 $(foreach lib,$(1),$(call intermediates-dir-for,JAVA_LIBRARIES,$(lib),,COMMON)/exported-sdk-libs)
919 define modules-for-tag-list
923 # Same as modules-for-tag-list, but operates on
926 define module-names-for-tag-list
938 define get-tagged-modules
939 $(filter-out \
940 $(call modules-for-tag-list,$(2)), \
941 $(call modules-for-tag-list,$(1)))
952 define append-path
958 ## Color-coded warnings and errors
959 ## Use echo-(warning|error) in a build rule
960 ## Use pretty-(warning|error) instead of $(warning)/$(error)
969 define echo-warning
970 echo -e "$(ESC_BOLD)$(1): $(ESC_WARNING)warning:$(ESC_RESET)$(ESC_BOLD)" '$(subst ','\'',$(2))' "$…
975 define echo-error
976 echo -e "$(ESC_BOLD)$(1): $(ESC_ERROR)error:$(ESC_RESET)$(ESC_BOLD)" '$(subst ','\'',$(2))' "$(ESC…
992 define include-depfile
997 define include-depfiles-for-objs
998 $(foreach obj, $(1), $(call include-depfile, $(obj:%.o=%.d), $(obj)))
1006 define track-src-file-obj
1007 $(eval $(call _track-src-file-obj,$(1)))
1009 define _track-src-file-obj
1019 define track-src-file-gen
1020 $(eval $(call _track-src-file-gen,$(2)))
1022 define _track-src-file-gen
1032 define track-gen-file-obj
1033 $(call track-src-file-obj,$(foreach f,$(1),\
1041 define transform-l-to-c-or-cpp
1043 @mkdir -p $(dir $@)
1044 M4=$(M4) $(LEX) -o$@ $<
1052 define transform-y-to-c-or-cpp
1054 @mkdir -p $(dir $@)
1056 --defines=$(basename $@).h \
1057 -o $@ $<
1064 ## Merge multiple .d files generated by llvm-rs-cc. This is necessary
1065 ## because ninja can handle only a single depfile per build target.
1066 ## .d files generated by llvm-rs-cc define .stamp, .bc, and optionally
1067 ## .java as build targets. However, there's no way to let ninja know
1075 define _merge-renderscript-d
1085 define transform-renderscripts-to-java-and-bc
1087 $(hide) rm -rf $(PRIVATE_RS_OUTPUT_DIR)
1088 $(hide) mkdir -p $(PRIVATE_RS_OUTPUT_DIR)/res/raw
1089 $(hide) mkdir -p $(PRIVATE_RS_OUTPUT_DIR)/src
1091 -o $(PRIVATE_RS_OUTPUT_DIR)/res/raw \
1092 -p $(PRIVATE_RS_OUTPUT_DIR)/src \
1093 -d $(PRIVATE_RS_OUTPUT_DIR) \
1094 -a $@ -MD \
1095 $(addprefix -target-api , $(PRIVATE_RS_TARGET_API)) \
1097 $(foreach inc,$(PRIVATE_RS_INCLUDES),$(addprefix -I , $(inc))) \
1099 $(SOONG_ZIP) -o $@ -C $(PRIVATE_RS_OUTPUT_DIR)/src -D $(PRIVATE_RS_OUTPUT_DIR)/src
1100 $(SOONG_ZIP) -o $(PRIVATE_RS_OUTPUT_RES_ZIP) -C $(PRIVATE_RS_OUTPUT_DIR)/res -D $(PRIVATE_RS_OUTPUT…
1101 $(call _merge-renderscript-d,$(PRIVATE_DEP_FILES),$@.d)
1104 define transform-bc-to-so
1106 $(hide) mkdir -p $(dir $@)
1107 $(hide) $(BCC_COMPAT) -O3 -o $(dir $@)/$(notdir $(<:.bc=.o)) -fPIC -shared \
1108 -rt-path $(RS_PREBUILT_CLCORE) -mtriple $(RS_COMPAT_TRIPLE) $<
1109 $(hide) $(PRIVATE_CXX_LINK) -shared -Wl,-soname,$(notdir $@) -nostdlib \
1110 -Wl,-rpath,\$$ORIGIN/../lib \
1113 -o $@ $(CLANG_TARGET_GLOBAL_LDFLAGS) -Wl,--hash-style=sysv \
1114 -L $(SOONG_OUT_DIR)/ndk/platforms/android-$(PRIVATE_SDK_VERSION)/arch-$(TARGET_ARCH)/usr/lib64 \
1115 -L $(SOONG_OUT_DIR)/ndk/platforms/android-$(PRIVATE_SDK_VERSION)/arch-$(TARGET_ARCH)/usr/lib \
1116 $(call intermediates-dir-for,SHARED_LIBRARIES,libRSSupport)/libRSSupport.so \
1117 -lm -lc
1124 define transform-renderscripts-to-cpp-and-bc
1126 $(hide) rm -rf $(PRIVATE_RS_OUTPUT_DIR)
1127 $(hide) mkdir -p $(PRIVATE_RS_OUTPUT_DIR)/
1129 -o $(PRIVATE_RS_OUTPUT_DIR)/ \
1130 -d $(PRIVATE_RS_OUTPUT_DIR) \
1131 -a $@ -MD \
1132 -reflect-c++ \
1133 $(addprefix -target-api , $(PRIVATE_RS_TARGET_API)) \
1135 $(addprefix -I , $(PRIVATE_RS_INCLUDES)) \
1137 $(call _merge-renderscript-d,$(PRIVATE_DEP_FILES),$@.d)
1138 $(hide) mkdir -p $(dir $@)
1147 define transform-aidl-to-java
1148 @mkdir -p $(dir $@)
1150 $(hide) $(AIDL) -d$(patsubst %.java,%.P,$@) $(PRIVATE_AIDL_FLAGS) $< $@
1152 #$(AIDL) $(PRIVATE_AIDL_FLAGS) $< - | indent -nut -br -npcs -l1000 > $@
1154 define transform-aidl-to-cpp
1155 @mkdir -p $(dir $@)
1156 @mkdir -p $(PRIVATE_HEADER_OUTPUT_DIR)
1158 $(hide) $(AIDL_CPP) -d$(basename $@).aidl.d --ninja $(PRIVATE_AIDL_FLAGS) \
1168 define define-aidl-java-rule
1169 define-aidl-java-rule-src := $(patsubst %.aidl,%.java,$(subst ../,dotdot/,$(addprefix $(2)/,$(1))))
1170 $$(define-aidl-java-rule-src) : $(call clean-path,$(LOCAL_PATH)/$(1)) $(AIDL)
1171 $$(transform-aidl-to-java)
1172 $(3) += $$(define-aidl-java-rule-src)
1181 define define-aidl-cpp-rule
1182 define-aidl-cpp-rule-src := $(patsubst %.aidl,%$(LOCAL_CPP_EXTENSION),$(subst ../,dotdot/,$(addpref…
1183 $$(define-aidl-cpp-rule-src) : $(call clean-path,$(LOCAL_PATH)/$(1)) $(AIDL_CPP)
1184 $$(transform-aidl-to-cpp)
1185 $(3) += $$(define-aidl-cpp-rule-src)
1192 define transform-vts-to-cpp
1193 @mkdir -p $(dir $@)
1194 @mkdir -p $(PRIVATE_HEADER_OUTPUT_DIR)
1196 $(hide) $(VTSC) -TODO_b/120496070 $(PRIVATE_VTS_FLAGS) \
1206 define define-vts-cpp-rule
1207 define-vts-cpp-rule-src := $(patsubst %.vts,%$(LOCAL_CPP_EXTENSION),$(subst ../,dotdot/,$(addprefix…
1208 $$(define-vts-cpp-rule-src) : $(LOCAL_PATH)/$(1) $(VTSC)
1209 $$(transform-vts-to-cpp)
1210 $(3) += $$(define-vts-cpp-rule-src)
1214 ## Commands for running java-event-log-tags.py
1217 define transform-logtags-to-java
1218 @mkdir -p $(dir $@)
1220 $(hide) $(JAVATAGS) -o $@ $< $(PRIVATE_MERGED_TAG)
1228 define transform-proto-to-java
1229 @mkdir -p $(dir $@)
1231 @rm -rf $(PRIVATE_PROTO_JAVA_OUTPUT_DIR)
1232 @mkdir -p $(PRIVATE_PROTO_JAVA_OUTPUT_DIR)
1235 $(addprefix --proto_path=, $(PRIVATE_PROTO_INCLUDES)) \
1240 $(SOONG_ZIP) -o $@ -C $(PRIVATE_PROTO_JAVA_OUTPUT_DIR) -D $(PRIVATE_PROTO_JAVA_OUTPUT_DIR)
1247 define transform-proto-to-cc
1249 @mkdir -p $(dir $@)
1252 $(addprefix --proto_path=, $(PRIVATE_PROTO_INCLUDES)) \
1261 ## Helper to set include paths form transform-*-to-o
1263 define c-includes
1264 $(addprefix -I , $(PRIVATE_C_INCLUDES)) \
1267 $(addprefix -I ,\
1268 $(filter-out $(PRIVATE_C_INCLUDES), \
1270 $(addprefix -isystem ,\
1271 $(filter-out $(PRIVATE_C_INCLUDES), \
1279 define transform-cpp-to-o-compiler-args
1280 $(c-includes) \
1281 -c \
1296 define call-clang-tidy
1299 -checks=$(PRIVATE_TIDY_CHECKS)
1302 define clang-tidy-cpp
1303 $(hide) $(call-clang-tidy) $< -- $(transform-cpp-to-o-compiler-args)
1307 define transform-cpp-to-o
1310 $(clang-tidy-cpp))
1313 define transform-cpp-to-o
1315 @mkdir -p $(dir $@)
1316 $(if $(PRIVATE_TIDY_CHECKS),$(clang-tidy-cpp))
1318 $(transform-cpp-to-o-compiler-args) \
1319 -MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
1329 define transform-c-or-s-to-o-compiler-args
1330 $(c-includes) \
1331 -c \
1340 define transform-c-to-o-compiler-args
1341 $(call transform-c-or-s-to-o-compiler-args, \
1348 define clang-tidy-c
1349 $(hide) $(call-clang-tidy) $< -- $(transform-c-to-o-compiler-args)
1353 define transform-c-to-o
1356 $(clang-tidy-c))
1359 define transform-c-to-o
1361 @mkdir -p $(dir $@)
1362 $(if $(PRIVATE_TIDY_CHECKS),$(clang-tidy-c))
1364 $(transform-c-to-o-compiler-args) \
1365 -MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
1369 define transform-s-to-o
1371 @mkdir -p $(dir $@)
1373 $(call transform-c-or-s-to-o-compiler-args, $(PRIVATE_ASFLAGS)) \
1374 -MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
1378 define transform-asm-to-o
1379 @mkdir -p $(dir $@)
1381 $(addprefix -I , $(PRIVATE_C_INCLUDES)) \
1384 -o $@ $<
1388 ## Commands for running gcc to compile an Objective-C file
1393 define transform-m-to-o
1395 $(call transform-c-or-s-to-o, $(PRIVATE_CFLAGS) $(PRIVATE_DEBUG_CFLAGS))
1402 define transform-host-cpp-to-o-compiler-args
1403 $(c-includes) \
1404 -c \
1416 define clang-tidy-host-cpp
1417 $(hide) $(call-clang-tidy) $< -- $(transform-host-cpp-to-o-compiler-args)
1421 define transform-host-cpp-to-o
1424 $(clang-tidy-host-cpp))
1427 define transform-host-cpp-to-o
1429 @mkdir -p $(dir $@)
1430 $(if $(PRIVATE_TIDY_CHECKS),$(clang-tidy-host-cpp))
1432 $(transform-host-cpp-to-o-compiler-args) \
1433 -MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
1442 define transform-host-c-or-s-to-o-common-args
1443 $(c-includes) \
1444 -c \
1452 define transform-host-c-or-s-to-o
1453 @mkdir -p $(dir $@)
1455 $(transform-host-c-or-s-to-o-common-args) \
1457 -MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
1460 define transform-host-c-to-o-compiler-args
1461 $(transform-host-c-or-s-to-o-common-args) \
1466 define clang-tidy-host-c
1467 $(hide) $(call-clang-tidy) $< -- $(transform-host-c-to-o-compiler-args)
1471 define transform-host-c-to-o
1474 $(clang-tidy-host-c))
1477 define transform-host-c-to-o
1479 @mkdir -p $(dir $@)
1480 $(if $(PRIVATE_TIDY_CHECKS), $(clang-tidy-host-c))
1482 $(transform-host-c-to-o-compiler-args) \
1483 -MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
1487 define transform-host-s-to-o
1489 $(call transform-host-c-or-s-to-o, $(PRIVATE_ASFLAGS))
1493 ## Commands for running gcc to compile a host Objective-C file
1496 define transform-host-m-to-o
1498 $(call transform-host-c-or-s-to-o, $(PRIVATE_CFLAGS) $(PRIVATE_DEBUG_CFLAGS) $(PRIVATE_CFLAGS_NO_OV…
1502 ## Commands for running gcc to compile a host Objective-C++ file
1505 define transform-host-mm-to-o
1506 $(transform-host-cpp-to-o)
1521 # $(4): the ninja pool to use for the rule
1522 define compile-dotdot-cpp-file
1526 $$(transform-$$(PRIVATE_HOST)cpp-to-o)
1527 $$(call include-depfiles-for-objs, $$(o))
1536 # $(4): the ninja pool to use for the rule
1537 define compile-dotdot-c-file
1541 $$(transform-$$(PRIVATE_HOST)c-to-o)
1542 $$(call include-depfiles-for-objs, $$(o))
1551 # $(4): the ninja pool to use for the rule
1552 define compile-dotdot-s-file
1556 $$(transform-$$(PRIVATE_HOST)s-to-o)
1557 $$(call include-depfiles-for-objs, $$(o))
1566 # $(4): the ninja pool to use for the rule
1567 define compile-dotdot-s-file-no-deps
1571 $$(transform-$$(PRIVATE_HOST)s-to-o)
1579 define _concat-if-arg2-not-empty
1589 define split-long-arguments
1591 $(call _concat-if-arg2-not-empty,$(1),$(wordlist 501,1000,$(2)))
1592 $(call _concat-if-arg2-not-empty,$(1),$(wordlist 1001,1500,$(2)))
1593 $(call _concat-if-arg2-not-empty,$(1),$(wordlist 1501,2000,$(2)))
1594 $(call _concat-if-arg2-not-empty,$(1),$(wordlist 2001,2500,$(2)))
1595 $(call _concat-if-arg2-not-empty,$(1),$(wordlist 2501,3000,$(2)))
1596 $(call _concat-if-arg2-not-empty,$(1),$(wordlist 3001,99999,$(2)))
1601 define _extract-and-include-single-target-whole-static-lib
1603 rm -rf $$ldir; \
1604 mkdir -p $$ldir; \
1610 if [ -e $$ldir/$$f ]; then \
1628 define extract-and-include-whole-static-libs-first
1634 define extract-and-include-target-whole-static-libs
1635 $(call extract-and-include-whole-static-libs-first, $(firstword $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIE…
1637 $(call _extract-and-include-single-target-whole-static-lib, $(lib), $(1)))
1642 define transform-o-to-static-lib
1644 @mkdir -p $(dir $@)
1645 @rm -f $@ $@.tmp
1646 $(call extract-and-include-target-whole-static-libs,$@.tmp)
1647 $(call split-long-arguments,$($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) \
1651 $(hide) mv -f $@.tmp $@
1660 define _extract-and-include-single-host-whole-static-lib
1662 rm -rf $$ldir; \
1663 mkdir -p $$ldir; \
1669 if [ -e $$ldir/$$f ]; then \
1685 define extract-and-include-host-whole-static-libs
1686 $(call extract-and-include-whole-static-libs-first, $(firstword $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIE…
1688 $(call _extract-and-include-single-host-whole-static-lib, $(lib),$(1)))
1694 define create-dummy.o-if-no-objs
1698 define get-dummy.o-if-no-objs
1702 define delete-dummy.o-if-no-objs
1704 && rm -f $(dir $(1))dummy.o)
1707 create-dummy.o-if-no-objs =
1708 get-dummy.o-if-no-objs =
1709 delete-dummy.o-if-no-objs =
1714 define transform-host-o-to-static-lib
1716 @mkdir -p $(dir $@)
1717 @rm -f $@ $@.tmp
1718 $(call extract-and-include-host-whole-static-libs,$@.tmp)
1719 $(call create-dummy.o-if-no-objs,$@.tmp)
1720 $(call split-long-arguments,$($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)AR) \
1722 $(PRIVATE_ALL_OBJECTS) $(call get-dummy.o-if-no-objs,$@.tmp))
1723 $(call delete-dummy.o-if-no-objs,$@.tmp)
1724 $(hide) mv -f $@.tmp $@
1733 # it to be overriden en-masse see combo/linux-arm.make for an example.
1735 define transform-host-o-to-shared-lib-inner
1737-Wl,-rpath,\$$ORIGIN/../$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)OUT_SHARED_LIBRA…
1738-Wl,-rpath,\$$ORIGIN/$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)OUT_SHARED_LIBRARIE…
1739 -shared -Wl,-soname,$(notdir $@) \
1745 -Wl,--whole-archive \
1747 -Wl,--no-whole-archive \
1748 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
1750 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
1753 -o $@ \
1758 define transform-host-o-to-shared-lib
1760 @mkdir -p $(dir $@)
1761 $(transform-host-o-to-shared-lib-inner)
1764 define transform-host-o-to-package
1766 @mkdir -p $(dir $@)
1767 $(transform-host-o-to-shared-lib-inner)
1775 define transform-o-to-shared-lib-inner
1777 -nostdlib -Wl,-soname,$(notdir $@) \
1778 -Wl,--gc-sections \
1779 -shared \
1782 -Wl,--whole-archive \
1784 -Wl,--no-whole-archive \
1785 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
1787 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
1793 -o $@ \
1798 define transform-o-to-shared-lib
1800 @mkdir -p $(dir $@)
1801 $(transform-o-to-shared-lib-inner)
1808 define transform-o-to-executable-inner
1809 $(hide) $(PRIVATE_CXX_LINK) -pie \
1810 -nostdlib -Bdynamic \
1811 -Wl,-dynamic-linker,$(PRIVATE_LINKER) \
1812 -Wl,--gc-sections \
1813 -Wl,-z,nocopyreloc \
1816 -Wl,--whole-archive \
1818 -Wl,--no-whole-archive \
1819 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
1821 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
1827 -o $@ \
1832 define transform-o-to-executable
1834 @mkdir -p $(dir $@)
1835 $(transform-o-to-executable-inner)
1842 ## have transform-o-to-static-executable defined.
1843 ## Clang driver needs -static to create static executable.
1844 ## However, bionic/linker uses -shared to overwrite.
1845 ## Linker for x86 targets does not allow coexistance of -static and -shared,
1846 ## so we add -static only if -shared is not used.
1849 define transform-o-to-static-executable-inner
1851 -nostdlib -Bstatic \
1852 $(if $(filter $(PRIVATE_LDFLAGS),-shared),,-static) \
1853 -Wl,--gc-sections \
1854 -o $@ \
1859 -Wl,--whole-archive \
1861 -Wl,--no-whole-archive \
1862 …$(filter-out %libcompiler_rt.hwasan.a %libc_nomalloc.hwasan.a %libc.hwasan.a %libcompiler_rt.a %li…
1863 -Wl,--start-group \
1869 -Wl,--end-group \
1873 define transform-o-to-static-executable
1875 @mkdir -p $(dir $@)
1876 $(transform-o-to-static-executable-inner)
1885 define transform-host-o-to-executable-inner
1888 -Wl,--whole-archive \
1890 -Wl,--no-whole-archive \
1891 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
1893 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
1897 -Wl,-rpath,\$$ORIGIN/$(path)) \
1902 -o $@ \
1907 define transform-host-o-to-executable
1909 @mkdir -p $(dir $@)
1910 $(transform-host-o-to-executable-inner)
1916 define package-coverage-files
1917 @rm -f $@ $@.lst $@.premerged
1920 $(hide) $(SOONG_ZIP) -o $@.premerged -C $(OUT_DIR) -l $@.lst
1921 …$(hide) $(MERGE_ZIPS) -ignore-duplicates $@ $@.premerged $(strip $(PRIVATE_ALL_WHOLE_STATIC_LIBRAR…
1933 define find-generated-R.java
1935 -name Manifest.java 2> /dev/null`; do \
1937 mkdir -p $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \
1941 -name R.java 2> /dev/null`; do \
1943 mkdir -p $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \
1949 @# enter the GENERATED_R_FILE-loop above. This avoids unnecessary rebuilding.
1956 define aapt2-compile-one-resource-file
1957 @mkdir -p $(dir $@)
1958 $(hide) $(AAPT2) compile -o $(dir $@) $(PRIVATE_AAPT2_CFLAGS) $<
1961 define aapt2-compile-resource-dirs
1962 @mkdir -p $(dir $@)
1963 $(hide) $(AAPT2) compile -o $@ $(addprefix --dir ,$(PRIVATE_SOURCE_RES_DIRS)) \
1967 # TODO(b/74574557): use aapt2 compile --zip if it gets implemented
1968 define aapt2-compile-resource-zips
1969 @mkdir -p $(dir $@)
1970 $(ZIPSYNC) -d $@.contents -l $@.list $(PRIVATE_SOURCE_RES_ZIPS)
1971 $(hide) $(AAPT2) compile -o $@ --dir $@.contents $(PRIVATE_AAPT2_CFLAGS)
1978 define aapt2-compile-one-resource-file-rule
1980 @echo "AAPT2 compile $$@ <- $$<"
1981 $$(call aapt2-compile-one-resource-file)
1985 # values-[config]/<file>.xml -> values-[config]_<file>.arsc.flat;
1992 define aapt2-compiled-resource-out-file
1994 $(eval _p_w := $(strip $(subst /,$(space),$(dir $(call clean-path,$(1))))))
1998 define aapt2-link
1999 @mkdir -p $(dir $@)
2000 rm -rf $(PRIVATE_JAVA_GEN_DIR)
2001 mkdir -p $(PRIVATE_JAVA_GEN_DIR)
2002 $(call dump-words-to-file,$(PRIVATE_RES_FLAT),$(dir $@)aapt2-flat-list)
2003 $(call dump-words-to-file,$(PRIVATE_OVERLAY_FLAT),$(dir $@)aapt2-flat-overlay-list)
2004 $(hide) $(AAPT2) link -o $@ \
2007 $(addprefix --manifest ,$(PRIVATE_ANDROID_MANIFEST)) \
2008 $(addprefix -I ,$(PRIVATE_AAPT_INCLUDES)) \
2009 $(addprefix -I ,$(PRIVATE_SHARED_ANDROID_LIBRARIES)) \
2010 $(addprefix -A ,$(foreach d,$(PRIVATE_ASSET_DIR),$(call clean-path,$(d)))) \
2011 $(addprefix --java ,$(PRIVATE_JAVA_GEN_DIR)) \
2012 $(addprefix --proguard ,$(PRIVATE_PROGUARD_OPTIONS_FILE)) \
2013 $(addprefix --min-sdk-version ,$(PRIVATE_DEFAULT_APP_TARGET_SDK)) \
2014 $(addprefix --target-sdk-version ,$(PRIVATE_DEFAULT_APP_TARGET_SDK)) \
2015 …$(if $(filter --product,$(PRIVATE_AAPT_FLAGS)),,$(addprefix --product ,$(PRIVATE_TARGET_AAPT_CHARA…
2016 $(addprefix -c ,$(PRIVATE_PRODUCT_AAPT_CONFIG)) \
2017 $(addprefix --preferred-density ,$(PRIVATE_PRODUCT_AAPT_PREF_CONFIG)) \
2018 $(if $(filter --version-code,$(PRIVATE_AAPT_FLAGS)),,--version-code $(PLATFORM_SDK_VERSION)) \
2019 …$(if $(filter --version-name,$(PRIVATE_AAPT_FLAGS)),,--version-name $(APPS_DEFAULT_VERSION_NAME)) \
2020 $(addprefix --rename-manifest-package ,$(PRIVATE_MANIFEST_PACKAGE_NAME)) \
2021 $(addprefix --rename-instrumentation-target-package ,$(PRIVATE_MANIFEST_INSTRUMENTATION_FOR)) \
2022 -R \@$(dir $@)aapt2-flat-overlay-list \
2023 \@$(dir $@)aapt2-flat-list
2024 $(SOONG_ZIP) -o $(PRIVATE_SRCJAR) -C $(PRIVATE_JAVA_GEN_DIR) -D $(PRIVATE_JAVA_GEN_DIR)
2025 $(EXTRACT_JAR_PACKAGES) -i $(PRIVATE_SRCJAR) -o $(PRIVATE_AAPT_EXTRA_PACKAGES) --prefix '--extra-pa…
2028 define _create-default-manifest-file
2030 rm -f $1
2032 echo ' <uses-sdk android:minSdkVersion="$(2)" />' && \
2036 define create-default-manifest-file
2037 $(eval $(call _create-default-manifest-file,$(1),$(2)))
2042 xlint_unchecked := -Xlint:unchecked
2044 # emit-line, <word list>, <output file>
2045 define emit-line
2046 $(if $(1),echo -n '$(strip $(1)) ' >> $(2))
2049 # dump-words-to-file, <word list>, <output file>
2050 define dump-words-to-file
2051 @rm -f $(2)
2053 @$(call emit-line,$(wordlist 1,500,$(1)),$(2))
2054 @$(call emit-line,$(wordlist 501,1000,$(1)),$(2))
2055 @$(call emit-line,$(wordlist 1001,1500,$(1)),$(2))
2056 @$(call emit-line,$(wordlist 1501,2000,$(1)),$(2))
2057 @$(call emit-line,$(wordlist 2001,2500,$(1)),$(2))
2058 @$(call emit-line,$(wordlist 2501,3000,$(1)),$(2))
2059 @$(call emit-line,$(wordlist 3001,3500,$(1)),$(2))
2060 @$(call emit-line,$(wordlist 3501,4000,$(1)),$(2))
2061 @$(call emit-line,$(wordlist 4001,4500,$(1)),$(2))
2062 @$(call emit-line,$(wordlist 4501,5000,$(1)),$(2))
2063 @$(call emit-line,$(wordlist 5001,5500,$(1)),$(2))
2064 @$(call emit-line,$(wordlist 5501,6000,$(1)),$(2))
2065 @$(call emit-line,$(wordlist 6001,6500,$(1)),$(2))
2066 @$(call emit-line,$(wordlist 6501,7000,$(1)),$(2))
2067 @$(call emit-line,$(wordlist 7001,7500,$(1)),$(2))
2068 @$(call emit-line,$(wordlist 7501,8000,$(1)),$(2))
2069 @$(call emit-line,$(wordlist 8001,8500,$(1)),$(2))
2070 @$(call emit-line,$(wordlist 8501,9000,$(1)),$(2))
2071 @$(call emit-line,$(wordlist 9001,9500,$(1)),$(2))
2072 @$(call emit-line,$(wordlist 9501,10000,$(1)),$(2))
2073 @$(call emit-line,$(wordlist 10001,10500,$(1)),$(2))
2074 @$(call emit-line,$(wordlist 10501,11000,$(1)),$(2))
2075 @$(call emit-line,$(wordlist 11001,11500,$(1)),$(2))
2076 @$(call emit-line,$(wordlist 11501,12000,$(1)),$(2))
2077 @$(call emit-line,$(wordlist 12001,12500,$(1)),$(2))
2078 @$(call emit-line,$(wordlist 12501,13000,$(1)),$(2))
2079 @$(call emit-line,$(wordlist 13001,13500,$(1)),$(2))
2085 # Returns an @-file argument that contains the output of a subshell
2086 # that looks like -C $(1) path/to/file1 -C $(1) path/to/file2
2087 # Also adds "-C out/empty ." which avoids errors in jar when
2089 define jar-args-sorted-files-in-directory
2090 @<(find $(1) -type f | sort | $(JAR_ARGS) $(1); echo "-C $(EMPTY_DIRECTORY) .")
2094 define fetch-additional-java-source
2095 $(hide) if [ -d "$(PRIVATE_SOURCE_INTERMEDIATES_DIR)" ]; then \
2096 find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name '*.java' -and -not -name '.*' >> $(1); \
2101 # - below we write the list of java files to java-source-list to avoid argument
2103 # - we filter out duplicate java file names because eclipse's compiler
2105 define write-java-source-list
2107 $(hide) rm -f $@
2108 $(call dump-words-to-file,$(sort $(PRIVATE_JAVA_SOURCES)),$@.tmp)
2109 $(call fetch-additional-java-source,$@.tmp)
2110 $(hide) tr ' ' '\n' < $@.tmp | $(NORMALIZE_PATH) | sort -u > $@
2117 define compile-java
2118 $(hide) rm -f $@
2119 $(hide) rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) $(PRIVATE_ANNO_INTERMEDIATES_DIR)
2120 $(hide) mkdir -p $(dir $@)
2121 $(hide) mkdir -p $(PRIVATE_CLASS_INTERMEDIATES_DIR) $(PRIVATE_ANNO_INTERMEDIATES_DIR)
2123 …$(ZIPSYNC) -d $(PRIVATE_SRCJAR_INTERMEDIATES_DIR) -l $(PRIVATE_SRCJAR_LIST_FILE) -f "*.java" $(PRI…
2124 $(hide) if [ -s $(PRIVATE_JAVA_SOURCE_LIST) $(if $(PRIVATE_SRCJARS),-o -s $(PRIVATE_SRCJAR_LIST_FIL…
2125 $(SOONG_JAVAC_WRAPPER) $(JAVAC_WRAPPER) $(1) -encoding UTF-8 \
2128 $(addprefix --system=,$(PRIVATE_SYSTEM_MODULES_DIR)), \
2129 $(addprefix -bootclasspath ,$(strip \
2130 $(call normalize-path-list,$(PRIVATE_BOOTCLASSPATH)) \
2134 --patch-module=$(PRIVATE_PATCH_MODULE)=$(call normalize-path-list,. $(2)))) \
2135 $(addprefix -classpath ,$(call normalize-path-list,$(strip \
2137 $(filter-out $(PRIVATE_SYSTEM_MODULES_LIBS),$(PRIVATE_BOOTCLASSPATH))) \
2140 -d $(PRIVATE_CLASS_INTERMEDIATES_DIR) -s $(PRIVATE_ANNO_INTERMEDIATES_DIR) \
2144 || ( rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) ; exit 41 ) \
2146 $(if $(PRIVATE_JAVA_LAYERS_FILE), $(hide) build/make/tools/java-layers.py \
2149 -name $(word 1, $(PRIVATE_JAR_EXCLUDE_FILES)) \
2150 $(addprefix -o -name , $(wordlist 2, 999, $(PRIVATE_JAR_EXCLUDE_FILES))) \
2151 | xargs rm -rf)
2153 $(hide) find $(PRIVATE_CLASS_INTERMEDIATES_DIR) -mindepth 1 -type f \
2155 -not -path $(PRIVATE_CLASS_INTERMEDIATES_DIR)/$(subst .,/,$(pkg))/\*) -delete ; \
2156 find $(PRIVATE_CLASS_INTERMEDIATES_DIR) -empty -delete)
2157 $(if $(PRIVATE_JAR_EXCLUDE_PACKAGES), $(hide) rm -rf \
2160 $(hide) $(SOONG_ZIP) -jar -o $@ -C $(PRIVATE_CLASS_INTERMEDIATES_DIR) -D $(PRIVATE_CLASS_INTERMEDIA…
2161 $(if $(PRIVATE_EXTRA_JAR_ARGS),$(call add-java-resources-to,$@))
2164 define transform-java-to-header.jar
2166 @mkdir -p $(dir $@)
2167 @rm -rf $(dir $@)/classes-turbine
2168 @mkdir $(dir $@)/classes-turbine
2169 $(hide) if [ -s $(PRIVATE_JAVA_SOURCE_LIST) -o -n "$(PRIVATE_SRCJARS)" ] ; then \
2170 $(JAVA) -jar $(TURBINE) \
2171 --output $@.premerged --temp_dir $(dir $@)/classes-turbine \
2172 --sources \@$(PRIVATE_JAVA_SOURCE_LIST) --source_jars $(PRIVATE_SRCJARS) \
2173 --javacopts $(PRIVATE_JAVACFLAGS) $(COMMON_JDK_FLAGS) -- \
2175 --system $(PRIVATE_SYSTEM_MODULES_DIR), \
2176 --bootclasspath $(strip $(PRIVATE_BOOTCLASSPATH))) \
2177 --classpath $(strip $(if $(PRIVATE_USE_SYSTEM_MODULES), \
2178 $(filter-out $(PRIVATE_SYSTEM_MODULES_LIBS),$(PRIVATE_BOOTCLASSPATH))) \
2180 || ( rm -rf $(dir $@)/classes-turbine ; exit 41 ) && \
2181 …$(MERGE_ZIPS) -j --ignore-duplicates -stripDir META-INF $@.tmp $@.premerged $(PRIVATE_STATIC_JAVA_…
2183 …$(MERGE_ZIPS) -j --ignore-duplicates -stripDir META-INF $@.tmp $(PRIVATE_STATIC_JAVA_HEADER_LIBRAR…
2186 $(hide) $(call commit-change-for-toc,$@)
2193 define transform-jarjar
2195 rm -f $@
2196 $(JAVA) -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@
2197 [ -e $@ ] || (echo "Missing output file"; exit 1)
2202 # of $1 when $1.tmp is identical to $1 so that ninja won't rebuild
2204 define commit-change-for-toc
2205 $(hide) if cmp -s $1.tmp $1 ; then \
2217 define _transform-dex-to-toc
2221 $(hide) ANDROID_LOG_TAGS="*:e" $(DEXDUMP) -l xml $$(PRIVATE_INPUT_DEX_FILES) > $$@.tmp
2222 $$(call commit-change-for-toc,$$@)
2227 define define-dex-to-toc-rule
2228 $(eval $(call _transform-dex-to-toc,$1))\
2235 define define-dex-to-toc-rule
2244 define codename-or-sdk-to-sdk
2250 define module-sdk-version
2252 $(if $(filter-out current system_current test_current core_current,$(LOCAL_SDK_VERSION)), \
2253 $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION)), \
2259 define module-target-sdk-version
2261 $(if $(filter-out current system_current test_current core_current,$(LOCAL_SDK_VERSION)), \
2262 $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION)), \
2268 define module-min-sdk-version
2269 $(if $(LOCAL_MIN_SDK_VERSION),$(LOCAL_MIN_SDK_VERSION),$(call module-target-sdk-version))
2273 define transform-classes.jar-to-dex
2275 @mkdir -p $(dir $@)tmp
2276 $(hide) rm -f $(dir $@)classes*.dex $(dir $@)d8_input.jar
2277 $(hide) $(ZIP2ZIP) -j -i $< -o $(dir $@)d8_input.jar "**/*.class"
2279 --output $(dir $@)tmp \
2280 $(addprefix --lib ,$(PRIVATE_D8_LIBS)) \
2281 --min-api $(PRIVATE_MIN_SDK_VERSION) \
2282 $(subst --main-dex-list=, --main-dex-list , \
2283 $(filter-out --core-library --multi-dex --minimal-main-dex,$(PRIVATE_DX_FLAGS))) \
2286 $(hide) rm -f $(dir $@)d8_input.jar
2287 $(hide) rm -rf $(dir $@)tmp
2294 define _add-jni-shared-libs-to-package-per-abi
2301 define create-jni-shared-libs-package
2302 rm -rf $(dir $(1))lib
2303 mkdir -p $(addprefix $(dir $(1))lib/,$(PRIVATE_JNI_SHARED_LIBRARIES_ABI))
2305 $(call _add-jni-shared-libs-to-package-per-abi,$(1),$(abi),\
2307 $(SOONG_ZIP) $(if $(2),-L 0) -o $(1) -C $(dir $(1)) -D $(dir $(1))lib
2308 rm -rf $(dir $(1))lib
2313 define create-dex-jar
2314 find $(dir $(2)) -maxdepth 1 -name "classes*.dex" | sort > $(1).lst
2315 $(SOONG_ZIP) -o $(1) -C $(dir $(2)) -l $(1).lst
2320 define add-java-resources-to
2321 $(call _java-resources,$(1),u)
2326 define create-java-resources-jar
2327 $(call _java-resources,$(1),c)
2330 define _java-resources
2331 $(call dump-words-to-file, $(PRIVATE_EXTRA_JAR_ARGS), $(1).jar-arg-list)
2332 $(hide) $(JAR) $(2)f $(1) @$(1).jar-arg-list
2333 @rm -f $(1).jar-arg-list
2340 define add-jar-resources-to-package
2341 rm -rf $(3)
2342 mkdir -p $(3)
2343 unzip -qo $(2) -d $(3) $$(zipinfo -1 $(2) | grep -v -E "\.class$$")
2344 $(JAR) uf $(1) $(call jar-args-sorted-files-in-directory,$(3))
2349 define extract-resources-jar
2350 $(ZIP2ZIP) -i $(2) -o $(1) -x '**/*.class' -x '**/*/'
2355 define sign-package
2356 $(call sign-package-arg,$@)
2360 define sign-package-arg
2362 $(hide) $(JAVA) -Djava.library.path=$$(dirname $(SIGNAPK_JNI_LIBRARY_PATH)) -jar $(SIGNAPK_JAR) \
2363 $(if $(strip $(PRIVATE_CERTIFICATE_LINEAGE)), --lineage $(PRIVATE_CERTIFICATE_LINEAGE)) \
2369 # Align STORED entries of a package on 4-byte boundaries to make them easier to mmap.
2371 define align-package
2372 $(hide) if ! $(ZIPALIGN) -c -p 4 $@ >/dev/null ; then \
2375 -f \
2376 -p \
2385 define check-package-alignment
2386 $(hide) if ! $(ZIPALIGN) -c -p 4 $@ >/dev/null ; then \
2387 $(call echo-error,$@,Improper package alignment); \
2393 define compress-package
2396 $(MINIGZIP) -c $@.uncompressed > $@.compressed; \
2397 rm -f $@.uncompressed; \
2401 ifeq ($(HOST_OS),linux)
2403 define extract-package
2404 $(AAPT2) dump resources $@ | awk -F ' |=' '/^Package/{print $$3}' >> $(PRODUCT_OUT)/appcompat/$(PRI…
2406 define appcompat-header
2408 mkdir -p $(PRODUCT_OUT)/appcompat && \
2409 rm -f $(PRODUCT_OUT)/appcompat/$(PRIVATE_MODULE).log && \
2410 echo -n "Package name: " >> $(PRODUCT_OUT)/appcompat/$(PRIVATE_MODULE).log && \
2411 $(extract-package) \
2414 …echo "Install path on $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT): $(PRIVATE_INSTALLED_MODULE)" >> $…
2418 define run-appcompat
2421 …/PACKAGING ANDROID_LOG_TAGS="*:e" $(ART_VERIDEX_APPCOMPAT_SCRIPT) --dex-file=$@ --api-flags=$(INTE…
2423 appcompat-files = \
2431 appcompat-header =
2432 run-appcompat =
2433 appcompat-files =
2434 endif # HOST_OS == linux
2435 .KATI_READONLY: appcompat-header run-appcompat appcompat-files
2439 define remove-timestamps-from-package
2445 define uncompress-dexs
2446 if (zipinfo $@ '*.dex' 2>/dev/null | grep -v ' stor ' >/dev/null) ; then \
2447 $(ZIP2ZIP) -i $@ -o $@.tmp -0 "classes*.dex" && \
2448 mv -f $@.tmp $@ ; \
2454 define uncompress-prebuilt-embedded-jni-libs
2455 if (zipinfo $@ 'lib/*.so' 2>/dev/null | grep -v ' stor ' >/dev/null) ; then \
2456 $(ZIP2ZIP) -i $@ -o $@.tmp -0 'lib/**/*.so' && mv -f $@.tmp $@ ; \
2462 define check-jni-dex-compression
2463 if (zipinfo $@ 'lib/*.so' '*.dex' 2>/dev/null | grep -v ' stor ' >/dev/null) ; then \
2464 $(call echo-error,$@,Contains compressed JNI libraries and/or dex files); \
2471 define remove-unwanted-prebuilt-embedded-jni-libs
2473 $(ZIP2ZIP) -i $@ -o $@.tmp \
2474 -x 'lib/**/*.so' $(addprefix -X ,$(PRIVATE_EMBEDDED_JNI_LIBS)) && \
2475 mv -f $@.tmp $@)
2483 # in transform-java-to-classes for the sake of vm-tests.
2484 define transform-host-java-to-package
2486 $(call compile-java,$(HOST_JAVAC),$(PRIVATE_ALL_JAVA_LIBRARIES))
2490 # in transform-java-to-classes for the sake of vm-tests.
2491 define transform-host-java-to-dalvik-package
2493 $(call compile-java,$(HOST_JAVAC),$(PRIVATE_ALL_JAVA_HEADER_LIBRARIES))
2503 define copy-one-header
2506 $$(copy-file-to-new-target-with-cp)
2512 define copy-one-file
2515 $$(copy-file-to-target)
2518 define copy-and-uncompress-dexs
2521 $$(copy-file-to-target)
2522 $$(uncompress-dexs)
2523 $$(align-package)
2531 define compat-copy-pair
2532 $(if $(filter-out $(2), $(LOCAL_INSTALLED_MODULE)), $(1):$(2))
2539 # $(3): filter-out target
2541 define filter-copy-pair
2549 define copy-many-files
2556 $(if $(filter-out $(_cmf_src), $(_cmf_dest)), \
2557 $(eval $(call copy-one-file,$(_cmf_src),$(_cmf_dest)))) \
2561 # Copy the file only if it's a well-formed init script file. For use via $(eval).
2564 define copy-init-script-file-checked
2574 $(call intermediates-dir-for,ETC,passwd_system)/passwd_system \
2575 $(call intermediates-dir-for,ETC,passwd_system_ext)/passwd_system_ext \
2576 $(call intermediates-dir-for,ETC,passwd_vendor)/passwd_vendor \
2577 $(call intermediates-dir-for,ETC,passwd_odm)/passwd_odm \
2578 $(call intermediates-dir-for,ETC,passwd_product)/passwd_product \
2579 $(call intermediates-dir-for,ETC,plat_property_contexts)/plat_property_contexts \
2580 $(call intermediates-dir-for,ETC,system_ext_property_contexts)/system_ext_property_contexts \
2581 $(call intermediates-dir-for,ETC,product_property_contexts)/product_property_contexts \
2582 $(call intermediates-dir-for,ETC,vendor_property_contexts)/vendor_property_contexts \
2583 $(call intermediates-dir-for,ETC,odm_property_contexts)/odm_property_contexts
2585 -p $(call intermediates-dir-for,ETC,passwd_system)/passwd_system \
2586 -p $(call intermediates-dir-for,ETC,passwd_system_ext)/passwd_system_ext \
2587 -p $(call intermediates-dir-for,ETC,passwd_vendor)/passwd_vendor \
2588 -p $(call intermediates-dir-for,ETC,passwd_odm)/passwd_odm \
2589 -p $(call intermediates-dir-for,ETC,passwd_product)/passwd_product \
2590--property-contexts=$(call intermediates-dir-for,ETC,plat_property_contexts)/plat_property_context…
2591--property-contexts=$(call intermediates-dir-for,ETC,system_ext_property_contexts)/system_ext_prop…
2592--property-contexts=$(call intermediates-dir-for,ETC,product_property_contexts)/product_property_c…
2593--property-contexts=$(call intermediates-dir-for,ETC,vendor_property_contexts)/vendor_property_con…
2594--property-contexts=$(call intermediates-dir-for,ETC,odm_property_contexts)/odm_property_contexts \
2600 $$(copy-file-to-target)
2603 # Copies many init script files and check they are well-formed.
2606 define copy-many-init-script-files-checked
2611 $(eval $(call copy-init-script-file-checked,$(_cmf_src),$(_cmf_dest))) \
2615 # Copy the file only if it's a well-formed xml file. For use via $(eval).
2618 define copy-xml-file-checked
2622 $$(copy-file-to-target)
2625 # Copies many xml files and check they are well-formed.
2628 define copy-many-xml-files-checked
2633 $(eval $(call copy-xml-file-checked,$(_cmf_src),$(_cmf_dest))) \
2637 # Copy the file only if it is a well-formed manifest file. For use viea $(eval)
2640 define copy-vintf-manifest-checked
2643 …$(hide) $(HOST_OUT_EXECUTABLES)/assemble_vintf -i $$< >/dev/null # Don't print the xml file to st…
2644 $$(copy-file-to-target)
2650 define copy-many-vintf-manifest-files-checked
2655 $(eval $(call copy-vintf-manifest-checked,$(_cmf_src),$(_cmf_dest))) \
2663 define copy-non-elf-file-checked
2665 $(call intermediates-dir-for,FAKE,check-non-elf-file-timestamps)/$(2).timestamp)
2667 @echo "Check non-ELF: $$<"
2668 $(hide) mkdir -p "$$(dir $$@)"
2669 $(hide) rm -f "$$@"
2671 if $(LLVM_READOBJ) -h "$$<" >/dev/null 2>&1; then \
2672 $(call echo-error,$(2),$(3)); \
2673 $(call echo-error,$(2),found ELF file: $$<); \
2679 @echo "Copy non-ELF: $$@"
2680 $$(copy-file-to-target)
2682 check-elf-prebuilt-product-copy-files: $(check_non_elf_file_timestamp)
2685 # The -t option to acp and the -p option to cp is
2695 # on file systems like ext4. Because of that, '-t' option was disabled
2696 # and copy-file-to-target was identical to copy-file-to-new-target.
2699 define copy-file-to-target
2700 @mkdir -p $(dir $@)
2701 $(hide) rm -f $@
2705 # The same as copy-file-to-target, but use the local
2707 define copy-file-to-target-with-cp
2708 @mkdir -p $(dir $@)
2709 $(hide) rm -f $@
2710 $(hide) cp -p "$<" "$@"
2713 # The same as copy-file-to-target, but strip out "# comment"-style
2715 define copy-file-to-target-strip-comments
2716 @mkdir -p $(dir $@)
2717 $(hide) rm -f $@
2718 $(hide) sed -e 's/#.*$$//' -e 's/[ \t]*$$//' -e '/^$$/d' < $< > $@
2721 # The same as copy-file-to-target, but don't preserve
2723 define copy-file-to-new-target
2724 @mkdir -p $(dir $@)
2725 $(hide) rm -f $@
2729 # The same as copy-file-to-new-target, but use the local
2731 define copy-file-to-new-target-with-cp
2732 @mkdir -p $(dir $@)
2733 $(hide) rm -f $@
2737 # The same as copy-file-to-new-target, but preserve symlinks. Symlinks are
2739 define copy-file-or-link-to-new-target
2740 @mkdir -p $(dir $@)
2741 $(hide) rm -f $@
2742 $(hide) if [ -h $< ]; then \
2743 ln -s $$(realpath $<) $@; \
2750 define transform-prebuilt-to-target
2752 $(copy-file-to-target)
2756 define transform-prebuilt-to-target-strip-comments
2758 $(copy-file-to-target-strip-comments)
2763 define copy-or-link-prebuilt-to-target
2765 $(copy-file-or-link-to-new-target)
2769 # For example $(HOST_OUT_EXECUTABLES)/aapt -> $(staging)/bin/aapt .
2773 define copy-files-with-structure
2776 $(hide) mkdir -p $(dir $(3)/$(s)); cp -Rf $(t) $(3)/$(s)$(newline))
2783 define symlink-file
2784 $(eval $(_symlink-file))
2787 define _symlink-file
2789 @echo "Symlink: $$@ -> $(2)"
2790 @mkdir -p $$(dir $$@)
2791 @rm -rf $$@
2792 $(hide) ln -sf $(2) $$@
2799 # $(3): LOCAL_STRIP_DEX, if non-empty then strip classes*.dex
2800 define dexpreopt-copy-jar
2803 $$(copy-file-to-target)
2804 $(if $(3),$$(call dexpreopt-remove-classes.dex,$$@))
2810 define dexpreopt-remove-classes.dex
2811 $(hide) if (zipinfo $1 '*.dex' 2>/dev/null | grep -v ' stor ' >/dev/null) ; then \
2812 zip --quiet --delete $(1) classes.dex; \
2814 while zip --quiet --delete $(1) classes$${dex_index}.dex > /dev/null; do \
2825 # Use --debug flag for eng builds by default
2827 R8_DEBUG_MODE := --debug
2832 define transform-jar-to-dex-r8
2834 $(hide) rm -f $(PRIVATE_PROGUARD_DICTIONARY)
2836 -injars '$<' \
2837 --min-api $(PRIVATE_MIN_SDK_VERSION) \
2838 --no-data-resources \
2839 --force-proguard-compatibility --output $(subst classes.dex,,$@) \
2842 $(addprefix -injars , $(PRIVATE_EXTRA_INPUT_JAR)) \
2844 -ignorewarnings
2849 ## Stuff source generated from one-off tools
2852 define transform-generated-source
2854 @mkdir -p $(dir $@)
2864 define get-file-size
2865 stat -c "%s" "$(1)" | tr -d '\n'
2870 define assert-max-image-size
2872 size=$$(for i in $(1); do $(call get-file-size,$$i); echo +; done; echo 0); \
2874 printname=$$(echo -n "$(1)" | tr " " +); \
2876 if [ "$$total" -gt "$$maxsize" ]; then \
2879 elif [ "$$total" -gt $$((maxsize - 32768)) ]; then \
2889 ## Define device-specific radio files
2896 define add-radio-file
2897 $(eval $(call add-radio-file-internal,$(1),$(notdir $(1))))
2899 define add-radio-file-internal
2902 $$(transform-prebuilt-to-target)
2905 # Version of add-radio-file that also arranges for the version of the
2909 # $(2): name of version variable in board-info (eg, "version-baseband")
2910 define add-radio-file-checked
2911 $(eval $(call add-radio-file-checked-internal,$(1),$(notdir $(1)),$(2)))
2913 define add-radio-file-checked-internal
2917 $$(transform-prebuilt-to-target)
2926 define if-build-from-source
2930 define if-build-from-source
2940 define include-if-build-from-source
2941 $(if $(call if-build-from-source,$(2),$(3)),$(eval include $(1)))
2949 define get-prebuilt-src-arch
2990 define record-module-type
2992 $(if $(filter-out $(SOONG_ANDROID_MK),$(LOCAL_MODULE_MAKEFILE)),
3015 # And for test config files, we'll check the .xml is well-formed before copy.
3022 define create-suite-dependencies
3029 $$(foreach f,$$(my_compat_dist_$(suite)),$$(call word-colon,2,$$(f))) \
3030 $$(foreach f,$$(my_compat_dist_config_$(suite)),$$(call word-colon,2,$$(f))) \
3036 $(foreach f,$(my_compat_dist_$(suite)), $(call word-colon,2,$(f))))) \
3037 $(call copy-many-xml-files-checked, \
3048 define _clean-path-strip-dotdot
3053 $(word 1,$(1)) $(call _clean-path-strip-dotdot,$(wordlist 2,$(words $(1)),$(1)))
3055 $(call _clean-path-strip-dotdot,$(wordlist 3,$(words $(1)),$(1)))
3058 $(word 1,$(1)) $(call _clean-path-strip-dotdot,$(wordlist 2,$(words $(1)),$(1)))
3070 define _clean-path-strip-root-dotdots
3072 $(call _clean-path-strip-root-dotdots,$(wordlist 2,$(words $(1)),$(1))),
3076 # Call _clean-path-strip-dotdot until the path stops changing
3077 # $(1): Non-empty if this path started with a /
3079 define _clean-path-expanded
3081 $(eval _ep := $(call _clean-path-strip-dotdot,$(2)))
3082 $(if $(1),$(eval _ep := $(call _clean-path-strip-root-dotdots,$(_ep))))
3085 $(call _clean-path-expanded,$(1),$(_ep))))
3088 # Clean the file path -- remove //, dir/.., extra .
3093 define clean-path
3097 $(eval _expanded_path := $(filter-out .,$(subst /,$(space),$(1))))
3098 …$(eval _path := $(if $(_rooted),/)$(subst $(space),/,$(call _clean-path-expanded,$(_rooted),$(_exp…
3106 $(error Call clean-path with only one path (without spaces))
3114 $(if $(call streq,$(call clean-path,$(1)),$(2)),,
3116 $(warning clean-path test '$(1)': expected '$(2)', got '$(call clean-path,$(1))'))
3172 $(error failed clean-path test)
3182 define try-validate-path-is-subdir
3187 $(if $(filter ../%,$(call clean-path,$(1))),
3197 define validate-path-is-subdir
3198 $(if $(call try-validate-path-is-subdir,$(1)),
3199 $(call pretty-error, Illegal path: $(call try-validate-path-is-subdir,$(1)))
3204 ## Given a space-delimited list of filepaths, returns
3209 define try-validate-paths-are-subdirs
3212 $(call try-validate-path-is-subdir,$(my_path))\
3217 define validate-paths-are-subdirs
3218 $(if $(call try-validate-paths-are-subdirs,$(1)),
3219 $(call pretty-error,Illegal paths:\'$(call try-validate-paths-are-subdirs,$(1))\')
3224 ## Tests of try-validate-path-is-subdir
3225 ## and try-validate-paths-are-subdirs
3226 define test-validate-paths-are-subdirs
3227 $(eval my_error := $(call try-validate-path-is-subdir,/tmp)) \
3232 $(eval my_error := $(call try-validate-path-is-subdir,../sibling)) \
3237 $(eval my_error := $(call try-validate-path-is-subdir,child/../../sibling)) \
3242 $(eval my_error := $(call try-validate-path-is-subdir,)) \
3247 $(eval my_error := $(call try-validate-path-is-subdir,subdir/subsubdir)) \
3253 $(eval my_error := $(call try-validate-paths-are-subdirs,a/b /c/d e/f))
3258 $(eval my_error := $(call try-validate-paths-are-subdirs,a/b c/d))
3265 $(strip $(call test-validate-paths-are-subdirs))
3270 ## Jacoco class filters are comma-separated lists of class
3274 define jacoco-class-filter-to-file-args
3275 $(strip $(call jacoco-validate-file-args,\
3281 define jacoco-validate-file-args
3283 $(call validate-paths-are-subdirs,$(1))
3285 $(if $(findstring ?,$(arg)),$(call pretty-error,\
3287 $(if $(findstring *,$(patsubst %*,%,$(arg))),$(call pretty-error,\
3297 -include $(TOPDIR)vendor/*/build/core/definitions.mk
3298 -include $(TOPDIR)device/*/build/core/definitions.mk
3299 -include $(TOPDIR)product/*/build/core/definitions.mk
3302 # $(foreach file,$^,$(if $(findstring,.a,$(suffix $file)),-l$(file),$(file)))
3316 # sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
3317 # -e '/^$$/ d' -e 's/$$/ :/' < $(df).d >> $(df).P; \
3318 # rm -f $(df).d
3319 # $(COMPILE.c) -o $@ $<
3321 #-include $(SRCS:%.c=$(DEPDIR)/%.P)
3325 # $(COMPILE.c) -MD -o $@ $<
3327 # sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
3328 # -e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $*.P; \
3329 # rm -f $*.d
3348 …$(strip $(1))||$(strip $(2))||$(strip $(3))||$(strip $(4))||$(call normalize-path-list, $(strip $(…
3376 define has-system-sdk-version
3377 $(filter-out system_server_%,$(filter system_%,$(1)))
3385 define get-numeric-sdk-version
3386 $(filter-out current,\
3387 $(if $(call has-system-sdk-version,$(1)),$(patsubst system_%,%,$(1)),$(1)))
3392 ## a-z A-Z 0-9
3393 ## _.+-,@~
3396 ## https://docs.bazel.build/versions/master/build-ref.html#name
3400 define verify-module-name
3401 $(if $(filter-out $(LOCAL_MODULE),$(subst /,,$(LOCAL_MODULE))), \
3402 …$(call pretty-warning,Module name contains a /$(comma) use LOCAL_MODULE_STEM and LOCAL_MODULE_RELA…
3403 $(if $(call _invalid-name-chars,$(LOCAL_MODULE)), \
3404 …$(call pretty-error,Invalid characters in module name: $(call _invalid-name-chars,$(LOCAL_MODULE))…
3406 define _invalid-name-chars
3407-,,$(subst $(comma),,$(subst @,,$(subst ~,,$(subst 0,,$(subst 1,,$(subst 2,,$(subst 3,,$(subst 4,,…
3409 .KATI_READONLY := verify-module-name _invalid-name-chars
3413 ## a-z A-Z 0-9
3414 ## _.+-,@~
3417 ## https://docs.bazel.build/versions/master/build-ref.html#name
3421 define verify-module-stem
3422 $(if $(filter-out $($(1)),$(subst /,,$($(1)))), \
3423 …$(call pretty-warning,Module stem \($(1)\) contains a /$(comma) use LOCAL_MODULE_RELATIVE_PATH ins…
3424 $(if $(call _invalid-name-chars,$($(1))), \
3425 …$(call pretty-error,Invalid characters in module stem \($(1)\): $(call _invalid-name-chars,$($(1))…
3427 .KATI_READONLY := verify-module-stem
3430 create-empty-package \
3431 initialize-package-file \
3432 add-jni-shared-libs-to-package \
3433 inherit-package,\
3444 define verify-vndk-libs-identical