0

Reuse json-to-struct source files.

The change aims at reducing number of files that need to be updated
whenever json_to_struct is updated.

Bug: b:404850650
Change-Id: I9b2cf8890c221bcc8a3cf4bbe156cad508bea514
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6387980
Commit-Queue: Tomasz Wiszkowski <ender@google.com>
Reviewed-by: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1437700}
This commit is contained in:
Tomasz Wiszkowski
2025-03-25 13:27:23 -07:00
committed by Chromium LUCI CQ
parent 364e8f8540
commit cabda0f1eb
3 changed files with 23 additions and 24 deletions
components/variations/field_trial_config
tools
json_to_struct
metrics

@ -1,21 +1,14 @@
# Copyright 2015 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//tools/json_to_struct/json_to_struct.gni")
action("field_trial_testing_config_action") {
visibility = [ ":field_trial_config" ]
script = "//tools/variations/fieldtrial_to_struct.py"
source = "//testing/variations/fieldtrial_testing_config.json"
inputs = [
"//tools/json_to_struct/aggregation.py",
"//tools/json_to_struct/element_generator.py",
"//tools/json_to_struct/java_element_generator.py",
"//tools/json_to_struct/json_to_struct.py",
"//tools/json_to_struct/class_generator.py",
"//tools/json_to_struct/struct_generator.py",
source,
]
inputs = JSON_TO_STRUCT_FILES + [ source ]
out_name = "fieldtrial_testing_config"
outputs = [
"$target_gen_dir/$out_name.cc",

@ -17,6 +17,20 @@
#
# visibility (optional)
# Normal meaning.
JSON_TO_STRUCT_FILES = [
"//tools/json_to_struct/aggregation.py",
"//tools/json_to_struct/element_generator.py",
"//tools/json_to_struct/java_element_generator.py",
"//tools/json_to_struct/json_to_struct.py",
"//tools/json_to_struct/class_generator.py",
"//tools/json_to_struct/struct_generator.py",
]
JSON_TO_STRUCT_TEST_FILES = [
"//tools/json_to_struct/element_generator_test.py",
"//tools/json_to_struct/struct_generator_test.py",
]
template("json_to_struct") {
assert(defined(invoker.source), "source required in $target_name")
assert(defined(invoker.schema_file), "schema_file required in $target_name")
@ -29,13 +43,10 @@ template("json_to_struct") {
visibility = [ ":$source_set_name" ]
script = "//tools/json_to_struct/json_to_struct.py"
inputs = [
"//tools/json_to_struct/aggregation.py",
"//tools/json_to_struct/element_generator.py",
"//tools/json_to_struct/struct_generator.py",
invoker.source,
invoker.schema_file,
]
inputs = JSON_TO_STRUCT_FILES + [
invoker.source,
invoker.schema_file,
]
out_dir = get_path_info(invoker.source, "gen_dir")
out_name = get_path_info(invoker.source, "name")

@ -3,6 +3,7 @@
# found in the LICENSE file.
import("//build/config/gclient_args.gni")
import("//tools/json_to_struct/json_to_struct.gni")
import("//tools/metrics/histograms/histograms_xml_files.gni")
# Only include histograms_xml if we have access to dirmd data, which
@ -71,14 +72,6 @@ group("metrics_python_tests") {
"//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/aggregation.py",
"//tools/json_to_struct/element_generator.py",
"//tools/json_to_struct/element_generator_test.py",
"//tools/json_to_struct/java_element_generator.py",
"//tools/json_to_struct/json_to_struct.py",
"//tools/json_to_struct/class_generator.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",
@ -169,6 +162,8 @@ group("metrics_python_tests") {
"//components/variations/service/generate_ui_string_overrider_unittest.py",
]
data += JSON_TO_STRUCT_FILES + JSON_TO_STRUCT_TEST_FILES
# Add platform-specific dependencies for dirmd.
if (is_win) {
data += [