diff options
-rwxr-xr-x | tools/gen_amalgamated | 8 | ||||
-rwxr-xr-x | tools/gen_android_bp | 21 | ||||
-rwxr-xr-x | tools/gen_bazel | 10 | ||||
-rwxr-xr-x | tools/gen_merged_protos | 153 | ||||
-rwxr-xr-x | tools/gen_tracing_cpp_headers_from_protos | 47 | ||||
-rwxr-xr-x | tools/heap_profile | 7 | ||||
-rwxr-xr-x | tools/install-build-deps | 437 | ||||
-rwxr-xr-x | tools/run_test_like_ci | 85 | ||||
-rwxr-xr-x | tools/trace_processor | 13 | ||||
-rwxr-xr-x | tools/traceconv | 13 |
10 files changed, 361 insertions, 433 deletions
diff --git a/tools/gen_amalgamated b/tools/gen_amalgamated index e7892b5c1..dcce1fbb0 100755 --- a/tools/gen_amalgamated +++ b/tools/gen_amalgamated @@ -353,8 +353,8 @@ class AmalgamatedProject(object): try: self.source.extend( self._patch_source( - source_name, self._process_source_includes( - include_dirs, deps, f))) + source_name, + self._process_source_includes(include_dirs, deps, f))) except Error as e: raise Error('Failed adding source %s: %s' % (source_name, e.message)) @@ -498,8 +498,8 @@ Build settings: Example build command: %s -""" % (header_file, source_file, ' '.join(self.cflags), ' '.join(self.ldflags), - ' '.join(self.libs), ' '.join(build_cmd)) +""" % (header_file, source_file, ' '.join(self.cflags), ' '.join( + self.ldflags), ' '.join(self.libs), ' '.join(build_cmd)) def get_build_command(self, output_prefix): """Returns an example command line for building the output source.""" diff --git a/tools/gen_android_bp b/tools/gen_android_bp index dd7d2c442..86aa750aa 100755 --- a/tools/gen_android_bp +++ b/tools/gen_android_bp @@ -147,8 +147,9 @@ additional_args = { ('header_libs', {'bionic_libc_platform_headers'}), ], 'perfetto_unittests': [('data', set(enumerate_data_deps())),], - 'traced_probes': [('required', - {'libperfetto_android_internal', 'trigger_perfetto'}),], + 'traced_probes': [ + ('required', {'libperfetto_android_internal', 'trigger_perfetto'}), + ], 'libperfetto_android_internal': [('static_libs', {'libhealthhalutils'}),], } @@ -496,12 +497,12 @@ def create_proto_modules(blueprint, gn, target): header_module.tools = tools for sfx in suffixes: - source_module.out.update( - '%s/%s' % (tree_path, src.replace('.proto', '.%s.cc' % sfx)) - for src in source_module.srcs) - header_module.out.update( - '%s/%s' % (tree_path, src.replace('.proto', '.%s.h' % sfx)) - for src in header_module.srcs) + source_module.out.update('%s/%s' % + (tree_path, src.replace('.proto', '.%s.cc' % sfx)) + for src in source_module.srcs) + header_module.out.update('%s/%s' % + (tree_path, src.replace('.proto', '.%s.h' % sfx)) + for src in header_module.srcs) return source_module @@ -702,8 +703,8 @@ def main(): action='store_true') parser.add_argument( '--desc', - help= - 'GN description (e.g., gn desc out --format=json --all-toolchains "//*"') + help='GN description (e.g., gn desc out --format=json --all-toolchains "//*"' + ) parser.add_argument( '--extras', help='Extra targets to include at the end of the Blueprint file', diff --git a/tools/gen_bazel b/tools/gen_bazel index f10ac3b58..dba8d8da6 100755 --- a/tools/gen_bazel +++ b/tools/gen_bazel @@ -97,9 +97,9 @@ external_deps = { ], '//gn:zlib': ['PERFETTO_CONFIG.deps.zlib'], '//gn/standalone:gen_git_revision': [], - '//src/trace_processor/metrics:gen_merged_sql_metrics': [ - [":cc_merged_sql_metrics"] - ] + '//src/trace_processor/metrics:gen_merged_sql_metrics': [[ + ":cc_merged_sql_metrics" + ]] } @@ -143,8 +143,8 @@ class BazelLabel(object): if isinstance(other, self.__class__): return self.name < other.name raise TypeError( - '\'<\' not supported between instances of \'%s\' and \'%s\'' % ( - type(self).__name__, type(other).__name__)) + '\'<\' not supported between instances of \'%s\' and \'%s\'' % + (type(self).__name__, type(other).__name__)) def __str__(self): """Converts the object into a Bazel Starlark label.""" diff --git a/tools/gen_merged_protos b/tools/gen_merged_protos index 0603ae347..2530e7144 100755 --- a/tools/gen_merged_protos +++ b/tools/gen_merged_protos @@ -22,89 +22,89 @@ import sys from codecs import open COMMON_PROTOS = ( - 'protos/perfetto/common/android_log_constants.proto', - 'protos/perfetto/common/data_source_descriptor.proto', - 'protos/perfetto/common/gpu_counter_descriptor.proto', - 'protos/perfetto/common/sys_stats_counters.proto', - 'protos/perfetto/common/trace_stats.proto', - 'protos/perfetto/common/tracing_service_state.proto', - 'protos/perfetto/common/track_event_descriptor.proto', + 'protos/perfetto/common/android_log_constants.proto', + 'protos/perfetto/common/data_source_descriptor.proto', + 'protos/perfetto/common/gpu_counter_descriptor.proto', + 'protos/perfetto/common/sys_stats_counters.proto', + 'protos/perfetto/common/trace_stats.proto', + 'protos/perfetto/common/tracing_service_state.proto', + 'protos/perfetto/common/track_event_descriptor.proto', ) CONFIG_PROTOS = ( - 'protos/perfetto/config/android/android_log_config.proto', - 'protos/perfetto/config/chrome/chrome_config.proto', - 'protos/perfetto/config/data_source_config.proto', - 'protos/perfetto/config/ftrace/ftrace_config.proto', - 'protos/perfetto/config/inode_file/inode_file_config.proto', - 'protos/perfetto/config/power/android_power_config.proto', - 'protos/perfetto/config/process_stats/process_stats_config.proto', - 'protos/perfetto/config/sys_stats/sys_stats_config.proto', - 'protos/perfetto/config/test_config.proto', - 'protos/perfetto/config/trace_config.proto', - 'protos/perfetto/config/profiling/heapprofd_config.proto', - 'protos/perfetto/config/profiling/java_hprof_config.proto', - 'protos/perfetto/config/gpu/gpu_counter_config.proto', - 'protos/perfetto/config/android/packages_list_config.proto', + 'protos/perfetto/config/android/android_log_config.proto', + 'protos/perfetto/config/chrome/chrome_config.proto', + 'protos/perfetto/config/data_source_config.proto', + 'protos/perfetto/config/ftrace/ftrace_config.proto', + 'protos/perfetto/config/inode_file/inode_file_config.proto', + 'protos/perfetto/config/power/android_power_config.proto', + 'protos/perfetto/config/process_stats/process_stats_config.proto', + 'protos/perfetto/config/sys_stats/sys_stats_config.proto', + 'protos/perfetto/config/test_config.proto', + 'protos/perfetto/config/trace_config.proto', + 'protos/perfetto/config/profiling/heapprofd_config.proto', + 'protos/perfetto/config/profiling/java_hprof_config.proto', + 'protos/perfetto/config/gpu/gpu_counter_config.proto', + 'protos/perfetto/config/android/packages_list_config.proto', ) MERGED_CONFIG_PROTO = 'protos/perfetto/config/perfetto_config.proto' TRACE_PROTOS = ( - 'protos/perfetto/trace/android/android_log.proto', - 'protos/perfetto/trace/android/graphics_frame_event.proto', - 'protos/perfetto/trace/android/packages_list.proto', - 'protos/perfetto/trace/chrome/chrome_benchmark_metadata.proto', - "protos/perfetto/trace/chrome/chrome_metadata.proto", - 'protos/perfetto/trace/clock_snapshot.proto', - 'protos/perfetto/trace/filesystem/inode_file_map.proto', - 'protos/perfetto/trace/ftrace/binder.proto', - 'protos/perfetto/trace/ftrace/block.proto', - 'protos/perfetto/trace/ftrace/clk.proto', - 'protos/perfetto/trace/ftrace/ext4.proto', - 'protos/perfetto/trace/ftrace/f2fs.proto', - 'protos/perfetto/trace/ftrace/filemap.proto', - 'protos/perfetto/trace/ftrace/ftrace.proto', - 'protos/perfetto/trace/ftrace/ftrace_event.proto', - 'protos/perfetto/trace/ftrace/ftrace_event_bundle.proto', - 'protos/perfetto/trace/ftrace/ftrace_stats.proto', - 'protos/perfetto/trace/ftrace/generic.proto', - 'protos/perfetto/trace/ftrace/kmem.proto', - 'protos/perfetto/trace/ftrace/lowmemorykiller.proto', - 'protos/perfetto/trace/ftrace/mm_event.proto', - 'protos/perfetto/trace/ftrace/power.proto', - 'protos/perfetto/trace/ftrace/raw_syscalls.proto', - 'protos/perfetto/trace/ftrace/sched.proto', - 'protos/perfetto/trace/ftrace/signal.proto', - 'protos/perfetto/trace/ftrace/systrace.proto', - 'protos/perfetto/trace/ftrace/task.proto', - 'protos/perfetto/trace/ftrace/vmscan.proto', - 'protos/perfetto/trace/interned_data/interned_data.proto', - 'protos/perfetto/trace/perfetto/perfetto_metatrace.proto', - 'protos/perfetto/trace/power/battery_counters.proto', - 'protos/perfetto/trace/power/power_rails.proto', - 'protos/perfetto/trace/profiling/heap_graph.proto', - 'protos/perfetto/trace/profiling/profile_common.proto', - 'protos/perfetto/trace/profiling/profile_packet.proto', - 'protos/perfetto/trace/ps/process_stats.proto', - 'protos/perfetto/trace/ps/process_tree.proto', - 'protos/perfetto/trace/sys_stats/sys_stats.proto', - 'protos/perfetto/trace/system_info.proto', - 'protos/perfetto/trace/trace.proto', - 'protos/perfetto/trace/trace_packet.proto', - 'protos/perfetto/trace/trace_packet_defaults.proto', - 'protos/perfetto/trace/track_event/debug_annotation.proto', - 'protos/perfetto/trace/track_event/log_message.proto', - 'protos/perfetto/trace/track_event/process_descriptor.proto', - 'protos/perfetto/trace/track_event/source_location.proto', - 'protos/perfetto/trace/track_event/task_execution.proto', - 'protos/perfetto/trace/track_event/thread_descriptor.proto', - 'protos/perfetto/trace/track_event/track_descriptor.proto', - 'protos/perfetto/trace/track_event/track_event.proto', - 'protos/perfetto/trace/trigger.proto', - 'protos/perfetto/trace/gpu/gpu_counter_event.proto', - 'protos/perfetto/trace/gpu/gpu_log.proto', - 'protos/perfetto/trace/gpu/gpu_render_stage_event.proto', + 'protos/perfetto/trace/android/android_log.proto', + 'protos/perfetto/trace/android/graphics_frame_event.proto', + 'protos/perfetto/trace/android/packages_list.proto', + 'protos/perfetto/trace/chrome/chrome_benchmark_metadata.proto', + "protos/perfetto/trace/chrome/chrome_metadata.proto", + 'protos/perfetto/trace/clock_snapshot.proto', + 'protos/perfetto/trace/filesystem/inode_file_map.proto', + 'protos/perfetto/trace/ftrace/binder.proto', + 'protos/perfetto/trace/ftrace/block.proto', + 'protos/perfetto/trace/ftrace/clk.proto', + 'protos/perfetto/trace/ftrace/ext4.proto', + 'protos/perfetto/trace/ftrace/f2fs.proto', + 'protos/perfetto/trace/ftrace/filemap.proto', + 'protos/perfetto/trace/ftrace/ftrace.proto', + 'protos/perfetto/trace/ftrace/ftrace_event.proto', + 'protos/perfetto/trace/ftrace/ftrace_event_bundle.proto', + 'protos/perfetto/trace/ftrace/ftrace_stats.proto', + 'protos/perfetto/trace/ftrace/generic.proto', + 'protos/perfetto/trace/ftrace/kmem.proto', + 'protos/perfetto/trace/ftrace/lowmemorykiller.proto', + 'protos/perfetto/trace/ftrace/mm_event.proto', + 'protos/perfetto/trace/ftrace/power.proto', + 'protos/perfetto/trace/ftrace/raw_syscalls.proto', + 'protos/perfetto/trace/ftrace/sched.proto', + 'protos/perfetto/trace/ftrace/signal.proto', + 'protos/perfetto/trace/ftrace/systrace.proto', + 'protos/perfetto/trace/ftrace/task.proto', + 'protos/perfetto/trace/ftrace/vmscan.proto', + 'protos/perfetto/trace/interned_data/interned_data.proto', + 'protos/perfetto/trace/perfetto/perfetto_metatrace.proto', + 'protos/perfetto/trace/power/battery_counters.proto', + 'protos/perfetto/trace/power/power_rails.proto', + 'protos/perfetto/trace/profiling/heap_graph.proto', + 'protos/perfetto/trace/profiling/profile_common.proto', + 'protos/perfetto/trace/profiling/profile_packet.proto', + 'protos/perfetto/trace/ps/process_stats.proto', + 'protos/perfetto/trace/ps/process_tree.proto', + 'protos/perfetto/trace/sys_stats/sys_stats.proto', + 'protos/perfetto/trace/system_info.proto', + 'protos/perfetto/trace/trace.proto', + 'protos/perfetto/trace/trace_packet.proto', + 'protos/perfetto/trace/trace_packet_defaults.proto', + 'protos/perfetto/trace/track_event/debug_annotation.proto', + 'protos/perfetto/trace/track_event/log_message.proto', + 'protos/perfetto/trace/track_event/process_descriptor.proto', + 'protos/perfetto/trace/track_event/source_location.proto', + 'protos/perfetto/trace/track_event/task_execution.proto', + 'protos/perfetto/trace/track_event/thread_descriptor.proto', + 'protos/perfetto/trace/track_event/track_descriptor.proto', + 'protos/perfetto/trace/track_event/track_event.proto', + 'protos/perfetto/trace/trigger.proto', + 'protos/perfetto/trace/gpu/gpu_counter_event.proto', + 'protos/perfetto/trace/gpu/gpu_log.proto', + 'protos/perfetto/trace/gpu/gpu_render_stage_event.proto', ) MERGED_TRACE_PROTO = 'protos/perfetto/trace/perfetto_trace.proto' @@ -124,6 +124,7 @@ syntax = "proto2"; package perfetto.protos; ''' + def merge_protos(proto_paths, output_path): root_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) merged_content = '' @@ -182,6 +183,7 @@ def merge_protos(proto_paths, output_path): fout.write(merged_content) return True + def main(): config_result = merge_protos(COMMON_PROTOS + CONFIG_PROTOS, MERGED_CONFIG_PROTO) @@ -189,5 +191,6 @@ def main(): MERGED_TRACE_PROTO) return 0 if config_result and trace_result else 1 + if __name__ == '__main__': sys.exit(main()) diff --git a/tools/gen_tracing_cpp_headers_from_protos b/tools/gen_tracing_cpp_headers_from_protos index faa303ac4..c21469849 100755 --- a/tools/gen_tracing_cpp_headers_from_protos +++ b/tools/gen_tracing_cpp_headers_from_protos @@ -19,32 +19,34 @@ import sys ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) PUB_CORE_H = 'include/perfetto/tracing/core' -CORE_H = 'include/perfetto/ext/tracing/core' +CORE_H = 'include/perfetto/ext/tracing/core' CORE_CPP = 'src/tracing/core' PROTOS = ( - # Classes that are exposed as part of the public API surface. - ('protos/perfetto/common/data_source_descriptor.proto', PUB_CORE_H, CORE_CPP), - ('protos/perfetto/common/tracing_service_state.proto', PUB_CORE_H, CORE_CPP), - ('protos/perfetto/config/chrome/chrome_config.proto', PUB_CORE_H, CORE_CPP), - ('protos/perfetto/config/data_source_config.proto', PUB_CORE_H, CORE_CPP), - ('protos/perfetto/config/test_config.proto', PUB_CORE_H, CORE_CPP), - ('protos/perfetto/config/trace_config.proto', PUB_CORE_H, CORE_CPP), + # Classes that are exposed as part of the public API surface. + ('protos/perfetto/common/data_source_descriptor.proto', PUB_CORE_H, CORE_CPP + ), + ('protos/perfetto/common/tracing_service_state.proto', PUB_CORE_H, + CORE_CPP), + ('protos/perfetto/config/chrome/chrome_config.proto', PUB_CORE_H, CORE_CPP), + ('protos/perfetto/config/data_source_config.proto', PUB_CORE_H, CORE_CPP), + ('protos/perfetto/config/test_config.proto', PUB_CORE_H, CORE_CPP), + ('protos/perfetto/config/trace_config.proto', PUB_CORE_H, CORE_CPP), - # Classes that are exposes only in the /ext/ (unstable) API surface. - ('protos/perfetto/common/commit_data_request.proto', CORE_H, CORE_CPP), - ('protos/perfetto/common/observable_events.proto', CORE_H, CORE_CPP), - ('protos/perfetto/common/trace_stats.proto', CORE_H, CORE_CPP), + # Classes that are exposes only in the /ext/ (unstable) API surface. + ('protos/perfetto/common/commit_data_request.proto', CORE_H, CORE_CPP), + ('protos/perfetto/common/observable_events.proto', CORE_H, CORE_CPP), + ('protos/perfetto/common/trace_stats.proto', CORE_H, CORE_CPP), - # Generate ftrace cpp/h files into the src/traced/probes/ directory. - ('protos/perfetto/config/ftrace/ftrace_config.proto', - 'src/traced/probes/ftrace', 'src/traced/probes/ftrace'), + # Generate ftrace cpp/h files into the src/traced/probes/ directory. + ('protos/perfetto/config/ftrace/ftrace_config.proto', + 'src/traced/probes/ftrace', 'src/traced/probes/ftrace'), - # Generate profiling cpp/h files into the src/profiling/memory/ directory. - ('protos/perfetto/config/profiling/heapprofd_config.proto', - 'src/profiling/memory', 'src/profiling/memory'), - ('protos/perfetto/config/profiling/java_hprof_config.proto', - 'src/profiling/memory', 'src/profiling/memory'), + # Generate profiling cpp/h files into the src/profiling/memory/ directory. + ('protos/perfetto/config/profiling/heapprofd_config.proto', + 'src/profiling/memory', 'src/profiling/memory'), + ('protos/perfetto/config/profiling/java_hprof_config.proto', + 'src/profiling/memory', 'src/profiling/memory'), ) @@ -62,13 +64,12 @@ def main(): return 1 out_dir = sys.argv[1] arch = 'mac' if sys.platform == 'darwin' else 'linux64' - clang_format_path = os.path.join( - ROOT_DIR, 'buildtools', arch, 'clang-format') + clang_format_path = os.path.join(ROOT_DIR, 'buildtools', arch, 'clang-format') clang_format = [clang_format_path, '-i', '--sort-includes'] ninja = os.path.join(ROOT_DIR, 'tools', 'ninja') run([ninja, '-C', out_dir, 'proto_to_cpp']) tool = os.path.join(out_dir, 'proto_to_cpp') - assert(os.path.exists(tool)) + assert (os.path.exists(tool)) for args in PROTOS: proto, header_dir, cpp_dir = args include_dir = header_dir.replace('include/', '') diff --git a/tools/heap_profile b/tools/heap_profile index d70591465..8f57b59bc 100755 --- a/tools/heap_profile +++ b/tools/heap_profile @@ -382,9 +382,10 @@ def main(argv): profile_files = os.listdir(profile_path) if not profile_files: print("No profiles generated", file=sys.stderr) - print("If this is unexpected, check " - "https://docs.perfetto.dev/#/heapprofd?id=troubleshooting.", - file=sys.stderr) + print( + "If this is unexpected, check " + "https://docs.perfetto.dev/#/heapprofd?id=troubleshooting.", + file=sys.stderr) return 1 subprocess.check_call( diff --git a/tools/install-build-deps b/tools/install-build-deps index bc85e6d02..99db737f0 100755 --- a/tools/install-build-deps +++ b/tools/install-build-deps @@ -41,169 +41,119 @@ from compat import urlretrieve # Dependencies required to build code on the host or when targeting desktop OS. BUILD_DEPS_HOST = [ - # GN - ('buildtools/mac/gn', - 'https://storage.googleapis.com/perfetto/gn-mac-b5b65ca39d93a7cde9fa713be31b114755252f28', - 'b5b65ca39d93a7cde9fa713be31b114755252f28', - 'darwin' - ), - ('buildtools/linux64/gn', - 'https://storage.googleapis.com/perfetto/gn-linux64-1370d9c5358868b7b66292821b6fe61950826870', - '1370d9c5358868b7b66292821b6fe61950826870', - 'linux2' - ), - - # clang-format - ('buildtools/mac/clang-format', - 'https://storage.googleapis.com/chromium-clang-format/025ca7c75f37ef4a40f3a67d81ddd11d7d0cdb9b', - '025ca7c75f37ef4a40f3a67d81ddd11d7d0cdb9b', - 'darwin' - ), - ('buildtools/linux64/clang-format', - 'https://storage.googleapis.com/chromium-clang-format/942fc8b1789144b8071d3fc03ff0fcbe1cf81ac8', - '942fc8b1789144b8071d3fc03ff0fcbe1cf81ac8', - 'linux2' - ), - # Keep the SHA1 in sync with |clang_format_rev| in chromium //buildtools/DEPS. - ('buildtools/clang_format/script', - 'https://chromium.googlesource.com/chromium/llvm-project/cfe/tools/clang-format.git', - '96636aa0e9f047f17447f2d45a094d0b59ed7917', - 'all' - ), - - # Ninja - ('buildtools/mac/ninja', - 'https://storage.googleapis.com/perfetto/ninja-mac-c15b0698da038b2bd2e8970c14c75fadc06b1add', - 'c15b0698da038b2bd2e8970c14c75fadc06b1add', - 'darwin' - ), - ('buildtools/linux64/ninja', - 'https://storage.googleapis.com/perfetto/ninja-linux64-c866952bda50c29a669222477309287119bbb7e8', - 'c866952bda50c29a669222477309287119bbb7e8', - 'linux2' - ), - - # Keep in sync with Android's //external/googletest/README.version. - ('buildtools/googletest.zip', - 'https://github.com/google/googletest/archive/ff07a5de0e81580547f1685e101194ed1a4fcd56.zip', - 'c7edec7d7e6db1fc37a20710de9c4d89e3a3893b', - 'all' - ), - - # Keep in sync with Android's //external/protobuf/README.version. - ('buildtools/protobuf.zip', - 'https://github.com/google/protobuf/releases/download/v3.0.0-beta-3/protobuf-cpp-3.0.0-beta-3.zip', - '3caec60aa9d8eefc8c3c3201b6b8ca19935edb89', - 'all' - ), - - # libc++, libc++abi and libunwind for Linux where we need to rebuild the C++ - # lib from sources. Keep the SHA1s in sync with Chrome's src/buildtools/DEPS. - ('buildtools/libcxx', - 'https://chromium.googlesource.com/chromium/llvm-project/libcxx.git', - '5938e0582bac570a41edb3d6a2217c299adc1bc6', - 'all' - ), - ('buildtools/libcxxabi', - 'https://chromium.googlesource.com/chromium/llvm-project/libcxxabi.git', - '0d529660e32d77d9111912d73f2c74fc5fa2a858', - 'all' - ), - ('buildtools/libunwind', - 'https://chromium.googlesource.com/external/llvm.org/libunwind.git', - '69d9b84cca8354117b9fe9705a4430d789ee599b', - 'all' - ), - - # Keep the revision in sync with Chrome's PACKAGE_VERSION in - # tools/clang/scripts/update.py. - ('buildtools/clang.tgz', - 'https://commondatastorage.googleapis.com/chromium-browser-clang/Linux_x64/clang-365097-f7e52fbd-8.tgz', - 'fe1b1e5bd7381ae655661cb9658487389561568d', - 'linux2' - ), - - # Keep in sync with chromium DEPS. - ('buildtools/libfuzzer', - 'https://chromium.googlesource.com/chromium/llvm-project/compiler-rt/lib/fuzzer.git', - 'b9f51dc8c98065df0c8da13c051046f5bab833db', - 'linux2' - ), - - # Benchmarking tool. - ('buildtools/benchmark.zip', - 'https://github.com/google/benchmark/archive/v1.3.0.zip', - 'f387e0df37d54bfd5be239e8d0d3ea2e2c3e34f4', - 'all' - ), - - # Libbacktrace, for stacktraces in Linux/Android debug builds. - ('buildtools/libbacktrace.zip', - 'https://github.com/ianlancetaylor/libbacktrace/archive/177940370e4a6b2509e92a0aaa9749184e64af43.zip', - 'b723fe9d671d1ab54df1297f6afbf2893a41c3ea', - 'all' - ), - - # Sqlite for the trace processing library. - # This is the amalgamated source whose compiled output is meant to be faster. - # We still pull the full source for the extensions (not amalgamated). - ('buildtools/sqlite.zip', - 'https://storage.googleapis.com/perfetto/sqlite-amalgamation-3250300.zip', - 'b78c2cb0d2c9182686c582312479f96a82bf5380', - 'all' - ), - ('buildtools/sqlite_src.zip', - 'https://storage.googleapis.com/perfetto/sqlite-src-3250300.zip', - 'd1af2883bb800852946f9bf8ab6055e7698e18ee', - 'all' - ), - - # JsonCpp for legacy json import. Used only by the trace processor in - # standalone builds. - ('buildtools/jsoncpp.zip', - 'https://github.com/open-source-parsers/jsoncpp/archive/1.0.0.zip', - '3219e26f2e249bb46b7d688478208c7ec138fea4', - 'all' - ), - - # These dependencies are for libunwindstack, which is used by src/profiling. - ('buildtools/android-core', - 'https://android.googlesource.com/platform/system/core.git', - '3f407fcc37b401c91784700c0a691ba8b1f7ef15', - 'all' - ), - - ('buildtools/lzma', - 'https://android.googlesource.com/platform/external/lzma.git', - '7851dce6f4ca17f5caa1c93a4e0a45686b1d56c3', - 'all' - ), - - ('buildtools/zlib', - 'https://android.googlesource.com/platform/external/zlib.git', - 'dfa0646a03b4e1707469e04dc931b09774968fe6', - 'all' - ), - - ('buildtools/bionic', - 'https://android.googlesource.com/platform/bionic.git', - 'a60488109cda997dfd83832731c8527feaa2825e', - 'all' - ), - - # Example traces for regression tests. - ('buildtools/test_data.zip', - 'https://storage.googleapis.com/perfetto/test-data-20191008-115945.zip', - '4738c53cec52dc2bf98d7c3a1b6f0bccfaaf26f8', - 'all', - ), - - # Linenoise, used only by trace_processor in standalone builds. - ('buildtools/linenoise', - 'https://fuchsia.googlesource.com/third_party/linenoise.git', - 'c894b9e59f02203dbe4e2be657572cf88c4230c3', - 'all' - ), + # GN + ('buildtools/mac/gn', + 'https://storage.googleapis.com/perfetto/gn-mac-b5b65ca39d93a7cde9fa713be31b114755252f28', + 'b5b65ca39d93a7cde9fa713be31b114755252f28', 'darwin'), + ('buildtools/linux64/gn', + 'https://storage.googleapis.com/perfetto/gn-linux64-1370d9c5358868b7b66292821b6fe61950826870', + '1370d9c5358868b7b66292821b6fe61950826870', 'linux2'), + + # clang-format + ('buildtools/mac/clang-format', + 'https://storage.googleapis.com/chromium-clang-format/025ca7c75f37ef4a40f3a67d81ddd11d7d0cdb9b', + '025ca7c75f37ef4a40f3a67d81ddd11d7d0cdb9b', 'darwin'), + ('buildtools/linux64/clang-format', + 'https://storage.googleapis.com/chromium-clang-format/942fc8b1789144b8071d3fc03ff0fcbe1cf81ac8', + '942fc8b1789144b8071d3fc03ff0fcbe1cf81ac8', 'linux2'), + # Keep the SHA1 in sync with |clang_format_rev| in chromium //buildtools/DEPS. + ('buildtools/clang_format/script', + 'https://chromium.googlesource.com/chromium/llvm-project/cfe/tools/clang-format.git', + '96636aa0e9f047f17447f2d45a094d0b59ed7917', 'all'), + + # Ninja + ('buildtools/mac/ninja', + 'https://storage.googleapis.com/perfetto/ninja-mac-c15b0698da038b2bd2e8970c14c75fadc06b1add', + 'c15b0698da038b2bd2e8970c14c75fadc06b1add', 'darwin'), + ('buildtools/linux64/ninja', + 'https://storage.googleapis.com/perfetto/ninja-linux64-c866952bda50c29a669222477309287119bbb7e8', + 'c866952bda50c29a669222477309287119bbb7e8', 'linux2'), + + # Keep in sync with Android's //external/googletest/README.version. + ('buildtools/googletest.zip', + 'https://github.com/google/googletest/archive/ff07a5de0e81580547f1685e101194ed1a4fcd56.zip', + 'c7edec7d7e6db1fc37a20710de9c4d89e3a3893b', 'all'), + + # Keep in sync with Android's //external/protobuf/README.version. + ('buildtools/protobuf.zip', + 'https://github.com/google/protobuf/releases/download/v3.0.0-beta-3/protobuf-cpp-3.0.0-beta-3.zip', + '3caec60aa9d8eefc8c3c3201b6b8ca19935edb89', 'all'), + + # libc++, libc++abi and libunwind for Linux where we need to rebuild the C++ + # lib from sources. Keep the SHA1s in sync with Chrome's src/buildtools/DEPS. + ('buildtools/libcxx', + 'https://chromium.googlesource.com/chromium/llvm-project/libcxx.git', + '5938e0582bac570a41edb3d6a2217c299adc1bc6', 'all'), + ('buildtools/libcxxabi', + 'https://chromium.googlesource.com/chromium/llvm-project/libcxxabi.git', + '0d529660e32d77d9111912d73f2c74fc5fa2a858', 'all'), + ('buildtools/libunwind', + 'https://chromium.googlesource.com/external/llvm.org/libunwind.git', + '69d9b84cca8354117b9fe9705a4430d789ee599b', 'all'), + + # Keep the revision in sync with Chrome's PACKAGE_VERSION in + # tools/clang/scripts/update.py. + ('buildtools/clang.tgz', + 'https://commondatastorage.googleapis.com/chromium-browser-clang/Linux_x64/clang-365097-f7e52fbd-8.tgz', + 'fe1b1e5bd7381ae655661cb9658487389561568d', 'linux2'), + + # Keep in sync with chromium DEPS. + ('buildtools/libfuzzer', + 'https://chromium.googlesource.com/chromium/llvm-project/compiler-rt/lib/fuzzer.git', + 'b9f51dc8c98065df0c8da13c051046f5bab833db', 'linux2'), + + # Benchmarking tool. + ('buildtools/benchmark.zip', + 'https://github.com/google/benchmark/archive/v1.3.0.zip', + 'f387e0df37d54bfd5be239e8d0d3ea2e2c3e34f4', 'all'), + + # Libbacktrace, for stacktraces in Linux/Android debug builds. + ('buildtools/libbacktrace.zip', + 'https://github.com/ianlancetaylor/libbacktrace/archive/177940370e4a6b2509e92a0aaa9749184e64af43.zip', + 'b723fe9d671d1ab54df1297f6afbf2893a41c3ea', 'all'), + + # Sqlite for the trace processing library. + # This is the amalgamated source whose compiled output is meant to be faster. + # We still pull the full source for the extensions (not amalgamated). + ('buildtools/sqlite.zip', + 'https://storage.googleapis.com/perfetto/sqlite-amalgamation-3250300.zip', + 'b78c2cb0d2c9182686c582312479f96a82bf5380', 'all'), + ('buildtools/sqlite_src.zip', + 'https://storage.googleapis.com/perfetto/sqlite-src-3250300.zip', + 'd1af2883bb800852946f9bf8ab6055e7698e18ee', 'all'), + + # JsonCpp for legacy json import. Used only by the trace processor in + # standalone builds. + ('buildtools/jsoncpp.zip', + 'https://github.com/open-source-parsers/jsoncpp/archive/1.0.0.zip', + '3219e26f2e249bb46b7d688478208c7ec138fea4', 'all'), + + # These dependencies are for libunwindstack, which is used by src/profiling. + ('buildtools/android-core', + 'https://android.googlesource.com/platform/system/core.git', + '3f407fcc37b401c91784700c0a691ba8b1f7ef15', 'all'), + ('buildtools/lzma', + 'https://android.googlesource.com/platform/external/lzma.git', + '7851dce6f4ca17f5caa1c93a4e0a45686b1d56c3', 'all'), + ('buildtools/zlib', + 'https://android.googlesource.com/platform/external/zlib.git', + 'dfa0646a03b4e1707469e04dc931b09774968fe6', 'all'), + ('buildtools/bionic', + 'https://android.googlesource.com/platform/bionic.git', + 'a60488109cda997dfd83832731c8527feaa2825e', 'all'), + + # Example traces for regression tests. + ( + 'buildtools/test_data.zip', + 'https://storage.googleapis.com/perfetto/test-data-20191008-115945.zip', + '4738c53cec52dc2bf98d7c3a1b6f0bccfaaf26f8', + 'all', + ), + + # Linenoise, used only by trace_processor in standalone builds. + ('buildtools/linenoise', + 'https://fuchsia.googlesource.com/third_party/linenoise.git', + 'c894b9e59f02203dbe4e2be657572cf88c4230c3', 'all'), ] # Dependencies required to build Android code. @@ -211,46 +161,34 @@ BUILD_DEPS_HOST = [ # - https://dl.google.com/android/repository/repository-11.xml # - https://dl.google.com/android/repository/sys-img/android/sys-img.xml BUILD_DEPS_ANDROID = [ - # Android NDK - ('buildtools/ndk.zip', - 'https://dl.google.com/android/repository/android-ndk-r17b-darwin-x86_64.zip', - 'f990aafaffec0b583d2c5420bfa622e52ac14248', - 'darwin' - ), - ('buildtools/ndk.zip', - 'https://dl.google.com/android/repository/android-ndk-r17b-linux-x86_64.zip', - 'dd5762ee7ef4995ad04fe0c45a608c344d99ca9f', - 'linux2' - ), + # Android NDK + ('buildtools/ndk.zip', + 'https://dl.google.com/android/repository/android-ndk-r17b-darwin-x86_64.zip', + 'f990aafaffec0b583d2c5420bfa622e52ac14248', 'darwin'), + ('buildtools/ndk.zip', + 'https://dl.google.com/android/repository/android-ndk-r17b-linux-x86_64.zip', + 'dd5762ee7ef4995ad04fe0c45a608c344d99ca9f', 'linux2'), ] # Dependencies required to run Android tests. TEST_DEPS_ANDROID = [ - # Android emulator images. - ('buildtools/aosp-arm.zip', - 'https://storage.googleapis.com/perfetto/aosp-02022018-arm.zip', - 'a480d5e7d3ca888b0a58fe15ce76b1791537429a', - 'all' - ), - - # platform-tools.zip contains adb binaries. - ('buildtools/android_sdk/platform-tools.zip', - 'https://dl.google.com/android/repository/platform-tools_r26.0.0-darwin.zip', - 'e75b6137dc444f777eb02f44a6d9819b3aabff82', - 'darwin' - ), - ('buildtools/android_sdk/platform-tools.zip', - 'https://dl.google.com/android/repository/platform-tools_r26.0.0-linux.zip', - '00de8a6631405b617c10f68cd11ff2e1cd528e23', - 'linux2' - ), - - # Android emulator binaries. - ('buildtools/emulator', - 'https://android.googlesource.com/platform/prebuilts/android-emulator.git', - '4b260028dc27bc92c39bee9129cb2ba839970956', - 'all' - ), + # Android emulator images. + ('buildtools/aosp-arm.zip', + 'https://storage.googleapis.com/perfetto/aosp-02022018-arm.zip', + 'a480d5e7d3ca888b0a58fe15ce76b1791537429a', 'all'), + + # platform-tools.zip contains adb binaries. + ('buildtools/android_sdk/platform-tools.zip', + 'https://dl.google.com/android/repository/platform-tools_r26.0.0-darwin.zip', + 'e75b6137dc444f777eb02f44a6d9819b3aabff82', 'darwin'), + ('buildtools/android_sdk/platform-tools.zip', + 'https://dl.google.com/android/repository/platform-tools_r26.0.0-linux.zip', + '00de8a6631405b617c10f68cd11ff2e1cd528e23', 'linux2'), + + # Android emulator binaries. + ('buildtools/emulator', + 'https://android.googlesource.com/platform/prebuilts/android-emulator.git', + '4b260028dc27bc92c39bee9129cb2ba839970956', 'all'), ] # This variable is updated by tools/roll-catapult-trace-viewer. @@ -259,51 +197,33 @@ CATAPULT_SHA1 = 'ff5d8fd7244680b4d4456c25d5fdc04c76f9ef66' TYPEFACES_SHA1 = '756b0a015b8f99f5718f7fdf967d052c1ec55ab3' UI_DEPS = [ - ('buildtools/nodejs.tgz', - 'https://storage.googleapis.com/perfetto/node-v10.3.0-darwin-x64.tar.gz', - '6d9a122785f38c256add3b25f74adf125497861a', - 'darwin' - ), - ('buildtools/nodejs.tgz', - 'https://storage.googleapis.com/perfetto/node-v10.3.0-linux-x64.tar.xz', - '118f6ea19f75089b3f12ac2ddfce357bff872b5e', - 'linux2' - ), - ('buildtools/emsdk/emscripten.tgz', - 'https://storage.googleapis.com/perfetto/emscripten-1.37.40.tar.gz', - '588c28221321ebbdfc8e3a6f47ea6106f589669b', - 'all' - ), - ('buildtools/emsdk/llvm.tgz', - 'https://storage.googleapis.com/perfetto/emscripten-llvm-e1.37.40-darwin.tar.gz', - '7a894ef0a52821c62f6abaac552dc4ce5d424607', - 'darwin' - ), - ('buildtools/emsdk/llvm.tgz', - 'https://storage.googleapis.com/perfetto/emscripten-llvm-e1.37.40-static-linux.tar.gz', - '478501b9b7a14884e546c84efe209a90052cbb07', - 'linux2' - ), - ('buildtools/d8.tgz', - 'https://storage.googleapis.com/perfetto/d8-linux2-5.7.492.65.tar.gz', - '95e82ad7faf0a6f74d950c2aa65e3858b7bdb6c6', - 'linux2' - ), - ('buildtools/d8.tgz', - 'https://storage.googleapis.com/perfetto/d8-darwin-6.6.346.32.tar.gz', - '1abd630619bb1977ab62095570a113d782a1545d', - 'darwin' - ), - ('buildtools/catapult_trace_viewer.tgz', - 'https://storage.googleapis.com/perfetto/catapult_trace_viewer-%s.tar.gz' % CATAPULT_SHA1, - CATAPULT_SHA1, - 'all' - ), - ('buildtools/typefaces.tgz', - 'https://storage.googleapis.com/perfetto/typefaces-%s.tar.gz' % TYPEFACES_SHA1, - TYPEFACES_SHA1, - 'all' - ) + ('buildtools/nodejs.tgz', + 'https://storage.googleapis.com/perfetto/node-v10.3.0-darwin-x64.tar.gz', + '6d9a122785f38c256add3b25f74adf125497861a', 'darwin'), + ('buildtools/nodejs.tgz', + 'https://storage.googleapis.com/perfetto/node-v10.3.0-linux-x64.tar.xz', + '118f6ea19f75089b3f12ac2ddfce357bff872b5e', 'linux2'), + ('buildtools/emsdk/emscripten.tgz', + 'https://storage.googleapis.com/perfetto/emscripten-1.37.40.tar.gz', + '588c28221321ebbdfc8e3a6f47ea6106f589669b', 'all'), + ('buildtools/emsdk/llvm.tgz', + 'https://storage.googleapis.com/perfetto/emscripten-llvm-e1.37.40-darwin.tar.gz', + '7a894ef0a52821c62f6abaac552dc4ce5d424607', 'darwin'), + ('buildtools/emsdk/llvm.tgz', + 'https://storage.googleapis.com/perfetto/emscripten-llvm-e1.37.40-static-linux.tar.gz', + '478501b9b7a14884e546c84efe209a90052cbb07', 'linux2'), + ('buildtools/d8.tgz', + 'https://storage.googleapis.com/perfetto/d8-linux2-5.7.492.65.tar.gz', + '95e82ad7faf0a6f74d950c2aa65e3858b7bdb6c6', 'linux2'), + ('buildtools/d8.tgz', + 'https://storage.googleapis.com/perfetto/d8-darwin-6.6.346.32.tar.gz', + '1abd630619bb1977ab62095570a113d782a1545d', 'darwin'), + ('buildtools/catapult_trace_viewer.tgz', + 'https://storage.googleapis.com/perfetto/catapult_trace_viewer-%s.tar.gz' % + CATAPULT_SHA1, CATAPULT_SHA1, 'all'), + ('buildtools/typefaces.tgz', + 'https://storage.googleapis.com/perfetto/typefaces-%s.tar.gz' % + TYPEFACES_SHA1, TYPEFACES_SHA1, 'all') ] ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) @@ -313,7 +233,7 @@ def ReadFile(path): if not os.path.exists(path): return None with open(path) as f: - return f.read().strip() + return f.read().strip() def MkdirRecursive(path): @@ -324,7 +244,7 @@ def MkdirRecursive(path): if not os.path.exists(cwd): os.makedirs(cwd) else: - assert(os.path.isdir(cwd)) + assert (os.path.isdir(cwd)) def HashLocalFile(path): @@ -354,25 +274,21 @@ def CheckoutGitRepo(path, git_url, revision): logging.info('Fetching %s @ %s into %s', git_url, revision, path) subprocess.check_call(['git', 'init', path], cwd=path) subprocess.check_call( - ['git', 'fetch', '--quiet', '--depth', '1', git_url, revision], cwd=path) + ['git', 'fetch', '--quiet', '--depth', '1', git_url, revision], cwd=path) subprocess.check_call(['git', 'checkout', revision, '--quiet'], cwd=path) - assert(IsGitRepoCheckoutOutAtRevision(path, revision)) + assert (IsGitRepoCheckoutOutAtRevision(path, revision)) return True def InstallNodeModules(): ui_dir = os.path.join(ROOT_DIR, 'ui') logging.info("Running npm install in {0}".format(ui_dir)) - subprocess.check_call( - [os.path.join(ui_dir, 'npm'), 'install', '--no-save'], - cwd=os.path.join(ROOT_DIR, 'ui')) + subprocess.check_call([os.path.join(ui_dir, 'npm'), 'install', '--no-save'], + cwd=os.path.join(ROOT_DIR, 'ui')) def CheckHashes(): - for deps in [BUILD_DEPS_HOST, - BUILD_DEPS_ANDROID, - TEST_DEPS_ANDROID, - UI_DEPS]: + for deps in [BUILD_DEPS_HOST, BUILD_DEPS_ANDROID, TEST_DEPS_ANDROID, UI_DEPS]: for rel_path, url, expected_sha1, platform in deps: if url.endswith('.git'): continue @@ -391,8 +307,8 @@ def Main(): parser = argparse.ArgumentParser() parser.add_argument('--no-android', action='store_true') parser.add_argument('--ui', action='store_true') - parser.add_argument('--check-hashes', help='Check hashes for all URLs', - action='store_true') + parser.add_argument( + '--check-hashes', help='Check hashes for all URLs', action='store_true') args = parser.parse_args() if args.check_hashes: CheckHashes() @@ -431,11 +347,11 @@ def Main(): download_path, expected_sha1, actual_sha1)) return 1 os.rename(download_path, local_path) - assert(HashLocalFile(local_path) == expected_sha1) + assert (HashLocalFile(local_path) == expected_sha1) if is_zip: logging.info('Extracting %s into %s' % (local_path, zip_target_dir)) - assert(os.path.commonprefix((ROOT_DIR, zip_target_dir)) == ROOT_DIR) + assert (os.path.commonprefix((ROOT_DIR, zip_target_dir)) == ROOT_DIR) if os.path.exists(zip_target_dir): logging.info('Deleting stale dir %s' % zip_target_dir) shutil.rmtree(zip_target_dir) @@ -456,7 +372,7 @@ def Main(): subdir = os.path.join(zip_target_dir, subdir[0]) if os.path.isdir(subdir): for subf in os.listdir(subdir): - shutil.move(os.path.join(subdir,subf), zip_target_dir) + shutil.move(os.path.join(subdir, subf), zip_target_dir) os.rmdir(subdir) # Create stamp and remove the archive. @@ -474,6 +390,7 @@ def Main(): logging.warning('Remember to run "gn clean <output_directory>" ' + 'to avoid stale binary files.') + if __name__ == '__main__': logging.basicConfig(level=logging.INFO) sys.exit(Main()) diff --git a/tools/run_test_like_ci b/tools/run_test_like_ci index 3a94ef90e..e569b98b9 100755 --- a/tools/run_test_like_ci +++ b/tools/run_test_like_ci @@ -26,54 +26,53 @@ from config import JOB_CONFIGS, SANDBOX_IMG def main(): - parser = argparse.ArgumentParser() - parser.add_argument('config', choices=JOB_CONFIGS.keys()) - args = parser.parse_args() + parser = argparse.ArgumentParser() + parser.add_argument('config', choices=JOB_CONFIGS.keys()) + args = parser.parse_args() - # Check that the directory is clean. - git_cmd = ['git', '-C', REPO_ROOT, 'status', '--porcelain'] - modified_files = subprocess.check_output(git_cmd) - if modified_files: - print('The current Git repo has modified/untracked files.') - print('The sandboxed VM will fetch the HEAD of your current git repo.') - print('This is probably not the state you want to be in.') - print('I suggest you press CTRL+C, commit and then re-run this script') - print('Modified files:\n' + modified_files) - raw_input('If you think you know what you are doing, press Enter instead') + # Check that the directory is clean. + git_cmd = ['git', '-C', REPO_ROOT, 'status', '--porcelain'] + modified_files = subprocess.check_output(git_cmd) + if modified_files: + print('The current Git repo has modified/untracked files.') + print('The sandboxed VM will fetch the HEAD of your current git repo.') + print('This is probably not the state you want to be in.') + print('I suggest you press CTRL+C, commit and then re-run this script') + print('Modified files:\n' + modified_files) + raw_input('If you think you know what you are doing, press Enter instead') - env = { - 'PERFETTO_TEST_GIT_REF': 'file:///ci/source', - } - env.update(JOB_CONFIGS[args.config]) + env = { + 'PERFETTO_TEST_GIT_REF': 'file:///ci/source', + } + env.update(JOB_CONFIGS[args.config]) - workdir = os.path.join(REPO_ROOT, 'out', 'tmp.ci') - cmd = [ - 'sudo', '--', 'docker', 'run', '-it', '--name', 'perfetto_ci', - '--cap-add', 'SYS_PTRACE', '--rm', '--volume', - '%s:/ci/ramdisk' % workdir, '--tmpfs', '/tmp:exec', - '--volume=%s:/ci/source:ro' % REPO_ROOT - ] - for kv in env.items(): - cmd += ['--env', '%s=%s' % kv] - cmd += [SANDBOX_IMG] - cmd += [ - 'bash', '-c', - 'cd /ci/ramdisk; bash /ci/init.sh || sudo -u perfetto -EH bash -i' - ] + workdir = os.path.join(REPO_ROOT, 'out', 'tmp.ci') + cmd = [ + 'sudo', '--', 'docker', 'run', '-it', '--name', 'perfetto_ci', + '--cap-add', 'SYS_PTRACE', '--rm', '--volume', + '%s:/ci/ramdisk' % workdir, '--tmpfs', '/tmp:exec', + '--volume=%s:/ci/source:ro' % REPO_ROOT + ] + for kv in env.items(): + cmd += ['--env', '%s=%s' % kv] + cmd += [SANDBOX_IMG] + cmd += [ + 'bash', '-c', + 'cd /ci/ramdisk; bash /ci/init.sh || sudo -u perfetto -EH bash -i' + ] - print('About to run\n', ' '.join(cmd)) - print('') - print('The VM will have read-only acess to: %s, mounted as /ci/source' % - REPO_ROOT) - print('The VM workdir /ci/ramdisk will be mounted into: %s' % workdir) - print( - 'The contents of %s will be deleted before starting the VM' % workdir) - raw_input('Press a key to continue') + print('About to run\n', ' '.join(cmd)) + print('') + print('The VM will have read-only acess to: %s, mounted as /ci/source' % + REPO_ROOT) + print('The VM workdir /ci/ramdisk will be mounted into: %s' % workdir) + print('The contents of %s will be deleted before starting the VM' % workdir) + raw_input('Press a key to continue') - shutil.rmtree(workdir, ignore_errors=True) - os.makedirs(workdir) - os.execvp(cmd[0], cmd[1:]) + shutil.rmtree(workdir, ignore_errors=True) + os.makedirs(workdir) + os.execvp(cmd[0], cmd[1:]) if __name__ == '__main__': - sys.exit(main()) + sys.exit(main()) diff --git a/tools/trace_processor b/tools/trace_processor index c8fb203d8..2af5b8f76 100755 --- a/tools/trace_processor +++ b/tools/trace_processor @@ -20,7 +20,7 @@ # cat ./trace_processor | bash # cat ./trace_processor | python - -BASH_FALLBACK=""" " +BASH_FALLBACK = """ " exec python - "$@" <<'#'EOF #""" @@ -31,18 +31,19 @@ import tempfile import urllib TRACE_PROCESSOR_SHELL_SHAS = { - 'linux': '8e7ce3affdaa1d1f66a0bd58368782784bf6c9a6', - 'mac':'78709d06d30260119f31963143073dde24f03da0', + 'linux': '8e7ce3affdaa1d1f66a0bd58368782784bf6c9a6', + 'mac': '78709d06d30260119f31963143073dde24f03da0', } TRACE_PROCESSOR_SHELL_PATH = tempfile.gettempdir() -TRACE_PROCESSOR_SHELL_BASE_URL = ( - 'https://storage.googleapis.com/perfetto/') +TRACE_PROCESSOR_SHELL_BASE_URL = ('https://storage.googleapis.com/perfetto/') + def check_hash(file_name, sha_value): with open(file_name, 'rb') as fd: file_hash = hashlib.sha1(fd.read()).hexdigest() return file_hash == sha_value + def load_trace_processor_shell(platform): sha_value = TRACE_PROCESSOR_SHELL_SHAS[platform] file_name = 'trace_processor_shell-' + platform + '-' + sha_value @@ -62,6 +63,7 @@ def load_trace_processor_shell(platform): os.chmod(local_file, 0o755) return local_file + def main(argv): platform = None if sys.platform.startswith('linux'): @@ -76,6 +78,7 @@ def main(argv): os.execv(trace_processor_shell_binary, [trace_processor_shell_binary] + argv[1:]) + if __name__ == '__main__': sys.exit(main(sys.argv)) diff --git a/tools/traceconv b/tools/traceconv index 49afea415..53cd5c47a 100755 --- a/tools/traceconv +++ b/tools/traceconv @@ -20,7 +20,7 @@ # cat ./traceconv | bash # cat ./traceconv | python - -BASH_FALLBACK=""" " +BASH_FALLBACK = """ " exec python - "$@" <<'#'EOF #""" @@ -33,18 +33,19 @@ import urllib # Keep this in sync with the SHAs in catapult file # systrace/systrace/tracing_agents/atrace_from_file_agent.py. TRACE_TO_TEXT_SHAS = { - 'linux': 'c579caa592b21f45102e8bd8cc984ebf25ebb401', - 'mac':'f3ad823b0b8d27ca66d3421131790dfa4e58708d', + 'linux': 'c579caa592b21f45102e8bd8cc984ebf25ebb401', + 'mac': 'f3ad823b0b8d27ca66d3421131790dfa4e58708d', } TRACE_TO_TEXT_PATH = tempfile.gettempdir() -TRACE_TO_TEXT_BASE_URL = ( - 'https://storage.googleapis.com/perfetto/') +TRACE_TO_TEXT_BASE_URL = ('https://storage.googleapis.com/perfetto/') + def check_hash(file_name, sha_value): with open(file_name, 'rb') as fd: file_hash = hashlib.sha1(fd.read()).hexdigest() return file_hash == sha_value + def load_trace_to_text(platform): sha_value = TRACE_TO_TEXT_SHAS[platform] file_name = 'trace_to_text-' + platform + '-' + sha_value @@ -64,6 +65,7 @@ def load_trace_to_text(platform): os.chmod(local_file, 0o755) return local_file + def main(argv): platform = None if sys.platform.startswith('linux'): @@ -77,6 +79,7 @@ def main(argv): trace_to_text_binary = load_trace_to_text(platform) os.execv(trace_to_text_binary, [trace_to_text_binary] + argv[1:]) + if __name__ == '__main__': sys.exit(main(sys.argv)) |