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

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

Issue 2428013002: Setting "SubSystem" option on "Link" page for Visual Studio project. (Closed)
Patch Set: Fixed missed space indent 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/visual_studio_utils_unittest.cc ('k') | 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/visual_studio_writer.h" 5 #include "tools/gn/visual_studio_writer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 } 146 }
147 147
148 void ParseCompilerOptions(const Target* target, CompilerOptions* options) { 148 void ParseCompilerOptions(const Target* target, CompilerOptions* options) {
149 for (ConfigValuesIterator iter(target); !iter.done(); iter.Next()) { 149 for (ConfigValuesIterator iter(target); !iter.done(); iter.Next()) {
150 ParseCompilerOptions(iter.cur().cflags(), options); 150 ParseCompilerOptions(iter.cur().cflags(), options);
151 ParseCompilerOptions(iter.cur().cflags_c(), options); 151 ParseCompilerOptions(iter.cur().cflags_c(), options);
152 ParseCompilerOptions(iter.cur().cflags_cc(), options); 152 ParseCompilerOptions(iter.cur().cflags_cc(), options);
153 } 153 }
154 } 154 }
155 155
156 void ParseLinkerOptions(const std::vector<std::string>& ldflags,
157 LinkerOptions* options) {
158 for (const std::string& flag : ldflags)
159 ParseLinkerOption(flag, options);
160 }
161
162 void ParseLinkerOptions(const Target* target, LinkerOptions* options) {
163 for (ConfigValuesIterator iter(target); !iter.done(); iter.Next()) {
164 ParseLinkerOptions(iter.cur().ldflags(), options);
165 }
166 }
167
156 // Returns a string piece pointing into the input string identifying the parent 168 // Returns a string piece pointing into the input string identifying the parent
157 // directory path, excluding the last slash. Note that the input pointer must 169 // directory path, excluding the last slash. Note that the input pointer must
158 // outlive the output. 170 // outlive the output.
159 base::StringPiece FindParentDir(const std::string* path) { 171 base::StringPiece FindParentDir(const std::string* path) {
160 DCHECK(path && !path->empty()); 172 DCHECK(path && !path->empty());
161 for (int i = static_cast<int>(path->size()) - 2; i >= 0; --i) { 173 for (int i = static_cast<int>(path->size()) - 2; i >= 0; --i) {
162 if (IsSlash((*path)[i])) 174 if (IsSlash((*path)[i]))
163 return base::StringPiece(path->data(), i); 175 return base::StringPiece(path->data(), i);
164 } 176 }
165 return base::StringPiece(); 177 return base::StringPiece();
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 if (!options.runtime_library.empty()) 544 if (!options.runtime_library.empty())
533 cl_compile->SubElement("RuntimeLibrary")->Text(options.runtime_library); 545 cl_compile->SubElement("RuntimeLibrary")->Text(options.runtime_library);
534 if (!options.treat_warning_as_error.empty()) { 546 if (!options.treat_warning_as_error.empty()) {
535 cl_compile->SubElement("TreatWarningAsError") 547 cl_compile->SubElement("TreatWarningAsError")
536 ->Text(options.treat_warning_as_error); 548 ->Text(options.treat_warning_as_error);
537 } 549 }
538 if (!options.warning_level.empty()) 550 if (!options.warning_level.empty())
539 cl_compile->SubElement("WarningLevel")->Text(options.warning_level); 551 cl_compile->SubElement("WarningLevel")->Text(options.warning_level);
540 } 552 }
541 553
542 // We don't include resource compilation and link options as ninja files 554 std::unique_ptr<XmlElementWriter> link =
543 // are used to generate real build. 555 item_definitions->SubElement("Link");
556 {
557 LinkerOptions options;
558 ParseLinkerOptions(target, &options);
559 if (!options.subsystem.empty())
560 link->SubElement("SubSystem")->Text(options.subsystem);
561 }
562
563 // We don't include resource compilation and other link options as ninja
564 // files are used to generate real build.
544 } 565 }
545 566
546 { 567 {
547 std::unique_ptr<XmlElementWriter> group = project.SubElement("ItemGroup"); 568 std::unique_ptr<XmlElementWriter> group = project.SubElement("ItemGroup");
548 std::vector<OutputFile> tool_outputs; // Prevent reallocation in loop. 569 std::vector<OutputFile> tool_outputs; // Prevent reallocation in loop.
549 570
550 for (const SourceFile& file : target->sources()) { 571 for (const SourceFile& file : target->sources()) {
551 const char* compile_type; 572 const char* compile_type;
552 Toolchain::ToolType tool_type = Toolchain::TYPE_NONE; 573 Toolchain::ToolType tool_type = Toolchain::TYPE_NONE;
553 if (target->GetOutputFilesForSource(file, &tool_type, &tool_outputs)) { 574 if (target->GetOutputFilesForSource(file, &tool_type, &tool_outputs)) {
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 } 859 }
839 } 860 }
840 861
841 std::string VisualStudioWriter::GetNinjaTarget(const Target* target) { 862 std::string VisualStudioWriter::GetNinjaTarget(const Target* target) {
842 std::ostringstream ninja_target_out; 863 std::ostringstream ninja_target_out;
843 DCHECK(!target->dependency_output_file().value().empty()); 864 DCHECK(!target->dependency_output_file().value().empty());
844 ninja_path_output_.WriteFile(ninja_target_out, 865 ninja_path_output_.WriteFile(ninja_target_out,
845 target->dependency_output_file()); 866 target->dependency_output_file());
846 return ninja_target_out.str(); 867 return ninja_target_out.str();
847 } 868 }
OLDNEW
« no previous file with comments | « tools/gn/visual_studio_utils_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698