2009-03-04 11:28:42 +08: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:=
|
|
|
|
|
|
|
|
# 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 files that are made by some tool
|
|
|
|
ALL_GENERATED_SOURCES:=
|
|
|
|
|
|
|
|
# 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:=
|
|
|
|
|
build: remove prelinker build build system
This patch removes support for prelinking from the build system. By now, the
prelinker has outlived its usefulness for several reasons. Firstly, the
speedup that it afforded in the early days of Android is now nullified by the
speed of hardware, as well as by the presence of Zygote. Secondly, the space
savings that come with prelinking (measued at 17MB on a recent honeycomb
stingray build) are no longer important either. Thirdly, prelinking reduces
the effectiveness of Address-Space-Layout Randomization. Finally, since it is
not part of the gcc suite, the prelinker needs to be maintained separately.
The patch deletes apriori, soslim, lsd, isprelinked, and iself from the source
tree. It also removes the prelink map.
LOCAL_PRELINK_MODULE becomes a no-op. Individual Android.mk will get cleaned
separately. Support for prelinking will have to be removed from the recovery
code and from the dynamic loader as well.
Change-Id: I5839c9c25f7772d5183eedfe20ab924f2a7cd411
2011-03-09 08:19:48 +08:00
|
|
|
# The list of dynamic binaries that haven't been stripped/compressed/etc.
|
2009-03-04 11:28:42 +08:00
|
|
|
ALL_ORIGINAL_DYNAMIC_BINARIES:=
|
|
|
|
|
|
|
|
# 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-13 04:57:38 +08:00
|
|
|
# GPL module license files
|
|
|
|
ALL_GPL_MODULE_LICENSE_FILES:=
|
|
|
|
|
2013-02-23 06:32:30 +08:00
|
|
|
# Target and host installed module's dependencies on shared libraries.
|
2013-04-16 08:32:21 +08:00
|
|
|
# They are list of "<module_name>:<installed_file>:lib1,lib2...".
|
2013-02-23 06:32:30 +08:00
|
|
|
TARGET_DEPENDENCIES_ON_SHARED_LIBRARIES :=
|
2014-05-21 05:43:51 +08:00
|
|
|
$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_DEPENDENCIES_ON_SHARED_LIBRARIES :=
|
2013-02-23 06:32:30 +08:00
|
|
|
HOST_DEPENDENCIES_ON_SHARED_LIBRARIES :=
|
2014-05-21 05:43:51 +08:00
|
|
|
$(HOST_2ND_ARCH_VAR_PREFIX)HOST_DEPENDENCIES_ON_SHARED_LIBRARIES :=
|
2015-08-15 03:59:50 +08:00
|
|
|
HOST_CROSS_DEPENDENCIES_ON_SHARED_LIBRARIES :=
|
2016-02-06 08:20:19 +08:00
|
|
|
$(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_DEPENDENCIES_ON_SHARED_LIBRARIES :=
|
2013-02-23 06:32:30 +08:00
|
|
|
|
2012-06-20 01:40:37 +08: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-15 03:59:50 +08:00
|
|
|
# Display names for various build targets
|
|
|
|
TARGET_DISPLAY := target
|
2016-08-02 08:41:49 +08:00
|
|
|
AUX_DISPLAY := aux
|
2015-08-15 03:59:50 +08:00
|
|
|
HOST_DISPLAY := host
|
|
|
|
HOST_CROSS_DISPLAY := host cross
|
|
|
|
|
2016-07-28 13:52:42 +08:00
|
|
|
# All installed initrc files
|
|
|
|
ALL_INIT_RC_INSTALLED_PAIRS :=
|
|
|
|
|
2009-03-04 11:28:42 +08: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 10:31:12 +08: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-13 04:56:50 +08:00
|
|
|
###########################################################
|
|
|
|
## Rule for touching GCNO files.
|
|
|
|
###########################################################
|
|
|
|
define gcno-touch-rule
|
|
|
|
$(2): $(1)
|
|
|
|
touch -c $$@
|
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
2009-04-10 10:31:12 +08:00
|
|
|
|
2009-03-04 11:28:42 +08:00
|
|
|
###########################################################
|
|
|
|
## Retrieve the directory of the current makefile
|
2014-03-02 07:32:04 +08:00
|
|
|
## Must be called before including any other makefile!!
|
2009-03-04 11:28:42 +08:00
|
|
|
###########################################################
|
|
|
|
|
|
|
|
# Figure out where we are.
|
|
|
|
define my-dir
|
2009-05-20 07:12:22 +08:00
|
|
|
$(strip \
|
2012-04-24 12:29:18 +08:00
|
|
|
$(eval LOCAL_MODULE_MAKEFILE := $$(lastword $$(MAKEFILE_LIST))) \
|
2014-03-02 07:32:04 +08:00
|
|
|
$(if $(filter $(BUILD_SYSTEM)/% $(OUT_DIR)/%,$(LOCAL_MODULE_MAKEFILE)), \
|
|
|
|
$(error my-dir must be called before including any other makefile.) \
|
2009-05-20 07:12:22 +08:00
|
|
|
, \
|
2012-04-24 12:29:18 +08:00
|
|
|
$(patsubst %/,%,$(dir $(LOCAL_MODULE_MAKEFILE))) \
|
2009-05-20 07:12:22 +08:00
|
|
|
) \
|
|
|
|
)
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
2016-05-28 06:23:13 +08:00
|
|
|
|
2009-03-04 11:28:42 +08:00
|
|
|
###########################################################
|
|
|
|
## Retrieve a list of all makefiles immediately below some directory
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define all-makefiles-under
|
2016-07-12 07:57:33 +08:00
|
|
|
$(wildcard $(1)/*/Android.mk)
|
2009-03-04 11:28:42 +08: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
|
2016-07-12 07:57:33 +08:00
|
|
|
$(shell build/tools/findleaves.py $(FIND_LEAVES_EXCLUDES) \
|
|
|
|
--mindepth=2 $(addprefix --dir=,$(1)) Android.mk)
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Retrieve a list of all makefiles immediately below your directory
|
2014-03-02 07:32:04 +08:00
|
|
|
## Must be called before including any other makefile!!
|
2009-03-04 11:28:42 +08: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 07:32:04 +08:00
|
|
|
## Must be called before including any other makefile!!
|
2009-03-04 11:28:42 +08:00
|
|
|
###########################################################
|
|
|
|
|
|
|
|
# $(1): List of directories to look for under this directory
|
|
|
|
define all-named-subdir-makefiles
|
2016-07-12 07:57:33 +08:00
|
|
|
$(wildcard $(addsuffix /Android.mk, $(addprefix $(call my-dir)/,$(1))))
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
2015-10-13 06:26:52 +08: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 11:28:42 +08: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 06:26:52 +08:00
|
|
|
$(call all-named-files-under,*.java,$(1))
|
2009-03-04 11:28:42 +08: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 06:26:52 +08:00
|
|
|
$(call all-named-files-under,*.c,$(1))
|
2009-03-04 11:28:42 +08: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 07:26:28 +08: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 11:28:42 +08: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 06:26:52 +08:00
|
|
|
$(call all-named-files-under,I*.aidl,$(1))
|
2009-03-04 11:28:42 +08: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-20 03:06:58 +08: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-03 01:36:20 +08: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 06:26:52 +08:00
|
|
|
$(call all-named-files-under,*.logtags,$(1))
|
2010-02-03 01:36:20 +08:00
|
|
|
endef
|
|
|
|
|
2010-11-03 09:43:16 +08: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 06:26:52 +08:00
|
|
|
$(call all-named-files-under,*.proto,$(1))
|
2010-11-03 09:43:16 +08:00
|
|
|
endef
|
|
|
|
|
2010-07-16 08:17:52 +08: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
|
2015-10-13 06:26:52 +08:00
|
|
|
$(call find-subdir-files,$(1) \( -name "*.rs" -or -name "*.fs" \) -and -not -name ".*")
|
2010-07-16 08:17:52 +08:00
|
|
|
endef
|
|
|
|
|
2009-12-18 09:47:28 +08:00
|
|
|
###########################################################
|
2014-02-12 05:48:35 +08: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 06:26:52 +08:00
|
|
|
$(call all-named-files-under,*.S,$(1))
|
2014-02-12 05:48:35 +08:00
|
|
|
endef
|
|
|
|
|
2009-12-18 09:47:28 +08: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 06:26:52 +08:00
|
|
|
$(call all-named-files-under,*.html,$(1))
|
2009-12-18 09:47:28 +08:00
|
|
|
endef
|
|
|
|
|
2009-03-04 11:28:42 +08: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 09:47:28 +08:00
|
|
|
$(call all-html-files-under,.)
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Find all of the files matching pattern
|
|
|
|
## SRC_FILES := $(call find-subdir-files, <pattern>)
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define find-subdir-files
|
2015-09-23 07:54:12 +08:00
|
|
|
$(sort $(patsubst ./%,%,$(shell cd $(LOCAL_PATH) ; find -L $(1))))
|
2009-03-04 11:28:42 +08: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 07:54:12 +08:00
|
|
|
$(sort $(filter-out $(patsubst %,$(1)/%,$(3)),$(patsubst ./%,%,$(shell cd \
|
|
|
|
$(LOCAL_PATH) ; find -L $(1) -maxdepth 1 -name $(2)))))
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Find all of the files matching pattern
|
|
|
|
## SRC_FILES := $(call all-subdir-java-files)
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define find-subdir-assets
|
2015-09-23 07:54:12 +08:00
|
|
|
$(sort $(if $(1),$(patsubst ./%,%, \
|
2016-05-12 17:15:28 +08:00
|
|
|
$(shell if [ -d $(1) ] ; then cd $(1) ; find -L ./ -not -name '.*' -and -type f ; fi)), \
|
2009-03-04 11:28:42 +08:00
|
|
|
$(warning Empty argument supplied to find-subdir-assets) \
|
2015-09-23 07:54:12 +08:00
|
|
|
))
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Find various file types in a list of directories relative to $(LOCAL_PATH)
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define find-other-java-files
|
2015-10-13 06:26:52 +08:00
|
|
|
$(call all-java-files-under,$(1))
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
|
|
|
define find-other-html-files
|
2015-10-13 06:26:52 +08:00
|
|
|
$(call all-html-files-under,$(1))
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
2013-12-05 08:04:49 +08: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 07:54:12 +08:00
|
|
|
$(sort $(patsubst ./%,%, \
|
2013-12-05 08:04:49 +08:00
|
|
|
$(shell cd $(1) ; \
|
|
|
|
find -L $(3) -name $(2) -and -not -name ".*") \
|
2015-09-23 07:54:12 +08:00
|
|
|
))
|
2013-12-05 08:04:49 +08:00
|
|
|
endef
|
|
|
|
|
2009-03-04 11:28:42 +08: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 07:30:21 +08:00
|
|
|
$(eval _fpf := $(sort $(wildcard $(foreach f, $(2), $(strip $(1))/$(f))))) \
|
2009-03-04 11:28:42 +08:00
|
|
|
$(if $(_fpf),$(_fpf), \
|
|
|
|
$(if $(filter-out ./ .,$(1)), \
|
|
|
|
$(call find-parent-file,$(patsubst %/,%,$(dir $(1))),$(2)) \
|
|
|
|
) \
|
|
|
|
) \
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Function we can evaluate to introduce a dynamic dependency
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define add-dependency
|
|
|
|
$(1): $(2)
|
|
|
|
endef
|
|
|
|
|
2014-09-08 20:45:14 +08: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 08:41:49 +08:00
|
|
|
define def-host-aux-target
|
|
|
|
$(eval _idf_val_:=$(if $(strip $(LOCAL_IS_HOST_MODULE)),HOST,$(if $(strip $(LOCAL_IS_AUX_MODULE)),AUX,))) \
|
|
|
|
$(_idf_val_)
|
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Returns correct _idfPrefix from the list:
|
|
|
|
## { HOST, HOST_CROSS, AUX, TARGET }
|
|
|
|
###########################################################
|
|
|
|
# the following rules checked in order:
|
|
|
|
# ($1 is in {AUX, HOST_CROSS} => $1;
|
|
|
|
# ($1 is empty) => TARGET;
|
|
|
|
# ($2 is not empty) => HOST_CROSS;
|
|
|
|
# => HOST;
|
|
|
|
define find-idf-prefix
|
|
|
|
$(strip \
|
|
|
|
$(eval _idf_pfx_:=$(strip $(filter AUX HOST_CROSS,$(1)))) \
|
|
|
|
$(eval _idf_pfx_:=$(if $(strip $(1)),$(if $(_idf_pfx_),$(_idf_pfx_),$(if $(strip $(2)),HOST_CROSS,HOST)),TARGET)) \
|
|
|
|
$(_idf_pfx_)
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2009-03-04 11:28:42 +08: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"
|
2016-08-02 08:41:49 +08:00
|
|
|
# $(3): { HOST, HOST_CROSS, AUX, <empty (TARGET)>, <other non-empty (HOST)> }
|
2009-03-04 11:28:42 +08:00
|
|
|
# $(4): if non-empty, force the intermediates to be COMMON
|
2015-08-15 03:59:50 +08: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 11:28:42 +08: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 08:41:49 +08:00
|
|
|
$(eval _idfPrefix := $(call find-idf-prefix,$(3),$(6))) \
|
2014-06-18 12:35:44 +08:00
|
|
|
$(eval _idf2ndArchPrefix := $(if $(strip $(5)),$(TARGET_2ND_ARCH_VAR_PREFIX))) \
|
2010-09-25 09:09:04 +08:00
|
|
|
$(if $(filter $(_idfPrefix)-$(_idfClass),$(COMMON_MODULE_CLASSES))$(4), \
|
2009-03-04 11:28:42 +08:00
|
|
|
$(eval _idfIntBase := $($(_idfPrefix)_OUT_COMMON_INTERMEDIATES)) \
|
2016-02-13 16:19:40 +08:00
|
|
|
,$(if $(filter $(_idfClass),$(PER_ARCH_MODULE_CLASSES)),\
|
2014-01-25 05:38:08 +08:00
|
|
|
$(eval _idfIntBase := $($(_idf2ndArchPrefix)$(_idfPrefix)_OUT_INTERMEDIATES)) \
|
|
|
|
,$(eval _idfIntBase := $($(_idfPrefix)_OUT_INTERMEDIATES)) \
|
|
|
|
) \
|
2009-03-04 11:28:42 +08: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 08:02:16 +08:00
|
|
|
# $(2): if non-empty, force the intermediates to be for the 2nd arch
|
2015-08-15 03:59:50 +08:00
|
|
|
# $(3): if non-empty, force the intermediates to be for the host cross os
|
2009-03-04 11:28:42 +08: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)) \
|
2016-08-02 08:41:49 +08:00
|
|
|
$(call intermediates-dir-for,$(LOCAL_MODULE_CLASS),$(LOCAL_MODULE),$(call def-host-aux-target),$(1),$(2),$(3)) \
|
2009-03-04 11:28:42 +08:00
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
2014-01-25 15:17:21 +08: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"
|
2016-08-02 08:41:49 +08:00
|
|
|
# $(3): { HOST, HOST_CROSS, AUX, <empty (TARGET)>, <other non-empty (HOST)> }
|
2014-01-25 15:17:21 +08: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 08:41:49 +08:00
|
|
|
$(eval _idfPrefix := $(call find-idf-prefix,$(3),)) \
|
2014-01-25 15:17:21 +08:00
|
|
|
$(if $(filter $(_idfPrefix)-$(_idfClass),$(COMMON_MODULE_CLASSES))$(4), \
|
2015-11-25 21:14:23 +08:00
|
|
|
$(eval _idfIntBase := $($(_idfPrefix)_OUT_COMMON_GEN)) \
|
2014-01-25 15:17:21 +08: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)) \
|
2016-08-02 08:41:49 +08:00
|
|
|
$(call generated-sources-dir-for,$(LOCAL_MODULE_CLASS),$(LOCAL_MODULE),$(call def-host-aux-target),$(1)) \
|
2014-01-25 15:17:21 +08:00
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2009-03-04 11:28:42 +08: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
|
|
|
|
|
2009-04-10 10:31:12 +08: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
|
|
|
|
$(foreach module,$(1),$(ALL_MODULES.$(module).STUBS))
|
|
|
|
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 11:28:42 +08:00
|
|
|
###########################################################
|
2010-09-29 08:27:56 +08:00
|
|
|
## Convert "core ext framework" to "out/.../javalib.jar ..."
|
2009-03-04 11:28:42 +08:00
|
|
|
## $(1): library list
|
|
|
|
## $(2): Non-empty if IS_HOST_MODULE
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
# $(1): library name
|
|
|
|
# $(2): Non-empty if IS_HOST_MODULE
|
|
|
|
define _java-lib-dir
|
|
|
|
$(call intermediates-dir-for, \
|
2010-09-29 08:27:56 +08:00
|
|
|
JAVA_LIBRARIES,$(1),$(2),COMMON)
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
|
|
|
# $(1): library name
|
|
|
|
# $(2): Non-empty if IS_HOST_MODULE
|
|
|
|
define _java-lib-full-classes.jar
|
2016-03-03 09:25:01 +08:00
|
|
|
$(call _java-lib-dir,$(1),$(2))/$(if $(2),javalib,classes)$(COMMON_JAVA_PACKAGE_SUFFIX)
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
2016-03-03 09:25:01 +08: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 11:28:42 +08:00
|
|
|
# $(1): library name list
|
|
|
|
# $(2): Non-empty if IS_HOST_MODULE
|
|
|
|
define java-lib-files
|
|
|
|
$(foreach lib,$(1),$(call _java-lib-full-classes.jar,$(lib),$(2)))
|
|
|
|
endef
|
|
|
|
|
2016-03-03 09:25:01 +08: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 11:28:42 +08:00
|
|
|
# $(2): Non-empty if IS_HOST_MODULE
|
2016-03-03 09:25:01 +08: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 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
2016-03-03 09:25:01 +08:00
|
|
|
# Get the jar files (you can pass to "javac -classpath") of host dalvik Java libraries.
|
|
|
|
# You can also use them as dependency files.
|
|
|
|
# A host dalvik Java library is different from a host Java library in that
|
|
|
|
# the java lib file is classes.jar, not javalib.jar.
|
2009-03-04 11:28:42 +08:00
|
|
|
# $(1): library name list
|
2016-03-03 09:25:01 +08:00
|
|
|
define host-dex-java-lib-files
|
|
|
|
$(foreach lib,$(1),$(call _java-lib-dir,$(lib),true)/classes.jar)
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
2014-09-08 20:45:14 +08:00
|
|
|
###########################################################
|
|
|
|
## Convert "core ext framework" to "out/.../classes.jack ..."
|
|
|
|
## $(1): library list
|
|
|
|
## $(2): Non-empty if IS_HOST_MODULE
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
# $(1): library name
|
|
|
|
# $(2): Non-empty if IS_HOST_MODULE
|
|
|
|
define _jack-lib-full-classes
|
|
|
|
$(call _java-lib-dir,$(1),$(2))/classes.jack
|
|
|
|
endef
|
|
|
|
|
|
|
|
# $(1): library name list
|
|
|
|
# $(2): Non-empty if IS_HOST_MODULE
|
|
|
|
define jack-lib-files
|
|
|
|
$(foreach lib,$(1),$(call _jack-lib-full-classes,$(lib),$(2)))
|
|
|
|
endef
|
|
|
|
|
2010-09-15 01:09:48 +08:00
|
|
|
###########################################################
|
|
|
|
## Run rot13 on a string
|
|
|
|
## $(1): the string. Must be one line.
|
|
|
|
###########################################################
|
|
|
|
define rot13
|
|
|
|
$(shell echo $(1) | tr 'a-zA-Z' 'n-za-mN-ZA-M')
|
|
|
|
endef
|
|
|
|
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Returns true if $(1) and $(2) are equal. Returns
|
|
|
|
## the empty string if they are not equal.
|
|
|
|
###########################################################
|
|
|
|
define streq
|
|
|
|
$(strip $(if $(strip $(1)),\
|
|
|
|
$(if $(strip $(2)),\
|
|
|
|
$(if $(filter-out __,_$(subst $(strip $(1)),,$(strip $(2)))$(subst $(strip $(2)),,$(strip $(1)))_),,true), \
|
|
|
|
),\
|
|
|
|
$(if $(strip $(2)),\
|
|
|
|
,\
|
|
|
|
true)\
|
|
|
|
))
|
|
|
|
endef
|
|
|
|
|
2009-03-04 11:28:42 +08:00
|
|
|
###########################################################
|
|
|
|
## Convert "a b c" into "a:b:c"
|
|
|
|
###########################################################
|
|
|
|
define normalize-path-list
|
|
|
|
$(subst $(space),:,$(strip $(1)))
|
|
|
|
endef
|
|
|
|
|
2016-08-05 23:45:10 +08:00
|
|
|
###########################################################
|
|
|
|
## Convert "a b c" into "a,b,c"
|
|
|
|
###########################################################
|
|
|
|
define normalize-comma-list
|
|
|
|
$(subst $(space),$(comma),$(strip $(1)))
|
|
|
|
endef
|
|
|
|
|
2009-04-10 10:31:12 +08:00
|
|
|
###########################################################
|
|
|
|
## Read the word out of a colon-separated list of words.
|
|
|
|
## This has the same behavior as the built-in function
|
|
|
|
## $(word n,str).
|
|
|
|
##
|
|
|
|
## The individual words may not contain spaces.
|
|
|
|
##
|
|
|
|
## $(1): 1 based index
|
|
|
|
## $(2): value of the form a:b:c...
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define word-colon
|
|
|
|
$(word $(1),$(subst :,$(space),$(2)))
|
|
|
|
endef
|
|
|
|
|
2009-03-04 11:28:42 +08:00
|
|
|
###########################################################
|
|
|
|
## Convert "a=b c= d e = f" into "a=b c=d e=f"
|
|
|
|
##
|
|
|
|
## $(1): list to collapse
|
|
|
|
## $(2): if set, separator word; usually "=", ":", or ":="
|
|
|
|
## Defaults to "=" if not set.
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define collapse-pairs
|
|
|
|
$(eval _cpSEP := $(strip $(if $(2),$(2),=)))\
|
|
|
|
$(subst $(space)$(_cpSEP)$(space),$(_cpSEP),$(strip \
|
|
|
|
$(subst $(_cpSEP), $(_cpSEP) ,$(1))))
|
|
|
|
endef
|
|
|
|
|
2011-06-18 08:05:35 +08:00
|
|
|
###########################################################
|
|
|
|
## Given a list of pairs, if multiple pairs have the same
|
|
|
|
## first components, keep only the first pair.
|
|
|
|
##
|
|
|
|
## $(1): list of pairs
|
|
|
|
## $(2): the separator word, such as ":", "=", etc.
|
|
|
|
define uniq-pairs-by-first-component
|
|
|
|
$(eval _upbfc_fc_set :=)\
|
|
|
|
$(strip $(foreach w,$(1), $(eval _first := $(word 1,$(subst $(2),$(space),$(w))))\
|
|
|
|
$(if $(filter $(_upbfc_fc_set),$(_first)),,$(w)\
|
|
|
|
$(eval _upbfc_fc_set += $(_first)))))\
|
|
|
|
$(eval _upbfc_fc_set :=)\
|
|
|
|
$(eval _first:=)
|
|
|
|
endef
|
|
|
|
|
2009-03-04 11:28:42 +08: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-19 04:41:53 +08:00
|
|
|
$(sort $(foreach tag,$(1),$(foreach m,$(ALL_MODULE_NAME_TAGS.$(tag)),$(ALL_MODULES.$(m).INSTALLED))))
|
2009-03-04 11:28:42 +08: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-08 03:44:22 +08:00
|
|
|
#TODO(jbq): as of 20100106 nobody uses the second parameter
|
2009-03-04 11:28:42 +08:00
|
|
|
define get-tagged-modules
|
|
|
|
$(filter-out \
|
|
|
|
$(call modules-for-tag-list,$(2)), \
|
|
|
|
$(call modules-for-tag-list,$(1)))
|
|
|
|
endef
|
|
|
|
|
2009-04-10 10:31:12 +08: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 11:28:42 +08:00
|
|
|
|
2016-06-16 10:20:57 +08:00
|
|
|
###########################################################
|
|
|
|
## Color-coded warnings and errors in build rules
|
|
|
|
##
|
|
|
|
## $(1): message to print
|
|
|
|
###########################################################
|
|
|
|
define echo-warning
|
|
|
|
echo -e "\e[1;35mwarning:\e[0m \e[1m" $(1) "\e[0m\n"
|
|
|
|
endef
|
|
|
|
|
|
|
|
define echo-error
|
|
|
|
echo -e "\e[1;31merror:\e[0m \e[1m" $(1) "\e[0m\n"
|
|
|
|
endef
|
|
|
|
|
|
|
|
|
2009-03-04 11:28:42 +08:00
|
|
|
###########################################################
|
|
|
|
## Package filtering
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
# Given a list of installed modules (short or long names)
|
|
|
|
# return a list of the packages (yes, .apk packages, not
|
|
|
|
# modules in general) that are overridden by this list and,
|
|
|
|
# therefore, should not be installed.
|
|
|
|
# $(1): mixed list of installed modules
|
|
|
|
# TODO: This is fragile; find a reliable way to get this information.
|
|
|
|
define _get-package-overrides
|
|
|
|
$(eval ### Discard any words containing slashes, unless they end in .apk, \
|
|
|
|
### in which case trim off the directory component and the suffix. \
|
|
|
|
### If there are no slashes, keep the entire word.)
|
|
|
|
$(eval _gpo_names := $(subst /,@@@ @@@,$(1)))
|
|
|
|
$(eval _gpo_names := \
|
|
|
|
$(filter %.apk,$(_gpo_names)) \
|
|
|
|
$(filter-out %@@@ @@@%,$(_gpo_names)))
|
|
|
|
$(eval _gpo_names := $(patsubst %.apk,%,$(_gpo_names)))
|
|
|
|
$(eval _gpo_names := $(patsubst @@@%,%,$(_gpo_names)))
|
|
|
|
|
|
|
|
$(eval ### Remove any remaining words that contain dots.)
|
|
|
|
$(eval _gpo_names := $(subst .,@@@ @@@,$(_gpo_names)))
|
|
|
|
$(eval _gpo_names := $(filter-out %@@@ @@@%,$(_gpo_names)))
|
|
|
|
|
|
|
|
$(eval ### Now we have a list of any words that could possibly refer to \
|
|
|
|
### packages, although there may be words that do not. Only \
|
|
|
|
### real packages will be present under PACKAGES.*, though.)
|
|
|
|
$(foreach _gpo_name,$(_gpo_names),$(PACKAGES.$(_gpo_name).OVERRIDES))
|
|
|
|
endef
|
|
|
|
|
|
|
|
define get-package-overrides
|
2011-12-23 01:46:19 +08:00
|
|
|
$(sort $(strip $(call _get-package-overrides,$(1))))
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Output the command lines, or not
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
ifeq ($(strip $(SHOW_COMMANDS)),)
|
|
|
|
define pretty
|
|
|
|
@echo $1
|
|
|
|
endef
|
|
|
|
else
|
|
|
|
define pretty
|
|
|
|
endef
|
|
|
|
endif
|
|
|
|
|
|
|
|
###########################################################
|
2016-01-25 17:59:43 +08:00
|
|
|
## Commands for munging the dependency files the compiler generates
|
2009-03-04 11:28:42 +08:00
|
|
|
###########################################################
|
2012-09-08 08:04:06 +08:00
|
|
|
# $(1): the input .d file
|
|
|
|
# $(2): the output .P file
|
|
|
|
define transform-d-to-p-args
|
|
|
|
$(hide) cp $(1) $(2); \
|
|
|
|
sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
|
|
|
|
-e '/^$$/ d' -e 's/$$/ :/' < $(1) >> $(2); \
|
|
|
|
rm -f $(1)
|
|
|
|
endef
|
2009-03-04 11:28:42 +08:00
|
|
|
|
|
|
|
define transform-d-to-p
|
2012-09-08 08:04:06 +08:00
|
|
|
$(call transform-d-to-p-args,$(@:%.o=%.d),$(@:%.o=%.P))
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
2016-01-25 17:59:43 +08: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 17:12:52 +08:00
|
|
|
# $(1): object files
|
|
|
|
define include-depfiles-for-objs
|
|
|
|
$(foreach obj, $(1), $(call include-depfile, $(obj:%.o=%.P), $(obj)))
|
|
|
|
endef
|
|
|
|
|
2016-01-20 12:07:08 +08: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 11:28:42 +08:00
|
|
|
###########################################################
|
|
|
|
## Commands for running lex
|
|
|
|
###########################################################
|
|
|
|
|
2016-01-12 08:28:45 +08:00
|
|
|
define transform-l-to-c-or-cpp
|
2009-03-04 11:28:42 +08:00
|
|
|
@echo "Lex: $(PRIVATE_MODULE) <= $<"
|
2015-07-17 08:14:27 +08:00
|
|
|
@mkdir -p $(dir $@)
|
2009-03-04 11:28:42 +08:00
|
|
|
$(hide) $(LEX) -o$@ $<
|
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Commands for running yacc
|
|
|
|
##
|
|
|
|
###########################################################
|
|
|
|
|
2016-01-12 08:28:45 +08:00
|
|
|
define transform-y-to-c-or-cpp
|
2009-03-04 11:28:42 +08:00
|
|
|
@echo "Yacc: $(PRIVATE_MODULE) <= $<"
|
2015-07-17 08:14:27 +08:00
|
|
|
@mkdir -p $(dir $@)
|
2016-01-12 08:28:45 +08:00
|
|
|
$(YACC) $(PRIVATE_YACCFLAGS) \
|
|
|
|
--defines=$(basename $@).h \
|
|
|
|
-o $@ $<
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
2010-07-16 08:17:52 +08:00
|
|
|
###########################################################
|
2012-10-30 07:06:00 +08:00
|
|
|
## Commands to compile RenderScript to Java
|
2010-07-16 08:17:52 +08:00
|
|
|
###########################################################
|
|
|
|
|
2016-02-01 16:59:01 +08: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
|
|
|
|
|
2010-07-16 08:17:52 +08: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
|
2011-05-26 08:16:22 +08:00
|
|
|
$(hide) $(PRIVATE_RS_CC) \
|
2010-07-31 09:37:29 +08:00
|
|
|
-o $(PRIVATE_RS_OUTPUT_DIR)/res/raw \
|
|
|
|
-p $(PRIVATE_RS_OUTPUT_DIR)/src \
|
2010-10-08 09:57:57 +08:00
|
|
|
-d $(PRIVATE_RS_OUTPUT_DIR) \
|
|
|
|
-a $@ -MD \
|
2011-08-11 04:53:05 +08:00
|
|
|
$(addprefix -target-api , $(PRIVATE_RS_TARGET_API)) \
|
2011-12-07 10:43:24 +08:00
|
|
|
$(PRIVATE_RS_FLAGS) \
|
2010-09-02 04:28:52 +08:00
|
|
|
$(foreach inc,$(PRIVATE_RS_INCLUDES),$(addprefix -I , $(inc))) \
|
2010-07-31 09:37:29 +08:00
|
|
|
$(PRIVATE_RS_SOURCE_FILES)
|
2016-02-01 16:59:01 +08:00
|
|
|
$(call _merge-renderscript-d,$(PRIVATE_DEP_FILES),$@.d)
|
|
|
|
$(call transform-d-to-p-args,$@.d,$@.P)
|
2010-07-16 08:17:52 +08:00
|
|
|
$(hide) mkdir -p $(dir $@)
|
|
|
|
$(hide) touch $@
|
|
|
|
endef
|
|
|
|
|
2012-11-29 08:52:41 +08:00
|
|
|
define transform-bc-to-so
|
2013-02-27 16:51:08 +08:00
|
|
|
@echo "Renderscript compatibility: $(notdir $@) <= $(notdir $<)"
|
2012-11-29 08:52:41 +08:00
|
|
|
$(hide) mkdir -p $(dir $@)
|
2012-12-18 06:23:14 +08:00
|
|
|
$(hide) $(BCC_COMPAT) -O3 -o $(dir $@)/$(notdir $(<:.bc=.o)) -fPIC -shared \
|
2014-09-03 10:09:35 +08:00
|
|
|
-rt-path $(RS_PREBUILT_CLCORE) -mtriple $(RS_COMPAT_TRIPLE) $<
|
2012-12-14 11:24:50 +08:00
|
|
|
$(hide) $(PRIVATE_CXX) -shared -Wl,-soname,$(notdir $@) -nostdlib \
|
2012-12-18 06:23:14 +08:00
|
|
|
-Wl,-rpath,\$$ORIGIN/../lib \
|
2013-01-19 08:27:23 +08:00
|
|
|
$(dir $@)/$(notdir $(<:.bc=.o)) \
|
2013-03-06 03:07:15 +08:00
|
|
|
$(RS_PREBUILT_COMPILER_RT) \
|
2014-11-16 06:25:33 +08:00
|
|
|
-o $@ $(TARGET_GLOBAL_LDFLAGS) -Wl,--hash-style=sysv -L prebuilts/gcc/ \
|
2015-03-06 03:29:30 +08:00
|
|
|
$(RS_PREBUILT_LIBPATH) -L $(TARGET_OUT_INTERMEDIATE_LIBRARIES) \
|
2013-03-28 07:51:38 +08:00
|
|
|
-lRSSupport -lm -lc
|
2012-11-29 08:52:41 +08:00
|
|
|
endef
|
|
|
|
|
2012-10-30 07:06:00 +08: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)/
|
|
|
|
$(hide) $(PRIVATE_RS_CC) \
|
|
|
|
-o $(PRIVATE_RS_OUTPUT_DIR)/ \
|
|
|
|
-d $(PRIVATE_RS_OUTPUT_DIR) \
|
|
|
|
-a $@ -MD \
|
|
|
|
-reflect-c++ \
|
2015-08-14 08:04:10 +08:00
|
|
|
$(addprefix -target-api , $(PRIVATE_RS_TARGET_API)) \
|
2012-10-30 07:06:00 +08:00
|
|
|
$(PRIVATE_RS_FLAGS) \
|
2014-05-29 07:17:09 +08:00
|
|
|
$(addprefix -I , $(PRIVATE_RS_INCLUDES)) \
|
2012-10-30 07:06:00 +08:00
|
|
|
$(PRIVATE_RS_SOURCE_FILES)
|
2016-01-25 17:59:43 +08:00
|
|
|
$(call _merge-renderscript-d,$(PRIVATE_DEP_FILES),$@.d)
|
|
|
|
$(call transform-d-to-p-args,$@.d,$@.P)
|
2012-10-30 07:06:00 +08:00
|
|
|
$(hide) mkdir -p $(dir $@)
|
|
|
|
$(hide) touch $@
|
|
|
|
endef
|
|
|
|
|
2009-03-04 11:28:42 +08: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 08:27:24 +08:00
|
|
|
define transform-aidl-to-cpp
|
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
@mkdir -p $(PRIVATE_HEADER_OUTPUT_DIR)
|
|
|
|
@echo "Generating C++ from AIDL: $(PRIVATE_MODULE) <= $<"
|
2016-01-20 01:26:10 +08:00
|
|
|
$(hide) $(AIDL_CPP) -d$(basename $@).aidl.P $(PRIVATE_AIDL_FLAGS) \
|
2015-10-15 08:27:24 +08:00
|
|
|
$< $(PRIVATE_HEADER_OUTPUT_DIR) $@
|
|
|
|
endef
|
|
|
|
|
2016-06-24 07:44:47 +08: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))))
|
|
|
|
$$(define-aidl-java-rule-src) : $(LOCAL_PATH)/$(1) $(AIDL)
|
|
|
|
$$(transform-aidl-to-java)
|
|
|
|
$(3) += $$(define-aidl-java-rule-src)
|
|
|
|
endef
|
|
|
|
|
2016-01-20 00:58:35 +08: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))))
|
|
|
|
$$(define-aidl-cpp-rule-src) : $(LOCAL_PATH)/$(1) $(AIDL_CPP)
|
|
|
|
$$(transform-aidl-to-cpp)
|
|
|
|
$(3) += $$(define-aidl-cpp-rule-src)
|
|
|
|
endef
|
2009-03-04 11:28:42 +08:00
|
|
|
|
2016-02-20 03:06:58 +08: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) <= $<"
|
|
|
|
$(hide) $(VTSC) -d$(basename $@).vts.P $(PRIVATE_VTS_FLAGS) \
|
|
|
|
$< $(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-12-01 06:28:59 +08:00
|
|
|
###########################################################
|
|
|
|
## Commands for running java-event-log-tags.py
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define transform-logtags-to-java
|
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
@echo "logtags: $@ <= $<"
|
2016-03-29 02:29:21 +08:00
|
|
|
$(hide) $(JAVATAGS) -o $@ $< $(PRIVATE_MERGED_TAG)
|
2009-12-01 06:28:59 +08:00
|
|
|
endef
|
|
|
|
|
2009-03-04 11:28:42 +08:00
|
|
|
|
2010-11-03 09:43:16 +08: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 18:44:53 +08:00
|
|
|
$(hide) for f in $(PRIVATE_PROTO_SRC_FILES); do \
|
|
|
|
$(PROTOC) \
|
2013-07-25 05:32:14 +08:00
|
|
|
$(addprefix --proto_path=, $(PRIVATE_PROTO_INCLUDES)) \
|
2013-07-26 03:28:19 +08:00
|
|
|
$(PRIVATE_PROTO_JAVA_OUTPUT_OPTION)="$(PRIVATE_PROTO_JAVA_OUTPUT_PARAMS):$(PRIVATE_PROTO_JAVA_OUTPUT_DIR)" \
|
2013-07-25 18:44:53 +08:00
|
|
|
$(PRIVATE_PROTOC_FLAGS) \
|
|
|
|
$$f || exit 33; \
|
|
|
|
done
|
2010-11-03 09:43:16 +08:00
|
|
|
$(hide) touch $@
|
|
|
|
endef
|
|
|
|
|
|
|
|
######################################################################
|
2015-04-08 02:59:34 +08:00
|
|
|
## Commands for running protoc to compile .proto into .pb.cc (or.pb.c) and .pb.h
|
2010-11-03 09:43:16 +08:00
|
|
|
######################################################################
|
|
|
|
define transform-proto-to-cc
|
|
|
|
@echo "Protoc: $@ <= $<"
|
2015-07-17 08:14:27 +08:00
|
|
|
@mkdir -p $(dir $@)
|
2010-11-03 09:43:16 +08:00
|
|
|
$(hide) $(PROTOC) \
|
|
|
|
$(addprefix --proto_path=, $(PRIVATE_PROTO_INCLUDES)) \
|
2010-11-06 02:30:58 +08:00
|
|
|
$(PRIVATE_PROTOC_FLAGS) \
|
2015-04-08 02:59:34 +08:00
|
|
|
$<
|
2016-05-06 11:02:08 +08:00
|
|
|
@# aprotoc outputs only .cc. Rename it to .cpp if necessary.
|
|
|
|
$(if $(PRIVATE_RENAME_CPP_EXT),\
|
|
|
|
$(hide) mv $(basename $@).cc $@)
|
2014-05-07 06:45:57 +08:00
|
|
|
endef
|
2010-11-03 09:43:16 +08:00
|
|
|
|
|
|
|
|
2015-07-30 08:14:24 +08:00
|
|
|
######################################################################
|
2015-08-21 00:08:17 +08:00
|
|
|
## Commands for generating DBus adaptors from .dbus-xml files.
|
2015-07-30 08:14:24 +08:00
|
|
|
######################################################################
|
2015-08-15 05:55:32 +08:00
|
|
|
define generate-dbus-adaptors
|
|
|
|
@echo "Generating DBus adaptors for $(PRIVATE_MODULE)"
|
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
$(hide) $(DBUS_GENERATOR) \
|
|
|
|
--service-config=$(PRIVATE_DBUS_SERVICE_CONFIG) \
|
|
|
|
--adaptor=$@ \
|
|
|
|
$<
|
|
|
|
endef
|
|
|
|
|
|
|
|
######################################################################
|
2015-08-21 00:08:17 +08:00
|
|
|
## Commands for generating DBus proxies from .dbus-xml files.
|
2015-08-15 05:55:32 +08:00
|
|
|
######################################################################
|
|
|
|
define generate-dbus-proxies
|
|
|
|
@echo "Generating DBus proxies for $(PRIVATE_MODULE)"
|
|
|
|
@mkdir -p $(dir $@)
|
2015-07-30 08:14:24 +08:00
|
|
|
$(hide) $(DBUS_GENERATOR) \
|
|
|
|
--service-config=$(PRIVATE_DBUS_SERVICE_CONFIG) \
|
2015-08-15 05:55:32 +08:00
|
|
|
--proxy=$@ \
|
2015-08-21 00:08:17 +08:00
|
|
|
$(filter %.dbus-xml,$^)
|
2015-07-30 08:14:24 +08:00
|
|
|
endef
|
|
|
|
|
2016-07-20 04:19:21 +08:00
|
|
|
###########################################################
|
|
|
|
## Helper to set include paths form transform-*-to-o
|
|
|
|
###########################################################
|
|
|
|
define c-includes
|
|
|
|
$(addprefix -I , $(PRIVATE_C_INCLUDES)) \
|
|
|
|
$$(cat $(PRIVATE_IMPORT_INCLUDES))\
|
|
|
|
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),,\
|
2016-07-21 03:22:57 +08:00
|
|
|
$(addprefix -I ,\
|
|
|
|
$(filter-out $(PRIVATE_C_INCLUDES), \
|
|
|
|
$(PRIVATE_GLOBAL_C_INCLUDES))) \
|
2016-07-20 04:19:21 +08:00
|
|
|
$(addprefix -isystem ,\
|
|
|
|
$(filter-out $(PRIVATE_C_INCLUDES), \
|
2016-07-21 03:22:57 +08:00
|
|
|
$(PRIVATE_GLOBAL_C_SYSTEM_INCLUDES))))
|
2016-07-20 04:19:21 +08:00
|
|
|
endef
|
2015-07-30 08:14:24 +08:00
|
|
|
|
2009-03-04 11:28:42 +08:00
|
|
|
###########################################################
|
|
|
|
## Commands for running gcc to compile a C++ file
|
|
|
|
###########################################################
|
|
|
|
|
2016-04-01 07:30:23 +08:00
|
|
|
define transform-cpp-to-o-compiler-args
|
2016-07-20 04:19:21 +08:00
|
|
|
$(c-includes) \
|
2009-03-04 11:28:42 +08:00
|
|
|
-c \
|
|
|
|
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
|
2010-07-14 05:55:47 +08:00
|
|
|
$(PRIVATE_TARGET_GLOBAL_CFLAGS) \
|
|
|
|
$(PRIVATE_TARGET_GLOBAL_CPPFLAGS) \
|
2009-03-04 11:28:42 +08:00
|
|
|
$(PRIVATE_ARM_CFLAGS) \
|
|
|
|
) \
|
2011-05-11 12:50:58 +08:00
|
|
|
$(PRIVATE_RTTI_FLAG) \
|
2009-03-04 11:28:42 +08:00
|
|
|
$(PRIVATE_CFLAGS) \
|
|
|
|
$(PRIVATE_CPPFLAGS) \
|
|
|
|
$(PRIVATE_DEBUG_CFLAGS) \
|
2015-06-11 07:33:43 +08:00
|
|
|
$(PRIVATE_CFLAGS_NO_OVERRIDE) \
|
2016-04-01 07:30:23 +08:00
|
|
|
$(PRIVATE_CPPFLAGS_NO_OVERRIDE)
|
|
|
|
endef
|
|
|
|
|
|
|
|
define clang-tidy-cpp
|
|
|
|
$(hide) $(PATH_TO_CLANG_TIDY) $(PRIVATE_TIDY_FLAGS) \
|
|
|
|
-checks=$(PRIVATE_TIDY_CHECKS) \
|
|
|
|
$< -- $(transform-cpp-to-o-compiler-args)
|
|
|
|
endef
|
|
|
|
|
|
|
|
ifneq (,$(filter 1 true,$(WITH_TIDY_ONLY)))
|
|
|
|
define transform-cpp-to-o
|
|
|
|
$(if $(PRIVATE_TIDY_CHECKS),
|
2016-06-25 02:13:34 +08:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) tidy $(PRIVATE_ARM_MODE) C++: $<"
|
2016-04-01 07:30:23 +08:00
|
|
|
$(clang-tidy-cpp))
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
2016-04-01 07:30:23 +08:00
|
|
|
else
|
|
|
|
define transform-cpp-to-o
|
2016-06-25 02:13:34 +08:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) $(PRIVATE_ARM_MODE) C++: $(PRIVATE_MODULE) <= $<"
|
2016-04-01 07:30:23 +08:00
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
$(if $(PRIVATE_TIDY_CHECKS),$(clang-tidy-cpp))
|
|
|
|
$(hide) $(RELATIVE_PWD) $(PRIVATE_CXX) \
|
|
|
|
$(transform-cpp-to-o-compiler-args) \
|
|
|
|
-MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
|
|
|
|
$(hide) $(transform-d-to-p)
|
|
|
|
endef
|
|
|
|
endif
|
2009-03-04 11:28:42 +08:00
|
|
|
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Commands for running gcc to compile a C file
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
# $(1): extra flags
|
2016-04-01 07:30:23 +08:00
|
|
|
define transform-c-or-s-to-o-compiler-args
|
2016-07-20 04:19:21 +08:00
|
|
|
$(c-includes) \
|
2009-03-04 11:28:42 +08:00
|
|
|
-c \
|
|
|
|
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
|
2010-07-14 05:55:47 +08:00
|
|
|
$(PRIVATE_TARGET_GLOBAL_CFLAGS) \
|
2014-11-26 16:53:46 +08:00
|
|
|
$(PRIVATE_TARGET_GLOBAL_CONLYFLAGS) \
|
2009-03-04 11:28:42 +08:00
|
|
|
$(PRIVATE_ARM_CFLAGS) \
|
|
|
|
) \
|
2016-04-01 07:30:23 +08:00
|
|
|
$(1)
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
2016-04-01 07:30:23 +08: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 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
2016-04-01 07:30:23 +08:00
|
|
|
define clang-tidy-c
|
|
|
|
$(hide) $(PATH_TO_CLANG_TIDY) $(PRIVATE_TIDY_FLAGS) \
|
|
|
|
-checks=$(PRIVATE_TIDY_CHECKS) \
|
|
|
|
$< -- $(transform-c-to-o-compiler-args)
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
2016-04-01 07:30:23 +08:00
|
|
|
ifneq (,$(filter 1 true,$(WITH_TIDY_ONLY)))
|
2009-03-04 11:28:42 +08:00
|
|
|
define transform-c-to-o
|
2016-04-01 07:30:23 +08:00
|
|
|
$(if $(PRIVATE_TIDY_CHECKS),
|
2016-06-25 02:13:34 +08:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) tidy $(PRIVATE_ARM_MODE) C: $<"
|
2016-04-01 07:30:23 +08:00
|
|
|
$(clang-tidy-c))
|
|
|
|
endef
|
|
|
|
else
|
|
|
|
define transform-c-to-o
|
2016-06-25 02:13:34 +08:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) $(PRIVATE_ARM_MODE) C: $(PRIVATE_MODULE) <= $<"
|
2016-04-01 07:30:23 +08:00
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
$(if $(PRIVATE_TIDY_CHECKS),$(clang-tidy-c))
|
|
|
|
$(hide) $(RELATIVE_PWD) $(PRIVATE_CC) \
|
|
|
|
$(transform-c-to-o-compiler-args) \
|
|
|
|
-MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
|
|
|
|
$(hide) $(transform-d-to-p)
|
|
|
|
endef
|
|
|
|
endif
|
|
|
|
|
|
|
|
define transform-s-to-o-no-deps
|
2016-06-25 02:13:34 +08:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) asm: $(PRIVATE_MODULE) <= $<"
|
2016-04-01 07:30:23 +08:00
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
$(RELATIVE_PWD) $(PRIVATE_CC) \
|
|
|
|
$(call transform-c-or-s-to-o-compiler-args, $(PRIVATE_ASFLAGS)) \
|
|
|
|
-MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
|
|
|
define transform-s-to-o
|
|
|
|
$(transform-s-to-o-no-deps)
|
2011-01-29 06:14:47 +08:00
|
|
|
$(transform-d-to-p)
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
2014-06-06 10:05:47 +08:00
|
|
|
# YASM compilation
|
|
|
|
define transform-asm-to-o
|
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
$(hide) $(YASM) \
|
|
|
|
$(addprefix -I , $(PRIVATE_C_INCLUDES)) \
|
2015-03-10 09:57:40 +08:00
|
|
|
$($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_YASM_FLAGS) \
|
2014-06-06 10:05:47 +08:00
|
|
|
$(PRIVATE_ASFLAGS) \
|
|
|
|
-o $@ $<
|
|
|
|
endef
|
|
|
|
|
2009-05-14 22:00:09 +08: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-no-deps
|
2016-06-25 02:13:34 +08:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) ObjC: $(PRIVATE_MODULE) <= $<"
|
2012-08-11 07:30:42 +08:00
|
|
|
$(call transform-c-or-s-to-o-no-deps, $(PRIVATE_CFLAGS) $(PRIVATE_DEBUG_CFLAGS))
|
2009-05-14 22:00:09 +08:00
|
|
|
endef
|
|
|
|
|
|
|
|
define transform-m-to-o
|
|
|
|
$(transform-m-to-o-no-deps)
|
2011-01-29 06:14:47 +08:00
|
|
|
$(transform-d-to-p)
|
2009-05-14 22:00:09 +08:00
|
|
|
endef
|
|
|
|
|
2009-03-04 11:28:42 +08:00
|
|
|
###########################################################
|
|
|
|
## Commands for running gcc to compile a host C++ file
|
|
|
|
###########################################################
|
|
|
|
|
2016-04-01 07:30:23 +08:00
|
|
|
define transform-host-cpp-to-o-compiler-args
|
2016-07-20 04:19:21 +08:00
|
|
|
$(c-includes) \
|
2009-03-04 11:28:42 +08:00
|
|
|
-c \
|
|
|
|
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
|
2013-12-10 19:07:41 +08:00
|
|
|
$(PRIVATE_HOST_GLOBAL_CFLAGS) \
|
|
|
|
$(PRIVATE_HOST_GLOBAL_CPPFLAGS) \
|
2009-03-04 11:28:42 +08:00
|
|
|
) \
|
|
|
|
$(PRIVATE_CFLAGS) \
|
|
|
|
$(PRIVATE_CPPFLAGS) \
|
|
|
|
$(PRIVATE_DEBUG_CFLAGS) \
|
2015-06-11 07:33:43 +08:00
|
|
|
$(PRIVATE_CFLAGS_NO_OVERRIDE) \
|
2016-04-01 07:30:23 +08:00
|
|
|
$(PRIVATE_CPPFLAGS_NO_OVERRIDE)
|
|
|
|
endef
|
|
|
|
|
|
|
|
define clang-tidy-host-cpp
|
|
|
|
$(hide) $(PATH_TO_CLANG_TIDY) $(PRIVATE_TIDY_FLAGS) \
|
|
|
|
-checks=$(PRIVATE_TIDY_CHECKS) \
|
|
|
|
$< -- $(transform-host-cpp-to-o-compiler-args)
|
|
|
|
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))
|
|
|
|
$(hide) $(RELATIVE_PWD) $(PRIVATE_CXX) \
|
|
|
|
$(transform-host-cpp-to-o-compiler-args) \
|
|
|
|
-MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
|
|
|
|
$(hide) $(transform-d-to-p)
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
2016-04-01 07:30:23 +08:00
|
|
|
endif
|
2009-03-04 11:28:42 +08:00
|
|
|
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Commands for running gcc to compile a host C file
|
|
|
|
###########################################################
|
|
|
|
|
2016-04-01 07:30:23 +08:00
|
|
|
define transform-host-c-or-s-to-o-common-args
|
2016-07-20 04:19:21 +08:00
|
|
|
$(c-includes) \
|
2009-03-04 11:28:42 +08:00
|
|
|
-c \
|
|
|
|
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
|
2013-12-10 19:07:41 +08:00
|
|
|
$(PRIVATE_HOST_GLOBAL_CFLAGS) \
|
2014-11-26 16:53:46 +08:00
|
|
|
$(PRIVATE_HOST_GLOBAL_CONLYFLAGS) \
|
2016-04-01 07:30:23 +08:00
|
|
|
)
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
2016-04-01 07:30:23 +08:00
|
|
|
# $(1): extra flags
|
|
|
|
define transform-host-c-or-s-to-o-no-deps
|
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
$(hide) $(RELATIVE_PWD) $(PRIVATE_CC) \
|
|
|
|
$(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
|
|
|
|
$(hide) $(PATH_TO_CLANG_TIDY) $(PRIVATE_TIDY_FLAGS) \
|
|
|
|
-checks=$(PRIVATE_TIDY_CHECKS) \
|
|
|
|
$< -- $(transform-host-c-to-o-compiler-args)
|
|
|
|
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-15 03:59:50 +08:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) C: $(PRIVATE_MODULE) <= $<"
|
2016-04-01 07:30:23 +08:00
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
$(if $(PRIVATE_TIDY_CHECKS), $(clang-tidy-host-c))
|
|
|
|
$(hide) $(RELATIVE_PWD) $(PRIVATE_CC) \
|
|
|
|
$(transform-host-c-to-o-compiler-args) \
|
|
|
|
-MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
|
|
|
|
$(hide) $(transform-d-to-p)
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
2016-04-01 07:30:23 +08:00
|
|
|
endif
|
2009-03-04 11:28:42 +08:00
|
|
|
|
|
|
|
define transform-host-s-to-o-no-deps
|
2015-08-15 03:59:50 +08:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) asm: $(PRIVATE_MODULE) <= $<"
|
2009-03-04 11:28:42 +08:00
|
|
|
$(call transform-host-c-or-s-to-o-no-deps, $(PRIVATE_ASFLAGS))
|
|
|
|
endef
|
|
|
|
|
|
|
|
define transform-host-s-to-o
|
|
|
|
$(transform-host-s-to-o-no-deps)
|
|
|
|
$(transform-d-to-p)
|
2009-05-14 22:00:09 +08:00
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Commands for running gcc to compile a host Objective-C file
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define transform-host-m-to-o-no-deps
|
2015-08-15 03:59:50 +08:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) ObjC: $(PRIVATE_MODULE) <= $<"
|
2016-03-04 09:37:50 +08:00
|
|
|
$(call transform-host-c-or-s-to-o-no-deps, $(PRIVATE_CFLAGS) $(PRIVATE_DEBUG_CFLAGS) $(PRIVATE_CFLAGS_NO_OVERRIDE))
|
2009-05-14 22:00:09 +08:00
|
|
|
endef
|
|
|
|
|
2011-02-11 23:19:31 +08:00
|
|
|
define transform-host-m-to-o
|
2009-05-14 22:00:09 +08:00
|
|
|
$(transform-host-m-to-o-no-deps)
|
|
|
|
$(transform-d-to-p)
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
2015-09-18 06:40:49 +08: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 09:03:11 +08: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.
|
|
|
|
define compile-dotdot-cpp-file
|
|
|
|
o := $(intermediates)/$(patsubst %$(LOCAL_CPP_EXTENSION),%.o,$(subst ../,$(DOTDOT_REPLACEMENT),$(1)))
|
|
|
|
$$(o) : $(TOPDIR)$(LOCAL_PATH)/$(1) $(2)
|
|
|
|
$$(transform-$$(PRIVATE_HOST)cpp-to-o)
|
2016-03-16 05:40:04 +08:00
|
|
|
$$(call include-depfiles-for-objs, $$(o))
|
2015-03-11 09:03:11 +08: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.
|
|
|
|
define compile-dotdot-c-file
|
|
|
|
o := $(intermediates)/$(patsubst %.c,%.o,$(subst ../,$(DOTDOT_REPLACEMENT),$(1)))
|
|
|
|
$$(o) : $(TOPDIR)$(LOCAL_PATH)/$(1) $(2)
|
|
|
|
$$(transform-$$(PRIVATE_HOST)c-to-o)
|
2016-03-16 05:40:04 +08:00
|
|
|
$$(call include-depfiles-for-objs, $$(o))
|
2015-03-11 09:03:11 +08: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.
|
|
|
|
define compile-dotdot-s-file
|
|
|
|
o := $(intermediates)/$(patsubst %.S,%.o,$(subst ../,$(DOTDOT_REPLACEMENT),$(1)))
|
|
|
|
$$(o) : $(TOPDIR)$(LOCAL_PATH)/$(1) $(2)
|
|
|
|
$$(transform-$$(PRIVATE_HOST)s-to-o)
|
2016-03-16 05:40:04 +08:00
|
|
|
$$(call include-depfiles-for-objs, $$(o))
|
2015-03-11 09:03:11 +08: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.
|
|
|
|
define compile-dotdot-s-file-no-deps
|
|
|
|
o := $(intermediates)/$(patsubst %.s,%.o,$(subst ../,$(DOTDOT_REPLACEMENT),$(1)))
|
|
|
|
$$(o) : $(TOPDIR)$(LOCAL_PATH)/$(1) $(2)
|
|
|
|
$$(transform-$$(PRIVATE_HOST)s-to-o-no-deps)
|
|
|
|
$(3) += $$(o)
|
|
|
|
endef
|
|
|
|
|
2009-03-04 11:28:42 +08:00
|
|
|
###########################################################
|
|
|
|
## Commands for running ar
|
|
|
|
###########################################################
|
|
|
|
|
2010-05-28 02:55:39 +08: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 23:03:52 +08:00
|
|
|
# Call the command at least once even if there are no arguments, as otherwise
|
|
|
|
# the output file won't be created.
|
2010-05-28 02:55:39 +08:00
|
|
|
#
|
|
|
|
# $(1): the command without arguments
|
|
|
|
# $(2): the arguments
|
|
|
|
define split-long-arguments
|
2012-06-15 23:03:52 +08:00
|
|
|
$(hide) $(1) $(wordlist 1,500,$(2))
|
2010-05-28 02:55:39 +08: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 10:48:00 +08:00
|
|
|
# $(1): the full path of the source static library.
|
|
|
|
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 09:14:03 +08:00
|
|
|
cp $(1) $$ldir; \
|
|
|
|
lib_to_include=$$ldir/$(notdir $(1)); \
|
2011-01-28 10:48:00 +08:00
|
|
|
filelist=; \
|
2015-01-08 09:14:03 +08:00
|
|
|
subdir=0; \
|
2014-04-18 01:03:35 +08:00
|
|
|
for f in `$($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) t $(1)`; do \
|
2015-01-08 09:14:03 +08: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 10:48:00 +08:00
|
|
|
done ; \
|
2014-01-16 08:02:16 +08:00
|
|
|
$($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_ARFLAGS) \
|
|
|
|
$(PRIVATE_ARFLAGS) $@ $$filelist
|
2011-01-28 10:48:00 +08:00
|
|
|
|
|
|
|
endef
|
|
|
|
|
2014-05-24 03:26:51 +08:00
|
|
|
# $(1): the full path of the source static library.
|
|
|
|
define extract-and-include-whole-static-libs-first
|
|
|
|
$(if $(strip $(1)),
|
|
|
|
$(hide) cp $(1) $@)
|
|
|
|
endef
|
|
|
|
|
2009-10-22 02:12:56 +08:00
|
|
|
define extract-and-include-target-whole-static-libs
|
2014-05-24 03:26:51 +08:00
|
|
|
$(call extract-and-include-whole-static-libs-first, $(firstword $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)))
|
|
|
|
$(foreach lib,$(wordlist 2,999,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)), \
|
2011-01-28 10:48:00 +08:00
|
|
|
$(call _extract-and-include-single-target-whole-static-lib, $(lib)))
|
2009-05-28 10:41:07 +08:00
|
|
|
endef
|
|
|
|
|
2009-03-04 11:28:42 +08: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-25 02:13:34 +08:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) StaticLib: $(PRIVATE_MODULE) ($@)"
|
2009-03-04 11:28:42 +08:00
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
@rm -f $@
|
2009-10-22 02:12:56 +08:00
|
|
|
$(extract-and-include-target-whole-static-libs)
|
2014-04-18 01:03:35 +08:00
|
|
|
$(call split-long-arguments,$($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) \
|
|
|
|
$($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_ARFLAGS) \
|
2015-04-03 09:02:33 +08:00
|
|
|
$(PRIVATE_ARFLAGS) $@,$(PRIVATE_ALL_OBJECTS))
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
2016-08-02 08:41:49 +08:00
|
|
|
# $(1): the full path of the source static library.
|
|
|
|
define _extract-and-include-single-aux-whole-static-lib
|
|
|
|
$(hide) ldir=$(PRIVATE_INTERMEDIATES_DIR)/WHOLE/$(basename $(notdir $(1)))_objs;\
|
|
|
|
rm -rf $$ldir; \
|
|
|
|
mkdir -p $$ldir; \
|
|
|
|
cp $(1) $$ldir; \
|
|
|
|
lib_to_include=$$ldir/$(notdir $(1)); \
|
|
|
|
filelist=; \
|
|
|
|
subdir=0; \
|
|
|
|
for f in `$(PRIVATE_AR) t $(1)`; do \
|
|
|
|
if [ -e $$ldir/$$f ]; then \
|
|
|
|
mkdir $$ldir/$$subdir; \
|
|
|
|
ext=$$subdir/; \
|
|
|
|
subdir=$$((subdir+1)); \
|
|
|
|
$(PRIVATE_AR) m $$lib_to_include $$f; \
|
|
|
|
else \
|
|
|
|
ext=; \
|
|
|
|
fi; \
|
|
|
|
$(PRIVATE_AR) p $$lib_to_include $$f > $$ldir/$$ext$$f; \
|
|
|
|
filelist="$$filelist $$ldir/$$ext$$f"; \
|
|
|
|
done ; \
|
|
|
|
$(PRIVATE_AR) $(AUX_GLOBAL_ARFLAGS) \
|
|
|
|
$(PRIVATE_ARFLAGS) $@ $$filelist
|
|
|
|
|
|
|
|
endef
|
|
|
|
|
|
|
|
define extract-and-include-aux-whole-static-libs
|
|
|
|
$(call extract-and-include-whole-static-libs-first, $(firstword $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)))
|
|
|
|
$(foreach lib,$(wordlist 2,999,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)), \
|
|
|
|
$(call _extract-and-include-single-aux-whole-static-lib, $(lib)))
|
|
|
|
endef
|
|
|
|
|
|
|
|
# Explicitly delete the archive first so that ar doesn't
|
|
|
|
# try to add to an existing archive.
|
|
|
|
define transform-o-to-aux-static-lib
|
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) StaticLib: $(PRIVATE_MODULE) ($@)"
|
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
@rm -f $@
|
|
|
|
$(extract-and-include-aux-whole-static-libs)
|
|
|
|
$(call split-long-arguments,$(PRIVATE_AR) \
|
|
|
|
$(AUX_GLOBAL_ARFLAGS) \
|
|
|
|
$(PRIVATE_ARFLAGS) $@,$(PRIVATE_ALL_OBJECTS))
|
|
|
|
endef
|
|
|
|
|
|
|
|
define transform-o-to-aux-executable-inner
|
|
|
|
$(hide) $(PRIVATE_CXX) -pie \
|
|
|
|
-Bdynamic \
|
|
|
|
-Wl,--gc-sections \
|
|
|
|
$(PRIVATE_ALL_OBJECTS) \
|
|
|
|
-Wl,--whole-archive \
|
2016-09-10 01:09:47 +08:00
|
|
|
$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES) \
|
2016-08-02 08:41:49 +08:00
|
|
|
-Wl,--no-whole-archive \
|
2016-09-10 01:09:47 +08:00
|
|
|
$(PRIVATE_ALL_STATIC_LIBRARIES) \
|
2016-08-02 08:41:49 +08:00
|
|
|
$(PRIVATE_LDFLAGS) \
|
|
|
|
-o $@
|
|
|
|
endef
|
|
|
|
|
|
|
|
define transform-o-to-aux-executable
|
|
|
|
@echo "$(AUX_DISPLAY) Executable: $(PRIVATE_MODULE) ($@)"
|
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
$(transform-o-to-aux-executable-inner)
|
|
|
|
endef
|
|
|
|
|
|
|
|
define transform-o-to-aux-static-executable-inner
|
|
|
|
$(hide) $(PRIVATE_CXX) \
|
|
|
|
-Bstatic \
|
|
|
|
-Wl,--gc-sections \
|
|
|
|
$(PRIVATE_ALL_OBJECTS) \
|
|
|
|
-Wl,--whole-archive \
|
2016-09-10 01:09:47 +08:00
|
|
|
$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES) \
|
2016-08-02 08:41:49 +08:00
|
|
|
-Wl,--no-whole-archive \
|
2016-09-10 01:09:47 +08:00
|
|
|
$(PRIVATE_ALL_STATIC_LIBRARIES) \
|
2016-08-02 08:41:49 +08:00
|
|
|
$(PRIVATE_LDFLAGS) \
|
|
|
|
-Wl,-Map=$(@).map \
|
|
|
|
-o $@
|
|
|
|
endef
|
|
|
|
|
|
|
|
define transform-o-to-aux-static-executable
|
|
|
|
@echo "$(AUX_DISPLAY) StaticExecutable: $(PRIVATE_MODULE) ($@)"
|
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
$(transform-o-to-aux-static-executable-inner)
|
|
|
|
endef
|
|
|
|
|
2009-03-04 11:28:42 +08:00
|
|
|
###########################################################
|
|
|
|
## Commands for running host ar
|
|
|
|
###########################################################
|
|
|
|
|
2011-01-28 10:48:00 +08:00
|
|
|
# $(1): the full path of the source static library.
|
|
|
|
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 09:14:03 +08:00
|
|
|
cp $(1) $$ldir; \
|
|
|
|
lib_to_include=$$ldir/$(notdir $(1)); \
|
2011-01-28 10:48:00 +08:00
|
|
|
filelist=; \
|
2015-01-08 09:14:03 +08:00
|
|
|
subdir=0; \
|
2015-08-15 03:59:50 +08:00
|
|
|
for f in `$($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)AR) t $(1) | \grep '\.o$$'`; do \
|
2015-01-08 09:14:03 +08:00
|
|
|
if [ -e $$ldir/$$f ]; then \
|
|
|
|
mkdir $$ldir/$$subdir; \
|
|
|
|
ext=$$subdir/; \
|
|
|
|
subdir=$$((subdir+1)); \
|
2015-08-15 03:59:50 +08:00
|
|
|
$($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)AR) m $$lib_to_include $$f; \
|
2015-01-08 09:14:03 +08:00
|
|
|
else \
|
|
|
|
ext=; \
|
|
|
|
fi; \
|
2015-08-15 03:59:50 +08:00
|
|
|
$($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)AR) p $$lib_to_include $$f > $$ldir/$$ext$$f; \
|
2015-01-08 09:14:03 +08:00
|
|
|
filelist="$$filelist $$ldir/$$ext$$f"; \
|
2011-01-28 10:48:00 +08:00
|
|
|
done ; \
|
2015-08-15 03:59:50 +08:00
|
|
|
$($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)AR) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)GLOBAL_ARFLAGS) \
|
2014-04-18 01:03:35 +08:00
|
|
|
$(PRIVATE_ARFLAGS) $@ $$filelist
|
2011-01-28 10:48:00 +08:00
|
|
|
|
|
|
|
endef
|
|
|
|
|
2009-10-22 02:12:56 +08:00
|
|
|
define extract-and-include-host-whole-static-libs
|
2014-05-24 03:26:51 +08:00
|
|
|
$(call extract-and-include-whole-static-libs-first, $(firstword $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)))
|
|
|
|
$(foreach lib,$(wordlist 2,999,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)), \
|
2011-01-28 10:48:00 +08:00
|
|
|
$(call _extract-and-include-single-host-whole-static-lib, $(lib)))
|
2009-10-22 02:12:56 +08:00
|
|
|
endef
|
|
|
|
|
2016-03-23 09:23:13 +08: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
|
|
|
|
$(if $(PRIVATE_ALL_OBJECTS),,$(hide) touch $(dir $@)dummy.o)
|
|
|
|
endef
|
|
|
|
|
|
|
|
define get-dummy.o-if-no-objs
|
|
|
|
$(if $(PRIVATE_ALL_OBJECTS),,$(dir $@)dummy.o)
|
|
|
|
endef
|
|
|
|
|
|
|
|
define delete-dummy.o-if-no-objs
|
|
|
|
$(if $(PRIVATE_ALL_OBJECTS),,$(hide) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)AR) d $@ $(dir $@)dummy.o \
|
|
|
|
&& rm -f $(dir $@)dummy.o)
|
|
|
|
endef
|
|
|
|
endif # HOST_OS is darwin
|
|
|
|
|
2009-03-04 11:28:42 +08: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-15 03:59:50 +08:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) StaticLib: $(PRIVATE_MODULE) ($@)"
|
2009-03-04 11:28:42 +08:00
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
@rm -f $@
|
2009-10-22 02:12:56 +08:00
|
|
|
$(extract-and-include-host-whole-static-libs)
|
2016-03-23 09:23:13 +08:00
|
|
|
$(create-dummy.o-if-no-objs)
|
2015-08-15 03:59:50 +08:00
|
|
|
$(call split-long-arguments,$($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)AR) \
|
|
|
|
$($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)GLOBAL_ARFLAGS) \
|
2016-03-23 09:23:13 +08:00
|
|
|
$(PRIVATE_ARFLAGS) $@,$(PRIVATE_ALL_OBJECTS) $(get-dummy.o-if-no-objs))
|
|
|
|
$(delete-dummy.o-if-no-objs)
|
2009-03-04 11:28:42 +08: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
|
2011-01-29 06:14:47 +08:00
|
|
|
$(hide) $(PRIVATE_CXX) \
|
2015-08-15 03:59:50 +08:00
|
|
|
-Wl,-rpath-link=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)OUT_INTERMEDIATE_LIBRARIES) \
|
|
|
|
-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)) \
|
2009-03-04 11:28:42 +08:00
|
|
|
-shared -Wl,-soname,$(notdir $@) \
|
|
|
|
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
|
2013-12-10 19:07:41 +08:00
|
|
|
$(PRIVATE_HOST_GLOBAL_LDFLAGS) \
|
2009-03-04 11:28:42 +08:00
|
|
|
) \
|
2014-02-12 22:24:41 +08:00
|
|
|
$(PRIVATE_LDFLAGS) \
|
2009-03-04 11:28:42 +08:00
|
|
|
$(PRIVATE_ALL_OBJECTS) \
|
|
|
|
-Wl,--whole-archive \
|
2016-09-10 01:09:47 +08:00
|
|
|
$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES) \
|
2009-03-04 11:28:42 +08:00
|
|
|
-Wl,--no-whole-archive \
|
2011-04-26 05:22:41 +08:00
|
|
|
$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
|
2016-09-10 01:09:47 +08:00
|
|
|
$(PRIVATE_ALL_STATIC_LIBRARIES) \
|
2011-04-26 05:22:41 +08:00
|
|
|
$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
|
2015-01-24 08:12:57 +08:00
|
|
|
$(if $(filter true,$(NATIVE_COVERAGE)),-lgcov) \
|
2015-01-26 08:20:57 +08:00
|
|
|
$(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_HOST_LIBPROFILE_RT)) \
|
2016-09-10 01:09:47 +08:00
|
|
|
$(PRIVATE_ALL_SHARED_LIBRARIES) \
|
2009-03-04 11:28:42 +08:00
|
|
|
-o $@ \
|
|
|
|
$(PRIVATE_LDLIBS)
|
|
|
|
endef
|
|
|
|
endif
|
|
|
|
|
|
|
|
define transform-host-o-to-shared-lib
|
2015-08-15 03:59:50 +08:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) SharedLib: $(PRIVATE_MODULE) ($@)"
|
2015-07-17 08:14:27 +08:00
|
|
|
@mkdir -p $(dir $@)
|
2011-01-29 06:14:47 +08:00
|
|
|
$(transform-host-o-to-shared-lib-inner)
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
|
|
|
define transform-host-o-to-package
|
2015-08-15 03:59:50 +08:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) Package: $(PRIVATE_MODULE) ($@)"
|
2015-07-17 08:14:27 +08:00
|
|
|
@mkdir -p $(dir $@)
|
2011-01-29 06:14:47 +08:00
|
|
|
$(transform-host-o-to-shared-lib-inner)
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Commands for running gcc to link a shared library or package
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define transform-o-to-shared-lib-inner
|
2011-01-29 06:14:47 +08:00
|
|
|
$(hide) $(PRIVATE_CXX) \
|
2014-11-14 02:15:46 +08:00
|
|
|
-nostdlib -Wl,-soname,$(notdir $@) \
|
|
|
|
-Wl,--gc-sections \
|
2015-01-25 21:15:12 +08:00
|
|
|
$(if $(filter true,$(PRIVATE_CLANG)),-shared,-Wl$(comma)-shared) \
|
2010-07-14 05:55:47 +08:00
|
|
|
$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
|
2015-07-03 06:57:45 +08:00
|
|
|
$(PRIVATE_TARGET_CRTBEGIN_SO_O) \
|
2009-03-04 11:28:42 +08:00
|
|
|
$(PRIVATE_ALL_OBJECTS) \
|
|
|
|
-Wl,--whole-archive \
|
2016-09-10 01:09:47 +08:00
|
|
|
$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES) \
|
2009-03-04 11:28:42 +08:00
|
|
|
-Wl,--no-whole-archive \
|
2011-04-26 05:22:41 +08:00
|
|
|
$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
|
2016-09-10 01:09:47 +08:00
|
|
|
$(PRIVATE_ALL_STATIC_LIBRARIES) \
|
2011-04-26 05:22:41 +08:00
|
|
|
$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
|
2015-10-09 05:16:39 +08:00
|
|
|
$(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_COVERAGE_LIB)) \
|
2015-04-01 06:21:30 +08:00
|
|
|
$(PRIVATE_TARGET_LIBATOMIC) \
|
|
|
|
$(PRIVATE_TARGET_LIBGCC) \
|
2014-11-14 02:15:46 +08:00
|
|
|
$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
|
|
|
|
$(PRIVATE_LDFLAGS) \
|
2016-07-27 02:54:47 +08:00
|
|
|
$(PRIVATE_ALL_SHARED_LIBRARIES) \
|
2016-03-10 06:54:55 +08:00
|
|
|
-o $@ \
|
2015-07-03 06:57:45 +08:00
|
|
|
$(PRIVATE_TARGET_CRTEND_SO_O) \
|
2009-03-04 11:28:42 +08:00
|
|
|
$(PRIVATE_LDLIBS)
|
|
|
|
endef
|
|
|
|
|
|
|
|
define transform-o-to-shared-lib
|
2016-06-25 02:13:34 +08:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) SharedLib: $(PRIVATE_MODULE) ($@)"
|
2015-07-17 08:14:27 +08:00
|
|
|
@mkdir -p $(dir $@)
|
2014-11-14 02:15:46 +08:00
|
|
|
$(transform-o-to-shared-lib-inner)
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Commands for filtering a target executable or library
|
|
|
|
###########################################################
|
|
|
|
|
2014-03-29 08:24:39 +08:00
|
|
|
ifneq ($(TARGET_BUILD_VARIANT),user)
|
|
|
|
TARGET_STRIP_EXTRA = && $(PRIVATE_OBJCOPY) --add-gnu-debuglink=$< $@
|
|
|
|
TARGET_STRIP_KEEP_SYMBOLS_EXTRA = --add-gnu-debuglink=$<
|
|
|
|
endif
|
|
|
|
|
2009-03-04 11:28:42 +08:00
|
|
|
define transform-to-stripped
|
2016-06-25 02:13:34 +08:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) Strip: $(PRIVATE_MODULE) ($@)"
|
2015-07-17 08:14:27 +08:00
|
|
|
@mkdir -p $(dir $@)
|
2014-08-21 08:12:32 +08:00
|
|
|
$(hide) $(PRIVATE_STRIP) --strip-all $< -o $@ \
|
|
|
|
$(if $(PRIVATE_NO_DEBUGLINK),,$(TARGET_STRIP_EXTRA))
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
2016-03-30 03:22:20 +08:00
|
|
|
define transform-to-stripped-keep-mini-debug-info
|
2016-06-25 02:13:34 +08:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) Strip (mini debug info): $(PRIVATE_MODULE) ($@)"
|
2016-03-30 03:22:20 +08:00
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
$(hide) $(PRIVATE_NM) -D $< --format=posix --defined-only | awk '{ print $$1 }' | sort >$@.dynsyms
|
|
|
|
$(hide) $(PRIVATE_NM) $< --format=posix --defined-only | awk '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D") print $$1 }' | sort >$@.funcsyms
|
|
|
|
$(hide) comm -13 $@.dynsyms $@.funcsyms >$@.keep_symbols
|
|
|
|
$(hide) $(PRIVATE_OBJCOPY) --only-keep-debug $< $@.debug
|
|
|
|
$(hide) $(PRIVATE_OBJCOPY) --rename-section .debug_frame=saved_debug_frame $@.debug $@.mini_debuginfo
|
|
|
|
$(hide) $(PRIVATE_OBJCOPY) -S --remove-section .gdb_index --remove-section .comment --keep-symbols=$@.keep_symbols $@.mini_debuginfo
|
|
|
|
$(hide) $(PRIVATE_OBJCOPY) --rename-section saved_debug_frame=.debug_frame $@.mini_debuginfo
|
|
|
|
$(hide) $(PRIVATE_STRIP) --strip-all -R .comment $< -o $@
|
|
|
|
$(hide) rm -f $@.mini_debuginfo.xz
|
|
|
|
$(hide) xz $@.mini_debuginfo
|
|
|
|
$(hide) $(PRIVATE_OBJCOPY) --add-section .gnu_debugdata=$@.mini_debuginfo.xz $@
|
|
|
|
$(hide) rm -f $@.dynsyms $@.funcsyms $@.keep_symbols $@.debug $@.mini_debuginfo.xz
|
|
|
|
endef
|
|
|
|
|
2014-03-19 05:50:09 +08:00
|
|
|
define transform-to-stripped-keep-symbols
|
2016-06-25 02:13:34 +08:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) Strip (keep symbols): $(PRIVATE_MODULE) ($@)"
|
2015-07-17 08:14:27 +08:00
|
|
|
@mkdir -p $(dir $@)
|
2014-03-29 08:24:39 +08:00
|
|
|
$(hide) $(PRIVATE_OBJCOPY) \
|
|
|
|
`$(PRIVATE_READELF) -S $< | awk '/.debug_/ {print "-R " $$2}' | xargs` \
|
|
|
|
$(TARGET_STRIP_KEEP_SYMBOLS_EXTRA) $< $@
|
2014-03-19 05:50:09 +08:00
|
|
|
endef
|
|
|
|
|
2015-04-21 07:59:05 +08:00
|
|
|
###########################################################
|
|
|
|
## Commands for packing a target executable or library
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define pack-elf-relocations
|
2016-06-25 02:13:34 +08:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) Pack Relocations: $(PRIVATE_MODULE) ($@)"
|
2015-07-17 08:14:27 +08:00
|
|
|
$(copy-file-to-target)
|
2015-04-21 07:59:05 +08:00
|
|
|
$(hide) $(RELOCATION_PACKER) $@
|
|
|
|
endef
|
2009-03-04 11:28:42 +08:00
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Commands for running gcc to link an executable
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define transform-o-to-executable-inner
|
2014-11-14 02:15:46 +08:00
|
|
|
$(hide) $(PRIVATE_CXX) -pie \
|
|
|
|
-nostdlib -Bdynamic \
|
2015-07-11 09:06:51 +08:00
|
|
|
-Wl,-dynamic-linker,$(PRIVATE_LINKER) \
|
2014-11-14 02:15:46 +08:00
|
|
|
-Wl,--gc-sections \
|
|
|
|
-Wl,-z,nocopyreloc \
|
2012-09-26 08:52:10 +08:00
|
|
|
$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
|
2014-02-22 08:17:05 +08:00
|
|
|
-Wl,-rpath-link=$(PRIVATE_TARGET_OUT_INTERMEDIATE_LIBRARIES) \
|
2015-07-03 06:57:45 +08:00
|
|
|
$(PRIVATE_TARGET_CRTBEGIN_DYNAMIC_O) \
|
2009-03-04 11:28:42 +08:00
|
|
|
$(PRIVATE_ALL_OBJECTS) \
|
|
|
|
-Wl,--whole-archive \
|
2016-09-10 01:09:47 +08:00
|
|
|
$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES) \
|
2009-03-04 11:28:42 +08:00
|
|
|
-Wl,--no-whole-archive \
|
2011-04-26 05:22:41 +08:00
|
|
|
$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
|
2016-09-10 01:09:47 +08:00
|
|
|
$(PRIVATE_ALL_STATIC_LIBRARIES) \
|
2011-04-26 05:22:41 +08:00
|
|
|
$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
|
2015-10-09 05:16:39 +08:00
|
|
|
$(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_COVERAGE_LIB)) \
|
2015-04-01 06:21:30 +08:00
|
|
|
$(PRIVATE_TARGET_LIBATOMIC) \
|
|
|
|
$(PRIVATE_TARGET_LIBGCC) \
|
2014-11-14 02:15:46 +08:00
|
|
|
$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
|
|
|
|
$(PRIVATE_LDFLAGS) \
|
2016-07-27 02:54:47 +08:00
|
|
|
$(PRIVATE_ALL_SHARED_LIBRARIES) \
|
2016-03-10 06:54:55 +08:00
|
|
|
-o $@ \
|
2015-07-03 06:57:45 +08:00
|
|
|
$(PRIVATE_TARGET_CRTEND_O) \
|
2009-03-04 11:28:42 +08:00
|
|
|
$(PRIVATE_LDLIBS)
|
|
|
|
endef
|
|
|
|
|
|
|
|
define transform-o-to-executable
|
2016-06-25 02:13:34 +08:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) Executable: $(PRIVATE_MODULE) ($@)"
|
2015-07-17 08:14:27 +08:00
|
|
|
@mkdir -p $(dir $@)
|
2014-11-14 02:15:46 +08:00
|
|
|
$(transform-o-to-executable-inner)
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
|
|
|
|
|
|
|
###########################################################
|
2014-11-14 02:15:46 +08: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-21 03:00:20 +08: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 11:28:42 +08:00
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define transform-o-to-static-executable-inner
|
2014-11-14 02:15:46 +08:00
|
|
|
$(hide) $(PRIVATE_CXX) \
|
|
|
|
-nostdlib -Bstatic \
|
2015-01-21 03:00:20 +08:00
|
|
|
$(if $(filter $(PRIVATE_LDFLAGS),-shared),,-static) \
|
2014-11-14 02:15:46 +08:00
|
|
|
-Wl,--gc-sections \
|
|
|
|
-o $@ \
|
|
|
|
$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
|
2015-07-03 06:57:45 +08:00
|
|
|
$(PRIVATE_TARGET_CRTBEGIN_STATIC_O) \
|
2014-11-14 02:15:46 +08:00
|
|
|
$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
|
|
|
|
$(PRIVATE_LDFLAGS) \
|
|
|
|
$(PRIVATE_ALL_OBJECTS) \
|
|
|
|
-Wl,--whole-archive \
|
2016-09-10 01:09:47 +08:00
|
|
|
$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES) \
|
2014-11-14 02:15:46 +08:00
|
|
|
-Wl,--no-whole-archive \
|
2016-09-10 01:09:47 +08:00
|
|
|
$(filter-out %libcompiler_rt.a,$(filter-out %libc_nomalloc.a,$(filter-out %libc.a,$(PRIVATE_ALL_STATIC_LIBRARIES)))) \
|
2014-11-14 02:15:46 +08:00
|
|
|
-Wl,--start-group \
|
2016-09-10 01:09:47 +08:00
|
|
|
$(filter %libc.a,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
|
|
|
|
$(filter %libc_nomalloc.a,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
|
2015-10-09 05:16:39 +08:00
|
|
|
$(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_COVERAGE_LIB)) \
|
2015-01-26 08:20:57 +08:00
|
|
|
$(PRIVATE_TARGET_LIBATOMIC) \
|
2016-09-10 01:09:47 +08:00
|
|
|
$(filter %libcompiler_rt.a,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
|
2014-11-14 13:24:04 +08:00
|
|
|
$(PRIVATE_TARGET_LIBGCC) \
|
2014-11-14 02:15:46 +08:00
|
|
|
-Wl,--end-group \
|
2015-07-03 06:57:45 +08:00
|
|
|
$(PRIVATE_TARGET_CRTEND_O)
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
|
|
|
define transform-o-to-static-executable
|
2016-06-25 02:13:34 +08:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) StaticExecutable: $(PRIVATE_MODULE) ($@)"
|
2015-07-17 08:14:27 +08:00
|
|
|
@mkdir -p $(dir $@)
|
2014-11-14 02:15:46 +08:00
|
|
|
$(transform-o-to-static-executable-inner)
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Commands for running gcc to link a host executable
|
|
|
|
###########################################################
|
2014-04-05 05:37:33 +08:00
|
|
|
ifdef BUILD_HOST_static
|
|
|
|
HOST_FPIE_FLAGS :=
|
|
|
|
else
|
2014-08-07 03:36:46 +08:00
|
|
|
HOST_FPIE_FLAGS := -pie
|
2014-10-02 15:51:11 +08:00
|
|
|
# Force the correct entry point to workaround a bug in binutils that manifests with -pie
|
2015-08-15 03:59:50 +08:00
|
|
|
ifeq ($(HOST_CROSS_OS),windows)
|
|
|
|
HOST_CROSS_FPIE_FLAGS += -Wl,-e_mainCRTStartup
|
2014-10-02 15:51:11 +08:00
|
|
|
endif
|
2014-04-05 05:37:33 +08:00
|
|
|
endif
|
2009-03-04 11:28:42 +08:00
|
|
|
|
|
|
|
ifneq ($(HOST_CUSTOM_LD_COMMAND),true)
|
|
|
|
define transform-host-o-to-executable-inner
|
2011-01-29 06:14:47 +08:00
|
|
|
$(hide) $(PRIVATE_CXX) \
|
2009-03-04 11:28:42 +08:00
|
|
|
$(PRIVATE_ALL_OBJECTS) \
|
|
|
|
-Wl,--whole-archive \
|
2016-09-10 01:09:47 +08:00
|
|
|
$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES) \
|
2009-03-04 11:28:42 +08:00
|
|
|
-Wl,--no-whole-archive \
|
2011-04-26 05:22:41 +08:00
|
|
|
$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
|
2016-09-10 01:09:47 +08:00
|
|
|
$(PRIVATE_ALL_STATIC_LIBRARIES) \
|
2011-04-26 05:22:41 +08:00
|
|
|
$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
|
2015-01-24 08:12:57 +08:00
|
|
|
$(if $(filter true,$(NATIVE_COVERAGE)),-lgcov) \
|
2015-01-26 08:20:57 +08:00
|
|
|
$(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_HOST_LIBPROFILE_RT)) \
|
2016-09-10 01:09:47 +08:00
|
|
|
$(PRIVATE_ALL_SHARED_LIBRARIES) \
|
2015-08-15 03:59:50 +08:00
|
|
|
-Wl,-rpath-link=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)OUT_INTERMEDIATE_LIBRARIES) \
|
Add NATIVE_TESTS class, move host native tests
Host native tests have been getting installed into
out/host/linux-x86/bin/..., but this pollutes the bin directory with a
lot of poorly named tests. Also, to support 32-bit and 64-bit tests, we
need to have different names with different suffixes. This causes
problems when tests expect to be named something specific (like gtest).
It's also convenient to store test data next to the test itself.
So with this change, native tests will be installed in
out/host/linux-x86/nativetest[64]/$(LOCAL_MODULE)/$(LOCAL_MODULE_STEM)
just like target tests get installed into /data/nativetest[64].
Implement this using a new NATIVE_TESTS class, which is like
EXECUTABLES, but sets up the install path differently, and configures
the rpath to load shared libraries with the proper relative path.
LOCAL_MODULE_RELATIVE_PATH can be used to control the directory name, it
will default to $(LOCAL_MODULE). This way multiple related tests can be
grouped together.
Target native tests also use NATIVE_TESTS now, but nothing should change
other than LOCAL_MODULE_RELATIVE_PATH can be used.
Change-Id: I535e42b1a6b21c5b8d6a580aa2f944d2be35e27d
2016-03-03 05:54:51 +08:00
|
|
|
$(foreach path,$(PRIVATE_RPATHS), \
|
|
|
|
-Wl,-rpath,\$$ORIGIN/$(path)) \
|
2011-11-11 01:57:40 +08:00
|
|
|
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
|
2013-12-10 19:07:41 +08:00
|
|
|
$(PRIVATE_HOST_GLOBAL_LDFLAGS) \
|
2011-11-11 01:57:40 +08:00
|
|
|
) \
|
2014-02-12 22:24:41 +08:00
|
|
|
$(PRIVATE_LDFLAGS) \
|
2009-03-04 11:28:42 +08:00
|
|
|
-o $@ \
|
|
|
|
$(PRIVATE_LDLIBS)
|
|
|
|
endef
|
|
|
|
endif
|
|
|
|
|
|
|
|
define transform-host-o-to-executable
|
2015-08-15 03:59:50 +08:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) Executable: $(PRIVATE_MODULE) ($@)"
|
2015-07-17 08:14:27 +08:00
|
|
|
@mkdir -p $(dir $@)
|
2011-01-29 06:14:47 +08:00
|
|
|
$(transform-host-o-to-executable-inner)
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Commands for running javac to make .class files
|
|
|
|
###########################################################
|
|
|
|
|
2015-09-20 01:56:35 +08:00
|
|
|
# Add BUILD_NUMBER to apps default version name if it's unbundled build.
|
|
|
|
ifdef TARGET_BUILD_APPS
|
2016-05-27 03:32:30 +08:00
|
|
|
TARGET_BUILD_WITH_APPS_VERSION_NAME := true
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifdef TARGET_BUILD_WITH_APPS_VERSION_NAME
|
2015-09-20 01:56:35 +08:00
|
|
|
APPS_DEFAULT_VERSION_NAME := $(PLATFORM_VERSION)-$(BUILD_NUMBER_FROM_FILE)
|
|
|
|
else
|
|
|
|
APPS_DEFAULT_VERSION_NAME := $(PLATFORM_VERSION)
|
|
|
|
endif
|
|
|
|
|
2009-03-04 11:28:42 +08:00
|
|
|
# TODO: Right now we generate the asset resources twice, first as part
|
|
|
|
# of generating the Java classes, then at the end when packaging the final
|
|
|
|
# assets. This should be changed to do one of two things: (1) Don't generate
|
|
|
|
# any resource files the first time, only create classes during that stage;
|
|
|
|
# or (2) Don't use the -c flag with the second stage, instead taking the
|
|
|
|
# resource files from the first stage as additional input. My original intent
|
|
|
|
# was to use approach (2), but this requires a little more work in the tool.
|
|
|
|
# Maybe we should just use approach (1).
|
|
|
|
|
|
|
|
# This rule creates the R.java and Manifest.java files, both of which
|
2011-03-16 04:19:30 +08:00
|
|
|
# are PRODUCT-neutral. Don't pass PRIVATE_PRODUCT_AAPT_CONFIG to this invocation.
|
2009-03-04 11:28:42 +08:00
|
|
|
define create-resource-java-files
|
|
|
|
@mkdir -p $(PRIVATE_SOURCE_INTERMEDIATES_DIR)
|
|
|
|
@mkdir -p $(dir $(PRIVATE_RESOURCE_PUBLICS_OUTPUT))
|
2010-03-11 08:02:42 +08:00
|
|
|
$(hide) $(AAPT) package $(PRIVATE_AAPT_FLAGS) -m \
|
2011-03-16 04:19:30 +08:00
|
|
|
$(eval # PRIVATE_PRODUCT_AAPT_CONFIG is intentionally missing-- see comment.) \
|
2009-03-04 11:28:42 +08:00
|
|
|
$(addprefix -J , $(PRIVATE_SOURCE_INTERMEDIATES_DIR)) \
|
|
|
|
$(addprefix -M , $(PRIVATE_ANDROID_MANIFEST)) \
|
|
|
|
$(addprefix -P , $(PRIVATE_RESOURCE_PUBLICS_OUTPUT)) \
|
|
|
|
$(addprefix -S , $(PRIVATE_RESOURCE_DIR)) \
|
|
|
|
$(addprefix -A , $(PRIVATE_ASSET_DIR)) \
|
2009-05-16 09:01:20 +08:00
|
|
|
$(addprefix -I , $(PRIVATE_AAPT_INCLUDES)) \
|
2009-08-31 04:39:24 +08:00
|
|
|
$(addprefix -G , $(PRIVATE_PROGUARD_OPTIONS_FILE)) \
|
2011-04-09 08:27:35 +08:00
|
|
|
$(addprefix --min-sdk-version , $(PRIVATE_DEFAULT_APP_TARGET_SDK)) \
|
|
|
|
$(addprefix --target-sdk-version , $(PRIVATE_DEFAULT_APP_TARGET_SDK)) \
|
2015-07-17 08:15:19 +08:00
|
|
|
$(if $(filter --version-code,$(PRIVATE_AAPT_FLAGS)),,--version-code $(PLATFORM_SDK_VERSION)) \
|
2015-09-20 01:56:35 +08:00
|
|
|
$(if $(filter --version-name,$(PRIVATE_AAPT_FLAGS)),,--version-name $(APPS_DEFAULT_VERSION_NAME)) \
|
2010-03-17 07:13:56 +08:00
|
|
|
$(addprefix --rename-manifest-package , $(PRIVATE_MANIFEST_PACKAGE_NAME)) \
|
2015-06-02 09:24:41 +08:00
|
|
|
$(addprefix --rename-instrumentation-target-package , $(PRIVATE_MANIFEST_INSTRUMENTATION_FOR)) \
|
|
|
|
--skip-symbols-without-default-localization
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
2015-12-05 05:59:18 +08:00
|
|
|
# Search for generated R.java/Manifest.java, copy the found R.java as $@.
|
|
|
|
# Also copy them to a central 'R' directory to make it easier to add the files to an IDE.
|
|
|
|
define find-generated-R.java
|
|
|
|
$(hide) for GENERATED_MANIFEST_FILE in `find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) \
|
|
|
|
-name Manifest.java 2> /dev/null`; do \
|
|
|
|
dir=`awk '/package/{gsub(/\./,"/",$$2);gsub(/;/,"",$$2);print $$2;exit}' $$GENERATED_MANIFEST_FILE`; \
|
|
|
|
mkdir -p $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \
|
|
|
|
$(ACP) -fp $$GENERATED_MANIFEST_FILE $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \
|
|
|
|
done;
|
|
|
|
$(hide) for GENERATED_R_FILE in `find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) \
|
|
|
|
-name R.java 2> /dev/null`; do \
|
|
|
|
dir=`awk '/package/{gsub(/\./,"/",$$2);gsub(/;/,"",$$2);print $$2;exit}' $$GENERATED_R_FILE`; \
|
|
|
|
mkdir -p $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \
|
|
|
|
$(ACP) -fp $$GENERATED_R_FILE $(TARGET_COMMON_OUT_ROOT)/R/$$dir \
|
|
|
|
|| exit 31; \
|
|
|
|
$(ACP) -fp $$GENERATED_R_FILE $@ || exit 32; \
|
|
|
|
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.
|
|
|
|
$(hide) touch $@
|
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
# AAPT2 compilation and link
|
|
|
|
###########################################################
|
|
|
|
define aapt2-compile-one-resource-file
|
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
$(hide) $(AAPT2) compile -o $(dir $@) $(PRIVATE_AAPT2_CFLAGS) --legacy $<
|
|
|
|
endef
|
|
|
|
|
2016-02-25 06:11:55 +08:00
|
|
|
define aapt2-compile-resource-dirs
|
2015-12-05 05:59:18 +08:00
|
|
|
@mkdir -p $(dir $@)
|
2016-02-25 06:11:55 +08:00
|
|
|
$(hide) $(AAPT2) compile -o $@ $(addprefix --dir ,$(PRIVATE_SOURCE_RES_DIRS)) \
|
2015-12-05 05:59:18 +08:00
|
|
|
$(PRIVATE_AAPT2_CFLAGS) --legacy
|
|
|
|
endef
|
|
|
|
|
|
|
|
# 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
|
|
|
|
$(eval _p_w := $(strip $(subst /,$(space),$(dir $(1)))))$(2)/$(subst $(space),/,$(_p_w))_$(if $(filter values%,$(lastword $(_p_w))),$(patsubst %.xml,%.arsc,$(notdir $(1))),$(notdir $(1))).flat
|
|
|
|
endef
|
|
|
|
|
|
|
|
define aapt2-link
|
2016-04-27 01:36:11 +08:00
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
$(call dump-words-to-file,$(PRIVATE_RES_FLAT),$(dir $@)aapt2-flat-list)
|
2015-12-05 05:59:18 +08:00
|
|
|
$(hide) $(AAPT2) link -o $@ \
|
|
|
|
$(PRIVATE_AAPT_FLAGS) \
|
|
|
|
$(addprefix --manifest ,$(PRIVATE_ANDROID_MANIFEST)) \
|
|
|
|
$(addprefix -I ,$(PRIVATE_AAPT_INCLUDES)) \
|
2016-02-25 06:11:55 +08:00
|
|
|
$(addprefix -I ,$(PRIVATE_SHARED_ANDROID_LIBRARIES)) \
|
2015-12-05 05:59:18 +08:00
|
|
|
$(addprefix --java ,$(PRIVATE_SOURCE_INTERMEDIATES_DIR)) \
|
|
|
|
$(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-27 03:13:43 +08: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)) \
|
2015-12-05 05:59:18 +08:00
|
|
|
$(addprefix -R , $(PRIVATE_OVERLAY_FLAT)) \
|
2016-04-27 01:36:11 +08:00
|
|
|
\@$(dir $@)aapt2-flat-list
|
2015-12-05 05:59:18 +08:00
|
|
|
endef
|
|
|
|
|
|
|
|
###########################################################
|
2010-07-08 02:42:19 +08:00
|
|
|
xlint_unchecked := -Xlint:unchecked
|
2009-03-04 11:28:42 +08: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 21:28:38 +08:00
|
|
|
@touch $(2)
|
2016-04-27 01:36:11 +08: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))
|
|
|
|
@$(if $(wordlist 13501,13502,$(1)),$(error Too many words ($(words $(1)))))
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
|
|
|
# For a list of jar files, unzip them to a specified directory,
|
2015-11-25 03:44:20 +08:00
|
|
|
# but make sure that no META-INF files come along for the ride,
|
|
|
|
# unless PRIVATE_DONT_DELETE_JAR_META_INF is set.
|
2009-03-04 11:28:42 +08:00
|
|
|
#
|
|
|
|
# $(1): files to unzip
|
|
|
|
# $(2): destination directory
|
|
|
|
define unzip-jar-files
|
|
|
|
$(hide) for f in $(1); \
|
|
|
|
do \
|
|
|
|
if [ ! -f $$f ]; then \
|
|
|
|
echo Missing file $$f; \
|
|
|
|
exit 1; \
|
|
|
|
fi; \
|
2009-06-10 06:08:29 +08:00
|
|
|
unzip -qo $$f -d $(2); \
|
2015-11-25 03:44:20 +08:00
|
|
|
done
|
|
|
|
$(if $(PRIVATE_DONT_DELETE_JAR_META_INF),,$(hide) rm -rf $(2)/META-INF)
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
2015-07-03 21:46:51 +08:00
|
|
|
# Call jack
|
|
|
|
#
|
|
|
|
define call-jack
|
2015-10-13 00:02:51 +08:00
|
|
|
JACK_VERSION=$(PRIVATE_JACK_VERSION) $(JACK) $(DEFAULT_JACK_EXTRA_ARGS)
|
2015-07-03 21:46:51 +08:00
|
|
|
endef
|
|
|
|
|
2010-12-11 04:10:24 +08:00
|
|
|
# Common definition to invoke javac on the host and target.
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
# $(1): javac
|
|
|
|
# $(2): bootclasspath
|
|
|
|
define compile-java
|
2009-04-10 10:31:12 +08:00
|
|
|
$(hide) rm -f $@
|
|
|
|
$(hide) rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR)
|
2010-12-11 04:10:24 +08:00
|
|
|
$(hide) mkdir -p $(dir $@)
|
2009-04-10 10:31:12 +08:00
|
|
|
$(hide) mkdir -p $(PRIVATE_CLASS_INTERMEDIATES_DIR)
|
2010-12-11 04:10:24 +08:00
|
|
|
$(call unzip-jar-files,$(PRIVATE_STATIC_JAVA_LIBRARIES),$(PRIVATE_CLASS_INTERMEDIATES_DIR))
|
2011-01-21 07:01:56 +08:00
|
|
|
$(call dump-words-to-file,$(PRIVATE_JAVA_SOURCES),$(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list)
|
2009-04-10 10:31:12 +08:00
|
|
|
$(hide) if [ -d "$(PRIVATE_SOURCE_INTERMEDIATES_DIR)" ]; then \
|
2015-08-05 03:44:38 +08:00
|
|
|
find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name '*.java' -and -not -name '.*' >> $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list; \
|
2009-03-04 11:28:42 +08:00
|
|
|
fi
|
2015-05-09 02:51:00 +08:00
|
|
|
$(hide) tr ' ' '\n' < $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list \
|
2015-10-23 07:30:00 +08:00
|
|
|
| $(NORMALIZE_PATH) | sort -u > $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq
|
2015-05-09 02:51:00 +08:00
|
|
|
$(hide) if [ -s $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq ] ; then \
|
2011-12-13 09:52:03 +08:00
|
|
|
$(1) -encoding UTF-8 \
|
2012-10-19 01:54:49 +08:00
|
|
|
$(if $(findstring true,$(PRIVATE_WARNINGS_ENABLE)),$(xlint_unchecked),) \
|
2010-12-11 04:10:24 +08:00
|
|
|
$(2) \
|
2009-03-04 11:28:42 +08:00
|
|
|
$(addprefix -classpath ,$(strip \
|
|
|
|
$(call normalize-path-list,$(PRIVATE_ALL_JAVA_LIBRARIES)))) \
|
2012-10-19 01:54:49 +08:00
|
|
|
$(if $(findstring true,$(PRIVATE_WARNINGS_ENABLE)),$(xlint_unchecked),) \
|
2009-03-04 11:28:42 +08:00
|
|
|
-extdirs "" -d $(PRIVATE_CLASS_INTERMEDIATES_DIR) \
|
2010-12-11 04:10:24 +08:00
|
|
|
$(PRIVATE_JAVACFLAGS) \
|
2011-01-21 07:01:56 +08:00
|
|
|
\@$(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq \
|
2011-12-13 09:52:03 +08:00
|
|
|
|| ( rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) ; exit 41 ) \
|
|
|
|
fi
|
2011-10-31 12:37:35 +08:00
|
|
|
$(if $(PRIVATE_JAVA_LAYERS_FILE), $(hide) build/tools/java-layers.py \
|
|
|
|
$(PRIVATE_JAVA_LAYERS_FILE) \@$(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq,)
|
2011-01-21 07:01:56 +08:00
|
|
|
$(hide) rm -f $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list
|
|
|
|
$(hide) rm -f $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq
|
2011-12-16 08:36:55 +08: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 09:41:19 +08: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))))
|
2013-09-25 10:05:52 +08:00
|
|
|
$(if $(PRIVATE_JAR_MANIFEST), \
|
2015-07-17 08:15:19 +08:00
|
|
|
$(hide) sed -e "s/%BUILD_NUMBER%/$(BUILD_NUMBER_FROM_FILE)/" \
|
2013-09-25 10:05:52 +08:00
|
|
|
$(PRIVATE_JAR_MANIFEST) > $(dir $@)/manifest.mf && \
|
|
|
|
jar -cfm $@ $(dir $@)/manifest.mf \
|
|
|
|
-C $(PRIVATE_CLASS_INTERMEDIATES_DIR) ., \
|
|
|
|
$(hide) jar -cf $@ -C $(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-15 06:23:56 +08:00
|
|
|
$(if $(PRIVATE_EXTRA_JAR_ARGS),$(call add-java-resources-to,$@))
|
2010-12-11 04:10:24 +08:00
|
|
|
endef
|
|
|
|
|
|
|
|
define transform-java-to-classes.jar
|
2016-06-25 02:13:34 +08:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) Java: $(PRIVATE_MODULE) ($(PRIVATE_CLASS_INTERMEDIATES_DIR))"
|
2010-12-11 04:10:24 +08:00
|
|
|
$(call compile-java,$(TARGET_JAVAC),$(PRIVATE_BOOTCLASSPATH))
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
2014-09-08 20:45:14 +08:00
|
|
|
# Invoke Jack to compile java from source to dex and jack files.
|
|
|
|
#
|
|
|
|
# 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 Jack doesn't like them.
|
|
|
|
define jack-java-to-dex
|
|
|
|
$(hide) rm -f $@
|
|
|
|
$(hide) rm -f $(PRIVATE_CLASSES_JACK)
|
|
|
|
$(hide) rm -rf $(PRIVATE_JACK_INTERMEDIATES_DIR)
|
|
|
|
$(hide) mkdir -p $(dir $@)
|
|
|
|
$(hide) mkdir -p $(dir $(PRIVATE_CLASSES_JACK))
|
|
|
|
$(hide) mkdir -p $(PRIVATE_JACK_INTERMEDIATES_DIR)
|
2015-01-09 17:36:40 +08:00
|
|
|
$(if $(PRIVATE_JACK_INCREMENTAL_DIR),$(hide) mkdir -p $(PRIVATE_JACK_INCREMENTAL_DIR))
|
2014-09-08 20:45:14 +08:00
|
|
|
$(call dump-words-to-file,$(PRIVATE_JAVA_SOURCES),$(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list)
|
|
|
|
$(hide) if [ -d "$(PRIVATE_SOURCE_INTERMEDIATES_DIR)" ]; then \
|
|
|
|
find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name '*.java' >> $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list; \
|
|
|
|
fi
|
2015-05-09 02:51:00 +08:00
|
|
|
$(hide) tr ' ' '\n' < $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list \
|
2015-10-23 07:30:00 +08:00
|
|
|
| $(NORMALIZE_PATH) | sort -u > $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list-uniq
|
2014-09-08 20:45:14 +08:00
|
|
|
$(if $(PRIVATE_JACK_PROGUARD_FLAGS), \
|
|
|
|
$(hide) echo -basedirectory $(CURDIR) > $@.flags; \
|
|
|
|
echo $(PRIVATE_JACK_PROGUARD_FLAGS) >> $@.flags; \
|
|
|
|
)
|
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-15 06:23:56 +08:00
|
|
|
$(if $(PRIVATE_EXTRA_JAR_ARGS),
|
|
|
|
$(hide) mkdir -p $@.res.tmp
|
|
|
|
$(hide) $(call create-empty-package-at,$@.res.tmp.zip)
|
|
|
|
$(hide) $(call add-java-resources-to,$@.res.tmp.zip)
|
2015-11-25 03:44:20 +08:00
|
|
|
$(hide) unzip -qo $@.res.tmp.zip -d $@.res.tmp
|
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-15 06:23:56 +08:00
|
|
|
$(hide) rm $@.res.tmp.zip)
|
2014-09-08 20:45:14 +08:00
|
|
|
$(hide) if [ -s $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list-uniq ] ; then \
|
|
|
|
export tmpEcjArg="@$(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list-uniq"; \
|
|
|
|
else \
|
|
|
|
export tmpEcjArg=""; \
|
|
|
|
fi; \
|
2015-10-13 00:02:51 +08:00
|
|
|
$(call call-jack) \
|
2014-09-08 20:45:14 +08:00
|
|
|
$(strip $(PRIVATE_JACK_FLAGS)) \
|
2015-11-20 00:53:00 +08:00
|
|
|
$(strip $(PRIVATE_JACK_COVERAGE_OPTIONS)) \
|
2014-09-08 20:45:14 +08:00
|
|
|
$(if $(NO_OPTIMIZE_DX), \
|
|
|
|
-D jack.dex.optimize="false") \
|
2015-05-20 23:52:15 +08:00
|
|
|
$(if $(PRIVATE_RMTYPEDEFS), \
|
|
|
|
-D jack.android.remove-typedef="true") \
|
2014-09-08 20:45:14 +08:00
|
|
|
$(addprefix --classpath ,$(strip \
|
2016-04-21 22:49:10 +08:00
|
|
|
$(call normalize-path-list,$(PRIVATE_JACK_SHARED_LIBRARIES)))) \
|
2014-09-08 20:45:14 +08:00
|
|
|
$(addprefix --import ,$(call reverse-list,$(PRIVATE_STATIC_JACK_LIBRARIES))) \
|
2016-08-05 23:45:10 +08:00
|
|
|
$(addprefix --pluginpath ,$(strip \
|
|
|
|
$(call normalize-path-list,$(PRIVATE_JACK_PLUGIN_PATH)))) \
|
|
|
|
$(if $(PRIVATE_JACK_PLUGIN),--plugin $(call normalize-comma-list,$(PRIVATE_JACK_PLUGIN))) \
|
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-15 06:23:56 +08:00
|
|
|
$(if $(PRIVATE_EXTRA_JAR_ARGS),--import-resource $@.res.tmp) \
|
2016-03-10 00:19:58 +08:00
|
|
|
-D jack.android.min-api-level=$(PRIVATE_JACK_MIN_SDK_VERSION) \
|
2014-09-08 20:45:14 +08:00
|
|
|
-D jack.import.resource.policy=keep-first \
|
2014-11-19 21:01:06 +08:00
|
|
|
-D jack.import.type.policy=keep-first \
|
2014-09-08 20:45:14 +08:00
|
|
|
--output-jack $(PRIVATE_CLASSES_JACK) \
|
2015-01-09 17:36:40 +08:00
|
|
|
$(if $(PRIVATE_JACK_INCREMENTAL_DIR),--incremental-folder $(PRIVATE_JACK_INCREMENTAL_DIR)) \
|
2014-11-19 21:01:06 +08:00
|
|
|
--output-dex $(PRIVATE_JACK_INTERMEDIATES_DIR) \
|
2014-09-08 20:45:14 +08:00
|
|
|
$(addprefix --config-jarjar ,$(strip $(PRIVATE_JARJAR_RULES))) \
|
|
|
|
$(if $(PRIVATE_JACK_PROGUARD_FLAGS),--config-proguard $@.flags) \
|
|
|
|
$$tmpEcjArg \
|
2015-07-02 18:10:17 +08:00
|
|
|
|| ( rm -rf $(PRIVATE_CLASSES_JACK); exit 41 )
|
2014-11-19 21:01:06 +08:00
|
|
|
$(hide) mv $(PRIVATE_JACK_INTERMEDIATES_DIR)/classes*.dex $(dir $@)
|
2014-09-08 20:45:14 +08:00
|
|
|
$(hide) rm -f $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list
|
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-15 06:23:56 +08:00
|
|
|
$(if $(PRIVATE_EXTRA_JAR_ARGS),$(hide) rm -rf $@.res.tmp)
|
2014-09-08 20:45:14 +08:00
|
|
|
$(hide) mv $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list-uniq $(PRIVATE_JACK_INTERMEDIATES_DIR).java-source-list
|
|
|
|
$(if $(PRIVATE_JAR_PACKAGES), $(hide) echo unsupported options PRIVATE_JAR_PACKAGES in $@; exit 53)
|
|
|
|
$(if $(PRIVATE_JAR_EXCLUDE_PACKAGES), $(hide) echo unsupported options JAR_EXCLUDE_PACKAGES in $@; exit 53)
|
2014-11-19 21:01:06 +08:00
|
|
|
$(if $(PRIVATE_JAR_MANIFEST), $(hide) echo unsupported options JAR_MANIFEST in $@; exit 53)
|
2014-09-08 20:45:14 +08:00
|
|
|
endef
|
|
|
|
|
2015-08-19 01:18:18 +08:00
|
|
|
# Invoke Jack to compile java source just to check it compiles correctly.
|
|
|
|
#
|
|
|
|
# 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 Jack doesn't like them.
|
|
|
|
define jack-check-java
|
|
|
|
$(hide) rm -f $@
|
|
|
|
$(hide) rm -f $@.java-source-list
|
|
|
|
$(hide) rm -f $@.java-source-list-uniq
|
|
|
|
$(hide) mkdir -p $(dir $@)
|
|
|
|
$(if $(PRIVATE_JACK_INCREMENTAL_DIR),$(hide) mkdir -p $(PRIVATE_JACK_INCREMENTAL_DIR))
|
|
|
|
$(call dump-words-to-file,$(PRIVATE_JAVA_SOURCES),$@.java-source-list)
|
|
|
|
$(hide) if [ -d "$(PRIVATE_SOURCE_INTERMEDIATES_DIR)" ]; then \
|
|
|
|
find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name '*.java' >> $@.java-source-list; \
|
|
|
|
fi
|
|
|
|
$(hide) tr ' ' '\n' < $@.java-source-list \
|
|
|
|
| sort -u > $@.java-source-list-uniq
|
|
|
|
$(hide) if [ -s $@.java-source-list-uniq ] ; then \
|
2016-03-29 09:39:42 +08:00
|
|
|
$(call call-jack) \
|
2015-08-19 01:18:18 +08:00
|
|
|
$(strip $(PRIVATE_JACK_FLAGS)) \
|
|
|
|
$(addprefix --classpath ,$(strip \
|
2016-04-21 22:49:10 +08:00
|
|
|
$(call normalize-path-list,$(call reverse-list,$(PRIVATE_STATIC_JACK_LIBRARIES)) $(PRIVATE_JACK_SHARED_LIBRARIES)))) \
|
2015-08-19 01:18:18 +08:00
|
|
|
-D jack.import.resource.policy=keep-first \
|
2016-03-10 00:19:58 +08:00
|
|
|
-D jack.android.min-api-level=$(PRIVATE_JACK_MIN_SDK_VERSION) \
|
2015-08-19 01:18:18 +08:00
|
|
|
-D jack.import.type.policy=keep-first \
|
|
|
|
$(if $(PRIVATE_JACK_INCREMENTAL_DIR),--incremental-folder $(PRIVATE_JACK_INCREMENTAL_DIR)) \
|
|
|
|
@$@.java-source-list-uniq; \
|
|
|
|
fi
|
|
|
|
touch $@
|
|
|
|
endef
|
|
|
|
|
2014-09-08 20:45:14 +08:00
|
|
|
define transform-jar-to-jack
|
|
|
|
$(hide) mkdir -p $(dir $@)
|
2014-11-19 21:01:06 +08:00
|
|
|
$(hide) mkdir -p $@.tmpjill.res
|
2015-11-25 06:09:11 +08:00
|
|
|
$(hide) unzip -qo $< -d $@.tmpjill.res
|
2014-11-19 21:01:06 +08:00
|
|
|
$(hide) find $@.tmpjill.res -iname "*.class" -delete
|
2015-10-13 00:02:51 +08:00
|
|
|
$(hide) $(call call-jack) \
|
2016-01-19 23:08:34 +08:00
|
|
|
$(PRIVATE_JACK_FLAGS) \
|
2016-08-05 23:45:10 +08:00
|
|
|
$(addprefix --pluginpath ,$(strip \
|
|
|
|
$(call normalize-path-list,$(PRIVATE_JACK_PLUGIN_PATH)))) \
|
|
|
|
$(if $(PRIVATE_JACK_PLUGIN),--plugin $(call normalize-comma-list,$(PRIVATE_JACK_PLUGIN))) \
|
2014-11-19 21:01:06 +08:00
|
|
|
-D jack.import.resource.policy=keep-first \
|
|
|
|
-D jack.import.type.policy=keep-first \
|
2016-03-10 00:19:58 +08:00
|
|
|
-D jack.android.min-api-level=$(PRIVATE_JACK_MIN_SDK_VERSION) \
|
2016-01-19 23:08:34 +08:00
|
|
|
--import $< \
|
2014-11-19 21:01:06 +08:00
|
|
|
--import-resource $@.tmpjill.res \
|
|
|
|
--output-jack $@
|
|
|
|
$(hide) rm -rf $@.tmpjill.res
|
2014-09-08 20:45:14 +08:00
|
|
|
endef
|
|
|
|
|
2015-11-09 15:47:42 +08: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-07 06:28:36 +08:00
|
|
|
# targets which depend on $1.
|
2015-11-09 15:47:42 +08: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 17:06:20 +08:00
|
|
|
## Rule to create a table of contents from a .jar file.
|
2015-11-09 15:47:42 +08:00
|
|
|
## Must be called with $(eval).
|
2015-12-09 17:06:20 +08:00
|
|
|
# $(1): A .jar file
|
2015-11-09 15:47:42 +08:00
|
|
|
define _transform-jar-to-toc
|
|
|
|
$1.toc: $1 | $(IJAR)
|
|
|
|
@echo Generating TOC: $$@
|
|
|
|
$(hide) $(IJAR) $$< $$@.tmp
|
|
|
|
$$(call commit-change-for-toc,$$@)
|
|
|
|
endef
|
|
|
|
|
|
|
|
## Define a rule which generates .jar.toc and mark it as .KATI_RESTAT.
|
2015-12-09 17:06:20 +08:00
|
|
|
# $(1): A .jar file
|
2015-11-09 15:47:42 +08:00
|
|
|
define define-jar-to-toc-rule
|
2015-12-05 08:44:03 +08:00
|
|
|
$(eval $(call _transform-jar-to-toc,$1))\
|
2015-11-09 15:47:42 +08:00
|
|
|
$(eval .KATI_RESTAT: $1.toc)
|
|
|
|
endef
|
|
|
|
|
2015-12-09 17:06:20 +08: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-25 00:17:04 +08:00
|
|
|
$(hide) ANDROID_LOG_TAGS="*:e" $(DEXDUMP) -l xml $$(PRIVATE_INPUT_DEX_FILES) > $$@.tmp
|
2015-12-09 17:06:20 +08: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 20:45:14 +08:00
|
|
|
|
|
|
|
# Invoke Jack to compile java from source to jack files without shrink or obfuscation.
|
|
|
|
#
|
|
|
|
# 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 Jack doesn't like them.
|
|
|
|
define java-to-jack
|
|
|
|
$(hide) rm -f $@
|
|
|
|
$(hide) rm -rf $(PRIVATE_JACK_INTERMEDIATES_DIR)
|
|
|
|
$(hide) mkdir -p $(dir $@)
|
|
|
|
$(hide) mkdir -p $(PRIVATE_JACK_INTERMEDIATES_DIR)
|
2015-01-09 17:36:40 +08:00
|
|
|
$(if $(PRIVATE_JACK_INCREMENTAL_DIR),$(hide) mkdir -p $(PRIVATE_JACK_INCREMENTAL_DIR))
|
2014-09-08 20:45:14 +08:00
|
|
|
$(call dump-words-to-file,$(PRIVATE_JAVA_SOURCES),$(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list)
|
|
|
|
$(hide) if [ -d "$(PRIVATE_SOURCE_INTERMEDIATES_DIR)" ]; then \
|
|
|
|
find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name '*.java' >> $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list; \
|
|
|
|
fi
|
2015-05-09 02:51:00 +08:00
|
|
|
$(hide) tr ' ' '\n' < $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list \
|
2015-10-23 07:30:00 +08:00
|
|
|
| $(NORMALIZE_PATH) | sort -u > $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list-uniq
|
2014-09-08 20:45:14 +08:00
|
|
|
$(if $(PRIVATE_JACK_PROGUARD_FLAGS), \
|
|
|
|
$(hide) echo -basedirectory $(CURDIR) > $@.flags; \
|
|
|
|
echo $(PRIVATE_JACK_PROGUARD_FLAGS) >> $@.flags; \
|
|
|
|
)
|
2014-11-19 21:01:06 +08:00
|
|
|
$(if $(PRIVATE_EXTRA_JAR_ARGS),
|
|
|
|
$(hide) mkdir -p $@.res.tmp
|
|
|
|
$(hide) $(call create-empty-package-at,$@.res.tmp.zip)
|
|
|
|
$(hide) $(call add-java-resources-to,$@.res.tmp.zip)
|
2015-01-14 23:21:39 +08:00
|
|
|
$(hide) unzip -qo $@.res.tmp.zip -d $@.res.tmp
|
2014-11-19 21:01:06 +08:00
|
|
|
$(hide) rm $@.res.tmp.zip)
|
2014-09-08 20:45:14 +08:00
|
|
|
$(hide) if [ -s $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list-uniq ] ; then \
|
|
|
|
export tmpEcjArg="@$(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list-uniq"; \
|
|
|
|
else \
|
|
|
|
export tmpEcjArg=""; \
|
|
|
|
fi; \
|
2015-10-13 00:02:51 +08:00
|
|
|
$(call call-jack) \
|
2014-09-08 20:45:14 +08:00
|
|
|
$(strip $(PRIVATE_JACK_FLAGS)) \
|
|
|
|
$(if $(NO_OPTIMIZE_DX), \
|
|
|
|
-D jack.dex.optimize="false") \
|
|
|
|
$(addprefix --classpath ,$(strip \
|
2016-04-21 22:49:10 +08:00
|
|
|
$(call normalize-path-list,$(PRIVATE_JACK_SHARED_LIBRARIES)))) \
|
2014-09-08 20:45:14 +08:00
|
|
|
$(addprefix --import ,$(call reverse-list,$(PRIVATE_STATIC_JACK_LIBRARIES))) \
|
2016-08-05 23:45:10 +08:00
|
|
|
$(addprefix --pluginpath ,$(strip \
|
|
|
|
$(call normalize-path-list,$(PRIVATE_JACK_PLUGIN_PATH)))) \
|
|
|
|
$(if $(PRIVATE_JACK_PLUGIN),--plugin $(call normalize-comma-list,$(PRIVATE_JACK_PLUGIN))) \
|
2014-11-19 21:01:06 +08:00
|
|
|
$(if $(PRIVATE_EXTRA_JAR_ARGS),--import-resource $@.res.tmp) \
|
2014-09-08 20:45:14 +08:00
|
|
|
-D jack.import.resource.policy=keep-first \
|
2014-11-19 21:01:06 +08:00
|
|
|
-D jack.import.type.policy=keep-first \
|
2016-03-10 00:19:58 +08:00
|
|
|
-D jack.android.min-api-level=$(PRIVATE_JACK_MIN_SDK_VERSION) \
|
2015-01-09 17:36:40 +08:00
|
|
|
$(if $(PRIVATE_JACK_INCREMENTAL_DIR),--incremental-folder $(PRIVATE_JACK_INCREMENTAL_DIR)) \
|
2014-09-08 20:45:14 +08:00
|
|
|
--output-jack $@ \
|
|
|
|
$(addprefix --config-jarjar ,$(strip $(PRIVATE_JARJAR_RULES))) \
|
|
|
|
$(if $(PRIVATE_JACK_PROGUARD_FLAGS),--config-proguard $@.flags) \
|
|
|
|
$$tmpEcjArg \
|
2014-11-19 21:01:06 +08:00
|
|
|
|| ( rm -f $@ ; exit 41 )
|
|
|
|
$(hide) rm -f $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list
|
|
|
|
$(if $(PRIVATE_EXTRA_JAR_ARGS),$(hide) rm -rf $@.res.tmp)
|
|
|
|
$(hide) mv $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list-uniq $(PRIVATE_JACK_INTERMEDIATES_DIR).java-source-list
|
2014-09-08 20:45:14 +08:00
|
|
|
$(if $(PRIVATE_JAR_PACKAGES), $(hide) echo unsupported options PRIVATE_JAR_PACKAGES in $@; exit 53)
|
|
|
|
$(if $(PRIVATE_JAR_EXCLUDE_PACKAGES), $(hide) echo unsupported options JAR_EXCLUDE_PACKAGES in $@; exit 53)
|
2014-11-19 21:01:06 +08:00
|
|
|
$(if $(PRIVATE_JAR_MANIFEST), $(hide) echo unsupported options JAR_MANIFEST in $@; exit 53)
|
2014-09-08 20:45:14 +08:00
|
|
|
endef
|
|
|
|
|
2009-03-04 11:28:42 +08:00
|
|
|
define transform-classes.jar-to-emma
|
|
|
|
$(hide) java -classpath $(EMMA_JAR) emma instr -outmode fullcopy -outfile \
|
2010-03-11 07:48:03 +08:00
|
|
|
$(PRIVATE_EMMA_COVERAGE_FILE) -ip $< -d $(PRIVATE_EMMA_INTERMEDIATES_DIR) \
|
2010-06-16 04:31:25 +08:00
|
|
|
$(addprefix -ix , $(PRIVATE_EMMA_COVERAGE_FILTER))
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
2014-11-19 21:01:06 +08:00
|
|
|
# Create a mostly-empty .jar file that we'll add to later.
|
|
|
|
# The MacOS jar tool doesn't like creating empty jar files,
|
|
|
|
# so we need to give it something.
|
|
|
|
# $(1) package to create
|
|
|
|
define create-empty-package-at
|
|
|
|
@mkdir -p $(dir $(1))
|
2015-02-27 02:34:33 +08:00
|
|
|
$(hide) touch $(dir $(1))zipdummy
|
|
|
|
$(hide) (cd $(dir $(1)) && jar cf $(notdir $(1)) zipdummy)
|
|
|
|
$(hide) zip -qd $(1) zipdummy
|
|
|
|
$(hide) rm $(dir $(1))zipdummy
|
2014-11-19 21:01:06 +08:00
|
|
|
endef
|
|
|
|
|
2009-03-04 11:28:42 +08:00
|
|
|
# Create a mostly-empty .jar file that we'll add to later.
|
|
|
|
# The MacOS jar tool doesn't like creating empty jar files,
|
|
|
|
# so we need to give it something.
|
|
|
|
define create-empty-package
|
2014-11-19 21:01:06 +08:00
|
|
|
$(call create-empty-package-at,$@)
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
|
|
|
#TODO: we kinda want to build different asset packages for
|
|
|
|
# different configurations, then combine them later (or something).
|
|
|
|
# Per-locale, etc.
|
|
|
|
# A list of dynamic and static parameters; build layers for
|
|
|
|
# dynamic params that lay over the static ones.
|
|
|
|
#TODO: update the manifest to point to the package file
|
2009-05-16 09:01:20 +08:00
|
|
|
#Note that the version numbers are given to aapt as simple default
|
|
|
|
#values; applications can override these by explicitly stating
|
|
|
|
#them in their manifest.
|
2009-03-04 11:28:42 +08:00
|
|
|
define add-assets-to-package
|
2010-03-11 08:02:42 +08:00
|
|
|
$(hide) $(AAPT) package -u $(PRIVATE_AAPT_FLAGS) \
|
2011-03-16 04:19:30 +08:00
|
|
|
$(addprefix -c , $(PRIVATE_PRODUCT_AAPT_CONFIG)) \
|
2014-05-10 01:57:48 +08:00
|
|
|
$(addprefix --preferred-density , $(PRIVATE_PRODUCT_AAPT_PREF_CONFIG)) \
|
2009-03-04 11:28:42 +08:00
|
|
|
$(addprefix -M , $(PRIVATE_ANDROID_MANIFEST)) \
|
|
|
|
$(addprefix -S , $(PRIVATE_RESOURCE_DIR)) \
|
|
|
|
$(addprefix -A , $(PRIVATE_ASSET_DIR)) \
|
|
|
|
$(addprefix -I , $(PRIVATE_AAPT_INCLUDES)) \
|
2011-04-09 08:27:35 +08:00
|
|
|
$(addprefix --min-sdk-version , $(PRIVATE_DEFAULT_APP_TARGET_SDK)) \
|
|
|
|
$(addprefix --target-sdk-version , $(PRIVATE_DEFAULT_APP_TARGET_SDK)) \
|
2016-02-27 03:13:43 +08:00
|
|
|
$(if $(filter --product,$(PRIVATE_AAPT_FLAGS)),,$(addprefix --product , $(PRIVATE_TARGET_AAPT_CHARACTERISTICS))) \
|
2015-07-17 08:15:19 +08:00
|
|
|
$(if $(filter --version-code,$(PRIVATE_AAPT_FLAGS)),,--version-code $(PLATFORM_SDK_VERSION)) \
|
2015-09-20 01:56:35 +08:00
|
|
|
$(if $(filter --version-name,$(PRIVATE_AAPT_FLAGS)),,--version-name $(APPS_DEFAULT_VERSION_NAME)) \
|
2010-02-06 12:36:42 +08:00
|
|
|
$(addprefix --rename-manifest-package , $(PRIVATE_MANIFEST_PACKAGE_NAME)) \
|
2010-09-03 06:41:01 +08:00
|
|
|
$(addprefix --rename-instrumentation-target-package , $(PRIVATE_MANIFEST_INSTRUMENTATION_FOR)) \
|
2015-06-02 09:24:41 +08:00
|
|
|
--skip-symbols-without-default-localization \
|
2009-03-04 11:28:42 +08:00
|
|
|
-F $@
|
|
|
|
endef
|
|
|
|
|
2014-06-25 11:01:52 +08:00
|
|
|
# We need the extra blank line, so that the command will be on a separate line.
|
|
|
|
# $(1): the ABI name
|
|
|
|
# $(2): the list of shared libraies
|
|
|
|
define _add-jni-shared-libs-to-package-per-abi
|
|
|
|
$(hide) cp $(2) $(dir $@)lib/$(1)
|
|
|
|
|
|
|
|
endef
|
|
|
|
|
2015-07-16 09:33:24 +08:00
|
|
|
# For apps_only build, don't uncompress/page-align the jni libraries,
|
|
|
|
# because the apk may be run on older platforms that don't support loading jni directly from apk.
|
|
|
|
ifdef TARGET_BUILD_APPS
|
|
|
|
JNI_COMPRESS_FLAGS :=
|
|
|
|
ZIPALIGN_PAGE_ALIGN_FLAGS :=
|
|
|
|
else
|
|
|
|
JNI_COMPRESS_FLAGS := -0
|
|
|
|
ZIPALIGN_PAGE_ALIGN_FLAGS := -p
|
|
|
|
endif
|
|
|
|
|
2009-03-04 11:28:42 +08:00
|
|
|
define add-jni-shared-libs-to-package
|
|
|
|
$(hide) rm -rf $(dir $@)lib
|
2014-06-25 11:01:52 +08:00
|
|
|
$(hide) mkdir -p $(addprefix $(dir $@)lib/,$(PRIVATE_JNI_SHARED_LIBRARIES_ABI))
|
|
|
|
$(foreach abi,$(PRIVATE_JNI_SHARED_LIBRARIES_ABI),\
|
|
|
|
$(call _add-jni-shared-libs-to-package-per-abi,$(abi),\
|
|
|
|
$(patsubst $(abi):%,%,$(filter $(abi):%,$(PRIVATE_JNI_SHARED_LIBRARIES)))))
|
2015-10-30 07:33:05 +08:00
|
|
|
$(hide) (cd $(dir $@) && zip -qrX $(JNI_COMPRESS_FLAGS) $(notdir $@) lib)
|
2009-03-04 11:28:42 +08:00
|
|
|
$(hide) rm -rf $(dir $@)lib
|
|
|
|
endef
|
|
|
|
|
|
|
|
#TODO: update the manifest to point to the dex file
|
|
|
|
define add-dex-to-package
|
2016-03-12 02:32:01 +08:00
|
|
|
$(call add-dex-to-package-arg,$@)
|
|
|
|
endef
|
|
|
|
|
|
|
|
# $(1): the package file.
|
|
|
|
define add-dex-to-package-arg
|
|
|
|
$(hide) find $(dir $(PRIVATE_DEX_FILE)) -maxdepth 1 -name "classes*.dex" | sort | xargs zip -qjX $(1)
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
2014-11-19 21:01:06 +08:00
|
|
|
# Add java resources added by the current module.
|
|
|
|
# $(1) destination package
|
|
|
|
#
|
|
|
|
define add-java-resources-to
|
|
|
|
$(call dump-words-to-file, $(PRIVATE_EXTRA_JAR_ARGS), $(1).jar-arg-list)
|
|
|
|
$(hide) jar uf $(1) @$(1).jar-arg-list
|
|
|
|
@rm -f $(1).jar-arg-list
|
|
|
|
endef
|
|
|
|
|
2014-09-08 20:45:14 +08:00
|
|
|
# Add resources carried by static Jack libraries.
|
|
|
|
#
|
|
|
|
define add-carried-jack-resources
|
|
|
|
$(hide) if [ -d $(PRIVATE_JACK_INTERMEDIATES_DIR) ] ; then \
|
2015-11-12 19:21:42 +08:00
|
|
|
find $(PRIVATE_JACK_INTERMEDIATES_DIR) -type f | sort \
|
2015-10-14 09:40:37 +08:00
|
|
|
| sed -e "s?^$(PRIVATE_JACK_INTERMEDIATES_DIR)/? -C \"$(PRIVATE_JACK_INTERMEDIATES_DIR)\" \"?" -e "s/$$/\"/" \
|
|
|
|
> $(dir $@)jack_res_jar_flags; \
|
|
|
|
if [ -s $(dir $@)jack_res_jar_flags ] ; then \
|
|
|
|
jar uf $@ @$(dir $@)jack_res_jar_flags; \
|
2014-09-08 20:45:14 +08:00
|
|
|
fi; \
|
|
|
|
fi
|
|
|
|
endef
|
|
|
|
|
2016-01-14 02:32:47 +08:00
|
|
|
# Returns the minSdkVersion of the specified APK as a decimal number. If the
|
|
|
|
# version is a codename, returns the current platform SDK version (always a
|
|
|
|
# decimal number) instead. If the APK does not specify a minSdkVersion, returns
|
|
|
|
# 0 to match how the Android platform interprets this situation at runtime.
|
|
|
|
#
|
2016-05-12 03:11:11 +08:00
|
|
|
# This currently substitutes any version which contains characters other than
|
|
|
|
# digits with the current platform's API Level number. This is because I
|
|
|
|
# couldn't figure out an easy way to perform the substitution only for the
|
|
|
|
# version codes listed in PLATFORM_VERSION_ALL_CODENAMES.
|
2016-01-14 02:32:47 +08:00
|
|
|
define get-package-min-sdk-version-int
|
|
|
|
$$(($(AAPT) dump badging $(1) 2>&1 | grep '^sdkVersion' || echo "sdkVersion:'0'") \
|
|
|
|
| cut -d"'" -f2 | \
|
2016-05-12 03:11:11 +08:00
|
|
|
sed -e s/^.*[^0-9].*$$/$(PLATFORM_SDK_VERSION)/)
|
2016-01-14 02:32:47 +08:00
|
|
|
endef
|
|
|
|
|
2009-03-04 11:28:42 +08:00
|
|
|
# Sign a package using the specified key/cert.
|
|
|
|
#
|
|
|
|
define sign-package
|
2016-03-12 02:32:01 +08:00
|
|
|
$(call sign-package-arg,$@)
|
|
|
|
endef
|
|
|
|
|
|
|
|
# $(1): the package file we are signing.
|
|
|
|
define sign-package-arg
|
|
|
|
$(hide) mv $(1) $(1).unsigned
|
2015-12-11 05:38:50 +08:00
|
|
|
$(hide) java -Djava.library.path=$(SIGNAPK_JNI_LIBRARY_PATH) -jar $(SIGNAPK_JAR) \
|
2016-01-14 02:32:47 +08:00
|
|
|
--min-sdk-version $(call get-package-min-sdk-version-int,$@.unsigned) \
|
2012-11-14 02:55:28 +08:00
|
|
|
$(PRIVATE_CERTIFICATE) $(PRIVATE_PRIVATE_KEY) \
|
2016-03-12 02:32:01 +08:00
|
|
|
$(PRIVATE_ADDITIONAL_CERTIFICATES) $(1).unsigned $(1).signed
|
|
|
|
$(hide) mv $(1).signed $(1)
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
2014-07-24 06:27:21 +08:00
|
|
|
# Align STORED entries of a package on 4-byte boundaries to make them easier to mmap.
|
2009-03-04 11:28:42 +08:00
|
|
|
#
|
|
|
|
define align-package
|
2016-04-29 22:32:00 +08:00
|
|
|
$(hide) if ! $(ZIPALIGN) -c $(ZIPALIGN_PAGE_ALIGN_FLAGS) 4 $@ >/dev/null ; then \
|
|
|
|
mv $@ $@.unaligned; \
|
|
|
|
$(ZIPALIGN) \
|
2015-07-16 09:33:24 +08:00
|
|
|
-f \
|
|
|
|
$(ZIPALIGN_PAGE_ALIGN_FLAGS) \
|
2014-07-24 06:27:21 +08:00
|
|
|
4 \
|
2016-04-29 22:32:00 +08:00
|
|
|
$@.unaligned $@.aligned; \
|
|
|
|
mv $@.aligned $@; \
|
|
|
|
fi
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
2015-10-30 07:33:05 +08:00
|
|
|
# Remove dynamic timestamps from packages
|
|
|
|
#
|
|
|
|
define remove-timestamps-from-package
|
|
|
|
$(hide) $(ZIPTIME) $@
|
|
|
|
endef
|
|
|
|
|
2015-05-02 05:02:26 +08:00
|
|
|
# Uncompress shared libraries embedded in an apk.
|
|
|
|
#
|
2015-04-18 07:53:15 +08:00
|
|
|
define uncompress-shared-libs
|
2016-05-18 04:33:34 +08:00
|
|
|
$(hide) if (zipinfo $@ $(PRIVATE_EMBEDDED_JNI_LIBS) 2>/dev/null | grep -v ' stor ' >/dev/null) ; then \
|
2015-05-02 05:02:26 +08:00
|
|
|
rm -rf $(dir $@)uncompressedlibs && mkdir $(dir $@)uncompressedlibs; \
|
|
|
|
unzip $@ $(PRIVATE_EMBEDDED_JNI_LIBS) -d $(dir $@)uncompressedlibs && \
|
|
|
|
zip -d $@ 'lib/*.so' && \
|
2015-11-12 10:20:37 +08:00
|
|
|
( cd $(dir $@)uncompressedlibs && find lib -type f | sort | zip -D -X -0 ../$(notdir $@) -@ ) && \
|
2015-05-02 05:02:26 +08:00
|
|
|
rm -rf $(dir $@)uncompressedlibs; \
|
|
|
|
fi
|
2015-04-18 07:53:15 +08:00
|
|
|
endef
|
|
|
|
|
2009-03-04 11:28:42 +08: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-11 04:10:24 +08: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 11:28:42 +08:00
|
|
|
define transform-host-java-to-package
|
2015-08-15 03:59:50 +08:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) Java: $(PRIVATE_MODULE) ($(PRIVATE_CLASS_INTERMEDIATES_DIR))"
|
2011-01-21 07:01:56 +08:00
|
|
|
$(call compile-java,$(HOST_JAVAC),$(PRIVATE_BOOTCLASSPATH))
|
2009-03-04 11:28:42 +08: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-03-01 04:45:18 +08:00
|
|
|
$(2): $(1)
|
2009-03-04 11:28:42 +08:00
|
|
|
@echo "Copy: $$@"
|
|
|
|
$$(copy-file-to-target)
|
|
|
|
endef
|
|
|
|
|
2012-05-18 08:12:04 +08:00
|
|
|
# Copies many files.
|
|
|
|
# $(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-files
|
|
|
|
$(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-one-file,$(_cmf_src),$(_cmf_dest))) \
|
|
|
|
$(_cmf_dest)))
|
|
|
|
endef
|
|
|
|
|
2012-05-15 05:39:00 +08: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
|
2016-03-01 09:52:39 +08:00
|
|
|
$(2): $(1)
|
2012-05-15 05:39:00 +08:00
|
|
|
@echo "Copy xml: $$@"
|
|
|
|
$(hide) xmllint $$< >/dev/null # Don't print the xml file to stdout.
|
|
|
|
$$(copy-file-to-target)
|
|
|
|
endef
|
|
|
|
|
2009-03-04 11:28:42 +08: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-03-01 04:45:18 +08: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 11:28:42 +08:00
|
|
|
define copy-file-to-target
|
|
|
|
@mkdir -p $(dir $@)
|
2016-03-01 04:45:18 +08: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-03-01 04:45:18 +08:00
|
|
|
$(hide) cp $< $@
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
|
|
|
# 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-03-01 04:45:18 +08:00
|
|
|
$(hide) rm -f $@
|
|
|
|
$(hide) cp -p $< $@
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
2009-08-12 10:16:46 +08:00
|
|
|
# The same as copy-file-to-target, but use the zipalign tool to do so.
|
|
|
|
define copy-file-to-target-with-zipalign
|
|
|
|
@mkdir -p $(dir $@)
|
2016-03-01 04:45:18 +08:00
|
|
|
$(hide) rm -f $@
|
2009-08-12 10:16:46 +08:00
|
|
|
$(hide) $(ZIPALIGN) -f 4 $< $@
|
|
|
|
endef
|
|
|
|
|
2009-08-07 04:02:19 +08: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-03-01 04:45:18 +08:00
|
|
|
$(hide) rm -f $@
|
2009-08-07 04:02:19 +08:00
|
|
|
$(hide) sed -e 's/#.*$$//' -e 's/[ \t]*$$//' -e '/^$$/d' < $< > $@
|
|
|
|
endef
|
|
|
|
|
2009-03-04 11:28:42 +08: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-03-01 04:45:18 +08: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-03-01 04:45:18 +08:00
|
|
|
$(hide) cp $< $@
|
2009-03-04 11:28:42 +08: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-03-01 04:45:18 +08:00
|
|
|
$(hide) rm -f $@
|
|
|
|
$(hide) cp $< $@
|
2009-03-04 11:28:42 +08:00
|
|
|
endef
|
|
|
|
|
|
|
|
# Copy a prebuilt file to a target location.
|
|
|
|
define transform-prebuilt-to-target
|
2016-06-25 02:13:34 +08:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) Prebuilt: $(PRIVATE_MODULE) ($@)"
|
2009-03-04 11:28:42 +08:00
|
|
|
$(copy-file-to-target)
|
|
|
|
endef
|
|
|
|
|
2009-08-12 10:16:46 +08:00
|
|
|
# Copy a prebuilt file to a target location, using zipalign on it.
|
|
|
|
define transform-prebuilt-to-target-with-zipalign
|
2016-06-25 02:13:34 +08:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) Prebuilt APK: $(PRIVATE_MODULE) ($@)"
|
2009-08-12 10:16:46 +08:00
|
|
|
$(copy-file-to-target-with-zipalign)
|
|
|
|
endef
|
|
|
|
|
2009-08-07 04:02:19 +08:00
|
|
|
# Copy a prebuilt file to a target location, stripping "# comment" comments.
|
|
|
|
define transform-prebuilt-to-target-strip-comments
|
2016-06-25 02:13:34 +08:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) Prebuilt: $(PRIVATE_MODULE) ($@)"
|
2009-08-07 04:02:19 +08:00
|
|
|
$(copy-file-to-target-strip-comments)
|
|
|
|
endef
|
|
|
|
|
2015-04-09 03:24:37 +08: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 07:02:57 +08:00
|
|
|
# Define a rule to create a symlink to a file.
|
|
|
|
# $(1): full path to source
|
|
|
|
# $(2): source (may be relative)
|
|
|
|
# $(3): full path to destination
|
|
|
|
define symlink-file
|
|
|
|
$(eval $(_symlink-file))
|
|
|
|
endef
|
|
|
|
|
|
|
|
# Order-only dependency because make/ninja will follow the link when checking
|
|
|
|
# the timestamp, so the file must exist
|
|
|
|
define _symlink-file
|
|
|
|
$(3): | $(1)
|
|
|
|
@echo "Symlink: $$@ -> $(2)"
|
|
|
|
@mkdir -p $(dir $$@)
|
|
|
|
@rm -rf $$@
|
|
|
|
$(hide) ln -sf $(2) $$@
|
|
|
|
endef
|
|
|
|
|
2010-02-02 01:51:23 +08:00
|
|
|
###########################################################
|
|
|
|
## Commands to call Proguard
|
|
|
|
###########################################################
|
|
|
|
define transform-jar-to-proguard
|
2013-08-22 09:32:49 +08:00
|
|
|
@echo Proguard: $@
|
2014-02-07 23:18:59 +08:00
|
|
|
$(hide) $(PROGUARD) -injars $< -outjars $@ $(PRIVATE_PROGUARD_FLAGS) \
|
|
|
|
$(addprefix -injars , $(PRIVATE_EXTRA_INPUT_JAR))
|
2010-02-02 01:51:23 +08:00
|
|
|
endef
|
|
|
|
|
2009-03-04 11:28:42 +08:00
|
|
|
###########################################################
|
|
|
|
## Stuff source generated from one-off tools
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
define transform-generated-source
|
2016-06-25 02:13:34 +08:00
|
|
|
@echo "$($(PRIVATE_PREFIX)DISPLAY) Generated: $(PRIVATE_MODULE) <= $<"
|
2009-03-04 11:28:42 +08:00
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
$(hide) $(PRIVATE_CUSTOM_TOOL)
|
|
|
|
endef
|
|
|
|
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Assertions about attributes of the target
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
# $(1): The file to check
|
|
|
|
ifndef get-file-size
|
|
|
|
$(error HOST_OS must define get-file-size)
|
|
|
|
endif
|
|
|
|
|
2009-07-03 00:00:54 +08:00
|
|
|
# Convert a partition data size (eg, as reported in /proc/mtd) to the
|
|
|
|
# size of the image used to flash that partition (which includes a
|
2010-12-06 22:24:58 +08:00
|
|
|
# spare area for each page).
|
2009-07-03 00:00:54 +08:00
|
|
|
# $(1): the partition data size
|
|
|
|
define image-size-from-data-size
|
2011-02-10 09:24:27 +08:00
|
|
|
$(strip $(eval _isfds_value := $$(shell echo $$$$(($(1) / $(BOARD_NAND_PAGE_SIZE) * \
|
|
|
|
($(BOARD_NAND_PAGE_SIZE)+$(BOARD_NAND_SPARE_SIZE))))))\
|
|
|
|
$(if $(filter 0, $(_isfds_value)),$(shell echo $$(($(BOARD_NAND_PAGE_SIZE)+$(BOARD_NAND_SPARE_SIZE)))),$(_isfds_value))\
|
|
|
|
$(eval _isfds_value :=))
|
2009-07-03 00:00:54 +08:00
|
|
|
endef
|
|
|
|
|
|
|
|
# $(1): The file(s) to check (often $@)
|
2014-06-17 05:19:36 +08:00
|
|
|
# $(2): The maximum total image size, in decimal bytes.
|
|
|
|
# Make sure to take into account any reserved space needed for the FS.
|
2009-03-04 11:28:42 +08:00
|
|
|
#
|
|
|
|
# If $(2) is empty, evaluates to "true"
|
|
|
|
#
|
|
|
|
# Reserve bad blocks. Make sure that MAX(1% of partition size, 2 blocks)
|
|
|
|
# is left over after the image has been flashed. Round the 1% up to the
|
|
|
|
# next whole flash block size.
|
|
|
|
define assert-max-file-size
|
|
|
|
$(if $(2), \
|
2009-07-09 03:09:04 +08:00
|
|
|
size=$$(for i in $(1); do $(call get-file-size,$$i); echo +; done; echo 0); \
|
|
|
|
total=$$(( $$( echo "$$size" ) )); \
|
2009-07-03 00:00:54 +08:00
|
|
|
printname=$$(echo -n "$(1)" | tr " " +); \
|
|
|
|
img_blocksize=$(call image-size-from-data-size,$(BOARD_FLASH_BLOCK_SIZE)); \
|
|
|
|
twoblocks=$$((img_blocksize * 2)); \
|
|
|
|
onepct=$$((((($(2) / 100) - 1) / img_blocksize + 1) * img_blocksize)); \
|
2014-06-17 05:19:36 +08:00
|
|
|
reserve=$$((twoblocks > onepct ? twoblocks : onepct)); \
|
2009-07-03 00:00:54 +08:00
|
|
|
maxsize=$$(($(2) - reserve)); \
|
2011-12-03 02:34:45 +08:00
|
|
|
echo "$$printname maxsize=$$maxsize blocksize=$$img_blocksize total=$$total reserve=$$reserve"; \
|
2009-07-03 00:00:54 +08:00
|
|
|
if [ "$$total" -gt "$$maxsize" ]; then \
|
|
|
|
echo "error: $$printname too large ($$total > [$(2) - $$reserve])"; \
|
|
|
|
false; \
|
2009-07-09 03:09:04 +08:00
|
|
|
elif [ "$$total" -gt $$((maxsize - 32768)) ]; then \
|
2009-07-03 00:00:54 +08:00
|
|
|
echo "WARNING: $$printname approaching size limit ($$total now; limit $$maxsize)"; \
|
2009-03-04 11:28:42 +08:00
|
|
|
fi \
|
|
|
|
, \
|
|
|
|
true \
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2009-08-08 07:38:08 +08:00
|
|
|
# Like assert-max-file-size, but the second argument is a partition
|
|
|
|
# size, which we'll convert to a max image size before checking it
|
|
|
|
# against the files.
|
|
|
|
#
|
|
|
|
# $(1): The file(s) to check (often $@)
|
|
|
|
# $(2): The partition size.
|
|
|
|
define assert-max-image-size
|
|
|
|
$(if $(2), \
|
2014-06-17 05:19:36 +08:00
|
|
|
$(call assert-max-file-size,$(1),$(call image-size-from-data-size,$(2))))
|
2009-08-08 07:38:08 +08:00
|
|
|
endef
|
|
|
|
|
2009-06-20 08:12:18 +08:00
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Define device-specific radio files
|
|
|
|
###########################################################
|
2013-07-27 03:19:20 +08:00
|
|
|
INSTALLED_RADIOIMAGE_TARGET :=
|
2009-06-20 08:12:18 +08: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-03 05:12:04 +08:00
|
|
|
$(eval $(call add-radio-file-internal,$(1),$(notdir $(1))))
|
2009-06-20 08:12:18 +08:00
|
|
|
endef
|
|
|
|
define add-radio-file-internal
|
2010-02-03 05:12:04 +08:00
|
|
|
INSTALLED_RADIOIMAGE_TARGET += $$(PRODUCT_OUT)/$(2)
|
2016-03-01 09:52:39 +08:00
|
|
|
$$(PRODUCT_OUT)/$(2) : $$(LOCAL_PATH)/$(1)
|
2009-06-20 08:12:18 +08:00
|
|
|
$$(transform-prebuilt-to-target)
|
|
|
|
endef
|
|
|
|
|
2012-03-21 07:42:22 +08: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 09:52:39 +08:00
|
|
|
$$(PRODUCT_OUT)/$(2) : $$(LOCAL_PATH)/$(1)
|
2012-03-21 07:42:22 +08:00
|
|
|
$$(transform-prebuilt-to-target)
|
|
|
|
endef
|
|
|
|
|
2009-06-20 08:12:18 +08:00
|
|
|
|
Add an inherit-package macro to the build system.
This lets you use the source code from one apk to build a new one
with a new module name, a new android package name and optionally,
a new certificate.
To use this, in a makefile, add this:
$(call inherit-package, \
packages/apps/Music/Android.mk, \
Music, \
MusicFork, \
my_cert, \
com.example.music)
You don't need the LOCAL_PATH and CLEAR_VARS stuff. It will override
only the packages that are defined in the makefile name you give, but
if other modules of other types are defined, you will get an error
saying that it's defined twice. In that case, you need to move the
duplicate library (for example a .so) out into a different makefile.
A LOCAL_OVERRIDES_PACKAGES entry is automatically created for the
forked app.
2010-02-05 09:37:21 +08:00
|
|
|
###########################################################
|
|
|
|
# Override the package defined in $(1), setting the
|
|
|
|
# variables listed below differently.
|
|
|
|
#
|
|
|
|
# $(1): The makefile to override (relative to the source
|
|
|
|
# tree root)
|
|
|
|
# $(2): Old LOCAL_PACKAGE_NAME value.
|
|
|
|
# $(3): New LOCAL_PACKAGE_NAME value.
|
2010-09-03 06:41:01 +08:00
|
|
|
# $(4): New LOCAL_MANIFEST_PACKAGE_NAME value.
|
|
|
|
# $(5): New LOCAL_CERTIFICATE value.
|
|
|
|
# $(6): New LOCAL_INSTRUMENTATION_FOR value.
|
|
|
|
# $(7): New LOCAL_MANIFEST_INSTRUMENTATION_FOR value.
|
Add an inherit-package macro to the build system.
This lets you use the source code from one apk to build a new one
with a new module name, a new android package name and optionally,
a new certificate.
To use this, in a makefile, add this:
$(call inherit-package, \
packages/apps/Music/Android.mk, \
Music, \
MusicFork, \
my_cert, \
com.example.music)
You don't need the LOCAL_PATH and CLEAR_VARS stuff. It will override
only the packages that are defined in the makefile name you give, but
if other modules of other types are defined, you will get an error
saying that it's defined twice. In that case, you need to move the
duplicate library (for example a .so) out into a different makefile.
A LOCAL_OVERRIDES_PACKAGES entry is automatically created for the
forked app.
2010-02-05 09:37:21 +08:00
|
|
|
#
|
|
|
|
# Note that LOCAL_PACKAGE_OVERRIDES is NOT cleared in
|
|
|
|
# clear_vars.mk.
|
|
|
|
###########################################################
|
|
|
|
define inherit-package
|
2010-09-03 06:41:01 +08:00
|
|
|
$(eval $(call inherit-package-internal,$(1),$(2),$(3),$(4),$(5),$(6),$(7)))
|
Add an inherit-package macro to the build system.
This lets you use the source code from one apk to build a new one
with a new module name, a new android package name and optionally,
a new certificate.
To use this, in a makefile, add this:
$(call inherit-package, \
packages/apps/Music/Android.mk, \
Music, \
MusicFork, \
my_cert, \
com.example.music)
You don't need the LOCAL_PATH and CLEAR_VARS stuff. It will override
only the packages that are defined in the makefile name you give, but
if other modules of other types are defined, you will get an error
saying that it's defined twice. In that case, you need to move the
duplicate library (for example a .so) out into a different makefile.
A LOCAL_OVERRIDES_PACKAGES entry is automatically created for the
forked app.
2010-02-05 09:37:21 +08:00
|
|
|
endef
|
|
|
|
|
|
|
|
define inherit-package-internal
|
|
|
|
LOCAL_PACKAGE_OVERRIDES \
|
2010-09-03 06:41:01 +08:00
|
|
|
:= $(strip $(1))||$(strip $(2))||$(strip $(3))||$(strip $(4))||&&$(strip $(5))||&&$(strip $(6))||&&$(strip $(7)) $(LOCAL_PACKAGE_OVERRIDES)
|
Add an inherit-package macro to the build system.
This lets you use the source code from one apk to build a new one
with a new module name, a new android package name and optionally,
a new certificate.
To use this, in a makefile, add this:
$(call inherit-package, \
packages/apps/Music/Android.mk, \
Music, \
MusicFork, \
my_cert, \
com.example.music)
You don't need the LOCAL_PATH and CLEAR_VARS stuff. It will override
only the packages that are defined in the makefile name you give, but
if other modules of other types are defined, you will get an error
saying that it's defined twice. In that case, you need to move the
duplicate library (for example a .so) out into a different makefile.
A LOCAL_OVERRIDES_PACKAGES entry is automatically created for the
forked app.
2010-02-05 09:37:21 +08:00
|
|
|
include $(1)
|
|
|
|
LOCAL_PACKAGE_OVERRIDES \
|
|
|
|
:= $(wordlist 1,$(words $(LOCAL_PACKAGE_OVERRIDES)), $(LOCAL_PACKAGE_OVERRIDES))
|
|
|
|
endef
|
|
|
|
|
|
|
|
# To be used with inherit-package above
|
|
|
|
# Evalutes to true if the package was overridden
|
|
|
|
define set-inherited-package-variables
|
|
|
|
$(strip $(call set-inherited-package-variables-internal))
|
|
|
|
endef
|
|
|
|
|
|
|
|
define keep-or-override
|
|
|
|
$(eval $(1) := $(if $(2),$(2),$($(1))))
|
|
|
|
endef
|
|
|
|
|
|
|
|
define set-inherited-package-variables-internal
|
|
|
|
$(eval _o := $(subst ||, ,$(lastword $(LOCAL_PACKAGE_OVERRIDES))))
|
|
|
|
$(eval _n := $(subst ||, ,$(firstword $(LOCAL_PACKAGE_OVERRIDES))))
|
|
|
|
$(if $(filter $(word 2,$(_n)),$(LOCAL_PACKAGE_NAME)), \
|
|
|
|
$(eval LOCAL_PACKAGE_NAME := $(word 3,$(_o))) \
|
|
|
|
$(eval LOCAL_MANIFEST_PACKAGE_NAME := $(word 4,$(_o))) \
|
2010-09-03 06:41:01 +08:00
|
|
|
$(call keep-or-override,LOCAL_CERTIFICATE,$(patsubst &&%,%,$(word 5,$(_o)))) \
|
|
|
|
$(call keep-or-override,LOCAL_INSTRUMENTATION_FOR,$(patsubst &&%,%,$(word 6,$(_o)))) \
|
|
|
|
$(call keep-or-override,LOCAL_MANIFEST_INSTRUMENTATION_FOR,$(patsubst &&%,%,$(word 7,$(_o)))) \
|
Add an inherit-package macro to the build system.
This lets you use the source code from one apk to build a new one
with a new module name, a new android package name and optionally,
a new certificate.
To use this, in a makefile, add this:
$(call inherit-package, \
packages/apps/Music/Android.mk, \
Music, \
MusicFork, \
my_cert, \
com.example.music)
You don't need the LOCAL_PATH and CLEAR_VARS stuff. It will override
only the packages that are defined in the makefile name you give, but
if other modules of other types are defined, you will get an error
saying that it's defined twice. In that case, you need to move the
duplicate library (for example a .so) out into a different makefile.
A LOCAL_OVERRIDES_PACKAGES entry is automatically created for the
forked app.
2010-02-05 09:37:21 +08:00
|
|
|
$(eval LOCAL_OVERRIDES_PACKAGES := $(sort $(LOCAL_OVERRIDES_PACKAGES) $(word 2,$(_o)))) \
|
|
|
|
true \
|
|
|
|
,)
|
|
|
|
endef
|
|
|
|
|
2009-03-04 11:28:42 +08:00
|
|
|
###########################################################
|
2012-11-15 07:57:07 +08:00
|
|
|
## API Check
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
# eval this to define a rule that runs apicheck.
|
|
|
|
#
|
|
|
|
# Args:
|
|
|
|
# $(1) target
|
|
|
|
# $(2) stable api file
|
|
|
|
# $(3) api file to be tested
|
2014-03-14 07:21:08 +08:00
|
|
|
# $(4) stable removed api file
|
2014-02-22 06:18:19 +08:00
|
|
|
# $(5) removed api file to be tested
|
|
|
|
# $(6) arguments for apicheck
|
|
|
|
# $(7) command to run if apicheck failed
|
|
|
|
# $(8) target dependent on this api check
|
|
|
|
# $(9) additional dependencies
|
2012-11-15 07:57:07 +08:00
|
|
|
define check-api
|
2014-03-14 07:21:08 +08:00
|
|
|
$(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(strip $(1))-timestamp: $(2) $(3) $(4) $(APICHECK) $(9)
|
2012-11-15 07:57:07 +08:00
|
|
|
@echo "Checking API:" $(1)
|
2014-02-22 06:18:19 +08:00
|
|
|
$(hide) ( $(APICHECK_COMMAND) $(6) $(2) $(3) $(4) $(5) || ( $(7) ; exit 38 ) )
|
2012-11-15 07:57:07 +08:00
|
|
|
$(hide) mkdir -p $$(dir $$@)
|
|
|
|
$(hide) touch $$@
|
2014-02-22 06:18:19 +08:00
|
|
|
$(8): $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(strip $(1))-timestamp
|
2012-11-15 07:57:07 +08:00
|
|
|
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 10:23:01 +08: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-27 01:41:27 +08:00
|
|
|
# Return the arch for the source file of a prebuilt
|
2015-10-05 00:28:47 +08: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-27 01:41:27 +08:00
|
|
|
# LOCAL_MODULE_TARGET_ARCH.
|
2014-02-28 06:10:53 +08: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-05 00:28:47 +08:00
|
|
|
$(if $(filter $(TARGET_2ND_ARCH),$(1)),$(TARGET_2ND_ARCH),$(if $(1),none))))
|
2014-02-28 06:10:53 +08:00
|
|
|
endef
|
|
|
|
|
2016-07-26 07:03:53 +08: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 \
|
|
|
|
HOST_DALVIK_JAVA_LIBRARY \
|
|
|
|
HOST_DALVIK_STATIC_JAVA_LIBRARY \
|
|
|
|
base_rules
|
|
|
|
|
|
|
|
$(foreach $(s),$(STATS.MODULE_TYPE),$(eval STATS.MODULE_TYPE.$(s) :=))
|
|
|
|
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
|
|
|
|
|
2016-09-15 12:38:29 +08:00
|
|
|
###########################################################
|
|
|
|
# Link type checking
|
|
|
|
###########################################################
|
|
|
|
define check-link-type
|
|
|
|
$(hide) mkdir -p $(dir $@) && rm -f $@
|
|
|
|
$(hide) $(CHECK_LINK_TYPE) --makefile $(PRIVATE_MAKEFILE) --module $(PRIVATE_MODULE) \
|
|
|
|
--type "$(PRIVATE_LINK_TYPE)" $(addprefix --allowed ,$(PRIVATE_ALLOWED_TYPES)) \
|
|
|
|
$(addprefix --warn ,$(PRIVATE_WARN_TYPES)) $(PRIVATE_DEPS)
|
|
|
|
$(hide) echo "$(PRIVATE_LINK_TYPE)" >$@
|
|
|
|
endef
|
|
|
|
|
|
|
|
define link-type-partitions
|
|
|
|
ifndef LOCAL_IS_HOST_MODULE
|
2016-09-23 01:56:36 +08:00
|
|
|
ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
|
|
|
|
ifneq ($(filter $(TARGET_OUT_VENDOR)/%,$(my_module_path)),)
|
2016-09-15 12:38:29 +08:00
|
|
|
$(1): PRIVATE_LINK_TYPE += partition:vendor
|
2016-09-23 01:56:36 +08:00
|
|
|
$(1): PRIVATE_WARN_TYPES += partition:data
|
2016-09-15 12:38:29 +08:00
|
|
|
$(1): PRIVATE_ALLOWED_TYPES += partition:vendor partition:oem partition:odm
|
2016-09-23 01:56:36 +08:00
|
|
|
else ifneq ($(filter $(TARGET_OUT_OEM)/%,$(my_module_path)),)
|
2016-09-15 12:38:29 +08:00
|
|
|
$(1): PRIVATE_LINK_TYPE += partition:oem
|
2016-09-23 01:56:36 +08:00
|
|
|
$(1): PRIVATE_WARN_TYPES += partition:data
|
2016-09-15 12:38:29 +08:00
|
|
|
$(1): PRIVATE_ALLOWED_TYPES += partition:vendor partition:oem partition:odm
|
2016-09-23 01:56:36 +08:00
|
|
|
else ifneq ($(filter $(TARGET_OUT_ODM)/%,$(my_module_path)),)
|
2016-09-15 12:38:29 +08:00
|
|
|
$(1): PRIVATE_LINK_TYPE += partition:odm
|
2016-09-23 01:56:36 +08:00
|
|
|
$(1): PRIVATE_WARN_TYPES += partition:data
|
2016-09-15 12:38:29 +08:00
|
|
|
$(1): PRIVATE_ALLOWED_TYPES += partition:vendor partition:oem partition:odm
|
2016-09-23 01:56:36 +08:00
|
|
|
else ifneq ($(filter $(TARGET_OUT_DATA)/%,$(my_module_path)),)
|
|
|
|
$(1): PRIVATE_LINK_TYPE += partition:data
|
|
|
|
$(1): PRIVATE_ALLOWED_TYPES += partition:data partition:vendor partition:oem partition:odm
|
2016-09-15 12:38:29 +08:00
|
|
|
else
|
2016-09-23 01:56:36 +08:00
|
|
|
$(1): PRIVATE_WARN_TYPES += partition:vendor partition:oem partition:odm partition:data
|
|
|
|
endif
|
|
|
|
else # uninstallable module
|
|
|
|
$(1): PRIVATE_ALLOWED_TYPES += partition:vendor partition:oem partition:odm partition:data
|
2016-09-15 12:38:29 +08:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endef
|
|
|
|
|
2012-11-15 07:57:07 +08:00
|
|
|
###########################################################
|
2009-03-04 11:28:42 +08:00
|
|
|
## Other includes
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
# -----------------------------------------------------------------
|
|
|
|
# Rules and functions to help copy important files to DIST_DIR
|
|
|
|
# when requested.
|
|
|
|
include $(BUILD_SYSTEM)/distdir.mk
|
|
|
|
|
2010-10-20 19:41:59 +08:00
|
|
|
# Include any vendor specific definitions.mk file
|
|
|
|
-include $(TOPDIR)vendor/*/build/core/definitions.mk
|
2014-10-28 23:32:11 +08:00
|
|
|
-include $(TOPDIR)device/*/build/core/definitions.mk
|
2015-08-21 06:39:56 +08:00
|
|
|
-include $(TOPDIR)product/*/build/core/definitions.mk
|
2010-10-20 19:41:59 +08:00
|
|
|
|
2009-03-04 11:28:42 +08: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
|