Revert "Add version consistently in all build configs and UI" This reverts commit 85a1a12e813346f51b3e89344209e8f196e8424c. Reason for revert: b/173245796 Change-Id: I3a1da3e6ba32d447185152ee5e4aa9fc8a5bb614
diff --git a/Android.bp b/Android.bp index 5a1bf65..68c4084 100644 --- a/Android.bp +++ b/Android.bp
@@ -140,7 +140,6 @@ "perfetto_protos_perfetto_trace_system_info_zero_gen_headers", "perfetto_protos_perfetto_trace_track_event_cpp_gen_headers", "perfetto_protos_perfetto_trace_track_event_zero_gen_headers", - "perfetto_src_base_version_gen_h", ], defaults: [ "perfetto_defaults", @@ -174,9 +173,6 @@ "include", "include/perfetto/base/build_configs/android_tree", ], - generated_headers: [ - "perfetto_src_base_version_gen_h", - ], defaults: [ "perfetto_defaults", ], @@ -220,9 +216,6 @@ "include", "include/perfetto/base/build_configs/android_tree", ], - generated_headers: [ - "perfetto_src_base_version_gen_h", - ], defaults: [ "perfetto_defaults", ], @@ -374,7 +367,6 @@ "perfetto_protos_perfetto_trace_system_info_zero_gen_headers", "perfetto_protos_perfetto_trace_track_event_cpp_gen_headers", "perfetto_protos_perfetto_trace_track_event_zero_gen_headers", - "perfetto_src_base_version_gen_h", ], defaults: [ "perfetto_defaults", @@ -403,9 +395,6 @@ static_libs: [ "libprotoc", ], - generated_headers: [ - "perfetto_src_base_version_gen_h", - ], defaults: [ "perfetto_defaults", ], @@ -554,7 +543,6 @@ "perfetto_protos_perfetto_trace_system_info_zero_gen_headers", "perfetto_protos_perfetto_trace_track_event_cpp_gen_headers", "perfetto_protos_perfetto_trace_track_event_zero_gen_headers", - "perfetto_src_base_version_gen_h", ], defaults: [ "perfetto_defaults", @@ -733,7 +721,6 @@ "perfetto_protos_perfetto_trace_system_info_zero_gen_headers", "perfetto_protos_perfetto_trace_track_event_cpp_gen_headers", "perfetto_protos_perfetto_trace_track_event_zero_gen_headers", - "perfetto_src_base_version_gen_h", ], export_generated_headers: [ "perfetto_protos_perfetto_common_cpp_gen_headers", @@ -777,7 +764,6 @@ "perfetto_protos_perfetto_trace_system_info_zero_gen_headers", "perfetto_protos_perfetto_trace_track_event_cpp_gen_headers", "perfetto_protos_perfetto_trace_track_event_zero_gen_headers", - "perfetto_src_base_version_gen_h", ], defaults: [ "perfetto_defaults", @@ -912,7 +898,6 @@ "perfetto_protos_perfetto_trace_system_info_zero_gen_headers", "perfetto_protos_perfetto_trace_track_event_cpp_gen_headers", "perfetto_protos_perfetto_trace_track_event_zero_gen_headers", - "perfetto_src_base_version_gen_h", "perfetto_src_perfetto_cmd_protos_gen_headers", ], defaults: [ @@ -1104,7 +1089,6 @@ "perfetto_protos_perfetto_trace_system_info_zero_gen_headers", "perfetto_protos_perfetto_trace_track_event_cpp_gen_headers", "perfetto_protos_perfetto_trace_track_event_zero_gen_headers", - "perfetto_src_base_version_gen_h", ], export_generated_headers: [ "perfetto_protos_perfetto_common_cpp_gen_headers", @@ -1162,7 +1146,6 @@ "perfetto_protos_perfetto_trace_system_info_zero_gen_headers", "perfetto_protos_perfetto_trace_track_event_cpp_gen_headers", "perfetto_protos_perfetto_trace_track_event_zero_gen_headers", - "perfetto_src_base_version_gen_h", ], defaults: [ "perfetto_defaults", @@ -1337,7 +1320,6 @@ "perfetto_protos_perfetto_trace_system_info_zero_gen_headers", "perfetto_protos_perfetto_trace_track_event_cpp_gen_headers", "perfetto_protos_perfetto_trace_track_event_zero_gen_headers", - "perfetto_src_base_version_gen_h", ], export_generated_headers: [ "perfetto_protos_perfetto_common_cpp_gen_headers", @@ -1395,7 +1377,6 @@ "perfetto_protos_perfetto_trace_system_info_zero_gen_headers", "perfetto_protos_perfetto_trace_track_event_cpp_gen_headers", "perfetto_protos_perfetto_trace_track_event_zero_gen_headers", - "perfetto_src_base_version_gen_h", ], defaults: [ "perfetto_defaults", @@ -1751,7 +1732,6 @@ "perfetto_protos_perfetto_trace_system_info_zero_gen_headers", "perfetto_protos_perfetto_trace_track_event_cpp_gen_headers", "perfetto_protos_perfetto_trace_track_event_zero_gen_headers", - "perfetto_src_base_version_gen_h", ], defaults: [ "perfetto_defaults", @@ -6214,7 +6194,6 @@ "src/base/unix_task_runner.cc", "src/base/utils.cc", "src/base/uuid.cc", - "src/base/version.cc", "src/base/virtual_destructors.cc", "src/base/waitable_event.cc", "src/base/watchdog_posix.cc", @@ -6268,22 +6247,6 @@ ], } -// GN: //src/base:version_gen_h -genrule { - name: "perfetto_src_base_version_gen_h", - srcs: [ - ".git/HEAD", - "CHANGELOG", - ], - cmd: "python3 $(location tools/write_version_header.py) --cpp_out=$(out)", - out: [ - "perfetto_version.gen.h", - ], - tool_files: [ - "tools/write_version_header.py", - ], -} - // GN: //src/ipc:client filegroup { name: "perfetto_src_ipc_client", @@ -6764,9 +6727,6 @@ static_libs: [ "libprotoc", ], - generated_headers: [ - "perfetto_src_base_version_gen_h", - ], defaults: [ "perfetto_defaults", ], @@ -8482,7 +8442,6 @@ "perfetto_protos_perfetto_trace_system_info_zero_gen_headers", "perfetto_protos_perfetto_trace_track_event_cpp_gen_headers", "perfetto_protos_perfetto_trace_track_event_zero_gen_headers", - "perfetto_src_base_version_gen_h", "perfetto_src_ipc_test_messages_cpp_gen_headers", "perfetto_src_ipc_test_messages_ipc_gen_headers", "perfetto_src_perfetto_cmd_protos_gen_headers", @@ -8529,9 +8488,6 @@ static_libs: [ "libprotoc", ], - generated_headers: [ - "perfetto_src_base_version_gen_h", - ], defaults: [ "perfetto_defaults", ], @@ -8637,7 +8593,6 @@ "perfetto_protos_perfetto_trace_sys_stats_zero_gen_headers", "perfetto_protos_perfetto_trace_system_info_zero_gen_headers", "perfetto_protos_perfetto_trace_track_event_zero_gen_headers", - "perfetto_src_base_version_gen_h", "perfetto_src_trace_processor_importers_gen_cc_config_descriptor", "perfetto_src_trace_processor_metrics_gen_cc_all_chrome_metrics_descriptor", "perfetto_src_trace_processor_metrics_gen_cc_metrics_descriptor", @@ -8780,7 +8735,6 @@ "perfetto_protos_perfetto_trace_system_info_zero_gen_headers", "perfetto_protos_perfetto_trace_track_event_zero_gen_headers", "perfetto_protos_third_party_pprof_zero_gen_headers", - "perfetto_src_base_version_gen_h", "perfetto_src_trace_processor_importers_gen_cc_config_descriptor", "perfetto_src_trace_processor_metrics_gen_cc_all_chrome_metrics_descriptor", "perfetto_src_trace_processor_metrics_gen_cc_metrics_descriptor", @@ -8944,7 +8898,6 @@ "perfetto_protos_perfetto_trace_system_info_zero_gen_headers", "perfetto_protos_perfetto_trace_track_event_cpp_gen_headers", "perfetto_protos_perfetto_trace_track_event_zero_gen_headers", - "perfetto_src_base_version_gen_h", ], defaults: [ "perfetto_defaults", @@ -9093,7 +9046,6 @@ "perfetto_protos_perfetto_trace_system_info_zero_gen_headers", "perfetto_protos_perfetto_trace_track_event_cpp_gen_headers", "perfetto_protos_perfetto_trace_track_event_zero_gen_headers", - "perfetto_src_base_version_gen_h", "perfetto_src_perfetto_cmd_protos_gen_headers", ], defaults: [
diff --git a/BUILD b/BUILD index bcba78d..cd7447d 100644 --- a/BUILD +++ b/BUILD
@@ -313,7 +313,6 @@ "include/perfetto/ext/base/unix_task_runner.h", "include/perfetto/ext/base/utils.h", "include/perfetto/ext/base/uuid.h", - "include/perfetto/ext/base/version.h", "include/perfetto/ext/base/waitable_event.h", "include/perfetto/ext/base/watchdog.h", "include/perfetto/ext/base/watchdog_noop.h", @@ -562,7 +561,6 @@ "src/base/unix_task_runner.cc", "src/base/utils.cc", "src/base/uuid.cc", - "src/base/version.cc", "src/base/virtual_destructors.cc", "src/base/waitable_event.cc", "src/base/watchdog_posix.cc", @@ -571,8 +569,6 @@ ":include_perfetto_base_base", ":include_perfetto_ext_base_base", ], - deps = [ - ] + PERFETTO_CONFIG.deps.version_header, linkstatic = True, ) @@ -589,20 +585,6 @@ linkstatic = True, ) -genrule( - name = "src_base_version_gen_h", - srcs = [ - "CHANGELOG", - ], - outs = [ - "perfetto_version.gen.h", - ], - cmd = "$(location gen_version_header_py) --cpp_out=$@", - exec_tools = [ - ":gen_version_header_py", - ], -) - # GN target: //src/ipc:client filegroup( name = "src_ipc_client", @@ -3469,20 +3451,6 @@ ], ) -# This is overridden in google internal builds via -# PERFETTO_CONFIG.deps.version_header (see perfetto_cfg.bzl). -perfetto_cc_library( - name = "cc_perfetto_version_header", - hdrs = ["perfetto_version.gen.h"], -) - -perfetto_py_binary( - name = "gen_version_header_py", - srcs = ["tools/write_version_header.py"], - main = "tools/write_version_header.py", - python_version = "PY3", -) - # Noop targets used to represent targets of the protobuf library. # These will be rewritten in Google3 to be dependencies on the real targets.
diff --git a/BUILD.extras b/BUILD.extras index 4a0dd08..83a17f0 100644 --- a/BUILD.extras +++ b/BUILD.extras
@@ -78,20 +78,6 @@ ], ) -# This is overridden in google internal builds via -# PERFETTO_CONFIG.deps.version_header (see perfetto_cfg.bzl). -perfetto_cc_library( - name = "cc_perfetto_version_header", - hdrs = ["perfetto_version.gen.h"], -) - -perfetto_py_binary( - name = "gen_version_header_py", - srcs = ["tools/write_version_header.py"], - main = "tools/write_version_header.py", - python_version = "PY3", -) - # Noop targets used to represent targets of the protobuf library. # These will be rewritten in Google3 to be dependencies on the real targets.
diff --git a/bazel/standalone/perfetto_cfg.bzl b/bazel/standalone/perfetto_cfg.bzl index 2d71aa8..d319db9 100644 --- a/bazel/standalone/perfetto_cfg.bzl +++ b/bazel/standalone/perfetto_cfg.bzl
@@ -34,12 +34,6 @@ # "perfetto_build_flags.h" file that can be included via: # #include "perfetto_build_flags.h". build_config = ["//:build_config_hdr"], - - # Target exposing the PERFETTO_VERSION_STRING() and - # PERFETTO_VERSION_SCM_REVISION() macros. This is overridden in google - # internal builds. - version_header = ["//:cc_perfetto_version_header"], - zlib = ["@perfetto_dep_zlib//:zlib"], jsoncpp = ["@perfetto_dep_jsoncpp//:jsoncpp"], linenoise = ["@perfetto_dep_linenoise//:linenoise"],
diff --git a/gn/gen_perfetto_version_header.gni b/gn/gen_perfetto_version_header.gni deleted file mode 100644 index a0c3ea6..0000000 --- a/gn/gen_perfetto_version_header.gni +++ /dev/null
@@ -1,51 +0,0 @@ -# Copyright (C) 2020 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. - -# This action generates a perfetto_version.gen.h which exposes some -# PERFETTO_VERSION_xxx() macros that contains the git revision and release -# number from the CHANGELOG. -# This template is used only in two places: in //base (for C++ code) and in -# //ui. This teamplate exists only to keep the logic consistent and avoid that -# base's and ui's logic diverge. - -import("perfetto.gni") - -template("gen_perfetto_version_header") { - action(target_name) { - script = "${perfetto_root_path}tools/write_version_header.py" - inputs = [ "${perfetto_root_path}CHANGELOG" ] - if (!is_perfetto_build_generator || perfetto_build_with_android) { - # Don't assume other build systems will fetch perfetto from a git - # checkout. - inputs += [ "${perfetto_root_path}.git/HEAD" ] - } - outputs = [] - args = [] - - if (defined(invoker.cpp_out)) { - args += [ - "--cpp_out", - rebase_path(invoker.cpp_out, root_build_dir), - ] - outputs += [ invoker.cpp_out ] - } - if (defined(invoker.ts_out)) { - args += [ - "--ts_out", - rebase_path(invoker.ts_out, root_build_dir), - ] - outputs += [ invoker.ts_out ] - } - } -}
diff --git a/gn/perfetto.gni b/gn/perfetto.gni index ba052c9..dd79c2a 100644 --- a/gn/perfetto.gni +++ b/gn/perfetto.gni
@@ -188,12 +188,11 @@ enable_perfetto_fuzzers = perfetto_build_standalone && defined(is_fuzzer) && is_fuzzer - # Enables the write_version_header.py tool that generates a .h that contains a - # macro with the current git revision and latest release version from - # CHANGELOG. If false base/version.h will return "unknown". + # Enables the gen_git_revision tool that generates a .h that contains a macro + # with the current git revision. Works only in standalone GN checkouts. + # If disabled, the version string will be "unknown". enable_perfetto_version_gen = - perfetto_build_standalone || is_perfetto_build_generator || - perfetto_build_with_android + perfetto_build_standalone && !is_perfetto_build_generator # Only for local development. When true the binaries (perfetto, traced, ...) # are monolithic and don't use a common shared library. This is mainly to
diff --git a/gn/standalone/BUILD.gn b/gn/standalone/BUILD.gn index 9527694..3938a89 100644 --- a/gn/standalone/BUILD.gn +++ b/gn/standalone/BUILD.gn
@@ -277,6 +277,22 @@ } } +config("gen_include_path") { + include_dirs = [ root_gen_dir ] +} + +# This action generates a perfetto_version.gen.h which contains the git SHA1 +# of HEAD. The file can be included from C/C++ sources and exposes a +# PERFETTO_GET_GIT_REVISION() macro that contains the git revision. +action("gen_git_revision") { + script = "gen_git_revision.py" + generated_header = "${root_gen_dir}/perfetto_version.gen.h" + args = [ rebase_path(generated_header, root_build_dir) ] + inputs = [] + outputs = [ generated_header ] + public_configs = [ ":gen_include_path" ] +} + # Checks that tools/install-build-deps has been run since it last changed. perfetto_check_build_deps("check_build_deps") { args = []
diff --git a/gn/standalone/gen_git_revision.py b/gn/standalone/gen_git_revision.py new file mode 100755 index 0000000..a45262a --- /dev/null +++ b/gn/standalone/gen_git_revision.py
@@ -0,0 +1,42 @@ +#!/usr/bin/env python +# Copyright (C) 2019 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 os +import subprocess +import sys + + +def main(argv): + if len(argv) != 2: + print('Usage: %s output_file.h' % argv[0]) + return 1 + script_dir = os.path.dirname(os.path.realpath(__file__)) + revision = subprocess.check_output( + ['git', '-C', script_dir, 'rev-parse', 'HEAD']).strip() + new_contents = '#define PERFETTO_GET_GIT_REVISION() "%s"\n' % revision + out_file = argv[1] + old_contents = '' + if os.path.isfile(out_file): + with open(out_file) as f: + old_contents = f.read() + if old_contents == new_contents: + return 0 + with open(out_file, 'w') as f: + f.write(new_contents) + return 0 + + +if __name__ == '__main__': + sys.exit(main(sys.argv))
diff --git a/include/perfetto/base/build_configs/android_tree/perfetto_build_flags.h b/include/perfetto/base/build_configs/android_tree/perfetto_build_flags.h index 7a34606..80d1ec5 100644 --- a/include/perfetto/base/build_configs/android_tree/perfetto_build_flags.h +++ b/include/perfetto/base/build_configs/android_tree/perfetto_build_flags.h
@@ -31,7 +31,7 @@ #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_FORCE_DLOG_ON() (0) #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_FORCE_DLOG_OFF() (0) #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_VERBOSE_LOGS() (1) -#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_VERSION_GEN() (1) +#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_VERSION_GEN() (0) #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_PERCENTILE() (0) #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_LINENOISE() (0) #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_HTTPD() (0)
diff --git a/include/perfetto/base/build_configs/bazel/perfetto_build_flags.h b/include/perfetto/base/build_configs/bazel/perfetto_build_flags.h index ae45e29..fc8f06a 100644 --- a/include/perfetto/base/build_configs/bazel/perfetto_build_flags.h +++ b/include/perfetto/base/build_configs/bazel/perfetto_build_flags.h
@@ -31,7 +31,7 @@ #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_FORCE_DLOG_ON() (0) #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_FORCE_DLOG_OFF() (0) #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_VERBOSE_LOGS() (1) -#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_VERSION_GEN() (1) +#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_VERSION_GEN() (0) #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_PERCENTILE() (1) #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_LINENOISE() (1) #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_HTTPD() (PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_ANDROID() || PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_LINUX() || PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_MAC())
diff --git a/include/perfetto/ext/base/BUILD.gn b/include/perfetto/ext/base/BUILD.gn index 45516be..66d3a4f 100644 --- a/include/perfetto/ext/base/BUILD.gn +++ b/include/perfetto/ext/base/BUILD.gn
@@ -44,7 +44,6 @@ "unix_task_runner.h", "utils.h", "uuid.h", - "version.h", "waitable_event.h", "watchdog.h", "watchdog_noop.h",
diff --git a/include/perfetto/ext/base/version.h b/include/perfetto/ext/base/version.h deleted file mode 100644 index 212424a..0000000 --- a/include/perfetto/ext/base/version.h +++ /dev/null
@@ -1,29 +0,0 @@ -/* - * Copyright (C) 2020 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. - */ - -#ifndef INCLUDE_PERFETTO_EXT_BASE_VERSION_H_ -#define INCLUDE_PERFETTO_EXT_BASE_VERSION_H_ - -namespace perfetto { -namespace base { - -// The returned pointer is a static string is safe to pass around. -const char* GetVersionString(); - -} // namespace base -} // namespace perfetto - -#endif // INCLUDE_PERFETTO_EXT_BASE_VERSION_H_
diff --git a/src/base/BUILD.gn b/src/base/BUILD.gn index 8a229a8..26c4ba9 100644 --- a/src/base/BUILD.gn +++ b/src/base/BUILD.gn
@@ -13,7 +13,6 @@ # limitations under the License. import("//build_overrides/build.gni") -import("../../gn/gen_perfetto_version_header.gni") import("../../gn/perfetto.gni") import("../../gn/perfetto_component.gni") import("../../gn/test.gni") @@ -39,7 +38,6 @@ "time.cc", "utils.cc", "uuid.cc", - "version.cc", "virtual_destructors.cc", "waitable_event.cc", "watchdog_posix.cc", @@ -59,23 +57,6 @@ if (enable_perfetto_stderr_crash_dump) { deps += [ ":debug_crash_stack_trace" ] } - - if (enable_perfetto_version_gen) { - deps += [ ":version_gen_h" ] - } -} - -if (enable_perfetto_version_gen) { - config("version_gen_config") { - include_dirs = [ root_gen_dir ] - } - - # Note: the build file translators (tools/gn_utils.py) depend on the hardcoded - # "//src/base:version_gen_h". If you rename this target, update build file - # translators accordingly. - gen_perfetto_version_header("version_gen_h") { - cpp_out = "${root_gen_dir}/perfetto_version.gen.h" - } } if (enable_perfetto_stderr_crash_dump) {
diff --git a/src/base/version.cc b/src/base/version.cc deleted file mode 100644 index 18569d3..0000000 --- a/src/base/version.cc +++ /dev/null
@@ -1,45 +0,0 @@ -/* - * Copyright (C) 2020 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. - */ - -#include "perfetto/ext/base/version.h" - -#include "perfetto/base/build_config.h" - -#include <stdio.h> - -#if PERFETTO_BUILDFLAG(PERFETTO_VERSION_GEN) -#include "perfetto_version.gen.h" -#else -#define PERFETTO_VERSION_STRING() "v0.0" -#define PERFETTO_VERSION_SCM_REVISION() "unknown" -#endif - -namespace perfetto { -namespace base { - -const char* GetVersionString() { - static const char* version_str = [] { - static constexpr size_t kMaxLen = 256; - char* version = new char[kMaxLen + 1]; - snprintf(version, kMaxLen, "Perfetto %s (%s)", PERFETTO_VERSION_STRING(), - PERFETTO_VERSION_SCM_REVISION()); - return version; - }(); - return version_str; -} - -} // namespace base -} // namespace perfetto
diff --git a/src/perfetto_cmd/perfetto_cmd.cc b/src/perfetto_cmd/perfetto_cmd.cc index 198abe2..e01778b 100644 --- a/src/perfetto_cmd/perfetto_cmd.cc +++ b/src/perfetto_cmd/perfetto_cmd.cc
@@ -41,7 +41,6 @@ #include "perfetto/ext/base/thread_utils.h" #include "perfetto/ext/base/utils.h" #include "perfetto/ext/base/uuid.h" -#include "perfetto/ext/base/version.h" #include "perfetto/ext/traced/traced.h" #include "perfetto/ext/tracing/core/basic_types.h" #include "perfetto/ext/tracing/core/trace_packet.h" @@ -204,7 +203,6 @@ OPT_STOP, OPT_QUERY, OPT_QUERY_RAW, - OPT_VERSION, }; static const struct option long_options[] = { {"help", no_argument, nullptr, 'h'}, @@ -230,7 +228,6 @@ {"app", required_argument, nullptr, OPT_ATRACE_APP}, {"query", no_argument, nullptr, OPT_QUERY}, {"query-raw", no_argument, nullptr, OPT_QUERY_RAW}, - {"version", no_argument, nullptr, OPT_VERSION}, {nullptr, 0, nullptr, 0}}; int option_index = 0; @@ -401,11 +398,6 @@ continue; } - if (option == OPT_VERSION) { - printf("%s\n", base::GetVersionString()); - return 0; - } - return PrintUsage(argv[0]); }
diff --git a/src/trace_processor/BUILD.gn b/src/trace_processor/BUILD.gn index 448e482..0808519 100644 --- a/src/trace_processor/BUILD.gn +++ b/src/trace_processor/BUILD.gn
@@ -349,6 +349,9 @@ "metrics:lib", "util", ] + if (enable_perfetto_version_gen) { + deps += [ "../../gn/standalone:gen_git_revision" ] + } if (enable_perfetto_trace_processor_linenoise) { deps += [ "../../gn:linenoise" ] }
diff --git a/src/trace_processor/trace_processor_shell.cc b/src/trace_processor/trace_processor_shell.cc index a1dc002..f5f4923 100644 --- a/src/trace_processor/trace_processor_shell.cc +++ b/src/trace_processor/trace_processor_shell.cc
@@ -35,7 +35,6 @@ #include "perfetto/ext/base/scoped_file.h" #include "perfetto/ext/base/string_splitter.h" #include "perfetto/ext/base/string_utils.h" -#include "perfetto/ext/base/version.h" #include "perfetto/trace_processor/read_trace.h" #include "perfetto/trace_processor/trace_processor.h" #include "src/trace_processor/metrics/chrome/all_chrome_metrics.descriptor.h" @@ -65,6 +64,12 @@ #include <sys/types.h> #endif +#if PERFETTO_BUILDFLAG(PERFETTO_VERSION_GEN) +#include "perfetto_version.gen.h" +#else +#define PERFETTO_GET_GIT_REVISION() "unknown" +#endif + #if PERFETTO_HAS_SIGNAL_H() #include <signal.h> #endif @@ -797,7 +802,7 @@ break; // EOF. if (option == 'v') { - printf("%s\n", base::GetVersionString()); + printf("%s\n", PERFETTO_GET_GIT_REVISION()); exit(0); }
diff --git a/src/traced/probes/BUILD.gn b/src/traced/probes/BUILD.gn index e568855..7eec236 100644 --- a/src/traced/probes/BUILD.gn +++ b/src/traced/probes/BUILD.gn
@@ -35,6 +35,9 @@ "../../../gn:default_deps", "../../tracing/ipc/producer", ] + if (enable_perfetto_version_gen) { + deps += [ "//gn/standalone:gen_git_revision" ] + } sources = [ "probes.cc" ] }
diff --git a/src/traced/probes/probes.cc b/src/traced/probes/probes.cc index 6ad1fe0..b05fd02 100644 --- a/src/traced/probes/probes.cc +++ b/src/traced/probes/probes.cc
@@ -22,13 +22,18 @@ #include "perfetto/base/logging.h" #include "perfetto/ext/base/unix_task_runner.h" -#include "perfetto/ext/base/version.h" #include "perfetto/ext/traced/traced.h" #include "perfetto/ext/tracing/ipc/default_socket.h" #include "src/traced/probes/ftrace/ftrace_procfs.h" #include "src/traced/probes/probes_producer.h" +#if PERFETTO_BUILDFLAG(PERFETTO_VERSION_GEN) +#include "perfetto_version.gen.h" +#else +#define PERFETTO_GET_GIT_REVISION() "unknown" +#endif + namespace perfetto { int __attribute__((visibility("default"))) ProbesMain(int argc, char** argv) { @@ -52,7 +57,7 @@ HardResetFtraceState(); return 0; case OPT_VERSION: - printf("%s\n", base::GetVersionString()); + printf("%s\n", PERFETTO_GET_GIT_REVISION()); return 0; default: PERFETTO_ELOG("Usage: %s [--cleanup-after-crash|--version]", argv[0]);
diff --git a/src/traced/service/BUILD.gn b/src/traced/service/BUILD.gn index 2ff0007..2b7798b 100644 --- a/src/traced/service/BUILD.gn +++ b/src/traced/service/BUILD.gn
@@ -42,6 +42,9 @@ "../../tracing/core:service", "../../tracing/ipc/service", ] + if (enable_perfetto_version_gen) { + deps += [ "//gn/standalone:gen_git_revision" ] + } sources = [ "builtin_producer.cc", "builtin_producer.h",
diff --git a/src/traced/service/service.cc b/src/traced/service/service.cc index c7918d0..d9a884e 100644 --- a/src/traced/service/service.cc +++ b/src/traced/service/service.cc
@@ -20,7 +20,6 @@ #include "perfetto/ext/base/string_utils.h" #include "perfetto/ext/base/unix_task_runner.h" -#include "perfetto/ext/base/version.h" #include "perfetto/ext/base/watchdog.h" #include "perfetto/ext/traced/traced.h" #include "perfetto/ext/tracing/ipc/default_socket.h" @@ -37,6 +36,12 @@ #include <unistd.h> #endif +#if PERFETTO_BUILDFLAG(PERFETTO_VERSION_GEN) +#include "perfetto_version.gen.h" +#else +#define PERFETTO_GET_GIT_REVISION() "unknown" +#endif + namespace perfetto { namespace { #if defined(PERFETTO_SET_SOCKET_PERMISSIONS) @@ -116,7 +121,7 @@ break; switch (option) { case OPT_VERSION: - printf("%s\n", base::GetVersionString()); + printf("%s\n", PERFETTO_GET_GIT_REVISION()); return 0; case OPT_SET_SOCKET_PERMISSIONS: { // Check that the socket permission argument is well formed.
diff --git a/tools/gen_amalgamated b/tools/gen_amalgamated index 95e9e97..63ad4dd 100755 --- a/tools/gen_amalgamated +++ b/tools/gen_amalgamated
@@ -581,13 +581,6 @@ args = parser.parse_args() targets = args.targets or default_targets - # The CHANGELOG mtime triggers the the perfetto_version.gen.h genrule. This is - # to avoid emitting a stale version information in the remote case of somebody - # running gen_amalgamated incrementally after having moved to another commit. - changelog_path = os.path.join(project_root, 'CHANGELOG') - assert(os.path.exists(changelog_path)) - subprocess.check_call(['touch', '-c', changelog_path]) - output = args.output if args.check: output = os.path.join(tempfile.mkdtemp(), 'perfetto_amalgamated')
diff --git a/tools/gen_android_bp b/tools/gen_android_bp index a697b1b..ec9c1b7 100755 --- a/tools/gen_android_bp +++ b/tools/gen_android_bp
@@ -747,21 +747,6 @@ return module -def create_gen_version_module(blueprint, target, bp_module_name): - module = Module('genrule', bp_module_name, gn_utils.GEN_VERSION_TARGET) - script_path = gn_utils.label_to_path(target.script) - module.genrule_headers.add(bp_module_name) - module.tool_files = [ script_path ] - module.out.update(target.outputs) - module.srcs.update(gn_utils.label_to_path(src) for src in target.inputs) - module.cmd = ' '.join([ - 'python3 $(location %s)' % script_path, - '--cpp_out=$(out)' - ]) - blueprint.add_module(module) - return module - - def _get_cflags(target): cflags = {flag for flag in target.cflags if re.match(cflag_allowlist, flag)} cflags |= set("-D%s" % define @@ -816,9 +801,6 @@ module = create_merged_sql_metrics_module(blueprint, target) elif re.match('.*gen_cc_.*_descriptor$', target.name): module = create_cc_proto_descriptor_module(blueprint, target) - elif target.type == 'action' and gn_utils.label_without_toolchain( - target.name) == gn_utils.GEN_VERSION_TARGET: - module = create_gen_version_module(blueprint, target, bp_module_name) else: raise Error('Unhandled action: {}'.format(target.name)) else:
diff --git a/tools/gen_bazel b/tools/gen_bazel index 6a9fd40..75bb2c7 100755 --- a/tools/gen_bazel +++ b/tools/gen_bazel
@@ -103,10 +103,10 @@ 'PERFETTO_CONFIG.deps.sqlite_ext_percentile' ], '//gn:zlib': ['PERFETTO_CONFIG.deps.zlib'], + '//gn/standalone:gen_git_revision': [], '//src/trace_processor/metrics:gen_merged_sql_metrics': [[ ':cc_merged_sql_metrics' - ]], - gn_utils.GEN_VERSION_TARGET: ['PERFETTO_CONFIG.deps.version_header'], + ]] } @@ -119,15 +119,6 @@ return [label] -def gen_version_header(target): - label = BazelLabel(get_bazel_label_name(target.name), 'genrule') - label.srcs += [re.sub('^//', '', x) for x in sorted(target.inputs)] - label.outs += target.outputs - label.cmd = r'$(location gen_version_header_py) --cpp_out=$@' - label.exec_tools += [':gen_version_header_py'] - return [label] - - def gen_cc_metrics_descriptor(target): label = BazelLabel( get_bazel_label_name(target.name), 'perfetto_cc_proto_descriptor') @@ -137,7 +128,6 @@ custom_actions = { - gn_utils.GEN_VERSION_TARGET: gen_version_header, '//src/trace_processor/metrics:gen_merged_sql_metrics': gen_sql_metrics, '//src/trace_processor/metrics:gen_cc_metrics_descriptor': gen_cc_metrics_descriptor,
diff --git a/tools/gn_utils.py b/tools/gn_utils.py index 45c5885..015b58d 100644 --- a/tools/gn_utils.py +++ b/tools/gn_utils.py
@@ -28,7 +28,6 @@ from compat import iteritems BUILDFLAGS_TARGET = '//gn:gen_buildflags' -GEN_VERSION_TARGET = '//src/base:version_gen_h' TARGET_TOOLCHAIN = '//gn/standalone/toolchain:gcc_like_host' HOST_TOOLCHAIN = '//gn/standalone/toolchain:gcc_like_host' LINKER_UNIT_TYPES = ('executable', 'shared_library', 'static_library')
diff --git a/tools/trace_to_text/BUILD.gn b/tools/trace_to_text/BUILD.gn index 70b4169..fe71f33 100644 --- a/tools/trace_to_text/BUILD.gn +++ b/tools/trace_to_text/BUILD.gn
@@ -117,6 +117,9 @@ "trace_to_systrace.h", "trace_to_text.h", ] + if (enable_perfetto_version_gen) { + deps += [ "//gn/standalone:gen_git_revision" ] + } } # Lite target for the WASM UI. Doesn't have any dependency on libprotobuf-full.
diff --git a/tools/trace_to_text/main.cc b/tools/trace_to_text/main.cc index 467b3fb..3e7cb1a 100644 --- a/tools/trace_to_text/main.cc +++ b/tools/trace_to_text/main.cc
@@ -23,7 +23,6 @@ #include "perfetto/base/logging.h" #include "perfetto/ext/base/string_utils.h" -#include "perfetto/ext/base/version.h" #include "tools/trace_to_text/deobfuscate_profile.h" #include "tools/trace_to_text/symbolize_profile.h" #include "tools/trace_to_text/trace_to_hprof.h" @@ -32,6 +31,11 @@ #include "tools/trace_to_text/trace_to_systrace.h" #include "tools/trace_to_text/trace_to_text.h" +#if PERFETTO_BUILDFLAG(PERFETTO_VERSION_GEN) +#include "perfetto_version.gen.h" +#else +#define PERFETTO_GET_GIT_REVISION() "unknown" +#endif #if !PERFETTO_BUILDFLAG(PERFETTO_OS_WIN) #include <unistd.h> @@ -75,7 +79,7 @@ bool full_sort = false; for (int i = 1; i < argc; i++) { if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0) { - printf("%s\n", base::GetVersionString()); + printf("%s\n", PERFETTO_GET_GIT_REVISION()); return 0; } else if (strcmp(argv[i], "-t") == 0 || strcmp(argv[i], "--truncate") == 0) {
diff --git a/tools/write_version_header.py b/tools/write_version_header.py deleted file mode 100755 index e189538..0000000 --- a/tools/write_version_header.py +++ /dev/null
@@ -1,137 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2020 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. -""" -Writes the perfetto_version{.gen.h, .ts} files. - -This tool is run as part of a genrule from GN, SoonG and Bazel builds. It -generates a source header (or in the case of --ts_out a TypeScript file) that -contains: -- The version number (e.g. v9.0) obtained parsing the CHANGELOG file. -- The git HEAD's commit-ish (e.g. 6b330b772b0e973f79c70ba2e9bb2b0110c6715d) -- The number of CLs from the release tag to HEAD. - -The latter is concatenated to the version number to distinguish builds made -fully from release tags (e.g., v9.0.0) vs builds made from the main branch which -are N cls ahead of the latest monthly release (e.g., v9.0.42). -""" - -import argparse -import os -import re -import sys -import subprocess - -# Note: PROJECT_ROOT is not accurate in bazel builds, where this script is -# executed in the bazel sandbox. -PROJECT_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) - - -def get_latest_release(): - """Returns a string like 'v9.0'. - - It does so by searching the latest version mentioned in the CHANGELOG.""" - if os.path.exists('CHANGELOG'): - changelog_path = 'CHANGELOG' - else: - changelog_path = os.path.join(PROJECT_ROOT, 'CHANGELOG') - with open(changelog_path) as f: - for line in f.readlines(): - m = re.match('^(v\d+[.]\d+)\s.*$', line) - if m is not None: - return m.group(1) - raise Exception('Failed to fetch Perfetto version from %s' % changelog_path) - - -def get_git_info(last_release_tag): - """Returns a tuple ('deadbeef', '1234'). - - The first value is the SHA1 of the HEAD. The second is the number of CLs from - the passed |last_release_tag| to HEAD.""" - commit_sha1 = 'unknown' - commits_since_release = '' - git_dir = os.path.join(PROJECT_ROOT, '.git') - if os.path.exists(git_dir): - try: - commit_sha1 = subprocess.check_output(['git', 'rev-parse', 'HEAD'], - cwd=PROJECT_ROOT).strip().decode() - with open(os.devnull, 'wb') as devnull: - commits_since_release = subprocess.check_output( - [ - 'git', 'rev-list', '--count', - 'refs/tags/%s..HEAD' % last_release_tag - ], - cwd=PROJECT_ROOT, - stderr=devnull).strip().decode() - except subprocess.CalledProcessError: - pass - - return (commit_sha1, commits_since_release) - - -def write_if_unchanged(path, content): - prev_content = None - if os.path.exists(path): - with open(path, 'r') as fprev: - prev_content = fprev.read() - if prev_content == content: - return 0 - with open(path, 'w') as fout: - fout.write(content) - - -def main(): - parser = argparse.ArgumentParser() - parser.add_argument('--cpp_out', help='Path of the generated .h file.') - parser.add_argument('--ts_out', help='Path of the generated .ts file.') - args = parser.parse_args() - - release = get_latest_release() - git_sha1, commits_since_release = get_git_info(release) - - # Try to compute the number of commits since the last release. This can fail - # in some environments (e.g. in android builds) because the bots pull only - # the main branch and don't pull the whole list of tags. - if commits_since_release: - version = '%s.%s' % (release, commits_since_release) # e.g., v9.0.42 . - else: - version = release # e.g., v9.0 . - - if args.cpp_out: - guard = '%s_' % args.cpp_out.upper() - guard = re.sub(r'[^\w]', '_', guard) - lines = [] - lines.append('// Generated by %s' % __file__) - lines.append('') - lines.append('#ifndef %s' % guard) - lines.append('#define %s' % guard) - lines.append('') - lines.append('#define PERFETTO_VERSION_STRING() "%s"' % version) - lines.append('#define PERFETTO_VERSION_SCM_REVISION() "%s"' % git_sha1) - lines.append('') - lines.append('#endif // %s' % guard) - lines.append('') - content = '\n'.join(lines) - write_if_unchanged(args.cpp_out, content) - - if args.ts_out: - lines = [] - lines.append('export const VERSION = "%s";' % version) - lines.append('export const SCM_REVISION = "%s";' % git_sha1) - content = '\n'.join(lines) - write_if_unchanged(args.ts_out, content) - - -if __name__ == '__main__': - sys.exit(main())
diff --git a/ui/BUILD.gn b/ui/BUILD.gn index 2aec99a..2c5722d 100644 --- a/ui/BUILD.gn +++ b/ui/BUILD.gn
@@ -12,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("../gn/gen_perfetto_version_header.gni") import("../gn/perfetto.gni") import("../gn/perfetto_check_build_deps.gni") import("../gn/wasm.gni") @@ -270,7 +269,6 @@ deps = [ ":dist_symlink", ":protos_to_ts", - ":version_ts_gen", ":wasm_gen", ] inputs = [ "tsconfig.json" ] @@ -600,7 +598,3 @@ rebase_path(ui_dir, root_build_dir), ] + dist_files } - -gen_perfetto_version_header("version_ts_gen") { - ts_out = "$ui_gen_dir/perfetto_version.ts" -}
diff --git a/ui/src/assets/sidebar.scss b/ui/src/assets/sidebar.scss index b368214..5bdc7cb 100644 --- a/ui/src/assets/sidebar.scss +++ b/ui/src/assets/sidebar.scss
@@ -182,7 +182,6 @@ .sidebar-footer { position: absolute; bottom: 0; - width: 100%; padding: 2px 10px; display: grid; height: - var(--sidebar-padding-bottom); @@ -227,19 +226,6 @@ line-height: 11px; } } - - .version { - position: absolute; - right: 8px; - bottom: 3px; - font-size: 12px; - font-family: 'Roboto Condensed', 'Roboto', sans-serif; - a { - color: rgba(255, 255, 255, 0.5); - text-decoration: none; - } - margin-top: 11px; - } } }
diff --git a/ui/src/base/logging.ts b/ui/src/base/logging.ts index 75a02ca..25c37d5 100644 --- a/ui/src/base/logging.ts +++ b/ui/src/base/logging.ts
@@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -import * as version from '../gen/perfetto_version'; - export type ErrorHandler = (err: string) => void; let errorHandler: ErrorHandler = (_: string) => {}; @@ -57,10 +55,8 @@ errLog += '\n'; errLog += errStack !== undefined ? errStack : JSON.stringify(errorObj); } - errLog += '\n\n'; - errLog += `${version.VERSION} ${version.SCM_REVISION}\n`; - errLog += `UA: ${navigator.userAgent}\n`; + errLog += `\n\nUA: ${navigator.userAgent}\n`; console.error(errLog, err); errorHandler(errLog); -} +} \ No newline at end of file
diff --git a/ui/src/frontend/sidebar.ts b/ui/src/frontend/sidebar.ts index 56eeb89..07798d8 100644 --- a/ui/src/frontend/sidebar.ts +++ b/ui/src/frontend/sidebar.ts
@@ -18,7 +18,6 @@ import {Actions} from '../common/actions'; import {QueryResponse} from '../common/queries'; import {EngineMode, TraceArrayBufferSource} from '../common/state'; -import * as version from '../gen/perfetto_version'; import {Animation} from './animation'; import {copyToClipboard} from './clipboard'; @@ -691,16 +690,6 @@ 'assessment')), m(EngineRPCWidget), m(ServiceWorkerWidget), - m( - '.version', - m('a', - { - href: `https://github.com/google/perfetto/tree/${ - version.SCM_REVISION}/ui`, - target: '_blank', - }, - `${version.VERSION}`), - ), ); } };