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

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

Issue 2394163004: GN: Check if targets with precompiled headers use unsupported toolchains. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 2 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 | « tools/gn/ninja_binary_target_writer.h ('k') | tools/gn/source_file_type.h » ('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 "tools/gn/ninja_binary_target_writer.h" 5 #include "tools/gn/ninja_binary_target_writer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include <cstring> 10 #include <cstring>
11 #include <set> 11 #include <set>
12 #include <sstream> 12 #include <sstream>
13 13
14 #include "base/containers/hash_tables.h" 14 #include "base/containers/hash_tables.h"
15 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "tools/gn/config_values_extractors.h" 16 #include "tools/gn/config_values_extractors.h"
17 #include "tools/gn/deps_iterator.h" 17 #include "tools/gn/deps_iterator.h"
18 #include "tools/gn/err.h" 18 #include "tools/gn/err.h"
19 #include "tools/gn/escape.h" 19 #include "tools/gn/escape.h"
20 #include "tools/gn/filesystem_utils.h" 20 #include "tools/gn/filesystem_utils.h"
21 #include "tools/gn/ninja_utils.h" 21 #include "tools/gn/ninja_utils.h"
22 #include "tools/gn/scheduler.h" 22 #include "tools/gn/scheduler.h"
23 #include "tools/gn/settings.h" 23 #include "tools/gn/settings.h"
24 #include "tools/gn/source_file_type.h" 24 #include "tools/gn/source_file_type.h"
25 #include "tools/gn/string_utils.h" 25 #include "tools/gn/string_utils.h"
26 #include "tools/gn/substitution_writer.h" 26 #include "tools/gn/substitution_writer.h"
27 #include "tools/gn/target.h" 27 #include "tools/gn/target.h"
28 28
29 // Represents a set of tool types. Must be first since it is also shared by
30 // some helper functions in the anonymous namespace below.
31 class NinjaBinaryTargetWriter::SourceFileTypeSet {
32 public:
33 SourceFileTypeSet() {
34 memset(flags_, 0, sizeof(bool) * static_cast<int>(SOURCE_NUMTYPES));
35 }
36
37 void Set(SourceFileType type) {
38 flags_[static_cast<int>(type)] = true;
39 }
40 bool Get(SourceFileType type) const {
41 return flags_[static_cast<int>(type)];
42 }
43
44 private:
45 bool flags_[static_cast<int>(SOURCE_NUMTYPES)];
46 };
47
48 namespace { 29 namespace {
49 30
50 // Returns the proper escape options for writing compiler and linker flags. 31 // Returns the proper escape options for writing compiler and linker flags.
51 EscapeOptions GetFlagOptions() { 32 EscapeOptions GetFlagOptions() {
52 EscapeOptions opts; 33 EscapeOptions opts;
53 opts.mode = ESCAPE_NINJA_COMMAND; 34 opts.mode = ESCAPE_NINJA_COMMAND;
54 return opts; 35 return opts;
55 } 36 }
56 37
57 struct DefineWriter { 38 struct DefineWriter {
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 output_value.replace(extension_offset - 1, 177 output_value.replace(extension_offset - 1,
197 std::string::npos, 178 std::string::npos,
198 output_extension); 179 output_extension);
199 } 180 }
200 181
201 // Appends the object files generated by the given source set to the given 182 // Appends the object files generated by the given source set to the given
202 // output vector. 183 // output vector.
203 void AddSourceSetObjectFiles(const Target* source_set, 184 void AddSourceSetObjectFiles(const Target* source_set,
204 UniqueVector<OutputFile>* obj_files) { 185 UniqueVector<OutputFile>* obj_files) {
205 std::vector<OutputFile> tool_outputs; // Prevent allocation in loop. 186 std::vector<OutputFile> tool_outputs; // Prevent allocation in loop.
206 NinjaBinaryTargetWriter::SourceFileTypeSet used_types; 187 SourceFileTypeSet used_types;
207 188
208 // Compute object files for all sources. Only link the first output from 189 // Compute object files for all sources. Only link the first output from
209 // the tool if there are more than one. 190 // the tool if there are more than one.
210 for (const auto& source : source_set->sources()) { 191 for (const auto& source : source_set->sources()) {
211 Toolchain::ToolType tool_type = Toolchain::TYPE_NONE; 192 Toolchain::ToolType tool_type = Toolchain::TYPE_NONE;
212 if (source_set->GetOutputFilesForSource(source, &tool_type, &tool_outputs)) 193 if (source_set->GetOutputFilesForSource(source, &tool_type, &tool_outputs))
213 obj_files->push_back(tool_outputs[0]); 194 obj_files->push_back(tool_outputs[0]);
214 195
215 used_types.Set(GetSourceFileType(source)); 196 used_types.Set(GetSourceFileType(source));
216 } 197 }
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after
1065 "\n" 1046 "\n"
1066 "In the latter case, either rename one of the files or move one of\n" 1047 "In the latter case, either rename one of the files or move one of\n"
1067 "the sources to a separate source_set to avoid them both being in\n" 1048 "the sources to a separate source_set to avoid them both being in\n"
1068 "the same target."); 1049 "the same target.");
1069 g_scheduler->FailWithError(err); 1050 g_scheduler->FailWithError(err);
1070 return false; 1051 return false;
1071 } 1052 }
1072 } 1053 }
1073 return true; 1054 return true;
1074 } 1055 }
OLDNEW
« no previous file with comments | « tools/gn/ninja_binary_target_writer.h ('k') | tools/gn/source_file_type.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698