| 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: | 
|   11 # |   11 # | 
|   12 # sources [required] A list of schema files to be compiled. |   12 # sources [required] A list of schema files to be compiled. | 
|   13 # |   13 # | 
|   14 # root_namespace [required] The namespace in which generated API code is to be |   14 # root_namespace [required] | 
 |   15 #   The namespace in which generated API code is to be | 
|   15 #   wrapped. C++ namespace syntax is accepted for nested namespace |   16 #   wrapped. C++ namespace syntax is accepted for nested namespace | 
|   16 #   (e.g. "foo::bar::api"). |   17 #   (e.g. "foo::bar::api"). | 
|   17 # |   18 # | 
|   18 # impl_dir [required] The path containing C++ implementations of API functions. |   19 # bundle [optional, default = false] | 
|   19 #   This path is used as the root path when looking for |   20 #   Boolean indicating if the schema files should be bundled or not. | 
|   20 #   {schema}/{schema}_api.h headers during the API bundle generation phase. |  | 
|   21 #   Such headers, if found, are automatically included by the generated code. |  | 
|   22 # |   21 # | 
|   23 # uncompiled_sources [optional] A list of schema files which should not be |   22 # impl_dir [required if bundle = true, otherwise unused] | 
|   24 #   compiled, but which should still be processed for API bundle generation. |   23 #   The path containing C++ implementations of API functions. This path is | 
 |   24 #   used as the root path when looking for {schema}/{schema}_api.h headers | 
 |   25 #   during the API bundle generation phase. Such headers, if found, are | 
 |   26 #   automatically included by the generated code. | 
|   25 # |   27 # | 
|   26 # deps [optional] If any deps are specified they will be inherited by the |   28 # uncompiled_sources [optional, only used when bundle = true] | 
|   27 #   static library target. |   29 #   A list of schema files which should not be compiled, but which should still | 
 |   30 #   be processed for API bundle generation. | 
 |   31 # | 
 |   32 # deps [optional] | 
 |   33 #   If any deps are specified they will be inherited by the static library | 
 |   34 #   target. | 
|   28 # |   35 # | 
|   29 # The static libarary target also inherits the visibility and output_name |   36 # The static libarary target also inherits the visibility and output_name | 
|   30 # of its invoker. |   37 # of its invoker. | 
|   31  |   38  | 
|   32 template("generated_extensions_api") { |   39 template("generated_extensions_api") { | 
|   33   assert(defined(invoker.sources), |   40   assert(defined(invoker.sources), | 
|   34          "\"sources\" must be defined for the $target_name template.") |   41          "\"sources\" must be defined for the $target_name template.") | 
|   35   assert(defined(invoker.root_namespace), |   42   assert(defined(invoker.root_namespace), | 
|   36          "\"root_namespace\" must be defined for the $target_name template.") |   43          "\"root_namespace\" must be defined for the $target_name template.") | 
|   37   assert(defined(invoker.impl_dir), |   44  | 
|   38          "\"impl_dir\" must be defined for the $target_name template.") |   45   bundle = defined(invoker.bundle) && invoker.bundle | 
|   39  |   46  | 
|   40   # Keep a copy of the target_name here since it will be trampled |   47   # Keep a copy of the target_name here since it will be trampled | 
|   41   # in nested targets. |   48   # in nested targets. | 
|   42   target_visibility = ":$target_name" |   49   target_visibility = ":$target_name" | 
|   43  |   50  | 
|   44   generated_config_name = target_name + "_generated_config" |   51   generated_config_name = target_name + "_generated_config" | 
|   45   config(generated_config_name) { |   52   config(generated_config_name) { | 
|   46     include_dirs = [ target_gen_dir ] |   53     include_dirs = [ target_gen_dir ] | 
|   47     visibility = target_visibility |   54     visibility = target_visibility | 
|   48   } |   55   } | 
|   49  |   56  | 
|   50   schemas = invoker.sources |   57   schemas = invoker.sources | 
|   51   root_namespace = invoker.root_namespace |   58   root_namespace = invoker.root_namespace | 
|   52   impl_dir = invoker.impl_dir |  | 
|   53   uncompiled_schemas = [] |  | 
|   54   if (defined(invoker.uncompiled_sources)) { |  | 
|   55     uncompiled_schemas = invoker.uncompiled_sources |  | 
|   56   } |  | 
|   57  |   59  | 
|   58   compiler_root = "//tools/json_schema_compiler" |   60   compiler_root = "//tools/json_schema_compiler" | 
|   59   compiler_script = "$compiler_root/compiler.py" |   61   compiler_script = "$compiler_root/compiler.py" | 
|   60   compiler_sources = [ |   62   compiler_sources = [ | 
|   61     "$compiler_root/cc_generator.py", |   63     "$compiler_root/cc_generator.py", | 
|   62     "$compiler_root/code.py", |   64     "$compiler_root/code.py", | 
|   63     "$compiler_root/compiler.py", |   65     "$compiler_root/compiler.py", | 
|   64     "$compiler_root/cpp_generator.py", |   66     "$compiler_root/cpp_generator.py", | 
|   65     "$compiler_root/cpp_type_generator.py", |   67     "$compiler_root/cpp_type_generator.py", | 
|   66     "$compiler_root/cpp_util.py", |   68     "$compiler_root/cpp_util.py", | 
| (...skipping 14 matching lines...) Expand all  Loading... | 
|   81     ] |   83     ] | 
|   82     args = [ |   84     args = [ | 
|   83       "{{source}}", |   85       "{{source}}", | 
|   84       "--root=" + rebase_path("//", root_build_dir), |   86       "--root=" + rebase_path("//", root_build_dir), | 
|   85       "--destdir=" + rebase_path(root_gen_dir, root_build_dir), |   87       "--destdir=" + rebase_path(root_gen_dir, root_build_dir), | 
|   86       "--namespace=$root_namespace", |   88       "--namespace=$root_namespace", | 
|   87       "--generator=cpp" ] |   89       "--generator=cpp" ] | 
|   88     visibility = target_visibility |   90     visibility = target_visibility | 
|   89   } |   91   } | 
|   90  |   92  | 
|   91   bundle_generator_name = target_name + "_bundle_generator" |   93   if (bundle) { | 
|   92   action(bundle_generator_name) { |   94     assert(defined(invoker.impl_dir), | 
|   93     script = compiler_script |   95            "\"impl_dir\" must be defined for the $target_name template.") | 
|   94     source_prereqs = compiler_sources + schemas + uncompiled_schemas |   96     impl_dir = invoker.impl_dir | 
|   95     outputs = [ |   97  | 
|   96       "$target_gen_dir/generated_api.cc", |   98     uncompiled_schemas = [] | 
|   97       "$target_gen_dir/generated_api.h", |   99     if (defined(invoker.uncompiled_sources)) { | 
|   98       "$target_gen_dir/generated_schemas.cc", |  100       uncompiled_schemas = invoker.uncompiled_sources | 
|   99       "$target_gen_dir/generated_schemas.h", |  101     } | 
|  100     ] |  102  | 
|  101     args = [ |  103     bundle_generator_name = target_name + "_bundle_generator" | 
|  102       "--root=" + rebase_path("//", root_build_dir), |  104     action(bundle_generator_name) { | 
|  103       "--destdir=" + rebase_path(root_gen_dir, root_build_dir), |  105       script = compiler_script | 
|  104       "--namespace=$root_namespace", |  106       source_prereqs = compiler_sources + schemas + uncompiled_schemas | 
|  105       "--generator=cpp-bundle", |  107       outputs = [ | 
|  106       "--impl-dir=" + rebase_path(impl_dir, "//"), |  108         "$target_gen_dir/generated_api.cc", | 
|  107     ] + |  109         "$target_gen_dir/generated_api.h", | 
|  108       rebase_path(schemas, root_build_dir) + |  110         "$target_gen_dir/generated_schemas.cc", | 
|  109       rebase_path(uncompiled_schemas, root_build_dir) |  111         "$target_gen_dir/generated_schemas.h", | 
 |  112       ] | 
 |  113       args = [ | 
 |  114         "--root=" + rebase_path("//", root_build_dir), | 
 |  115         "--destdir=" + rebase_path(root_gen_dir, root_build_dir), | 
 |  116         "--namespace=$root_namespace", | 
 |  117         "--generator=cpp-bundle", | 
 |  118         "--impl-dir=" + rebase_path(impl_dir, "//"), | 
 |  119       ] + | 
 |  120         rebase_path(schemas, root_build_dir) + | 
 |  121         rebase_path(uncompiled_schemas, root_build_dir) | 
 |  122     } | 
|  110   } |  123   } | 
|  111  |  124  | 
|  112   source_set(target_name) { |  125   source_set(target_name) { | 
|  113     sources = |  126     sources = get_target_outputs(":$schema_generator_name") | 
|  114       get_target_outputs(":$schema_generator_name") + |  | 
|  115       get_target_outputs(":$bundle_generator_name") |  | 
|  116  |  127  | 
|  117     deps = [ |  128     deps = [ | 
|  118       ":$schema_generator_name", |  129       ":$schema_generator_name", | 
|  119       ":$bundle_generator_name", |  | 
|  120       "//tools/json_schema_compiler:generated_api_util", |  130       "//tools/json_schema_compiler:generated_api_util", | 
|  121     ] |  131     ] | 
|  122  |  132  | 
 |  133     if (bundle) { | 
 |  134       sources += get_target_outputs(":$bundle_generator_name") | 
 |  135       deps += [ ":$bundle_generator_name" ] | 
 |  136     } | 
 |  137  | 
|  123     if (defined(invoker.deps)) { |  138     if (defined(invoker.deps)) { | 
|  124       deps += invoker.deps |  139       deps += invoker.deps | 
|  125     } |  140     } | 
|  126     direct_dependent_configs = [ ":$generated_config_name" ] |  141     direct_dependent_configs = [ ":$generated_config_name" ] | 
|  127  |  142  | 
|  128     if (defined(invoker.visibility)) { |  143     if (defined(invoker.visibility)) { | 
|  129       visibility = invoker.visibility |  144       visibility = invoker.visibility | 
|  130     } |  145     } | 
|  131     if (defined(invoker.output_name)) { |  146     if (defined(invoker.output_name)) { | 
|  132       output_name = invoker.output_name |  147       output_name = invoker.output_name | 
|  133     } |  148     } | 
|  134   } |  149   } | 
|  135 } |  150 } | 
| OLD | NEW |