| 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> |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 private: | 31 private: |
| 32 FRIEND_TEST_ALL_PREFIXES(VisualStudioWriterTest, ResolveSolutionFolders); | 32 FRIEND_TEST_ALL_PREFIXES(VisualStudioWriterTest, ResolveSolutionFolders); |
| 33 FRIEND_TEST_ALL_PREFIXES(VisualStudioWriterTest, | 33 FRIEND_TEST_ALL_PREFIXES(VisualStudioWriterTest, |
| 34 ResolveSolutionFolders_AbsPath); | 34 ResolveSolutionFolders_AbsPath); |
| 35 | 35 |
| 36 // Solution project or folder. | 36 // Solution project or folder. |
| 37 struct SolutionEntry { | 37 struct SolutionEntry { |
| 38 SolutionEntry(const std::string& name, | 38 SolutionEntry(const std::string& name, |
| 39 const std::string& path, | 39 const std::string& path, |
| 40 const std::string& guid); | 40 const std::string& guid); |
| 41 | 41 virtual ~SolutionEntry(); |
| 42 ~SolutionEntry(); | |
| 43 | 42 |
| 44 // Entry name. For projects must be unique in the solution. | 43 // Entry name. For projects must be unique in the solution. |
| 45 std::string name; | 44 std::string name; |
| 46 // Absolute project file or folder directory path. | 45 // Absolute project file or folder directory path. |
| 47 std::string path; | 46 std::string path; |
| 48 // Absolute label dir path (only for projects). | |
| 49 std::string label_dir_path; | |
| 50 // GUID-like string. | 47 // GUID-like string. |
| 51 std::string guid; | 48 std::string guid; |
| 52 // Pointer to parent folder. nullptr if entry has no parent. | 49 // Pointer to parent folder. nullptr if entry has no parent. |
| 53 SolutionEntry* parent_folder; | 50 SolutionEntry* parent_folder; |
| 54 }; | 51 }; |
| 55 | 52 |
| 56 using SolutionEntries = std::vector<SolutionEntry*>; | 53 struct SolutionProject : public SolutionEntry { |
| 54 SolutionProject(const std::string& name, |
| 55 const std::string& path, |
| 56 const std::string& guid, |
| 57 const std::string& label_dir_path, |
| 58 const std::string& config_platform); |
| 59 ~SolutionProject() override; |
| 60 |
| 61 // Absolute label dir path. |
| 62 std::string label_dir_path; |
| 63 // Configuration platform. May be different than solution config platform. |
| 64 std::string config_platform; |
| 65 }; |
| 66 |
| 67 using SolutionProjects = std::vector<SolutionProject*>; |
| 68 using SolutionFolders = std::vector<SolutionEntry*>; |
| 57 | 69 |
| 58 explicit VisualStudioWriter(const BuildSettings* build_settings); | 70 explicit VisualStudioWriter(const BuildSettings* build_settings); |
| 59 ~VisualStudioWriter(); | 71 ~VisualStudioWriter(); |
| 60 | 72 |
| 61 bool WriteProjectFiles(const Target* target, Err* err); | 73 bool WriteProjectFiles(const Target* target, Err* err); |
| 62 bool WriteProjectFileContents(std::ostream& out, | 74 bool WriteProjectFileContents(std::ostream& out, |
| 63 const SolutionEntry& solution_project, | 75 const SolutionProject& solution_project, |
| 64 const Target* target, | 76 const Target* target, |
| 65 Err* err); | 77 Err* err); |
| 66 void WriteFiltersFileContents(std::ostream& out, const Target* target); | 78 void WriteFiltersFileContents(std::ostream& out, const Target* target); |
| 67 bool WriteSolutionFile(Err* err); | 79 bool WriteSolutionFile(Err* err); |
| 68 void WriteSolutionFileContents(std::ostream& out, | 80 void WriteSolutionFileContents(std::ostream& out, |
| 69 const base::FilePath& solution_dir_path); | 81 const base::FilePath& solution_dir_path); |
| 70 | 82 |
| 71 // Resolves all solution folders (parent folders for projects) into |folders_| | 83 // Resolves all solution folders (parent folders for projects) into |folders_| |
| 72 // and updates |root_folder_dir_|. Also sets |parent_folder| for |projects_|. | 84 // and updates |root_folder_dir_|. Also sets |parent_folder| for |projects_|. |
| 73 void ResolveSolutionFolders(); | 85 void ResolveSolutionFolders(); |
| 74 | 86 |
| 75 const BuildSettings* build_settings_; | 87 const BuildSettings* build_settings_; |
| 76 | 88 |
| 77 // Indicates if project files are generated for Debug mode configuration. | 89 // Indicates if project files are generated for Debug mode configuration. |
| 78 bool is_debug_config_; | 90 bool is_debug_config_; |
| 79 | 91 |
| 80 // Platform for projects configuration (Win32, x64). | 92 // Platform for solution configuration (Win32, x64). Some projects may be |
| 93 // configured for different platform. |
| 81 std::string config_platform_; | 94 std::string config_platform_; |
| 82 | 95 |
| 83 // All projects contained by solution. | 96 // All projects contained by solution. |
| 84 SolutionEntries projects_; | 97 SolutionProjects projects_; |
| 85 | 98 |
| 86 // Absolute root solution folder path. | 99 // Absolute root solution folder path. |
| 87 std::string root_folder_path_; | 100 std::string root_folder_path_; |
| 88 | 101 |
| 89 // Folders for all solution projects. | 102 // Folders for all solution projects. |
| 90 SolutionEntries folders_; | 103 SolutionFolders folders_; |
| 91 | 104 |
| 92 // Semicolon-separated Windows SDK include directories. | 105 // Semicolon-separated Windows SDK include directories. |
| 93 std::string windows_kits_include_dirs_; | 106 std::string windows_kits_include_dirs_; |
| 94 | 107 |
| 95 DISALLOW_COPY_AND_ASSIGN(VisualStudioWriter); | 108 DISALLOW_COPY_AND_ASSIGN(VisualStudioWriter); |
| 96 }; | 109 }; |
| 97 | 110 |
| 98 #endif // TOOLS_GN_VISUAL_STUDIO_WRITER_H_ | 111 #endif // TOOLS_GN_VISUAL_STUDIO_WRITER_H_ |
| OLD | NEW |