# Copyright (C) 2018 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")

# Prevent that this file is accidentally included in embedder builds.
assert(enable_perfetto_tools)

# Lists all tools. The root "all" target depends on this.
group("tools") {
  testonly = true
  deps = [
    ":copy_protoc",
    ":idle_alloc",
    "compact_reencode",
    "ftrace_proto_gen",
    "protoprofile",
  ]
  if (is_linux || is_android) {
    deps += [
      "busy_threads",
      "cpu_utilization",
      "dump_ftrace_stats",
      "skippy",
    ]
  }
  if (enable_perfetto_tools_trace_to_text) {
    deps += [
      "trace_to_text",
      "trace_to_text:trace_to_text_lite",
    ]
  }
}

if (is_linux && enable_perfetto_heapprofd) {
  executable("profiling_sample_distribution") {
    sources = [ "profiling_sample_distribution.cc" ]
    deps = [
      "../gn:default_deps",
      "../src/base",
      "../src/profiling/memory:client",
    ]
  }
}

executable("idle_alloc") {
  deps = [ "../gn:default_deps" ]
  sources = [ "idle_alloc.cc" ]
}

# The protoc binary can end up in out/protoc or out/gcc_like_host/protoc
# depending on whether this is a pure-host build vs a host+target (i.e. android)
# build. This rule ensures that in both cases we end up with a host binary in
# out/protoc, so tools can consistently refer to that one location.
protoc_target = "../gn:protoc($host_toolchain)"
if (current_toolchain != host_toolchain) {
  copy("copy_protoc") {
    testonly = true
    deps = [ protoc_target ]
    host_out_dir = get_label_info(protoc_target, "root_out_dir")
    sources = [ "$host_out_dir/protoc" ]
    outputs = [ "$root_build_dir/protoc" ]
  }
} else {
  # Nothing to do, in this case protoc is already built in the root out dir.
  group("copy_protoc") {
    public_deps = [ protoc_target ]
  }
}
