2009-03-04 04:28:42 +01:00
|
|
|
#
|
|
|
|
# Copyright (C) 2008 The Android Open Source Project
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
#
|
|
|
|
|
|
|
|
##
|
|
|
|
## Common build system definitions. Mostly standard
|
|
|
|
## commands for building various types of targets, which
|
|
|
|
## are used by others to construct the final targets.
|
|
|
|
##
|
|
|
|
|
|
|
|
# These are variables we use to collect overall lists
|
|
|
|
# of things being processed.
|
|
|
|
|
|
|
|
# Full paths to all of the documentation
|
|
|
|
ALL_DOCS:=
|
|
|
|
|
|
|
|
# The short names of all of the targets in the system.
|
|
|
|
# For each element of ALL_MODULES, two other variables
|
|
|
|
# are defined:
|
|
|
|
# $(ALL_MODULES.$(target)).BUILT
|
|
|
|
# $(ALL_MODULES.$(target)).INSTALLED
|
|
|
|
# The BUILT variable contains LOCAL_BUILT_MODULE for that
|
|
|
|
# target, and the INSTALLED variable contains the LOCAL_INSTALLED_MODULE.
|
|
|
|
# Some targets may have multiple files listed in the BUILT and INSTALLED
|
|
|
|
# sub-variables.
|
|
|
|
ALL_MODULES:=
|
|
|
|
|
2021-04-15 19:41:38 +02:00
|
|
|
# The relative paths of the non-module targets in the system.
|
|
|
|
ALL_NON_MODULES:=
|
|
|
|
NON_MODULES_WITHOUT_LICENSE_METADATA:=
|
|
|
|
|
2022-05-28 04:40:41 +02:00
|
|
|
# List of copied targets that need license metadata copied.
|
|
|
|
ALL_COPIED_TARGETS:=
|
|
|
|
|
2009-03-04 04:28:42 +01:00
|
|
|
# Full paths to targets that should be added to the "make droid"
|
|
|
|
# set of installed targets.
|
|
|
|
ALL_DEFAULT_INSTALLED_MODULES:=
|
|
|
|
|
|
|
|
# The list of tags that have been defined by
|
|
|
|
# LOCAL_MODULE_TAGS. Each word in this variable maps
|
|
|
|
# to a corresponding ALL_MODULE_TAGS.<tagname> variable
|
|
|
|
# that contains all of the INSTALLED_MODULEs with that tag.
|
|
|
|
ALL_MODULE_TAGS:=
|
|
|
|
|
|
|
|
# Similar to ALL_MODULE_TAGS, but contains the short names
|
|
|
|
# of all targets for a particular tag. The top-level variable
|
|
|
|
# won't have the list of tags; ust ALL_MODULE_TAGS to get
|
|
|
|
# the list of all known tags. (This means that this variable
|
|
|
|
# will always be empty; it's just here as a placeholder for
|
|
|
|
# its sub-variables.)
|
|
|
|
ALL_MODULE_NAME_TAGS:=
|
|
|
|
|
|
|
|
# Full path to all asm, C, C++, lex and yacc generated C files.
|
|
|
|
# These all have an order-only dependency on the copied headers
|
|
|
|
ALL_C_CPP_ETC_OBJECTS:=
|
|
|
|
|
|
|
|
# These files go into the SDK
|
|
|
|
ALL_SDK_FILES:=
|
|
|
|
|
|
|
|
# Files for dalvik. This is often build without building the rest of the OS.
|
|
|
|
INTERNAL_DALVIK_MODULES:=
|
|
|
|
|
|
|
|
# All findbugs xml files
|
|
|
|
ALL_FINDBUGS_FILES:=
|
|
|
|
|
2011-12-12 21:57:38 +01:00
|
|
|
# GPL module license files
|
|
|
|
ALL_GPL_MODULE_LICENSE_FILES:=
|
|
|
|
|
2018-12-17 06:45:15 +01:00
|
|
|
# Packages with certificate violation
|
|
|
|
CERTIFICATE_VIOLATION_MODULES :=
|
|
|
|
|
2013-02-22 23:32:30 +01:00
|
|
|
# Target and host installed module's dependencies on shared libraries.
|
2013-04-16 02:32:21 +02:00
|
|
|
# They are list of "<module_name>:<installed_file>:lib1,lib2...".
|
2013-02-22 23:32:30 +01:00
|
|
|
TARGET_DEPENDENCIES_ON_SHARED_LIBRARIES :=
|
2014-05-20 23:43:51 +02:00
|
|
|
$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_DEPENDENCIES_ON_SHARED_LIBRARIES :=
|
2013-02-22 23:32:30 +01:00
|
|
|
HOST_DEPENDENCIES_ON_SHARED_LIBRARIES :=
|
2014-05-20 23:43:51 +02:00
|
|
|
$(HOST_2ND_ARCH_VAR_PREFIX)HOST_DEPENDENCIES_ON_SHARED_LIBRARIES :=
|
2015-08-14 21:59:50 +02:00
|
|
|
HOST_CROSS_DEPENDENCIES_ON_SHARED_LIBRARIES :=
|
2016-02-06 01:20:19 +01:00
|
|
|
$(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_DEPENDENCIES_ON_SHARED_LIBRARIES :=
|
2013-02-22 23:32:30 +01:00
|
|
|
|
2012-06-19 19:40:37 +02:00
|
|
|
# Generated class file names for Android resource.
|
|
|
|
# They are escaped and quoted so can be passed safely to a bash command.
|
|
|
|
ANDROID_RESOURCE_GENERATED_CLASSES := 'R.class' 'R$$*.class' 'Manifest.class' 'Manifest$$*.class'
|
|
|
|
|
2015-08-14 21:59:50 +02:00
|
|
|
# Display names for various build targets
|
|
|
|
TARGET_DISPLAY := target
|
|
|
|
HOST_DISPLAY := host
|
|
|
|
HOST_CROSS_DISPLAY := host cross
|
|
|
|
|
2016-07-28 07:52:42 +02:00
|
|
|
# All installed initrc files
|
|
|
|
ALL_INIT_RC_INSTALLED_PAIRS :=
|
|
|
|
|
2018-04-05 00:41:05 +02:00
|
|
|
# All installed vintf manifest fragments for a partition at
|
|
|
|
ALL_VINTF_MANIFEST_FRAGMENTS_LIST:=
|
|
|
|
|
2018-04-13 23:39:53 +02:00
|
|
|
# All tests that should be skipped in presubmit check.
|
|
|
|
ALL_DISABLED_PRESUBMIT_TESTS :=
|
|
|
|
|
2020-11-12 01:25:20 +01:00
|
|
|
# All compatibility suites mentioned in LOCAL_COMPATIBILITY_SUITE
|
Export list of "installable" files to soong_ui
These are a (partial) list of files that we'd install with a default
build. The idea is that if something is removed from this list, soong_ui
can remove it from the installed location before running ninja.
It's okay if there are things missing from this list, it's not intended
to be a 100% solution replacing installclean / CleanSpec.mk, just
something that handles 80% of the cases without user involvement.
In particular, if something is removed from PRODUCT_PACKAGES, we'll
remove it from disk, but not necessarily rebuild the image files. That's
the same as most use cases of CleanSpec.mk today, and often some other
change will trigger the necessary images to be rebuilt.
We should be able to fix that by changing all of the image creation
rules to depend on the (partial) list of files they care about, or by
fixing ninja to rebuild things when their list of dependencies change.
(Other tools run into this same problem)
The list of test files is also included so that we can remove obsolete
tests from their "installed" locations within test suites and the
testcases folders.
Test: remove a module from PRODUCT_PACKAGES, see the print and file removed
Test: change the name of a cts test, see the old one removed from cts
Change-Id: I67f270a6713369099ca523aaf991ee3beb815c0a
2020-01-03 22:26:36 +01:00
|
|
|
ALL_COMPATIBILITY_SUITES :=
|
|
|
|
|
2020-08-27 00:27:26 +02:00
|
|
|
# All compatibility suite files to dist.
|
|
|
|
ALL_COMPATIBILITY_DIST_FILES :=
|
|
|
|
|
2020-06-09 03:50:14 +02:00
|
|
|
# All LINK_TYPE entries
|
|
|
|
ALL_LINK_TYPES :=
|
|
|
|
|
|
|
|
# All exported/imported include entries
|
|
|
|
EXPORTS_LIST :=
|
|
|
|
|
|
|
|
# All modules already converted to Soong
|
|
|
|
SOONG_ALREADY_CONV :=
|
|
|
|
|
2020-06-09 06:00:18 +02:00
|
|
|
# ALL_DEPS.*.ALL_DEPS keys
|
|
|
|
ALL_DEPS.MODULES :=
|
|
|
|
|
2009-03-04 04:28:42 +01:00
|
|
|
###########################################################
|
|
|
|
## Debugging; prints a variable list to stdout
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
# $(1): variable name list, not variable values
|
|
|
|
define print-vars
|
|
|
|
$(foreach var,$(1), \
|
|
|
|
$(info $(var):) \
|
|
|
|
$(foreach word,$($(var)), \
|
|
|
|
$(info $(space)$(space)$(word)) \
|
|
|
|
) \
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2009-04-10 04:31:12 +02:00
|
|
|
###########################################################
|
|
|
|
## Evaluates to true if the string contains the word true,
|
|
|
|
## and empty otherwise
|
|
|
|
## $(1): a var to test
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define true-or-empty
|
|
|
|
$(filter true, $(1))
|
|
|
|
endef
|
|
|
|
|
2016-09-12 22:56:50 +02:00
|
|
|
###########################################################
|
|
|
|
## Rule for touching GCNO files.
|
|
|
|
###########################################################
|
|
|
|
define gcno-touch-rule
|
|
|
|
$(2): $(1)
|
|
|
|
touch -c $$@
|
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
2009-04-10 04:31:12 +02:00
|
|
|
|
2009-03-04 04:28:42 +01:00
|
|
|
###########################################################
|
|
|
|
## Retrieve the directory of the current makefile
|
2014-03-02 00:32:04 +01:00
|
|
|
## Must be called before including any other makefile!!
|
2009-03-04 04:28:42 +01:00
|
|
|
###########################################################
|
|
|
|
|
|
|
|
# Figure out where we are.
|
|
|
|
define my-dir
|
2009-05-20 01:12:22 +02:00
|
|
|
$(strip \
|
2012-04-24 06:29:18 +02:00
|
|
|
$(eval LOCAL_MODULE_MAKEFILE := $$(lastword $$(MAKEFILE_LIST))) \
|
2014-03-02 00:32:04 +01:00
|
|
|
$(if $(filter $(BUILD_SYSTEM)/% $(OUT_DIR)/%,$(LOCAL_MODULE_MAKEFILE)), \
|
|
|
|
$(error my-dir must be called before including any other makefile.) \
|
2009-05-20 01:12:22 +02:00
|
|
|
, \
|
2012-04-24 06:29:18 +02:00
|
|
|
$(patsubst %/,%,$(dir $(LOCAL_MODULE_MAKEFILE))) \
|
2009-05-20 01:12:22 +02:00
|
|
|
) \
|
|
|
|
)
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
2016-05-28 00:23:13 +02:00
|
|
|
|
2009-03-04 04:28:42 +01:00
|
|
|
###########################################################
|
|
|
|
## Retrieve a list of all makefiles immediately below some directory
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define all-makefiles-under
|
2016-07-12 01:57:33 +02:00
|
|
|
$(wildcard $(1)/*/Android.mk)
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Look under a directory for makefiles that don't have parent
|
|
|
|
## makefiles.
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
# $(1): directory to search under
|
|
|
|
# Ignores $(1)/Android.mk
|
|
|
|
define first-makefiles-under
|
2017-12-06 23:38:40 +01:00
|
|
|
$(shell build/make/tools/findleaves.py $(FIND_LEAVES_EXCLUDES) \
|
2016-07-12 01:57:33 +02:00
|
|
|
--mindepth=2 $(addprefix --dir=,$(1)) Android.mk)
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Retrieve a list of all makefiles immediately below your directory
|
2014-03-02 00:32:04 +01:00
|
|
|
## Must be called before including any other makefile!!
|
2009-03-04 04:28:42 +01:00
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define all-subdir-makefiles
|
|
|
|
$(call all-makefiles-under,$(call my-dir))
|
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Look in the named list of directories for makefiles,
|
|
|
|
## relative to the current directory.
|
2014-03-02 00:32:04 +01:00
|
|
|
## Must be called before including any other makefile!!
|
2009-03-04 04:28:42 +01:00
|
|
|
###########################################################
|
|
|
|
|
|
|
|
# $(1): List of directories to look for under this directory
|
|
|
|
define all-named-subdir-makefiles
|
2016-07-12 01:57:33 +02:00
|
|
|
$(wildcard $(addsuffix /Android.mk, $(addprefix $(call my-dir)/,$(1))))
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
2015-10-13 00:26:52 +02:00
|
|
|
###########################################################
|
|
|
|
## Find all of the directories under the named directories with
|
|
|
|
## the specified name.
|
|
|
|
## Meant to be used like:
|
|
|
|
## INC_DIRS := $(call all-named-dirs-under,inc,.)
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define all-named-dirs-under
|
|
|
|
$(call find-subdir-files,$(2) -type d -name "$(1)")
|
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Find all the directories under the current directory that
|
|
|
|
## haves name that match $(1)
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define all-subdir-named-dirs
|
|
|
|
$(call all-named-dirs-under,$(1),.)
|
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Find all of the files under the named directories with
|
|
|
|
## the specified name.
|
|
|
|
## Meant to be used like:
|
|
|
|
## SRC_FILES := $(call all-named-files-under,*.h,src tests)
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define all-named-files-under
|
|
|
|
$(call find-files-in-subdirs,$(LOCAL_PATH),"$(1)",$(2))
|
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Find all of the files under the current directory with
|
|
|
|
## the specified name.
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define all-subdir-named-files
|
|
|
|
$(call all-named-files-under,$(1),.)
|
|
|
|
endef
|
|
|
|
|
2009-03-04 04:28:42 +01:00
|
|
|
###########################################################
|
|
|
|
## Find all of the java files under the named directories.
|
|
|
|
## Meant to be used like:
|
|
|
|
## SRC_FILES := $(call all-java-files-under,src tests)
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define all-java-files-under
|
2015-10-13 00:26:52 +02:00
|
|
|
$(call all-named-files-under,*.java,$(1))
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Find all of the java files from here. Meant to be used like:
|
|
|
|
## SRC_FILES := $(call all-subdir-java-files)
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define all-subdir-java-files
|
|
|
|
$(call all-java-files-under,.)
|
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Find all of the c files under the named directories.
|
|
|
|
## Meant to be used like:
|
|
|
|
## SRC_FILES := $(call all-c-files-under,src tests)
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define all-c-files-under
|
2015-10-13 00:26:52 +02:00
|
|
|
$(call all-named-files-under,*.c,$(1))
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Find all of the c files from here. Meant to be used like:
|
|
|
|
## SRC_FILES := $(call all-subdir-c-files)
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define all-subdir-c-files
|
|
|
|
$(call all-c-files-under,.)
|
|
|
|
endef
|
|
|
|
|
2015-09-30 01:26:28 +02:00
|
|
|
###########################################################
|
|
|
|
## Find all of the cpp files under the named directories.
|
|
|
|
## LOCAL_CPP_EXTENSION is respected if set.
|
|
|
|
## Meant to be used like:
|
|
|
|
## SRC_FILES := $(call all-cpp-files-under,src tests)
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define all-cpp-files-under
|
|
|
|
$(sort $(patsubst ./%,%, \
|
|
|
|
$(shell cd $(LOCAL_PATH) ; \
|
|
|
|
find -L $(1) -name "*$(or $(LOCAL_CPP_EXTENSION),.cpp)" -and -not -name ".*") \
|
|
|
|
))
|
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Find all of the cpp files from here. Meant to be used like:
|
|
|
|
## SRC_FILES := $(call all-subdir-cpp-files)
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define all-subdir-cpp-files
|
|
|
|
$(call all-cpp-files-under,.)
|
|
|
|
endef
|
|
|
|
|
2009-03-04 04:28:42 +01:00
|
|
|
###########################################################
|
|
|
|
## Find all files named "I*.aidl" under the named directories,
|
|
|
|
## which must be relative to $(LOCAL_PATH). The returned list
|
|
|
|
## is relative to $(LOCAL_PATH).
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define all-Iaidl-files-under
|
2015-10-13 00:26:52 +02:00
|
|
|
$(call all-named-files-under,I*.aidl,$(1))
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Find all of the "I*.aidl" files under $(LOCAL_PATH).
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define all-subdir-Iaidl-files
|
|
|
|
$(call all-Iaidl-files-under,.)
|
|
|
|
endef
|
|
|
|
|
2016-02-19 20:06:58 +01:00
|
|
|
###########################################################
|
|
|
|
## Find all files named "*.vts" under the named directories,
|
|
|
|
## which must be relative to $(LOCAL_PATH). The returned list
|
|
|
|
## is relative to $(LOCAL_PATH).
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define all-vts-files-under
|
|
|
|
$(call all-named-files-under,*.vts,$(1))
|
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Find all of the "*.vts" files under $(LOCAL_PATH).
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define all-subdir-vts-files
|
|
|
|
$(call all-vts-files-under,.)
|
|
|
|
endef
|
|
|
|
|
2010-02-02 18:36:20 +01:00
|
|
|
###########################################################
|
|
|
|
## Find all of the logtags files under the named directories.
|
|
|
|
## Meant to be used like:
|
|
|
|
## SRC_FILES := $(call all-logtags-files-under,src)
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define all-logtags-files-under
|
2015-10-13 00:26:52 +02:00
|
|
|
$(call all-named-files-under,*.logtags,$(1))
|
2010-02-02 18:36:20 +01:00
|
|
|
endef
|
|
|
|
|
2010-11-03 02:43:16 +01:00
|
|
|
###########################################################
|
|
|
|
## Find all of the .proto files under the named directories.
|
|
|
|
## Meant to be used like:
|
|
|
|
## SRC_FILES := $(call all-proto-files-under,src)
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define all-proto-files-under
|
2015-10-13 00:26:52 +02:00
|
|
|
$(call all-named-files-under,*.proto,$(1))
|
2010-11-03 02:43:16 +01:00
|
|
|
endef
|
|
|
|
|
2010-07-16 02:17:52 +02:00
|
|
|
###########################################################
|
|
|
|
## Find all of the RenderScript files under the named directories.
|
|
|
|
## Meant to be used like:
|
|
|
|
## SRC_FILES := $(call all-renderscript-files-under,src)
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define all-renderscript-files-under
|
2019-07-12 17:33:31 +02:00
|
|
|
$(call find-subdir-files,$(1) \( -name "*.rscript" -or -name "*.fs" \) -and -not -name ".*")
|
2010-07-16 02:17:52 +02:00
|
|
|
endef
|
|
|
|
|
2009-12-18 02:47:28 +01:00
|
|
|
###########################################################
|
2014-02-11 22:48:35 +01:00
|
|
|
## Find all of the S files under the named directories.
|
|
|
|
## Meant to be used like:
|
|
|
|
## SRC_FILES := $(call all-c-files-under,src tests)
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define all-S-files-under
|
2015-10-13 00:26:52 +02:00
|
|
|
$(call all-named-files-under,*.S,$(1))
|
2014-02-11 22:48:35 +01:00
|
|
|
endef
|
|
|
|
|
2009-12-18 02:47:28 +01:00
|
|
|
###########################################################
|
|
|
|
## Find all of the html files under the named directories.
|
|
|
|
## Meant to be used like:
|
|
|
|
## SRC_FILES := $(call all-html-files-under,src tests)
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define all-html-files-under
|
2015-10-13 00:26:52 +02:00
|
|
|
$(call all-named-files-under,*.html,$(1))
|
2009-12-18 02:47:28 +01:00
|
|
|
endef
|
|
|
|
|
2009-03-04 04:28:42 +01:00
|
|
|
###########################################################
|
|
|
|
## Find all of the html files from here. Meant to be used like:
|
|
|
|
## SRC_FILES := $(call all-subdir-html-files)
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define all-subdir-html-files
|
2009-12-18 02:47:28 +01:00
|
|
|
$(call all-html-files-under,.)
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Find all of the files matching pattern
|
|
|
|
## SRC_FILES := $(call find-subdir-files, <pattern>)
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define find-subdir-files
|
2015-09-23 01:54:12 +02:00
|
|
|
$(sort $(patsubst ./%,%,$(shell cd $(LOCAL_PATH) ; find -L $(1))))
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
# find the files in the subdirectory $1 of LOCAL_DIR
|
|
|
|
# matching pattern $2, filtering out files $3
|
|
|
|
# e.g.
|
|
|
|
# SRC_FILES += $(call find-subdir-subdir-files, \
|
|
|
|
# css, *.cpp, DontWantThis.cpp)
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define find-subdir-subdir-files
|
2015-09-23 01:54:12 +02:00
|
|
|
$(sort $(filter-out $(patsubst %,$(1)/%,$(3)),$(patsubst ./%,%,$(shell cd \
|
|
|
|
$(LOCAL_PATH) ; find -L $(1) -maxdepth 1 -name $(2)))))
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Find all of the files matching pattern
|
|
|
|
## SRC_FILES := $(call all-subdir-java-files)
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define find-subdir-assets
|
2015-09-23 01:54:12 +02:00
|
|
|
$(sort $(if $(1),$(patsubst ./%,%, \
|
2019-05-29 00:09:53 +02:00
|
|
|
$(shell if [ -d $(1) ] ; then cd $(1) ; find -L ./ -not -name '.*' -and -type f ; fi)), \
|
|
|
|
$(warning Empty argument supplied to find-subdir-assets in $(LOCAL_PATH)) \
|
2015-09-23 01:54:12 +02:00
|
|
|
))
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Find various file types in a list of directories relative to $(LOCAL_PATH)
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define find-other-java-files
|
2015-10-13 00:26:52 +02:00
|
|
|
$(call all-java-files-under,$(1))
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
|
|
|
define find-other-html-files
|
2015-10-13 00:26:52 +02:00
|
|
|
$(call all-html-files-under,$(1))
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
2013-12-05 01:04:49 +01:00
|
|
|
###########################################################
|
|
|
|
# Use utility find to find given files in the given subdirs.
|
|
|
|
# This function uses $(1), instead of LOCAL_PATH as the base.
|
|
|
|
# $(1): the base dir, relative to the root of the source tree.
|
|
|
|
# $(2): the file name pattern to be passed to find as "-name".
|
|
|
|
# $(3): a list of subdirs of the base dir.
|
|
|
|
# Returns: a list of paths relative to the base dir.
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define find-files-in-subdirs
|
2015-09-23 01:54:12 +02:00
|
|
|
$(sort $(patsubst ./%,%, \
|
2013-12-05 01:04:49 +01:00
|
|
|
$(shell cd $(1) ; \
|
|
|
|
find -L $(3) -name $(2) -and -not -name ".*") \
|
2015-09-23 01:54:12 +02:00
|
|
|
))
|
2013-12-05 01:04:49 +01:00
|
|
|
endef
|
|
|
|
|
2009-03-04 04:28:42 +01:00
|
|
|
###########################################################
|
|
|
|
## Scan through each directory of $(1) looking for files
|
|
|
|
## that match $(2) using $(wildcard). Useful for seeing if
|
|
|
|
## a given directory or one of its parents contains
|
|
|
|
## a particular file. Returns the first match found,
|
|
|
|
## starting furthest from the root.
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define find-parent-file
|
|
|
|
$(strip \
|
2015-09-30 01:30:21 +02:00
|
|
|
$(eval _fpf := $(sort $(wildcard $(foreach f, $(2), $(strip $(1))/$(f))))) \
|
2009-03-04 04:28:42 +01:00
|
|
|
$(if $(_fpf),$(_fpf), \
|
|
|
|
$(if $(filter-out ./ .,$(1)), \
|
|
|
|
$(call find-parent-file,$(patsubst %/,%,$(dir $(1))),$(2)) \
|
|
|
|
) \
|
|
|
|
) \
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2016-12-10 01:05:09 +01:00
|
|
|
###########################################################
|
|
|
|
## Find test data in a form required by LOCAL_TEST_DATA
|
|
|
|
## $(1): the base dir, relative to the root of the source tree.
|
2018-03-31 05:04:33 +02:00
|
|
|
## $(2): the file name pattern to be passed to find as "-name"
|
|
|
|
## $(3): a list of subdirs of the base dir
|
2016-12-10 01:05:09 +01:00
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define find-test-data-in-subdirs
|
|
|
|
$(foreach f,$(sort $(patsubst ./%,%, \
|
|
|
|
$(shell cd $(1) ; \
|
|
|
|
find -L $(3) -type f -and -name $(2) -and -not -name ".*") \
|
|
|
|
)),$(1):$(f))
|
|
|
|
endef
|
|
|
|
|
2009-03-04 04:28:42 +01:00
|
|
|
###########################################################
|
|
|
|
## Function we can evaluate to introduce a dynamic dependency
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define add-dependency
|
|
|
|
$(1): $(2)
|
|
|
|
endef
|
|
|
|
|
2014-09-08 14:45:14 +02:00
|
|
|
###########################################################
|
|
|
|
## Reverse order of a list
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define reverse-list
|
|
|
|
$(if $(1),$(call reverse-list,$(wordlist 2,$(words $(1)),$(1)))) $(firstword $(1))
|
|
|
|
endef
|
|
|
|
|
2016-08-02 02:41:49 +02:00
|
|
|
###########################################################
|
2021-01-07 04:34:31 +01:00
|
|
|
## Sometimes a notice dependency will reference an unadorned
|
|
|
|
## module name that only appears in ALL_MODULES adorned with
|
|
|
|
## an ARCH suffix or a `host_cross_` prefix.
|
|
|
|
##
|
|
|
|
## After all of the modules are processed in base_rules.mk,
|
|
|
|
## replace all such dependencies with every matching adorned
|
|
|
|
## module name.
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define fix-notice-deps
|
|
|
|
$(strip \
|
|
|
|
$(eval _all_module_refs := \
|
|
|
|
$(sort \
|
|
|
|
$(foreach m,$(sort $(ALL_MODULES)), \
|
2021-04-15 19:41:38 +02:00
|
|
|
$(call word-colon,1,$(ALL_MODULES.$(m).NOTICE_DEPS)) \
|
2021-01-07 04:34:31 +01:00
|
|
|
) \
|
|
|
|
) \
|
|
|
|
) \
|
|
|
|
$(foreach m, $(_all_module_refs), \
|
|
|
|
$(eval _lookup.$(m) := \
|
|
|
|
$(sort \
|
|
|
|
$(if $(strip $(ALL_MODULES.$(m).PATH)), \
|
|
|
|
$(m), \
|
|
|
|
$(filter $(m)_32 $(m)_64 host_cross_$(m) host_cross_$(m)_32 host_cross_$(m)_64, $(ALL_MODULES)) \
|
|
|
|
) \
|
|
|
|
) \
|
|
|
|
) \
|
|
|
|
) \
|
|
|
|
$(foreach m, $(ALL_MODULES), \
|
|
|
|
$(eval ALL_MODULES.$(m).NOTICE_DEPS := \
|
|
|
|
$(sort \
|
2021-02-19 02:17:49 +01:00
|
|
|
$(foreach d,$(sort $(ALL_MODULES.$(m).NOTICE_DEPS)), \
|
2021-04-15 19:41:38 +02:00
|
|
|
$(foreach n,$(_lookup.$(call word-colon,1,$(d))),$(n):$(call wordlist-colon,2,9999,$(d))) \
|
2021-01-07 04:34:31 +01:00
|
|
|
) \
|
|
|
|
) \
|
|
|
|
) \
|
|
|
|
) \
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
2021-01-07 04:34:31 +01:00
|
|
|
## Target directory for license metadata files.
|
|
|
|
###########################################################
|
|
|
|
define license-metadata-dir
|
2022-09-13 04:09:52 +02:00
|
|
|
$(call generated-sources-dir-for,META,lic,$(filter-out $(PRODUCT_OUT)%,$(1)))
|
2021-01-07 04:34:31 +01:00
|
|
|
endef
|
|
|
|
|
2022-06-14 20:18:45 +02:00
|
|
|
TARGETS_MISSING_LICENSE_METADATA:=
|
|
|
|
|
2022-02-09 06:51:41 +01:00
|
|
|
###########################################################
|
|
|
|
# License metadata targets corresponding to targets in $(1)
|
|
|
|
###########################################################
|
|
|
|
define corresponding-license-metadata
|
2022-06-14 20:18:45 +02:00
|
|
|
$(strip $(filter-out 0p,$(foreach target, $(sort $(1)), \
|
2022-02-13 00:39:22 +01:00
|
|
|
$(if $(strip $(ALL_MODULES.$(target).META_LIC)), \
|
|
|
|
$(ALL_MODULES.$(target).META_LIC), \
|
|
|
|
$(if $(strip $(ALL_TARGETS.$(target).META_LIC)), \
|
|
|
|
$(ALL_TARGETS.$(target).META_LIC), \
|
2022-06-14 20:18:45 +02:00
|
|
|
$(eval TARGETS_MISSING_LICENSE_METADATA += $(target)) \
|
|
|
|
) \
|
|
|
|
) \
|
|
|
|
)))
|
2022-02-09 06:51:41 +01:00
|
|
|
endef
|
|
|
|
|
2022-05-28 04:40:41 +02:00
|
|
|
###########################################################
|
|
|
|
## Record a target $(1) copied from another target(s) $(2) that will need
|
|
|
|
## license metadata.
|
|
|
|
###########################################################
|
|
|
|
define declare-copy-target-license-metadata
|
2022-12-01 20:44:14 +01:00
|
|
|
$(strip $(if $(filter $(OUT_DIR)%,$(2)),\
|
2022-05-28 04:40:41 +02:00
|
|
|
$(eval _tgt:=$(strip $(1)))\
|
|
|
|
$(eval ALL_COPIED_TARGETS.$(_tgt).SOURCES := $(ALL_COPIED_TARGETS.$(_tgt).SOURCES) $(filter $(OUT_DIR)%,$(2)))\
|
2022-12-01 20:44:14 +01:00
|
|
|
$(eval ALL_COPIED_TARGETS += $(_tgt))))
|
2022-05-28 04:40:41 +02:00
|
|
|
endef
|
|
|
|
|
2021-01-07 04:34:31 +01:00
|
|
|
###########################################################
|
2021-04-15 19:41:38 +02:00
|
|
|
## License metadata build rule for my_register_name $(1)
|
2021-01-07 04:34:31 +01:00
|
|
|
###########################################################
|
|
|
|
define license-metadata-rule
|
2022-03-24 07:28:40 +01:00
|
|
|
$(foreach meta_lic, $(ALL_MODULES.$(1).DELAYED_META_LIC),$(call _license-metadata-rule,$(1),$(meta_lic)))
|
2021-12-03 23:46:20 +01:00
|
|
|
endef
|
|
|
|
|
2022-03-24 07:28:40 +01:00
|
|
|
$(KATI_obsolete_var notice-rule, This function has been removed)
|
|
|
|
|
2021-12-03 23:46:20 +01:00
|
|
|
define _license-metadata-rule
|
2021-04-15 19:41:38 +02:00
|
|
|
$(strip $(eval _srcs := $(strip $(foreach d,$(ALL_MODULES.$(1).NOTICE_DEPS),$(if $(strip $(ALL_MODULES.$(call word-colon,1,$(d)).INSTALLED)), $(ALL_MODULES.$(call word-colon,1,$(d)).INSTALLED),$(if $(strip $(ALL_MODULES.$(call word-colon,1,$(d)).BUILT)), $(ALL_MODULES.$(call word-colon,1,$(d)).BUILT), $(call word-colon,1,$d)))))))
|
2021-12-03 23:46:20 +01:00
|
|
|
$(strip $(eval _deps := $(sort $(filter-out $(2)%,\
|
|
|
|
$(foreach d,$(ALL_MODULES.$(1).NOTICE_DEPS),\
|
|
|
|
$(addsuffix :$(call wordlist-colon,2,9999,$(d)), \
|
|
|
|
$(foreach dt,$(ALL_MODULES.$(d).BUILT) $(ALL_MODULES.$(d).INSTALLED),\
|
|
|
|
$(ALL_TARGETS.$(dt).META_LIC))))))))
|
2021-02-19 02:17:49 +01:00
|
|
|
$(strip $(eval _notices := $(sort $(ALL_MODULES.$(1).NOTICES))))
|
2021-04-15 19:41:38 +02:00
|
|
|
$(strip $(eval _tgts := $(sort $(ALL_MODULES.$(1).BUILT))))
|
|
|
|
$(strip $(eval _inst := $(sort $(ALL_MODULES.$(1).INSTALLED))))
|
|
|
|
$(strip $(eval _path := $(sort $(ALL_MODULES.$(1).PATH))))
|
|
|
|
$(strip $(eval _map := $(strip $(foreach _m,$(sort $(ALL_MODULES.$(1).LICENSE_INSTALL_MAP)), \
|
|
|
|
$(eval _s := $(call word-colon,1,$(_m))) \
|
|
|
|
$(eval _d := $(call word-colon,2,$(_m))) \
|
|
|
|
$(eval _ns := $(if $(strip $(ALL_MODULES.$(_s).INSTALLED)),$(ALL_MODULES.$(_s).INSTALLED),$(if $(strip $(ALL_MODULES.$(_s).BUILT)),$(ALL_MODULES.$(_s).BUILT),$(_s)))) \
|
|
|
|
$(foreach ns,$(_ns),$(ns):$(_d) ) \
|
|
|
|
))))
|
2021-01-07 04:34:31 +01:00
|
|
|
|
2021-12-03 23:46:20 +01:00
|
|
|
$(2): PRIVATE_KINDS := $(sort $(ALL_MODULES.$(1).LICENSE_KINDS))
|
|
|
|
$(2): PRIVATE_CONDITIONS := $(sort $(ALL_MODULES.$(1).LICENSE_CONDITIONS))
|
|
|
|
$(2): PRIVATE_NOTICES := $(_notices)
|
|
|
|
$(2): PRIVATE_NOTICE_DEPS := $(_deps)
|
|
|
|
$(2): PRIVATE_SOURCES := $(_srcs)
|
|
|
|
$(2): PRIVATE_TARGETS := $(_tgts)
|
|
|
|
$(2): PRIVATE_INSTALLED := $(_inst)
|
|
|
|
$(2): PRIVATE_PATH := $(_path)
|
|
|
|
$(2): PRIVATE_IS_CONTAINER := $(ALL_MODULES.$(1).IS_CONTAINER)
|
|
|
|
$(2): PRIVATE_PACKAGE_NAME := $(strip $(ALL_MODULES.$(1).LICENSE_PACKAGE_NAME))
|
|
|
|
$(2): PRIVATE_INSTALL_MAP := $(_map)
|
2022-10-13 22:25:35 +02:00
|
|
|
$(2): PRIVATE_MODULE_NAME := $(1)
|
2021-12-03 23:46:20 +01:00
|
|
|
$(2): PRIVATE_MODULE_TYPE := $(ALL_MODULES.$(1).MODULE_TYPE)
|
|
|
|
$(2): PRIVATE_MODULE_CLASS := $(ALL_MODULES.$(1).MODULE_CLASS)
|
|
|
|
$(2): PRIVATE_INSTALL_MAP := $(_map)
|
2022-03-25 21:22:59 +01:00
|
|
|
$(2): PRIVATE_ARGUMENT_FILE := $(call intermediates-dir-for,PACKAGING,notice)/$(2)/arguments
|
2021-12-03 23:46:20 +01:00
|
|
|
$(2): $(BUILD_LICENSE_METADATA)
|
|
|
|
$(2) : $(foreach d,$(_deps),$(call word-colon,1,$(d))) $(foreach n,$(_notices),$(call word-colon,1,$(n)) )
|
2021-01-07 04:34:31 +01:00
|
|
|
rm -f $$@
|
|
|
|
mkdir -p $$(dir $$@)
|
2022-03-25 21:22:59 +01:00
|
|
|
mkdir -p $$(dir $$(PRIVATE_ARGUMENT_FILE))
|
|
|
|
$$(call dump-words-to-file,\
|
2022-10-13 22:25:35 +02:00
|
|
|
$$(addprefix -mn ,$$(PRIVATE_MODULE_NAME))\
|
2022-03-25 21:22:59 +01:00
|
|
|
$$(addprefix -mt ,$$(PRIVATE_MODULE_TYPE))\
|
|
|
|
$$(addprefix -mc ,$$(PRIVATE_MODULE_CLASS))\
|
|
|
|
$$(addprefix -k ,$$(PRIVATE_KINDS))\
|
|
|
|
$$(addprefix -c ,$$(PRIVATE_CONDITIONS))\
|
|
|
|
$$(addprefix -n ,$$(PRIVATE_NOTICES))\
|
|
|
|
$$(addprefix -d ,$$(PRIVATE_NOTICE_DEPS))\
|
|
|
|
$$(addprefix -s ,$$(PRIVATE_SOURCES))\
|
|
|
|
$$(addprefix -m ,$$(PRIVATE_INSTALL_MAP))\
|
|
|
|
$$(addprefix -t ,$$(PRIVATE_TARGETS))\
|
|
|
|
$$(addprefix -i ,$$(PRIVATE_INSTALLED))\
|
|
|
|
$$(addprefix -r ,$$(PRIVATE_PATH)),\
|
|
|
|
$$(PRIVATE_ARGUMENT_FILE))
|
2022-03-22 21:05:19 +01:00
|
|
|
OUT_DIR=$(OUT_DIR) $(BUILD_LICENSE_METADATA) \
|
2021-10-21 01:22:05 +02:00
|
|
|
$$(if $$(PRIVATE_IS_CONTAINER),-is_container) \
|
|
|
|
-p '$$(PRIVATE_PACKAGE_NAME)' \
|
2022-03-25 21:22:59 +01:00
|
|
|
@$$(PRIVATE_ARGUMENT_FILE) \
|
2021-10-21 01:22:05 +02:00
|
|
|
-o $$@
|
2021-12-03 23:46:20 +01:00
|
|
|
endef
|
2021-01-07 04:34:31 +01:00
|
|
|
|
|
|
|
|
2021-04-15 19:41:38 +02:00
|
|
|
###########################################################
|
|
|
|
## License metadata build rule for non-module target $(1)
|
|
|
|
###########################################################
|
|
|
|
define non-module-license-metadata-rule
|
2022-09-13 04:09:52 +02:00
|
|
|
$(strip $(eval _dir := $(call license-metadata-dir,$(1))))
|
2021-04-15 19:41:38 +02:00
|
|
|
$(strip $(eval _tgt := $(strip $(1))))
|
2022-03-22 21:05:19 +01:00
|
|
|
$(strip $(eval _meta := $(call append-path,$(_dir),$(patsubst $(OUT_DIR)%,out%,$(_tgt).meta_lic))))
|
2021-04-15 19:41:38 +02:00
|
|
|
$(strip $(eval _deps := $(sort $(filter-out 0p: :,$(foreach d,$(strip $(ALL_NON_MODULES.$(_tgt).DEPENDENCIES)),$(ALL_TARGETS.$(call word-colon,1,$(d)).META_LIC):$(call wordlist-colon,2,9999,$(d)))))))
|
|
|
|
$(strip $(eval _notices := $(sort $(ALL_NON_MODULES.$(_tgt).NOTICES))))
|
|
|
|
$(strip $(eval _path := $(sort $(ALL_NON_MODULES.$(_tgt).PATH))))
|
|
|
|
$(strip $(eval _install_map := $(ALL_NON_MODULES.$(_tgt).ROOT_MAPPINGS)))
|
|
|
|
|
2022-03-22 21:05:19 +01:00
|
|
|
$(_meta): PRIVATE_KINDS := $(sort $(ALL_NON_MODULES.$(_tgt).LICENSE_KINDS))
|
|
|
|
$(_meta): PRIVATE_CONDITIONS := $(sort $(ALL_NON_MODULES.$(_tgt).LICENSE_CONDITIONS))
|
|
|
|
$(_meta): PRIVATE_NOTICES := $(_notices)
|
|
|
|
$(_meta): PRIVATE_NOTICE_DEPS := $(_deps)
|
|
|
|
$(_meta): PRIVATE_SOURCES := $(ALL_NON_MODULES.$(_tgt).DEPENDENCIES)
|
|
|
|
$(_meta): PRIVATE_TARGETS := $(_tgt)
|
|
|
|
$(_meta): PRIVATE_PATH := $(_path)
|
|
|
|
$(_meta): PRIVATE_IS_CONTAINER := $(ALL_NON_MODULES.$(_tgt).IS_CONTAINER)
|
|
|
|
$(_meta): PRIVATE_PACKAGE_NAME := $(strip $(ALL_NON_MODULES.$(_tgt).LICENSE_PACKAGE_NAME))
|
|
|
|
$(_meta): PRIVATE_INSTALL_MAP := $(strip $(_install_map))
|
2022-03-25 21:22:59 +01:00
|
|
|
$(_meta): PRIVATE_ARGUMENT_FILE := $(call intermediates-dir-for,PACKAGING,notice)/$(_meta)/arguments
|
2022-03-22 21:05:19 +01:00
|
|
|
$(_meta): $(BUILD_LICENSE_METADATA)
|
|
|
|
$(_meta) : $(foreach d,$(_deps),$(call word-colon,1,$(d))) $(foreach n,$(_notices),$(call word-colon,1,$(n)) )
|
2021-04-15 19:41:38 +02:00
|
|
|
rm -f $$@
|
|
|
|
mkdir -p $$(dir $$@)
|
2022-03-25 21:22:59 +01:00
|
|
|
mkdir -p $$(dir $$(PRIVATE_ARGUMENT_FILE))
|
|
|
|
$$(call dump-words-to-file,\
|
|
|
|
$$(addprefix -k ,$$(PRIVATE_KINDS))\
|
|
|
|
$$(addprefix -c ,$$(PRIVATE_CONDITIONS))\
|
|
|
|
$$(addprefix -n ,$$(PRIVATE_NOTICES))\
|
|
|
|
$$(addprefix -d ,$$(PRIVATE_NOTICE_DEPS))\
|
|
|
|
$$(addprefix -s ,$$(PRIVATE_SOURCES))\
|
|
|
|
$$(addprefix -m ,$$(PRIVATE_INSTALL_MAP))\
|
|
|
|
$$(addprefix -t ,$$(PRIVATE_TARGETS))\
|
|
|
|
$$(addprefix -r ,$$(PRIVATE_PATH)),\
|
|
|
|
$$(PRIVATE_ARGUMENT_FILE))
|
2022-03-22 21:05:19 +01:00
|
|
|
OUT_DIR=$(OUT_DIR) $(BUILD_LICENSE_METADATA) \
|
2021-10-21 01:22:05 +02:00
|
|
|
-mt raw -mc unknown \
|
|
|
|
$$(if $$(PRIVATE_IS_CONTAINER),-is_container) \
|
|
|
|
$$(addprefix -r ,$$(PRIVATE_PATH)) \
|
2022-03-25 21:22:59 +01:00
|
|
|
@$$(PRIVATE_ARGUMENT_FILE) \
|
2021-10-21 01:22:05 +02:00
|
|
|
-o $$@
|
2021-04-15 19:41:38 +02:00
|
|
|
|
|
|
|
endef
|
|
|
|
|
2022-05-28 04:40:41 +02:00
|
|
|
###########################################################
|
|
|
|
## Record missing dependencies for non-module target $(1)
|
|
|
|
###########################################################
|
|
|
|
define record-missing-non-module-dependencies
|
|
|
|
$(strip $(eval _tgt := $(strip $(1))))
|
|
|
|
$(strip $(foreach d,$(strip $(ALL_NON_MODULES.$(_tgt).DEPENDENCIES)), \
|
|
|
|
$(if $(strip $(ALL_TARGETS.$(d).META_LIC)), \
|
|
|
|
, \
|
|
|
|
$(eval NON_MODULES_WITHOUT_LICENSE_METADATA += $(d))) \
|
|
|
|
))
|
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## License metadata build rule for copied target $(1)
|
|
|
|
###########################################################
|
|
|
|
define copied-target-license-metadata-rule
|
|
|
|
$(if $(strip $(ALL_TARGETS.$(1).META_LIC)),,$(call _copied-target-license-metadata-rule,$(1)))
|
|
|
|
endef
|
|
|
|
|
|
|
|
define _copied-target-license-metadata-rule
|
2022-09-13 04:09:52 +02:00
|
|
|
$(strip $(eval _dir := $(call license-metadata-dir,$(1))))
|
2022-05-28 04:40:41 +02:00
|
|
|
$(strip $(eval _meta := $(call append-path,$(_dir),$(patsubst $(OUT_DIR)%,out%,$(1).meta_lic))))
|
|
|
|
$(strip $(eval ALL_TARGETS.$(1).META_LIC:=$(_meta)))
|
|
|
|
$(strip $(eval _dep:=))
|
|
|
|
$(strip $(foreach s,$(ALL_COPIED_TARGETS.$(1).SOURCES),\
|
|
|
|
$(eval _dmeta:=$(ALL_TARGETS.$(s).META_LIC))\
|
2022-12-01 20:44:14 +01:00
|
|
|
$(if $(filter-out 0p,$(_dep)),\
|
|
|
|
$(if $(filter-out $(_dep),$(_dmeta)),$(error cannot copy target from multiple modules: $(1) from $(_dep) and $(_dmeta))),\
|
|
|
|
$(eval _dep:=$(_dmeta)))))
|
|
|
|
$(if $(filter 0p,$(_dep)),$(eval ALL_TARGETS.$(1).META_LIC:=0p))
|
2022-05-28 04:40:41 +02:00
|
|
|
$(strip $(if $(strip $(_dep)),,$(error cannot copy target from unknown module: $(1) from $(ALL_COPIED_TARGETS.$(1).SOURCES))))
|
|
|
|
|
|
|
|
ifneq (0p,$(ALL_TARGETS.$(1).META_LIC))
|
|
|
|
$(_meta): PRIVATE_DEST_TARGET := $(1)
|
|
|
|
$(_meta): PRIVATE_SOURCE_TARGETS := $(ALL_COPIED_TARGETS.$(1).SOURCES)
|
|
|
|
$(_meta): PRIVATE_SOURCE_METADATA := $(_dep)
|
|
|
|
$(_meta): PRIVATE_ARGUMENT_FILE := $(call intermediates-dir-for,PACKAGING,copynotice)/$(_meta)/arguments
|
2022-06-14 20:18:45 +02:00
|
|
|
$(_meta) : $(_dep) $(COPY_LICENSE_METADATA)
|
2022-05-28 04:40:41 +02:00
|
|
|
rm -f $$@
|
|
|
|
mkdir -p $$(dir $$@)
|
|
|
|
mkdir -p $$(dir $$(PRIVATE_ARGUMENT_FILE))
|
|
|
|
$$(call dump-words-to-file,\
|
|
|
|
$$(addprefix -i ,$$(PRIVATE_DEST_TARGET))\
|
|
|
|
$$(addprefix -s ,$$(PRIVATE_SOURCE_TARGETS))\
|
|
|
|
$$(addprefix -d ,$$(PRIVATE_SOURCE_METADATA)),\
|
|
|
|
$$(PRIVATE_ARGUMENT_FILE))
|
|
|
|
OUT_DIR=$(OUT_DIR) $(COPY_LICENSE_METADATA) \
|
|
|
|
@$$(PRIVATE_ARGUMENT_FILE) \
|
|
|
|
-o $$@
|
|
|
|
|
|
|
|
endif
|
2022-12-01 20:44:14 +01:00
|
|
|
|
|
|
|
$(eval _dep:=)
|
|
|
|
$(eval _dmeta:=)
|
|
|
|
$(eval _meta:=)
|
|
|
|
$(eval _dir:=)
|
2022-05-28 04:40:41 +02:00
|
|
|
endef
|
|
|
|
|
2021-04-15 19:41:38 +02:00
|
|
|
###########################################################
|
|
|
|
## Declare the license metadata for non-module target $(1).
|
|
|
|
##
|
|
|
|
## $(2) -- license kinds e.g. SPDX-license-identifier-Apache-2.0
|
|
|
|
## $(3) -- license conditions e.g. notice by_exception_only
|
|
|
|
## $(4) -- license text filenames (notices)
|
|
|
|
## $(5) -- package name
|
|
|
|
## $(6) -- project path
|
|
|
|
###########################################################
|
|
|
|
define declare-license-metadata
|
|
|
|
$(strip \
|
2022-03-22 21:05:19 +01:00
|
|
|
$(eval _tgt := $(subst //,/,$(strip $(1)))) \
|
2021-04-15 19:41:38 +02:00
|
|
|
$(eval ALL_NON_MODULES += $(_tgt)) \
|
2022-09-13 04:09:52 +02:00
|
|
|
$(eval ALL_TARGETS.$(_tgt).META_LIC := $(call license-metadata-dir,$(1))/$(patsubst $(OUT_DIR)%,out%,$(_tgt)).meta_lic) \
|
2021-04-15 19:41:38 +02:00
|
|
|
$(eval ALL_NON_MODULES.$(_tgt).LICENSE_KINDS := $(strip $(2))) \
|
|
|
|
$(eval ALL_NON_MODULES.$(_tgt).LICENSE_CONDITIONS := $(strip $(3))) \
|
|
|
|
$(eval ALL_NON_MODULES.$(_tgt).NOTICES := $(strip $(4))) \
|
|
|
|
$(eval ALL_NON_MODULES.$(_tgt).LICENSE_PACKAGE_NAME := $(strip $(5))) \
|
|
|
|
$(eval ALL_NON_MODULES.$(_tgt).PATH := $(strip $(6))) \
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2022-02-09 06:51:41 +01:00
|
|
|
###########################################################
|
|
|
|
## Declare that non-module targets copied from project $(1) and
|
|
|
|
## optionally ending in $(2) have the following license
|
|
|
|
## metadata:
|
|
|
|
##
|
|
|
|
## $(3) -- license kinds e.g. SPDX-license-identifier-Apache-2.0
|
|
|
|
## $(4) -- license conditions e.g. notice by_exception_only
|
|
|
|
## $(5) -- license text filenames (notices)
|
|
|
|
## $(6) -- package name
|
|
|
|
###########################################################
|
|
|
|
define declare-copy-files-license-metadata
|
|
|
|
$(strip \
|
|
|
|
$(foreach _pair,$(filter $(1)%$(2),$(PRODUCT_COPY_FILES)),$(eval $(call declare-license-metadata,$(PRODUCT_OUT)/$(call word-colon,2,$(_pair)),$(3),$(4),$(5),$(6),$(1)))) \
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2021-04-15 19:41:38 +02:00
|
|
|
###########################################################
|
|
|
|
## Declare the license metadata for non-module container-type target $(1).
|
|
|
|
##
|
|
|
|
## Container-type targets are targets like .zip files that
|
|
|
|
## merely aggregate other files.
|
|
|
|
##
|
|
|
|
## $(2) -- license kinds e.g. SPDX-license-identifier-Apache-2.0
|
|
|
|
## $(3) -- license conditions e.g. notice by_exception_only
|
|
|
|
## $(4) -- license text filenames (notices)
|
|
|
|
## $(5) -- package name
|
|
|
|
## $(6) -- project path
|
|
|
|
###########################################################
|
|
|
|
define declare-container-license-metadata
|
|
|
|
$(strip \
|
2022-03-22 21:05:19 +01:00
|
|
|
$(eval _tgt := $(subst //,/,$(strip $(1)))) \
|
2021-04-15 19:41:38 +02:00
|
|
|
$(eval ALL_NON_MODULES += $(_tgt)) \
|
2022-09-13 04:09:52 +02:00
|
|
|
$(eval ALL_TARGETS.$(_tgt).META_LIC := $(call license-metadata-dir,$(1))/$(patsubst $(OUT_DIR)%,out%,$(_tgt)).meta_lic) \
|
2021-04-15 19:41:38 +02:00
|
|
|
$(eval ALL_NON_MODULES.$(_tgt).LICENSE_KINDS := $(strip $(2))) \
|
|
|
|
$(eval ALL_NON_MODULES.$(_tgt).LICENSE_CONDITIONS := $(strip $(3))) \
|
|
|
|
$(eval ALL_NON_MODULES.$(_tgt).NOTICES := $(strip $(4))) \
|
|
|
|
$(eval ALL_NON_MODULES.$(_tgt).LICENSE_PACKAGE_NAME := $(strip $(5))) \
|
|
|
|
$(eval ALL_NON_MODULES.$(_tgt).PATH := $(strip $(6))) \
|
|
|
|
$(eval ALL_NON_MODULES.$(_tgt).IS_CONTAINER := true) \
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Declare that non-module target $(1) is a non-copyrightable file.
|
|
|
|
##
|
|
|
|
## e.g. an information-only file merely listing other files.
|
|
|
|
###########################################################
|
|
|
|
define declare-0p-target
|
|
|
|
$(strip \
|
2022-03-22 21:05:19 +01:00
|
|
|
$(eval _tgt := $(subst //,/,$(strip $(1)))) \
|
2021-04-15 19:41:38 +02:00
|
|
|
$(eval ALL_0P_TARGETS += $(_tgt)) \
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2022-02-09 06:51:41 +01:00
|
|
|
###########################################################
|
|
|
|
## Declare that non-module targets copied from project $(1) and
|
|
|
|
## optionally ending in $(2) are non-copyrightable files.
|
|
|
|
##
|
|
|
|
## e.g. an information-only file merely listing other files.
|
|
|
|
###########################################################
|
|
|
|
define declare-0p-copy-files
|
|
|
|
$(strip \
|
|
|
|
$(foreach _pair,$(filter $(1)%$(2),$(PRODUCT_COPY_FILES)),$(eval $(call declare-0p-target,$(PRODUCT_OUT)/$(call word-colon,2,$(_pair))))) \
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2021-04-15 19:41:38 +02:00
|
|
|
###########################################################
|
|
|
|
## Declare non-module target $(1) to have a first-party license
|
|
|
|
## (Android Apache 2.0)
|
|
|
|
##
|
|
|
|
## $(2) -- project path
|
|
|
|
###########################################################
|
|
|
|
define declare-1p-target
|
|
|
|
$(call declare-license-metadata,$(1),SPDX-license-identifier-Apache-2.0,notice,build/soong/licenses/LICENSE,Android,$(2))
|
|
|
|
endef
|
|
|
|
|
2022-02-09 06:51:41 +01:00
|
|
|
###########################################################
|
|
|
|
## Declare that non-module targets copied from project $(1) and
|
|
|
|
## optionally ending in $(2) are first-party licensed
|
|
|
|
## (Android Apache 2.0)
|
|
|
|
###########################################################
|
|
|
|
define declare-1p-copy-files
|
|
|
|
$(foreach _pair,$(filter $(1)%$(2),$(PRODUCT_COPY_FILES)),$(call declare-1p-target,$(PRODUCT_OUT)/$(call word-colon,2,$(_pair)),$(1)))
|
|
|
|
endef
|
|
|
|
|
2021-04-15 19:41:38 +02:00
|
|
|
###########################################################
|
|
|
|
## Declare non-module container-type target $(1) to have a
|
|
|
|
## first-party license (Android Apache 2.0).
|
|
|
|
##
|
|
|
|
## Container-type targets are targets like .zip files that
|
|
|
|
## merely aggregate other files.
|
|
|
|
##
|
|
|
|
## $92) -- project path
|
|
|
|
###########################################################
|
|
|
|
define declare-1p-container
|
|
|
|
$(call declare-container-license-metadata,$(1),SPDX-license-identifier-Apache-2.0,notice,build/soong/licenses/LICENSE,Android,$(2))
|
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Declare license dependencies $(2) for non-module target $(1)
|
|
|
|
###########################################################
|
|
|
|
define declare-license-deps
|
|
|
|
$(strip \
|
2022-09-13 04:53:23 +02:00
|
|
|
$(eval _tgt := $(subst //,/,$(strip $(1)))) \
|
2021-04-15 19:41:38 +02:00
|
|
|
$(eval ALL_NON_MODULES += $(_tgt)) \
|
2022-09-13 04:09:52 +02:00
|
|
|
$(eval ALL_TARGETS.$(_tgt).META_LIC := $(call license-metadata-dir,$(1))/$(patsubst $(OUT_DIR)%,out%,$(_tgt)).meta_lic) \
|
2021-04-15 19:41:38 +02:00
|
|
|
$(eval ALL_NON_MODULES.$(_tgt).DEPENDENCIES := $(strip $(ALL_NON_MODULES.$(_tgt).DEPENDENCIES) $(2))) \
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Declare license dependencies $(2) for non-module container-type target $(1)
|
|
|
|
##
|
|
|
|
## Container-type targets are targets like .zip files that
|
|
|
|
## merely aggregate other files.
|
|
|
|
##
|
|
|
|
## $(3) -- root mappings space-separated source:target
|
|
|
|
###########################################################
|
|
|
|
define declare-container-license-deps
|
|
|
|
$(strip \
|
2022-09-13 04:53:23 +02:00
|
|
|
$(eval _tgt := $(subst //,/,$(strip $(1)))) \
|
2021-04-15 19:41:38 +02:00
|
|
|
$(eval ALL_NON_MODULES += $(_tgt)) \
|
2022-09-13 04:09:52 +02:00
|
|
|
$(eval ALL_TARGETS.$(_tgt).META_LIC := $(call license-metadata-dir,$(1))/$(patsubst $(OUT_DIR)%,out%,$(_tgt)).meta_lic) \
|
2021-04-15 19:41:38 +02:00
|
|
|
$(eval ALL_NON_MODULES.$(_tgt).DEPENDENCIES := $(strip $(ALL_NON_MODULES.$(_tgt).DEPENDENCIES) $(2))) \
|
|
|
|
$(eval ALL_NON_MODULES.$(_tgt).IS_CONTAINER := true) \
|
|
|
|
$(eval ALL_NON_MODULES.$(_tgt).ROOT_MAPPINGS := $(strip $(ALL_NON_MODULES.$(_tgt).ROOT_MAPPINGS) $(3))) \
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Declares the rule to report targets with no license metadata.
|
|
|
|
###########################################################
|
|
|
|
define report-missing-licenses-rule
|
|
|
|
.PHONY: reportmissinglicenses
|
2022-06-14 20:18:45 +02:00
|
|
|
reportmissinglicenses: PRIVATE_NON_MODULES:=$(sort $(NON_MODULES_WITHOUT_LICENSE_METADATA) $(TARGETS_MISSING_LICENSE_METADATA))
|
|
|
|
reportmissinglicenses: PRIVATE_COPIED_FILES:=$(sort $(filter $(NON_MODULES_WITHOUT_LICENSE_METADATA) $(TARGETS_MISSING_LICENSE_METADATA),\
|
|
|
|
$(foreach _pair,$(PRODUCT_COPY_FILES), $(PRODUCT_OUT)/$(call word-colon,2,$(_pair)))))
|
2021-04-15 19:41:38 +02:00
|
|
|
reportmissinglicenses:
|
|
|
|
@echo Reporting $$(words $$(PRIVATE_NON_MODULES)) targets without license metadata
|
|
|
|
$$(foreach t,$$(PRIVATE_NON_MODULES),if ! [ -h $$(t) ]; then echo No license metadata for $$(t) >&2; fi;)
|
2022-02-13 00:39:22 +01:00
|
|
|
$$(foreach t,$$(PRIVATE_COPIED_FILES),if ! [ -h $$(t) ]; then echo No license metadata for copied file $$(t) >&2; fi;)
|
2022-06-14 20:18:45 +02:00
|
|
|
echo $$(words $$(PRIVATE_NON_MODULES)) targets missing license metadata >&2
|
2021-04-15 19:41:38 +02:00
|
|
|
|
|
|
|
endef
|
|
|
|
|
2022-03-01 05:05:44 +01:00
|
|
|
|
|
|
|
###########################################################
|
|
|
|
# Returns the unique list of built license metadata files.
|
|
|
|
###########################################################
|
|
|
|
define all-license-metadata
|
|
|
|
$(sort \
|
|
|
|
$(foreach t,$(ALL_NON_MODULES),$(if $(filter 0p,$(ALL_TARGETS.$(t).META_LIC)),, $(ALL_TARGETS.$(t).META_LIC))) \
|
|
|
|
$(foreach m,$(ALL_MODULES), $(ALL_MODULES.$(m).META_LIC)) \
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
# Declares the rule to report all library names used in any notice files.
|
|
|
|
###########################################################
|
|
|
|
define report-all-notice-library-names-rule
|
|
|
|
$(strip $(eval _all := $(call all-license-metadata)))
|
|
|
|
|
|
|
|
.PHONY: reportallnoticelibrarynames
|
2022-09-13 04:09:52 +02:00
|
|
|
reportallnoticelibrarynames: PRIVATE_LIST_FILE := $(call license-metadata-dir,COMMON)/filelist
|
2022-03-01 05:05:44 +01:00
|
|
|
reportallnoticelibrarynames: | $(COMPLIANCENOTICE_SHIPPEDLIBS)
|
|
|
|
reportallnoticelibrarynames: $(_all)
|
|
|
|
@echo Reporting notice library names for at least $$(words $(_all)) license metadata files
|
|
|
|
$(hide) rm -f $$(PRIVATE_LIST_FILE)
|
|
|
|
$(hide) mkdir -p $$(dir $$(PRIVATE_LIST_FILE))
|
|
|
|
$(hide) find out -name '*meta_lic' -type f -printf '"%p"\n' >$$(PRIVATE_LIST_FILE)
|
2022-03-22 21:05:19 +01:00
|
|
|
OUT_DIR=$(OUT_DIR) $(COMPLIANCENOTICE_SHIPPEDLIBS) @$$(PRIVATE_LIST_FILE)
|
2022-03-01 05:05:44 +01:00
|
|
|
endef
|
|
|
|
|
2022-03-09 22:38:37 +01:00
|
|
|
###########################################################
|
|
|
|
# Declares the rule to build all license metadata.
|
|
|
|
###########################################################
|
|
|
|
define build-all-license-metadata-rule
|
|
|
|
$(strip $(eval _all := $(call all-license-metadata)))
|
|
|
|
|
|
|
|
.PHONY: alllicensemetadata
|
|
|
|
alllicensemetadata: $(_all)
|
|
|
|
@echo Building all $(words $(_all)) license metadata files
|
|
|
|
endef
|
|
|
|
|
|
|
|
|
2021-01-07 04:34:31 +01:00
|
|
|
###########################################################
|
|
|
|
## Declares a license metadata build rule for ALL_MODULES
|
|
|
|
###########################################################
|
|
|
|
define build-license-metadata
|
2021-04-15 19:41:38 +02:00
|
|
|
$(strip \
|
|
|
|
$(foreach t,$(sort $(ALL_0P_TARGETS)), \
|
|
|
|
$(eval ALL_TARGETS.$(t).META_LIC := 0p) \
|
|
|
|
) \
|
2022-09-07 05:15:01 +02:00
|
|
|
$(foreach t,$(sort $(ALL_COPIED_TARGETS)),$(eval $(call copied-target-license-metadata-rule,$(t)))) \
|
2021-12-03 23:46:20 +01:00
|
|
|
$(foreach t,$(sort $(ALL_NON_MODULES)),$(eval $(call non-module-license-metadata-rule,$(t)))) \
|
|
|
|
$(foreach m,$(sort $(ALL_MODULES)),$(eval $(call license-metadata-rule,$(m)))) \
|
2022-03-09 22:38:37 +01:00
|
|
|
$(eval $(call build-all-license-metadata-rule)))
|
2021-01-07 04:34:31 +01:00
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
2016-08-02 02:41:49 +02:00
|
|
|
## Returns correct _idfPrefix from the list:
|
2020-03-07 03:09:06 +01:00
|
|
|
## { HOST, HOST_CROSS, TARGET }
|
2016-08-02 02:41:49 +02:00
|
|
|
###########################################################
|
|
|
|
# the following rules checked in order:
|
2020-03-07 03:09:06 +01:00
|
|
|
# ($1 is in {HOST_CROSS} => $1;
|
2016-08-02 02:41:49 +02:00
|
|
|
# ($1 is empty) => TARGET;
|
|
|
|
# ($2 is not empty) => HOST_CROSS;
|
|
|
|
# => HOST;
|
|
|
|
define find-idf-prefix
|
|
|
|
$(strip \
|
2020-03-07 03:09:06 +01:00
|
|
|
$(eval _idf_pfx_:=$(strip $(filter HOST_CROSS,$(1)))) \
|
2016-08-02 02:41:49 +02:00
|
|
|
$(eval _idf_pfx_:=$(if $(strip $(1)),$(if $(_idf_pfx_),$(_idf_pfx_),$(if $(strip $(2)),HOST_CROSS,HOST)),TARGET)) \
|
|
|
|
$(_idf_pfx_)
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2020-06-09 15:36:03 +02:00
|
|
|
###########################################################
|
2009-03-04 04:28:42 +01:00
|
|
|
## The intermediates directory. Where object files go for
|
|
|
|
## a given target. We could technically get away without
|
|
|
|
## the "_intermediates" suffix on the directory, but it's
|
|
|
|
## nice to be able to grep for that string to find out if
|
|
|
|
## anyone's abusing the system.
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
# $(1): target class, like "APPS"
|
|
|
|
# $(2): target name, like "NotePad"
|
2020-03-07 03:09:06 +01:00
|
|
|
# $(3): { HOST, HOST_CROSS, <empty (TARGET)>, <other non-empty (HOST)> }
|
2009-03-04 04:28:42 +01:00
|
|
|
# $(4): if non-empty, force the intermediates to be COMMON
|
2015-08-14 21:59:50 +02:00
|
|
|
# $(5): if non-empty, force the intermediates to be for the 2nd arch
|
|
|
|
# $(6): if non-empty, force the intermediates to be for the host cross os
|
2009-03-04 04:28:42 +01:00
|
|
|
define intermediates-dir-for
|
|
|
|
$(strip \
|
|
|
|
$(eval _idfClass := $(strip $(1))) \
|
|
|
|
$(if $(_idfClass),, \
|
|
|
|
$(error $(LOCAL_PATH): Class not defined in call to intermediates-dir-for)) \
|
|
|
|
$(eval _idfName := $(strip $(2))) \
|
|
|
|
$(if $(_idfName),, \
|
|
|
|
$(error $(LOCAL_PATH): Name not defined in call to intermediates-dir-for)) \
|
2016-08-02 02:41:49 +02:00
|
|
|
$(eval _idfPrefix := $(call find-idf-prefix,$(3),$(6))) \
|
2014-06-18 06:35:44 +02:00
|
|
|
$(eval _idf2ndArchPrefix := $(if $(strip $(5)),$(TARGET_2ND_ARCH_VAR_PREFIX))) \
|
2020-06-09 06:00:18 +02:00
|
|
|
$(if $(filter $(_idfPrefix)_$(_idfClass),$(COMMON_MODULE_CLASSES))$(4), \
|
2009-03-04 04:28:42 +01:00
|
|
|
$(eval _idfIntBase := $($(_idfPrefix)_OUT_COMMON_INTERMEDIATES)) \
|
2016-02-13 09:19:40 +01:00
|
|
|
,$(if $(filter $(_idfClass),$(PER_ARCH_MODULE_CLASSES)),\
|
2014-01-24 22:38:08 +01:00
|
|
|
$(eval _idfIntBase := $($(_idf2ndArchPrefix)$(_idfPrefix)_OUT_INTERMEDIATES)) \
|
|
|
|
,$(eval _idfIntBase := $($(_idfPrefix)_OUT_INTERMEDIATES)) \
|
|
|
|
) \
|
2009-03-04 04:28:42 +01:00
|
|
|
) \
|
|
|
|
$(_idfIntBase)/$(_idfClass)/$(_idfName)_intermediates \
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
|
|
|
# Uses LOCAL_MODULE_CLASS, LOCAL_MODULE, and LOCAL_IS_HOST_MODULE
|
|
|
|
# to determine the intermediates directory.
|
|
|
|
#
|
|
|
|
# $(1): if non-empty, force the intermediates to be COMMON
|
2014-01-16 01:02:16 +01:00
|
|
|
# $(2): if non-empty, force the intermediates to be for the 2nd arch
|
2015-08-14 21:59:50 +02:00
|
|
|
# $(3): if non-empty, force the intermediates to be for the host cross os
|
2009-03-04 04:28:42 +01:00
|
|
|
define local-intermediates-dir
|
|
|
|
$(strip \
|
|
|
|
$(if $(strip $(LOCAL_MODULE_CLASS)),, \
|
|
|
|
$(error $(LOCAL_PATH): LOCAL_MODULE_CLASS not defined before call to local-intermediates-dir)) \
|
|
|
|
$(if $(strip $(LOCAL_MODULE)),, \
|
|
|
|
$(error $(LOCAL_PATH): LOCAL_MODULE not defined before call to local-intermediates-dir)) \
|
2020-03-07 03:09:06 +01:00
|
|
|
$(call intermediates-dir-for,$(LOCAL_MODULE_CLASS),$(LOCAL_MODULE),$(if $(strip $(LOCAL_IS_HOST_MODULE)),HOST),$(1),$(2),$(3)) \
|
2009-03-04 04:28:42 +01:00
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2022-06-14 20:18:45 +02:00
|
|
|
# Uses LOCAL_MODULE_CLASS, LOCAL_MODULE, and LOCAL_IS_HOST_MODULE
|
|
|
|
# to determine the intermediates directory.
|
|
|
|
#
|
|
|
|
# $(1): if non-empty, force the intermediates to be COMMON
|
|
|
|
# $(2): if non-empty, force the intermediates to be for the 2nd arch
|
|
|
|
# $(3): if non-empty, force the intermediates to be for the host cross os
|
|
|
|
define local-meta-intermediates-dir
|
|
|
|
$(strip \
|
|
|
|
$(if $(strip $(LOCAL_MODULE_CLASS)),, \
|
|
|
|
$(error $(LOCAL_PATH): LOCAL_MODULE_CLASS not defined before call to local-meta-intermediates-dir)) \
|
|
|
|
$(if $(strip $(LOCAL_MODULE)),, \
|
|
|
|
$(error $(LOCAL_PATH): LOCAL_MODULE not defined before call to local-meta-intermediates-dir)) \
|
|
|
|
$(call intermediates-dir-for,META$(LOCAL_MODULE_CLASS),$(LOCAL_MODULE),$(if $(strip $(LOCAL_IS_HOST_MODULE)),HOST),$(1),$(2),$(3)) \
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2009-03-04 04:28:42 +01:00
|
|
|
###########################################################
|
2014-01-25 08:17:21 +01:00
|
|
|
## The generated sources directory. Placing generated
|
|
|
|
## source files directly in the intermediates directory
|
|
|
|
## causes problems for multiarch builds, where there are
|
|
|
|
## two intermediates directories for a single target. Put
|
|
|
|
## them in a separate directory, and they will be copied to
|
|
|
|
## each intermediates directory automatically.
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
# $(1): target class, like "APPS"
|
|
|
|
# $(2): target name, like "NotePad"
|
2020-03-07 03:09:06 +01:00
|
|
|
# $(3): { HOST, HOST_CROSS, <empty (TARGET)>, <other non-empty (HOST)> }
|
2014-01-25 08:17:21 +01:00
|
|
|
# $(4): if non-empty, force the generated sources to be COMMON
|
|
|
|
define generated-sources-dir-for
|
|
|
|
$(strip \
|
|
|
|
$(eval _idfClass := $(strip $(1))) \
|
|
|
|
$(if $(_idfClass),, \
|
|
|
|
$(error $(LOCAL_PATH): Class not defined in call to generated-sources-dir-for)) \
|
|
|
|
$(eval _idfName := $(strip $(2))) \
|
|
|
|
$(if $(_idfName),, \
|
|
|
|
$(error $(LOCAL_PATH): Name not defined in call to generated-sources-dir-for)) \
|
2016-08-02 02:41:49 +02:00
|
|
|
$(eval _idfPrefix := $(call find-idf-prefix,$(3),)) \
|
2020-06-09 06:00:18 +02:00
|
|
|
$(if $(filter $(_idfPrefix)_$(_idfClass),$(COMMON_MODULE_CLASSES))$(4), \
|
2015-11-25 14:14:23 +01:00
|
|
|
$(eval _idfIntBase := $($(_idfPrefix)_OUT_COMMON_GEN)) \
|
2014-01-25 08:17:21 +01:00
|
|
|
, \
|
|
|
|
$(eval _idfIntBase := $($(_idfPrefix)_OUT_GEN)) \
|
|
|
|
) \
|
|
|
|
$(_idfIntBase)/$(_idfClass)/$(_idfName)_intermediates \
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
|
|
|
# Uses LOCAL_MODULE_CLASS, LOCAL_MODULE, and LOCAL_IS_HOST_MODULE
|
|
|
|
# to determine the generated sources directory.
|
|
|
|
#
|
|
|
|
# $(1): if non-empty, force the intermediates to be COMMON
|
|
|
|
define local-generated-sources-dir
|
|
|
|
$(strip \
|
|
|
|
$(if $(strip $(LOCAL_MODULE_CLASS)),, \
|
|
|
|
$(error $(LOCAL_PATH): LOCAL_MODULE_CLASS not defined before call to local-generated-sources-dir)) \
|
|
|
|
$(if $(strip $(LOCAL_MODULE)),, \
|
|
|
|
$(error $(LOCAL_PATH): LOCAL_MODULE not defined before call to local-generated-sources-dir)) \
|
2020-03-07 03:09:06 +01:00
|
|
|
$(call generated-sources-dir-for,$(LOCAL_MODULE_CLASS),$(LOCAL_MODULE),$(if $(strip $(LOCAL_IS_HOST_MODULE)),HOST),$(1)) \
|
2014-01-25 08:17:21 +01:00
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2021-04-07 03:04:06 +02:00
|
|
|
###########################################################
|
|
|
|
## The packaging directory for a module. Similar to intermedates, but
|
|
|
|
## in a location that will be wiped by an m installclean.
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
# $(1): subdir in PACKAGING
|
|
|
|
# $(2): target class, like "APPS"
|
|
|
|
# $(3): target name, like "NotePad"
|
|
|
|
# $(4): { HOST, HOST_CROSS, <empty (TARGET)>, <other non-empty (HOST)> }
|
|
|
|
define packaging-dir-for
|
|
|
|
$(strip \
|
|
|
|
$(eval _pdfClass := $(strip $(2))) \
|
|
|
|
$(if $(_pdfClass),, \
|
|
|
|
$(error $(LOCAL_PATH): Class not defined in call to generated-sources-dir-for)) \
|
|
|
|
$(eval _pdfName := $(strip $(3))) \
|
|
|
|
$(if $(_pdfName),, \
|
|
|
|
$(error $(LOCAL_PATH): Name not defined in call to generated-sources-dir-for)) \
|
|
|
|
$(call intermediates-dir-for,PACKAGING,$(1),$(4))/$(_pdfClass)/$(_pdfName)_intermediates \
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
|
|
|
# Uses LOCAL_MODULE_CLASS, LOCAL_MODULE, and LOCAL_IS_HOST_MODULE
|
|
|
|
# to determine the packaging directory.
|
|
|
|
#
|
|
|
|
# $(1): subdir in PACKAGING
|
|
|
|
define local-packaging-dir
|
|
|
|
$(strip \
|
|
|
|
$(if $(strip $(LOCAL_MODULE_CLASS)),, \
|
|
|
|
$(error $(LOCAL_PATH): LOCAL_MODULE_CLASS not defined before call to local-generated-sources-dir)) \
|
|
|
|
$(if $(strip $(LOCAL_MODULE)),, \
|
|
|
|
$(error $(LOCAL_PATH): LOCAL_MODULE not defined before call to local-generated-sources-dir)) \
|
|
|
|
$(call packaging-dir-for,$(1),$(LOCAL_MODULE_CLASS),$(LOCAL_MODULE),$(if $(strip $(LOCAL_IS_HOST_MODULE)),HOST)) \
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
|
|
|
|
2009-03-04 04:28:42 +01:00
|
|
|
###########################################################
|
|
|
|
## Convert a list of short module names (e.g., "framework", "Browser")
|
|
|
|
## into the list of files that are built for those modules.
|
|
|
|
## NOTE: this won't return reliable results until after all
|
|
|
|
## sub-makefiles have been included.
|
|
|
|
## $(1): target list
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define module-built-files
|
|
|
|
$(foreach module,$(1),$(ALL_MODULES.$(module).BUILT))
|
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Convert a list of short modules names (e.g., "framework", "Browser")
|
|
|
|
## into the list of files that are installed for those modules.
|
|
|
|
## NOTE: this won't return reliable results until after all
|
|
|
|
## sub-makefiles have been included.
|
|
|
|
## $(1): target list
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define module-installed-files
|
|
|
|
$(foreach module,$(1),$(ALL_MODULES.$(module).INSTALLED))
|
|
|
|
endef
|
|
|
|
|
2019-01-19 04:37:47 +01:00
|
|
|
###########################################################
|
|
|
|
## Convert a list of short modules names (e.g., "framework", "Browser")
|
|
|
|
## into the list of files that are built *for the target* for those modules.
|
|
|
|
## NOTE: this won't return reliable results until after all
|
|
|
|
## sub-makefiles have been included.
|
|
|
|
## $(1): target list
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define module-target-built-files
|
|
|
|
$(foreach module,$(1),$(ALL_MODULES.$(module).TARGET_BUILT))
|
|
|
|
endef
|
|
|
|
|
2009-04-10 04:31:12 +02:00
|
|
|
###########################################################
|
|
|
|
## Convert a list of short modules names (e.g., "framework", "Browser")
|
|
|
|
## into the list of files that should be used when linking
|
|
|
|
## against that module as a public API.
|
|
|
|
## TODO: Allow this for more than JAVA_LIBRARIES modules
|
|
|
|
## NOTE: this won't return reliable results until after all
|
|
|
|
## sub-makefiles have been included.
|
|
|
|
## $(1): target list
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define module-stubs-files
|
2018-06-04 07:14:18 +02:00
|
|
|
$(foreach module,$(1),$(if $(filter $(module),$(JAVA_SDK_LIBRARIES)),\
|
|
|
|
$(call java-lib-files,$(module).stubs),$(ALL_MODULES.$(module).STUBS)))
|
2009-04-10 04:31:12 +02:00
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Evaluates to the timestamp file for a doc module, which
|
|
|
|
## is the dependency that should be used.
|
|
|
|
## $(1): doc module
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define doc-timestamp-for
|
|
|
|
$(OUT_DOCS)/$(strip $(1))-timestamp
|
|
|
|
endef
|
|
|
|
|
|
|
|
|
2009-03-04 04:28:42 +01:00
|
|
|
###########################################################
|
2010-09-29 02:27:56 +02:00
|
|
|
## Convert "core ext framework" to "out/.../javalib.jar ..."
|
2009-03-04 04:28:42 +01:00
|
|
|
## $(1): library list
|
|
|
|
## $(2): Non-empty if IS_HOST_MODULE
|
|
|
|
###########################################################
|
|
|
|
|
2016-03-03 02:25:01 +01:00
|
|
|
# Get the jar files (you can pass to "javac -classpath") of static or shared
|
|
|
|
# Java libraries that you want to link against.
|
2009-03-04 04:28:42 +01:00
|
|
|
# $(1): library name list
|
|
|
|
# $(2): Non-empty if IS_HOST_MODULE
|
|
|
|
define java-lib-files
|
2017-09-26 23:55:43 +02:00
|
|
|
$(foreach lib,$(1),$(call intermediates-dir-for,JAVA_LIBRARIES,$(lib),$(2),COMMON)/classes.jar)
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
2017-08-31 23:43:04 +02:00
|
|
|
# Get the header jar files (you can pass to "javac -classpath") of static or shared
|
|
|
|
# Java libraries that you want to link against.
|
|
|
|
# $(1): library name list
|
|
|
|
# $(2): Non-empty if IS_HOST_MODULE
|
2017-09-27 01:17:24 +02:00
|
|
|
ifneq ($(TURBINE_ENABLED),false)
|
2017-08-31 23:43:04 +02:00
|
|
|
define java-lib-header-files
|
2017-09-26 23:55:43 +02:00
|
|
|
$(foreach lib,$(1),$(call intermediates-dir-for,JAVA_LIBRARIES,$(lib),$(2),COMMON)/classes-header.jar)
|
2017-08-31 23:43:04 +02:00
|
|
|
endef
|
2017-09-27 01:17:24 +02:00
|
|
|
else
|
|
|
|
define java-lib-header-files
|
|
|
|
$(call java-lib-files,$(1),$(2))
|
|
|
|
endef
|
|
|
|
endif
|
2017-08-31 23:43:04 +02:00
|
|
|
|
2016-03-03 02:25:01 +01:00
|
|
|
# Get the dependency files (you can put on the right side of "|" of a build rule)
|
|
|
|
# of the Java libraries.
|
|
|
|
# $(1): library name list
|
2009-03-04 04:28:42 +01:00
|
|
|
# $(2): Non-empty if IS_HOST_MODULE
|
2016-03-03 02:25:01 +01:00
|
|
|
# Historically for target Java libraries we used a different file (javalib.jar)
|
|
|
|
# as the dependency.
|
|
|
|
# Now we can use classes.jar as dependency, so java-lib-deps is the same
|
|
|
|
# as java-lib-files.
|
|
|
|
define java-lib-deps
|
|
|
|
$(call java-lib-files,$(1),$(2))
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
2017-09-26 23:55:43 +02:00
|
|
|
# Get the jar files (you can pass to "javac -classpath") of static or shared
|
|
|
|
# APK libraries that you want to link against.
|
|
|
|
# $(1): library name list
|
|
|
|
define app-lib-files
|
|
|
|
$(foreach lib,$(1),$(call intermediates-dir-for,APPS,$(lib),,COMMON)/classes.jar)
|
|
|
|
endef
|
|
|
|
|
|
|
|
# Get the header jar files (you can pass to "javac -classpath") of static or shared
|
|
|
|
# APK libraries that you want to link against.
|
|
|
|
# $(1): library name list
|
2017-09-27 01:17:24 +02:00
|
|
|
ifneq ($(TURBINE_ENABLED),false)
|
2017-09-26 23:55:43 +02:00
|
|
|
define app-lib-header-files
|
|
|
|
$(foreach lib,$(1),$(call intermediates-dir-for,APPS,$(lib),,COMMON)/classes-header.jar)
|
|
|
|
endef
|
2017-09-27 01:17:24 +02:00
|
|
|
else
|
|
|
|
define app-lib-header-files
|
|
|
|
$(call app-lib-files,$(1))
|
|
|
|
endef
|
|
|
|
endif
|
2009-03-04 04:28:42 +01:00
|
|
|
|
2018-05-22 08:39:59 +02:00
|
|
|
# Get the exported-sdk-libs files which collectively give you the list of exported java sdk
|
|
|
|
# lib names that are (transitively) exported from the given set of java libs
|
|
|
|
# $(1): library name list
|
|
|
|
define exported-sdk-libs-files
|
|
|
|
$(foreach lib,$(1),$(call intermediates-dir-for,JAVA_LIBRARIES,$(lib),,COMMON)/exported-sdk-libs)
|
|
|
|
endef
|
|
|
|
|
2009-03-04 04:28:42 +01:00
|
|
|
###########################################################
|
|
|
|
## MODULE_TAG set operations
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
# Given a list of tags, return the targets that specify
|
|
|
|
# any of those tags.
|
|
|
|
# $(1): tag list
|
|
|
|
define modules-for-tag-list
|
2014-11-18 21:41:53 +01:00
|
|
|
$(sort $(foreach tag,$(1),$(foreach m,$(ALL_MODULE_NAME_TAGS.$(tag)),$(ALL_MODULES.$(m).INSTALLED))))
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
|
|
|
# Same as modules-for-tag-list, but operates on
|
|
|
|
# ALL_MODULE_NAME_TAGS.
|
|
|
|
# $(1): tag list
|
|
|
|
define module-names-for-tag-list
|
|
|
|
$(sort $(foreach tag,$(1),$(ALL_MODULE_NAME_TAGS.$(tag))))
|
|
|
|
endef
|
|
|
|
|
|
|
|
# Given an accept and reject list, find the matching
|
|
|
|
# set of targets. If a target has multiple tags and
|
|
|
|
# any of them are rejected, the target is rejected.
|
|
|
|
# Reject overrides accept.
|
|
|
|
# $(1): list of tags to accept
|
|
|
|
# $(2): list of tags to reject
|
|
|
|
#TODO(dbort): do $(if $(strip $(1)),$(1),$(ALL_MODULE_TAGS))
|
2010-01-07 20:44:22 +01:00
|
|
|
#TODO(jbq): as of 20100106 nobody uses the second parameter
|
2009-03-04 04:28:42 +01:00
|
|
|
define get-tagged-modules
|
|
|
|
$(filter-out \
|
2019-05-29 00:09:53 +02:00
|
|
|
$(call modules-for-tag-list,$(2)), \
|
|
|
|
$(call modules-for-tag-list,$(1)))
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
2009-04-10 04:31:12 +02:00
|
|
|
###########################################################
|
|
|
|
## Append a leaf to a base path. Properly deals with
|
|
|
|
## base paths ending in /.
|
|
|
|
##
|
|
|
|
## $(1): base path
|
|
|
|
## $(2): leaf path
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define append-path
|
|
|
|
$(subst //,/,$(1)/$(2))
|
|
|
|
endef
|
|
|
|
|
2009-03-04 04:28:42 +01:00
|
|
|
|
2016-06-16 04:20:57 +02:00
|
|
|
###########################################################
|
2017-02-16 00:48:11 +01:00
|
|
|
## Color-coded warnings and errors
|
|
|
|
## Use echo-(warning|error) in a build rule
|
|
|
|
## Use pretty-(warning|error) instead of $(warning)/$(error)
|
2016-06-16 04:20:57 +02:00
|
|
|
###########################################################
|
2017-06-01 04:20:09 +02:00
|
|
|
ESC_BOLD := \033[1m
|
|
|
|
ESC_WARNING := \033[35m
|
|
|
|
ESC_ERROR := \033[31m
|
|
|
|
ESC_RESET := \033[0m
|
2017-02-16 00:48:11 +01:00
|
|
|
|
|
|
|
# $(1): path (and optionally line) information
|
|
|
|
# $(2): message to print
|
2016-06-16 04:20:57 +02:00
|
|
|
define echo-warning
|
2018-11-05 13:02:46 +01:00
|
|
|
echo -e "$(ESC_BOLD)$(1): $(ESC_WARNING)warning:$(ESC_RESET)$(ESC_BOLD)" '$(subst ','\'',$(2))' "$(ESC_RESET)" >&2
|
2016-06-16 04:20:57 +02:00
|
|
|
endef
|
|
|
|
|
2017-02-16 00:48:11 +01:00
|
|
|
# $(1): path (and optionally line) information
|
|
|
|
# $(2): message to print
|
2016-06-16 04:20:57 +02:00
|
|
|
define echo-error
|
2018-11-05 13:02:46 +01:00
|
|
|
echo -e "$(ESC_BOLD)$(1): $(ESC_ERROR)error:$(ESC_RESET)$(ESC_BOLD)" '$(subst ','\'',$(2))' "$(ESC_RESET)" >&2
|
2016-06-16 04:20:57 +02:00
|
|
|
endef
|
|
|
|
|
2009-03-04 04:28:42 +01:00
|
|
|
###########################################################
|
2018-10-19 01:11:40 +02:00
|
|
|
## Legacy showcommands compatibility
|
2009-03-04 04:28:42 +01:00
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define pretty
|
|
|
|
@echo $1
|
|
|
|
endef
|
|
|
|
|
2016-01-25 10:59:43 +01:00
|
|
|
###########################################################
|
|
|
|
## Commands for including the dependency files the compiler generates
|
|
|
|
###########################################################
|
|
|
|
# $(1): the .P file
|
|
|
|
# $(2): the main build target
|
|
|
|
define include-depfile
|
|
|
|
$(eval $(2) : .KATI_DEPFILE := $1)
|
|
|
|
endef
|
|
|
|
|
2016-03-03 10:12:52 +01:00
|
|
|
# $(1): object files
|
|
|
|
define include-depfiles-for-objs
|
2016-11-11 03:19:36 +01:00
|
|
|
$(foreach obj, $(1), $(call include-depfile, $(obj:%.o=%.d), $(obj)))
|
2016-03-03 10:12:52 +01:00
|
|
|
endef
|
|
|
|
|
2016-01-20 05:07:08 +01:00
|
|
|
###########################################################
|
|
|
|
## Track source files compiled to objects
|
|
|
|
###########################################################
|
|
|
|
# $(1): list of sources
|
|
|
|
# $(2): list of matching objects
|
|
|
|
define track-src-file-obj
|
|
|
|
$(eval $(call _track-src-file-obj,$(1)))
|
|
|
|
endef
|
|
|
|
define _track-src-file-obj
|
|
|
|
i := w
|
|
|
|
$(foreach s,$(1),
|
|
|
|
my_tracked_src_files += $(s)
|
|
|
|
my_src_file_obj_$(s) := $$(word $$(words $$(i)),$$(2))
|
|
|
|
i += w)
|
|
|
|
endef
|
|
|
|
|
|
|
|
# $(1): list of sources
|
|
|
|
# $(2): list of matching generated sources
|
|
|
|
define track-src-file-gen
|
|
|
|
$(eval $(call _track-src-file-gen,$(2)))
|
|
|
|
endef
|
|
|
|
define _track-src-file-gen
|
|
|
|
i := w
|
|
|
|
$(foreach s,$(1),
|
|
|
|
my_tracked_gen_files += $(s)
|
|
|
|
my_src_file_gen_$(s) := $$(word $$(words $$(i)),$$(1))
|
|
|
|
i += w)
|
|
|
|
endef
|
|
|
|
|
|
|
|
# $(1): list of generated sources
|
|
|
|
# $(2): list of matching objects
|
|
|
|
define track-gen-file-obj
|
|
|
|
$(call track-src-file-obj,$(foreach f,$(1),\
|
|
|
|
$(or $(my_src_file_gen_$(f)),$(f))),$(2))
|
|
|
|
endef
|
|
|
|
|
2009-03-04 04:28:42 +01:00
|
|
|
###########################################################
|
|
|
|
## Commands for running lex
|
|
|
|
###########################################################
|
|
|
|
|
2016-01-12 01:28:45 +01:00
|
|
|
define transform-l-to-c-or-cpp
|
2009-03-04 04:28:42 +01:00
|
|
|
@echo "Lex: $(PRIVATE_MODULE) <= $<"
|
2015-07-17 02:14:27 +02:00
|
|
|
@mkdir -p $(dir $@)
|
2020-01-09 07:31:12 +01:00
|
|
|
M4=$(M4) $(LEX) -o$@ $<
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Commands for running yacc
|
|
|
|
##
|
|
|
|
###########################################################
|
|
|
|
|
2016-01-12 01:28:45 +01:00
|
|
|
define transform-y-to-c-or-cpp
|
2009-03-04 04:28:42 +01:00
|
|
|
@echo "Yacc: $(PRIVATE_MODULE) <= $<"
|
2015-07-17 02:14:27 +02:00
|
|
|
@mkdir -p $(dir $@)
|
2020-01-09 07:31:12 +01:00
|
|
|
M4=$(M4) $(YACC) $(PRIVATE_YACCFLAGS) \
|
2016-01-12 01:28:45 +01:00
|
|
|
--defines=$(basename $@).h \
|
|
|
|
-o $@ $<
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
2010-07-16 02:17:52 +02:00
|
|
|
###########################################################
|
2012-10-30 00:06:00 +01:00
|
|
|
## Commands to compile RenderScript to Java
|
2010-07-16 02:17:52 +02:00
|
|
|
###########################################################
|
|
|
|
|
2016-02-01 09:59:01 +01:00
|
|
|
## Merge multiple .d files generated by llvm-rs-cc. This is necessary
|
|
|
|
## because ninja can handle only a single depfile per build target.
|
|
|
|
## .d files generated by llvm-rs-cc define .stamp, .bc, and optionally
|
|
|
|
## .java as build targets. However, there's no way to let ninja know
|
|
|
|
## dependencies to .bc files and .java files, so we give up build
|
|
|
|
## targets for them. As we write the .stamp file as the target by
|
|
|
|
## ourselves, the awk script removes the first lines before the colon
|
|
|
|
## and append a backslash to the last line to concatenate contents of
|
|
|
|
## multiple files.
|
|
|
|
# $(1): .d files to be merged
|
|
|
|
# $(2): merged .d file
|
|
|
|
define _merge-renderscript-d
|
|
|
|
$(hide) echo '$@: $(backslash)' > $2
|
|
|
|
$(foreach d,$1, \
|
|
|
|
$(hide) awk 'start { sub(/( \\)?$$/, " \\"); print } /:/ { start=1 }' < $d >> $2$(newline))
|
|
|
|
$(hide) echo >> $2
|
|
|
|
endef
|
|
|
|
|
2017-04-28 03:25:50 +02:00
|
|
|
# b/37755219
|
|
|
|
RS_CC_ASAN_OPTIONS := ASAN_OPTIONS=detect_leaks=0:detect_container_overflow=0
|
|
|
|
|
2010-07-16 02:17:52 +02:00
|
|
|
define transform-renderscripts-to-java-and-bc
|
|
|
|
@echo "RenderScript: $(PRIVATE_MODULE) <= $(PRIVATE_RS_SOURCE_FILES)"
|
|
|
|
$(hide) rm -rf $(PRIVATE_RS_OUTPUT_DIR)
|
|
|
|
$(hide) mkdir -p $(PRIVATE_RS_OUTPUT_DIR)/res/raw
|
|
|
|
$(hide) mkdir -p $(PRIVATE_RS_OUTPUT_DIR)/src
|
2017-04-28 03:25:50 +02:00
|
|
|
$(hide) $(RS_CC_ASAN_OPTIONS) $(PRIVATE_RS_CC) \
|
2010-07-31 03:37:29 +02:00
|
|
|
-o $(PRIVATE_RS_OUTPUT_DIR)/res/raw \
|
|
|
|
-p $(PRIVATE_RS_OUTPUT_DIR)/src \
|
2010-10-08 03:57:57 +02:00
|
|
|
-d $(PRIVATE_RS_OUTPUT_DIR) \
|
|
|
|
-a $@ -MD \
|
2011-08-10 22:53:05 +02:00
|
|
|
$(addprefix -target-api , $(PRIVATE_RS_TARGET_API)) \
|
2011-12-07 03:43:24 +01:00
|
|
|
$(PRIVATE_RS_FLAGS) \
|
2010-09-01 22:28:52 +02:00
|
|
|
$(foreach inc,$(PRIVATE_RS_INCLUDES),$(addprefix -I , $(inc))) \
|
2010-07-31 03:37:29 +02:00
|
|
|
$(PRIVATE_RS_SOURCE_FILES)
|
2018-03-13 07:39:27 +01:00
|
|
|
$(SOONG_ZIP) -o $@ -C $(PRIVATE_RS_OUTPUT_DIR)/src -D $(PRIVATE_RS_OUTPUT_DIR)/src
|
|
|
|
$(SOONG_ZIP) -o $(PRIVATE_RS_OUTPUT_RES_ZIP) -C $(PRIVATE_RS_OUTPUT_DIR)/res -D $(PRIVATE_RS_OUTPUT_DIR)/res
|
2016-02-01 09:59:01 +01:00
|
|
|
$(call _merge-renderscript-d,$(PRIVATE_DEP_FILES),$@.d)
|
2010-07-16 02:17:52 +02:00
|
|
|
endef
|
|
|
|
|
2012-11-29 01:52:41 +01:00
|
|
|
define transform-bc-to-so
|
2013-02-27 09:51:08 +01:00
|
|
|
@echo "Renderscript compatibility: $(notdir $@) <= $(notdir $<)"
|
2012-11-29 01:52:41 +01:00
|
|
|
$(hide) mkdir -p $(dir $@)
|
2012-12-17 23:23:14 +01:00
|
|
|
$(hide) $(BCC_COMPAT) -O3 -o $(dir $@)/$(notdir $(<:.bc=.o)) -fPIC -shared \
|
2019-05-29 00:09:53 +02:00
|
|
|
-rt-path $(RS_PREBUILT_CLCORE) -mtriple $(RS_COMPAT_TRIPLE) $<
|
2021-06-29 00:49:58 +02:00
|
|
|
$(hide) $(PRIVATE_CXX_LINK) -fuse-ld=lld -target $(CLANG_TARGET_TRIPLE) -shared -Wl,-soname,$(notdir $@) -nostdlib \
|
2019-05-29 00:09:53 +02:00
|
|
|
-Wl,-rpath,\$$ORIGIN/../lib \
|
|
|
|
$(dir $@)/$(notdir $(<:.bc=.o)) \
|
|
|
|
$(RS_PREBUILT_COMPILER_RT) \
|
2021-06-29 00:49:58 +02:00
|
|
|
-o $@ $(CLANG_TARGET_GLOBAL_LLDFLAGS) -Wl,--hash-style=sysv \
|
2019-05-29 00:09:53 +02:00
|
|
|
-L $(SOONG_OUT_DIR)/ndk/platforms/android-$(PRIVATE_SDK_VERSION)/arch-$(TARGET_ARCH)/usr/lib64 \
|
|
|
|
-L $(SOONG_OUT_DIR)/ndk/platforms/android-$(PRIVATE_SDK_VERSION)/arch-$(TARGET_ARCH)/usr/lib \
|
|
|
|
$(call intermediates-dir-for,SHARED_LIBRARIES,libRSSupport)/libRSSupport.so \
|
|
|
|
-lm -lc
|
2012-11-29 01:52:41 +01:00
|
|
|
endef
|
|
|
|
|
2012-10-30 00:06:00 +01:00
|
|
|
###########################################################
|
|
|
|
## Commands to compile RenderScript to C++
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define transform-renderscripts-to-cpp-and-bc
|
|
|
|
@echo "RenderScript: $(PRIVATE_MODULE) <= $(PRIVATE_RS_SOURCE_FILES)"
|
|
|
|
$(hide) rm -rf $(PRIVATE_RS_OUTPUT_DIR)
|
|
|
|
$(hide) mkdir -p $(PRIVATE_RS_OUTPUT_DIR)/
|
2017-04-28 03:25:50 +02:00
|
|
|
$(hide) $(RS_CC_ASAN_OPTIONS) $(PRIVATE_RS_CC) \
|
2012-10-30 00:06:00 +01:00
|
|
|
-o $(PRIVATE_RS_OUTPUT_DIR)/ \
|
|
|
|
-d $(PRIVATE_RS_OUTPUT_DIR) \
|
|
|
|
-a $@ -MD \
|
|
|
|
-reflect-c++ \
|
2015-08-14 02:04:10 +02:00
|
|
|
$(addprefix -target-api , $(PRIVATE_RS_TARGET_API)) \
|
2012-10-30 00:06:00 +01:00
|
|
|
$(PRIVATE_RS_FLAGS) \
|
2014-05-29 01:17:09 +02:00
|
|
|
$(addprefix -I , $(PRIVATE_RS_INCLUDES)) \
|
2012-10-30 00:06:00 +01:00
|
|
|
$(PRIVATE_RS_SOURCE_FILES)
|
2016-01-25 10:59:43 +01:00
|
|
|
$(call _merge-renderscript-d,$(PRIVATE_DEP_FILES),$@.d)
|
2012-10-30 00:06:00 +01:00
|
|
|
$(hide) mkdir -p $(dir $@)
|
|
|
|
$(hide) touch $@
|
|
|
|
endef
|
|
|
|
|
2009-03-04 04:28:42 +01:00
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Commands for running aidl
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define transform-aidl-to-java
|
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
@echo "Aidl: $(PRIVATE_MODULE) <= $<"
|
|
|
|
$(hide) $(AIDL) -d$(patsubst %.java,%.P,$@) $(PRIVATE_AIDL_FLAGS) $< $@
|
|
|
|
endef
|
|
|
|
#$(AIDL) $(PRIVATE_AIDL_FLAGS) $< - | indent -nut -br -npcs -l1000 > $@
|
|
|
|
|
2015-10-15 02:27:24 +02:00
|
|
|
define transform-aidl-to-cpp
|
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
@mkdir -p $(PRIVATE_HEADER_OUTPUT_DIR)
|
|
|
|
@echo "Generating C++ from AIDL: $(PRIVATE_MODULE) <= $<"
|
2018-07-06 20:35:09 +02:00
|
|
|
$(hide) $(AIDL_CPP) -d$(basename $@).aidl.d --ninja $(PRIVATE_AIDL_FLAGS) \
|
2015-10-15 02:27:24 +02:00
|
|
|
$< $(PRIVATE_HEADER_OUTPUT_DIR) $@
|
|
|
|
endef
|
|
|
|
|
2016-06-24 01:44:47 +02:00
|
|
|
## Given a .aidl file path, generate the rule to compile it a .java file
|
|
|
|
# $(1): a .aidl source file
|
|
|
|
# $(2): a directory to place the generated .java files in
|
|
|
|
# $(3): name of a variable to add the path to the generated source file to
|
|
|
|
#
|
|
|
|
# You must call this with $(eval).
|
|
|
|
define define-aidl-java-rule
|
|
|
|
define-aidl-java-rule-src := $(patsubst %.aidl,%.java,$(subst ../,dotdot/,$(addprefix $(2)/,$(1))))
|
2019-06-12 19:13:28 +02:00
|
|
|
$$(define-aidl-java-rule-src) : $(call clean-path,$(LOCAL_PATH)/$(1)) $(AIDL)
|
2016-06-24 01:44:47 +02:00
|
|
|
$$(transform-aidl-to-java)
|
|
|
|
$(3) += $$(define-aidl-java-rule-src)
|
|
|
|
endef
|
|
|
|
|
2016-01-19 17:58:35 +01:00
|
|
|
## Given a .aidl file path generate the rule to compile it a .cpp file.
|
|
|
|
# $(1): a .aidl source file
|
|
|
|
# $(2): a directory to place the generated .cpp files in
|
|
|
|
# $(3): name of a variable to add the path to the generated source file to
|
|
|
|
#
|
|
|
|
# You must call this with $(eval).
|
|
|
|
define define-aidl-cpp-rule
|
|
|
|
define-aidl-cpp-rule-src := $(patsubst %.aidl,%$(LOCAL_CPP_EXTENSION),$(subst ../,dotdot/,$(addprefix $(2)/,$(1))))
|
2019-06-12 19:13:28 +02:00
|
|
|
$$(define-aidl-cpp-rule-src) : $(call clean-path,$(LOCAL_PATH)/$(1)) $(AIDL_CPP)
|
2016-01-19 17:58:35 +01:00
|
|
|
$$(transform-aidl-to-cpp)
|
|
|
|
$(3) += $$(define-aidl-cpp-rule-src)
|
|
|
|
endef
|
2009-03-04 04:28:42 +01:00
|
|
|
|
2016-02-19 20:06:58 +01:00
|
|
|
###########################################################
|
|
|
|
## Commands for running vts
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define transform-vts-to-cpp
|
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
@mkdir -p $(PRIVATE_HEADER_OUTPUT_DIR)
|
|
|
|
@echo "Generating C++ from VTS: $(PRIVATE_MODULE) <= $<"
|
2019-01-09 21:48:17 +01:00
|
|
|
$(hide) $(VTSC) -TODO_b/120496070 $(PRIVATE_VTS_FLAGS) \
|
2016-02-19 20:06:58 +01:00
|
|
|
$< $(PRIVATE_HEADER_OUTPUT_DIR) $@
|
|
|
|
endef
|
|
|
|
|
|
|
|
## Given a .vts file path generate the rule to compile it a .cpp file.
|
|
|
|
# $(1): a .vts source file
|
|
|
|
# $(2): a directory to place the generated .cpp files in
|
|
|
|
# $(3): name of a variable to add the path to the generated source file to
|
|
|
|
#
|
|
|
|
# You must call this with $(eval).
|
|
|
|
define define-vts-cpp-rule
|
|
|
|
define-vts-cpp-rule-src := $(patsubst %.vts,%$(LOCAL_CPP_EXTENSION),$(subst ../,dotdot/,$(addprefix $(2)/,$(1))))
|
|
|
|
$$(define-vts-cpp-rule-src) : $(LOCAL_PATH)/$(1) $(VTSC)
|
|
|
|
$$(transform-vts-to-cpp)
|
|
|
|
$(3) += $$(define-vts-cpp-rule-src)
|
|
|
|
endef
|
|
|
|
|
2009-11-30 23:28:59 +01:00
|
|
|
###########################################################
|
|
|
|
## Commands for running java-event-log-tags.py
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define transform-logtags-to-java
|
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
@echo "logtags: $@ <= $<"
|
2016-03-28 20:29:21 +02:00
|
|
|
$(hide) $(JAVATAGS) -o $@ $< $(PRIVATE_MERGED_TAG)
|
2009-11-30 23:28:59 +01:00
|
|
|
endef
|
|
|
|
|
2009-03-04 04:28:42 +01:00
|
|
|
|
2010-11-03 02:43:16 +01:00
|
|
|
###########################################################
|
|
|
|
## Commands for running protoc to compile .proto into .java
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define transform-proto-to-java
|
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
@echo "Protoc: $@ <= $(PRIVATE_PROTO_SRC_FILES)"
|
|
|
|
@rm -rf $(PRIVATE_PROTO_JAVA_OUTPUT_DIR)
|
|
|
|
@mkdir -p $(PRIVATE_PROTO_JAVA_OUTPUT_DIR)
|
2013-07-25 12:44:53 +02:00
|
|
|
$(hide) for f in $(PRIVATE_PROTO_SRC_FILES); do \
|
|
|
|
$(PROTOC) \
|
2013-07-24 23:32:14 +02:00
|
|
|
$(addprefix --proto_path=, $(PRIVATE_PROTO_INCLUDES)) \
|
2013-07-25 21:28:19 +02:00
|
|
|
$(PRIVATE_PROTO_JAVA_OUTPUT_OPTION)="$(PRIVATE_PROTO_JAVA_OUTPUT_PARAMS):$(PRIVATE_PROTO_JAVA_OUTPUT_DIR)" \
|
2013-07-25 12:44:53 +02:00
|
|
|
$(PRIVATE_PROTOC_FLAGS) \
|
|
|
|
$$f || exit 33; \
|
|
|
|
done
|
2019-06-11 01:31:07 +02:00
|
|
|
$(SOONG_ZIP) -o $@ -C $(PRIVATE_PROTO_JAVA_OUTPUT_DIR) -D $(PRIVATE_PROTO_JAVA_OUTPUT_DIR)
|
2010-11-03 02:43:16 +01:00
|
|
|
endef
|
|
|
|
|
|
|
|
######################################################################
|
2015-04-07 20:59:34 +02:00
|
|
|
## Commands for running protoc to compile .proto into .pb.cc (or.pb.c) and .pb.h
|
2010-11-03 02:43:16 +01:00
|
|
|
######################################################################
|
2016-10-06 03:01:10 +02:00
|
|
|
|
2010-11-03 02:43:16 +01:00
|
|
|
define transform-proto-to-cc
|
|
|
|
@echo "Protoc: $@ <= $<"
|
2015-07-17 02:14:27 +02:00
|
|
|
@mkdir -p $(dir $@)
|
2016-10-06 03:01:10 +02:00
|
|
|
$(hide) \
|
2019-05-29 00:09:53 +02:00
|
|
|
$(PROTOC) \
|
|
|
|
$(addprefix --proto_path=, $(PRIVATE_PROTO_INCLUDES)) \
|
|
|
|
$(PRIVATE_PROTOC_FLAGS) \
|
|
|
|
$<
|
2016-05-06 05:02:08 +02:00
|
|
|
@# aprotoc outputs only .cc. Rename it to .cpp if necessary.
|
|
|
|
$(if $(PRIVATE_RENAME_CPP_EXT),\
|
|
|
|
$(hide) mv $(basename $@).cc $@)
|
2014-05-07 00:45:57 +02:00
|
|
|
endef
|
2010-11-03 02:43:16 +01:00
|
|
|
|
2016-07-19 22:19:21 +02:00
|
|
|
###########################################################
|
|
|
|
## Helper to set include paths form transform-*-to-o
|
|
|
|
###########################################################
|
|
|
|
define c-includes
|
|
|
|
$(addprefix -I , $(PRIVATE_C_INCLUDES)) \
|
2019-07-31 19:31:20 +02:00
|
|
|
$(foreach i,$(PRIVATE_IMPORTED_INCLUDES),$(EXPORTS.$(i)))\
|
2016-07-19 22:19:21 +02:00
|
|
|
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),,\
|
2016-07-20 21:22:57 +02:00
|
|
|
$(addprefix -I ,\
|
|
|
|
$(filter-out $(PRIVATE_C_INCLUDES), \
|
|
|
|
$(PRIVATE_GLOBAL_C_INCLUDES))) \
|
2016-07-19 22:19:21 +02:00
|
|
|
$(addprefix -isystem ,\
|
|
|
|
$(filter-out $(PRIVATE_C_INCLUDES), \
|
2016-07-20 21:22:57 +02:00
|
|
|
$(PRIVATE_GLOBAL_C_SYSTEM_INCLUDES))))
|
2016-07-19 22:19:21 +02:00
|
|
|
endef
|
2015-07-30 02:14:24 +02:00
|
|
|
|
2009-03-04 04:28:42 +01:00
|
|
|
###########################################################
|
|
|
|
## Commands for running gcc to compile a C++ file
|
|
|
|
###########################################################
|
|
|
|
|
2016-04-01 01:30:23 +02:00
|
|
|
define transform-cpp-to-o-compiler-args
|
2019-05-29 00:09:53 +02:00
|
|
|
$(c-includes) \
|
|
|
|
-c \
|
|
|
|
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
|
|
|
|
$(PRIVATE_TARGET_GLOBAL_CFLAGS) \
|
|
|
|
$(PRIVATE_TARGET_GLOBAL_CPPFLAGS) \
|
|
|
|
$(PRIVATE_ARM_CFLAGS) \
|
|
|
|
) \
|
|
|
|
$(PRIVATE_RTTI_FLAG) \
|
|
|
|
$(PRIVATE_CFLAGS) \
|
|
|
|
$(PRIVATE_CPPFLAGS) \
|
|
|
|
$(PRIVATE_DEBUG_CFLAGS) \
|
|
|
|
$(PRIVATE_CFLAGS_NO_OVERRIDE) \
|
|
|
|
$(PRIVATE_CPPFLAGS_NO_OVERRIDE)
|
2016-04-01 01:30:23 +02:00
|
|
|
endef
|
|
|
|
|
2019-04-05 01:21:53 +02:00
|
|
|
# PATH_TO_CLANG_TIDY is defined in build/soong
|
2018-08-27 05:37:49 +02:00
|
|
|
define call-clang-tidy
|
2019-04-05 01:21:53 +02:00
|
|
|
$(PATH_TO_CLANG_TIDY) \
|
2018-08-27 05:37:49 +02:00
|
|
|
$(PRIVATE_TIDY_FLAGS) \
|
|
|
|
-checks=$(PRIVATE_TIDY_CHECKS)
|
|
|
|
endef
|
|
|
|
|
2016-04-01 01:30:23 +02:00
|
|
|
define clang-tidy-cpp
|
2018-08-27 05:37:49 +02:00
|
|
|
$(hide) $(call-clang-tidy) $< -- $(transform-cpp-to-o-compiler-args)
|
2016-04-01 01:30:23 +02:00
|
|
|
endef
|
|
|
|
|
|
|
|
ifneq (,$(filter 1 true,$(WITH_TIDY_ONLY)))
|
|
|
|
define transform-cpp-to-o
|
|
|
|
$(if $(PRIVATE_TIDY_CHECKS),
|
2016-06-24 20:13:34 +02:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) tidy $(PRIVATE_ARM_MODE) C++: $<"
|
2016-04-01 01:30:23 +02:00
|
|
|
$(clang-tidy-cpp))
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
2016-04-01 01:30:23 +02:00
|
|
|
else
|
|
|
|
define transform-cpp-to-o
|
2016-06-24 20:13:34 +02:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) $(PRIVATE_ARM_MODE) C++: $(PRIVATE_MODULE) <= $<"
|
2016-04-01 01:30:23 +02:00
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
$(if $(PRIVATE_TIDY_CHECKS),$(clang-tidy-cpp))
|
2020-10-20 07:52:49 +02:00
|
|
|
$(hide) $(RELATIVE_PWD) $(PRIVATE_CXX) \
|
2016-04-01 01:30:23 +02:00
|
|
|
$(transform-cpp-to-o-compiler-args) \
|
|
|
|
-MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
|
|
|
|
endef
|
|
|
|
endif
|
2009-03-04 04:28:42 +01:00
|
|
|
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Commands for running gcc to compile a C file
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
# $(1): extra flags
|
2016-04-01 01:30:23 +02:00
|
|
|
define transform-c-or-s-to-o-compiler-args
|
2019-05-29 00:09:53 +02:00
|
|
|
$(c-includes) \
|
|
|
|
-c \
|
|
|
|
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
|
|
|
|
$(PRIVATE_TARGET_GLOBAL_CFLAGS) \
|
|
|
|
$(PRIVATE_TARGET_GLOBAL_CONLYFLAGS) \
|
|
|
|
$(PRIVATE_ARM_CFLAGS) \
|
|
|
|
) \
|
|
|
|
$(1)
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
2016-04-01 01:30:23 +02:00
|
|
|
define transform-c-to-o-compiler-args
|
|
|
|
$(call transform-c-or-s-to-o-compiler-args, \
|
|
|
|
$(PRIVATE_CFLAGS) \
|
|
|
|
$(PRIVATE_CONLYFLAGS) \
|
|
|
|
$(PRIVATE_DEBUG_CFLAGS) \
|
|
|
|
$(PRIVATE_CFLAGS_NO_OVERRIDE))
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
2016-04-01 01:30:23 +02:00
|
|
|
define clang-tidy-c
|
2018-08-27 05:37:49 +02:00
|
|
|
$(hide) $(call-clang-tidy) $< -- $(transform-c-to-o-compiler-args)
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
2016-04-01 01:30:23 +02:00
|
|
|
ifneq (,$(filter 1 true,$(WITH_TIDY_ONLY)))
|
2009-03-04 04:28:42 +01:00
|
|
|
define transform-c-to-o
|
2016-04-01 01:30:23 +02:00
|
|
|
$(if $(PRIVATE_TIDY_CHECKS),
|
2016-06-24 20:13:34 +02:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) tidy $(PRIVATE_ARM_MODE) C: $<"
|
2016-04-01 01:30:23 +02:00
|
|
|
$(clang-tidy-c))
|
|
|
|
endef
|
|
|
|
else
|
|
|
|
define transform-c-to-o
|
2016-06-24 20:13:34 +02:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) $(PRIVATE_ARM_MODE) C: $(PRIVATE_MODULE) <= $<"
|
2016-04-01 01:30:23 +02:00
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
$(if $(PRIVATE_TIDY_CHECKS),$(clang-tidy-c))
|
2020-10-20 07:52:49 +02:00
|
|
|
$(hide) $(RELATIVE_PWD) $(PRIVATE_CC) \
|
2016-04-01 01:30:23 +02:00
|
|
|
$(transform-c-to-o-compiler-args) \
|
|
|
|
-MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
|
|
|
|
endef
|
|
|
|
endif
|
|
|
|
|
2016-11-11 03:19:36 +01:00
|
|
|
define transform-s-to-o
|
2016-06-24 20:13:34 +02:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) asm: $(PRIVATE_MODULE) <= $<"
|
2016-04-01 01:30:23 +02:00
|
|
|
@mkdir -p $(dir $@)
|
2020-10-20 07:52:49 +02:00
|
|
|
$(RELATIVE_PWD) $(PRIVATE_CC) \
|
2016-04-01 01:30:23 +02:00
|
|
|
$(call transform-c-or-s-to-o-compiler-args, $(PRIVATE_ASFLAGS)) \
|
|
|
|
-MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
2014-06-06 04:05:47 +02:00
|
|
|
# YASM compilation
|
|
|
|
define transform-asm-to-o
|
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
$(hide) $(YASM) \
|
|
|
|
$(addprefix -I , $(PRIVATE_C_INCLUDES)) \
|
2015-03-10 02:57:40 +01:00
|
|
|
$($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_YASM_FLAGS) \
|
2014-06-06 04:05:47 +02:00
|
|
|
$(PRIVATE_ASFLAGS) \
|
|
|
|
-o $@ $<
|
|
|
|
endef
|
|
|
|
|
2009-05-14 16:00:09 +02:00
|
|
|
###########################################################
|
|
|
|
## Commands for running gcc to compile an Objective-C file
|
|
|
|
## This should never happen for target builds but this
|
|
|
|
## will error at build time.
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define transform-m-to-o
|
2016-11-11 03:19:36 +01:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) ObjC: $(PRIVATE_MODULE) <= $<"
|
|
|
|
$(call transform-c-or-s-to-o, $(PRIVATE_CFLAGS) $(PRIVATE_DEBUG_CFLAGS))
|
2009-05-14 16:00:09 +02:00
|
|
|
endef
|
|
|
|
|
2009-03-04 04:28:42 +01:00
|
|
|
###########################################################
|
|
|
|
## Commands for running gcc to compile a host C++ file
|
|
|
|
###########################################################
|
|
|
|
|
2016-04-01 01:30:23 +02:00
|
|
|
define transform-host-cpp-to-o-compiler-args
|
2019-05-29 00:09:53 +02:00
|
|
|
$(c-includes) \
|
|
|
|
-c \
|
|
|
|
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
|
|
|
|
$(PRIVATE_HOST_GLOBAL_CFLAGS) \
|
|
|
|
$(PRIVATE_HOST_GLOBAL_CPPFLAGS) \
|
|
|
|
) \
|
|
|
|
$(PRIVATE_CFLAGS) \
|
|
|
|
$(PRIVATE_CPPFLAGS) \
|
|
|
|
$(PRIVATE_DEBUG_CFLAGS) \
|
|
|
|
$(PRIVATE_CFLAGS_NO_OVERRIDE) \
|
|
|
|
$(PRIVATE_CPPFLAGS_NO_OVERRIDE)
|
2016-04-01 01:30:23 +02:00
|
|
|
endef
|
|
|
|
|
|
|
|
define clang-tidy-host-cpp
|
2018-08-27 05:37:49 +02:00
|
|
|
$(hide) $(call-clang-tidy) $< -- $(transform-host-cpp-to-o-compiler-args)
|
2016-04-01 01:30:23 +02:00
|
|
|
endef
|
|
|
|
|
|
|
|
ifneq (,$(filter 1 true,$(WITH_TIDY_ONLY)))
|
|
|
|
define transform-host-cpp-to-o
|
|
|
|
$(if $(PRIVATE_TIDY_CHECKS),
|
|
|
|
@echo "tidy $($(PRIVATE_PREFIX)DISPLAY) C++: $<"
|
|
|
|
$(clang-tidy-host-cpp))
|
|
|
|
endef
|
|
|
|
else
|
|
|
|
define transform-host-cpp-to-o
|
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) C++: $(PRIVATE_MODULE) <= $<"
|
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
$(if $(PRIVATE_TIDY_CHECKS),$(clang-tidy-host-cpp))
|
2020-10-20 07:52:49 +02:00
|
|
|
$(hide) $(RELATIVE_PWD) $(PRIVATE_CXX) \
|
2016-04-01 01:30:23 +02:00
|
|
|
$(transform-host-cpp-to-o-compiler-args) \
|
|
|
|
-MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
2016-04-01 01:30:23 +02:00
|
|
|
endif
|
2009-03-04 04:28:42 +01:00
|
|
|
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Commands for running gcc to compile a host C file
|
|
|
|
###########################################################
|
|
|
|
|
2016-04-01 01:30:23 +02:00
|
|
|
define transform-host-c-or-s-to-o-common-args
|
2019-05-29 00:09:53 +02:00
|
|
|
$(c-includes) \
|
|
|
|
-c \
|
|
|
|
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
|
|
|
|
$(PRIVATE_HOST_GLOBAL_CFLAGS) \
|
|
|
|
$(PRIVATE_HOST_GLOBAL_CONLYFLAGS) \
|
|
|
|
)
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
2016-04-01 01:30:23 +02:00
|
|
|
# $(1): extra flags
|
2016-11-11 03:19:36 +01:00
|
|
|
define transform-host-c-or-s-to-o
|
2016-04-01 01:30:23 +02:00
|
|
|
@mkdir -p $(dir $@)
|
2020-10-20 07:52:49 +02:00
|
|
|
$(hide) $(RELATIVE_PWD) $(PRIVATE_CC) \
|
2016-04-01 01:30:23 +02:00
|
|
|
$(transform-host-c-or-s-to-o-common-args) \
|
|
|
|
$(1) \
|
|
|
|
-MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
|
|
|
|
endef
|
|
|
|
|
|
|
|
define transform-host-c-to-o-compiler-args
|
|
|
|
$(transform-host-c-or-s-to-o-common-args) \
|
|
|
|
$(PRIVATE_CFLAGS) $(PRIVATE_CONLYFLAGS) \
|
|
|
|
$(PRIVATE_DEBUG_CFLAGS) $(PRIVATE_CFLAGS_NO_OVERRIDE)
|
|
|
|
endef
|
|
|
|
|
|
|
|
define clang-tidy-host-c
|
2018-08-27 05:37:49 +02:00
|
|
|
$(hide) $(call-clang-tidy) $< -- $(transform-host-c-to-o-compiler-args)
|
2016-04-01 01:30:23 +02:00
|
|
|
endef
|
|
|
|
|
|
|
|
ifneq (,$(filter 1 true,$(WITH_TIDY_ONLY)))
|
|
|
|
define transform-host-c-to-o
|
|
|
|
$(if $(PRIVATE_TIDY_CHECKS),
|
|
|
|
@echo "tidy $($(PRIVATE_PREFIX)DISPLAY) C: $<"
|
|
|
|
$(clang-tidy-host-c))
|
|
|
|
endef
|
|
|
|
else
|
|
|
|
define transform-host-c-to-o
|
2015-08-14 21:59:50 +02:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) C: $(PRIVATE_MODULE) <= $<"
|
2016-04-01 01:30:23 +02:00
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
$(if $(PRIVATE_TIDY_CHECKS), $(clang-tidy-host-c))
|
2020-10-20 07:52:49 +02:00
|
|
|
$(hide) $(RELATIVE_PWD) $(PRIVATE_CC) \
|
2016-04-01 01:30:23 +02:00
|
|
|
$(transform-host-c-to-o-compiler-args) \
|
|
|
|
-MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
2016-04-01 01:30:23 +02:00
|
|
|
endif
|
2009-03-04 04:28:42 +01:00
|
|
|
|
|
|
|
define transform-host-s-to-o
|
2016-11-11 03:19:36 +01:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) asm: $(PRIVATE_MODULE) <= $<"
|
|
|
|
$(call transform-host-c-or-s-to-o, $(PRIVATE_ASFLAGS))
|
2009-05-14 16:00:09 +02:00
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Commands for running gcc to compile a host Objective-C file
|
|
|
|
###########################################################
|
|
|
|
|
2011-02-11 16:19:31 +01:00
|
|
|
define transform-host-m-to-o
|
2016-11-11 03:19:36 +01:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) ObjC: $(PRIVATE_MODULE) <= $<"
|
|
|
|
$(call transform-host-c-or-s-to-o, $(PRIVATE_CFLAGS) $(PRIVATE_DEBUG_CFLAGS) $(PRIVATE_CFLAGS_NO_OVERRIDE))
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
2015-09-18 00:40:49 +02:00
|
|
|
###########################################################
|
|
|
|
## Commands for running gcc to compile a host Objective-C++ file
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define transform-host-mm-to-o
|
|
|
|
$(transform-host-cpp-to-o)
|
|
|
|
endef
|
|
|
|
|
2015-03-11 02:03:11 +01:00
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Rules to compile a single C/C++ source with ../ in the path
|
|
|
|
###########################################################
|
|
|
|
# Replace "../" in object paths with $(DOTDOT_REPLACEMENT).
|
|
|
|
DOTDOT_REPLACEMENT := dotdot/
|
|
|
|
|
|
|
|
## Rule to compile a C++ source file with ../ in the path.
|
|
|
|
## Must be called with $(eval).
|
|
|
|
# $(1): the C++ source file in LOCAL_SRC_FILES.
|
|
|
|
# $(2): the additional dependencies.
|
|
|
|
# $(3): the variable name to collect the output object file.
|
2019-11-12 01:04:34 +01:00
|
|
|
# $(4): the ninja pool to use for the rule
|
2015-03-11 02:03:11 +01:00
|
|
|
define compile-dotdot-cpp-file
|
|
|
|
o := $(intermediates)/$(patsubst %$(LOCAL_CPP_EXTENSION),%.o,$(subst ../,$(DOTDOT_REPLACEMENT),$(1)))
|
2019-11-12 01:04:34 +01:00
|
|
|
$$(o) : .KATI_NINJA_POOL := $(4)
|
2019-06-12 07:59:53 +02:00
|
|
|
$$(o) : $(TOPDIR)$(LOCAL_PATH)/$(1) $(2) $(CLANG_CXX)
|
2015-03-11 02:03:11 +01:00
|
|
|
$$(transform-$$(PRIVATE_HOST)cpp-to-o)
|
2016-03-15 22:40:04 +01:00
|
|
|
$$(call include-depfiles-for-objs, $$(o))
|
2015-03-11 02:03:11 +01:00
|
|
|
$(3) += $$(o)
|
|
|
|
endef
|
|
|
|
|
|
|
|
## Rule to compile a C source file with ../ in the path.
|
|
|
|
## Must be called with $(eval).
|
|
|
|
# $(1): the C source file in LOCAL_SRC_FILES.
|
|
|
|
# $(2): the additional dependencies.
|
|
|
|
# $(3): the variable name to collect the output object file.
|
2019-11-12 01:04:34 +01:00
|
|
|
# $(4): the ninja pool to use for the rule
|
2015-03-11 02:03:11 +01:00
|
|
|
define compile-dotdot-c-file
|
|
|
|
o := $(intermediates)/$(patsubst %.c,%.o,$(subst ../,$(DOTDOT_REPLACEMENT),$(1)))
|
2019-11-12 01:04:34 +01:00
|
|
|
$$(o) : .KATI_NINJA_POOL := $(4)
|
2019-06-12 07:59:53 +02:00
|
|
|
$$(o) : $(TOPDIR)$(LOCAL_PATH)/$(1) $(2) $(CLANG)
|
2015-03-11 02:03:11 +01:00
|
|
|
$$(transform-$$(PRIVATE_HOST)c-to-o)
|
2016-03-15 22:40:04 +01:00
|
|
|
$$(call include-depfiles-for-objs, $$(o))
|
2015-03-11 02:03:11 +01:00
|
|
|
$(3) += $$(o)
|
|
|
|
endef
|
|
|
|
|
|
|
|
## Rule to compile a .S source file with ../ in the path.
|
|
|
|
## Must be called with $(eval).
|
|
|
|
# $(1): the .S source file in LOCAL_SRC_FILES.
|
|
|
|
# $(2): the additional dependencies.
|
|
|
|
# $(3): the variable name to collect the output object file.
|
2019-11-12 01:04:34 +01:00
|
|
|
# $(4): the ninja pool to use for the rule
|
2015-03-11 02:03:11 +01:00
|
|
|
define compile-dotdot-s-file
|
|
|
|
o := $(intermediates)/$(patsubst %.S,%.o,$(subst ../,$(DOTDOT_REPLACEMENT),$(1)))
|
2019-11-12 01:04:34 +01:00
|
|
|
$$(o) : .KATI_NINJA_POOL := $(4)
|
2019-06-12 07:59:53 +02:00
|
|
|
$$(o) : $(TOPDIR)$(LOCAL_PATH)/$(1) $(2) $(CLANG)
|
2015-03-11 02:03:11 +01:00
|
|
|
$$(transform-$$(PRIVATE_HOST)s-to-o)
|
2016-03-15 22:40:04 +01:00
|
|
|
$$(call include-depfiles-for-objs, $$(o))
|
2015-03-11 02:03:11 +01:00
|
|
|
$(3) += $$(o)
|
|
|
|
endef
|
|
|
|
|
|
|
|
## Rule to compile a .s source file with ../ in the path.
|
|
|
|
## Must be called with $(eval).
|
|
|
|
# $(1): the .s source file in LOCAL_SRC_FILES.
|
|
|
|
# $(2): the additional dependencies.
|
|
|
|
# $(3): the variable name to collect the output object file.
|
2019-11-12 01:04:34 +01:00
|
|
|
# $(4): the ninja pool to use for the rule
|
2015-03-11 02:03:11 +01:00
|
|
|
define compile-dotdot-s-file-no-deps
|
|
|
|
o := $(intermediates)/$(patsubst %.s,%.o,$(subst ../,$(DOTDOT_REPLACEMENT),$(1)))
|
2019-11-12 01:04:34 +01:00
|
|
|
$$(o) : .KATI_NINJA_POOL := $(4)
|
2019-06-12 07:59:53 +02:00
|
|
|
$$(o) : $(TOPDIR)$(LOCAL_PATH)/$(1) $(2) $(CLANG)
|
2016-11-11 03:19:36 +01:00
|
|
|
$$(transform-$$(PRIVATE_HOST)s-to-o)
|
2015-03-11 02:03:11 +01:00
|
|
|
$(3) += $$(o)
|
|
|
|
endef
|
|
|
|
|
2009-03-04 04:28:42 +01:00
|
|
|
###########################################################
|
|
|
|
## Commands for running ar
|
|
|
|
###########################################################
|
|
|
|
|
2010-05-27 20:55:39 +02:00
|
|
|
define _concat-if-arg2-not-empty
|
|
|
|
$(if $(2),$(hide) $(1) $(2))
|
|
|
|
endef
|
|
|
|
|
|
|
|
# Split long argument list into smaller groups and call the command repeatedly
|
2012-06-15 17:03:52 +02:00
|
|
|
# Call the command at least once even if there are no arguments, as otherwise
|
|
|
|
# the output file won't be created.
|
2010-05-27 20:55:39 +02:00
|
|
|
#
|
|
|
|
# $(1): the command without arguments
|
|
|
|
# $(2): the arguments
|
|
|
|
define split-long-arguments
|
2012-06-15 17:03:52 +02:00
|
|
|
$(hide) $(1) $(wordlist 1,500,$(2))
|
2010-05-27 20:55:39 +02:00
|
|
|
$(call _concat-if-arg2-not-empty,$(1),$(wordlist 501,1000,$(2)))
|
|
|
|
$(call _concat-if-arg2-not-empty,$(1),$(wordlist 1001,1500,$(2)))
|
|
|
|
$(call _concat-if-arg2-not-empty,$(1),$(wordlist 1501,2000,$(2)))
|
|
|
|
$(call _concat-if-arg2-not-empty,$(1),$(wordlist 2001,2500,$(2)))
|
|
|
|
$(call _concat-if-arg2-not-empty,$(1),$(wordlist 2501,3000,$(2)))
|
|
|
|
$(call _concat-if-arg2-not-empty,$(1),$(wordlist 3001,99999,$(2)))
|
|
|
|
endef
|
|
|
|
|
2011-01-28 03:48:00 +01:00
|
|
|
# $(1): the full path of the source static library.
|
2017-02-04 00:10:05 +01:00
|
|
|
# $(2): the full path of the destination static library.
|
2011-01-28 03:48:00 +01:00
|
|
|
define _extract-and-include-single-target-whole-static-lib
|
|
|
|
$(hide) ldir=$(PRIVATE_INTERMEDIATES_DIR)/WHOLE/$(basename $(notdir $(1)))_objs;\
|
|
|
|
rm -rf $$ldir; \
|
|
|
|
mkdir -p $$ldir; \
|
2015-01-08 02:14:03 +01:00
|
|
|
cp $(1) $$ldir; \
|
|
|
|
lib_to_include=$$ldir/$(notdir $(1)); \
|
2011-01-28 03:48:00 +01:00
|
|
|
filelist=; \
|
2015-01-08 02:14:03 +01:00
|
|
|
subdir=0; \
|
2014-04-17 19:03:35 +02:00
|
|
|
for f in `$($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) t $(1)`; do \
|
2015-01-08 02:14:03 +01:00
|
|
|
if [ -e $$ldir/$$f ]; then \
|
|
|
|
mkdir $$ldir/$$subdir; \
|
|
|
|
ext=$$subdir/; \
|
|
|
|
subdir=$$((subdir+1)); \
|
|
|
|
$($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) m $$lib_to_include $$f; \
|
|
|
|
else \
|
|
|
|
ext=; \
|
|
|
|
fi; \
|
|
|
|
$($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) p $$lib_to_include $$f > $$ldir/$$ext$$f; \
|
|
|
|
filelist="$$filelist $$ldir/$$ext$$f"; \
|
2011-01-28 03:48:00 +01:00
|
|
|
done ; \
|
2014-01-16 01:02:16 +01:00
|
|
|
$($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_ARFLAGS) \
|
2017-11-01 10:21:20 +01:00
|
|
|
$(PRIVATE_ARFLAGS) $(2) $$filelist
|
2011-01-28 03:48:00 +01:00
|
|
|
|
|
|
|
endef
|
|
|
|
|
2014-05-23 21:26:51 +02:00
|
|
|
# $(1): the full path of the source static library.
|
2017-02-04 00:10:05 +01:00
|
|
|
# $(2): the full path of the destination static library.
|
2014-05-23 21:26:51 +02:00
|
|
|
define extract-and-include-whole-static-libs-first
|
|
|
|
$(if $(strip $(1)),
|
2017-02-04 00:10:05 +01:00
|
|
|
$(hide) cp $(1) $(2))
|
2014-05-23 21:26:51 +02:00
|
|
|
endef
|
|
|
|
|
2017-02-04 00:10:05 +01:00
|
|
|
# $(1): the full path of the destination static library.
|
2009-10-21 20:12:56 +02:00
|
|
|
define extract-and-include-target-whole-static-libs
|
2017-02-04 00:10:05 +01:00
|
|
|
$(call extract-and-include-whole-static-libs-first, $(firstword $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)),$(1))
|
2014-05-23 21:26:51 +02:00
|
|
|
$(foreach lib,$(wordlist 2,999,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)), \
|
2017-02-04 00:10:05 +01:00
|
|
|
$(call _extract-and-include-single-target-whole-static-lib, $(lib), $(1)))
|
2009-05-28 04:41:07 +02:00
|
|
|
endef
|
|
|
|
|
2009-03-04 04:28:42 +01:00
|
|
|
# Explicitly delete the archive first so that ar doesn't
|
|
|
|
# try to add to an existing archive.
|
|
|
|
define transform-o-to-static-lib
|
2016-06-24 20:13:34 +02:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) StaticLib: $(PRIVATE_MODULE) ($@)"
|
2009-03-04 04:28:42 +01:00
|
|
|
@mkdir -p $(dir $@)
|
2017-02-04 00:10:05 +01:00
|
|
|
@rm -f $@ $@.tmp
|
|
|
|
$(call extract-and-include-target-whole-static-libs,$@.tmp)
|
2014-04-17 19:03:35 +02:00
|
|
|
$(call split-long-arguments,$($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) \
|
|
|
|
$($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_ARFLAGS) \
|
2017-01-24 01:57:38 +01:00
|
|
|
$(PRIVATE_ARFLAGS) \
|
2017-02-04 00:10:05 +01:00
|
|
|
$@.tmp,$(PRIVATE_ALL_OBJECTS))
|
|
|
|
$(hide) mv -f $@.tmp $@
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Commands for running host ar
|
|
|
|
###########################################################
|
|
|
|
|
2011-01-28 03:48:00 +01:00
|
|
|
# $(1): the full path of the source static library.
|
2017-02-04 00:10:05 +01:00
|
|
|
# $(2): the full path of the destination static library.
|
2011-01-28 03:48:00 +01:00
|
|
|
define _extract-and-include-single-host-whole-static-lib
|
|
|
|
$(hide) ldir=$(PRIVATE_INTERMEDIATES_DIR)/WHOLE/$(basename $(notdir $(1)))_objs;\
|
|
|
|
rm -rf $$ldir; \
|
|
|
|
mkdir -p $$ldir; \
|
2015-01-08 02:14:03 +01:00
|
|
|
cp $(1) $$ldir; \
|
|
|
|
lib_to_include=$$ldir/$(notdir $(1)); \
|
2011-01-28 03:48:00 +01:00
|
|
|
filelist=; \
|
2015-01-08 02:14:03 +01:00
|
|
|
subdir=0; \
|
2015-08-14 21:59:50 +02:00
|
|
|
for f in `$($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)AR) t $(1) | \grep '\.o$$'`; do \
|
2015-01-08 02:14:03 +01:00
|
|
|
if [ -e $$ldir/$$f ]; then \
|
|
|
|
mkdir $$ldir/$$subdir; \
|
|
|
|
ext=$$subdir/; \
|
|
|
|
subdir=$$((subdir+1)); \
|
2015-08-14 21:59:50 +02:00
|
|
|
$($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)AR) m $$lib_to_include $$f; \
|
2015-01-08 02:14:03 +01:00
|
|
|
else \
|
|
|
|
ext=; \
|
|
|
|
fi; \
|
2015-08-14 21:59:50 +02:00
|
|
|
$($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)AR) p $$lib_to_include $$f > $$ldir/$$ext$$f; \
|
2015-01-08 02:14:03 +01:00
|
|
|
filelist="$$filelist $$ldir/$$ext$$f"; \
|
2011-01-28 03:48:00 +01:00
|
|
|
done ; \
|
2015-08-14 21:59:50 +02:00
|
|
|
$($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)AR) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)GLOBAL_ARFLAGS) \
|
2017-02-04 00:10:05 +01:00
|
|
|
$(2) $$filelist
|
2011-01-28 03:48:00 +01:00
|
|
|
|
|
|
|
endef
|
|
|
|
|
2009-10-21 20:12:56 +02:00
|
|
|
define extract-and-include-host-whole-static-libs
|
2017-02-04 00:10:05 +01:00
|
|
|
$(call extract-and-include-whole-static-libs-first, $(firstword $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)),$(1))
|
2014-05-23 21:26:51 +02:00
|
|
|
$(foreach lib,$(wordlist 2,999,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)), \
|
2017-02-04 00:10:05 +01:00
|
|
|
$(call _extract-and-include-single-host-whole-static-lib, $(lib),$(1)))
|
2009-10-21 20:12:56 +02:00
|
|
|
endef
|
|
|
|
|
2016-03-23 02:23:13 +01:00
|
|
|
ifeq ($(HOST_OS),darwin)
|
|
|
|
# On Darwin the host ar fails if there is nothing to add to .a at all.
|
|
|
|
# We work around by adding a dummy.o and then deleting it.
|
|
|
|
define create-dummy.o-if-no-objs
|
2017-02-04 00:10:05 +01:00
|
|
|
$(if $(PRIVATE_ALL_OBJECTS),,$(hide) touch $(dir $(1))dummy.o)
|
2016-03-23 02:23:13 +01:00
|
|
|
endef
|
|
|
|
|
|
|
|
define get-dummy.o-if-no-objs
|
2017-02-04 00:10:05 +01:00
|
|
|
$(if $(PRIVATE_ALL_OBJECTS),,$(dir $(1))dummy.o)
|
2016-03-23 02:23:13 +01:00
|
|
|
endef
|
|
|
|
|
|
|
|
define delete-dummy.o-if-no-objs
|
2017-02-04 00:10:05 +01:00
|
|
|
$(if $(PRIVATE_ALL_OBJECTS),,$(hide) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)AR) d $(1) $(dir $(1))dummy.o \
|
|
|
|
&& rm -f $(dir $(1))dummy.o)
|
2016-03-23 02:23:13 +01:00
|
|
|
endef
|
2018-01-30 01:18:40 +01:00
|
|
|
else
|
|
|
|
create-dummy.o-if-no-objs =
|
|
|
|
get-dummy.o-if-no-objs =
|
|
|
|
delete-dummy.o-if-no-objs =
|
2016-03-23 02:23:13 +01:00
|
|
|
endif # HOST_OS is darwin
|
|
|
|
|
2009-03-04 04:28:42 +01:00
|
|
|
# Explicitly delete the archive first so that ar doesn't
|
|
|
|
# try to add to an existing archive.
|
|
|
|
define transform-host-o-to-static-lib
|
2015-08-14 21:59:50 +02:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) StaticLib: $(PRIVATE_MODULE) ($@)"
|
2009-03-04 04:28:42 +01:00
|
|
|
@mkdir -p $(dir $@)
|
2017-02-04 00:10:05 +01:00
|
|
|
@rm -f $@ $@.tmp
|
|
|
|
$(call extract-and-include-host-whole-static-libs,$@.tmp)
|
|
|
|
$(call create-dummy.o-if-no-objs,$@.tmp)
|
2015-08-14 21:59:50 +02:00
|
|
|
$(call split-long-arguments,$($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)AR) \
|
2017-02-04 00:10:05 +01:00
|
|
|
$($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)GLOBAL_ARFLAGS) $@.tmp,\
|
|
|
|
$(PRIVATE_ALL_OBJECTS) $(call get-dummy.o-if-no-objs,$@.tmp))
|
|
|
|
$(call delete-dummy.o-if-no-objs,$@.tmp)
|
|
|
|
$(hide) mv -f $@.tmp $@
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Commands for running gcc to link a shared library or package
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
# ld just seems to be so finicky with command order that we allow
|
|
|
|
# it to be overriden en-masse see combo/linux-arm.make for an example.
|
|
|
|
ifneq ($(HOST_CUSTOM_LD_COMMAND),true)
|
|
|
|
define transform-host-o-to-shared-lib-inner
|
2019-08-06 21:54:48 +02:00
|
|
|
$(hide) $(PRIVATE_CXX_LINK) \
|
2019-05-29 00:09:53 +02:00
|
|
|
-Wl,-rpath,\$$ORIGIN/../$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)OUT_SHARED_LIBRARIES)) \
|
|
|
|
-Wl,-rpath,\$$ORIGIN/$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)OUT_SHARED_LIBRARIES)) \
|
|
|
|
-shared -Wl,-soname,$(notdir $@) \
|
|
|
|
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
|
|
|
|
$(PRIVATE_HOST_GLOBAL_LDFLAGS) \
|
|
|
|
) \
|
|
|
|
$(PRIVATE_LDFLAGS) \
|
2022-11-10 00:52:56 +01:00
|
|
|
$(PRIVATE_CRTBEGIN) \
|
2019-05-29 00:09:53 +02:00
|
|
|
$(PRIVATE_ALL_OBJECTS) \
|
|
|
|
-Wl,--whole-archive \
|
|
|
|
$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES) \
|
|
|
|
-Wl,--no-whole-archive \
|
|
|
|
$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
|
|
|
|
$(PRIVATE_ALL_STATIC_LIBRARIES) \
|
|
|
|
$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
|
|
|
|
$(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_HOST_LIBPROFILE_RT)) \
|
2022-11-10 00:52:56 +01:00
|
|
|
$(PRIVATE_LIBCRT_BUILTINS) \
|
2019-05-29 00:09:53 +02:00
|
|
|
$(PRIVATE_ALL_SHARED_LIBRARIES) \
|
|
|
|
-o $@ \
|
2022-11-10 00:52:56 +01:00
|
|
|
$(PRIVATE_CRTEND) \
|
2019-05-29 00:09:53 +02:00
|
|
|
$(PRIVATE_LDLIBS)
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
endif
|
|
|
|
|
|
|
|
define transform-host-o-to-shared-lib
|
2015-08-14 21:59:50 +02:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) SharedLib: $(PRIVATE_MODULE) ($@)"
|
2015-07-17 02:14:27 +02:00
|
|
|
@mkdir -p $(dir $@)
|
2011-01-28 23:14:47 +01:00
|
|
|
$(transform-host-o-to-shared-lib-inner)
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
|
|
|
define transform-host-o-to-package
|
2015-08-14 21:59:50 +02:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) Package: $(PRIVATE_MODULE) ($@)"
|
2015-07-17 02:14:27 +02:00
|
|
|
@mkdir -p $(dir $@)
|
2011-01-28 23:14:47 +01:00
|
|
|
$(transform-host-o-to-shared-lib-inner)
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Commands for running gcc to link a shared library or package
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define transform-o-to-shared-lib-inner
|
2019-08-06 21:54:48 +02:00
|
|
|
$(hide) $(PRIVATE_CXX_LINK) \
|
2019-05-29 00:09:53 +02:00
|
|
|
-nostdlib -Wl,-soname,$(notdir $@) \
|
|
|
|
-Wl,--gc-sections \
|
|
|
|
-shared \
|
|
|
|
$(PRIVATE_TARGET_CRTBEGIN_SO_O) \
|
|
|
|
$(PRIVATE_ALL_OBJECTS) \
|
|
|
|
-Wl,--whole-archive \
|
|
|
|
$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES) \
|
|
|
|
-Wl,--no-whole-archive \
|
|
|
|
$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
|
|
|
|
$(PRIVATE_ALL_STATIC_LIBRARIES) \
|
|
|
|
$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
|
|
|
|
$(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_COVERAGE_LIB)) \
|
|
|
|
$(PRIVATE_TARGET_LIBCRT_BUILTINS) \
|
|
|
|
$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
|
|
|
|
$(PRIVATE_LDFLAGS) \
|
|
|
|
$(PRIVATE_ALL_SHARED_LIBRARIES) \
|
|
|
|
-o $@ \
|
|
|
|
$(PRIVATE_TARGET_CRTEND_SO_O) \
|
|
|
|
$(PRIVATE_LDLIBS)
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
|
|
|
define transform-o-to-shared-lib
|
2016-06-24 20:13:34 +02:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) SharedLib: $(PRIVATE_MODULE) ($@)"
|
2015-07-17 02:14:27 +02:00
|
|
|
@mkdir -p $(dir $@)
|
2014-11-13 19:15:46 +01:00
|
|
|
$(transform-o-to-shared-lib-inner)
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Commands for running gcc to link an executable
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define transform-o-to-executable-inner
|
2019-08-06 21:54:48 +02:00
|
|
|
$(hide) $(PRIVATE_CXX_LINK) -pie \
|
2019-05-29 00:09:53 +02:00
|
|
|
-nostdlib -Bdynamic \
|
|
|
|
-Wl,-dynamic-linker,$(PRIVATE_LINKER) \
|
|
|
|
-Wl,--gc-sections \
|
|
|
|
-Wl,-z,nocopyreloc \
|
|
|
|
$(PRIVATE_TARGET_CRTBEGIN_DYNAMIC_O) \
|
|
|
|
$(PRIVATE_ALL_OBJECTS) \
|
|
|
|
-Wl,--whole-archive \
|
|
|
|
$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES) \
|
|
|
|
-Wl,--no-whole-archive \
|
|
|
|
$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
|
|
|
|
$(PRIVATE_ALL_STATIC_LIBRARIES) \
|
|
|
|
$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
|
|
|
|
$(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_COVERAGE_LIB)) \
|
|
|
|
$(PRIVATE_TARGET_LIBCRT_BUILTINS) \
|
|
|
|
$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
|
|
|
|
$(PRIVATE_LDFLAGS) \
|
|
|
|
$(PRIVATE_ALL_SHARED_LIBRARIES) \
|
|
|
|
-o $@ \
|
|
|
|
$(PRIVATE_TARGET_CRTEND_O) \
|
|
|
|
$(PRIVATE_LDLIBS)
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
|
|
|
define transform-o-to-executable
|
2016-06-24 20:13:34 +02:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) Executable: $(PRIVATE_MODULE) ($@)"
|
2015-07-17 02:14:27 +02:00
|
|
|
@mkdir -p $(dir $@)
|
2014-11-13 19:15:46 +01:00
|
|
|
$(transform-o-to-executable-inner)
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
|
|
|
|
|
|
|
###########################################################
|
2014-11-13 19:15:46 +01:00
|
|
|
## Commands for linking a static executable. In practice,
|
|
|
|
## we only use this on arm, so the other platforms don't
|
|
|
|
## have transform-o-to-static-executable defined.
|
2015-01-20 20:00:20 +01:00
|
|
|
## Clang driver needs -static to create static executable.
|
|
|
|
## However, bionic/linker uses -shared to overwrite.
|
|
|
|
## Linker for x86 targets does not allow coexistance of -static and -shared,
|
|
|
|
## so we add -static only if -shared is not used.
|
2009-03-04 04:28:42 +01:00
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define transform-o-to-static-executable-inner
|
2019-08-06 21:54:48 +02:00
|
|
|
$(hide) $(PRIVATE_CXX_LINK) \
|
2019-05-29 00:09:53 +02:00
|
|
|
-nostdlib -Bstatic \
|
|
|
|
$(if $(filter $(PRIVATE_LDFLAGS),-shared),,-static) \
|
|
|
|
-Wl,--gc-sections \
|
|
|
|
-o $@ \
|
|
|
|
$(PRIVATE_TARGET_CRTBEGIN_STATIC_O) \
|
|
|
|
$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
|
|
|
|
$(PRIVATE_LDFLAGS) \
|
|
|
|
$(PRIVATE_ALL_OBJECTS) \
|
|
|
|
-Wl,--whole-archive \
|
|
|
|
$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES) \
|
|
|
|
-Wl,--no-whole-archive \
|
|
|
|
$(filter-out %libcompiler_rt.hwasan.a %libc_nomalloc.hwasan.a %libc.hwasan.a %libcompiler_rt.a %libc_nomalloc.a %libc.a,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
|
|
|
|
-Wl,--start-group \
|
|
|
|
$(filter %libc.a %libc.hwasan.a,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
|
|
|
|
$(filter %libc_nomalloc.a %libc_nomalloc.hwasan.a,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
|
|
|
|
$(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_COVERAGE_LIB)) \
|
|
|
|
$(filter %libcompiler_rt.a %libcompiler_rt.hwasan.a,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
|
|
|
|
$(PRIVATE_TARGET_LIBCRT_BUILTINS) \
|
|
|
|
-Wl,--end-group \
|
|
|
|
$(PRIVATE_TARGET_CRTEND_O)
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
|
|
|
define transform-o-to-static-executable
|
2016-06-24 20:13:34 +02:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) StaticExecutable: $(PRIVATE_MODULE) ($@)"
|
2015-07-17 02:14:27 +02:00
|
|
|
@mkdir -p $(dir $@)
|
2014-11-13 19:15:46 +01:00
|
|
|
$(transform-o-to-static-executable-inner)
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Commands for running gcc to link a host executable
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
ifneq ($(HOST_CUSTOM_LD_COMMAND),true)
|
|
|
|
define transform-host-o-to-executable-inner
|
2019-08-06 21:54:48 +02:00
|
|
|
$(hide) $(PRIVATE_CXX_LINK) \
|
2022-11-10 00:52:56 +01:00
|
|
|
$(PRIVATE_CRTBEGIN) \
|
2019-05-29 00:09:53 +02:00
|
|
|
$(PRIVATE_ALL_OBJECTS) \
|
|
|
|
-Wl,--whole-archive \
|
|
|
|
$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES) \
|
|
|
|
-Wl,--no-whole-archive \
|
|
|
|
$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
|
|
|
|
$(PRIVATE_ALL_STATIC_LIBRARIES) \
|
|
|
|
$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
|
|
|
|
$(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_HOST_LIBPROFILE_RT)) \
|
2022-11-10 00:52:56 +01:00
|
|
|
$(PRIVATE_LIBCRT_BUILTINS) \
|
2019-05-29 00:09:53 +02:00
|
|
|
$(PRIVATE_ALL_SHARED_LIBRARIES) \
|
|
|
|
$(foreach path,$(PRIVATE_RPATHS), \
|
|
|
|
-Wl,-rpath,\$$ORIGIN/$(path)) \
|
|
|
|
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
|
|
|
|
$(PRIVATE_HOST_GLOBAL_LDFLAGS) \
|
|
|
|
) \
|
|
|
|
$(PRIVATE_LDFLAGS) \
|
|
|
|
-o $@ \
|
2022-11-10 00:52:56 +01:00
|
|
|
$(PRIVATE_CRTEND) \
|
2019-05-29 00:09:53 +02:00
|
|
|
$(PRIVATE_LDLIBS)
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
endif
|
|
|
|
|
|
|
|
define transform-host-o-to-executable
|
2015-08-14 21:59:50 +02:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) Executable: $(PRIVATE_MODULE) ($@)"
|
2015-07-17 02:14:27 +02:00
|
|
|
@mkdir -p $(dir $@)
|
2011-01-28 23:14:47 +01:00
|
|
|
$(transform-host-o-to-executable-inner)
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
2019-05-01 00:14:44 +02:00
|
|
|
###########################################################
|
|
|
|
## Commands for packaging native coverage files
|
|
|
|
###########################################################
|
|
|
|
define package-coverage-files
|
|
|
|
@rm -f $@ $@.lst $@.premerged
|
|
|
|
@touch $@.lst
|
|
|
|
$(foreach obj,$(strip $(PRIVATE_ALL_OBJECTS)), $(hide) echo $(obj) >> $@.lst$(newline))
|
|
|
|
$(hide) $(SOONG_ZIP) -o $@.premerged -C $(OUT_DIR) -l $@.lst
|
|
|
|
$(hide) $(MERGE_ZIPS) -ignore-duplicates $@ $@.premerged $(strip $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES))
|
|
|
|
endef
|
2009-03-04 04:28:42 +01:00
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Commands for running javac to make .class files
|
|
|
|
###########################################################
|
|
|
|
|
2017-04-27 23:05:49 +02:00
|
|
|
# b/37750224
|
|
|
|
AAPT_ASAN_OPTIONS := ASAN_OPTIONS=detect_leaks=0
|
|
|
|
|
2021-07-13 06:53:13 +02:00
|
|
|
# Search for generated R.java in $1, copy the found R.java as $2.
|
2015-12-04 22:59:18 +01:00
|
|
|
define find-generated-R.java
|
2018-03-09 01:49:16 +01:00
|
|
|
$(hide) for GENERATED_R_FILE in `find $(1) \
|
2015-12-04 22:59:18 +01:00
|
|
|
-name R.java 2> /dev/null`; do \
|
2019-05-29 00:36:47 +02:00
|
|
|
cp $$GENERATED_R_FILE $(2) || exit 32; \
|
2015-12-04 22:59:18 +01:00
|
|
|
done;
|
|
|
|
@# Ensure that the target file is always created, i.e. also in case we did not
|
|
|
|
@# enter the GENERATED_R_FILE-loop above. This avoids unnecessary rebuilding.
|
2018-03-09 01:49:16 +01:00
|
|
|
$(hide) touch $(2)
|
2015-12-04 22:59:18 +01:00
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
# AAPT2 compilation and link
|
|
|
|
###########################################################
|
|
|
|
define aapt2-compile-one-resource-file
|
|
|
|
@mkdir -p $(dir $@)
|
2019-06-21 01:51:35 +02:00
|
|
|
$(hide) $(AAPT2) compile -o $(dir $@) $(PRIVATE_AAPT2_CFLAGS) $<
|
2015-12-04 22:59:18 +01:00
|
|
|
endef
|
|
|
|
|
2016-02-24 23:11:55 +01:00
|
|
|
define aapt2-compile-resource-dirs
|
2015-12-04 22:59:18 +01:00
|
|
|
@mkdir -p $(dir $@)
|
2016-02-24 23:11:55 +01:00
|
|
|
$(hide) $(AAPT2) compile -o $@ $(addprefix --dir ,$(PRIVATE_SOURCE_RES_DIRS)) \
|
2019-06-21 01:51:35 +02:00
|
|
|
$(PRIVATE_AAPT2_CFLAGS)
|
2015-12-04 22:59:18 +01:00
|
|
|
endef
|
|
|
|
|
2018-03-13 07:33:15 +01:00
|
|
|
# TODO(b/74574557): use aapt2 compile --zip if it gets implemented
|
|
|
|
define aapt2-compile-resource-zips
|
|
|
|
@mkdir -p $(dir $@)
|
2018-03-16 00:26:08 +01:00
|
|
|
$(ZIPSYNC) -d $@.contents -l $@.list $(PRIVATE_SOURCE_RES_ZIPS)
|
2019-06-21 01:51:35 +02:00
|
|
|
$(hide) $(AAPT2) compile -o $@ --dir $@.contents $(PRIVATE_AAPT2_CFLAGS)
|
2018-03-13 07:33:15 +01:00
|
|
|
endef
|
|
|
|
|
2015-12-04 22:59:18 +01:00
|
|
|
# Set up rule to compile one resource file with aapt2.
|
|
|
|
# Must be called with $(eval).
|
|
|
|
# $(1): the source file
|
|
|
|
# $(2): the output file
|
|
|
|
define aapt2-compile-one-resource-file-rule
|
|
|
|
$(2) : $(1) $(AAPT2)
|
|
|
|
@echo "AAPT2 compile $$@ <- $$<"
|
|
|
|
$$(call aapt2-compile-one-resource-file)
|
|
|
|
endef
|
|
|
|
|
|
|
|
# Convert input resource file path to output file path.
|
|
|
|
# values-[config]/<file>.xml -> values-[config]_<file>.arsc.flat;
|
|
|
|
# For other resource file, just replace the last "/" with "_" and
|
|
|
|
# add .flat extension.
|
|
|
|
#
|
|
|
|
# $(1): the input resource file path
|
|
|
|
# $(2): the base dir of the output file path
|
|
|
|
# Returns: the compiled output file path
|
|
|
|
define aapt2-compiled-resource-out-file
|
2018-07-31 22:43:48 +02:00
|
|
|
$(strip \
|
|
|
|
$(eval _p_w := $(strip $(subst /,$(space),$(dir $(call clean-path,$(1))))))
|
|
|
|
$(2)/$(subst $(space),/,$(_p_w))_$(if $(filter values%,$(lastword $(_p_w))),$(patsubst %.xml,%.arsc,$(notdir $(1))),$(notdir $(1))).flat)
|
2015-12-04 22:59:18 +01:00
|
|
|
endef
|
|
|
|
|
|
|
|
define aapt2-link
|
2016-04-26 19:36:11 +02:00
|
|
|
@mkdir -p $(dir $@)
|
2018-03-09 01:49:16 +01:00
|
|
|
rm -rf $(PRIVATE_JAVA_GEN_DIR)
|
|
|
|
mkdir -p $(PRIVATE_JAVA_GEN_DIR)
|
2016-04-26 19:36:11 +02:00
|
|
|
$(call dump-words-to-file,$(PRIVATE_RES_FLAT),$(dir $@)aapt2-flat-list)
|
2016-06-24 23:56:29 +02:00
|
|
|
$(call dump-words-to-file,$(PRIVATE_OVERLAY_FLAT),$(dir $@)aapt2-flat-overlay-list)
|
2015-12-04 22:59:18 +01:00
|
|
|
$(hide) $(AAPT2) link -o $@ \
|
|
|
|
$(PRIVATE_AAPT_FLAGS) \
|
2018-05-02 21:52:43 +02:00
|
|
|
$(if $(PRIVATE_STATIC_LIBRARY_EXTRA_PACKAGES),$$(cat $(PRIVATE_STATIC_LIBRARY_EXTRA_PACKAGES))) \
|
2015-12-04 22:59:18 +01:00
|
|
|
$(addprefix --manifest ,$(PRIVATE_ANDROID_MANIFEST)) \
|
|
|
|
$(addprefix -I ,$(PRIVATE_AAPT_INCLUDES)) \
|
2016-02-24 23:11:55 +01:00
|
|
|
$(addprefix -I ,$(PRIVATE_SHARED_ANDROID_LIBRARIES)) \
|
2019-06-12 19:13:28 +02:00
|
|
|
$(addprefix -A ,$(foreach d,$(PRIVATE_ASSET_DIR),$(call clean-path,$(d)))) \
|
2018-03-09 01:49:16 +01:00
|
|
|
$(addprefix --java ,$(PRIVATE_JAVA_GEN_DIR)) \
|
2015-12-04 22:59:18 +01:00
|
|
|
$(addprefix --proguard ,$(PRIVATE_PROGUARD_OPTIONS_FILE)) \
|
|
|
|
$(addprefix --min-sdk-version ,$(PRIVATE_DEFAULT_APP_TARGET_SDK)) \
|
|
|
|
$(addprefix --target-sdk-version ,$(PRIVATE_DEFAULT_APP_TARGET_SDK)) \
|
2016-02-26 20:13:43 +01:00
|
|
|
$(if $(filter --product,$(PRIVATE_AAPT_FLAGS)),,$(addprefix --product ,$(PRIVATE_TARGET_AAPT_CHARACTERISTICS))) \
|
|
|
|
$(addprefix -c ,$(PRIVATE_PRODUCT_AAPT_CONFIG)) \
|
|
|
|
$(addprefix --preferred-density ,$(PRIVATE_PRODUCT_AAPT_PREF_CONFIG)) \
|
|
|
|
$(if $(filter --version-code,$(PRIVATE_AAPT_FLAGS)),,--version-code $(PLATFORM_SDK_VERSION)) \
|
|
|
|
$(if $(filter --version-name,$(PRIVATE_AAPT_FLAGS)),,--version-name $(APPS_DEFAULT_VERSION_NAME)) \
|
|
|
|
$(addprefix --rename-manifest-package ,$(PRIVATE_MANIFEST_PACKAGE_NAME)) \
|
|
|
|
$(addprefix --rename-instrumentation-target-package ,$(PRIVATE_MANIFEST_INSTRUMENTATION_FOR)) \
|
2016-06-24 23:56:29 +02:00
|
|
|
-R \@$(dir $@)aapt2-flat-overlay-list \
|
2016-04-26 19:36:11 +02:00
|
|
|
\@$(dir $@)aapt2-flat-list
|
2018-03-09 01:49:16 +01:00
|
|
|
$(SOONG_ZIP) -o $(PRIVATE_SRCJAR) -C $(PRIVATE_JAVA_GEN_DIR) -D $(PRIVATE_JAVA_GEN_DIR)
|
2018-05-02 21:52:43 +02:00
|
|
|
$(EXTRACT_JAR_PACKAGES) -i $(PRIVATE_SRCJAR) -o $(PRIVATE_AAPT_EXTRA_PACKAGES) --prefix '--extra-packages '
|
2015-12-04 22:59:18 +01:00
|
|
|
endef
|
|
|
|
|
2018-05-09 22:29:51 +02:00
|
|
|
define _create-default-manifest-file
|
|
|
|
$(1):
|
|
|
|
rm -f $1
|
2018-05-24 01:32:48 +02:00
|
|
|
(echo '<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="missing.manifest">' && \
|
|
|
|
echo ' <uses-sdk android:minSdkVersion="$(2)" />' && \
|
|
|
|
echo '</manifest>' ) > $1
|
2018-05-09 22:29:51 +02:00
|
|
|
endef
|
|
|
|
|
|
|
|
define create-default-manifest-file
|
2018-05-24 01:32:48 +02:00
|
|
|
$(eval $(call _create-default-manifest-file,$(1),$(2)))
|
2018-05-09 22:29:51 +02:00
|
|
|
endef
|
|
|
|
|
|
|
|
|
2015-12-04 22:59:18 +01:00
|
|
|
###########################################################
|
2010-07-07 20:42:19 +02:00
|
|
|
xlint_unchecked := -Xlint:unchecked
|
2009-03-04 04:28:42 +01:00
|
|
|
|
|
|
|
# emit-line, <word list>, <output file>
|
|
|
|
define emit-line
|
|
|
|
$(if $(1),echo -n '$(strip $(1)) ' >> $(2))
|
|
|
|
endef
|
|
|
|
|
|
|
|
# dump-words-to-file, <word list>, <output file>
|
|
|
|
define dump-words-to-file
|
|
|
|
@rm -f $(2)
|
2015-10-06 15:28:38 +02:00
|
|
|
@touch $(2)
|
2016-04-26 19:36:11 +02:00
|
|
|
@$(call emit-line,$(wordlist 1,500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 501,1000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 1001,1500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 1501,2000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 2001,2500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 2501,3000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 3001,3500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 3501,4000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 4001,4500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 4501,5000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 5001,5500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 5501,6000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 6001,6500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 6501,7000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 7001,7500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 7501,8000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 8001,8500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 8501,9000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 9001,9500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 9501,10000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 10001,10500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 10501,11000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 11001,11500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 11501,12000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 12001,12500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 12501,13000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 13001,13500,$(1)),$(2))
|
2022-03-25 21:22:59 +01:00
|
|
|
@$(call emit-line,$(wordlist 13501,14000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 14001,14500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 14501,15000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 15001,15500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 15501,16000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 16001,16500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 16501,17000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 17001,17500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 17501,18000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 18001,18500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 18501,19000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 19001,19500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 19501,20000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 20001,20500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 20501,21000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 21001,21500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 21501,22000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 22001,22500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 22501,23000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 23001,23500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 23501,24000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 24001,24500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 24501,25000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 25001,25500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 25501,26000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 26001,26500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 26501,27000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 27001,27500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 27501,28000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 28001,28500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 28501,29000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 29001,29500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 29501,30000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 30001,30500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 30501,31000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 31001,31500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 31501,32000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 32001,32500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 32501,33000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 33001,33500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 33501,34000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 34001,34500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 34501,35000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 35001,35500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 35501,36000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 36001,36500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 36501,37000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 37001,37500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 37501,38000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 38001,38500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 38501,39000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 39001,39500,$(1)),$(2))
|
2022-06-14 20:18:45 +02:00
|
|
|
@$(call emit-line,$(wordlist 39501,40000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 40001,40500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 40501,41000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 41001,41500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 41501,42000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 42001,42500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 42501,43000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 43001,43500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 43501,44000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 44001,44500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 44501,45000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 45001,45500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 45501,46000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 46001,46500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 46501,47000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 47001,47500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 47501,48000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 48001,48500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 48501,49000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 49001,49500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 49501,50000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 50001,50500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 50501,51000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 51001,51500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 51501,52000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 52001,52500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 52501,53000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 53001,53500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 53501,54000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 54001,54500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 54501,55000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 55001,55500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 55501,56000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 56001,56500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 56501,57000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 57001,57500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 57501,58000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 58001,58500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 58501,59000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 59001,59500,$(1)),$(2))
|
2023-03-24 21:12:45 +01:00
|
|
|
@$(call emit-line,$(wordlist 59501,60000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 60001,60500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 60501,61000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 61001,61500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 61501,62000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 62001,62500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 62501,63000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 63001,63500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 63501,64000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 64001,64500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 64501,65000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 65001,65500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 65501,66000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 66001,66500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 66501,67000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 67001,67500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 67501,68000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 68001,68500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 68501,69000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 69001,69500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 69501,70000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 70001,70500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 70501,71000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 71001,71500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 71501,72000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 72001,72500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 72501,73000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 73001,73500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 73501,74000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 74001,74500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 74501,75000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 75001,75500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 75501,76000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 76001,76500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 76501,77000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 77001,77500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 77501,78000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 78001,78500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 78501,79000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 79001,79500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 79501,80000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 80001,80500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 80501,81000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 81001,81500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 81501,82000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 82001,82500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 82501,83000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 83001,83500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 83501,84000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 84001,84500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 84501,85000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 85001,85500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 85501,86000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 86001,86500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 86501,87000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 87001,87500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 87501,88000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 88001,88500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 88501,89000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 89001,89500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 89501,90000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 90001,90500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 90501,91000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 91001,91500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 91501,92000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 92001,92500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 92501,93000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 93001,93500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 93501,94000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 94001,94500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 94501,95000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 95001,95500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 95501,96000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 96001,96500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 96501,97000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 97001,97500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 97501,98000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 98001,98500,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 98501,99000,$(1)),$(2))
|
|
|
|
@$(call emit-line,$(wordlist 99001,99500,$(1)),$(2))
|
|
|
|
@$(if $(wordlist 99501,99502,$(1)),$(error dump-words-to-file: Too many words ($(words $(1)))))
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
2017-08-11 00:24:10 +02:00
|
|
|
# Return jar arguments to compress files in a given directory
|
|
|
|
# $(1): directory
|
|
|
|
#
|
|
|
|
# Returns an @-file argument that contains the output of a subshell
|
|
|
|
# that looks like -C $(1) path/to/file1 -C $(1) path/to/file2
|
|
|
|
# Also adds "-C out/empty ." which avoids errors in jar when
|
|
|
|
# there are no files in the directory.
|
|
|
|
define jar-args-sorted-files-in-directory
|
|
|
|
@<(find $(1) -type f | sort | $(JAR_ARGS) $(1); echo "-C $(EMPTY_DIRECTORY) .")
|
|
|
|
endef
|
|
|
|
|
2017-10-04 18:26:06 +02:00
|
|
|
# append additional Java sources(resources/Proto sources, and etc) to $(1).
|
|
|
|
define fetch-additional-java-source
|
|
|
|
$(hide) if [ -d "$(PRIVATE_SOURCE_INTERMEDIATES_DIR)" ]; then \
|
|
|
|
find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name '*.java' -and -not -name '.*' >> $(1); \
|
|
|
|
fi
|
|
|
|
endef
|
|
|
|
|
2010-12-10 21:10:24 +01:00
|
|
|
# Some historical notes:
|
|
|
|
# - below we write the list of java files to java-source-list to avoid argument
|
|
|
|
# list length problems with Cygwin
|
|
|
|
# - we filter out duplicate java file names because eclipse's compiler
|
|
|
|
# doesn't like them.
|
2017-05-27 00:22:02 +02:00
|
|
|
define write-java-source-list
|
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) Java source list: $(PRIVATE_MODULE)"
|
|
|
|
$(hide) rm -f $@
|
|
|
|
$(call dump-words-to-file,$(sort $(PRIVATE_JAVA_SOURCES)),$@.tmp)
|
2017-10-04 18:26:06 +02:00
|
|
|
$(call fetch-additional-java-source,$@.tmp)
|
2017-05-27 00:22:02 +02:00
|
|
|
$(hide) tr ' ' '\n' < $@.tmp | $(NORMALIZE_PATH) | sort -u > $@
|
|
|
|
endef
|
|
|
|
|
|
|
|
# Common definition to invoke javac on the host and target.
|
2010-12-10 21:10:24 +01:00
|
|
|
#
|
|
|
|
# $(1): javac
|
2017-09-24 04:52:43 +02:00
|
|
|
# $(2): classpath_libs
|
2010-12-10 21:10:24 +01:00
|
|
|
define compile-java
|
2009-04-10 04:31:12 +02:00
|
|
|
$(hide) rm -f $@
|
2018-03-16 00:26:08 +01:00
|
|
|
$(hide) rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) $(PRIVATE_ANNO_INTERMEDIATES_DIR)
|
2010-12-10 21:10:24 +01:00
|
|
|
$(hide) mkdir -p $(dir $@)
|
2018-03-16 00:26:08 +01:00
|
|
|
$(hide) mkdir -p $(PRIVATE_CLASS_INTERMEDIATES_DIR) $(PRIVATE_ANNO_INTERMEDIATES_DIR)
|
2018-03-08 00:44:54 +01:00
|
|
|
$(if $(PRIVATE_SRCJARS),\
|
2018-03-16 00:26:08 +01:00
|
|
|
$(ZIPSYNC) -d $(PRIVATE_SRCJAR_INTERMEDIATES_DIR) -l $(PRIVATE_SRCJAR_LIST_FILE) -f "*.java" $(PRIVATE_SRCJARS))
|
2018-03-15 21:05:46 +01:00
|
|
|
$(hide) if [ -s $(PRIVATE_JAVA_SOURCE_LIST) $(if $(PRIVATE_SRCJARS),-o -s $(PRIVATE_SRCJAR_LIST_FILE) )] ; then \
|
2017-10-12 09:04:20 +02:00
|
|
|
$(SOONG_JAVAC_WRAPPER) $(JAVAC_WRAPPER) $(1) -encoding UTF-8 \
|
2012-10-18 19:54:49 +02:00
|
|
|
$(if $(findstring true,$(PRIVATE_WARNINGS_ENABLE)),$(xlint_unchecked),) \
|
2017-10-12 22:34:40 +02:00
|
|
|
$(if $(PRIVATE_USE_SYSTEM_MODULES), \
|
2017-11-01 17:53:09 +01:00
|
|
|
$(addprefix --system=,$(PRIVATE_SYSTEM_MODULES_DIR)), \
|
2017-10-12 22:34:40 +02:00
|
|
|
$(addprefix -bootclasspath ,$(strip \
|
|
|
|
$(call normalize-path-list,$(PRIVATE_BOOTCLASSPATH)) \
|
|
|
|
$(PRIVATE_EMPTY_BOOTCLASSPATH)))) \
|
2018-01-09 21:33:08 +01:00
|
|
|
$(if $(PRIVATE_USE_SYSTEM_MODULES), \
|
|
|
|
$(if $(PRIVATE_PATCH_MODULE), \
|
|
|
|
--patch-module=$(PRIVATE_PATCH_MODULE)=$(call normalize-path-list,. $(2)))) \
|
2017-11-01 17:53:09 +01:00
|
|
|
$(addprefix -classpath ,$(call normalize-path-list,$(strip \
|
|
|
|
$(if $(PRIVATE_USE_SYSTEM_MODULES), \
|
|
|
|
$(filter-out $(PRIVATE_SYSTEM_MODULES_LIBS),$(PRIVATE_BOOTCLASSPATH))) \
|
|
|
|
$(2)))) \
|
2012-10-18 19:54:49 +02:00
|
|
|
$(if $(findstring true,$(PRIVATE_WARNINGS_ENABLE)),$(xlint_unchecked),) \
|
2017-07-18 17:17:15 +02:00
|
|
|
-d $(PRIVATE_CLASS_INTERMEDIATES_DIR) -s $(PRIVATE_ANNO_INTERMEDIATES_DIR) \
|
2010-12-10 21:10:24 +01:00
|
|
|
$(PRIVATE_JAVACFLAGS) \
|
2017-05-27 00:22:02 +02:00
|
|
|
\@$(PRIVATE_JAVA_SOURCE_LIST) \
|
2018-03-08 00:44:54 +01:00
|
|
|
$(if $(PRIVATE_SRCJARS),\@$(PRIVATE_SRCJAR_LIST_FILE)) \
|
2017-03-29 23:01:24 +02:00
|
|
|
|| ( rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) ; exit 41 ) \
|
2011-12-13 02:52:03 +01:00
|
|
|
fi
|
2011-12-16 01:36:55 +01:00
|
|
|
$(if $(PRIVATE_JAR_EXCLUDE_FILES), $(hide) find $(PRIVATE_CLASS_INTERMEDIATES_DIR) \
|
|
|
|
-name $(word 1, $(PRIVATE_JAR_EXCLUDE_FILES)) \
|
|
|
|
$(addprefix -o -name , $(wordlist 2, 999, $(PRIVATE_JAR_EXCLUDE_FILES))) \
|
|
|
|
| xargs rm -rf)
|
2014-05-24 03:41:19 +02:00
|
|
|
$(if $(PRIVATE_JAR_PACKAGES), \
|
|
|
|
$(hide) find $(PRIVATE_CLASS_INTERMEDIATES_DIR) -mindepth 1 -type f \
|
|
|
|
$(foreach pkg, $(PRIVATE_JAR_PACKAGES), \
|
|
|
|
-not -path $(PRIVATE_CLASS_INTERMEDIATES_DIR)/$(subst .,/,$(pkg))/\*) -delete ; \
|
|
|
|
find $(PRIVATE_CLASS_INTERMEDIATES_DIR) -empty -delete)
|
|
|
|
$(if $(PRIVATE_JAR_EXCLUDE_PACKAGES), $(hide) rm -rf \
|
|
|
|
$(foreach pkg, $(PRIVATE_JAR_EXCLUDE_PACKAGES), \
|
|
|
|
$(PRIVATE_CLASS_INTERMEDIATES_DIR)/$(subst .,/,$(pkg))))
|
2020-04-16 21:43:40 +02:00
|
|
|
$(hide) $(SOONG_ZIP) -jar -o $@ -C $(PRIVATE_CLASS_INTERMEDIATES_DIR) -D $(PRIVATE_CLASS_INTERMEDIATES_DIR)
|
Running jarjar on Java resources.
Before this change, Java resources are added as a separate step
(add-java-resources-to-package) after dex is run, so jarjar isn't run on
the resource files.
With this change, we add Java resources immediately after we call javac,
so jarjar is run on the resource files (the module's own resource, as
well as resources carried by static Java libraries).
When we generate the final apk/jar, we use the jarjar'ed jar as the
inital pacakge file, with class files and empty folders removed.
When jack is enabled, in jack-java-to-dex we add the Java resources to
a temp jar using the PRIVATE_EXTRA_JAR_ARGS, and extrac the files in a
temp dir. Jack will process the resource files and output the result to
PRIVATE_JACK_INTERMEDIATES_DIR. When we package the final apk/jar, we
need to call add-carried-jack-resources to readd the resources.
(TODO: if jack can output all resources to a jar/zip file, we can use
that file as the initial package file as well.)
Bug: 18837479
Change-Id: I8d7296e30ec8d005054cf04c4f2aed6d7a0d823b
2015-01-14 23:23:56 +01:00
|
|
|
$(if $(PRIVATE_EXTRA_JAR_ARGS),$(call add-java-resources-to,$@))
|
2010-12-10 21:10:24 +01:00
|
|
|
endef
|
|
|
|
|
2017-08-31 23:43:04 +02:00
|
|
|
define transform-java-to-header.jar
|
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) Turbine: $(PRIVATE_MODULE)"
|
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
@rm -rf $(dir $@)/classes-turbine
|
|
|
|
@mkdir $(dir $@)/classes-turbine
|
2018-03-15 21:05:46 +01:00
|
|
|
$(hide) if [ -s $(PRIVATE_JAVA_SOURCE_LIST) -o -n "$(PRIVATE_SRCJARS)" ] ; then \
|
2017-08-31 23:43:04 +02:00
|
|
|
$(JAVA) -jar $(TURBINE) \
|
2017-09-24 03:19:05 +02:00
|
|
|
--output $@.premerged --temp_dir $(dir $@)/classes-turbine \
|
2018-03-08 00:44:54 +01:00
|
|
|
--sources \@$(PRIVATE_JAVA_SOURCE_LIST) --source_jars $(PRIVATE_SRCJARS) \
|
2018-03-14 06:19:17 +01:00
|
|
|
--javacopts $(PRIVATE_JAVACFLAGS) $(COMMON_JDK_FLAGS) -- \
|
2019-11-01 03:13:50 +01:00
|
|
|
$(if $(PRIVATE_USE_SYSTEM_MODULES), \
|
|
|
|
--system $(PRIVATE_SYSTEM_MODULES_DIR), \
|
2019-11-01 03:14:03 +01:00
|
|
|
--bootclasspath $(strip $(PRIVATE_BOOTCLASSPATH))) \
|
|
|
|
--classpath $(strip $(if $(PRIVATE_USE_SYSTEM_MODULES), \
|
2019-11-01 03:13:50 +01:00
|
|
|
$(filter-out $(PRIVATE_SYSTEM_MODULES_LIBS),$(PRIVATE_BOOTCLASSPATH))) \
|
2019-11-01 03:14:03 +01:00
|
|
|
$(PRIVATE_ALL_JAVA_HEADER_LIBRARIES)) \
|
2017-09-21 23:45:28 +02:00
|
|
|
|| ( rm -rf $(dir $@)/classes-turbine ; exit 41 ) && \
|
2019-04-29 19:25:20 +02:00
|
|
|
$(MERGE_ZIPS) -j --ignore-duplicates -stripDir META-INF $@.tmp $@.premerged $(PRIVATE_STATIC_JAVA_HEADER_LIBRARIES) ; \
|
2017-09-13 22:13:53 +02:00
|
|
|
else \
|
2019-04-29 19:25:20 +02:00
|
|
|
$(MERGE_ZIPS) -j --ignore-duplicates -stripDir META-INF $@.tmp $(PRIVATE_STATIC_JAVA_HEADER_LIBRARIES) ; \
|
2017-08-31 23:43:04 +02:00
|
|
|
fi
|
|
|
|
$(hide) $(ZIPTIME) $@.tmp
|
|
|
|
$(hide) $(call commit-change-for-toc,$@)
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
2021-02-08 19:55:05 +01:00
|
|
|
# Runs jarjar on an input file. Jarjar doesn't exit with a nonzero return code
|
|
|
|
# when there is a syntax error in a rules file and doesn't write the output
|
|
|
|
# file, so removes the output file before running jarjar and check if it exists
|
|
|
|
# after running jarjar.
|
|
|
|
define transform-jarjar
|
|
|
|
echo $($(PRIVATE_PREFIX)DISPLAY) JarJar: $@
|
|
|
|
rm -f $@
|
|
|
|
$(JAVA) -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@
|
|
|
|
[ -e $@ ] || (echo "Missing output file"; exit 1)
|
|
|
|
endef
|
|
|
|
|
2015-11-09 08:47:42 +01:00
|
|
|
# Moves $1.tmp to $1 if necessary. This is designed to be used with
|
|
|
|
# .KATI_RESTAT. For kati, this function doesn't update the timestamp
|
|
|
|
# of $1 when $1.tmp is identical to $1 so that ninja won't rebuild
|
2016-01-06 23:28:36 +01:00
|
|
|
# targets which depend on $1.
|
2015-11-09 08:47:42 +01:00
|
|
|
define commit-change-for-toc
|
|
|
|
$(hide) if cmp -s $1.tmp $1 ; then \
|
|
|
|
rm $1.tmp ; \
|
|
|
|
else \
|
|
|
|
mv $1.tmp $1 ; \
|
|
|
|
fi
|
|
|
|
endef
|
|
|
|
|
2015-12-09 10:06:20 +01:00
|
|
|
ifeq (,$(TARGET_BUILD_APPS))
|
|
|
|
|
|
|
|
## Rule to create a table of contents from a .dex file.
|
|
|
|
## Must be called with $(eval).
|
|
|
|
# $(1): The directory which contains classes*.dex files
|
|
|
|
define _transform-dex-to-toc
|
|
|
|
$1/classes.dex.toc: PRIVATE_INPUT_DEX_FILES := $1/classes*.dex
|
|
|
|
$1/classes.dex.toc: $1/classes.dex $(DEXDUMP)
|
|
|
|
@echo Generating TOC: $$@
|
2016-06-24 18:17:04 +02:00
|
|
|
$(hide) ANDROID_LOG_TAGS="*:e" $(DEXDUMP) -l xml $$(PRIVATE_INPUT_DEX_FILES) > $$@.tmp
|
2015-12-09 10:06:20 +01:00
|
|
|
$$(call commit-change-for-toc,$$@)
|
|
|
|
endef
|
|
|
|
|
|
|
|
## Define a rule which generates .dex.toc and mark it as .KATI_RESTAT.
|
|
|
|
# $(1): The directory which contains classes*.dex files
|
|
|
|
define define-dex-to-toc-rule
|
|
|
|
$(eval $(call _transform-dex-to-toc,$1))\
|
|
|
|
$(eval .KATI_RESTAT: $1/classes.dex.toc)
|
|
|
|
endef
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
# Turn off .toc optimization for apps build as we cannot build dexdump.
|
|
|
|
define define-dex-to-toc-rule
|
|
|
|
endef
|
|
|
|
|
|
|
|
endif # TARGET_BUILD_APPS
|
|
|
|
|
2014-09-08 14:45:14 +02:00
|
|
|
|
2017-03-15 02:11:38 +01:00
|
|
|
# Takes an sdk version that might be PLATFORM_VERSION_CODENAME (for example P),
|
|
|
|
# returns a number greater than the highest existing sdk version if it is, or
|
|
|
|
# the input if it is not.
|
|
|
|
define codename-or-sdk-to-sdk
|
|
|
|
$(if $(filter $(1),$(PLATFORM_VERSION_CODENAME)),10000,$(1))
|
|
|
|
endef
|
|
|
|
|
2019-02-07 00:40:03 +01:00
|
|
|
# Uses LOCAL_SDK_VERSION and PLATFORM_SDK_VERSION to determine a compileSdkVersion
|
|
|
|
# in the form of a number or a codename (28 or P)
|
|
|
|
define module-sdk-version
|
|
|
|
$(strip \
|
|
|
|
$(if $(filter-out current system_current test_current core_current,$(LOCAL_SDK_VERSION)), \
|
|
|
|
$(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION)), \
|
|
|
|
$(PLATFORM_SDK_VERSION)))
|
|
|
|
endef
|
|
|
|
|
|
|
|
# Uses LOCAL_SDK_VERSION and DEFAULT_APP_TARGET_SDK to determine
|
|
|
|
# a targetSdkVersion in the form of a number or a codename (28 or P).
|
|
|
|
define module-target-sdk-version
|
|
|
|
$(strip \
|
|
|
|
$(if $(filter-out current system_current test_current core_current,$(LOCAL_SDK_VERSION)), \
|
|
|
|
$(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION)), \
|
|
|
|
$(DEFAULT_APP_TARGET_SDK)))
|
|
|
|
endef
|
|
|
|
|
|
|
|
# Uses LOCAL_MIN_SDK_VERSION, LOCAL_SDK_VERSION and DEFAULT_APP_TARGET_SDK to determine
|
|
|
|
# a minSdkVersion in the form of a number or a codename (28 or P).
|
|
|
|
define module-min-sdk-version
|
|
|
|
$(if $(LOCAL_MIN_SDK_VERSION),$(LOCAL_MIN_SDK_VERSION),$(call module-target-sdk-version))
|
|
|
|
endef
|
|
|
|
|
2016-12-22 02:11:03 +01:00
|
|
|
|
2016-12-21 23:29:13 +01:00
|
|
|
define transform-classes.jar-to-dex
|
|
|
|
@echo "target Dex: $(PRIVATE_MODULE)"
|
2020-02-13 06:54:26 +01:00
|
|
|
@mkdir -p $(dir $@)tmp
|
2017-12-13 09:11:40 +01:00
|
|
|
$(hide) rm -f $(dir $@)classes*.dex $(dir $@)d8_input.jar
|
|
|
|
$(hide) $(ZIP2ZIP) -j -i $< -o $(dir $@)d8_input.jar "**/*.class"
|
2022-04-22 11:47:42 +02:00
|
|
|
$(hide) $(D8_WRAPPER) $(D8_COMMAND) \
|
2020-02-13 06:54:26 +01:00
|
|
|
--output $(dir $@)tmp \
|
2018-09-21 21:36:53 +02:00
|
|
|
$(addprefix --lib ,$(PRIVATE_D8_LIBS)) \
|
2017-12-01 23:32:58 +01:00
|
|
|
--min-api $(PRIVATE_MIN_SDK_VERSION) \
|
2017-12-13 09:11:40 +01:00
|
|
|
$(subst --main-dex-list=, --main-dex-list , \
|
2017-12-21 20:52:57 +01:00
|
|
|
$(filter-out --core-library --multi-dex --minimal-main-dex,$(PRIVATE_DX_FLAGS))) \
|
2017-12-13 09:11:40 +01:00
|
|
|
$(dir $@)d8_input.jar
|
2020-02-13 06:54:26 +01:00
|
|
|
$(hide) mv $(dir $@)tmp/* $(dir $@)
|
2017-12-13 09:11:40 +01:00
|
|
|
$(hide) rm -f $(dir $@)d8_input.jar
|
2020-02-13 06:54:26 +01:00
|
|
|
$(hide) rm -rf $(dir $@)tmp
|
2017-12-01 23:32:58 +01:00
|
|
|
endef
|
|
|
|
|
2014-06-25 05:01:52 +02:00
|
|
|
# We need the extra blank line, so that the command will be on a separate line.
|
2018-09-14 00:11:42 +02:00
|
|
|
# $(1): the package
|
|
|
|
# $(2): the ABI name
|
|
|
|
# $(3): the list of shared libraies
|
2014-06-25 05:01:52 +02:00
|
|
|
define _add-jni-shared-libs-to-package-per-abi
|
2018-09-14 00:11:42 +02:00
|
|
|
$(hide) cp $(3) $(dir $(1))lib/$(2)
|
2014-06-25 05:01:52 +02:00
|
|
|
|
|
|
|
endef
|
|
|
|
|
2018-09-14 00:11:42 +02:00
|
|
|
# $(1): the package file
|
2019-02-07 01:36:32 +01:00
|
|
|
# $(2): if true, uncompress jni libs
|
2018-09-14 22:39:07 +02:00
|
|
|
define create-jni-shared-libs-package
|
|
|
|
rm -rf $(dir $(1))lib
|
|
|
|
mkdir -p $(addprefix $(dir $(1))lib/,$(PRIVATE_JNI_SHARED_LIBRARIES_ABI))
|
2014-06-25 05:01:52 +02:00
|
|
|
$(foreach abi,$(PRIVATE_JNI_SHARED_LIBRARIES_ABI),\
|
2018-09-14 00:11:42 +02:00
|
|
|
$(call _add-jni-shared-libs-to-package-per-abi,$(1),$(abi),\
|
2014-06-25 05:01:52 +02:00
|
|
|
$(patsubst $(abi):%,%,$(filter $(abi):%,$(PRIVATE_JNI_SHARED_LIBRARIES)))))
|
2019-02-07 01:36:32 +01:00
|
|
|
$(SOONG_ZIP) $(if $(2),-L 0) -o $(1) -C $(dir $(1)) -D $(dir $(1))lib
|
2018-09-14 22:39:07 +02:00
|
|
|
rm -rf $(dir $(1))lib
|
2018-09-15 14:46:44 +02:00
|
|
|
endef
|
|
|
|
|
2018-09-14 22:39:07 +02:00
|
|
|
# $(1): the jar file.
|
|
|
|
# $(2): the classes.dex file.
|
|
|
|
define create-dex-jar
|
|
|
|
find $(dir $(2)) -maxdepth 1 -name "classes*.dex" | sort > $(1).lst
|
|
|
|
$(SOONG_ZIP) -o $(1) -C $(dir $(2)) -l $(1).lst
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
2018-09-14 22:39:07 +02:00
|
|
|
# Add java resources added by the current module to an existing package.
|
|
|
|
# $(1) destination package.
|
2014-11-19 14:01:06 +01:00
|
|
|
define add-java-resources-to
|
2018-09-14 22:39:07 +02:00
|
|
|
$(call _java-resources,$(1),u)
|
|
|
|
endef
|
|
|
|
|
|
|
|
# Add java resources added by the current module to a new jar.
|
|
|
|
# $(1) destination jar.
|
|
|
|
define create-java-resources-jar
|
|
|
|
$(call _java-resources,$(1),c)
|
|
|
|
endef
|
|
|
|
|
|
|
|
define _java-resources
|
2014-11-19 14:01:06 +01:00
|
|
|
$(call dump-words-to-file, $(PRIVATE_EXTRA_JAR_ARGS), $(1).jar-arg-list)
|
2018-09-14 22:39:07 +02:00
|
|
|
$(hide) $(JAR) $(2)f $(1) @$(1).jar-arg-list
|
2014-11-19 14:01:06 +01:00
|
|
|
@rm -f $(1).jar-arg-list
|
|
|
|
endef
|
|
|
|
|
2017-08-03 05:17:34 +02:00
|
|
|
# Add resources (non .class files) from a jar to a package
|
|
|
|
# $(1): the package file
|
|
|
|
# $(2): the jar file
|
|
|
|
# $(3): temporary directory
|
|
|
|
define add-jar-resources-to-package
|
|
|
|
rm -rf $(3)
|
|
|
|
mkdir -p $(3)
|
2021-08-06 16:02:34 +02:00
|
|
|
zipinfo -1 $(2) > /dev/null
|
2017-08-03 05:17:34 +02:00
|
|
|
unzip -qo $(2) -d $(3) $$(zipinfo -1 $(2) | grep -v -E "\.class$$")
|
2017-08-11 00:24:10 +02:00
|
|
|
$(JAR) uf $(1) $(call jar-args-sorted-files-in-directory,$(3))
|
2017-08-03 05:17:34 +02:00
|
|
|
endef
|
|
|
|
|
2018-09-14 22:39:07 +02:00
|
|
|
# $(1): the output resources jar.
|
|
|
|
# $(2): the input jar
|
|
|
|
define extract-resources-jar
|
|
|
|
$(ZIP2ZIP) -i $(2) -o $(1) -x '**/*.class' -x '**/*/'
|
|
|
|
endef
|
|
|
|
|
2009-03-04 04:28:42 +01:00
|
|
|
# Sign a package using the specified key/cert.
|
|
|
|
#
|
|
|
|
define sign-package
|
2016-03-11 19:32:01 +01:00
|
|
|
$(call sign-package-arg,$@)
|
|
|
|
endef
|
|
|
|
|
|
|
|
# $(1): the package file we are signing.
|
|
|
|
define sign-package-arg
|
|
|
|
$(hide) mv $(1) $(1).unsigned
|
2019-08-08 21:56:01 +02:00
|
|
|
$(hide) $(JAVA) -Djava.library.path=$$(dirname $(SIGNAPK_JNI_LIBRARY_PATH)) -jar $(SIGNAPK_JAR) \
|
2020-04-02 22:01:08 +02:00
|
|
|
$(if $(strip $(PRIVATE_CERTIFICATE_LINEAGE)), --lineage $(PRIVATE_CERTIFICATE_LINEAGE)) \
|
2021-10-20 17:37:23 +02:00
|
|
|
$(if $(strip $(PRIVATE_ROTATION_MIN_SDK_VERSION)), --rotation-min-sdk-version $(PRIVATE_ROTATION_MIN_SDK_VERSION)) \
|
2012-11-13 19:55:28 +01:00
|
|
|
$(PRIVATE_CERTIFICATE) $(PRIVATE_PRIVATE_KEY) \
|
2016-03-11 19:32:01 +01:00
|
|
|
$(PRIVATE_ADDITIONAL_CERTIFICATES) $(1).unsigned $(1).signed
|
|
|
|
$(hide) mv $(1).signed $(1)
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
2014-07-24 00:27:21 +02:00
|
|
|
# Align STORED entries of a package on 4-byte boundaries to make them easier to mmap.
|
2009-03-04 04:28:42 +01:00
|
|
|
#
|
|
|
|
define align-package
|
2019-10-10 21:50:51 +02:00
|
|
|
$(hide) if ! $(ZIPALIGN) -c -p 4 $@ >/dev/null ; then \
|
2016-04-29 16:32:00 +02:00
|
|
|
mv $@ $@.unaligned; \
|
|
|
|
$(ZIPALIGN) \
|
2015-07-16 03:33:24 +02:00
|
|
|
-f \
|
2019-02-07 01:36:32 +01:00
|
|
|
-p \
|
2014-07-24 00:27:21 +02:00
|
|
|
4 \
|
2016-04-29 16:32:00 +02:00
|
|
|
$@.unaligned $@.aligned; \
|
|
|
|
mv $@.aligned $@; \
|
|
|
|
fi
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
2021-05-13 01:49:25 +02:00
|
|
|
# Verifies ZIP alignment of a package.
|
|
|
|
#
|
|
|
|
define check-package-alignment
|
|
|
|
$(hide) if ! $(ZIPALIGN) -c -p 4 $@ >/dev/null ; then \
|
|
|
|
$(call echo-error,$@,Improper package alignment); \
|
|
|
|
exit 1; \
|
|
|
|
fi
|
|
|
|
endef
|
|
|
|
|
2017-08-07 13:31:17 +02:00
|
|
|
# Compress a package using the standard gzip algorithm.
|
|
|
|
define compress-package
|
|
|
|
$(hide) \
|
|
|
|
mv $@ $@.uncompressed; \
|
|
|
|
$(MINIGZIP) -c $@.uncompressed > $@.compressed; \
|
|
|
|
rm -f $@.uncompressed; \
|
|
|
|
mv $@.compressed $@;
|
|
|
|
endef
|
|
|
|
|
2018-07-13 17:44:28 +02:00
|
|
|
ifeq ($(HOST_OS),linux)
|
|
|
|
# Runs appcompat and store logs in $(PRODUCT_OUT)/appcompat
|
2018-07-31 16:29:13 +02:00
|
|
|
define extract-package
|
2019-02-26 07:21:24 +01:00
|
|
|
$(AAPT2) dump resources $@ | awk -F ' |=' '/^Package/{print $$3}' >> $(PRODUCT_OUT)/appcompat/$(PRIVATE_MODULE).log &&
|
2018-07-31 16:29:13 +02:00
|
|
|
endef
|
|
|
|
define appcompat-header
|
|
|
|
$(hide) \
|
|
|
|
mkdir -p $(PRODUCT_OUT)/appcompat && \
|
|
|
|
rm -f $(PRODUCT_OUT)/appcompat/$(PRIVATE_MODULE).log && \
|
|
|
|
echo -n "Package name: " >> $(PRODUCT_OUT)/appcompat/$(PRIVATE_MODULE).log && \
|
2019-02-26 07:21:24 +01:00
|
|
|
$(extract-package) \
|
2018-07-31 16:29:13 +02:00
|
|
|
echo "Module name in Android tree: $(PRIVATE_MODULE)" >> $(PRODUCT_OUT)/appcompat/$(PRIVATE_MODULE).log && \
|
|
|
|
echo "Local path in Android tree: $(PRIVATE_PATH)" >> $(PRODUCT_OUT)/appcompat/$(PRIVATE_MODULE).log && \
|
|
|
|
echo "Install path on $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT): $(PRIVATE_INSTALLED_MODULE)" >> $(PRODUCT_OUT)/appcompat/$(PRIVATE_MODULE).log && \
|
|
|
|
echo >> $(PRODUCT_OUT)/appcompat/$(PRIVATE_MODULE).log
|
|
|
|
endef
|
2019-07-10 15:00:44 +02:00
|
|
|
ART_VERIDEX_APPCOMPAT_SCRIPT:=$(HOST_OUT)/bin/appcompat.sh
|
2018-07-13 17:44:28 +02:00
|
|
|
define run-appcompat
|
|
|
|
$(hide) \
|
2018-07-31 16:29:13 +02:00
|
|
|
echo "appcompat.sh output:" >> $(PRODUCT_OUT)/appcompat/$(PRIVATE_MODULE).log && \
|
2019-07-10 15:00:44 +02:00
|
|
|
PACKAGING=$(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING ANDROID_LOG_TAGS="*:e" $(ART_VERIDEX_APPCOMPAT_SCRIPT) --dex-file=$@ --api-flags=$(INTERNAL_PLATFORM_HIDDENAPI_FLAGS) 2>&1 >> $(PRODUCT_OUT)/appcompat/$(PRIVATE_MODULE).log
|
2018-07-13 17:44:28 +02:00
|
|
|
endef
|
2018-09-17 23:36:37 +02:00
|
|
|
appcompat-files = \
|
2019-08-01 13:15:19 +02:00
|
|
|
$(AAPT2) \
|
2019-07-10 15:00:44 +02:00
|
|
|
$(ART_VERIDEX_APPCOMPAT_SCRIPT) \
|
2018-10-30 19:24:06 +01:00
|
|
|
$(INTERNAL_PLATFORM_HIDDENAPI_FLAGS) \
|
2018-09-17 23:36:37 +02:00
|
|
|
$(HOST_OUT_EXECUTABLES)/veridex \
|
|
|
|
$(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/core_dex_intermediates/classes.dex \
|
|
|
|
$(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/oahl_dex_intermediates/classes.dex
|
2018-07-13 17:44:28 +02:00
|
|
|
else
|
2018-07-31 16:29:13 +02:00
|
|
|
appcompat-header =
|
2018-07-13 17:44:28 +02:00
|
|
|
run-appcompat =
|
2018-09-17 23:36:37 +02:00
|
|
|
appcompat-files =
|
2018-07-31 16:29:13 +02:00
|
|
|
endif # HOST_OS == linux
|
2018-09-17 23:36:37 +02:00
|
|
|
.KATI_READONLY: appcompat-header run-appcompat appcompat-files
|
2018-07-13 17:44:28 +02:00
|
|
|
|
2015-10-30 00:33:05 +01:00
|
|
|
# Remove dynamic timestamps from packages
|
|
|
|
#
|
|
|
|
define remove-timestamps-from-package
|
|
|
|
$(hide) $(ZIPTIME) $@
|
|
|
|
endef
|
|
|
|
|
2017-09-19 13:51:45 +02:00
|
|
|
# Uncompress dex files embedded in an apk.
|
|
|
|
#
|
|
|
|
define uncompress-dexs
|
2018-10-08 06:32:07 +02:00
|
|
|
if (zipinfo $@ '*.dex' 2>/dev/null | grep -v ' stor ' >/dev/null) ; then \
|
|
|
|
$(ZIP2ZIP) -i $@ -o $@.tmp -0 "classes*.dex" && \
|
|
|
|
mv -f $@.tmp $@ ; \
|
2017-09-19 13:51:45 +02:00
|
|
|
fi
|
|
|
|
endef
|
|
|
|
|
2018-10-09 19:17:55 +02:00
|
|
|
# Uncompress shared JNI libraries embedded in an apk.
|
2015-05-01 23:02:26 +02:00
|
|
|
#
|
2018-10-09 19:17:55 +02:00
|
|
|
define uncompress-prebuilt-embedded-jni-libs
|
|
|
|
if (zipinfo $@ 'lib/*.so' 2>/dev/null | grep -v ' stor ' >/dev/null) ; then \
|
2021-02-19 00:06:08 +01:00
|
|
|
$(ZIP2ZIP) -i $@ -o $@.tmp -0 'lib/**/*.so' && mv -f $@.tmp $@ ; \
|
2015-05-01 23:02:26 +02:00
|
|
|
fi
|
2015-04-18 01:53:15 +02:00
|
|
|
endef
|
|
|
|
|
2021-05-13 01:49:25 +02:00
|
|
|
# Verifies shared JNI libraries and dex files in an apk are uncompressed.
|
|
|
|
#
|
|
|
|
define check-jni-dex-compression
|
|
|
|
if (zipinfo $@ 'lib/*.so' '*.dex' 2>/dev/null | grep -v ' stor ' >/dev/null) ; then \
|
|
|
|
$(call echo-error,$@,Contains compressed JNI libraries and/or dex files); \
|
|
|
|
exit 1; \
|
|
|
|
fi
|
|
|
|
endef
|
|
|
|
|
2021-02-19 00:06:08 +01:00
|
|
|
# Remove unwanted shared JNI libraries embedded in an apk.
|
|
|
|
#
|
|
|
|
define remove-unwanted-prebuilt-embedded-jni-libs
|
|
|
|
$(if $(PRIVATE_EMBEDDED_JNI_LIBS), \
|
|
|
|
$(ZIP2ZIP) -i $@ -o $@.tmp \
|
|
|
|
-x 'lib/**/*.so' $(addprefix -X ,$(PRIVATE_EMBEDDED_JNI_LIBS)) && \
|
|
|
|
mv -f $@.tmp $@)
|
|
|
|
endef
|
|
|
|
|
2009-03-04 04:28:42 +01:00
|
|
|
# TODO(joeo): If we can ever upgrade to post 3.81 make and get the
|
|
|
|
# new prebuilt rules to work, we should change this to copy the
|
|
|
|
# resources to the out directory and then copy the resources.
|
|
|
|
|
2010-12-10 21:10:24 +01:00
|
|
|
# Note: we intentionally don't clean PRIVATE_CLASS_INTERMEDIATES_DIR
|
|
|
|
# in transform-java-to-classes for the sake of vm-tests.
|
2009-03-04 04:28:42 +01:00
|
|
|
define transform-host-java-to-package
|
2017-08-31 23:43:04 +02:00
|
|
|
@echo "Host Java: $(PRIVATE_MODULE) ($(PRIVATE_CLASS_INTERMEDIATES_DIR))"
|
2017-09-24 04:52:43 +02:00
|
|
|
$(call compile-java,$(HOST_JAVAC),$(PRIVATE_ALL_JAVA_LIBRARIES))
|
2017-08-31 23:43:04 +02:00
|
|
|
endef
|
|
|
|
|
|
|
|
# Note: we intentionally don't clean PRIVATE_CLASS_INTERMEDIATES_DIR
|
|
|
|
# in transform-java-to-classes for the sake of vm-tests.
|
|
|
|
define transform-host-java-to-dalvik-package
|
|
|
|
@echo "Dalvik Java: $(PRIVATE_MODULE) ($(PRIVATE_CLASS_INTERMEDIATES_DIR))"
|
2017-09-24 04:52:43 +02:00
|
|
|
$(call compile-java,$(HOST_JAVAC),$(PRIVATE_ALL_JAVA_HEADER_LIBRARIES))
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Commands for copying files
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
# Define a rule to copy a header. Used via $(eval) by copy_headers.make.
|
|
|
|
# $(1): source header
|
|
|
|
# $(2): destination header
|
|
|
|
define copy-one-header
|
|
|
|
$(2): $(1)
|
|
|
|
@echo "Header: $$@"
|
|
|
|
$$(copy-file-to-new-target-with-cp)
|
|
|
|
endef
|
|
|
|
|
|
|
|
# Define a rule to copy a file. For use via $(eval).
|
|
|
|
# $(1): source file
|
|
|
|
# $(2): destination file
|
|
|
|
define copy-one-file
|
Replace some uses of acp with cp
ACP was originally created to overcome differences with cp between
Linux, Darwin, and Windows. We've since dropped Windows as a build host,
and don't use features like '-u' anymore.
For most of our current usecases, 'acp' is identical to 'cp' except that
it splits 'cp -p' into 'acp -p' for mode and ownership, and 'acp -t' for
timestamps. On Linux, this could be specified using
'--preserve=mode,ownership', but Darwin doesn't have this.
Since we're removing the destination file before copying, 'cp' already
preserves the mode (modulated by the umask). So the only extra thing
that gets preserved with 'acp -p' is ownership, which we should not care
about in the build system. (In many cases we shouldn't be preserving
mode either, so that readonly source trees can actually be marked
readonly, but that will be a future change)
Change-Id: Ied96fdc303ac5c774347c07363daec8b6dfb22e4
2016-02-29 21:45:18 +01:00
|
|
|
$(2): $(1)
|
2009-03-04 04:28:42 +01:00
|
|
|
@echo "Copy: $$@"
|
|
|
|
$$(copy-file-to-target)
|
|
|
|
endef
|
|
|
|
|
2022-07-30 00:31:21 +02:00
|
|
|
# Define a rule to copy a license metadata file. For use via $(eval).
|
|
|
|
# $(1): source license metadata file
|
|
|
|
# $(2): destination license metadata file
|
|
|
|
# $(3): built targets
|
|
|
|
# $(4): installed targets
|
|
|
|
define copy-one-license-metadata-file
|
|
|
|
$(2): PRIVATE_BUILT=$(3)
|
|
|
|
$(2): PRIVATE_INSTALLED=$(4)
|
|
|
|
$(2): $(1)
|
|
|
|
@echo "Copy: $$@"
|
|
|
|
$$(call copy-license-metadata-file-to-target,$$(PRIVATE_BUILT),$$(PRIVATE_INSTALLED))
|
|
|
|
endef
|
|
|
|
|
2017-09-19 14:10:31 +02:00
|
|
|
define copy-and-uncompress-dexs
|
2018-10-08 06:32:07 +02:00
|
|
|
$(2): $(1) $(ZIPALIGN) $(ZIP2ZIP)
|
2017-09-19 14:10:31 +02:00
|
|
|
@echo "Uncompress dexs in: $$@"
|
|
|
|
$$(copy-file-to-target)
|
|
|
|
$$(uncompress-dexs)
|
|
|
|
$$(align-package)
|
|
|
|
endef
|
|
|
|
|
2019-03-14 02:04:05 +01:00
|
|
|
# Create copy pair for compatibility suite
|
|
|
|
# Filter out $(LOCAL_INSTALLED_MODULE) to prevent overriding target
|
|
|
|
# $(1): source path
|
|
|
|
# $(2): destination path
|
|
|
|
# The format of copy pair is src:dst
|
|
|
|
define compat-copy-pair
|
|
|
|
$(if $(filter-out $(2), $(LOCAL_INSTALLED_MODULE)), $(1):$(2))
|
|
|
|
endef
|
|
|
|
|
2019-09-13 21:02:46 +02:00
|
|
|
# Create copy pair for $(1) $(2)
|
|
|
|
# If $(2) is substring of $(3) do nothing.
|
|
|
|
# $(1): source path
|
|
|
|
# $(2): destination path
|
|
|
|
# $(3): filter-out target
|
|
|
|
# The format of copy pair is src:dst
|
|
|
|
define filter-copy-pair
|
|
|
|
$(if $(findstring $(2), $(3)),,$(1):$(2))
|
|
|
|
endef
|
|
|
|
|
2012-05-18 02:12:04 +02:00
|
|
|
# Copies many files.
|
|
|
|
# $(1): The files to copy. Each entry is a ':' separated src:dst pair
|
2019-02-11 23:24:38 +01:00
|
|
|
# $(2): An optional directory to prepend to the destination
|
2012-05-18 02:12:04 +02:00
|
|
|
# Evaluates to the list of the dst files (ie suitable for a dependency list)
|
|
|
|
define copy-many-files
|
|
|
|
$(foreach f, $(1), $(strip \
|
|
|
|
$(eval _cmf_tuple := $(subst :, ,$(f))) \
|
|
|
|
$(eval _cmf_src := $(word 1,$(_cmf_tuple))) \
|
|
|
|
$(eval _cmf_dest := $(word 2,$(_cmf_tuple))) \
|
2019-02-11 23:24:38 +01:00
|
|
|
$(if $(strip $(2)), \
|
|
|
|
$(eval _cmf_dest := $(patsubst %/,%,$(strip $(2)))/$(patsubst /%,%,$(_cmf_dest)))) \
|
2018-10-05 10:58:14 +02:00
|
|
|
$(if $(filter-out $(_cmf_src), $(_cmf_dest)), \
|
|
|
|
$(eval $(call copy-one-file,$(_cmf_src),$(_cmf_dest)))) \
|
2012-05-18 02:12:04 +02:00
|
|
|
$(_cmf_dest)))
|
|
|
|
endef
|
|
|
|
|
2018-06-13 23:51:05 +02:00
|
|
|
# Copy the file only if it's a well-formed init script file. For use via $(eval).
|
|
|
|
# $(1): source file
|
|
|
|
# $(2): destination file
|
|
|
|
define copy-init-script-file-checked
|
2021-04-22 03:04:30 +02:00
|
|
|
ifdef TARGET_BUILD_UNBUNDLED
|
2022-06-18 17:23:35 +02:00
|
|
|
# TODO (b/185624993): Remove the check on TARGET_BUILD_UNBUNDLED when host_init_verifier can run
|
2021-04-22 03:04:30 +02:00
|
|
|
# without requiring the HIDL interface map.
|
|
|
|
$(2): $(1)
|
|
|
|
else ifneq ($(HOST_OS),darwin)
|
2018-06-13 23:51:05 +02:00
|
|
|
# Host init verifier doesn't exist on darwin.
|
2019-06-20 22:40:39 +02:00
|
|
|
$(2): \
|
|
|
|
$(1) \
|
|
|
|
$(HOST_INIT_VERIFIER) \
|
2019-07-12 00:31:36 +02:00
|
|
|
$(call intermediates-dir-for,ETC,passwd_system)/passwd_system \
|
2020-11-11 00:33:41 +01:00
|
|
|
$(call intermediates-dir-for,ETC,passwd_system_ext)/passwd_system_ext \
|
2019-07-12 00:31:36 +02:00
|
|
|
$(call intermediates-dir-for,ETC,passwd_vendor)/passwd_vendor \
|
|
|
|
$(call intermediates-dir-for,ETC,passwd_odm)/passwd_odm \
|
2019-11-09 02:57:21 +01:00
|
|
|
$(call intermediates-dir-for,ETC,passwd_product)/passwd_product \
|
|
|
|
$(call intermediates-dir-for,ETC,plat_property_contexts)/plat_property_contexts \
|
|
|
|
$(call intermediates-dir-for,ETC,system_ext_property_contexts)/system_ext_property_contexts \
|
|
|
|
$(call intermediates-dir-for,ETC,product_property_contexts)/product_property_contexts \
|
|
|
|
$(call intermediates-dir-for,ETC,vendor_property_contexts)/vendor_property_contexts \
|
|
|
|
$(call intermediates-dir-for,ETC,odm_property_contexts)/odm_property_contexts
|
2019-07-12 00:31:36 +02:00
|
|
|
$(hide) $(HOST_INIT_VERIFIER) \
|
|
|
|
-p $(call intermediates-dir-for,ETC,passwd_system)/passwd_system \
|
2020-11-11 00:33:41 +01:00
|
|
|
-p $(call intermediates-dir-for,ETC,passwd_system_ext)/passwd_system_ext \
|
2019-07-12 00:31:36 +02:00
|
|
|
-p $(call intermediates-dir-for,ETC,passwd_vendor)/passwd_vendor \
|
|
|
|
-p $(call intermediates-dir-for,ETC,passwd_odm)/passwd_odm \
|
|
|
|
-p $(call intermediates-dir-for,ETC,passwd_product)/passwd_product \
|
2019-11-09 02:57:21 +01:00
|
|
|
--property-contexts=$(call intermediates-dir-for,ETC,plat_property_contexts)/plat_property_contexts \
|
|
|
|
--property-contexts=$(call intermediates-dir-for,ETC,system_ext_property_contexts)/system_ext_property_contexts \
|
|
|
|
--property-contexts=$(call intermediates-dir-for,ETC,product_property_contexts)/product_property_contexts \
|
|
|
|
--property-contexts=$(call intermediates-dir-for,ETC,vendor_property_contexts)/vendor_property_contexts \
|
|
|
|
--property-contexts=$(call intermediates-dir-for,ETC,odm_property_contexts)/odm_property_contexts \
|
2019-10-15 23:59:27 +02:00
|
|
|
$$<
|
2018-06-13 23:51:05 +02:00
|
|
|
else
|
|
|
|
$(2): $(1)
|
|
|
|
endif
|
|
|
|
@echo "Copy init script: $$@"
|
|
|
|
$$(copy-file-to-target)
|
|
|
|
endef
|
|
|
|
|
|
|
|
# Copies many init script files and check they are well-formed.
|
|
|
|
# $(1): The init script files to copy. Each entry is a ':' separated src:dst pair.
|
|
|
|
# Evaluates to the list of the dst files. (ie suitable for a dependency list.)
|
|
|
|
define copy-many-init-script-files-checked
|
|
|
|
$(foreach f, $(1), $(strip \
|
|
|
|
$(eval _cmf_tuple := $(subst :, ,$(f))) \
|
|
|
|
$(eval _cmf_src := $(word 1,$(_cmf_tuple))) \
|
|
|
|
$(eval _cmf_dest := $(word 2,$(_cmf_tuple))) \
|
|
|
|
$(eval $(call copy-init-script-file-checked,$(_cmf_src),$(_cmf_dest))) \
|
|
|
|
$(_cmf_dest)))
|
|
|
|
endef
|
|
|
|
|
2012-05-14 23:39:00 +02:00
|
|
|
# Copy the file only if it's a well-formed xml file. For use via $(eval).
|
|
|
|
# $(1): source file
|
|
|
|
# $(2): destination file, must end with .xml.
|
|
|
|
define copy-xml-file-checked
|
2018-02-27 03:26:44 +01:00
|
|
|
$(2): $(1) $(XMLLINT)
|
2012-05-14 23:39:00 +02:00
|
|
|
@echo "Copy xml: $$@"
|
2018-02-27 03:26:44 +01:00
|
|
|
$(hide) $(XMLLINT) $$< >/dev/null # Don't print the xml file to stdout.
|
2012-05-14 23:39:00 +02:00
|
|
|
$$(copy-file-to-target)
|
|
|
|
endef
|
|
|
|
|
2018-06-25 07:47:53 +02:00
|
|
|
# Copies many xml files and check they are well-formed.
|
|
|
|
# $(1): The xml files to copy. Each entry is a ':' separated src:dst pair.
|
|
|
|
# Evaluates to the list of the dst files. (ie suitable for a dependency list.)
|
|
|
|
define copy-many-xml-files-checked
|
|
|
|
$(foreach f, $(1), $(strip \
|
|
|
|
$(eval _cmf_tuple := $(subst :, ,$(f))) \
|
|
|
|
$(eval _cmf_src := $(word 1,$(_cmf_tuple))) \
|
|
|
|
$(eval _cmf_dest := $(word 2,$(_cmf_tuple))) \
|
|
|
|
$(eval $(call copy-xml-file-checked,$(_cmf_src),$(_cmf_dest))) \
|
|
|
|
$(_cmf_dest)))
|
|
|
|
endef
|
|
|
|
|
2018-04-05 00:41:05 +02:00
|
|
|
# Copy the file only if it is a well-formed manifest file. For use viea $(eval)
|
|
|
|
# $(1): source file
|
|
|
|
# $(2): destination file
|
|
|
|
define copy-vintf-manifest-checked
|
|
|
|
$(2): $(1) $(HOST_OUT_EXECUTABLES)/assemble_vintf
|
|
|
|
@echo "Copy xml: $$@"
|
|
|
|
$(hide) $(HOST_OUT_EXECUTABLES)/assemble_vintf -i $$< >/dev/null # Don't print the xml file to stdout.
|
|
|
|
$$(copy-file-to-target)
|
|
|
|
endef
|
|
|
|
|
|
|
|
# Copies many vintf manifest files checked.
|
|
|
|
# $(1): The files to copy. Each entry is a ':' separated src:dst pair
|
|
|
|
# Evaluates to the list of the dst files (ie suitable for a dependency list)
|
|
|
|
define copy-many-vintf-manifest-files-checked
|
|
|
|
$(foreach f, $(1), $(strip \
|
|
|
|
$(eval _cmf_tuple := $(subst :, ,$(f))) \
|
|
|
|
$(eval _cmf_src := $(word 1,$(_cmf_tuple))) \
|
|
|
|
$(eval _cmf_dest := $(word 2,$(_cmf_tuple))) \
|
|
|
|
$(eval $(call copy-vintf-manifest-checked,$(_cmf_src),$(_cmf_dest))) \
|
|
|
|
$(_cmf_dest)))
|
|
|
|
endef
|
|
|
|
|
2020-03-17 10:49:49 +01:00
|
|
|
# Copy the file only if it's not an ELF file. For use via $(eval).
|
|
|
|
# $(1): source file
|
|
|
|
# $(2): destination file
|
|
|
|
# $(3): message to print on error
|
|
|
|
define copy-non-elf-file-checked
|
2020-05-14 11:17:29 +02:00
|
|
|
$(eval check_non_elf_file_timestamp := \
|
|
|
|
$(call intermediates-dir-for,FAKE,check-non-elf-file-timestamps)/$(2).timestamp)
|
|
|
|
$(check_non_elf_file_timestamp): $(1) $(LLVM_READOBJ)
|
|
|
|
@echo "Check non-ELF: $$<"
|
|
|
|
$(hide) mkdir -p "$$(dir $$@)"
|
|
|
|
$(hide) rm -f "$$@"
|
2020-03-17 10:49:49 +01:00
|
|
|
$(hide) \
|
2020-05-14 11:17:29 +02:00
|
|
|
if $(LLVM_READOBJ) -h "$$<" >/dev/null 2>&1; then \
|
|
|
|
$(call echo-error,$(2),$(3)); \
|
|
|
|
$(call echo-error,$(2),found ELF file: $$<); \
|
2020-03-17 10:49:49 +01:00
|
|
|
false; \
|
|
|
|
fi
|
2020-05-14 11:17:29 +02:00
|
|
|
$(hide) touch "$$@"
|
|
|
|
|
|
|
|
$(2): $(1) $(check_non_elf_file_timestamp)
|
|
|
|
@echo "Copy non-ELF: $$@"
|
2020-03-17 10:49:49 +01:00
|
|
|
$$(copy-file-to-target)
|
2020-05-14 11:17:29 +02:00
|
|
|
|
|
|
|
check-elf-prebuilt-product-copy-files: $(check_non_elf_file_timestamp)
|
2020-03-17 10:49:49 +01:00
|
|
|
endef
|
|
|
|
|
2009-03-04 04:28:42 +01:00
|
|
|
# The -t option to acp and the -p option to cp is
|
|
|
|
# required for OSX. OSX has a ridiculous restriction
|
|
|
|
# where it's an error for a .a file's modification time
|
|
|
|
# to disagree with an internal timestamp, and this
|
|
|
|
# macro is used to install .a files (among other things).
|
|
|
|
|
|
|
|
# Copy a single file from one place to another,
|
|
|
|
# preserving permissions and overwriting any existing
|
|
|
|
# file.
|
Replace some uses of acp with cp
ACP was originally created to overcome differences with cp between
Linux, Darwin, and Windows. We've since dropped Windows as a build host,
and don't use features like '-u' anymore.
For most of our current usecases, 'acp' is identical to 'cp' except that
it splits 'cp -p' into 'acp -p' for mode and ownership, and 'acp -t' for
timestamps. On Linux, this could be specified using
'--preserve=mode,ownership', but Darwin doesn't have this.
Since we're removing the destination file before copying, 'cp' already
preserves the mode (modulated by the umask). So the only extra thing
that gets preserved with 'acp -p' is ownership, which we should not care
about in the build system. (In many cases we shouldn't be preserving
mode either, so that readonly source trees can actually be marked
readonly, but that will be a future change)
Change-Id: Ied96fdc303ac5c774347c07363daec8b6dfb22e4
2016-02-29 21:45:18 +01:00
|
|
|
# When we used acp, it could not handle high resolution timestamps
|
|
|
|
# on file systems like ext4. Because of that, '-t' option was disabled
|
|
|
|
# and copy-file-to-target was identical to copy-file-to-new-target.
|
|
|
|
# Keep the behavior until we audit and ensure that switching this back
|
|
|
|
# won't break anything.
|
2009-03-04 04:28:42 +01:00
|
|
|
define copy-file-to-target
|
|
|
|
@mkdir -p $(dir $@)
|
2016-02-29 21:45:18 +01:00
|
|
|
$(hide) rm -f $@
|
2017-06-27 02:31:03 +02:00
|
|
|
$(hide) cp "$<" "$@"
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
2022-07-30 00:31:21 +02:00
|
|
|
# Same as copy-file-to-target, but assume file is a licenes metadata file,
|
|
|
|
# and append built from $(1) and installed from $(2).
|
|
|
|
define copy-license-metadata-file-to-target
|
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
$(hide) rm -f $@
|
|
|
|
$(hide) cp "$<" "$@" $(strip \
|
|
|
|
$(foreach b,$(1), && (grep -F 'built: "'"$(b)"'"' "$@" >/dev/null || echo 'built: "'"$(b)"'"' >>"$@")) \
|
|
|
|
$(foreach i,$(2), && (grep -F 'installed: "'"$(i)"'"' "$@" >/dev/null || echo 'installed: "'"$(i)"'"' >>"$@")) \
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2009-03-04 04:28:42 +01:00
|
|
|
# The same as copy-file-to-target, but use the local
|
|
|
|
# cp command instead of acp.
|
|
|
|
define copy-file-to-target-with-cp
|
|
|
|
@mkdir -p $(dir $@)
|
2016-02-29 21:45:18 +01:00
|
|
|
$(hide) rm -f $@
|
2017-06-27 02:31:03 +02:00
|
|
|
$(hide) cp -p "$<" "$@"
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
2009-08-06 22:02:19 +02:00
|
|
|
# The same as copy-file-to-target, but strip out "# comment"-style
|
|
|
|
# comments (for config files and such).
|
|
|
|
define copy-file-to-target-strip-comments
|
|
|
|
@mkdir -p $(dir $@)
|
2016-02-29 21:45:18 +01:00
|
|
|
$(hide) rm -f $@
|
2009-08-06 22:02:19 +02:00
|
|
|
$(hide) sed -e 's/#.*$$//' -e 's/[ \t]*$$//' -e '/^$$/d' < $< > $@
|
|
|
|
endef
|
|
|
|
|
2009-03-04 04:28:42 +01:00
|
|
|
# The same as copy-file-to-target, but don't preserve
|
|
|
|
# the old modification time.
|
|
|
|
define copy-file-to-new-target
|
|
|
|
@mkdir -p $(dir $@)
|
2016-02-29 21:45:18 +01:00
|
|
|
$(hide) rm -f $@
|
Replace some uses of acp with cp
ACP was originally created to overcome differences with cp between
Linux, Darwin, and Windows. We've since dropped Windows as a build host,
and don't use features like '-u' anymore.
For most of our current usecases, 'acp' is identical to 'cp' except that
it splits 'cp -p' into 'acp -p' for mode and ownership, and 'acp -t' for
timestamps. On Linux, this could be specified using
'--preserve=mode,ownership', but Darwin doesn't have this.
Since we're removing the destination file before copying, 'cp' already
preserves the mode (modulated by the umask). So the only extra thing
that gets preserved with 'acp -p' is ownership, which we should not care
about in the build system. (In many cases we shouldn't be preserving
mode either, so that readonly source trees can actually be marked
readonly, but that will be a future change)
Change-Id: Ied96fdc303ac5c774347c07363daec8b6dfb22e4
2016-02-29 21:45:18 +01:00
|
|
|
$(hide) cp $< $@
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
|
|
|
# The same as copy-file-to-new-target, but use the local
|
|
|
|
# cp command instead of acp.
|
|
|
|
define copy-file-to-new-target-with-cp
|
|
|
|
@mkdir -p $(dir $@)
|
2016-02-29 21:45:18 +01:00
|
|
|
$(hide) rm -f $@
|
|
|
|
$(hide) cp $< $@
|
2009-03-04 04:28:42 +01:00
|
|
|
endef
|
|
|
|
|
2020-08-21 17:36:23 +02:00
|
|
|
# The same as copy-file-to-new-target, but preserve symlinks. Symlinks are
|
|
|
|
# converted to absolute to not break.
|
|
|
|
define copy-file-or-link-to-new-target
|
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
$(hide) rm -f $@
|
|
|
|
$(hide) if [ -h $< ]; then \
|
|
|
|
ln -s $$(realpath $<) $@; \
|
|
|
|
else \
|
|
|
|
cp $< $@; \
|
|
|
|
fi
|
|
|
|
endef
|
|
|
|
|
2009-03-04 04:28:42 +01:00
|
|
|
# Copy a prebuilt file to a target location.
|
|
|
|
define transform-prebuilt-to-target
|
2016-06-24 20:13:34 +02:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) Prebuilt: $(PRIVATE_MODULE) ($@)"
|
2009-03-04 04:28:42 +01:00
|
|
|
$(copy-file-to-target)
|
|
|
|
endef
|
|
|
|
|
2009-08-06 22:02:19 +02:00
|
|
|
# Copy a prebuilt file to a target location, stripping "# comment" comments.
|
|
|
|
define transform-prebuilt-to-target-strip-comments
|
2016-06-24 20:13:34 +02:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) Prebuilt: $(PRIVATE_MODULE) ($@)"
|
2009-08-06 22:02:19 +02:00
|
|
|
$(copy-file-to-target-strip-comments)
|
|
|
|
endef
|
|
|
|
|
2020-08-21 17:36:23 +02:00
|
|
|
# Copy a prebuilt file to a target location, but preserve symlinks rather than
|
|
|
|
# dereference them.
|
|
|
|
define copy-or-link-prebuilt-to-target
|
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) Prebuilt: $(PRIVATE_MODULE) ($@)"
|
|
|
|
$(copy-file-or-link-to-new-target)
|
|
|
|
endef
|
|
|
|
|
2015-04-08 21:24:37 +02:00
|
|
|
# Copy a list of files/directories to target location, with sub dir structure preserved.
|
|
|
|
# For example $(HOST_OUT_EXECUTABLES)/aapt -> $(staging)/bin/aapt .
|
|
|
|
# $(1): the source list of files/directories.
|
|
|
|
# $(2): the path prefix to strip. In the above example it would be $(HOST_OUT).
|
|
|
|
# $(3): the target location.
|
|
|
|
define copy-files-with-structure
|
|
|
|
$(foreach t,$(1),\
|
|
|
|
$(eval s := $(patsubst $(2)%,%,$(t)))\
|
|
|
|
$(hide) mkdir -p $(dir $(3)/$(s)); cp -Rf $(t) $(3)/$(s)$(newline))
|
|
|
|
endef
|
|
|
|
|
2016-07-15 01:02:57 +02:00
|
|
|
# Define a rule to create a symlink to a file.
|
2020-01-06 18:55:11 +01:00
|
|
|
# $(1): any dependencies
|
2017-03-17 00:51:46 +01:00
|
|
|
# $(2): source (may be relative)
|
|
|
|
# $(3): full path to destination
|
2016-07-15 01:02:57 +02:00
|
|
|
define symlink-file
|
|
|
|
$(eval $(_symlink-file))
|
2022-03-09 22:38:37 +01:00
|
|
|
$(eval $(call declare-license-metadata,$(3),,,,,,))
|
|
|
|
$(eval $(call declare-license-deps,$(3),$(1)))
|
2016-07-15 01:02:57 +02:00
|
|
|
endef
|
|
|
|
|
|
|
|
define _symlink-file
|
2020-01-06 18:55:11 +01:00
|
|
|
$(3): $(1)
|
2016-07-15 01:02:57 +02:00
|
|
|
@echo "Symlink: $$@ -> $(2)"
|
2021-04-14 11:22:49 +02:00
|
|
|
@mkdir -p $$(dir $$@)
|
2016-07-15 01:02:57 +02:00
|
|
|
@rm -rf $$@
|
2017-03-17 00:51:46 +01:00
|
|
|
$(hide) ln -sf $(2) $$@
|
2020-09-22 15:47:13 +02:00
|
|
|
$(3): .KATI_SYMLINK_OUTPUTS := $(3)
|
2016-07-15 01:02:57 +02:00
|
|
|
endef
|
|
|
|
|
2017-10-06 22:55:48 +02:00
|
|
|
# Copy an apk to a target location while removing classes*.dex
|
|
|
|
# $(1): source file
|
|
|
|
# $(2): destination file
|
2018-10-22 22:44:27 +02:00
|
|
|
# $(3): LOCAL_STRIP_DEX, if non-empty then strip classes*.dex
|
2017-10-06 22:55:48 +02:00
|
|
|
define dexpreopt-copy-jar
|
|
|
|
$(2): $(1)
|
2018-01-09 12:46:30 +01:00
|
|
|
@echo "Copy: $$@"
|
2017-10-06 22:55:48 +02:00
|
|
|
$$(copy-file-to-target)
|
2018-10-22 22:44:27 +02:00
|
|
|
$(if $(3),$$(call dexpreopt-remove-classes.dex,$$@))
|
2017-10-06 22:55:48 +02:00
|
|
|
endef
|
|
|
|
|
2018-01-09 12:46:30 +01:00
|
|
|
# $(1): the .jar or .apk to remove classes.dex. Note that if all dex files
|
|
|
|
# are uncompressed in the archive, then dexopt will not do a copy of the dex
|
|
|
|
# files and we should not strip.
|
2017-10-06 22:55:48 +02:00
|
|
|
define dexpreopt-remove-classes.dex
|
2018-01-09 12:46:30 +01:00
|
|
|
$(hide) if (zipinfo $1 '*.dex' 2>/dev/null | grep -v ' stor ' >/dev/null) ; then \
|
|
|
|
zip --quiet --delete $(1) classes.dex; \
|
2017-10-06 22:55:48 +02:00
|
|
|
dex_index=2; \
|
|
|
|
while zip --quiet --delete $(1) classes$${dex_index}.dex > /dev/null; do \
|
|
|
|
let dex_index=dex_index+1; \
|
2018-01-09 12:46:30 +01:00
|
|
|
done \
|
|
|
|
fi
|
2017-10-06 22:55:48 +02:00
|
|
|
endef
|
|
|
|
|
2022-04-06 03:11:20 +02:00
|
|
|
# Copy an unstripped binary to the symbols directory while also extracting
|
|
|
|
# a hash mapping to the mapping directory.
|
|
|
|
# $(1): unstripped intermediates file
|
|
|
|
# $(2): path in symbols directory
|
|
|
|
define copy-unstripped-elf-file-with-mapping
|
|
|
|
$(call _copy-symbols-file-with-mapping,$(1),$(2),\
|
|
|
|
elf,$(patsubst $(TARGET_OUT_UNSTRIPPED)/%,$(call intermediates-dir-for,PACKAGING,elf_symbol_mapping)/%,$(2).textproto))
|
|
|
|
endef
|
|
|
|
|
|
|
|
# Copy an R8 dictionary to the packaging directory while also extracting
|
|
|
|
# a hash mapping to the mapping directory.
|
|
|
|
# $(1): unstripped intermediates file
|
|
|
|
# $(2): path in packaging directory
|
|
|
|
# $(3): path in mappings packaging directory
|
|
|
|
define copy-r8-dictionary-file-with-mapping
|
|
|
|
$(call _copy-symbols-file-with-mapping,$(1),$(2),r8,$(3))
|
|
|
|
endef
|
|
|
|
|
|
|
|
# Copy an unstripped binary or R8 dictionary to the symbols directory
|
|
|
|
# while also extracting a hash mapping to the mapping directory.
|
|
|
|
# $(1): unstripped intermediates file
|
|
|
|
# $(2): path in symbols directory
|
|
|
|
# $(3): file type (elf or r8)
|
|
|
|
# $(4): path in the mappings directory
|
|
|
|
define _copy-symbols-file-with-mapping
|
|
|
|
$(2): .KATI_IMPLICIT_OUTPUTS := $(4)
|
|
|
|
$(2): $(SYMBOLS_MAP)
|
|
|
|
$(2): $(1)
|
|
|
|
@echo "Copy symbols with mapping: $$@"
|
|
|
|
$$(copy-file-to-target)
|
|
|
|
$(SYMBOLS_MAP) -$(strip $(3)) $(2) -write_if_changed $(4)
|
|
|
|
.KATI_RESTAT: $(2)
|
|
|
|
endef
|
|
|
|
|
|
|
|
# Returns the directory to copy proguard dictionaries into
|
|
|
|
define local-proguard-dictionary-directory
|
|
|
|
$(call intermediates-dir-for,PACKAGING,proguard_dictionary)/out/target/common/obj/$(LOCAL_MODULE_CLASS)/$(LOCAL_MODULE)_intermediates
|
|
|
|
endef
|
|
|
|
|
|
|
|
# Returns the directory to copy proguard dictionary mappings into
|
|
|
|
define local-proguard-dictionary-mapping-directory
|
|
|
|
$(call intermediates-dir-for,PACKAGING,proguard_dictionary_mapping)/out/target/common/obj/$(LOCAL_MODULE_CLASS)/$(LOCAL_MODULE)_intermediates
|
|
|
|
endef
|
|
|
|
|
2010-02-01 18:51:23 +01:00
|
|
|
|
2009-03-04 04:28:42 +01:00
|
|
|
###########################################################
|
2017-10-12 16:09:13 +02:00
|
|
|
## Commands to call R8
|
|
|
|
###########################################################
|
2018-11-29 00:19:46 +01:00
|
|
|
|
|
|
|
# Use --debug flag for eng builds by default
|
|
|
|
ifeq (eng,$(TARGET_BUILD_VARIANT))
|
|
|
|
R8_DEBUG_MODE := --debug
|
|
|
|
else
|
|
|
|
R8_DEBUG_MODE :=
|
|
|
|
endif
|
|
|
|
|
2017-10-12 16:09:13 +02:00
|
|
|
define transform-jar-to-dex-r8
|
|
|
|
@echo R8: $@
|
2018-08-23 11:17:17 +02:00
|
|
|
$(hide) rm -f $(PRIVATE_PROGUARD_DICTIONARY)
|
2022-04-22 11:47:42 +02:00
|
|
|
$(hide) $(R8_WRAPPER) $(R8_COMMAND) \
|
2019-02-22 00:04:37 +01:00
|
|
|
-injars '$<' \
|
2017-10-12 16:09:13 +02:00
|
|
|
--min-api $(PRIVATE_MIN_SDK_VERSION) \
|
2018-09-14 15:17:00 +02:00
|
|
|
--no-data-resources \
|
2017-10-12 16:09:13 +02:00
|
|
|
--force-proguard-compatibility --output $(subst classes.dex,,$@) \
|
2018-11-29 00:19:46 +01:00
|
|
|
$(R8_DEBUG_MODE) \
|
2017-10-12 16:09:13 +02:00
|
|
|
$(PRIVATE_PROGUARD_FLAGS) \
|
|
|
|
$(addprefix -injars , $(PRIVATE_EXTRA_INPUT_JAR)) \
|
2021-02-22 13:20:51 +01:00
|
|
|
$(PRIVATE_DX_FLAGS) \
|
|
|
|
-ignorewarnings
|
2018-08-23 11:17:17 +02:00
|
|
|
$(hide) touch $(PRIVATE_PROGUARD_DICTIONARY)
|
2017-10-12 16:09:13 +02:00
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
2009-03-04 04:28:42 +01:00
|
|
|
## Stuff source generated from one-off tools
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define transform-generated-source
|
2016-06-24 20:13:34 +02:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) Generated: $(PRIVATE_MODULE) <= $<"
|
2009-03-04 04:28:42 +01:00
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
$(hide) $(PRIVATE_CUSTOM_TOOL)
|
|
|
|
endef
|
|
|
|
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Assertions about attributes of the target
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
# $(1): The file to check
|
2019-09-05 19:02:41 +02:00
|
|
|
define get-file-size
|
|
|
|
stat -c "%s" "$(1)" | tr -d '\n'
|
|
|
|
endef
|
2009-03-04 04:28:42 +01:00
|
|
|
|
2009-07-02 18:00:54 +02:00
|
|
|
# $(1): The file(s) to check (often $@)
|
2017-10-04 14:22:41 +02:00
|
|
|
# $(2): The partition size.
|
|
|
|
define assert-max-image-size
|
2009-03-04 04:28:42 +01:00
|
|
|
$(if $(2), \
|
2009-07-08 21:09:04 +02:00
|
|
|
size=$$(for i in $(1); do $(call get-file-size,$$i); echo +; done; echo 0); \
|
|
|
|
total=$$(( $$( echo "$$size" ) )); \
|
2009-07-02 18:00:54 +02:00
|
|
|
printname=$$(echo -n "$(1)" | tr " " +); \
|
2017-10-17 18:50:08 +02:00
|
|
|
maxsize=$$(($(2))); \
|
2009-07-02 18:00:54 +02:00
|
|
|
if [ "$$total" -gt "$$maxsize" ]; then \
|
2017-10-04 14:22:41 +02:00
|
|
|
echo "error: $$printname too large ($$total > $$maxsize)"; \
|
2009-07-02 18:00:54 +02:00
|
|
|
false; \
|
2009-07-08 21:09:04 +02:00
|
|
|
elif [ "$$total" -gt $$((maxsize - 32768)) ]; then \
|
2009-07-02 18:00:54 +02:00
|
|
|
echo "WARNING: $$printname approaching size limit ($$total now; limit $$maxsize)"; \
|
2009-03-04 04:28:42 +01:00
|
|
|
fi \
|
|
|
|
, \
|
|
|
|
true \
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2009-06-20 02:12:18 +02:00
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Define device-specific radio files
|
|
|
|
###########################################################
|
2013-07-26 21:19:20 +02:00
|
|
|
INSTALLED_RADIOIMAGE_TARGET :=
|
2009-06-20 02:12:18 +02:00
|
|
|
|
|
|
|
# Copy a radio image file to the output location, and add it to
|
|
|
|
# INSTALLED_RADIOIMAGE_TARGET.
|
|
|
|
# $(1): filename
|
|
|
|
define add-radio-file
|
2010-02-02 22:12:04 +01:00
|
|
|
$(eval $(call add-radio-file-internal,$(1),$(notdir $(1))))
|
2009-06-20 02:12:18 +02:00
|
|
|
endef
|
|
|
|
define add-radio-file-internal
|
2010-02-02 22:12:04 +01:00
|
|
|
INSTALLED_RADIOIMAGE_TARGET += $$(PRODUCT_OUT)/$(2)
|
2016-03-01 02:52:39 +01:00
|
|
|
$$(PRODUCT_OUT)/$(2) : $$(LOCAL_PATH)/$(1)
|
2009-06-20 02:12:18 +02:00
|
|
|
$$(transform-prebuilt-to-target)
|
|
|
|
endef
|
|
|
|
|
2012-03-21 00:42:22 +01:00
|
|
|
# Version of add-radio-file that also arranges for the version of the
|
|
|
|
# file to be checked against the contents of
|
|
|
|
# $(TARGET_BOARD_INFO_FILE).
|
|
|
|
# $(1): filename
|
|
|
|
# $(2): name of version variable in board-info (eg, "version-baseband")
|
|
|
|
define add-radio-file-checked
|
|
|
|
$(eval $(call add-radio-file-checked-internal,$(1),$(notdir $(1)),$(2)))
|
|
|
|
endef
|
|
|
|
define add-radio-file-checked-internal
|
|
|
|
INSTALLED_RADIOIMAGE_TARGET += $$(PRODUCT_OUT)/$(2)
|
|
|
|
BOARD_INFO_CHECK += $(3):$(LOCAL_PATH)/$(1)
|
2016-03-01 02:52:39 +01:00
|
|
|
$$(PRODUCT_OUT)/$(2) : $$(LOCAL_PATH)/$(1)
|
2012-03-21 00:42:22 +01:00
|
|
|
$$(transform-prebuilt-to-target)
|
|
|
|
endef
|
|
|
|
|
Build from source or prebuilt
With this change, you can easily switch between building from source
code and prebuilt.
Set LOCAL_PREBUILT_MODULE_FILE to the path of the prebuilt file,
relative to the top of the source tree, in the usual module definition.
The prebuilt will be used unless any of the followings satisfied:
1) ANDROID_BUILD_FROM_SOURCE is "true", which disable prebuilt globally;
2) The module name is in ANDROID_NO_PREBUILT_MODULES;
3) The LOCAL_PATH is prefixed by any of ANDROID_NO_PREBUILT_PATHS.
A developer can set ANDROID_NO_PREBUILT_MODULES or
ANDROID_NO_PREBUILT_PATHS to build only his own module(s) from source,
while build other modules from prebuilts.
You can set ANDROID_BUILD_FROM_SOURCE to true to build everything from
source.
Those variables can be set with shell environmental variable or in your
buildspec.mk.
Sometimes module B is able to be built from source only if module A is
also
built from source, for example, if B is the test apk of A.
In that case, you can use the macro include-if-build-from-source to
include B's Android.mk only if A is built from source too, or
if-build-from-source to conditionally include the definition of module
B,
if their module definitions are in the same Android.mk.
Support host-executable-hook and host-shared-library-hook.
Change-Id: Icab7cf028c87eaba0dd7efc2a7749fd6f32b44e4
2012-12-14 03:23:01 +01:00
|
|
|
## Whether to build from source if prebuilt alternative exists
|
|
|
|
###########################################################
|
|
|
|
# $(1): module name
|
|
|
|
# $(2): LOCAL_PATH
|
|
|
|
# Expands to empty string if not from source.
|
|
|
|
ifeq (true,$(ANDROID_BUILD_FROM_SOURCE))
|
|
|
|
define if-build-from-source
|
|
|
|
true
|
|
|
|
endef
|
|
|
|
else
|
|
|
|
define if-build-from-source
|
|
|
|
$(if $(filter $(ANDROID_NO_PREBUILT_MODULES),$(1))$(filter \
|
|
|
|
$(addsuffix %,$(ANDROID_NO_PREBUILT_PATHS)),$(2)),true)
|
|
|
|
endef
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Include makefile $(1) if build from source for module $(2)
|
|
|
|
# $(1): the makefile to include
|
|
|
|
# $(2): module name
|
|
|
|
# $(3): LOCAL_PATH
|
|
|
|
define include-if-build-from-source
|
|
|
|
$(if $(call if-build-from-source,$(2),$(3)),$(eval include $(1)))
|
|
|
|
endef
|
|
|
|
|
2014-09-26 19:41:27 +02:00
|
|
|
# Return the arch for the source file of a prebuilt
|
2015-10-04 18:28:47 +02:00
|
|
|
# Return "none" if no matching arch found and return empty
|
|
|
|
# if the input is empty, so the result can be passed to
|
2014-09-26 19:41:27 +02:00
|
|
|
# LOCAL_MODULE_TARGET_ARCH.
|
2014-02-27 23:10:53 +01:00
|
|
|
# $(1) the list of archs supported by the prebuilt
|
|
|
|
define get-prebuilt-src-arch
|
|
|
|
$(strip $(if $(filter $(TARGET_ARCH),$(1)),$(TARGET_ARCH),\
|
2015-10-04 18:28:47 +02:00
|
|
|
$(if $(filter $(TARGET_2ND_ARCH),$(1)),$(TARGET_2ND_ARCH),$(if $(1),none))))
|
2014-02-27 23:10:53 +01:00
|
|
|
endef
|
|
|
|
|
2016-07-26 01:03:53 +02:00
|
|
|
# ###############################################################
|
|
|
|
# Set up statistics gathering
|
|
|
|
# ###############################################################
|
|
|
|
STATS.MODULE_TYPE := \
|
|
|
|
HOST_STATIC_LIBRARY \
|
|
|
|
HOST_SHARED_LIBRARY \
|
|
|
|
STATIC_LIBRARY \
|
|
|
|
SHARED_LIBRARY \
|
|
|
|
EXECUTABLE \
|
|
|
|
HOST_EXECUTABLE \
|
|
|
|
PACKAGE \
|
|
|
|
PHONY_PACKAGE \
|
|
|
|
HOST_PREBUILT \
|
|
|
|
PREBUILT \
|
|
|
|
MULTI_PREBUILT \
|
|
|
|
JAVA_LIBRARY \
|
|
|
|
STATIC_JAVA_LIBRARY \
|
|
|
|
HOST_JAVA_LIBRARY \
|
|
|
|
DROIDDOC \
|
|
|
|
COPY_HEADERS \
|
|
|
|
NATIVE_TEST \
|
|
|
|
NATIVE_BENCHMARK \
|
|
|
|
HOST_NATIVE_TEST \
|
|
|
|
FUZZ_TEST \
|
|
|
|
HOST_FUZZ_TEST \
|
|
|
|
STATIC_TEST_LIBRARY \
|
|
|
|
HOST_STATIC_TEST_LIBRARY \
|
|
|
|
NOTICE_FILE \
|
2017-03-02 20:47:33 +01:00
|
|
|
base_rules \
|
2017-11-13 22:38:17 +01:00
|
|
|
HEADER_LIBRARY \
|
|
|
|
HOST_TEST_CONFIG \
|
|
|
|
TARGET_TEST_CONFIG
|
2016-07-26 01:03:53 +02:00
|
|
|
|
2017-10-10 05:27:06 +02:00
|
|
|
$(foreach s,$(STATS.MODULE_TYPE),$(eval STATS.MODULE_TYPE.$(s) :=))
|
2016-07-26 01:03:53 +02:00
|
|
|
define record-module-type
|
|
|
|
$(strip $(if $(LOCAL_RECORDED_MODULE_TYPE),,
|
|
|
|
$(if $(filter-out $(SOONG_ANDROID_MK),$(LOCAL_MODULE_MAKEFILE)),
|
|
|
|
$(if $(filter $(1),$(STATS.MODULE_TYPE)),
|
|
|
|
$(eval LOCAL_RECORDED_MODULE_TYPE := true)
|
|
|
|
$(eval STATS.MODULE_TYPE.$(1) += 1),
|
|
|
|
$(error Invalid module type: $(1))))))
|
|
|
|
endef
|
|
|
|
|
2017-02-17 03:04:10 +01:00
|
|
|
###########################################################
|
|
|
|
## Compatibility suite tools
|
|
|
|
###########################################################
|
|
|
|
|
2017-04-04 21:47:19 +02:00
|
|
|
# Return a list of output directories for a given suite and the current LOCAL_MODULE.
|
|
|
|
# Can be passed a subdirectory to use for the common testcase directory.
|
2017-02-17 03:04:10 +01:00
|
|
|
define compatibility_suite_dirs
|
|
|
|
$(strip \
|
2021-09-25 00:47:44 +02:00
|
|
|
$(if $(COMPATIBILITY_TESTCASES_OUT_$(1)), \
|
|
|
|
$(if $(COMPATIBILITY_TESTCASES_OUT_INCLUDE_MODULE_FOLDER_$(1))$(LOCAL_COMPATIBILITY_PER_TESTCASE_DIRECTORY),\
|
|
|
|
$(COMPATIBILITY_TESTCASES_OUT_$(1))/$(LOCAL_MODULE)$(2),\
|
|
|
|
$(COMPATIBILITY_TESTCASES_OUT_$(1)))) \
|
2017-04-04 21:47:19 +02:00
|
|
|
$($(my_prefix)OUT_TESTCASES)/$(LOCAL_MODULE)$(2))
|
2017-02-17 03:04:10 +01:00
|
|
|
endef
|
|
|
|
|
|
|
|
# For each suite:
|
|
|
|
# 1. Copy the files to the many suite output directories.
|
2018-06-25 07:47:53 +02:00
|
|
|
# And for test config files, we'll check the .xml is well-formed before copy.
|
2017-02-17 03:04:10 +01:00
|
|
|
# 2. Add all the files to each suite's dependent files list.
|
2018-10-26 08:21:38 +02:00
|
|
|
# 3. Do the dependency addition to my_all_targets.
|
|
|
|
# 4. Save the module name to COMPATIBILITY.$(suite).MODULES for each suite.
|
2020-08-27 00:27:26 +02:00
|
|
|
# 5. Collect files to dist to ALL_COMPATIBILITY_DIST_FILES.
|
2018-06-25 07:47:53 +02:00
|
|
|
# Requires for each suite: use my_compat_dist_config_$(suite) to define the test config.
|
|
|
|
# and use my_compat_dist_$(suite) to define the others.
|
2017-02-17 03:04:10 +01:00
|
|
|
define create-suite-dependencies
|
|
|
|
$(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
|
2022-03-20 07:20:59 +01:00
|
|
|
$(eval $(if $(strip $(module_license_metadata)),\
|
2022-05-28 04:40:41 +02:00
|
|
|
$$(foreach f,$$(my_compat_dist_$(suite)),$$(call declare-copy-target-license-metadata,$$(call word-colon,2,$$(f)),$$(call word-colon,1,$$(f)))),\
|
2022-09-07 05:15:01 +02:00
|
|
|
$$(eval my_test_data += $$(my_compat_dist_$(suite))) \
|
2022-03-20 07:20:59 +01:00
|
|
|
)) \
|
|
|
|
$(eval $(if $(strip $(module_license_metadata)),\
|
2022-05-28 04:40:41 +02:00
|
|
|
$$(foreach f,$$(my_compat_dist_config_$(suite)),$$(call declare-copy-target-license-metadata,$$(call word-colon,2,$$(f)),$$(call word-colon,1,$$(f)))),\
|
2022-09-07 05:15:01 +02:00
|
|
|
$$(eval my_test_config += $$(my_compat_dist_config_$(suite))) \
|
2022-03-20 07:20:59 +01:00
|
|
|
)) \
|
2020-06-09 06:00:18 +02:00
|
|
|
$(if $(filter $(suite),$(ALL_COMPATIBILITY_SUITES)),,\
|
|
|
|
$(eval ALL_COMPATIBILITY_SUITES += $(suite)) \
|
|
|
|
$(eval COMPATIBILITY.$(suite).FILES :=) \
|
|
|
|
$(eval COMPATIBILITY.$(suite).MODULES :=)) \
|
|
|
|
$(eval COMPATIBILITY.$(suite).FILES += \
|
|
|
|
$$(foreach f,$$(my_compat_dist_$(suite)),$$(call word-colon,2,$$(f))) \
|
|
|
|
$$(foreach f,$$(my_compat_dist_config_$(suite)),$$(call word-colon,2,$$(f))) \
|
|
|
|
$$(my_compat_dist_test_data_$(suite))) \
|
2020-08-27 00:27:26 +02:00
|
|
|
$(eval ALL_COMPATIBILITY_DIST_FILES += $$(my_compat_dist_$(suite))) \
|
2020-06-09 06:00:18 +02:00
|
|
|
$(eval COMPATIBILITY.$(suite).MODULES += $$(my_register_name))) \
|
2020-08-27 00:27:26 +02:00
|
|
|
$(eval $(my_all_targets) : \
|
|
|
|
$(sort $(foreach suite,$(LOCAL_COMPATIBILITY_SUITE), \
|
|
|
|
$(foreach f,$(my_compat_dist_$(suite)), $(call word-colon,2,$(f))))) \
|
2018-06-25 07:47:53 +02:00
|
|
|
$(call copy-many-xml-files-checked, \
|
|
|
|
$(sort $(foreach suite,$(LOCAL_COMPATIBILITY_SUITE),$(my_compat_dist_config_$(suite))))))
|
2017-02-17 03:04:10 +01:00
|
|
|
endef
|
|
|
|
|
2017-04-27 02:37:17 +02:00
|
|
|
###########################################################
|
|
|
|
## Path Cleaning
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
# Remove "dir .." combinations (but keep ".. ..")
|
|
|
|
#
|
|
|
|
# $(1): The expanded path, where / is converted to ' ' to work with $(word)
|
|
|
|
define _clean-path-strip-dotdot
|
|
|
|
$(strip \
|
|
|
|
$(if $(word 2,$(1)),
|
|
|
|
$(if $(call streq,$(word 2,$(1)),..),
|
|
|
|
$(if $(call streq,$(word 1,$(1)),..),
|
|
|
|
$(word 1,$(1)) $(call _clean-path-strip-dotdot,$(wordlist 2,$(words $(1)),$(1)))
|
|
|
|
,
|
|
|
|
$(call _clean-path-strip-dotdot,$(wordlist 3,$(words $(1)),$(1)))
|
|
|
|
)
|
|
|
|
,
|
|
|
|
$(word 1,$(1)) $(call _clean-path-strip-dotdot,$(wordlist 2,$(words $(1)),$(1)))
|
|
|
|
)
|
|
|
|
,
|
|
|
|
$(1)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
|
|
|
# Remove any leading .. from the path (in case of /..)
|
|
|
|
#
|
|
|
|
# Should only be called if the original path started with /
|
|
|
|
# $(1): The expanded path, where / is converted to ' ' to work with $(word)
|
|
|
|
define _clean-path-strip-root-dotdots
|
|
|
|
$(strip $(if $(call streq,$(firstword $(1)),..),
|
|
|
|
$(call _clean-path-strip-root-dotdots,$(wordlist 2,$(words $(1)),$(1))),
|
|
|
|
$(1)))
|
|
|
|
endef
|
|
|
|
|
|
|
|
# Call _clean-path-strip-dotdot until the path stops changing
|
|
|
|
# $(1): Non-empty if this path started with a /
|
|
|
|
# $(2): The expanded path, where / is converted to ' ' to work with $(word)
|
|
|
|
define _clean-path-expanded
|
|
|
|
$(strip \
|
|
|
|
$(eval _ep := $(call _clean-path-strip-dotdot,$(2)))
|
|
|
|
$(if $(1),$(eval _ep := $(call _clean-path-strip-root-dotdots,$(_ep))))
|
|
|
|
$(if $(call streq,$(2),$(_ep)),
|
|
|
|
$(_ep),
|
|
|
|
$(call _clean-path-expanded,$(1),$(_ep))))
|
|
|
|
endef
|
|
|
|
|
|
|
|
# Clean the file path -- remove //, dir/.., extra .
|
|
|
|
#
|
|
|
|
# This should be the same semantics as golang's filepath.Clean
|
|
|
|
#
|
|
|
|
# $(1): The file path to clean
|
|
|
|
define clean-path
|
|
|
|
$(strip \
|
|
|
|
$(if $(call streq,$(words $(1)),1),
|
|
|
|
$(eval _rooted := $(filter /%,$(1)))
|
|
|
|
$(eval _expanded_path := $(filter-out .,$(subst /,$(space),$(1))))
|
|
|
|
$(eval _path := $(if $(_rooted),/)$(subst $(space),/,$(call _clean-path-expanded,$(_rooted),$(_expanded_path))))
|
|
|
|
$(if $(_path),
|
|
|
|
$(_path),
|
|
|
|
.
|
|
|
|
)
|
|
|
|
,
|
|
|
|
$(if $(call streq,$(words $(1)),0),
|
|
|
|
.,
|
|
|
|
$(error Call clean-path with only one path (without spaces))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
|
|
|
ifeq ($(TEST_MAKE_clean_path),true)
|
|
|
|
define my_test
|
|
|
|
$(if $(call streq,$(call clean-path,$(1)),$(2)),,
|
|
|
|
$(eval my_failed := true)
|
|
|
|
$(warning clean-path test '$(1)': expected '$(2)', got '$(call clean-path,$(1))'))
|
|
|
|
endef
|
|
|
|
my_failed :=
|
|
|
|
|
|
|
|
# Already clean
|
|
|
|
$(call my_test,abc,abc)
|
|
|
|
$(call my_test,abc/def,abc/def)
|
|
|
|
$(call my_test,a/b/c,a/b/c)
|
|
|
|
$(call my_test,.,.)
|
|
|
|
$(call my_test,..,..)
|
|
|
|
$(call my_test,../..,../..)
|
|
|
|
$(call my_test,../../abc,../../abc)
|
|
|
|
$(call my_test,/abc,/abc)
|
|
|
|
$(call my_test,/,/)
|
|
|
|
|
|
|
|
# Empty is current dir
|
|
|
|
$(call my_test,,.)
|
|
|
|
|
|
|
|
# Remove trailing slash
|
|
|
|
$(call my_test,abc/,abc)
|
|
|
|
$(call my_test,abc/def/,abc/def)
|
|
|
|
$(call my_test,a/b/c/,a/b/c)
|
|
|
|
$(call my_test,./,.)
|
|
|
|
$(call my_test,../,..)
|
|
|
|
$(call my_test,../../,../..)
|
|
|
|
$(call my_test,/abc/,/abc)
|
|
|
|
|
|
|
|
# Remove doubled slash
|
|
|
|
$(call my_test,abc//def//ghi,abc/def/ghi)
|
|
|
|
$(call my_test,//abc,/abc)
|
|
|
|
$(call my_test,///abc,/abc)
|
|
|
|
$(call my_test,//abc//,/abc)
|
|
|
|
$(call my_test,abc//,abc)
|
|
|
|
|
|
|
|
# Remove . elements
|
|
|
|
$(call my_test,abc/./def,abc/def)
|
|
|
|
$(call my_test,/./abc/def,/abc/def)
|
|
|
|
$(call my_test,abc/.,abc)
|
|
|
|
|
|
|
|
# Remove .. elements
|
|
|
|
$(call my_test,abc/def/ghi/../jkl,abc/def/jkl)
|
|
|
|
$(call my_test,abc/def/../ghi/../jkl,abc/jkl)
|
|
|
|
$(call my_test,abc/def/..,abc)
|
|
|
|
$(call my_test,abc/def/../..,.)
|
|
|
|
$(call my_test,/abc/def/../..,/)
|
|
|
|
$(call my_test,abc/def/../../..,..)
|
|
|
|
$(call my_test,/abc/def/../../..,/)
|
|
|
|
$(call my_test,abc/def/../../../ghi/jkl/../../../mno,../../mno)
|
|
|
|
$(call my_test,/../abc,/abc)
|
|
|
|
|
|
|
|
# Combinations
|
|
|
|
$(call my_test,abc/./../def,def)
|
|
|
|
$(call my_test,abc//./../def,def)
|
|
|
|
$(call my_test,abc/../../././../def,../../def)
|
|
|
|
|
|
|
|
ifdef my_failed
|
|
|
|
$(error failed clean-path test)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2017-10-25 00:24:24 +02:00
|
|
|
###########################################################
|
|
|
|
## Given a filepath, returns nonempty if the path cannot be
|
|
|
|
## validated to be contained in the current directory
|
|
|
|
## This is, this function checks for '/' and '..'
|
|
|
|
##
|
|
|
|
## $(1): path to validate
|
|
|
|
define try-validate-path-is-subdir
|
2018-10-03 14:38:00 +02:00
|
|
|
$(strip \
|
2017-10-25 00:24:24 +02:00
|
|
|
$(if $(filter /%,$(1)),
|
|
|
|
$(1) starts with a slash
|
|
|
|
)
|
|
|
|
$(if $(filter ../%,$(call clean-path,$(1))),
|
|
|
|
$(1) escapes its parent using '..'
|
|
|
|
)
|
|
|
|
$(if $(strip $(1)),
|
|
|
|
,
|
|
|
|
'$(1)' is empty
|
|
|
|
)
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
|
|
|
define validate-path-is-subdir
|
|
|
|
$(if $(call try-validate-path-is-subdir,$(1)),
|
|
|
|
$(call pretty-error, Illegal path: $(call try-validate-path-is-subdir,$(1)))
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Given a space-delimited list of filepaths, returns
|
|
|
|
## nonempty if any cannot be validated to be contained in
|
|
|
|
## the current directory
|
|
|
|
##
|
|
|
|
## $(1): path list to validate
|
|
|
|
define try-validate-paths-are-subdirs
|
|
|
|
$(strip \
|
|
|
|
$(foreach my_path,$(1),\
|
|
|
|
$(call try-validate-path-is-subdir,$(my_path))\
|
|
|
|
)
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
|
|
|
define validate-paths-are-subdirs
|
|
|
|
$(if $(call try-validate-paths-are-subdirs,$(1)),
|
|
|
|
$(call pretty-error,Illegal paths:\'$(call try-validate-paths-are-subdirs,$(1))\')
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Tests of try-validate-path-is-subdir
|
|
|
|
## and try-validate-paths-are-subdirs
|
|
|
|
define test-validate-paths-are-subdirs
|
|
|
|
$(eval my_error := $(call try-validate-path-is-subdir,/tmp)) \
|
|
|
|
$(if $(call streq,$(my_error),/tmp starts with a slash),
|
|
|
|
,
|
|
|
|
$(error incorrect error message for path /tmp. Got '$(my_error)')
|
|
|
|
) \
|
|
|
|
$(eval my_error := $(call try-validate-path-is-subdir,../sibling)) \
|
|
|
|
$(if $(call streq,$(my_error),../sibling escapes its parent using '..'),
|
|
|
|
,
|
|
|
|
$(error incorrect error message for path ../sibling. Got '$(my_error)')
|
|
|
|
) \
|
|
|
|
$(eval my_error := $(call try-validate-path-is-subdir,child/../../sibling)) \
|
|
|
|
$(if $(call streq,$(my_error),child/../../sibling escapes its parent using '..'),
|
|
|
|
,
|
|
|
|
$(error incorrect error message for path child/../../sibling. Got '$(my_error)')
|
|
|
|
) \
|
|
|
|
$(eval my_error := $(call try-validate-path-is-subdir,)) \
|
|
|
|
$(if $(call streq,$(my_error),'' is empty),
|
|
|
|
,
|
|
|
|
$(error incorrect error message for empty path ''. Got '$(my_error)')
|
|
|
|
) \
|
|
|
|
$(eval my_error := $(call try-validate-path-is-subdir,subdir/subsubdir)) \
|
|
|
|
$(if $(call streq,$(my_error),),
|
|
|
|
,
|
|
|
|
$(error rejected valid path 'subdir/subsubdir'. Got '$(my_error)')
|
|
|
|
)
|
|
|
|
|
|
|
|
$(eval my_error := $(call try-validate-paths-are-subdirs,a/b /c/d e/f))
|
|
|
|
$(if $(call streq,$(my_error),/c/d starts with a slash),
|
|
|
|
,
|
|
|
|
$(error incorrect error message for path list 'a/b /c/d e/f'. Got '$(my_error)')
|
|
|
|
)
|
|
|
|
$(eval my_error := $(call try-validate-paths-are-subdirs,a/b c/d))
|
|
|
|
$(if $(call streq,$(my_error),),
|
|
|
|
,
|
|
|
|
$(error rejected valid path list 'a/b c/d'. Got '$(my_error)')
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
# run test
|
|
|
|
$(strip $(call test-validate-paths-are-subdirs))
|
|
|
|
|
2017-11-22 00:01:26 +01:00
|
|
|
###########################################################
|
|
|
|
## Validate jacoco class filters and convert them to
|
|
|
|
## file arguments
|
|
|
|
## Jacoco class filters are comma-separated lists of class
|
|
|
|
## files (android.app.Application), and may have '*' as the
|
|
|
|
## last character to match all classes in a package
|
|
|
|
## including subpackages.
|
|
|
|
define jacoco-class-filter-to-file-args
|
|
|
|
$(strip $(call jacoco-validate-file-args,\
|
|
|
|
$(subst $(comma),$(space),\
|
|
|
|
$(subst .,/,\
|
|
|
|
$(strip $(1))))))
|
|
|
|
endef
|
|
|
|
|
|
|
|
define jacoco-validate-file-args
|
|
|
|
$(strip $(1)\
|
|
|
|
$(call validate-paths-are-subdirs,$(1))
|
|
|
|
$(foreach arg,$(1),\
|
|
|
|
$(if $(findstring ?,$(arg)),$(call pretty-error,\
|
|
|
|
'?' filters are not supported in LOCAL_JACK_COVERAGE_INCLUDE_FILTER or LOCAL_JACK_COVERAGE_EXCLUDE_FILTER))\
|
|
|
|
$(if $(findstring *,$(patsubst %*,%,$(arg))),$(call pretty-error,\
|
|
|
|
'*' is only supported at the end of a filter in LOCAL_JACK_COVERAGE_INCLUDE_FILTER or LOCAL_JACK_COVERAGE_EXCLUDE_FILTER))\
|
|
|
|
))
|
|
|
|
endef
|
2017-10-25 00:24:24 +02:00
|
|
|
|
2012-11-15 00:57:07 +01:00
|
|
|
###########################################################
|
2009-03-04 04:28:42 +01:00
|
|
|
## Other includes
|
|
|
|
###########################################################
|
|
|
|
|
2010-10-20 13:41:59 +02:00
|
|
|
# Include any vendor specific definitions.mk file
|
|
|
|
-include $(TOPDIR)vendor/*/build/core/definitions.mk
|
2014-10-28 16:32:11 +01:00
|
|
|
-include $(TOPDIR)device/*/build/core/definitions.mk
|
2015-08-21 00:39:56 +02:00
|
|
|
-include $(TOPDIR)product/*/build/core/definitions.mk
|
2022-08-18 21:22:15 +02:00
|
|
|
# Also the project-specific definitions.mk file
|
|
|
|
-include $(TOPDIR)vendor/*/*/build/core/definitions.mk
|
|
|
|
-include $(TOPDIR)device/*/*/build/core/definitions.mk
|
|
|
|
-include $(TOPDIR)product/*/*/build/core/definitions.mk
|
2010-10-20 13:41:59 +02:00
|
|
|
|
2009-03-04 04:28:42 +01:00
|
|
|
# broken:
|
|
|
|
# $(foreach file,$^,$(if $(findstring,.a,$(suffix $file)),-l$(file),$(file)))
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Misc notes
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
#DEPDIR = .deps
|
|
|
|
#df = $(DEPDIR)/$(*F)
|
|
|
|
|
|
|
|
#SRCS = foo.c bar.c ...
|
|
|
|
|
|
|
|
#%.o : %.c
|
|
|
|
# @$(MAKEDEPEND); \
|
|
|
|
# cp $(df).d $(df).P; \
|
|
|
|
# sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
|
|
|
|
# -e '/^$$/ d' -e 's/$$/ :/' < $(df).d >> $(df).P; \
|
|
|
|
# rm -f $(df).d
|
|
|
|
# $(COMPILE.c) -o $@ $<
|
|
|
|
|
|
|
|
#-include $(SRCS:%.c=$(DEPDIR)/%.P)
|
|
|
|
|
|
|
|
|
|
|
|
#%.o : %.c
|
|
|
|
# $(COMPILE.c) -MD -o $@ $<
|
|
|
|
# @cp $*.d $*.P; \
|
|
|
|
# sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
|
|
|
|
# -e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $*.P; \
|
|
|
|
# rm -f $*.d
|
2017-02-01 16:44:58 +01:00
|
|
|
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
# Append the information to generate a RRO package for the
|
|
|
|
# source module.
|
|
|
|
#
|
|
|
|
# $(1): Source module name.
|
|
|
|
# $(2): Whether $(3) is a manifest package name or not.
|
|
|
|
# $(3): Manifest package name if $(2) is true.
|
|
|
|
# Otherwise, android manifest file path of the
|
|
|
|
# source module.
|
|
|
|
# $(4): Whether LOCAL_EXPORT_PACKAGE_RESOURCES is set or
|
|
|
|
# not for the source module.
|
|
|
|
# $(5): Resource overlay list.
|
2019-03-18 12:43:30 +01:00
|
|
|
# $(6): Target partition
|
2017-02-01 16:44:58 +01:00
|
|
|
###########################################################
|
|
|
|
define append_enforce_rro_sources
|
|
|
|
$(eval ENFORCE_RRO_SOURCES += \
|
2019-03-18 12:43:30 +01:00
|
|
|
$(strip $(1))||$(strip $(2))||$(strip $(3))||$(strip $(4))||$(call normalize-path-list, $(strip $(5)))||$(strip $(6)) \
|
|
|
|
)
|
2017-02-01 16:44:58 +01:00
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
# Generate all RRO packages for source modules stored in
|
|
|
|
# ENFORCE_RRO_SOURCES
|
|
|
|
###########################################################
|
|
|
|
define generate_all_enforce_rro_packages
|
|
|
|
$(foreach source,$(ENFORCE_RRO_SOURCES), \
|
|
|
|
$(eval _o := $(subst ||,$(space),$(source))) \
|
|
|
|
$(eval enforce_rro_source_module := $(word 1,$(_o))) \
|
|
|
|
$(eval enforce_rro_source_is_manifest_package_name := $(word 2,$(_o))) \
|
|
|
|
$(eval enforce_rro_source_manifest_package_info := $(word 3,$(_o))) \
|
|
|
|
$(eval enforce_rro_use_res_lib := $(word 4,$(_o))) \
|
|
|
|
$(eval enforce_rro_source_overlays := $(subst :, ,$(word 5,$(_o)))) \
|
2019-03-18 12:43:30 +01:00
|
|
|
$(eval enforce_rro_partition := $(word 6,$(_o))) \
|
2017-02-01 16:44:58 +01:00
|
|
|
$(eval include $(BUILD_SYSTEM)/generate_enforce_rro.mk) \
|
2019-04-02 23:43:32 +02:00
|
|
|
$(eval ALL_MODULES.$$(enforce_rro_source_module).REQUIRED_FROM_TARGET += $$(LOCAL_PACKAGE_NAME)) \
|
2017-02-01 16:44:58 +01:00
|
|
|
)
|
2017-04-08 01:28:41 +02:00
|
|
|
endef
|
2017-10-16 12:20:34 +02:00
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Find system_$(VER) in LOCAL_SDK_VERSION
|
2020-03-07 10:34:57 +01:00
|
|
|
## note: system_server_* is excluded. It's a different API surface
|
2017-10-16 12:20:34 +02:00
|
|
|
##
|
|
|
|
## $(1): LOCAL_SDK_VERSION
|
|
|
|
###########################################################
|
|
|
|
define has-system-sdk-version
|
2020-03-07 10:34:57 +01:00
|
|
|
$(filter-out system_server_%,$(filter system_%,$(1)))
|
2017-10-16 12:20:34 +02:00
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Get numerical version in LOCAL_SDK_VERSION
|
|
|
|
##
|
|
|
|
## $(1): LOCAL_SDK_VERSION
|
|
|
|
###########################################################
|
|
|
|
define get-numeric-sdk-version
|
|
|
|
$(filter-out current,\
|
|
|
|
$(if $(call has-system-sdk-version,$(1)),$(patsubst system_%,%,$(1)),$(1)))
|
|
|
|
endef
|
2018-02-09 00:39:20 +01:00
|
|
|
|
2018-06-10 23:49:01 +02:00
|
|
|
###########################################################
|
|
|
|
## Verify module name meets character requirements:
|
|
|
|
## a-z A-Z 0-9
|
2018-07-16 22:57:52 +02:00
|
|
|
## _.+-,@~
|
2018-06-10 23:49:01 +02:00
|
|
|
##
|
2018-06-12 07:28:00 +02:00
|
|
|
## This is a subset of bazel's target name restrictions:
|
2018-06-10 23:49:01 +02:00
|
|
|
## https://docs.bazel.build/versions/master/build-ref.html#name
|
2018-07-16 22:57:52 +02:00
|
|
|
##
|
|
|
|
## Kati has problems with '=': https://github.com/google/kati/issues/138
|
2018-06-10 23:49:01 +02:00
|
|
|
###########################################################
|
|
|
|
define verify-module-name
|
2018-06-12 07:28:00 +02:00
|
|
|
$(if $(filter-out $(LOCAL_MODULE),$(subst /,,$(LOCAL_MODULE))), \
|
|
|
|
$(call pretty-warning,Module name contains a /$(comma) use LOCAL_MODULE_STEM and LOCAL_MODULE_RELATIVE_PATH instead)) \
|
2018-06-10 23:49:01 +02:00
|
|
|
$(if $(call _invalid-name-chars,$(LOCAL_MODULE)), \
|
|
|
|
$(call pretty-error,Invalid characters in module name: $(call _invalid-name-chars,$(LOCAL_MODULE))))
|
|
|
|
endef
|
|
|
|
define _invalid-name-chars
|
2018-07-16 22:57:52 +02:00
|
|
|
$(subst _,,$(subst .,,$(subst +,,$(subst -,,$(subst $(comma),,$(subst @,,$(subst ~,,$(subst 0,,$(subst 1,,$(subst 2,,$(subst 3,,$(subst 4,,$(subst 5,,$(subst 6,,$(subst 7,,$(subst 8,,$(subst 9,,$(subst a,,$(subst b,,$(subst c,,$(subst d,,$(subst e,,$(subst f,,$(subst g,,$(subst h,,$(subst i,,$(subst j,,$(subst k,,$(subst l,,$(subst m,,$(subst n,,$(subst o,,$(subst p,,$(subst q,,$(subst r,,$(subst s,,$(subst t,,$(subst u,,$(subst v,,$(subst w,,$(subst x,,$(subst y,,$(subst z,,$(call to-lower,$(1)))))))))))))))))))))))))))))))))))))))))))))
|
2018-06-10 23:49:01 +02:00
|
|
|
endef
|
|
|
|
.KATI_READONLY := verify-module-name _invalid-name-chars
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Verify module stem meets character requirements:
|
|
|
|
## a-z A-Z 0-9
|
2018-07-16 22:57:52 +02:00
|
|
|
## _.+-,@~
|
2018-06-10 23:49:01 +02:00
|
|
|
##
|
|
|
|
## This is a subset of bazel's target name restrictions:
|
|
|
|
## https://docs.bazel.build/versions/master/build-ref.html#name
|
|
|
|
##
|
|
|
|
## $(1): The module stem variable to check
|
|
|
|
###########################################################
|
|
|
|
define verify-module-stem
|
2018-06-12 07:28:00 +02:00
|
|
|
$(if $(filter-out $($(1)),$(subst /,,$($(1)))), \
|
|
|
|
$(call pretty-warning,Module stem \($(1)\) contains a /$(comma) use LOCAL_MODULE_RELATIVE_PATH instead)) \
|
2018-06-10 23:49:01 +02:00
|
|
|
$(if $(call _invalid-name-chars,$($(1))), \
|
2018-06-12 07:28:00 +02:00
|
|
|
$(call pretty-error,Invalid characters in module stem \($(1)\): $(call _invalid-name-chars,$($(1)))))
|
2018-06-10 23:49:01 +02:00
|
|
|
endef
|
|
|
|
.KATI_READONLY := verify-module-stem
|
2018-09-14 22:39:07 +02:00
|
|
|
|
|
|
|
$(KATI_obsolete_var \
|
|
|
|
create-empty-package \
|
|
|
|
initialize-package-file \
|
2019-05-29 18:15:33 +02:00
|
|
|
add-jni-shared-libs-to-package \
|
|
|
|
inherit-package,\
|
2018-09-14 22:39:07 +02:00
|
|
|
These functions have been removed)
|
2018-11-13 05:16:26 +01:00
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Verify the variants of a VNDK library are identical
|
|
|
|
##
|
|
|
|
## $(1): Path to the core variant shared library file.
|
|
|
|
## $(2): Path to the vendor variant shared library file.
|
|
|
|
## $(3): TOOLS_PREFIX
|
|
|
|
###########################################################
|
|
|
|
LIBRARY_IDENTITY_CHECK_SCRIPT := build/make/tools/check_identical_lib.sh
|
|
|
|
define verify-vndk-libs-identical
|
|
|
|
@echo "Checking VNDK vendor variant: $(2)"
|
|
|
|
$(hide) CLANG_BIN="$(LLVM_PREBUILTS_PATH)" \
|
2019-05-29 00:09:53 +02:00
|
|
|
CROSS_COMPILE="$(strip $(3))" \
|
|
|
|
XZ="$(XZ)" \
|
|
|
|
$(LIBRARY_IDENTITY_CHECK_SCRIPT) $(SOONG_STRIP_PATH) $(1) $(2)
|
2018-11-13 05:16:26 +01:00
|
|
|
endef
|
2020-04-07 18:50:32 +02:00
|
|
|
|
|
|
|
# Convert Soong libraries that have SDK variant
|
|
|
|
define use_soong_sdk_libraries
|
|
|
|
$(foreach l,$(1),$(if $(filter $(l),$(SOONG_SDK_VARIANT_MODULES)),\
|
|
|
|
$(l).sdk,$(l)))
|
|
|
|
endef
|