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

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

Issue 952053004: Fix 'gn clean'. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "base/files/file_path.h" 5 #include "base/files/file_path.h"
6 #include "base/files/file_util.h" 6 #include "base/files/file_util.h"
7 #include "base/files/scoped_file.h" 7 #include "base/files/scoped_file.h"
8 #include "base/strings/string_split.h" 8 #include "base/strings/string_split.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "tools/gn/commands.h" 10 #include "tools/gn/commands.h"
11 #include "tools/gn/err.h" 11 #include "tools/gn/err.h"
12 #include "tools/gn/setup.h" 12 #include "tools/gn/setup.h"
13 13
14 namespace { 14 namespace {
15 15
16 // Extracts from a build.ninja the commands to run GN. 16 // Extracts from a build.ninja the commands to run GN.
17 // 17 //
18 // The commands to run GN are the gn rule and build.ninja build step at the top 18 // The commands to run GN are the gn rule and build.ninja build step at the top
19 // of the build.ninja file. We want to keep these when deleting GN builds since 19 // of the build.ninja file. We want to keep these when deleting GN builds since
20 // we want to preserve the command-line flags to GN. 20 // we want to preserve the command-line flags to GN.
21 // 21 //
22 // On error, returns the empty string. 22 // On error, returns the empty string.
23 std::string ExtractGNBuildCommands(const base::FilePath& build_ninja_file) { 23 std::string ExtractGNBuildCommands(const base::FilePath& build_ninja_file) {
24 std::string file_contents; 24 std::string file_contents;
25 if (!base::ReadFileToString(build_ninja_file, &file_contents)) { 25 if (!base::ReadFileToString(build_ninja_file, &file_contents)) {
26 return std::string(); 26 return std::string();
27 } 27 }
28 28
29 std::vector<std::string> lines; 29 std::vector<std::string> lines;
30 base::SplitString(file_contents, '\n', &lines); 30 base::SplitStringDontTrim(file_contents, '\n', &lines);
31 31
32 std::string result; 32 std::string result;
33 int num_blank_lines = 0; 33 int num_blank_lines = 0;
34 for (size_t i = 0; i < lines.size(); ++i) { 34 for (size_t i = 0; i < lines.size(); ++i) {
35 result += lines[i]; 35 result += lines[i];
36 result += "\n"; 36 result += "\n";
37 if (lines[i].empty()) { 37 if (lines[i].empty()) {
38 ++num_blank_lines; 38 ++num_blank_lines;
39 } 39 }
40 if (num_blank_lines == 2) 40 if (num_blank_lines == 2)
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 static_cast<int>(dummy_content.size())) == -1) { 142 static_cast<int>(dummy_content.size())) == -1) {
143 Err(Location(), std::string("Failed to write build.ninja.d.")) 143 Err(Location(), std::string("Failed to write build.ninja.d."))
144 .PrintToStdout(); 144 .PrintToStdout();
145 return 1; 145 return 1;
146 } 146 }
147 147
148 return 0; 148 return 0;
149 } 149 }
150 150
151 } // namespace commands 151 } // namespace commands
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698