Merge "Support Android.bp in mgrep"
diff --git a/core/Makefile b/core/Makefile
index a1d483b..dc760b5 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -1139,7 +1139,8 @@
@echo Installed file list: $@
@mkdir -p $(dir $@)
@rm -f $@
- $(hide) build/tools/fileslist.py $(TARGET_OUT) > $@
+ $(hide) build/tools/fileslist.py $(TARGET_OUT) > $(@:.txt=.json)
+ $(hide) build/tools/fileslist_util.py -c $(@:.txt=.json) > $@
.PHONY: installed-file-list
installed-file-list: $(INSTALLED_FILES_FILE)
@@ -1575,7 +1576,8 @@
@echo Installed file list: $@
@mkdir -p $(dir $@)
@rm -f $@
- $(hide) build/tools/fileslist.py $(TARGET_OUT_VENDOR) > $@
+ $(hide) build/tools/fileslist.py $(TARGET_OUT_VENDOR) > $(@:.txt=.json)
+ $(hide) build/tools/fileslist_util.py -c $(@:.txt=.json) > $@
vendorimage_intermediates := \
$(call intermediates-dir-for,PACKAGING,vendor)
@@ -2027,6 +2029,15 @@
$(call dist-for-goals, target-files-package, $(BUILT_TARGET_FILES_PACKAGE))
endif
+# -----------------------------------------------------------------
+# NDK Sysroot Package
+NDK_SYSROOT_TARGET := $(PRODUCT_OUT)/ndk_sysroot.tar.bz2
+$(NDK_SYSROOT_TARGET): ndk
+ @echo Package NDK sysroot...
+ $(hide) tar cjf $@ -C $(SOONG_OUT_DIR) ndk
+
+$(call dist-for-goals,sdk,$(NDK_SYSROOT_TARGET))
+
ifeq ($(build_ota_package),true)
# -----------------------------------------------------------------
# OTA update package
diff --git a/core/binary.mk b/core/binary.mk
index c682d4e..8467876 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -58,7 +58,7 @@
my_export_c_include_dirs := $(LOCAL_EXPORT_C_INCLUDE_DIRS)
my_export_c_include_deps := $(LOCAL_EXPORT_C_INCLUDE_DEPS)
-ifneq (,$(foreach dir,$(COVERAGE_PATHS),$(filter $(dir)%,$(LOCAL_PATH))))
+ifneq (,$(strip $(foreach dir,$(subst $(comma),$(space),$(COVERAGE_PATHS)),$(filter $(dir)%,$(LOCAL_PATH)))))
my_native_coverage := true
else
my_native_coverage := false
@@ -159,7 +159,7 @@
my_ndk_stl_include_path :=
my_ndk_stl_shared_lib_fullpath :=
my_ndk_stl_static_lib :=
- my_ndk_stl_cppflags :=
+ my_ndk_cpp_std_version :=
my_cpu_variant := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)
ifeq (mips32r6,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH_VARIANT))
my_cpu_variant := mips32r6
@@ -235,7 +235,7 @@
my_ldlibs += -ldl
- my_ndk_stl_cppflags := -std=c++11
+ my_ndk_cpp_std_version := c++11
else # LOCAL_NDK_STL_VARIANT is not c++_* either
ifneq (,$(filter gnustl_%, $(LOCAL_NDK_STL_VARIANT)))
my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_GCC_VERSION)/libs/$(my_cpu_variant)/include \
@@ -367,30 +367,38 @@
my_clang := true
endif
-my_cpp_std_version := -std=gnu++14
+my_c_std_version := $(DEFAULT_C_STD_VERSION)
+my_cpp_std_version := $(DEFAULT_CPP_STD_VERSION)
ifneq ($(my_clang),true)
# GCC uses an invalid C++14 ABI (emits calls to
# __cxa_throw_bad_array_length, which is not a valid C++ RT ABI).
# http://b/25022512
- my_cpp_std_version := -std=gnu++11
+ my_cpp_std_version := $(DEFAULT_GCC_CPP_STD_VERSION)
endif
ifdef LOCAL_SDK_VERSION
# The NDK handles this itself.
- my_cpp_std_version :=
+ my_cpp_std_version := $(my_ndk_cpp_std_version)
endif
ifdef LOCAL_IS_HOST_MODULE
ifneq ($(my_clang),true)
# The host GCC doesn't support C++14 (and is deprecated, so likely
# never will). Build these modules with C++11.
- my_cpp_std_version := -std=gnu++11
+ my_cpp_std_version := $(DEFAULT_GCC_CPP_STD_VERSION)
endif
endif
-my_cppflags := $(my_cpp_std_version) $(my_cppflags)
+my_c_std_conlyflags :=
+my_cpp_std_cppflags :=
+ifneq (,$(my_c_std_version))
+ my_c_std_conlyflags := -std=$(my_c_std_version)
+endif
+ifneq (,$(my_cpp_std_version))
+ my_cpp_std_cppflags := -std=$(my_cpp_std_version)
+endif
# arch-specific static libraries go first so that generic ones can depend on them
my_static_libraries := $(LOCAL_STATIC_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_STATIC_LIBRARIES_$(my_32_64_bit_suffix)) $(my_static_libraries)
@@ -467,7 +475,6 @@
ifdef LOCAL_SDK_VERSION
my_target_global_c_includes :=
my_target_global_c_system_includes := $(my_ndk_stl_include_path) $(my_ndk_sysroot_include)
-my_target_global_cppflags := $(my_ndk_stl_cppflags)
else
my_target_global_c_includes := $(SRC_HEADERS) \
$($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)PROJECT_INCLUDES) \
@@ -475,18 +482,17 @@
my_target_global_c_system_includes := $(SRC_SYSTEM_HEADERS) \
$($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)PROJECT_SYSTEM_INCLUDES) \
$($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_SYSTEM_INCLUDES)
-my_target_global_cppflags :=
endif # LOCAL_SDK_VERSION
ifeq ($(my_clang),true)
my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CFLAGS)
-my_target_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CONLYFLAGS)
-my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CPPFLAGS)
+my_target_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CONLYFLAGS) $(my_c_std_conlyflags)
+my_target_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CPPFLAGS) $(my_cpp_std_cppflags)
my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_LDFLAGS)
else
my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CFLAGS)
-my_target_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CONLYFLAGS)
-my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CPPFLAGS)
+my_target_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CONLYFLAGS) $(my_c_std_conlyflags)
+my_target_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CPPFLAGS) $(my_cpp_std_cppflags)
my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_LDFLAGS)
endif # my_clang
@@ -508,13 +514,13 @@
ifeq ($(my_clang),true)
my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CFLAGS)
-my_host_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CONLYFLAGS)
-my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CPPFLAGS)
+my_host_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CONLYFLAGS) $(my_c_std_conlyflags)
+my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CPPFLAGS) $(my_cpp_std_cppflags)
my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_LDFLAGS)
else
my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CFLAGS)
-my_host_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CONLYFLAGS)
-my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CPPFLAGS)
+my_host_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CONLYFLAGS) $(my_c_std_conlyflags)
+my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CPPFLAGS) $(my_cpp_std_cppflags)
my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_LDFLAGS)
endif # my_clang
diff --git a/core/dex_preopt_libart.mk b/core/dex_preopt_libart.mk
index ab54b1d..7a0fb95 100644
--- a/core/dex_preopt_libart.mk
+++ b/core/dex_preopt_libart.mk
@@ -104,7 +104,8 @@
--instruction-set=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH) \
--instruction-set-variant=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT) \
--instruction-set-features=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES) \
- --include-patch-information --runtime-arg -Xnorelocate --no-generate-debug-info \
+ --include-patch-information --runtime-arg -Xnorelocate \
+ --no-generate-debug-info --generate-build-id \
--abort-on-hard-verifier-error \
--no-inline-from=core-oj.jar \
$(PRIVATE_DEX_PREOPT_FLAGS) \
diff --git a/core/dex_preopt_libart_boot.mk b/core/dex_preopt_libart_boot.mk
index c26b0fc..5d383a9 100644
--- a/core/dex_preopt_libart_boot.mk
+++ b/core/dex_preopt_libart_boot.mk
@@ -71,6 +71,7 @@
--instruction-set=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH) \
--instruction-set-variant=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT) \
--instruction-set-features=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES) \
- --android-root=$(PRODUCT_OUT)/system --include-patch-information --runtime-arg -Xnorelocate --no-generate-debug-info \
+ --android-root=$(PRODUCT_OUT)/system --include-patch-information --runtime-arg -Xnorelocate \
+ --no-generate-debug-info --generate-build-id \
--multi-image --no-inline-from=core-oj.jar \
$(PRODUCT_DEX_PREOPT_BOOT_FLAGS) $(GLOBAL_DEXPREOPT_FLAGS) $(COMPILED_CLASSES_FLAGS) $(ART_BOOT_IMAGE_EXTRA_ARGS)
diff --git a/target/board/generic/BoardConfig.mk b/target/board/generic/BoardConfig.mk
index 325b0ce..b471f9a 100644
--- a/target/board/generic/BoardConfig.mk
+++ b/target/board/generic/BoardConfig.mk
@@ -35,6 +35,7 @@
ifeq ($(HOST_OS),linux)
ifeq ($(WITH_DEXPREOPT),)
WITH_DEXPREOPT := true
+ WITH_DEXPREOPT_BOOT_IMG_ONLY := false
endif
endif
diff --git a/target/board/generic/sepolicy/goldfish_setup.te b/target/board/generic/sepolicy/goldfish_setup.te
index b8f121c..bc25967 100644
--- a/target/board/generic/sepolicy/goldfish_setup.te
+++ b/target/board/generic/sepolicy/goldfish_setup.te
@@ -12,6 +12,7 @@
allow goldfish_setup toolbox_exec:file rx_file_perms;
allow goldfish_setup self:capability { net_admin net_raw };
allow goldfish_setup self:udp_socket create_socket_perms;
+allowxperm goldfish_setup self:udp_socket ioctl priv_sock_ioctls;
net_domain(goldfish_setup)
diff --git a/target/board/generic_arm64/BoardConfig.mk b/target/board/generic_arm64/BoardConfig.mk
index 02d0a6f..34fffed 100644
--- a/target/board/generic_arm64/BoardConfig.mk
+++ b/target/board/generic_arm64/BoardConfig.mk
@@ -65,6 +65,7 @@
ifeq ($(HOST_OS),linux)
ifeq ($(WITH_DEXPREOPT),)
WITH_DEXPREOPT := true
+ WITH_DEXPREOPT_BOOT_IMG_ONLY := false
endif
endif
diff --git a/target/board/generic_mips/BoardConfig.mk b/target/board/generic_mips/BoardConfig.mk
index 1152105..b68d88b 100644
--- a/target/board/generic_mips/BoardConfig.mk
+++ b/target/board/generic_mips/BoardConfig.mk
@@ -42,6 +42,7 @@
ifeq ($(HOST_OS),linux)
ifeq ($(WITH_DEXPREOPT),)
WITH_DEXPREOPT := true
+ WITH_DEXPREOPT_BOOT_IMG_ONLY := false
endif
endif
diff --git a/target/board/generic_mips64/BoardConfig.mk b/target/board/generic_mips64/BoardConfig.mk
index ed9c9b3..44e6287 100644
--- a/target/board/generic_mips64/BoardConfig.mk
+++ b/target/board/generic_mips64/BoardConfig.mk
@@ -57,6 +57,7 @@
ifeq ($(HOST_OS),linux)
ifeq ($(WITH_DEXPREOPT),)
WITH_DEXPREOPT := true
+ WITH_DEXPREOPT_BOOT_IMG_ONLY := false
endif
endif
diff --git a/target/board/generic_x86/BoardConfig.mk b/target/board/generic_x86/BoardConfig.mk
index 50ecb98..f8ac496 100644
--- a/target/board/generic_x86/BoardConfig.mk
+++ b/target/board/generic_x86/BoardConfig.mk
@@ -22,6 +22,7 @@
# of an SDK AVD. Note that this operation only works on Linux for now
ifeq ($(HOST_OS),linux)
WITH_DEXPREOPT ?= true
+WITH_DEXPREOPT_BOOT_IMG_ONLY ?= false
endif
# Build OpenGLES emulation host and guest libraries
diff --git a/target/board/generic_x86_64/BoardConfig.mk b/target/board/generic_x86_64/BoardConfig.mk
index 6958ba5..bd831f8 100755
--- a/target/board/generic_x86_64/BoardConfig.mk
+++ b/target/board/generic_x86_64/BoardConfig.mk
@@ -28,6 +28,7 @@
# of an SDK AVD. Note that this operation only works on Linux for now
ifeq ($(HOST_OS),linux)
WITH_DEXPREOPT ?= true
+WITH_DEXPREOPT_BOOT_IMG_ONLY ?= false
endif
# Build OpenGLES emulation host and guest libraries
diff --git a/target/board/generic_x86_arm/BoardConfig.mk b/target/board/generic_x86_arm/BoardConfig.mk
index 6e2573e..75207fc 100644
--- a/target/board/generic_x86_arm/BoardConfig.mk
+++ b/target/board/generic_x86_arm/BoardConfig.mk
@@ -39,6 +39,7 @@
ifeq ($(HOST_OS),linux)
ifeq ($(WITH_DEXPREOPT),)
WITH_DEXPREOPT := true
+ WITH_DEXPREOPT_BOOT_IMG_ONLY := false
endif
endif
diff --git a/tools/fat16copy.py b/tools/fat16copy.py
index 1dd15b7..af8bd83 100755
--- a/tools/fat16copy.py
+++ b/tools/fat16copy.py
@@ -222,7 +222,8 @@
data.seek(0, os.SEEK_END)
size = data.tell()
- chunk = self.backing.fs.allocate(size or 1)
+ # Empty files shouldn't have any clusters assigned.
+ chunk = self.backing.fs.allocate(size) if size > 0 else 0
(shortname, ext) = self.make_short_name(name)
self.add_dentry(0, shortname, ext, name, chunk, size)
@@ -240,10 +241,19 @@
"""
chunk = self.backing.fs.allocate(1)
(shortname, ext) = self.make_short_name(name)
- new_dentry = dentry(self.backing.fs, ATTRIBUTE_SUBDIRECTORY,
- shortname, ext, name, chunk, 0)
- new_dentry.commit(self.backing)
- return new_dentry.open_directory()
+ new_dentry = self.add_dentry(ATTRIBUTE_SUBDIRECTORY, shortname,
+ ext, name, chunk, 0)
+ result = new_dentry.open_directory()
+
+ parent_cluster = 0
+
+ if hasattr(self.backing, 'start_cluster'):
+ parent_cluster = self.backing.start_cluster
+
+ result.add_dentry(ATTRIBUTE_SUBDIRECTORY, '.', '', '', chunk, 0)
+ result.add_dentry(ATTRIBUTE_SUBDIRECTORY, '..', '', '', parent_cluster, 0)
+
+ return result
def lfn_checksum(name_data):
"""
@@ -380,28 +390,23 @@
record_count = len(longname_record_data) + 1
found_count = 0
-
- while True:
+ while found_count < record_count:
record = f.read(32)
if record is None or len(record) != 32:
- break
+ # We reached the EOF, so we need to extend the file with a new cluster.
+ f.write("\0" * self.fs.bytes_per_cluster)
+ f.seek(-self.fs.bytes_per_cluster, os.SEEK_CUR)
+ record = f.read(32)
marker = struct.unpack("B", record[0])[0]
if marker == DEL_MARKER or marker == 0:
found_count += 1
-
- if found_count == record_count:
- break
else:
found_count = 0
- if found_count != record_count:
- f.write("\0" * self.fs.bytes_per_cluster)
- f.seek(-self.fs.bytes_per_cluster, os.SEEK_CUR)
- else:
- f.seek(-(record_count * 32), os.SEEK_CUR)
+ f.seek(-(record_count * 32), os.SEEK_CUR)
f.write(entry)
class root_dentry_file(fake_file):
@@ -624,6 +629,8 @@
Allocate a new cluster chain big enough to hold at least the given amount
of bytes.
"""
+ assert amount > 0, "Must allocate a non-zero amount."
+
f = self.f
f.seek(FAT_TABLE_START + 4)
@@ -686,38 +693,17 @@
Given a cluster which is the *last* cluster in a chain, extend it to hold
at least `amount` more bytes.
"""
- return_cluster = None
+ if amount == 0:
+ return
f = self.f
-
- position = FAT_TABLE_START + cluster * 2
- f.seek(position)
-
+ entry_offset = FAT_TABLE_START + cluster * 2
+ f.seek(entry_offset)
assert read_le_short(f) == 0xFFFF, "Extending from middle of chain"
- rewind_short(f)
- while position + 2 < FAT_TABLE_START + self.fat_size and amount > 0:
- skip_short(f)
- got = read_le_short(f)
- rewind_short(f)
- rewind_short(f)
-
- if got != 0:
- break
-
- cluster += 1
- return_cluster = return_cluster or cluster
- position += 2
- self.write_cluster_entry(cluster)
-
- if amount < 0:
- self.write_cluster_entry(0xFFFF)
- return return_cluster
-
- new_chunk = self.allocate(amount)
- f.seek(FAT_TABLE_START + cluster * 2)
- self.write_cluster_entry(new_chunk)
-
- return return_cluster or new_chunk
+ return_cluster = self.allocate(amount)
+ f.seek(entry_offset)
+ self.write_cluster_entry(return_cluster)
+ return return_cluster
def write_file(self, head_cluster, start_byte, data):
"""
@@ -728,35 +714,31 @@
data: The data to write.
"""
f = self.f
+ last_offset = start_byte + len(data)
+ current_offset = 0
+ current_cluster = head_cluster
- while True:
- if start_byte < self.bytes_per_cluster:
- to_write = data[:self.bytes_per_cluster - start_byte]
- data = data[self.bytes_per_cluster - start_byte:]
+ while current_offset < last_offset:
+ # Write everything that falls in the cluster starting at current_offset.
+ data_begin = max(0, current_offset - start_byte)
+ data_end = min(len(data),
+ current_offset + self.bytes_per_cluster - start_byte)
+ if data_end > data_begin:
+ cluster_file_offset = (self.data_start() + self.root_entries * 32 +
+ (current_cluster - 2) * self.bytes_per_cluster)
+ f.seek(cluster_file_offset + max(0, start_byte - current_offset))
+ f.write(data[data_begin:data_end])
- cluster_bytes_from_root = (head_cluster - 2) * \
- self.bytes_per_cluster
- bytes_from_root = cluster_bytes_from_root + start_byte
- bytes_from_data_start = bytes_from_root + self.root_entries * 32
+ # Advance to the next cluster in the chain or get a new cluster if needed.
+ current_offset += self.bytes_per_cluster
+ if last_offset > current_offset:
+ f.seek(FAT_TABLE_START + current_cluster * 2)
+ next_cluster = read_le_short(f)
+ if next_cluster > MAX_CLUSTER_ID:
+ next_cluster = self.extend_cluster(current_cluster, len(data))
+ current_cluster = next_cluster
+ assert current_cluster > 0, "Cannot write free cluster"
- f.seek(self.data_start() + bytes_from_data_start)
- f.write(to_write)
-
- if len(data) == 0:
- return
-
- start_byte -= self.bytes_per_cluster
-
- if start_byte < 0:
- start_byte = 0
-
- f.seek(FAT_TABLE_START + head_cluster * 2)
- next_cluster = read_le_short(f)
- if next_cluster > MAX_CLUSTER_ID:
- head_cluster = self.extend_cluster(head_cluster, len(data))
- else:
- head_cluster = next_cluster
- assert head_cluster > 0, "Cannot write free cluster"
def add_item(directory, item):
"""
@@ -770,7 +752,7 @@
if len(base) == 0:
base = os.path.basename(item[:-1])
sub = directory.new_subdirectory(base)
- for next_item in os.listdir(item):
+ for next_item in sorted(os.listdir(item)):
add_item(sub, os.path.join(item, next_item))
else:
with open(item, 'rb') as f:
diff --git a/tools/fileslist.py b/tools/fileslist.py
index a11efaa..b9e7350 100755
--- a/tools/fileslist.py
+++ b/tools/fileslist.py
@@ -15,12 +15,24 @@
# limitations under the License.
#
-import operator, os, sys
+import json, hashlib, operator, os, sys
def get_file_size(path):
st = os.lstat(path)
return st.st_size;
+def get_file_digest(path):
+ if os.path.isfile(path) == False:
+ return "----------------------------------------------------------------"
+ digest = hashlib.sha256()
+ with open(path, 'rb') as f:
+ while True:
+ buf = f.read(1024*1024)
+ if not buf:
+ break
+ digest.update(buf)
+ return digest.hexdigest();
+
def main(argv):
output = []
roots = argv[1:]
@@ -30,16 +42,17 @@
relative = dir[base:]
for f in files:
try:
- row = (
- get_file_size(os.path.sep.join((dir, f))),
- os.path.sep.join((relative, f)),
- )
+ path = os.path.sep.join((dir, f))
+ row = {
+ "Size": get_file_size(path),
+ "Name": os.path.sep.join((relative, f)),
+ "SHA256": get_file_digest(path),
+ }
output.append(row)
except os.error:
pass
- output.sort(key=operator.itemgetter(0), reverse=True)
- for row in output:
- print "%12d %s" % row
+ output.sort(key=operator.itemgetter("Size", "Name"), reverse=True)
+ print json.dumps(output, indent=2, separators=(',',': '))
if __name__ == '__main__':
main(sys.argv)
diff --git a/tools/fileslist_util.py b/tools/fileslist_util.py
new file mode 100755
index 0000000..ff40d51
--- /dev/null
+++ b/tools/fileslist_util.py
@@ -0,0 +1,68 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2016 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.
+#
+
+import getopt, json, sys
+
+def PrintFileNames(path):
+ with open(path) as jf:
+ data = json.load(jf)
+ for line in data:
+ print(line["Name"])
+
+def PrintCanonicalList(path):
+ with open(path) as jf:
+ data = json.load(jf)
+ for line in data:
+ print "{0:12d} {1}".format(line["Size"], line["Name"])
+
+def PrintUsage(name):
+ print("""
+Usage: %s -[nc] json_files_list
+ -n produces list of files only
+ -c produces classic installed-files.txt
+""" % (name))
+
+def main(argv):
+ try:
+ opts, args = getopt.getopt(argv[1:], "nc", "")
+ except getopt.GetoptError, err:
+ print(err)
+ PrintUsage(argv[0])
+ sys.exit(2)
+
+ if len(opts) == 0:
+ print("No conversion option specified")
+ PrintUsage(argv[0])
+ sys.exit(2)
+
+ if len(args) == 0:
+ print("No input file specified")
+ PrintUsage(argv[0])
+ sys.exit(2)
+
+ for o, a in opts:
+ if o == ("-n"):
+ PrintFileNames(args[0])
+ sys.exit()
+ elif o == ("-c"):
+ PrintCanonicalList(args[0])
+ sys.exit()
+ else:
+ assert False, "Unsupported option"
+
+if __name__ == '__main__':
+ main(sys.argv)
diff --git a/tools/warn.py b/tools/warn.py
index 3c75825..45ffda0 100755
--- a/tools/warn.py
+++ b/tools/warn.py
@@ -81,6 +81,7 @@
# dump_csv():
import argparse
+import multiprocessing
import os
import re
@@ -99,6 +100,10 @@
parser.add_argument('--separator',
help='Separator between the end of a URL and the line '
'number argument. e.g. #')
+parser.add_argument('--processes',
+ type=int,
+ default=multiprocessing.cpu_count(),
+ help='Number of parallel processes to process warnings')
parser.add_argument(dest='buildlog', metavar='build.log',
help='Path to build.log file')
args = parser.parse_args()
@@ -1696,14 +1701,47 @@
simple_project_pattern('frameworks/av/cmds'),
simple_project_pattern('frameworks/av/drm'),
simple_project_pattern('frameworks/av/include'),
- simple_project_pattern('frameworks/av/media'),
+ simple_project_pattern('frameworks/av/media/common_time'),
+ simple_project_pattern('frameworks/av/media/img_utils'),
+ simple_project_pattern('frameworks/av/media/libcpustats'),
+ simple_project_pattern('frameworks/av/media/libeffects'),
+ simple_project_pattern('frameworks/av/media/libmediaplayerservice'),
+ simple_project_pattern('frameworks/av/media/libmedia'),
+ simple_project_pattern('frameworks/av/media/libstagefright'),
+ simple_project_pattern('frameworks/av/media/mtp'),
+ simple_project_pattern('frameworks/av/media/ndk'),
+ simple_project_pattern('frameworks/av/media/utils'),
+ project_name_and_pattern('frameworks/av/media/Other',
+ 'frameworks/av/media'),
simple_project_pattern('frameworks/av/radio'),
simple_project_pattern('frameworks/av/services'),
+ simple_project_pattern('frameworks/av/soundtrigger'),
project_name_and_pattern('frameworks/av/Other', 'frameworks/av'),
- simple_project_pattern('frameworks/base'),
- simple_project_pattern('frameworks/compile'),
+ simple_project_pattern('frameworks/base/cmds'),
+ simple_project_pattern('frameworks/base/core'),
+ simple_project_pattern('frameworks/base/drm'),
+ simple_project_pattern('frameworks/base/media'),
+ simple_project_pattern('frameworks/base/libs'),
+ simple_project_pattern('frameworks/base/native'),
+ simple_project_pattern('frameworks/base/packages'),
+ simple_project_pattern('frameworks/base/rs'),
+ simple_project_pattern('frameworks/base/services'),
+ simple_project_pattern('frameworks/base/tests'),
+ simple_project_pattern('frameworks/base/tools'),
+ project_name_and_pattern('frameworks/base/Other', 'frameworks/base'),
+ simple_project_pattern('frameworks/compile/libbcc'),
+ simple_project_pattern('frameworks/compile/mclinker'),
+ simple_project_pattern('frameworks/compile/slang'),
+ project_name_and_pattern('frameworks/compile/Other', 'frameworks/compile'),
simple_project_pattern('frameworks/minikin'),
- simple_project_pattern('frameworks/native'),
+ simple_project_pattern('frameworks/ml'),
+ simple_project_pattern('frameworks/native/cmds'),
+ simple_project_pattern('frameworks/native/include'),
+ simple_project_pattern('frameworks/native/libs'),
+ simple_project_pattern('frameworks/native/opengl'),
+ simple_project_pattern('frameworks/native/services'),
+ simple_project_pattern('frameworks/native/vulkan'),
+ project_name_and_pattern('frameworks/native/Other', 'frameworks/native'),
simple_project_pattern('frameworks/opt'),
simple_project_pattern('frameworks/rs'),
simple_project_pattern('frameworks/webview'),
@@ -1730,16 +1768,58 @@
simple_project_pattern('prebuilts'),
simple_project_pattern('system/bt'),
simple_project_pattern('system/connectivity'),
- simple_project_pattern('system/core'),
- simple_project_pattern('system/extras'),
+ simple_project_pattern('system/core/adb'),
+ simple_project_pattern('system/core/base'),
+ simple_project_pattern('system/core/debuggerd'),
+ simple_project_pattern('system/core/fastboot'),
+ simple_project_pattern('system/core/fingerprintd'),
+ simple_project_pattern('system/core/fs_mgr'),
+ simple_project_pattern('system/core/gatekeeperd'),
+ simple_project_pattern('system/core/healthd'),
+ simple_project_pattern('system/core/include'),
+ simple_project_pattern('system/core/init'),
+ simple_project_pattern('system/core/libbacktrace'),
+ simple_project_pattern('system/core/liblog'),
+ simple_project_pattern('system/core/libpixelflinger'),
+ simple_project_pattern('system/core/libprocessgroup'),
+ simple_project_pattern('system/core/libsysutils'),
+ simple_project_pattern('system/core/logcat'),
+ simple_project_pattern('system/core/logd'),
+ simple_project_pattern('system/core/run-as'),
+ simple_project_pattern('system/core/sdcard'),
+ simple_project_pattern('system/core/toolbox'),
+ project_name_and_pattern('system/core/Other', 'system/core'),
+ simple_project_pattern('system/extras/ANRdaemon'),
+ simple_project_pattern('system/extras/cpustats'),
+ simple_project_pattern('system/extras/crypto-perf'),
+ simple_project_pattern('system/extras/ext4_utils'),
+ simple_project_pattern('system/extras/f2fs_utils'),
+ simple_project_pattern('system/extras/iotop'),
+ simple_project_pattern('system/extras/libfec'),
+ simple_project_pattern('system/extras/memory_replay'),
+ simple_project_pattern('system/extras/micro_bench'),
+ simple_project_pattern('system/extras/mmap-perf'),
+ simple_project_pattern('system/extras/multinetwork'),
+ simple_project_pattern('system/extras/perfprofd'),
+ simple_project_pattern('system/extras/procrank'),
+ simple_project_pattern('system/extras/runconuid'),
+ simple_project_pattern('system/extras/showmap'),
+ simple_project_pattern('system/extras/simpleperf'),
+ simple_project_pattern('system/extras/su'),
+ simple_project_pattern('system/extras/tests'),
+ simple_project_pattern('system/extras/verity'),
+ project_name_and_pattern('system/extras/Other', 'system/extras'),
simple_project_pattern('system/gatekeeper'),
simple_project_pattern('system/keymaster'),
+ simple_project_pattern('system/libhidl'),
simple_project_pattern('system/libhwbinder'),
simple_project_pattern('system/media'),
simple_project_pattern('system/netd'),
+ simple_project_pattern('system/nvram'),
simple_project_pattern('system/security'),
simple_project_pattern('system/sepolicy'),
simple_project_pattern('system/tools'),
+ simple_project_pattern('system/update_engine'),
simple_project_pattern('system/vold'),
project_name_and_pattern('system/Other', 'system'),
simple_project_pattern('toolchain'),
@@ -1991,22 +2071,13 @@
return -1
-def classify_warning(line):
+def classify_one_warning(line, results):
for i in range(len(warn_patterns)):
w = warn_patterns[i]
for cpat in w['compiled_patterns']:
if cpat.match(line):
- w['members'].append(line)
p = find_project_index(line)
- index = len(warning_messages)
- warning_messages.append(line)
- warning_records.append([i, p, index])
- pname = '???' if p < 0 else project_names[p]
- # Count warnings by project.
- if pname in w['projects']:
- w['projects'][pname] += 1
- else:
- w['projects'][pname] = 1
+ results.append([line, i, p])
return
else:
# If we end up here, there was a problem parsing the log
@@ -2015,6 +2086,38 @@
pass
+def classify_warnings(lines):
+ results = []
+ for line in lines:
+ classify_one_warning(line, results)
+ return results
+
+
+def parallel_classify_warnings(warning_lines):
+ """Classify all warning lines with num_cpu parallel processes."""
+ num_cpu = args.processes
+ groups = [[] for x in range(num_cpu)]
+ i = 0
+ for x in warning_lines:
+ groups[i].append(x)
+ i = (i + 1) % num_cpu
+ pool = multiprocessing.Pool(num_cpu)
+ group_results = pool.map(classify_warnings, groups)
+ for result in group_results:
+ for line, pattern_idx, project_idx in result:
+ pattern = warn_patterns[pattern_idx]
+ pattern['members'].append(line)
+ message_idx = len(warning_messages)
+ warning_messages.append(line)
+ warning_records.append([pattern_idx, project_idx, message_idx])
+ pname = '???' if project_idx < 0 else project_names[project_idx]
+ # Count warnings by project.
+ if pname in pattern['projects']:
+ pattern['projects'][pname] += 1
+ else:
+ pattern['projects'][pname] = 1
+
+
def compile_patterns():
"""Precompiling every pattern speeds up parsing by about 30x."""
for i in warn_patterns:
@@ -2082,14 +2185,12 @@
warning_pattern = re.compile('^[^ ]*/[^ ]*: warning: .*')
compile_patterns()
- # read the log file and classify all the warnings
+ # Collect all warnings into the warning_lines set.
warning_lines = set()
for line in infile:
if warning_pattern.match(line):
line = normalize_warning_line(line)
- if line not in warning_lines:
- classify_warning(line)
- warning_lines.add(line)
+ warning_lines.add(line)
elif line_counter < 50:
# save a little bit of time by only doing this for the first few lines
line_counter += 1
@@ -2102,6 +2203,7 @@
m = re.search('(?<=^TARGET_BUILD_VARIANT=).*', line)
if m is not None:
target_variant = m.group(0)
+ parallel_classify_warnings(warning_lines)
# Return s with escaped backslash and quotation characters.
diff --git a/tools/zipalign/ZipAlign.cpp b/tools/zipalign/ZipAlign.cpp
index aef91a5..d56ac29 100644
--- a/tools/zipalign/ZipAlign.cpp
+++ b/tools/zipalign/ZipAlign.cpp
@@ -19,8 +19,9 @@
*/
#include "ZipFile.h"
-#include <stdlib.h>
#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
using namespace android;
diff --git a/tools/zipalign/ZipEntry.cpp b/tools/zipalign/ZipEntry.cpp
index a9c2d33..63d75d1 100644
--- a/tools/zipalign/ZipEntry.cpp
+++ b/tools/zipalign/ZipEntry.cpp
@@ -23,10 +23,11 @@
#include "ZipEntry.h"
#include <utils/Log.h>
-#include <stdio.h>
-#include <string.h>
#include <assert.h>
#include <inttypes.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
using namespace android;