| # Copyright (C) 2017 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("//build_overrides/build.gni") |
| import("../../gn/gen_perfetto_version_header.gni") |
| import("../../gn/perfetto.gni") |
| import("../../gn/perfetto_component.gni") |
| import("../../gn/test.gni") |
| import("../../gn/wasm.gni") |
| |
| # On standalone builds this is all the OSes we support. On chromium builds, |
| # though, this really means !is_fuchsia && !is_nacl. |
| _subprocess_supported = |
| is_linux || is_chromeos || is_android || is_mac || is_win |
| |
| perfetto_component("base") { |
| deps = [ "../../gn:default_deps" ] |
| public_deps = [ |
| "../../include/perfetto/base", |
| "../../include/perfetto/ext/base", |
| ] |
| sources = [ |
| "android_utils.cc", |
| "base64.cc", |
| "crash_keys.cc", |
| "ctrl_c_handler.cc", |
| "event_fd.cc", |
| "file_utils.cc", |
| "getopt_compat.cc", |
| "log_ring_buffer.h", |
| "logging.cc", |
| "metatrace.cc", |
| "paged_memory.cc", |
| "periodic_task.cc", |
| "pipe.cc", |
| "status.cc", |
| "string_splitter.cc", |
| "string_utils.cc", |
| "string_view.cc", |
| "temp_file.cc", |
| "thread_checker.cc", |
| "time.cc", |
| "utils.cc", |
| "uuid.cc", |
| "version.cc", |
| "virtual_destructors.cc", |
| "waitable_event.cc", |
| "watchdog_posix.cc", |
| ] |
| |
| if (!is_nacl) { |
| sources += [ |
| "thread_task_runner.cc", |
| "unix_task_runner.cc", |
| ] |
| } |
| |
| if (_subprocess_supported) { |
| sources += [ |
| "subprocess.cc", |
| "subprocess_posix.cc", |
| "subprocess_windows.cc", |
| ] |
| } |
| |
| 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) { |
| source_set("debug_crash_stack_trace") { |
| sources = [ "debug_crash_stack_trace.cc" ] |
| deps = [ |
| "../../gn:default_deps", |
| "../../include/perfetto/ext/base", |
| "../../include/perfetto/ext/base", |
| ] |
| if (is_linux || is_android) { |
| deps += [ "../../gn:libbacktrace" ] |
| } |
| cflags = [ "-Wno-deprecated" ] |
| } |
| } |
| |
| if (enable_perfetto_ipc) { |
| # This cannot be in :base as it does not build on WASM. |
| perfetto_component("unix_socket") { |
| deps = [ |
| "../../gn:default_deps", |
| "../../include/perfetto/ext/base", |
| ] |
| sources = [ "unix_socket.cc" ] |
| if (is_win && perfetto_build_standalone) { |
| libs = [ "Ws2_32.lib" ] |
| } |
| } |
| } |
| |
| source_set("test_support") { |
| testonly = true |
| deps = [ |
| ":base", |
| "../../gn:default_deps", |
| ] |
| sources = [ |
| "test/tmp_dir_tree.cc", |
| "test/tmp_dir_tree.h", |
| "test/utils.cc", |
| "test/utils.h", |
| "test/vm_test_utils.cc", |
| "test/vm_test_utils.h", |
| ] |
| |
| if (!is_nacl) { |
| # test_task_runner depends on unix_task_runner, which isn't available on |
| # NaCL. |
| sources += [ |
| "test/test_task_runner.cc", |
| "test/test_task_runner.h", |
| ] |
| } |
| } |
| |
| perfetto_unittest_source_set("unittests") { |
| testonly = true |
| deps = [ |
| ":base", |
| ":test_support", |
| "../../gn:default_deps", |
| "../../gn:gtest_and_gmock", |
| ] |
| |
| sources = [ |
| "base64_unittest.cc", |
| "circular_queue_unittest.cc", |
| "flat_set_unittest.cc", |
| "getopt_compat_unittest.cc", |
| "logging_unittest.cc", |
| "no_destructor_unittest.cc", |
| "optional_unittest.cc", |
| "paged_memory_unittest.cc", |
| "periodic_task_unittest.cc", |
| "scoped_file_unittest.cc", |
| "string_splitter_unittest.cc", |
| "string_utils_unittest.cc", |
| "string_view_unittest.cc", |
| "string_writer_unittest.cc", |
| "task_runner_unittest.cc", |
| "temp_file_unittest.cc", |
| "thread_checker_unittest.cc", |
| "time_unittest.cc", |
| "utils_unittest.cc", |
| "uuid_unittest.cc", |
| "weak_ptr_unittest.cc", |
| ] |
| if (_subprocess_supported) { |
| # Don't run on Fuchsia, NaCL. They pretend to be POSIX but then give up on |
| # execve(2). |
| sources += [ "subprocess_unittest.cc" ] |
| } |
| |
| # TODO: Enable these for Windows when possible. |
| if (!is_win) { |
| sources += [ |
| "metatrace_unittest.cc", |
| "thread_task_runner_unittest.cc", |
| "watchdog_posix_unittest.cc", |
| ] |
| } |
| if (is_fuchsia) { |
| deps += [ "//third_party/fuchsia-sdk/sdk/pkg/fdio" ] |
| } |
| if (perfetto_build_standalone || perfetto_build_with_android) { |
| # This causes some problems on the chromium waterfall. |
| if (is_linux || is_android) { |
| sources += [ "watchdog_unittest.cc" ] |
| } |
| sources += [ "unix_socket_unittest.cc" ] |
| deps += [ ":unix_socket" ] |
| } |
| } |
| |
| if (enable_perfetto_benchmarks) { |
| source_set("benchmarks") { |
| testonly = true |
| deps = [ |
| ":base", |
| "../../gn:benchmark", |
| "../../gn:default_deps", |
| ] |
| sources = [ "flat_set_benchmark.cc" ] |
| } |
| } |