Merge "prevent unintended m bp2build "" when running b"
diff --git a/core/Makefile b/core/Makefile
index bd77911..0e38838 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -1398,7 +1398,6 @@
ifeq ($(BUILDING_VENDOR_KERNEL_BOOT_IMAGE),true)
INTERNAL_VENDOR_KERNEL_RAMDISK_FILES := $(filter $(TARGET_VENDOR_KERNEL_RAMDISK_OUT)/%, \
- $(ALL_GENERATED_SOURCES) \
$(ALL_DEFAULT_INSTALLED_MODULES))
INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor_kernel_boot)/vendor_kernel_ramdisk.cpio$(RAMDISK_EXT)
@@ -6159,25 +6158,39 @@
# -----------------------------------------------------------------
# A zip of the symbols directory. Keep the full paths to make it
# more obvious where these files came from.
+# Also produces a textproto containing mappings from elf IDs to symbols
+# filename, which will allow finding the appropriate symbols to deobfuscate
+# a stack trace frame.
#
+
name := $(TARGET_PRODUCT)
ifeq ($(TARGET_BUILD_TYPE),debug)
name := $(name)_debug
endif
-name := $(name)-symbols-$(FILE_NAME_TAG)
-SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
+# The path to the zip file containing binaries with symbols.
+SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name)-symbols-$(FILE_NAME_TAG).zip
+# The path to a file containing mappings from elf IDs to filenames.
+SYMBOLS_MAPPING := $(PRODUCT_OUT)/$(name)-symbols-mapping-$(FILE_NAME_TAG).textproto
+.KATI_READONLY := SYMBOLS_ZIP SYMBOLS_MAPPING
# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
ifeq (,$(TARGET_BUILD_UNBUNDLED))
$(SYMBOLS_ZIP): $(INTERNAL_ALLIMAGES_FILES) $(updater_dep)
endif
$(SYMBOLS_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,symbols)/filelist
-$(SYMBOLS_ZIP): $(SOONG_ZIP)
+$(SYMBOLS_ZIP): PRIVATE_MAPPING_PACKAGING_DIR := $(call intermediates-dir-for,PACKAGING,elf_symbol_mapping)
+$(SYMBOLS_ZIP): $(SOONG_ZIP) $(SYMBOLS_MAP)
@echo "Package symbols: $@"
$(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
- $(hide) mkdir -p $(dir $@) $(TARGET_OUT_UNSTRIPPED) $(dir $(PRIVATE_LIST_FILE))
+ $(hide) mkdir -p $(TARGET_OUT_UNSTRIPPED) $(dir $(PRIVATE_LIST_FILE)) $(PRIVATE_MAPPING_PACKAGING_DIR)
+ # Find all of the files in the symbols directory and zip them into the symbols zip.
$(hide) find -L $(TARGET_OUT_UNSTRIPPED) -type f | sort >$(PRIVATE_LIST_FILE)
$(hide) $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
+ # Find all of the files in the symbols mapping directory and merge them into the symbols mapping textproto.
+ $(hide) find -L $(PRIVATE_MAPPING_PACKAGING_DIR) -type f | sort >$(PRIVATE_LIST_FILE)
+ $(hide) $(SYMBOLS_MAP) -merge $(SYMBOLS_MAPPING) -ignore_missing_files @$(PRIVATE_LIST_FILE)
+$(SYMBOLS_ZIP): .KATI_IMPLICIT_OUTPUTS := $(SYMBOLS_MAPPING)
+
# -----------------------------------------------------------------
# A zip of the coverage directory.
#
@@ -6270,17 +6283,35 @@
#------------------------------------------------------------------
# A zip of Proguard obfuscation dictionary files.
+# Also produces a textproto containing mappings from the hashes of the
+# dictionary contents (which are also stored in the dex files on the
+# devices) to the filename of the proguard dictionary, which will allow
+# finding the appropriate dictionary to deobfuscate a stack trace frame.
#
+
+# The path to the zip file containing proguard dictionaries.
PROGUARD_DICT_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-$(FILE_NAME_TAG).zip
+# The path to the zip file containing mappings from dictionary hashes to filenames.
+PROGUARD_DICT_MAPPING := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-mapping-$(FILE_NAME_TAG).textproto
+.KATI_READONLY := PROGUARD_DICT_ZIP PROGUARD_DICT_MAPPING
# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
ifeq (,$(TARGET_BUILD_UNBUNDLED))
$(PROGUARD_DICT_ZIP): $(INTERNAL_ALLIMAGES_FILES) $(updater_dep)
endif
$(PROGUARD_DICT_ZIP): PRIVATE_PACKAGING_DIR := $(call intermediates-dir-for,PACKAGING,proguard_dictionary)
-$(PROGUARD_DICT_ZIP): $(SOONG_ZIP)
+$(PROGUARD_DICT_ZIP): PRIVATE_MAPPING_PACKAGING_DIR := $(call intermediates-dir-for,PACKAGING,proguard_dictionary_mapping)
+$(PROGUARD_DICT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard_dictionary_filelist)/filelist
+$(PROGUARD_DICT_ZIP): $(SOONG_ZIP) $(SYMBOLS_MAP)
@echo "Packaging Proguard obfuscation dictionary files."
- mkdir -p $(dir $@) $(PRIVATE_PACKAGING_DIR)
- $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(PRIVATE_PACKAGING_DIR) -P out/target/common/obj -D $(PRIVATE_PACKAGING_DIR)
+ rm -rf $@ $(PRIVATE_LIST_FILE)
+ mkdir -p $(PRIVATE_PACKAGING_DIR) $(PRIVATE_MAPPING_PACKAGING_DIR) $(dir $(PRIVATE_LIST_FILE))
+ # Zip all of the files in the proguard dictionary directory.
+ $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(PRIVATE_PACKAGING_DIR) -D $(PRIVATE_PACKAGING_DIR)
+ # Find all of the files in the proguard dictionary mapping directory and merge them into the mapping textproto.
+ # Strip the PRIVATE_PACKAGING_DIR off the filenames to match soong_zip's -C argument.
+ $(hide) find -L $(PRIVATE_MAPPING_PACKAGING_DIR) -type f | sort >$(PRIVATE_LIST_FILE)
+ $(SYMBOLS_MAP) -merge $(PROGUARD_DICT_MAPPING) -strip_prefix $(PRIVATE_PACKAGING_DIR)/ -ignore_missing_files @$(PRIVATE_LIST_FILE)
+$(PROGUARD_DICT_ZIP): .KATI_IMPLICIT_OUTPUTS := $(PROGUARD_DICT_MAPPING)
#------------------------------------------------------------------
# A zip of Proguard usage files.
diff --git a/core/base_rules.mk b/core/base_rules.mk
index c01cde8..e6b8f20 100644
--- a/core/base_rules.mk
+++ b/core/base_rules.mk
@@ -713,6 +713,10 @@
endif
ifdef LOCAL_MULTILIB
multi_arch := true
+else ifeq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
+ ifeq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES)
+ multi_arch := true
+ endif
endif
ifdef multi_arch
diff --git a/core/config.mk b/core/config.mk
index e2bdcbd..205a2fb 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -620,6 +620,7 @@
OTA_FROM_TARGET_FILES := $(HOST_OUT_EXECUTABLES)/ota_from_target_files$(HOST_EXECUTABLE_SUFFIX)
SPARSE_IMG := $(HOST_OUT_EXECUTABLES)/sparse_img$(HOST_EXECUTABLE_SUFFIX)
CHECK_PARTITION_SIZES := $(HOST_OUT_EXECUTABLES)/check_partition_sizes$(HOST_EXECUTABLE_SUFFIX)
+SYMBOLS_MAP := $(HOST_OUT_EXECUTABLES)/symbols_map
PROGUARD_HOME := external/proguard
PROGUARD := $(PROGUARD_HOME)/bin/proguard.sh
diff --git a/core/definitions.mk b/core/definitions.mk
index 2711f57..7308a38 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -622,24 +622,29 @@
$(2): PRIVATE_MODULE_TYPE := $(ALL_MODULES.$(1).MODULE_TYPE)
$(2): PRIVATE_MODULE_CLASS := $(ALL_MODULES.$(1).MODULE_CLASS)
$(2): PRIVATE_INSTALL_MAP := $(_map)
+$(2): PRIVATE_ARGUMENT_FILE := $(call intermediates-dir-for,PACKAGING,notice)/$(2)/arguments
$(2): $(BUILD_LICENSE_METADATA)
$(2) : $(foreach d,$(_deps),$(call word-colon,1,$(d))) $(foreach n,$(_notices),$(call word-colon,1,$(n)) )
rm -f $$@
mkdir -p $$(dir $$@)
+ mkdir -p $$(dir $$(PRIVATE_ARGUMENT_FILE))
+ $$(call dump-words-to-file,\
+ $$(addprefix -mt ,$$(PRIVATE_MODULE_TYPE))\
+ $$(addprefix -mc ,$$(PRIVATE_MODULE_CLASS))\
+ $$(addprefix -k ,$$(PRIVATE_KINDS))\
+ $$(addprefix -c ,$$(PRIVATE_CONDITIONS))\
+ $$(addprefix -n ,$$(PRIVATE_NOTICES))\
+ $$(addprefix -d ,$$(PRIVATE_NOTICE_DEPS))\
+ $$(addprefix -s ,$$(PRIVATE_SOURCES))\
+ $$(addprefix -m ,$$(PRIVATE_INSTALL_MAP))\
+ $$(addprefix -t ,$$(PRIVATE_TARGETS))\
+ $$(addprefix -i ,$$(PRIVATE_INSTALLED))\
+ $$(addprefix -r ,$$(PRIVATE_PATH)),\
+ $$(PRIVATE_ARGUMENT_FILE))
OUT_DIR=$(OUT_DIR) $(BUILD_LICENSE_METADATA) \
- $$(addprefix -mt ,$$(PRIVATE_MODULE_TYPE)) \
- $$(addprefix -mc ,$$(PRIVATE_MODULE_CLASS)) \
- $$(addprefix -k ,$$(PRIVATE_KINDS)) \
- $$(addprefix -c ,$$(PRIVATE_CONDITIONS)) \
- $$(addprefix -n ,$$(PRIVATE_NOTICES)) \
- $$(addprefix -d ,$$(PRIVATE_NOTICE_DEPS)) \
- $$(addprefix -s ,$$(PRIVATE_SOURCES)) \
- $$(addprefix -m ,$$(PRIVATE_INSTALL_MAP)) \
- $$(addprefix -t ,$$(PRIVATE_TARGETS)) \
- $$(addprefix -i ,$$(PRIVATE_INSTALLED)) \
$$(if $$(PRIVATE_IS_CONTAINER),-is_container) \
-p '$$(PRIVATE_PACKAGE_NAME)' \
- $$(addprefix -r ,$$(PRIVATE_PATH)) \
+ @$$(PRIVATE_ARGUMENT_FILE) \
-o $$@
endef
@@ -693,22 +698,27 @@
$(_meta): PRIVATE_IS_CONTAINER := $(ALL_NON_MODULES.$(_tgt).IS_CONTAINER)
$(_meta): PRIVATE_PACKAGE_NAME := $(strip $(ALL_NON_MODULES.$(_tgt).LICENSE_PACKAGE_NAME))
$(_meta): PRIVATE_INSTALL_MAP := $(strip $(_install_map))
+$(_meta): PRIVATE_ARGUMENT_FILE := $(call intermediates-dir-for,PACKAGING,notice)/$(_meta)/arguments
$(_meta): $(BUILD_LICENSE_METADATA)
$(_meta) : $(foreach d,$(_deps),$(call word-colon,1,$(d))) $(foreach n,$(_notices),$(call word-colon,1,$(n)) )
rm -f $$@
mkdir -p $$(dir $$@)
+ mkdir -p $$(dir $$(PRIVATE_ARGUMENT_FILE))
+ $$(call dump-words-to-file,\
+ $$(addprefix -k ,$$(PRIVATE_KINDS))\
+ $$(addprefix -c ,$$(PRIVATE_CONDITIONS))\
+ $$(addprefix -n ,$$(PRIVATE_NOTICES))\
+ $$(addprefix -d ,$$(PRIVATE_NOTICE_DEPS))\
+ $$(addprefix -s ,$$(PRIVATE_SOURCES))\
+ $$(addprefix -m ,$$(PRIVATE_INSTALL_MAP))\
+ $$(addprefix -t ,$$(PRIVATE_TARGETS))\
+ $$(addprefix -r ,$$(PRIVATE_PATH)),\
+ $$(PRIVATE_ARGUMENT_FILE))
OUT_DIR=$(OUT_DIR) $(BUILD_LICENSE_METADATA) \
-mt raw -mc unknown \
- $$(addprefix -k ,$$(PRIVATE_KINDS)) \
- $$(addprefix -c ,$$(PRIVATE_CONDITIONS)) \
- $$(addprefix -n ,$$(PRIVATE_NOTICES)) \
- $$(addprefix -d ,$$(PRIVATE_NOTICE_DEPS)) \
- $$(addprefix -s ,$$(PRIVATE_SOURCES)) \
- $$(addprefix -m ,$$(PRIVATE_INSTALL_MAP)) \
- $$(addprefix -t ,$$(PRIVATE_TARGETS)) \
$$(if $$(PRIVATE_IS_CONTAINER),-is_container) \
- -p '$$(PRIVATE_PACKAGE_NAME)' \
$$(addprefix -r ,$$(PRIVATE_PATH)) \
+ @$$(PRIVATE_ARGUMENT_FILE) \
-o $$@
endef
@@ -2368,7 +2378,59 @@
@$(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)))))
+ @$(call emit-line,$(wordlist 13501,14000,$(1)),$(2))
+ @$(call emit-line,$(wordlist 14001,14500,$(1)),$(2))
+ @$(call emit-line,$(wordlist 14501,15000,$(1)),$(2))
+ @$(call emit-line,$(wordlist 15001,15500,$(1)),$(2))
+ @$(call emit-line,$(wordlist 15501,16000,$(1)),$(2))
+ @$(call emit-line,$(wordlist 16001,16500,$(1)),$(2))
+ @$(call emit-line,$(wordlist 16501,17000,$(1)),$(2))
+ @$(call emit-line,$(wordlist 17001,17500,$(1)),$(2))
+ @$(call emit-line,$(wordlist 17501,18000,$(1)),$(2))
+ @$(call emit-line,$(wordlist 18001,18500,$(1)),$(2))
+ @$(call emit-line,$(wordlist 18501,19000,$(1)),$(2))
+ @$(call emit-line,$(wordlist 19001,19500,$(1)),$(2))
+ @$(call emit-line,$(wordlist 19501,20000,$(1)),$(2))
+ @$(call emit-line,$(wordlist 20001,20500,$(1)),$(2))
+ @$(call emit-line,$(wordlist 20501,21000,$(1)),$(2))
+ @$(call emit-line,$(wordlist 21001,21500,$(1)),$(2))
+ @$(call emit-line,$(wordlist 21501,22000,$(1)),$(2))
+ @$(call emit-line,$(wordlist 22001,22500,$(1)),$(2))
+ @$(call emit-line,$(wordlist 22501,23000,$(1)),$(2))
+ @$(call emit-line,$(wordlist 23001,23500,$(1)),$(2))
+ @$(call emit-line,$(wordlist 23501,24000,$(1)),$(2))
+ @$(call emit-line,$(wordlist 24001,24500,$(1)),$(2))
+ @$(call emit-line,$(wordlist 24501,25000,$(1)),$(2))
+ @$(call emit-line,$(wordlist 25001,25500,$(1)),$(2))
+ @$(call emit-line,$(wordlist 25501,26000,$(1)),$(2))
+ @$(call emit-line,$(wordlist 26001,26500,$(1)),$(2))
+ @$(call emit-line,$(wordlist 26501,27000,$(1)),$(2))
+ @$(call emit-line,$(wordlist 27001,27500,$(1)),$(2))
+ @$(call emit-line,$(wordlist 27501,28000,$(1)),$(2))
+ @$(call emit-line,$(wordlist 28001,28500,$(1)),$(2))
+ @$(call emit-line,$(wordlist 28501,29000,$(1)),$(2))
+ @$(call emit-line,$(wordlist 29001,29500,$(1)),$(2))
+ @$(call emit-line,$(wordlist 29501,30000,$(1)),$(2))
+ @$(call emit-line,$(wordlist 30001,30500,$(1)),$(2))
+ @$(call emit-line,$(wordlist 30501,31000,$(1)),$(2))
+ @$(call emit-line,$(wordlist 31001,31500,$(1)),$(2))
+ @$(call emit-line,$(wordlist 31501,32000,$(1)),$(2))
+ @$(call emit-line,$(wordlist 32001,32500,$(1)),$(2))
+ @$(call emit-line,$(wordlist 32501,33000,$(1)),$(2))
+ @$(call emit-line,$(wordlist 33001,33500,$(1)),$(2))
+ @$(call emit-line,$(wordlist 33501,34000,$(1)),$(2))
+ @$(call emit-line,$(wordlist 34001,34500,$(1)),$(2))
+ @$(call emit-line,$(wordlist 34501,35000,$(1)),$(2))
+ @$(call emit-line,$(wordlist 35001,35500,$(1)),$(2))
+ @$(call emit-line,$(wordlist 35501,36000,$(1)),$(2))
+ @$(call emit-line,$(wordlist 36001,36500,$(1)),$(2))
+ @$(call emit-line,$(wordlist 36501,37000,$(1)),$(2))
+ @$(call emit-line,$(wordlist 37001,37500,$(1)),$(2))
+ @$(call emit-line,$(wordlist 37501,38000,$(1)),$(2))
+ @$(call emit-line,$(wordlist 38001,38500,$(1)),$(2))
+ @$(call emit-line,$(wordlist 38501,39000,$(1)),$(2))
+ @$(call emit-line,$(wordlist 39001,39500,$(1)),$(2))
+ @$(if $(wordlist 39501,39502,$(1)),$(error Too many words ($(words $(1)))))
endef
# Return jar arguments to compress files in a given directory
# $(1): directory
@@ -3111,6 +3173,50 @@
fi
endef
+# Copy an unstripped binary to the symbols directory while also extracting
+# a hash mapping to the mapping directory.
+# $(1): unstripped intermediates file
+# $(2): path in symbols directory
+define copy-unstripped-elf-file-with-mapping
+$(call _copy-symbols-file-with-mapping,$(1),$(2),\
+ elf,$(patsubst $(TARGET_OUT_UNSTRIPPED)/%,$(call intermediates-dir-for,PACKAGING,elf_symbol_mapping)/%,$(2).textproto))
+endef
+
+# Copy an R8 dictionary to the packaging directory while also extracting
+# a hash mapping to the mapping directory.
+# $(1): unstripped intermediates file
+# $(2): path in packaging directory
+# $(3): path in mappings packaging directory
+define copy-r8-dictionary-file-with-mapping
+$(call _copy-symbols-file-with-mapping,$(1),$(2),r8,$(3))
+endef
+
+# Copy an unstripped binary or R8 dictionary to the symbols directory
+# while also extracting a hash mapping to the mapping directory.
+# $(1): unstripped intermediates file
+# $(2): path in symbols directory
+# $(3): file type (elf or r8)
+# $(4): path in the mappings directory
+define _copy-symbols-file-with-mapping
+$(2): .KATI_IMPLICIT_OUTPUTS := $(4)
+$(2): $(SYMBOLS_MAP)
+$(2): $(1)
+ @echo "Copy symbols with mapping: $$@"
+ $$(copy-file-to-target)
+ $(SYMBOLS_MAP) -$(strip $(3)) $(2) -write_if_changed $(4)
+.KATI_RESTAT: $(2)
+endef
+
+# Returns the directory to copy proguard dictionaries into
+define local-proguard-dictionary-directory
+$(call intermediates-dir-for,PACKAGING,proguard_dictionary)/out/target/common/obj/$(LOCAL_MODULE_CLASS)/$(LOCAL_MODULE)_intermediates
+endef
+
+# Returns the directory to copy proguard dictionary mappings into
+define local-proguard-dictionary-mapping-directory
+$(call intermediates-dir-for,PACKAGING,proguard_dictionary_mapping)/out/target/common/obj/$(LOCAL_MODULE_CLASS)/$(LOCAL_MODULE)_intermediates
+endef
+
###########################################################
## Commands to call R8
diff --git a/core/dynamic_binary.mk b/core/dynamic_binary.mk
index 52d7ddc..0d2cd7f 100644
--- a/core/dynamic_binary.mk
+++ b/core/dynamic_binary.mk
@@ -55,9 +55,7 @@
endif
symbolic_input := $(inject_module)
symbolic_output := $(my_unstripped_path)/$(my_installed_module_stem)
-$(symbolic_output) : $(symbolic_input)
- @echo "target Symbolic: $(PRIVATE_MODULE) ($@)"
- $(copy-file-to-target)
+$(eval $(call copy-unstripped-elf-file-with-mapping,$(symbolic_input),$(symbolic_output)))
###########################################################
## Store breakpad symbols
diff --git a/core/jacoco.mk b/core/jacoco.mk
index e8c74ee..7099526 100644
--- a/core/jacoco.mk
+++ b/core/jacoco.mk
@@ -50,6 +50,7 @@
unzip -qDD $(PRIVATE_FULL_CLASSES_PRE_JACOCO_JAR) \
-d $(PRIVATE_UNZIPPED_PATH) \
$(PRIVATE_INCLUDE_ARGS)
+ chmod -R =rwX $(PRIVATE_UNZIPPED_PATH)
(cd $(PRIVATE_UNZIPPED_PATH) && rm -rf $(PRIVATE_EXCLUDE_ARGS))
(cd $(PRIVATE_UNZIPPED_PATH) && find -not -name "*.class" -type f -exec rm {} \;)
touch $(PRIVATE_UNZIPPED_TIMESTAMP_PATH)
diff --git a/core/main.mk b/core/main.mk
index 72958da..6a2407c 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -1761,13 +1761,13 @@
endif
$(PROGUARD_DICT_ZIP) : $(apps_only_installed_files)
- $(call dist-for-goals,apps_only, $(PROGUARD_DICT_ZIP))
+ $(call dist-for-goals,apps_only, $(PROGUARD_DICT_ZIP) $(PROGUARD_DICT_MAPPING))
$(PROGUARD_USAGE_ZIP) : $(apps_only_installed_files)
$(call dist-for-goals,apps_only, $(PROGUARD_USAGE_ZIP))
$(SYMBOLS_ZIP) : $(apps_only_installed_files)
- $(call dist-for-goals,apps_only, $(SYMBOLS_ZIP))
+ $(call dist-for-goals,apps_only, $(SYMBOLS_ZIP) $(SYMBOLS_MAPPING))
$(COVERAGE_ZIP) : $(apps_only_installed_files)
$(call dist-for-goals,apps_only, $(COVERAGE_ZIP))
@@ -1818,7 +1818,9 @@
$(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET) \
$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET) \
$(SYMBOLS_ZIP) \
+ $(SYMBOLS_MAPPING) \
$(PROGUARD_DICT_ZIP) \
+ $(PROGUARD_DICT_MAPPING) \
$(PROGUARD_USAGE_ZIP) \
$(COVERAGE_ZIP) \
$(INSTALLED_FILES_FILE) \
@@ -1962,6 +1964,7 @@
$(call dist-for-goals,sdk, \
$(ALL_SDK_TARGETS) \
$(SYMBOLS_ZIP) \
+ $(SYMBOLS_MAPPING) \
$(COVERAGE_ZIP) \
$(APPCOMPAT_ZIP) \
$(INSTALLED_BUILD_PROP_TARGET) \
diff --git a/core/product_config.rbc b/core/product_config.rbc
index 0e7dbf1..81f9689 100644
--- a/core/product_config.rbc
+++ b/core/product_config.rbc
@@ -385,7 +385,7 @@
def __words(string_or_list):
if type(string_or_list) == "list":
- return string_or_list
+ string_or_list = " ".join(string_or_list)
return _mkstrip(string_or_list).split()
# Handle manipulation functions.
@@ -439,10 +439,6 @@
"""Returns basename."""
return path.rsplit("/",1)[-1]
-def __dir(path):
- """Returns dirname."""
- return path.rsplit("/",1)[0]
-
def _board_platform_in(g, string_or_list):
"""Returns true if board is in the list."""
board = g.get("TARGET_BOARD_PLATFORM","")
@@ -504,10 +500,15 @@
Return:
list of words
"""
- rex = __mk2regex(__words(pattern))
+ patterns = [__mkparse_pattern(x) for x in __words(pattern)]
res = []
for w in __words(text):
- if not _regex_match(rex, w):
+ match = False
+ for p in patterns:
+ if __mkpattern_matches(p, w):
+ match = True
+ break
+ if not match:
res.append(w)
return res
@@ -519,13 +520,22 @@
which stands for any sequence of characters.
text: string or list of words.
"""
- rex = __mk2regex(__words(pattern))
+ patterns = [__mkparse_pattern(x) for x in __words(pattern)]
res = []
for w in __words(text):
- if _regex_match(rex, w):
- res.append(w)
+ for p in patterns:
+ if __mkpattern_matches(p, w):
+ res.append(w)
+ break
return res
+def _dir(paths):
+ """Equivalent to the GNU make function $(dir).
+
+ Returns the folder of the file for each path in paths.
+ """
+ return " ".join([w.rsplit("/",1)[0] for w in __words(paths)])
+
def _notdir(paths):
"""Equivalent to the GNU make function $(notdir).
@@ -533,15 +543,6 @@
"""
return " ".join([__base(w) for w in __words(paths)])
-def __mk2regex(words):
- """Returns regular expression equivalent to Make pattern."""
-
- # TODO(asmundak): this will mishandle '\%'
- return "^(" + "|".join([w.replace("%", ".*", 1) for w in words if w]) + ")$"
-
-def _regex_match(regex, w):
- return rblf_regex(regex, w)
-
def _require_artifacts_in_path(paths, allowed_paths):
"""TODO."""
pass
@@ -598,7 +599,11 @@
def __mkparse_pattern(pattern):
- """Parses Make's patsubst pattern."""
+ """Parses Make's patsubst pattern.
+
+ This is equivalent to pattern.split('%', 1), except it
+ also takes into account escaping the % symbols.
+ """
in_escape = False
res = []
acc = ""
@@ -618,6 +623,21 @@
res.append(acc)
return res
+def __mkpattern_matches(pattern, word):
+ """Returns if a pattern matches a given word.
+
+ The pattern must be a list of strings of length at most 2.
+ This checks if word is either equal to the pattern or
+ starts/ends with the two parts of the pattern.
+ """
+ if len(pattern) > 2:
+ fail("Pattern can have at most 2 components")
+ elif len(pattern) == 1:
+ return pattern[0]==word
+ else:
+ return ((len(word) >= len(pattern[0])+len(pattern[1]))
+ and word.startswith(pattern[0])
+ and word.endswith(pattern[1]))
def __mkpatsubst_word(parsed_pattern,parsed_subst, word):
(before, after) = parsed_pattern
@@ -639,12 +659,11 @@
$1 in regex terms).
"""
parsed_pattern = __mkparse_pattern(pattern)
- words = s if type(s) == "list" else _mkstrip(s).split(" ")
if len(parsed_pattern) == 1:
- out_words = [ replacement if x == pattern else x for x in words]
+ out_words = [ replacement if x == pattern else x for x in __words(s)]
else:
parsed_replacement = __mkparse_pattern(replacement)
- out_words = [__mkpatsubst_word(parsed_pattern, parsed_replacement, x) for x in words]
+ out_words = [__mkpatsubst_word(parsed_pattern, parsed_replacement, x) for x in __words(s)]
return out_words if type(s) == "list" else " ".join(out_words)
@@ -740,7 +759,7 @@
copy_files = _copy_files,
copy_if_exists = _copy_if_exists,
cfg = __h_cfg,
- dir = __dir,
+ dir = _dir,
enforce_product_packages_exist = _enforce_product_packages_exist,
expand_wildcard = _expand_wildcard,
file_exists = rblf_file_exists,
diff --git a/core/soong_app_prebuilt.mk b/core/soong_app_prebuilt.mk
index 006e1dc..d771d22 100644
--- a/core/soong_app_prebuilt.mk
+++ b/core/soong_app_prebuilt.mk
@@ -100,18 +100,24 @@
endif
ifdef LOCAL_SOONG_PROGUARD_DICT
+ my_proguard_dictionary_directory := $(local-proguard-dictionary-directory)
+ my_proguard_dictionary_mapping_directory := $(local-proguard-dictionary-mapping-directory)
$(eval $(call copy-one-file,$(LOCAL_SOONG_PROGUARD_DICT),\
$(intermediates.COMMON)/proguard_dictionary))
- $(eval $(call copy-one-file,$(LOCAL_SOONG_PROGUARD_DICT),\
- $(call local-packaging-dir,proguard_dictionary)/proguard_dictionary))
+ $(eval $(call copy-r8-dictionary-file-with-mapping,\
+ $(LOCAL_SOONG_PROGUARD_DICT),\
+ $(my_proguard_dictionary_directory)/proguard_dictionary,\
+ $(my_proguard_dictionary_mapping_directory)/proguard_dictionary.textproto))
$(eval $(call copy-one-file,$(LOCAL_SOONG_CLASSES_JAR),\
- $(call local-packaging-dir,proguard_dictionary)/classes.jar))
+ $(my_proguard_dictionary_directory)/classes.jar))
$(call add-dependency,$(LOCAL_BUILT_MODULE),\
$(intermediates.COMMON)/proguard_dictionary)
$(call add-dependency,$(LOCAL_BUILT_MODULE),\
- $(call local-packaging-dir,proguard_dictionary)/proguard_dictionary)
+ $(my_proguard_dictionary_directory)/proguard_dictionary)
$(call add-dependency,$(LOCAL_BUILT_MODULE),\
- $(call local-packaging-dir,proguard_dictionary)/classes.jar)
+ $(my_proguard_dictionary_mapping_directory)/proguard_dictionary.textproto)
+ $(call add-dependency,$(LOCAL_BUILT_MODULE),\
+ $(my_proguard_dictionary_directory)/classes.jar)
endif
ifdef LOCAL_SOONG_PROGUARD_USAGE_ZIP
diff --git a/core/soong_cc_rust_prebuilt.mk b/core/soong_cc_rust_prebuilt.mk
index ca52374..7a177ff 100644
--- a/core/soong_cc_rust_prebuilt.mk
+++ b/core/soong_cc_rust_prebuilt.mk
@@ -184,7 +184,7 @@
# drop /root as /root is mounted as /
my_unstripped_path := $(patsubst $(TARGET_OUT_UNSTRIPPED)/root/%,$(TARGET_OUT_UNSTRIPPED)/%, $(my_unstripped_path))
symbolic_output := $(my_unstripped_path)/$(my_installed_module_stem)
- $(eval $(call copy-one-file,$(LOCAL_SOONG_UNSTRIPPED_BINARY),$(symbolic_output)))
+ $(eval $(call copy-unstripped-elf-file-with-mapping,$(LOCAL_SOONG_UNSTRIPPED_BINARY),$(symbolic_output)))
$(LOCAL_BUILT_MODULE): | $(symbolic_output)
ifeq ($(BREAKPAD_GENERATE_SYMBOLS),true)
diff --git a/core/soong_java_prebuilt.mk b/core/soong_java_prebuilt.mk
index b819cdc..a8f475f 100644
--- a/core/soong_java_prebuilt.mk
+++ b/core/soong_java_prebuilt.mk
@@ -62,18 +62,24 @@
endif
ifdef LOCAL_SOONG_PROGUARD_DICT
+ my_proguard_dictionary_directory := $(local-proguard-dictionary-directory)
+ my_proguard_dictionary_mapping_directory := $(local-proguard-dictionary-mapping-directory)
$(eval $(call copy-one-file,$(LOCAL_SOONG_PROGUARD_DICT),\
$(intermediates.COMMON)/proguard_dictionary))
- $(eval $(call copy-one-file,$(LOCAL_SOONG_PROGUARD_DICT),\
- $(call local-packaging-dir,proguard_dictionary)/proguard_dictionary))
+ $(eval $(call copy-r8-dictionary-file-with-mapping,\
+ $(LOCAL_SOONG_PROGUARD_DICT),\
+ $(my_proguard_dictionary_directory)/proguard_dictionary,\
+ $(my_proguard_dictionary_mapping_directory)/proguard_dictionary.textproto))
$(eval $(call copy-one-file,$(LOCAL_SOONG_CLASSES_JAR),\
- $(call local-packaging-dir,proguard_dictionary)/classes.jar))
+ $(my_proguard_dictionary_directory)/classes.jar))
$(call add-dependency,$(common_javalib.jar),\
$(intermediates.COMMON)/proguard_dictionary)
$(call add-dependency,$(common_javalib.jar),\
- $(call local-packaging-dir,proguard_dictionary)/proguard_dictionary)
+ $(my_proguard_dictionary_directory)/proguard_dictionary)
$(call add-dependency,$(common_javalib.jar),\
- $(call local-packaging-dir,proguard_dictionary)/classes.jar)
+ $(my_proguard_dictionary_mapping_directory)/proguard_dictionary.textproto)
+ $(call add-dependency,$(common_javalib.jar),\
+ $(my_proguard_dictionary_directory)/classes.jar)
endif
ifdef LOCAL_SOONG_PROGUARD_USAGE_ZIP
diff --git a/tests/run.rbc b/tests/run.rbc
index a9b1673..82a5e72 100644
--- a/tests/run.rbc
+++ b/tests/run.rbc
@@ -53,7 +53,11 @@
assert_eq(["from/a:to/a", "from/b:to/b"], rblf.product_copy_files_by_pattern("from/%", "to/%", "a b"))
assert_eq([], rblf.filter(["a", "", "b"], "f"))
-assert_eq(["", "b"], rblf.filter_out(["a", "" ], ["a", "", "b"] ))
+assert_eq(["ab%c", "axyzb%c"], rblf.filter(["a%b%c"], ["ab%c", "axyzb%c", "axyzb%cd", "axyzbwc"]))
+assert_eq(["abc", "bcd"], rblf.filter(["a%", "b%"], ["abc", "def", "bcd", "xabc"]))
+assert_eq(["b", "ab"], rblf.filter_out(["a", "" ], ["a", "", "b", "ab"]))
+assert_eq(["c"], rblf.filter_out(["a", "b" ], ["a", "b", "c"]))
+assert_eq(["c"], rblf.filter_out(["a%", "b" ], ["abc", "b", "c"]))
assert_eq("foo.c no_folder", rblf.notdir(["src/foo.c", "no_folder"]))
assert_eq("foo.c no_folder", rblf.notdir("src/foo.c no_folder"))
diff --git a/tools/checkowners.py b/tools/checkowners.py
index d6853d8..f037321 100755
--- a/tools/checkowners.py
+++ b/tools/checkowners.py
@@ -5,8 +5,8 @@
import argparse
import re
import sys
-import urllib
-import urllib2
+import urllib.request, urllib.parse, urllib.error
+import urllib.request, urllib.error, urllib.parse
parser = argparse.ArgumentParser(description='Check OWNERS file syntax')
parser.add_argument('-v', '--verbose', dest='verbose',
@@ -25,15 +25,15 @@
def echo(msg):
if args.verbose:
- print msg
+ print(msg)
def find_address(address):
if address not in checked_addresses:
request = (gerrit_server + '/accounts/?n=1&q=email:'
- + urllib.quote(address))
+ + urllib.parse.quote(address))
echo('Checking email address: ' + address)
- result = urllib2.urlopen(request).read()
+ result = urllib.request.urlopen(request).read()
checked_addresses[address] = result.find('"_account_id":') >= 0
if checked_addresses[address]:
echo('Found email address: ' + address)
@@ -43,7 +43,7 @@
def check_address(fname, num, address):
if find_address(address):
return 0
- print '%s:%d: ERROR: unknown email address: %s' % (fname, num, address)
+ print('%s:%d: ERROR: unknown email address: %s' % (fname, num, address))
return 1
@@ -72,7 +72,7 @@
stripped_line = re.sub('#.*$', '', line).strip()
if not patterns.match(stripped_line):
error += 1
- print '%s:%d: ERROR: unknown line [%s]' % (fname, num, line.strip())
+ print('%s:%d: ERROR: unknown line [%s]' % (fname, num, line.strip()))
elif args.check_address:
if perfile_pattern.match(stripped_line):
for addr in perfile_pattern.match(stripped_line).group(1).split(','):
diff --git a/tools/rbcrun/host.go b/tools/rbcrun/host.go
index 4915de9..c6e89f0 100644
--- a/tools/rbcrun/host.go
+++ b/tools/rbcrun/host.go
@@ -20,7 +20,6 @@
"os"
"os/exec"
"path/filepath"
- "regexp"
"strings"
"go.starlark.net/starlark"
@@ -125,23 +124,6 @@
return starlark.True, nil
}
-// regexMatch(pattern, s) returns True if s matches pattern (a regex)
-func regexMatch(_ *starlark.Thread, b *starlark.Builtin, args starlark.Tuple,
- kwargs []starlark.Tuple) (starlark.Value, error) {
- var pattern, s string
- if err := starlark.UnpackPositionalArgs(b.Name(), args, kwargs, 2, &pattern, &s); err != nil {
- return starlark.None, err
- }
- match, err := regexp.MatchString(pattern, s)
- if err != nil {
- return starlark.None, err
- }
- if match {
- return starlark.True, nil
- }
- return starlark.False, nil
-}
-
// wildcard(pattern, top=None) expands shell's glob pattern. If 'top' is present,
// the 'top/pattern' is globbed and then 'top/' prefix is removed.
func wildcard(_ *starlark.Thread, b *starlark.Builtin, args starlark.Tuple,
@@ -291,8 +273,6 @@
"rblf_file_exists": starlark.NewBuiltin("rblf_file_exists", fileExists),
// To convert find-copy-subdir and product-copy-files-by pattern
"rblf_find_files": starlark.NewBuiltin("rblf_find_files", find),
- // To convert makefile's $(filter ...)/$(filter-out)
- "rblf_regex": starlark.NewBuiltin("rblf_regex", regexMatch),
// To convert makefile's $(shell cmd)
"rblf_shell": starlark.NewBuiltin("rblf_shell", shell),
// Output to stderr
diff --git a/tools/rbcrun/host_test.go b/tools/rbcrun/host_test.go
index 3be5ee6..97f6ce9 100644
--- a/tools/rbcrun/host_test.go
+++ b/tools/rbcrun/host_test.go
@@ -147,10 +147,6 @@
}
}
-func TestRegex(t *testing.T) {
- exerciseStarlarkTestFile(t, "testdata/regex.star")
-}
-
func TestShell(t *testing.T) {
if err := os.Setenv("TEST_DATA_DIR", dataDir()); err != nil {
t.Fatal(err)
diff --git a/tools/rbcrun/testdata/regex.star b/tools/rbcrun/testdata/regex.star
deleted file mode 100644
index 04e1d42..0000000
--- a/tools/rbcrun/testdata/regex.star
+++ /dev/null
@@ -1,13 +0,0 @@
-# Tests rblf_regex
-load("assert.star", "assert")
-
-
-def test():
- pattern = "^(foo.*bar|abc.*d|1.*)$"
- for w in ("foobar", "fooxbar", "abcxd", "123"):
- assert.true(rblf_regex(pattern, w), "%s should match %s" % (w, pattern))
- for w in ("afoobar", "abcde"):
- assert.true(not rblf_regex(pattern, w), "%s should not match %s" % (w, pattern))
-
-
-test()