- Move NCI generated files to arch-specific directories
[reactos.git] / reactos / tools / rbuild / backend / msvc / msvc.h
1 /*
2 * Copyright (C) 2005 Trevor McCort
3 * Copyright (C) 2005 Casper S. Hornstrup
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19 #ifndef __MSVC_H__
20 #define __MSVC_H__
21
22 #include <fstream>
23 #include <vector>
24 #include <string>
25
26 #include "../backend.h"
27
28 class FileUnit
29 {
30 public:
31 std::string filename;
32 std::string folder;
33 };
34
35 enum OptimizationType
36 {
37 Debug,
38 Release,
39 Speed
40 };
41
42 enum HeadersType
43 {
44 MSVCHeaders,
45 WineHeaders
46 };
47
48 class MSVCConfiguration
49 {
50 public:
51 MSVCConfiguration(const OptimizationType optimization,
52 const HeadersType headers = MSVCHeaders,
53 const std::string &name = "");
54 virtual ~MSVCConfiguration() {}
55 std::string name;
56 OptimizationType optimization;
57 HeadersType headers;
58 };
59
60 class MSVCBackend : public Backend
61 {
62 public:
63
64 MSVCBackend(Project &project,
65 Configuration& configuration);
66 virtual ~MSVCBackend() {}
67
68 virtual void Process();
69
70 private:
71
72 void ProcessModules();
73 void ProcessFile(std::string &filename);
74
75 bool CheckFolderAdded(std::string &folder);
76 void AddFolders(std::string &folder);
77
78 void OutputFolders();
79 void OutputFileUnits();
80
81 std::string DspFileName ( const Module& module ) const;
82 std::string VcprojFileName ( const Module& module ) const;
83 std::string DswFileName ( const Module& module ) const;
84 std::string SlnFileName ( const Module& module ) const;
85 std::string OptFileName ( const Module& module ) const;
86 std::string SuoFileName ( const Module& module ) const;
87 std::string NcbFileName ( const Module& module ) const;
88
89 std::vector<MSVCConfiguration*> m_configurations;
90
91 std::vector<FileUnit> m_fileUnits;
92 std::vector<std::string> m_folders;
93
94 int m_unitCount;
95
96 FILE* m_dswFile;
97 FILE* m_slnFile;
98 FILE* m_rulesFile;
99
100 // functions in msvcmaker.cpp:
101
102 void _generate_dsp ( const Module& module );
103 void _generate_dsw_header ( FILE* OUT );
104 void _generate_dsw_project (
105 FILE* OUT,
106 const Module& module,
107 std::string dsp_file,
108 const std::vector<Dependency*>& dependencies );
109
110 void _generate_dsw_footer ( FILE* OUT );
111 void _generate_wine_dsw ( FILE* OUT );
112
113 // functions in vcprojmaker.cpp:
114
115 std::string _get_solution_version ( void );
116 std::string _gen_guid();
117 std::string _replace_str(
118 std::string string1,
119 const std::string &find_str,
120 const std::string &replace_str);
121
122 std::string _get_vc_dir ( void ) const;
123
124 void _generate_vcproj ( const Module& module );
125
126 void _generate_sln_header ( FILE* OUT );
127 void _generate_sln_footer ( FILE* OUT );
128 void _generate_sln ( FILE* OUT );
129 //void _generate_rules_file ( FILE* OUT );
130 void _generate_sln_project (
131 FILE* OUT,
132 const Module& module,
133 std::string vcproj_file,
134 std::string sln_guid,
135 std::string vcproj_guid,
136 const std::vector<Library*>& libraries );
137 void _generate_sln_configurations (
138 FILE* OUT,
139 std::string vcproj_guid );
140 void _clean_project_files ( void );
141 void _get_object_files ( const Module& module, std::vector<std::string>& out ) const;
142 void _get_def_files ( const Module& module, std::vector<std::string>& out ) const;
143 void _install_files ( const std::string& vcdir, const std::string& config );
144 bool _copy_file ( const std::string& inputname, const std::string& targetname ) const;
145 const Property* _lookup_property ( const Module& module, const std::string& name ) const;
146 };
147
148 #endif // __MSVC_H__
149