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

action("histograms_xml") {
  script = "histograms/merge_xml.py"
  sources = [
    "histograms/enums.xml",
    "histograms/histograms.xml",
    "ukm/ukm.xml",
  ]
  output = "$root_out_dir/histograms.xml"
  outputs = [ output ]
  args = rebase_path(sources, root_build_dir) + [
           "--output",
           rebase_path(output, root_build_dir),
         ]
}

copy("actions_xml") {
  sources = [ "actions/actions.xml" ]
  outputs = [ "$root_out_dir/actions.xml" ]
}

copy("rappor_xml") {
  sources = [ "rappor/rappor.xml" ]
  outputs = [ "$root_out_dir/rappor.xml" ]
}

copy("ukm_xml") {
  sources = [ "ukm/ukm.xml" ]
  outputs = [ "$root_out_dir/ukm.xml" ]
}

group("metrics_metadata") {
  deps = [
    ":actions_xml",
    ":histograms_xml",
    ":rappor_xml",
    ":ukm_xml",
  ]
}

# This group defines the isolate files needed to run metrics_python_tests.py on
# on bots. This also tells the build system when the tests should be re-run -
# when one of the dependent files changes.
#
# When adding new entries to this test suite, you can test things locally with
# isolation using the following command:
#
#  tools/mb/mb.py run out/gn metrics_python_tests -- \
#    --isolated-script-test-output=/tmp/output.json
#
group("metrics_python_tests") {
  data = [
    # The run_isolated_script_test.py script and its dependencies.
    "//testing/scripts/run_isolated_script_test.py",
    "//testing/scripts/common.py",
    "//testing/xvfb.py",
    "//testing/test_env.py",
    "//third_party/catapult/third_party/typ/",

    # Scripts we depend on. Their unit tests are also included.
    "//tools/json_comment_eater/json_comment_eater.py",
    "//tools/json_comment_eater/json_comment_eater_test.py",
    "//tools/json_comment_eater/everything.json",
    "//tools/json_comment_eater/everything_expected.json",
    "//tools/json_to_struct/element_generator.py",
    "//tools/json_to_struct/element_generator_test.py",
    "//tools/json_to_struct/json_to_struct.py",
    "//tools/json_to_struct/struct_generator.py",
    "//tools/json_to_struct/struct_generator_test.py",

    # The metrics_python_tests.py runner and its dependencies.
    "//tools/metrics/metrics_python_tests.py",

    "//tools/metrics/actions/action_utils.py",
    "//tools/metrics/actions/actions_print_style.py",
    "//tools/metrics/actions/extract_actions.py",
    "//tools/metrics/actions/extract_actions_test.py",

    "//tools/metrics/common/diff_util.py",
    "//tools/metrics/common/models.py",
    "//tools/metrics/common/path_util.py",
    "//tools/metrics/common/presubmit_util.py",
    "//tools/metrics/common/pretty_print_xml.py",
    "//tools/metrics/common/etree_util.py",

    "//tools/metrics/histograms/test_data/enums.xml",
    "//tools/metrics/histograms/test_data/histograms.xml",
    "//tools/metrics/histograms/test_data/ukm.xml",
    "//tools/metrics/histograms/enums.xml",
    "//tools/metrics/histograms/expand_owners.py",
    "//tools/metrics/histograms/expand_owners_unittest.py",
    "//tools/metrics/histograms/extract_histograms.py",
    "//tools/metrics/histograms/generate_expired_histograms_array.py",
    "//tools/metrics/histograms/generate_expired_histograms_array_unittest.py",
    "//tools/metrics/histograms/histogram_ownership.py",
    "//tools/metrics/histograms/histograms.xml",
    "//tools/metrics/histograms/histogram_paths.py",
    "//tools/metrics/histograms/histograms_print_style.py",
    "//tools/metrics/histograms/merge_xml.py",
    "//tools/metrics/histograms/merge_xml_test.py",
    "//tools/metrics/histograms/populate_enums.py",
    "//tools/metrics/histograms/pretty_print.py",
    "//tools/metrics/histograms/pretty_print_test.py",

    "//tools/metrics/rappor/rappor_model.py",
    "//tools/metrics/rappor/rappor_model_test.py",

    "//tools/metrics/ukm/ukm.xml",
    "//tools/metrics/ukm/codegen.py",
    "//tools/metrics/ukm/codegen_test.py",
    "//tools/metrics/ukm/builders_template.py",
    "//tools/metrics/ukm/decode_template.py",
    "//tools/metrics/ukm/gen_builders.py",
    "//tools/metrics/ukm/gen_builders_test.py",
    "//tools/metrics/ukm/ukm_model.py",
    "//tools/metrics/ukm/ukm_model_test.py",
    "//tools/metrics/ukm/xml_validations.py",
    "//tools/metrics/ukm/xml_validations_test.py",

    "//tools/python/google/path_utils.py",

    "//tools/variations/fieldtrial_to_struct_unittest.py",
    "//tools/variations/fieldtrial_to_struct.py",
    "//tools/variations/fieldtrial_util_unittest.py",
    "//tools/variations/fieldtrial_util.py",
    "//tools/variations/split_variations_cmd_unittest.py",
    "//tools/variations/split_variations_cmd.py",
    "//tools/variations/unittest_data/expected_output.cc",
    "//tools/variations/unittest_data/expected_output.h",
    "//tools/variations/unittest_data/test_config.json",
    "//tools/variations/unittest_data/variations_cmd.txt",
    "//components/variations/field_trial_config/field_trial_testing_config_schema.json",
    "//components/variations/service/generate_ui_string_overrider.py",
    "//components/variations/service/generate_ui_string_overrider_unittest.py",
  ]
}
