| OLD | NEW |
| 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 <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 std::string GetConfigurationType(const Target* target, Err* err) { | 118 std::string GetConfigurationType(const Target* target, Err* err) { |
| 119 switch (target->output_type()) { | 119 switch (target->output_type()) { |
| 120 case Target::EXECUTABLE: | 120 case Target::EXECUTABLE: |
| 121 return "Application"; | 121 return "Application"; |
| 122 case Target::SHARED_LIBRARY: | 122 case Target::SHARED_LIBRARY: |
| 123 case Target::LOADABLE_MODULE: | 123 case Target::LOADABLE_MODULE: |
| 124 return "DynamicLibrary"; | 124 return "DynamicLibrary"; |
| 125 case Target::STATIC_LIBRARY: | 125 case Target::STATIC_LIBRARY: |
| 126 case Target::SOURCE_SET: | 126 case Target::SOURCE_SET: |
| 127 return "StaticLibrary"; | 127 return "StaticLibrary"; |
| 128 case Target::GROUP: |
| 129 return "Utility"; |
| 128 | 130 |
| 129 default: | 131 default: |
| 130 *err = Err(Location(), | 132 *err = Err(Location(), |
| 131 "Visual Studio doesn't support '" + target->label().name() + | 133 "Visual Studio doesn't support '" + target->label().name() + |
| 132 "' target output type: " + | 134 "' target output type: " + |
| 133 Target::GetStringForOutputType(target->output_type())); | 135 Target::GetStringForOutputType(target->output_type())); |
| 134 return std::string(); | 136 return std::string(); |
| 135 } | 137 } |
| 136 } | 138 } |
| 137 | 139 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 if (target_cpu_value != nullptr && | 254 if (target_cpu_value != nullptr && |
| 253 target_cpu_value->string_value() == "x64") | 255 target_cpu_value->string_value() == "x64") |
| 254 config_platform = "x64"; | 256 config_platform = "x64"; |
| 255 } | 257 } |
| 256 | 258 |
| 257 VisualStudioWriter writer(build_settings, config_platform, version); | 259 VisualStudioWriter writer(build_settings, config_platform, version); |
| 258 writer.projects_.reserve(targets.size()); | 260 writer.projects_.reserve(targets.size()); |
| 259 writer.folders_.reserve(targets.size()); | 261 writer.folders_.reserve(targets.size()); |
| 260 | 262 |
| 261 for (const Target* target : targets) { | 263 for (const Target* target : targets) { |
| 262 // Skip actions, groups and bundle targets. | 264 // Skip actions and bundle targets. |
| 263 if (target->output_type() == Target::GROUP || | 265 if (target->output_type() == Target::COPY_FILES || |
| 264 target->output_type() == Target::COPY_FILES || | |
| 265 target->output_type() == Target::ACTION || | 266 target->output_type() == Target::ACTION || |
| 266 target->output_type() == Target::ACTION_FOREACH || | 267 target->output_type() == Target::ACTION_FOREACH || |
| 267 target->output_type() == Target::BUNDLE_DATA) { | 268 target->output_type() == Target::BUNDLE_DATA) { |
| 268 continue; | 269 continue; |
| 269 } | 270 } |
| 270 | 271 |
| 271 if (!writer.WriteProjectFiles(target, err)) | 272 if (!writer.WriteProjectFiles(target, err)) |
| 272 return false; | 273 return false; |
| 273 } | 274 } |
| 274 | 275 |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 | 418 |
| 418 project.SubElement("PropertyGroup", XmlAttributes("Label", "UserMacros")); | 419 project.SubElement("PropertyGroup", XmlAttributes("Label", "UserMacros")); |
| 419 | 420 |
| 420 { | 421 { |
| 421 scoped_ptr<XmlElementWriter> properties = | 422 scoped_ptr<XmlElementWriter> properties = |
| 422 project.SubElement("PropertyGroup"); | 423 project.SubElement("PropertyGroup"); |
| 423 { | 424 { |
| 424 scoped_ptr<XmlElementWriter> out_dir = properties->SubElement("OutDir"); | 425 scoped_ptr<XmlElementWriter> out_dir = properties->SubElement("OutDir"); |
| 425 path_output.WriteDir(out_dir->StartContent(false), | 426 path_output.WriteDir(out_dir->StartContent(false), |
| 426 build_settings_->build_dir(), | 427 build_settings_->build_dir(), |
| 427 PathOutput::DIR_INCLUDE_LAST_SLASH); | 428 PathOutput::DIR_NO_LAST_SLASH); |
| 428 } | 429 } |
| 429 properties->SubElement("TargetName")->Text("$(ProjectName)"); | 430 properties->SubElement("TargetName")->Text("$(ProjectName)"); |
| 430 properties->SubElement("TargetPath") | 431 if (target->output_type() != Target::GROUP) { |
| 431 ->Text("$(OutDir)\\$(ProjectName)$(TargetExt)"); | 432 properties->SubElement("TargetPath") |
| 433 ->Text("$(OutDir)\\$(ProjectName)$(TargetExt)"); |
| 434 } |
| 432 } | 435 } |
| 433 | 436 |
| 434 { | 437 { |
| 435 scoped_ptr<XmlElementWriter> item_definitions = | 438 scoped_ptr<XmlElementWriter> item_definitions = |
| 436 project.SubElement("ItemDefinitionGroup"); | 439 project.SubElement("ItemDefinitionGroup"); |
| 437 { | 440 { |
| 438 scoped_ptr<XmlElementWriter> cl_compile = | 441 scoped_ptr<XmlElementWriter> cl_compile = |
| 439 item_definitions->SubElement("ClCompile"); | 442 item_definitions->SubElement("ClCompile"); |
| 440 { | 443 { |
| 441 scoped_ptr<XmlElementWriter> include_dirs = | 444 scoped_ptr<XmlElementWriter> include_dirs = |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 } | 794 } |
| 792 } | 795 } |
| 793 | 796 |
| 794 std::string VisualStudioWriter::GetNinjaTarget(const Target* target) { | 797 std::string VisualStudioWriter::GetNinjaTarget(const Target* target) { |
| 795 std::ostringstream ninja_target_out; | 798 std::ostringstream ninja_target_out; |
| 796 DCHECK(!target->dependency_output_file().value().empty()); | 799 DCHECK(!target->dependency_output_file().value().empty()); |
| 797 ninja_path_output_.WriteFile(ninja_target_out, | 800 ninja_path_output_.WriteFile(ninja_target_out, |
| 798 target->dependency_output_file()); | 801 target->dependency_output_file()); |
| 799 return ninja_target_out.str(); | 802 return ninja_target_out.str(); |
| 800 } | 803 } |
| OLD | NEW |