summaryrefslogtreecommitdiffstats
path: root/tools/gn/function_process_file_template.cc
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-19 16:50:52 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-19 16:50:52 +0000
commite9bf4fcb470f7220306c39827fc3fd9be0a27741 (patch)
tree59d2c4de7ab1964d6c421dd014b629ce9bd961e1 /tools/gn/function_process_file_template.cc
parent252e6603f3012cdc8de4a212999ef62660769be7 (diff)
downloadchromium_src-e9bf4fcb470f7220306c39827fc3fd9be0a27741.zip
chromium_src-e9bf4fcb470f7220306c39827fc3fd9be0a27741.tar.gz
chromium_src-e9bf4fcb470f7220306c39827fc3fd9be0a27741.tar.bz2
Add directory extraction to GN path handling.
Some of the mojo templates want to put generated files in the directory corresponding to the source file, rather than the directory containing the BUILD file. Previously, this required putting the BUILD files in the same directory. This patch adds the ability to specify the generated file directory corresponding to the input file in the action_foreach file templates so this can be expressed naturally. For parity, it also adds qquerying for this information via get_path_info. BUG= R=cjhopman@chromium.org Review URL: https://codereview.chromium.org/334333005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278402 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/gn/function_process_file_template.cc')
-rw-r--r--tools/gn/function_process_file_template.cc22
1 files changed, 20 insertions, 2 deletions
diff --git a/tools/gn/function_process_file_template.cc b/tools/gn/function_process_file_template.cc
index 5d4c9d7..061c901 100644
--- a/tools/gn/function_process_file_template.cc
+++ b/tools/gn/function_process_file_template.cc
@@ -5,6 +5,10 @@
#include "tools/gn/file_template.h"
#include "tools/gn/functions.h"
#include "tools/gn/parse_tree.h"
+#include "tools/gn/scope.h"
+#include "tools/gn/settings.h"
+#include "tools/gn/target.h"
+#include "tools/gn/value_extractors.h"
namespace functions {
@@ -67,12 +71,26 @@ Value RunProcessFileTemplate(Scope* scope,
return Value();
}
- FileTemplate file_template(args[1], err);
+ FileTemplate file_template(scope->settings(), args[1], err);
if (err->has_error())
return Value();
+ Target::FileList input_files;
+ if (!ExtractListOfRelativeFiles(scope->settings()->build_settings(), args[0],
+ scope->GetSourceDir(), &input_files, err))
+ return Value();
+
Value ret(function, Value::LIST);
- file_template.Apply(args[0], function, &ret.list_value(), err);
+
+ // Temporary holding place, allocate outside to re-use buffer.
+ std::vector<std::string> string_output;
+
+ for (size_t i = 0; i < input_files.size(); i++) {
+ string_output.clear();
+ file_template.Apply(input_files[i], &string_output);
+ for (size_t out_i = 0; out_i < string_output.size(); out_i++)
+ ret.list_value().push_back(Value(function, string_output[out_i]));
+ }
return ret;
}