| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 # Converts a .json file to a C++ struct. | 5 # Converts a fieldtrial_testing_config.json file to a C++ struct. |
| 6 # | 6 # |
| 7 # Variables: | 7 # Variables: |
| 8 # | 8 # |
| 9 # source (required) | 9 # source (required) |
| 10 # Single file name of source .json file. | 10 # Single file name of source .json file. |
| 11 # | 11 # |
| 12 # schema_file (required) | 12 # schema_file (required) |
| 13 # Single file name of the .json file that defines the schema. | 13 # Single file name of the .json file that defines the schema. |
| 14 # | 14 # |
| 15 # namespace (required) | 15 # namespace (required) |
| 16 # Namespace name to put result in. | 16 # Namespace name to put result in. |
| 17 # | 17 # |
| 18 # output (required) |
| 19 # Name of the output file. |
| 20 # |
| 21 # out_dir (required) |
| 22 # Name of the output directory. |
| 23 # |
| 18 # visibility (optional) | 24 # visibility (optional) |
| 19 # Normal meaning. | 25 # Normal meaning. |
| 20 template("json_to_struct") { | 26 template("fieldtrial_to_struct") { |
| 21 assert(defined(invoker.source), "source required in $target_name") | 27 assert(defined(invoker.source), "source required in $target_name") |
| 22 assert(defined(invoker.schema_file), "schema_file required in $target_name") | 28 assert(defined(invoker.schema_file), "schema_file required in $target_name") |
| 23 assert(defined(invoker.namespace), "namespace required in $target_name") | 29 assert(defined(invoker.namespace), "namespace required in $target_name") |
| 30 assert(defined(invoker.output), "output required in $target_name") |
| 31 assert(defined(invoker.out_dir), "out_dir required in $target_name") |
| 24 | 32 |
| 25 action_name = target_name + "_action" | 33 action_name = target_name + "_action" |
| 26 source_set_name = target_name | 34 source_set_name = target_name |
| 27 | 35 |
| 28 action(action_name) { | 36 action(action_name) { |
| 29 visibility = [ ":$source_set_name" ] | 37 visibility = [ ":$source_set_name" ] |
| 30 script = "//tools/json_to_struct/json_to_struct.py" | 38 script = "//tools/variations/fieldtrial_to_struct.py" |
| 31 | 39 |
| 32 inputs = [ | 40 inputs = [ |
| 33 "//tools/json_to_struct/element_generator.py", | 41 "//tools/json_to_struct/element_generator.py", |
| 42 "//tools/json_to_struct/json_to_struct.py", |
| 34 "//tools/json_to_struct/struct_generator.py", | 43 "//tools/json_to_struct/struct_generator.py", |
| 35 invoker.source, | 44 invoker.source, |
| 36 ] | 45 ] |
| 37 | 46 |
| 38 out_dir = get_path_info(invoker.source, "gen_dir") | 47 out_dir = get_path_info(invoker.out_dir, "gen_dir") |
| 39 out_name = get_path_info(invoker.source, "name") | 48 out_name = invoker.output |
| 40 outputs = [ | 49 outputs = [ |
| 41 "$out_dir/$out_name.cc", | 50 "$out_dir/$out_name.cc", |
| 42 "$out_dir/$out_name.h", | 51 "$out_dir/$out_name.h", |
| 43 ] | 52 ] |
| 44 | 53 |
| 45 args = [ | 54 args = [ |
| 46 rebase_path(invoker.source, root_build_dir), | 55 rebase_path(invoker.source, root_build_dir), |
| 47 "--destbase=" + rebase_path(out_dir, root_build_dir), | 56 "--destbase=" + rebase_path(out_dir, root_build_dir), |
| 48 "--namespace=" + invoker.namespace, | 57 "--namespace=" + invoker.namespace, |
| 49 "--schema=" + rebase_path(invoker.schema_file, root_build_dir), | 58 "--schema=" + rebase_path(invoker.schema_file, root_build_dir), |
| 59 "--output=" + invoker.output, |
| 50 ] | 60 ] |
| 51 } | 61 } |
| 52 | 62 |
| 53 source_set(source_set_name) { | 63 source_set(source_set_name) { |
| 54 if (defined(invoker.visibility)) { | 64 if (defined(invoker.visibility)) { |
| 55 visibility = invoker.visibility | 65 visibility = invoker.visibility |
| 56 } | 66 } |
| 57 | 67 |
| 58 sources = get_target_outputs(":$action_name") | 68 sources = get_target_outputs(":$action_name") |
| 59 | 69 |
| 60 deps = [ | 70 deps = [ |
| 61 ":$action_name", | 71 ":$action_name", |
| 62 ] | 72 ] |
| 63 } | 73 } |
| 64 } | 74 } |
| OLD | NEW |