# 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("gn/perfetto.gni")
import("gn/test.gni")

# +----------------------------------------------------------------------------+
# | "all" targets definition: defines targets reachable by the various configs |
# +----------------------------------------------------------------------------+
# There is a subtletly here related with chromium and other GN embedders.
# When adding a dependency some_dir/:target_name, some_dir/BUILD.gn is
# "discovered". As a side effect any *other* target defined in some_dir/BUILD.gn
# (and its transitive dependencies) becomes implicitly part of the "default"
# target, the one invoked running ninja -C out/xxx without further args.
# Because of this, care must be taken to wrap dependencies to targets in other
# build files with if (enable_xxx) flags. Accidentally including a harmless
# target that happens to be defined in the same BUILD.gn that contains targets
# incompatible with the chromium build will cause build/roll failures.

all_targets = [ "protos/perfetto/trace:perfetto_trace_protos" ]

if (enable_perfetto_platform_services) {
  all_targets += [
    "src/perfetto_cmd:perfetto",
    "src/perfetto_cmd:trigger_perfetto",
    "src/traced/service:traced",
  ]
  if (enable_perfetto_traced_probes) {
    all_targets += [ "src/traced/probes:traced_probes" ]
  }
  if (enable_perfetto_traced_relay) {
    all_targets += [ "src/traced_relay:traced_relay" ]
  }
}

if (enable_perfetto_trace_processor && enable_perfetto_trace_processor_sqlite) {
  all_targets += [ "src/trace_processor:trace_processor_shell" ]
}

if (enable_perfetto_trace_processor) {
  all_targets += [ "src/trace_redaction:trace_redactor" ]
}

if (enable_perfetto_traceconv) {
  all_targets += [ "src/traceconv" ]
  if (is_cross_compiling) {
    # In many cross-compilation scenarios (typically Android) developers expect
    # the host version of traceconv to be available somewhere in out/, so
    # they can convert Android traces on their dev machine. Also
    # tools/gen_android_bp explicitly depends on the host version for the
    # cc_binary_host("traceconv") target in Android.bp.
    # Note that when cross-compiling the host executable will be available in
    # out/xxx/gcc_like_host/traceconv NOT just out/xxx/traceconv.
    all_targets += [ "src/traceconv($host_toolchain)" ]
  }
}

if (enable_perfetto_heapprofd) {
  all_targets += [ "src/profiling/memory:heapprofd" ]

  if (is_linux && !is_android) {
    all_targets += [ "src/profiling/memory:heapprofd_glibc_preload" ]
  }
  if (perfetto_build_with_android) {
    all_targets += [
      "src/profiling/memory:heapprofd_client",
      "src/profiling/memory:heapprofd_client_api",
    ]
  }
}

if (enable_perfetto_traced_perf) {
  all_targets += [ "src/profiling/perf:traced_perf" ]
}

if (perfetto_build_with_android) {
  all_targets += [ "src/android_internal:libperfetto_android_internal" ]
}

if (enable_perfetto_tools) {
  all_targets += [ "src/tools" ]

  # Windows does not have an IPC implementation.
  if (!is_win) {
    all_targets += [ "src/websocket_bridge" ]
  }
}

if (enable_perfetto_unittests) {
  import("gn/perfetto_unittests.gni")
  test("perfetto_unittests") {
    if (is_fuchsia) {
      additional_manifest_fragments =
          [ "//build/config/fuchsia/test/network.shard.test-cml" ]  # nogncheck
    }
    deps = perfetto_unittests_targets
  }
  all_targets += [ ":perfetto_unittests" ]
}

if (enable_perfetto_integration_tests) {
  import("gn/perfetto_integrationtests.gni")
  test("perfetto_integrationtests") {
    deps = perfetto_integrationtests_targets
  }
  all_targets += [
    ":perfetto_integrationtests",
    "examples/sdk:sdk_example",
    "test:client_api_example",
    "test/stress_test",
  ]
  if (!is_win && !is_mac) {
    all_targets += [
      "examples/shared_lib:example_shlib_data_source",
      "examples/shared_lib:example_shlib_track_event",
    ]
  }
}

if (enable_perfetto_trace_processor_json) {
  test("trace_processor_minimal_smoke_tests") {
    testonly = true
    deps = [
      "gn:default_deps",
      "src/trace_processor:storage_minimal_smoke_tests",
    ]
  }
  all_targets += [ ":trace_processor_minimal_smoke_tests" ]
}

if (enable_perfetto_benchmarks) {
  import("gn/perfetto_benchmarks.gni")
  executable("perfetto_benchmarks") {
    testonly = true
    deps = perfetto_benchmarks_targets
  }
  all_targets += [ ":perfetto_benchmarks" ]
}

if (enable_perfetto_fuzzers) {
  import("gn/perfetto_fuzzers.gni")
  group("fuzzers") {
    testonly = true
    deps = perfetto_fuzzers_targets
  }
  all_targets += [ ":fuzzers" ]
}

# Less interesting stuff that makes sense only in the standalone build, mainly
# compile-time checks for the CI.
if (perfetto_build_standalone) {
  all_targets += [
    "test/configs",

    # Used to evaluate the Python folder for Bazel script generation.
    "python:trace_processor_py",

    # For syntax-checking the protos.
    "protos/perfetto/trace:merged_trace_lite",

    # For checking all generated xxx.gen.{cc,h} files without waiting for
    # embedders to try to use them and fail.
    "protos/perfetto/config:cpp",
    "protos/perfetto/common:cpp",

    # Used in the when updating the ftrace protos
    "protos/perfetto/trace/ftrace:descriptor",

    # Checks that the "fake" backend implementations build.
    "src/tracing:client_api_no_backends_compile_test",
  ]
  if (is_linux || is_android || is_mac) {
    all_targets += [ "src/tracebox" ]
  }
}

# The CTS code is built (but not ran) also in standalone builds. This is to
# catch refactoring breakages earlier without having to wait for treehugger.
if (is_android && (perfetto_build_standalone || perfetto_build_with_android)) {
  all_targets += [ "test/cts:perfetto_cts_deps" ]
  all_targets += [ "test/vts:perfetto_vts_deps" ]
}

group("all") {
  testonly = true  # allow to build also test targets
  deps = all_targets
}

# This target is used when running ninja without any argument (by default would
# build all reachable targets). This is mainly used to prevent the UI being
# built when running ninja -C out/xxx.
# This has effect only in standalone builds, no effect on chromium builds.
# Chromium's "all" target depends on our "all" target above. However chromium's
# "default" target depends on any target that we cause to be discovered by
# depending on other GN files.
group("default") {
  testonly = true
  deps = [ ":all" ]
}

# +----------------------------------------------------------------------------+
# | Other definitions: root targets that don't belong to any other subdirectory|
# +----------------------------------------------------------------------------+

if (enable_perfetto_ui) {
  group("ui") {
    deps = [ "ui" ]
  }
}

if (enable_perfetto_site) {
  group("site") {
    deps = [ "infra/perfetto.dev:site" ]
  }
}

# In Android builds, we build the code of traced and traced_probes in one shared
# library that exposes one xxx_main() for each. The executables themselves are
# tiny shells that just invoke their own entry point into the library.
# This is done merely for saving binary size, because the three binaries happen
# to share a lot of code.
# When setting monolithic_binaries=true (only supported in standalone builds)
# it builds more conventional executables, where each binary has the full
# implementation and no shared library dependency. This is to make dev cycles
# on Android faster, avoiding all the LD_LIBRARY_PATH boilerplate.
# libperfetto.so is also used for stuff that is exposed to the rest of the
# Android tree.
if (enable_perfetto_platform_services) {
  if (monolithic_binaries) {
    libperfetto_target_type = "static_library"
  } else {
    libperfetto_target_type = "shared_library"
  }

  target(libperfetto_target_type, "libperfetto") {
    if (libperfetto_target_type == "static_library") {
      complete_static_lib = true
    }
    deps = [
      "gn:default_deps",
      "src/traced/service",
    ]
    if (enable_perfetto_traced_probes) {
      deps += [ "src/traced/probes" ]
    }
  }
}

if (!build_with_chromium) {
  # Client library target exposed to the Android tree.
  # Still in experimental stage and not API stable yet.
  # See "libperfetto_client_example" (in Android.bp.extras) for an example
  # on how to use the Perfetto Client API from the android tree.
  static_library("libperfetto_client_experimental") {
    complete_static_lib = true
    public_deps = [
      "gn:default_deps",
      "src/tracing:client_api",
      "src/tracing:platform_impl",
    ]
    sources = [ "include/perfetto/tracing.h" ]
    assert_no_deps = [ "gn:protobuf_lite" ]
  }
}

# TODO(primiano): there seem to be two "libperfetto" and one
# "libperfetto_client_experimental" targets defined within this BUILD.gn file.
# Rationalize them with eseckler@. For now seems this one is only used from
# chromium and the other one only from the Android tree.
if (build_with_chromium) {
  component("libperfetto") {
    public_configs = [ "gn:public_config" ]
    deps = [
      "src/trace_processor/importers/memory_tracker:graph_processor",
      "src/tracing:client_api",
      "src/tracing:platform_impl",
      "src/tracing/core",
    ]
    configs -= [ "//build/config/compiler:chromium_code" ]  # nogncheck
    configs += [ "//build/config/compiler:no_chromium_code" ]  # nogncheck
    public_deps = [
      "include/perfetto/ext/trace_processor/importers/memory_tracker",
      "include/perfetto/ext/tracing/core",
      "include/perfetto/tracing",
      "protos/perfetto/common:zero",
      "protos/perfetto/trace:zero",
      "protos/perfetto/trace/chrome:zero",
      "protos/perfetto/trace/etw:zero",
      "protos/perfetto/trace/interned_data:zero",
      "protos/perfetto/trace/profiling:zero",
      "protos/perfetto/trace/ps:zero",
      "protos/perfetto/trace/track_event:zero",
    ]
    if (enable_perfetto_ipc) {
      deps += [
        "src/tracing/ipc/producer",
        "src/tracing/ipc/service",
      ]
      public_deps += [ "include/perfetto/ext/tracing/ipc:ipc" ]
    }
    if (!is_nacl) {
      deps += [
        "src/trace_processor:export_json",
        "src/trace_processor:storage_minimal",
      ]
      public_deps += [
        "include/perfetto/ext/trace_processor:export_json",
        "include/perfetto/trace_processor:storage",
      ]
    }
  }

  # TODO(altimin): this is a temp workaround around very strange link failures
  # on win-dbg-ng buildbot.
  if (!is_win) {
    libtrace_processor_target_type = "source_set"
  } else {
    libtrace_processor_target_type = "component"
  }

  # In Chromium, we want to ensure that we don't link dynamically against sqlite
  # (as Chromium also uses a more restricted version of sqlite which is actually
  # shipped to the users).
  # source_set helps us to achieve that.
  target(libtrace_processor_target_type, "libtrace_processor") {
    public_configs = [ "gn:public_config" ]
    deps = [ "src/trace_processor:lib" ]
    configs -= [ "//build/config/compiler:chromium_code" ]  # nogncheck
    configs += [ "//build/config/compiler:no_chromium_code" ]  # nogncheck
    public_deps = [ "include/perfetto/trace_processor" ]
  }
  component("perfetto_test_support") {
    testonly = true
    public_configs = [ "gn:public_config" ]
    configs -= [ "//build/config/compiler:chromium_code" ]  # nogncheck
    configs += [ "//build/config/compiler:no_chromium_code" ]  # nogncheck
    public_deps = [ "include/perfetto/test:test_support" ]
    deps = [ "src/tracing/test:test_support" ]
  }
}
