| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 # Defines a static library corresponding to the output of schema compiler tools | 5 # Defines a static library corresponding to the output of schema compiler tools |
| 6 # over a set of extensions API schemas (IDL or JSON format.) The library target | 6 # over a set of extensions API schemas (IDL or JSON format.) The library target |
| 7 # has implicit hard dependencies on all schema files listed by the invoker and | 7 # has implicit hard dependencies on all schema files listed by the invoker and |
| 8 # is itself a hard dependency. | 8 # is itself a hard dependency. |
| 9 # | 9 # |
| 10 # Invocations of this template may use the following variables: | 10 # Invocations of this template may use the following variables: |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 # of its invoker. | 50 # of its invoker. |
| 51 | 51 |
| 52 template("json_schema_api") { | 52 template("json_schema_api") { |
| 53 assert(defined(invoker.sources), | 53 assert(defined(invoker.sources), |
| 54 "\"sources\" must be defined for the $target_name template.") | 54 "\"sources\" must be defined for the $target_name template.") |
| 55 assert(defined(invoker.root_namespace), | 55 assert(defined(invoker.root_namespace), |
| 56 "\"root_namespace\" must be defined for the $target_name template.") | 56 "\"root_namespace\" must be defined for the $target_name template.") |
| 57 | 57 |
| 58 schemas = defined(invoker.schemas) && invoker.schemas | 58 schemas = defined(invoker.schemas) && invoker.schemas |
| 59 bundle = defined(invoker.bundle) && invoker.bundle | 59 bundle = defined(invoker.bundle) && invoker.bundle |
| 60 bundle_registration = defined(invoker.bundle_registration) && | 60 bundle_registration = |
| 61 invoker.bundle_registration | 61 defined(invoker.bundle_registration) && invoker.bundle_registration |
| 62 | 62 |
| 63 schema_include_rules = "" | 63 schema_include_rules = "" |
| 64 if (defined(invoker.schema_include_rules)) { | 64 if (defined(invoker.schema_include_rules)) { |
| 65 schema_include_rules = invoker.schema_include_rules | 65 schema_include_rules = invoker.schema_include_rules |
| 66 } | 66 } |
| 67 | 67 |
| 68 # Keep a copy of the target_name here since it will be trampled | 68 # Keep a copy of the target_name here since it will be trampled |
| 69 # in nested targets. | 69 # in nested targets. |
| 70 target_visibility = [ ":$target_name" ] | 70 target_visibility = [ ":$target_name" ] |
| 71 | 71 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 101 outputs = [ | 101 outputs = [ |
| 102 "$target_gen_dir/{{source_name_part}}.cc", | 102 "$target_gen_dir/{{source_name_part}}.cc", |
| 103 "$target_gen_dir/{{source_name_part}}.h", | 103 "$target_gen_dir/{{source_name_part}}.h", |
| 104 ] | 104 ] |
| 105 args = [ | 105 args = [ |
| 106 "{{source}}", | 106 "{{source}}", |
| 107 "--root=" + rebase_path("//", root_build_dir), | 107 "--root=" + rebase_path("//", root_build_dir), |
| 108 "--destdir=" + rebase_path(root_gen_dir, root_build_dir), | 108 "--destdir=" + rebase_path(root_gen_dir, root_build_dir), |
| 109 "--namespace=$root_namespace", | 109 "--namespace=$root_namespace", |
| 110 "--generator=cpp", | 110 "--generator=cpp", |
| 111 "--include-rules=$schema_include_rules" ] | 111 "--include-rules=$schema_include_rules", |
| 112 ] |
| 112 | 113 |
| 113 if (defined(invoker.visibility)) { | 114 if (defined(invoker.visibility)) { |
| 114 # If visibility is restricted, add our own target to it. | 115 # If visibility is restricted, add our own target to it. |
| 115 visibility = [ invoker.visibility, target_visibility ] | 116 visibility = [ |
| 117 invoker.visibility, |
| 118 target_visibility, |
| 119 ] |
| 116 } | 120 } |
| 117 } | 121 } |
| 118 } | 122 } |
| 119 | 123 |
| 120 if (bundle) { | 124 if (bundle) { |
| 121 uncompiled_sources = [] | 125 uncompiled_sources = [] |
| 122 if (defined(invoker.uncompiled_sources)) { | 126 if (defined(invoker.uncompiled_sources)) { |
| 123 uncompiled_sources = invoker.uncompiled_sources | 127 uncompiled_sources = invoker.uncompiled_sources |
| 124 } | 128 } |
| 125 | 129 |
| 126 bundle_generator_schema_name = target_name + "_bundle_generator_schema" | 130 bundle_generator_schema_name = target_name + "_bundle_generator_schema" |
| 127 action(bundle_generator_schema_name) { | 131 action(bundle_generator_schema_name) { |
| 128 script = compiler_script | 132 script = compiler_script |
| 129 inputs = compiler_sources + sources + uncompiled_sources | 133 inputs = compiler_sources + sources + uncompiled_sources |
| 130 outputs = [ | 134 outputs = [ |
| 131 "$target_gen_dir/generated_schemas.cc", | 135 "$target_gen_dir/generated_schemas.cc", |
| 132 "$target_gen_dir/generated_schemas.h", | 136 "$target_gen_dir/generated_schemas.h", |
| 133 ] | 137 ] |
| 134 args = [ | 138 args = [ |
| 135 "--root=" + rebase_path("//", root_build_dir), | 139 "--root=" + rebase_path("//", root_build_dir), |
| 136 "--destdir=" + rebase_path(root_gen_dir, root_build_dir), | 140 "--destdir=" + rebase_path(root_gen_dir, root_build_dir), |
| 137 "--namespace=$root_namespace", | 141 "--namespace=$root_namespace", |
| 138 "--generator=cpp-bundle-schema", | 142 "--generator=cpp-bundle-schema", |
| 139 "--include-rules=$schema_include_rules" ] | 143 "--include-rules=$schema_include_rules", |
| 140 + rebase_path(sources, root_build_dir) | 144 ] + rebase_path(sources, root_build_dir) + |
| 141 + rebase_path(uncompiled_sources, root_build_dir) | 145 rebase_path(uncompiled_sources, root_build_dir) |
| 142 } | 146 } |
| 143 } | 147 } |
| 144 | 148 |
| 145 if (bundle_registration) { | 149 if (bundle_registration) { |
| 146 uncompiled_sources = [] | 150 uncompiled_sources = [] |
| 147 if (defined(invoker.uncompiled_sources)) { | 151 if (defined(invoker.uncompiled_sources)) { |
| 148 uncompiled_sources = invoker.uncompiled_sources | 152 uncompiled_sources = invoker.uncompiled_sources |
| 149 } | 153 } |
| 150 | 154 |
| 151 assert(defined(invoker.impl_dir), | 155 assert(defined(invoker.impl_dir), |
| 152 "\"impl_dir\" must be defined for the $target_name template.") | 156 "\"impl_dir\" must be defined for the $target_name template.") |
| 153 impl_dir = invoker.impl_dir | 157 impl_dir = invoker.impl_dir |
| 154 | 158 |
| 155 bundle_generator_registration_name = target_name + | 159 bundle_generator_registration_name = |
| 156 "_bundle_generator_registration" | 160 target_name + "_bundle_generator_registration" |
| 157 action(bundle_generator_registration_name) { | 161 action(bundle_generator_registration_name) { |
| 158 script = compiler_script | 162 script = compiler_script |
| 159 inputs = compiler_sources + sources + uncompiled_sources | 163 inputs = compiler_sources + sources + uncompiled_sources |
| 160 outputs = [ | 164 outputs = [ |
| 161 "$root_gen_dir/$impl_dir/generated_api_registration.cc", | 165 "$root_gen_dir/$impl_dir/generated_api_registration.cc", |
| 162 "$root_gen_dir/$impl_dir/generated_api_registration.h", | 166 "$root_gen_dir/$impl_dir/generated_api_registration.h", |
| 163 ] | 167 ] |
| 164 args = [ | 168 args = [ |
| 165 "--root=" + rebase_path("//", root_build_dir), | 169 "--root=" + rebase_path("//", root_build_dir), |
| 166 "--destdir=" + rebase_path(root_gen_dir, root_build_dir), | 170 "--destdir=" + rebase_path(root_gen_dir, root_build_dir), |
| 167 "--namespace=$root_namespace", | 171 "--namespace=$root_namespace", |
| 168 "--generator=cpp-bundle-registration", | 172 "--generator=cpp-bundle-registration", |
| 169 "--impl-dir=" + rebase_path(impl_dir, "//"), | 173 "--impl-dir=" + rebase_path(impl_dir, "//"), |
| 170 "--include-rules=$schema_include_rules" ] | 174 "--include-rules=$schema_include_rules", |
| 171 + rebase_path(sources, root_build_dir) | 175 ] + rebase_path(sources, root_build_dir) + |
| 172 + rebase_path(uncompiled_sources, root_build_dir) | 176 rebase_path(uncompiled_sources, root_build_dir) |
| 173 } | 177 } |
| 174 } | 178 } |
| 175 | 179 |
| 176 source_set(target_name) { | 180 source_set(target_name) { |
| 177 sources = [] | 181 sources = [] |
| 178 deps = [] | 182 deps = [] |
| 179 public_deps = [] | 183 public_deps = [] |
| 180 | 184 |
| 181 if (schemas) { | 185 if (schemas) { |
| 182 sources += get_target_outputs(":$schema_generator_name") | 186 sources += get_target_outputs(":$schema_generator_name") |
| (...skipping 17 matching lines...) Expand all Loading... |
| 200 public_configs = [ ":$generated_config_name" ] | 204 public_configs = [ ":$generated_config_name" ] |
| 201 | 205 |
| 202 if (defined(invoker.visibility)) { | 206 if (defined(invoker.visibility)) { |
| 203 visibility = invoker.visibility | 207 visibility = invoker.visibility |
| 204 } | 208 } |
| 205 if (defined(invoker.output_name)) { | 209 if (defined(invoker.output_name)) { |
| 206 output_name = invoker.output_name | 210 output_name = invoker.output_name |
| 207 } | 211 } |
| 208 } | 212 } |
| 209 } | 213 } |
| OLD | NEW |