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 #ifndef TOOLS_GN_VISUAL_STUDIO_WRITER_H_ | 5 #ifndef TOOLS_GN_VISUAL_STUDIO_WRITER_H_ |
6 #define TOOLS_GN_VISUAL_STUDIO_WRITER_H_ | 6 #define TOOLS_GN_VISUAL_STUDIO_WRITER_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 | 14 |
15 namespace base { | 15 namespace base { |
16 class FilePath; | 16 class FilePath; |
17 } | 17 } |
18 | 18 |
19 class Builder; | 19 class Builder; |
20 class BuildSettings; | 20 class BuildSettings; |
21 class Err; | 21 class Err; |
22 class Target; | 22 class Target; |
23 | 23 |
24 class VisualStudioWriter { | 24 class VisualStudioWriter { |
25 public: | 25 public: |
| 26 enum Version { |
| 27 Vs2013 = 1, // Visual Studio 2013 |
| 28 Vs2015 // Visual Studio 2015 |
| 29 }; |
| 30 |
26 // On failure will populate |err| and will return false. | 31 // On failure will populate |err| and will return false. |
27 static bool RunAndWriteFiles(const BuildSettings* build_settings, | 32 static bool RunAndWriteFiles(const BuildSettings* build_settings, |
28 Builder* builder, | 33 Builder* builder, |
| 34 Version version, |
29 Err* err); | 35 Err* err); |
30 | 36 |
31 private: | 37 private: |
32 FRIEND_TEST_ALL_PREFIXES(VisualStudioWriterTest, ResolveSolutionFolders); | 38 FRIEND_TEST_ALL_PREFIXES(VisualStudioWriterTest, ResolveSolutionFolders); |
33 FRIEND_TEST_ALL_PREFIXES(VisualStudioWriterTest, | 39 FRIEND_TEST_ALL_PREFIXES(VisualStudioWriterTest, |
34 ResolveSolutionFolders_AbsPath); | 40 ResolveSolutionFolders_AbsPath); |
35 | 41 |
36 // Solution project or folder. | 42 // Solution project or folder. |
37 struct SolutionEntry { | 43 struct SolutionEntry { |
38 SolutionEntry(const std::string& name, | 44 SolutionEntry(const std::string& name, |
(...skipping 21 matching lines...) Expand all Loading... |
60 | 66 |
61 // Absolute label dir path. | 67 // Absolute label dir path. |
62 std::string label_dir_path; | 68 std::string label_dir_path; |
63 // Configuration platform. May be different than solution config platform. | 69 // Configuration platform. May be different than solution config platform. |
64 std::string config_platform; | 70 std::string config_platform; |
65 }; | 71 }; |
66 | 72 |
67 using SolutionProjects = std::vector<SolutionProject*>; | 73 using SolutionProjects = std::vector<SolutionProject*>; |
68 using SolutionFolders = std::vector<SolutionEntry*>; | 74 using SolutionFolders = std::vector<SolutionEntry*>; |
69 | 75 |
70 explicit VisualStudioWriter(const BuildSettings* build_settings); | 76 explicit VisualStudioWriter(const BuildSettings* build_settings, |
| 77 Version version); |
71 ~VisualStudioWriter(); | 78 ~VisualStudioWriter(); |
72 | 79 |
73 bool WriteProjectFiles(const Target* target, Err* err); | 80 bool WriteProjectFiles(const Target* target, Err* err); |
74 bool WriteProjectFileContents(std::ostream& out, | 81 bool WriteProjectFileContents(std::ostream& out, |
75 const SolutionProject& solution_project, | 82 const SolutionProject& solution_project, |
76 const Target* target, | 83 const Target* target, |
77 Err* err); | 84 Err* err); |
78 void WriteFiltersFileContents(std::ostream& out, const Target* target); | 85 void WriteFiltersFileContents(std::ostream& out, const Target* target); |
79 bool WriteSolutionFile(Err* err); | 86 bool WriteSolutionFile(Err* err); |
80 void WriteSolutionFileContents(std::ostream& out, | 87 void WriteSolutionFileContents(std::ostream& out, |
81 const base::FilePath& solution_dir_path); | 88 const base::FilePath& solution_dir_path); |
82 | 89 |
83 // Resolves all solution folders (parent folders for projects) into |folders_| | 90 // Resolves all solution folders (parent folders for projects) into |folders_| |
84 // and updates |root_folder_dir_|. Also sets |parent_folder| for |projects_|. | 91 // and updates |root_folder_dir_|. Also sets |parent_folder| for |projects_|. |
85 void ResolveSolutionFolders(); | 92 void ResolveSolutionFolders(); |
86 | 93 |
87 const BuildSettings* build_settings_; | 94 const BuildSettings* build_settings_; |
88 | 95 |
| 96 // Toolset version. |
| 97 const char* toolset_version_; |
| 98 |
| 99 // Project version. |
| 100 const char* project_version_; |
| 101 |
| 102 // Visual Studio version string. |
| 103 const char* version_string_; |
| 104 |
89 // Indicates if project files are generated for Debug mode configuration. | 105 // Indicates if project files are generated for Debug mode configuration. |
90 bool is_debug_config_; | 106 bool is_debug_config_; |
91 | 107 |
92 // Platform for solution configuration (Win32, x64). Some projects may be | 108 // Platform for solution configuration (Win32, x64). Some projects may be |
93 // configured for different platform. | 109 // configured for different platform. |
94 std::string config_platform_; | 110 std::string config_platform_; |
95 | 111 |
96 // All projects contained by solution. | 112 // All projects contained by solution. |
97 SolutionProjects projects_; | 113 SolutionProjects projects_; |
98 | 114 |
99 // Absolute root solution folder path. | 115 // Absolute root solution folder path. |
100 std::string root_folder_path_; | 116 std::string root_folder_path_; |
101 | 117 |
102 // Folders for all solution projects. | 118 // Folders for all solution projects. |
103 SolutionFolders folders_; | 119 SolutionFolders folders_; |
104 | 120 |
105 // Semicolon-separated Windows SDK include directories. | 121 // Semicolon-separated Windows SDK include directories. |
106 std::string windows_kits_include_dirs_; | 122 std::string windows_kits_include_dirs_; |
107 | 123 |
108 DISALLOW_COPY_AND_ASSIGN(VisualStudioWriter); | 124 DISALLOW_COPY_AND_ASSIGN(VisualStudioWriter); |
109 }; | 125 }; |
110 | 126 |
111 #endif // TOOLS_GN_VISUAL_STUDIO_WRITER_H_ | 127 #endif // TOOLS_GN_VISUAL_STUDIO_WRITER_H_ |
OLD | NEW |