Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(362)

Side by Side Diff: tools/gn/function_write_file.cc

Issue 387663003: Improve GN handling of directory templates. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/gn/function_process_file_template.cc ('k') | tools/gn/ninja_action_target_writer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 #include <iostream> 5 #include <iostream>
6 #include <sstream> 6 #include <sstream>
7 7
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/strings/string_split.h" 9 #include "base/strings/string_split.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 return Value(); 53 return Value();
54 } 54 }
55 55
56 // Compute the file name and make sure it's in the output dir. 56 // Compute the file name and make sure it's in the output dir.
57 if (!args[0].VerifyTypeIs(Value::STRING, err)) 57 if (!args[0].VerifyTypeIs(Value::STRING, err))
58 return Value(); 58 return Value();
59 const SourceDir& cur_dir = scope->GetSourceDir(); 59 const SourceDir& cur_dir = scope->GetSourceDir();
60 SourceFile source_file = cur_dir.ResolveRelativeFile(args[0].string_value()); 60 SourceFile source_file = cur_dir.ResolveRelativeFile(args[0].string_value());
61 if (!EnsureStringIsInOutputDir( 61 if (!EnsureStringIsInOutputDir(
62 scope->settings()->build_settings()->build_dir(), 62 scope->settings()->build_settings()->build_dir(),
63 source_file.value(), args[0], err)) 63 source_file.value(), args[0], false, err))
64 return Value(); 64 return Value();
65 65
66 // Compute output. 66 // Compute output.
67 std::ostringstream contents; 67 std::ostringstream contents;
68 if (args[1].type() == Value::LIST) { 68 if (args[1].type() == Value::LIST) {
69 const std::vector<Value>& list = args[1].list_value(); 69 const std::vector<Value>& list = args[1].list_value();
70 for (size_t i = 0; i < list.size(); i++) 70 for (size_t i = 0; i < list.size(); i++)
71 contents << list[i].ToString(false) << std::endl; 71 contents << list[i].ToString(false) << std::endl;
72 } else { 72 } else {
73 contents << args[1].ToString(false); 73 contents << args[1].ToString(false);
(...skipping 19 matching lines...) Expand all
93 if (base::WriteFile(file_path, new_contents.c_str(), int_size) 93 if (base::WriteFile(file_path, new_contents.c_str(), int_size)
94 != int_size) { 94 != int_size) {
95 *err = Err(function->function(), "Unable to write file.", 95 *err = Err(function->function(), "Unable to write file.",
96 "I was writing \"" + FilePathToUTF8(file_path) + "\"."); 96 "I was writing \"" + FilePathToUTF8(file_path) + "\".");
97 return Value(); 97 return Value();
98 } 98 }
99 return Value(); 99 return Value();
100 } 100 }
101 101
102 } // namespace functions 102 } // namespace functions
OLDNEW
« no previous file with comments | « tools/gn/function_process_file_template.cc ('k') | tools/gn/ninja_action_target_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698