| # Copyright (c) 2013 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. |
| |
| template("grit") { |
| assert(defined(source), |
| "\"source\" must be defined for the grit template $target_name") |
| assert(!defined(sources) && !defined(outputs), |
| "Neither \"sources\" nor \"outputs\" can be defined for the grit " + |
| "template $target_name") |
| |
| resource_ids = "$relative_source_root_dir/tools/gritsettings/resource_ids" |
| output_dir = "$relative_target_gen_dir" |
| |
| # Note that this needs to be source-absolute since the current directory will |
| # be that of the file invoking the template, not this file. |
| grit_info_script = "$relative_source_root_dir/tools/grit/grit_info.py" |
| |
| grit_inputs = exec_script(grit_info_script, |
| [ "--inputs", source, "-f", resource_ids], "list lines") |
| grit_outputs = exec_script(grit_info_script, |
| [ "--outputs", "$output_dir", source, "-f", resource_ids ], |
| "list lines") |
| |
| # The current grit setup makes an file in $target_gen_dir/grit/foo.h that |
| # the source code expects to include via "grit/foo.h". It would be nice to |
| # change this to including absolute paths relative to the root gen directory |
| # (like "mycomponent/foo.h"). This config sets up the include path. |
| grit_config = target_name + "_grit_config" |
| config(grit_config) { |
| includes = [ target_gen_dir ] |
| } |
| |
| grit_custom_target = target_name + "_grit" |
| custom(grit_custom_target) { |
| script = "$relative_source_root_dir/tools/grit/grit.py" |
| data = grit_inputs # TODO(brettw) this should be inputs or something |
| outputs = grit_outputs |
| |
| # TODO(brettw) grit_defines. |
| args = [ |
| "-i", source, "build", |
| "-f", resource_ids, |
| "-o", relative_target_gen_dir, |
| ] |
| } |
| |
| # This is the thing that people actually link with, it must be named the |
| # same as the argument the template was invoked with. |
| static_library(target_name) { |
| sources = grit_outputs |
| deps = [ ":$grit_custom_target" ] |
| direct_dependent_configs = [ ":$grit_config" ] |
| } |
| } |