# Copyright 2020 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

assert(is_fuchsia)

import("//build/util/generate_wrapper.gni")

template("compute_fuchsia_package_sizes") {
  generate_wrapper(target_name) {
    forward_variables_from(invoker,
                           [
                             "data",
                             "data_deps",
                           ])
    testonly = true
    executable = "//build/fuchsia/binary_sizes.py"
    wrapper_script = "$root_out_dir/bin/run_${target_name}"

    assert(target_cpu == "arm64" || target_cpu == "x64",
           "target_cpu must be arm64 or x64")

    if (!defined(data)) {
      data = []
    }

    if (!defined(data_deps)) {
      data_deps = []
    }

    # Declares the files that are needed for test execution on the
    # swarming test client.
    # TODO(crbug.com/1347172): Remove arm64 once the execution of fuchsia_sizes
    # has been migrated to x64 machines.
    data += [
      "//build/fuchsia/",
      "//tools/fuchsia/size_tests/",
      "//third_party/fuchsia-sdk/sdk/arch/",
      "//third_party/fuchsia-sdk/sdk/tools/arm64/",
      "//third_party/fuchsia-sdk/sdk/tools/x64/",
    ]

    executable_args = [
      "--output-directory",
      "@WrappedPath(.)",
    ]
    if (defined(invoker.executable_args)) {
      executable_args += invoker.executable_args
    }
  }
}