# 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.

import("../../../gn/perfetto.gni")

config("include_path") {
  include_dirs = [ target_gen_dir ]
}

action("configs") {
  testonly = true

  sources = [
    "backfills.cfg",
    "bursts.cfg",
    "heavy.cfg",
    "simple.cfg",
    "stalls.cfg",
    "xxl_packets.cfg",
  ]

  protoc_target = "../../../gn:protoc($host_toolchain)"
  protoc_out_dir = get_label_info(protoc_target, "root_out_dir")
  protoc_rel_dir = rebase_path(protoc_out_dir, root_build_dir)
  out_header = "$target_gen_dir/stress_test_config_blobs.h"
  out_header_rel = rebase_path(out_header, root_build_dir)
  protoc_ext = ""
  if (host_os == "win") {
    protoc_ext = ".exe"
  }

  deps = [ protoc_target ]
  script = "../gen_configs_blob.py"
  outputs = [ out_header ]
  args = [
    "--protoc=$protoc_rel_dir/protoc${protoc_ext}",
    "--out=$out_header_rel",
  ]
  foreach(source, sources) {
    args += [ rebase_path(source, root_build_dir) ]
  }
  public_configs = [ ":include_path" ]
}
