├── GenerateQTProject.sln
├── GenerateQTProject
├── App.config
├── GenerateQTProject.csproj
├── Properties
│ └── AssemblyInfo.cs
├── qtBuildPreset.xml
└── src
│ ├── Configuration.cs
│ ├── ConsoleActions.cs
│ ├── Errors.cs
│ ├── FileActions.cs
│ ├── Generator.cs
│ ├── Program.cs
│ └── ProjectFileParsers
│ ├── ProjectFileParser.cs
│ └── VCX_Parser.cs
├── LICENSE
└── README.md
/GenerateQTProject.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2013
4 | VisualStudioVersion = 12.0.31101.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GenerateQTProject", "GenerateQTProject\GenerateQTProject.csproj", "{49963CCF-EA50-4345-AA99-908417B7DE11}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Debug|x86 = Debug|x86
12 | Release|Any CPU = Release|Any CPU
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {49963CCF-EA50-4345-AA99-908417B7DE11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {49963CCF-EA50-4345-AA99-908417B7DE11}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {49963CCF-EA50-4345-AA99-908417B7DE11}.Debug|x86.ActiveCfg = Debug|x86
19 | {49963CCF-EA50-4345-AA99-908417B7DE11}.Debug|x86.Build.0 = Debug|x86
20 | {49963CCF-EA50-4345-AA99-908417B7DE11}.Release|Any CPU.ActiveCfg = Release|Any CPU
21 | {49963CCF-EA50-4345-AA99-908417B7DE11}.Release|Any CPU.Build.0 = Release|Any CPU
22 | {49963CCF-EA50-4345-AA99-908417B7DE11}.Release|x86.ActiveCfg = Release|x86
23 | {49963CCF-EA50-4345-AA99-908417B7DE11}.Release|x86.Build.0 = Release|x86
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | EndGlobal
29 |
--------------------------------------------------------------------------------
/GenerateQTProject/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/GenerateQTProject/GenerateQTProject.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {49963CCF-EA50-4345-AA99-908417B7DE11}
8 | Exe
9 | Properties
10 | GenerateQTProject
11 | uProGen
12 | v4.0
13 | 512
14 | Client
15 | publish\
16 | true
17 | Disk
18 | false
19 | Foreground
20 | 7
21 | Days
22 | false
23 | false
24 | true
25 | 0
26 | 1.0.0.%2a
27 | false
28 | false
29 | true
30 |
31 |
32 | AnyCPU
33 | true
34 | full
35 | false
36 | bin\Debug\
37 | DEBUG;TRACE
38 | prompt
39 | 4
40 |
41 |
42 | AnyCPU
43 | pdbonly
44 | true
45 | bin\Release\
46 | TRACE
47 | prompt
48 | 4
49 |
50 |
51 | true
52 | bin\x86\Debug\
53 | DEBUG;TRACE
54 | full
55 | x86
56 | prompt
57 | MinimumRecommendedRules.ruleset
58 | true
59 |
60 |
61 | bin\x86\Release\
62 | TRACE
63 | true
64 | pdbonly
65 | x86
66 | prompt
67 | MinimumRecommendedRules.ruleset
68 | true
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 | Always
96 |
97 |
98 |
99 |
100 | False
101 | Microsoft .NET Framework 4 Client Profile %28x86 und x64%29
102 | true
103 |
104 |
105 | False
106 | .NET Framework 3.5 SP1
107 | false
108 |
109 |
110 | False
111 | Windows Installer 4.5
112 | true
113 |
114 |
115 |
116 |
123 |
--------------------------------------------------------------------------------
/GenerateQTProject/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 | using System.Resources;
5 |
6 | // General Information about an assembly is controlled through the following
7 | // set of attributes. Change these attribute values to modify the information
8 | // associated with an assembly.
9 | [assembly: AssemblyTitle("Unreal Qt Project Generator")]
10 | [assembly: AssemblyDescription("This small tool allows you to generate a Qt .pro file based on an Unreal Engine 4 Visual Studio project.")]
11 | [assembly: AssemblyConfiguration("")]
12 | [assembly: AssemblyCompany("N. Baumann")]
13 | [assembly: AssemblyProduct("uProGen")]
14 | [assembly: AssemblyCopyright("Copyright © 2015")]
15 | [assembly: AssemblyTrademark("")]
16 | [assembly: AssemblyCulture("")]
17 |
18 | // Setting ComVisible to false makes the types in this assembly not visible
19 | // to COM components. If you need to access a type in this assembly from
20 | // COM, set the ComVisible attribute to true on that type.
21 | [assembly: ComVisible(false)]
22 |
23 | // The following GUID is for the ID of the typelib if this project is exposed to COM
24 | [assembly: Guid("1c1f3a5d-383e-4b90-8a70-0516e9542ea8")]
25 |
26 | // Version information for an assembly consists of the following four values:
27 | //
28 | // Major Version
29 | // Minor Version
30 | // Build Number
31 | // Revision
32 | //
33 | // You can specify all the values or you can default the Build and Revision Numbers
34 | // by using the '*' as shown below:
35 | // [assembly: AssemblyVersion("1.0.*")]
36 | [assembly: AssemblyVersion("1.0.0.3")]
37 | [assembly: AssemblyFileVersion("1.0.0.3")]
38 | [assembly: NeutralResourcesLanguageAttribute("en")]
39 |
--------------------------------------------------------------------------------
/GenerateQTProject/qtBuildPreset.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | EnvironmentId
7 | $QT_ENV_ID
8 |
9 |
10 | ProjectExplorer.Project.ActiveTarget
11 | 0
12 |
13 |
14 | ProjectExplorer.Project.Target.0
15 |
16 | Unreal Engine 4
17 | Unreal Engine 4
18 | $QT_CONF_ID
19 | 2
20 | 0
21 | 4
22 |
23 | $PROJECT_DIR/Intermediate/ProjectFiles
24 |
25 |
26 | true
27 | $PROJECT_NAMEEditor Win64 DebugGame "$UPROJ_FILE" -rocket -waitmutex
28 | $UNREAL_PATH/Engine/Build/BatchFiles/Build.bat
29 | $PROJECT_DIR
30 | Custom process step
31 |
32 | ProjectExplorer.ProcessStep
33 |
34 | 1
35 | Build
36 |
37 | ProjectExplorer.BuildSteps.Build
38 |
39 |
40 |
41 | true
42 | $PROJECT_NAMEEditor Win64 DebugGame "$UPROJ_FILE" -rocket -waitmutex
43 | $UNREAL_PATH/Engine/Build/BatchFiles/Clean.bat
44 | $PROJECT_DIR
45 | Custom process step
46 |
47 | ProjectExplorer.ProcessStep
48 |
49 | 1
50 | Clean
51 |
52 | ProjectExplorer.BuildSteps.Clean
53 |
54 | 2
55 | false
56 |
57 | Release
58 | Debug Editor
59 | Qt4ProjectManager.Qt4BuildConfiguration
60 | 0
61 | true
62 |
63 |
64 | $PROJECT_DIR/Intermediate/ProjectFiles
65 |
66 |
67 | true
68 | $PROJECT_NAME Win64 DebugGame "$UPROJ_FILE" -rocket -waitmutex
69 | $UNREAL_PATH/Engine/Build/BatchFiles/Build.bat
70 | $PROJECT_DIR
71 | Custom process step
72 |
73 | ProjectExplorer.ProcessStep
74 |
75 | 1
76 | Build
77 |
78 | ProjectExplorer.BuildSteps.Build
79 |
80 |
81 |
82 | true
83 | $PROJECT_NAME Win64 DebugGame "$UPROJ_FILE" -rocket -waitmutex
84 | $UNREAL_PATH/Engine/Build/BatchFiles/Clean.bat
85 | $PROJECT_DIR
86 | Custom process step
87 |
88 | ProjectExplorer.ProcessStep
89 |
90 | 1
91 | Clean
92 |
93 | ProjectExplorer.BuildSteps.Clean
94 |
95 | 2
96 | false
97 |
98 | Release
99 | Debug Standalone
100 | Qt4ProjectManager.Qt4BuildConfiguration
101 | 0
102 | true
103 |
104 |
105 | $PROJECT_DIR/Intermediate/ProjectFiles
106 |
107 |
108 | true
109 | $PROJECT_NAMEEditor Win64 Development "$UPROJ_FILE" -rocket -waitmutex
110 | $UNREAL_PATH/Engine/Build/BatchFiles/Build.bat
111 | $PROJECT_DIR
112 | Custom process step
113 |
114 | ProjectExplorer.ProcessStep
115 |
116 | 1
117 | Build
118 |
119 | ProjectExplorer.BuildSteps.Build
120 |
121 |
122 |
123 | true
124 | $PROJECT_NAMEEditor Win64 Development "$UPROJ_FILE" -rocket -waitmutex
125 | $UNREAL_PATH/Engine/Build/BatchFiles/Clean.bat
126 | $PROJECT_DIR
127 | Custom process step
128 |
129 | ProjectExplorer.ProcessStep
130 |
131 | 1
132 | Clean
133 |
134 | ProjectExplorer.BuildSteps.Clean
135 |
136 | 2
137 | false
138 |
139 | Release
140 | Development Editor
141 | Qt4ProjectManager.Qt4BuildConfiguration
142 | 0
143 | true
144 |
145 |
146 | $PROJECT_DIR/Intermediate/ProjectFiles
147 |
148 |
149 | true
150 | $PROJECT_NAME Win64 Development "$UPROJ_FILE" -rocket -waitmutex
151 | $UNREAL_PATH/Engine/Build/BatchFiles/Build.bat
152 | $PROJECT_DIR
153 | Custom process step
154 |
155 | ProjectExplorer.ProcessStep
156 |
157 | 1
158 | Build
159 |
160 | ProjectExplorer.BuildSteps.Build
161 |
162 |
163 |
164 | true
165 | $PROJECT_NAME Win64 Development "$UPROJ_FILE" -rocket -waitmutex
166 | $UNREAL_PATH/Engine/Build/BatchFiles/Clean.bat
167 | $PROJECT_DIR
168 | Custom process step
169 |
170 | ProjectExplorer.ProcessStep
171 |
172 | 1
173 | Clean
174 |
175 | ProjectExplorer.BuildSteps.Clean
176 |
177 | 2
178 | false
179 |
180 | Release
181 | Development Standalone
182 | Qt4ProjectManager.Qt4BuildConfiguration
183 | 0
184 | true
185 |
186 |
187 | $PROJECT_DIR/Intermediate/ProjectFiles
188 |
189 |
190 | true
191 | "$UPROJ_FILE" -run=cook -targetplatform=WindowsNoEditor -iterate -silent
192 | $UNREAL_PATH/Engine/Binaries/Win64/UE4Editor.exe
193 | $PROJECT_DIR
194 | Custom process step
195 |
196 | ProjectExplorer.ProcessStep
197 |
198 | 1
199 | Build
200 |
201 | ProjectExplorer.BuildSteps.Build
202 |
203 | 1
204 | false
205 |
206 | Release
207 | Cook
208 | Qt4ProjectManager.Qt4BuildConfiguration
209 | 0
210 | true
211 |
212 |
213 | $PROJECT_DIR/Intermediate/ProjectFiles
214 |
215 |
216 | true
217 | "$UPROJ_FILE" -run=cook -targetplatform=WindowsNoEditor -silent
218 | $UNREAL_PATH/Engine/Binaries/Win64/UE4Editor.exe
219 | $PROJECT_DIR
220 | Custom process step
221 |
222 | ProjectExplorer.ProcessStep
223 |
224 |
225 | true
226 | $PROJECT_NAME Win32 Shipping "$UPROJ_FILE" -rocket -waitmutex
227 | $UNREAL_PATH/Engine/Build/BatchFiles/Build.bat
228 | $PROJECT_DIR
229 | Custom process step
230 |
231 | ProjectExplorer.ProcessStep
232 |
233 | 2
234 | Build
235 |
236 | ProjectExplorer.BuildSteps.Build
237 |
238 |
239 |
240 | true
241 | $PROJECT_NAME Win32 Shipping "$UPROJ_FILE" -rocket -waitmutex
242 | $UNREAL_PATH/Engine/Build/BatchFiles/Clean.bat
243 | $PROJECT_DIR
244 | Custom process step
245 |
246 | ProjectExplorer.ProcessStep
247 |
248 | 1
249 | Clean
250 |
251 | ProjectExplorer.BuildSteps.Clean
252 |
253 | 2
254 | false
255 |
256 | Release
257 | Shipping
258 | Qt4ProjectManager.Qt4BuildConfiguration
259 | 0
260 | true
261 |
262 | 6
263 |
264 |
265 | 0
266 | Deployment
267 |
268 | ProjectExplorer.BuildSteps.Deploy
269 |
270 | 1
271 | Local Deployment
272 |
273 | ProjectExplorer.DefaultDeployConfiguration
274 |
275 | 1
276 |
277 |
278 |
279 | false
280 | false
281 | false
282 | false
283 | true
284 | 0.01
285 | 10
286 | true
287 | 1
288 | 25
289 |
290 | 1
291 | true
292 | false
293 | true
294 | valgrind
295 |
296 | 0
297 | 1
298 | 2
299 | 3
300 | 4
301 | 5
302 | 6
303 | 7
304 | 8
305 | 9
306 | 10
307 | 11
308 | 12
309 | 13
310 | 14
311 |
312 | 2
313 |
314 | -debug
315 | ../../Binaries/Win64/$PROJECT_NAME-Win64-DebugGame.exe
316 | false
317 | $PROJECT_DIR/Binaries/Win64
318 | UE4
319 | Debug Game Standalone
320 | ProjectExplorer.CustomExecutableRunConfiguration
321 | 3768
322 | false
323 | true
324 | false
325 | false
326 | true
327 |
328 |
329 |
330 | false
331 | false
332 | false
333 | false
334 | true
335 | 0.01
336 | 10
337 | true
338 | 1
339 | 25
340 |
341 | 1
342 | true
343 | false
344 | true
345 | valgrind
346 |
347 | 0
348 | 1
349 | 2
350 | 3
351 | 4
352 | 5
353 | 6
354 | 7
355 | 8
356 | 9
357 | 10
358 | 11
359 | 12
360 | 13
361 | 14
362 |
363 | 2
364 |
365 |
366 | ../../Binaries/Win64/$PROJECT_NAME.exe
367 | false
368 | $PROJECT_DIR/Binaries/Win64
369 | UE4
370 | Development Standalone
371 | ProjectExplorer.CustomExecutableRunConfiguration
372 | 3768
373 | false
374 | true
375 | false
376 | false
377 | true
378 |
379 |
380 |
381 | false
382 | false
383 | false
384 | false
385 | true
386 | 0.01
387 | 10
388 | true
389 | 1
390 | 25
391 |
392 | 1
393 | true
394 | false
395 | true
396 | valgrind
397 |
398 | 0
399 | 1
400 | 2
401 | 3
402 | 4
403 | 5
404 | 6
405 | 7
406 | 8
407 | 9
408 | 10
409 | 11
410 | 12
411 | 13
412 | 14
413 |
414 | 2
415 |
416 |
417 | ../../Binaries/Win32/$PROJECT_NAME-Win32-Shipping.exe
418 | false
419 | $PROJECT_DIR/Binaries/Win32
420 | UE4
421 | Shipping
422 | ProjectExplorer.CustomExecutableRunConfiguration
423 | 3768
424 | false
425 | true
426 | false
427 | false
428 | true
429 |
430 |
431 |
432 | false
433 | false
434 | false
435 | false
436 | true
437 | 0.01
438 | 10
439 | true
440 | 1
441 | 25
442 |
443 | 1
444 | true
445 | false
446 | true
447 | valgrind
448 |
449 | 0
450 | 1
451 | 2
452 | 3
453 | 4
454 | 5
455 | 6
456 | 7
457 | 8
458 | 9
459 | 10
460 | 11
461 | 12
462 | 13
463 | 14
464 |
465 | 2
466 |
467 | "$UPROJ_FILE" -debug
468 | $UNREAL_PATH/Engine/Binaries/Win64/UE4Editor.exe
469 | false
470 | $PROJECT_DIR/Binaries/Win64
471 | UE4
472 | Debug Game Editor
473 | ProjectExplorer.CustomExecutableRunConfiguration
474 | 3768
475 | false
476 | true
477 | false
478 | false
479 | true
480 |
481 |
482 |
483 | false
484 | false
485 | false
486 | false
487 | true
488 | 0.01
489 | 10
490 | true
491 | 1
492 | 25
493 |
494 | 1
495 | true
496 | false
497 | true
498 | valgrind
499 |
500 | 0
501 | 1
502 | 2
503 | 3
504 | 4
505 | 5
506 | 6
507 | 7
508 | 8
509 | 9
510 | 10
511 | 11
512 | 12
513 | 13
514 | 14
515 |
516 | 2
517 |
518 | "$UPROJ_FILE"
519 | $UNREAL_PATH/Engine/Binaries/Win64/UE4Editor.exe
520 | false
521 | $PROJECT_DIR/Binaries/Win64
522 | UE4
523 | Development Editor
524 | ProjectExplorer.CustomExecutableRunConfiguration
525 | 3768
526 | false
527 | true
528 | false
529 | false
530 | true
531 |
532 | 5
533 |
534 |
535 |
536 | ProjectExplorer.Project.TargetCount
537 | 1
538 |
539 |
540 | ProjectExplorer.Project.Updater.FileVersion
541 | 14
542 |
543 |
544 | Version
545 | 14
546 |
547 |
548 |
--------------------------------------------------------------------------------
/GenerateQTProject/src/Configuration.cs:
--------------------------------------------------------------------------------
1 | /**
2 | * Unreal Qt Project Generator
3 | *
4 | * Configuration.cs
5 | *
6 | * Copyright (c) 2016 N. Baumann
7 | *
8 | * This software is licensed under MIT license
9 | *
10 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
11 | * and associated documentation files (the "Software"), to deal in the Software without restriction,
12 | * including without limitation the rights to use, copy, modify, merge,
13 | * publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
14 | * to whom the Software is furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
21 | * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | using System;
25 | using System.IO;
26 | using System.Text.RegularExpressions;
27 |
28 | namespace GenerateQTProject
29 | {
30 | public struct ConfigurationData
31 | {
32 | // this information has to be copied over from a .pro.user file on this computer once
33 | public string qtCreatorEnvironmentId;
34 | public string qtCreatorUnrealConfigurationId;
35 | }
36 |
37 | public static class Configuration
38 | {
39 | public const string CONFIG_FILE_NAME = "config.ini";
40 | public static ConfigurationData data;
41 |
42 | // regex pattern for Qt environment and configuration ids
43 | const string ENV_ID_PATTERN = "^\\{[0-9a-f]{8}\\-[0-9a-f]{4}\\-[0-9a-f]{4}\\-[0-9a-f]{4}\\-[0-9a-f]{12}\\}$";
44 |
45 | ///
46 | /// Checks if a Qt id has a valid format
47 | ///
48 | /// Qt id (some combined hexadecimal values)
49 | /// True if format is valid
50 | public static bool IsValidQtId(string id)
51 | {
52 | return Regex.Match(id, ENV_ID_PATTERN).Success;
53 | }
54 |
55 | ///
56 | /// Checks if configuration file is present
57 | ///
58 | /// True if configuration file exists
59 | public static bool HasConfigurationFile()
60 | {
61 | return File.Exists(FileActions.PROGRAM_DIR + CONFIG_FILE_NAME);
62 | }
63 |
64 | ///
65 | /// Load data from configuration file
66 | /// Atm the function only loads 2 values (because there are only two settings), but it could easily be extended to detect more settings.
67 | ///
68 | /// True if valid configuration was read and stored in data field
69 | public static bool LoadConfiguration()
70 | {
71 | data = new ConfigurationData();
72 |
73 | if (!File.Exists(FileActions.PROGRAM_DIR + CONFIG_FILE_NAME))
74 | {
75 | return false;
76 | }
77 |
78 | string[] config = File.ReadAllLines(FileActions.PROGRAM_DIR + CONFIG_FILE_NAME);
79 |
80 | string line = "";
81 |
82 | for (int i = 0; i < config.Length; ++i)
83 | {
84 | line = config[i];
85 |
86 | // ignore comments
87 | if (line.Contains("\'"))
88 | line = line.Remove(line.IndexOf('\''));
89 |
90 | line = line.Trim();
91 |
92 | string[] key_val_pair = line.Split('=');
93 |
94 | // skip line if no key value pair was found
95 | if (line == "" || key_val_pair.Length != 2)
96 | continue;
97 |
98 | key_val_pair[0] = key_val_pair[0].Trim();
99 | key_val_pair[1] = key_val_pair[1].Trim();
100 |
101 | switch (key_val_pair[0])
102 | {
103 | case "qt_environment_id":
104 | data.qtCreatorEnvironmentId = key_val_pair[1];
105 | if (!Regex.Match(data.qtCreatorEnvironmentId, ENV_ID_PATTERN).Success)
106 | {
107 | Console.WriteLine("CONFIG ERROR: Invalid QtCreator environment ID set.");
108 | return false;
109 | }
110 | break;
111 | case "unreal_project_configuration_id":
112 | data.qtCreatorUnrealConfigurationId = key_val_pair[1];
113 | if (!Regex.Match(data.qtCreatorUnrealConfigurationId, ENV_ID_PATTERN).Success)
114 | {
115 | Console.WriteLine("CONFIG ERROR: Invalid QtCreator configuration ID set.");
116 | return false;
117 | }
118 | break;
119 | default:
120 | Console.WriteLine("CONFIG ERROR: Configuration parse error.\n");
121 | return false;
122 | }
123 | }
124 |
125 | if (data.qtCreatorEnvironmentId == "" || data.qtCreatorUnrealConfigurationId == "")
126 | return false;
127 |
128 | return true;
129 | }
130 |
131 | ///
132 | /// Writes the initial configuration file
133 | ///
134 | /// Data to write
135 | /// True if successful
136 | public static bool WriteWizardConfig(ConfigurationData data)
137 | {
138 | string file = "";
139 | file += "[General]\r\n\r\n";
140 | file += "' These values can be found in a .pro.user file of a project on this computer which uses (exclusively) your Unreal Engine build kit.\r\n";
141 | file += "qt_environment_id = " + data.qtCreatorEnvironmentId + "\r\n";
142 | file += "unreal_project_configuration_id = " + data.qtCreatorUnrealConfigurationId + "\r\n\r\n";
143 |
144 | try
145 | {
146 | File.WriteAllText(FileActions.PROGRAM_DIR + CONFIG_FILE_NAME, file);
147 | }
148 | catch
149 | {
150 | return false;
151 | }
152 |
153 | return true;
154 | }
155 | }
156 |
157 |
158 | }
159 |
--------------------------------------------------------------------------------
/GenerateQTProject/src/ConsoleActions.cs:
--------------------------------------------------------------------------------
1 | /**
2 | * Unreal Qt Project Generator
3 | *
4 | * ConsoleActions.cs
5 | *
6 | * Copyright (c) 2016 N. Baumann
7 | *
8 | * This software is licensed under MIT license
9 | *
10 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
11 | * and associated documentation files (the "Software"), to deal in the Software without restriction,
12 | * including without limitation the rights to use, copy, modify, merge,
13 | * publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
14 | * to whom the Software is furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
21 | * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | using System;
25 | using System.IO;
26 | using System.Diagnostics;
27 | using System.Text.RegularExpressions;
28 |
29 | namespace GenerateQTProject
30 | {
31 | ///
32 | /// This class contains all methods related to console input and output
33 | ///
34 | class ConsoleActions
35 | {
36 | ///
37 | /// Asks for project directory, repeats until valid path is entered
38 | ///
39 | public static string InputProjectPath()
40 | {
41 | string projDir = "";
42 | Console.WriteLine("This small tool automates the process of generating a Qt project from an Unreal Engine 4 VS project.\n");
43 | Console.WriteLine("Before you procede make sure you have created an Unreal Engine build kit in QtCreator (and have completed debugger setup if you intend to debug with QtCreator)\n");
44 | Console.WriteLine("WARNING: The project folder inside the source folder and the .vcxproj file must use the same name as the .uproject file of your project. (Which is default)\n\n");
45 |
46 | bool isValid = false;
47 | do
48 | {
49 | Console.WriteLine("Please enter path to the directory where your .uproject file is located (drag and drop folder here):");
50 | projDir = Console.ReadLine();
51 |
52 | projDir = projDir.Replace("\"", "");
53 |
54 | if (!projDir.EndsWith("\\"))
55 | projDir += "\\";
56 |
57 | if (Directory.Exists(projDir))
58 | {
59 | foreach (string file in Directory.GetFiles(projDir))
60 | {
61 | if (file.EndsWith(".uproject"))
62 | {
63 | isValid = true;
64 | break;
65 | }
66 | }
67 | }
68 |
69 | if (!isValid)
70 | Console.WriteLine("Invalid directory path\n");
71 |
72 | } while (!isValid);
73 |
74 | return projDir;
75 | }
76 |
77 | ///
78 | /// Run a small wizard which is able to autodetect the Qt Creator ids
79 | ///
80 | public static void StartConfigWizard()
81 | {
82 | PrintHeader();
83 | ConfigurationData newConfig = new ConfigurationData();
84 |
85 | Console.WriteLine("It seems that you run this program for the first time as no configuration file was found.\n");
86 | Console.WriteLine("This program now needs to detect your Qt environment id and the id of your Unreal Engine build kit.\n\n");
87 |
88 | Console.WriteLine("When you now press enter, an empty project will be opened in QtCreator.");
89 | Console.WriteLine("The only thing you have to do is:\n\n 1. Select your Unreal Engine build kit when asked by QtCreator\n 2. Hit the configure project button\n 3. Close QtCreator.\n");
90 | Console.WriteLine("Please make sure that QtCreator is not currently running, then press enter to proceed...");
91 | Console.ReadLine();
92 |
93 | File.WriteAllText(FileActions.PROGRAM_DIR + "temp.pro", "");
94 | Process qtCreatorProcess = Process.Start(FileActions.PROGRAM_DIR + "temp.pro");
95 | Console.WriteLine("QtCreator launched, waiting for user interaction...");
96 | qtCreatorProcess.WaitForExit();
97 | Console.WriteLine("QtCreator closed...\n");
98 |
99 | PrintHeader();
100 |
101 | if (!File.Exists(FileActions.PROGRAM_DIR + "temp.pro.user"))
102 | {
103 | Errors.ErrorExit(ErrorCode.QT_PRO_USERFILE_MISSING);
104 | }
105 |
106 | string userContent = "";
107 | try
108 | {
109 | userContent = File.ReadAllText(FileActions.PROGRAM_DIR + "temp.pro.user");
110 | }
111 | catch
112 | {
113 | Errors.ErrorExit(ErrorCode.QT_PRO_USERFILE_READ_FAILED);
114 | }
115 |
116 | try
117 | {
118 | File.Delete(FileActions.PROGRAM_DIR + "temp.pro.user");
119 | File.Delete(FileActions.PROGRAM_DIR + "temp.pro");
120 | }
121 | catch
122 | {
123 | Console.WriteLine("\nERROR: Error while deleting temporary pro file.");
124 | }
125 |
126 | const string middle_env_id_pattern = "\\{[0-9a-f]{8}\\-[0-9a-f]{4}\\-[0-9a-f]{4}\\-[0-9a-f]{4}\\-[0-9a-f]{12}\\}";
127 |
128 | var envMatch = Regex.Match(userContent, "\\EnvironmentId\\[\\s]*\n[\\s]*\\(?" + middle_env_id_pattern + ")");
129 | if (envMatch.Success && Configuration.IsValidQtId(envMatch.Groups["id"].Value))
130 | {
131 | newConfig.qtCreatorEnvironmentId = envMatch.Groups["id"].Value;
132 | }
133 | else
134 | {
135 | Errors.ErrorExit(ErrorCode.ENVIRONMENT_ID_NOT_FOUND);
136 | }
137 |
138 | var confMatch = Regex.Match(userContent, "key=\"ProjectExplorer.ProjectConfiguration.Id\"\\>(?" + middle_env_id_pattern + ")");
139 | if (confMatch.Success && Configuration.IsValidQtId(confMatch.Groups["id"].Value))
140 | {
141 | newConfig.qtCreatorUnrealConfigurationId = confMatch.Groups["id"].Value;
142 | }
143 | else
144 | {
145 | Errors.ErrorExit(ErrorCode.CONFIGURATION_ID_NOT_FOUND);
146 | }
147 |
148 | if (!Configuration.WriteWizardConfig(newConfig))
149 | {
150 | Errors.ErrorExit(ErrorCode.CONFIGURATION_WRITE_FAILED);
151 | }
152 | }
153 |
154 | ///
155 | /// If this is the first run, display the disclaimer, if accepted this is stored in a file in the AppData folder
156 | ///
157 | public static void DisplayFirstRunDisclaimer()
158 | {
159 | string savePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\UnrealQtGenerator";
160 |
161 | if (!File.Exists(savePath + "\\vars.conf"))
162 | {
163 | Console.WriteLine("This Software is provided free of charge.\n");
164 | Console.WriteLine("THIS SOFTWARE IS PROVIDED BY ME “AS IS” AND ANY EXPRESS OR " +
165 | "IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY" +
166 | " AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL I" +
167 | " BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES " +
168 | "(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, " +
169 | "OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, " +
170 | "WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING " +
171 | "IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n");
172 | Console.WriteLine("This Software is UNOFFICIAL, I am neither affiliated with Epic Games nor with the Qt-Project.\n"
173 | + "\"Qt\" is a registered trademark of Digia Plc and/or its subsidiaries. \"Unreal\" is a registered trademark of Epic Games, Inc.\n");
174 |
175 | Console.Write(" - Press \"y\" to accept the disclaimer and to continue, or \"n\" to decline...");
176 | bool accepted = false;
177 | while (!accepted)
178 | {
179 | ConsoleKeyInfo k = Console.ReadKey();
180 | if (k.Key == ConsoleKey.Y)
181 | accepted = true;
182 | else if (k.Key == ConsoleKey.N)
183 | Environment.Exit(-1);
184 | }
185 |
186 | if (!Directory.Exists(savePath))
187 | Directory.CreateDirectory(savePath);
188 |
189 | try
190 | {
191 | File.WriteAllText(savePath + "\\vars.conf", "DisclaimerAccepted");
192 | }
193 | catch (Exception)
194 | {
195 | Console.WriteLine("ERROR: Disclaimer accepted state couldn't be stored.");
196 | }
197 |
198 | // clear disclaimer text
199 | Console.Clear();
200 | PrintHeader();
201 | }
202 | }
203 |
204 | ///
205 | /// Prints application header to console
206 | ///
207 | public static void PrintHeader()
208 | {
209 | Console.Clear();
210 | Console.WriteLine();
211 | Console.WriteLine("***********************************************");
212 | Console.WriteLine("****** Unreal Qt Project Generator v0.3 ******");
213 | Console.WriteLine("****** ©2015 AlphaN ******");
214 | Console.WriteLine("****** Special Thanks to Antares ******");
215 | Console.WriteLine("***********************************************");
216 | Console.WriteLine();
217 | }
218 | }
219 | }
220 |
--------------------------------------------------------------------------------
/GenerateQTProject/src/Errors.cs:
--------------------------------------------------------------------------------
1 | /**
2 | * Unreal Qt Project Generator
3 | *
4 | * Errors.cs
5 | *
6 | * Copyright (c) 2016 N. Baumann
7 | *
8 | * This software is licensed under MIT license
9 | *
10 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
11 | * and associated documentation files (the "Software"), to deal in the Software without restriction,
12 | * including without limitation the rights to use, copy, modify, merge,
13 | * publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
14 | * to whom the Software is furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
21 | * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | using System;
25 |
26 | namespace GenerateQTProject
27 | {
28 | /* Error codes */
29 | public enum ErrorCode
30 | {
31 | ENGINE_PATH_NOT_FOUND_IN_PROJECT_FILE,
32 | INVALID_ENGINE_PATH_FOUND,
33 | DEFINES_AND_INCLUDES_READ_FAILED,
34 | PROJECT_FILE_WRITE_FAILED,
35 | CODE_PROJECT_FILE_READ_FAILED,
36 | DEFINES_AND_INCLUDES_WRITE_FAILED,
37 | QT_PRO_USERFILE_WRITE_FAILED,
38 | QT_PRO_USERFILE_MISSING,
39 | QT_PRO_USERFILE_READ_FAILED,
40 | ENVIRONMENT_ID_NOT_FOUND,
41 | CONFIGURATION_ID_NOT_FOUND,
42 | CONFIGURATION_WRITE_FAILED,
43 | UPROJECT_NOT_FOUND,
44 | BUILD_PRESET_MISSING,
45 | CONFIG_OPEN_ERROR,
46 | BUILD_PRESET_READ_FAILED,
47 | SOURCE_PATH_NOT_FOUND
48 | };
49 |
50 | ///
51 | /// Contains all the different error messages.
52 | ///
53 | public static class Errors
54 | {
55 | ///
56 | /// Prints the error message which corresponds to the error code,
57 | /// waits for user to press enter and terminates program with given error code.
58 | ///
59 | /// Error code
60 | public static void ErrorExit(ErrorCode code)
61 | {
62 | Console.WriteLine("\nERROR: " + ErrorMsg[(int)code] + "\n");
63 | Console.WriteLine(" - Press Enter to quit application...");
64 | Console.ReadLine();
65 | Environment.Exit((int)code + 1);
66 | }
67 |
68 | /* ERROR MESSAGES*/
69 |
70 | private static string[] ErrorMsg =
71 | {
72 | "Unreal Engine path not found in vcxproj file.",
73 | "Invalid engine path found in vcxproj. Maybe you have no longer installed the Unreal Engine build with which you created this project?",
74 | "Defines or includes couldn't be retrieved from project file.",
75 | "Couldn't write project file.",
76 | "The project file couldn't be read.",
77 | "Couldn't write defines and include files.",
78 | "Couldn't write .pro.user file.",
79 | "No .pro.user file was generated, cannot proceede (you can also edit the configuration file manually).",
80 | "Error while reading .pro.user file.",
81 | "Error while reading environment id from user file.",
82 | "Error while reading configuration id from user file.",
83 | "Error while writing configuration file.",
84 | "The .uproject file was not found.",
85 | "qtBuildPreset.xml (has to be in same folder as this .exe) file is missing.",
86 | "An error occurred while trying to open the configuration file.",
87 | "Error while reading qtBuildPreset.xml.",
88 | "Source folder not found!"
89 | };
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/GenerateQTProject/src/FileActions.cs:
--------------------------------------------------------------------------------
1 | /**
2 | * Unreal Qt Project Generator
3 | *
4 | * FileActions.cs
5 | *
6 | * Copyright (c) 2016 N. Baumann
7 | *
8 | * This software is licensed under MIT license
9 | *
10 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
11 | * and associated documentation files (the "Software"), to deal in the Software without restriction,
12 | * including without limitation the rights to use, copy, modify, merge,
13 | * publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
14 | * to whom the Software is furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
21 | * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | using System;
25 | using System.Collections.Generic;
26 | using System.IO;
27 |
28 | namespace GenerateQTProject
29 | {
30 | ///
31 | /// IO methods (file search etc.)
32 | ///
33 | class FileActions
34 | {
35 | ///
36 | /// Directory where the uProGen executable is located.
37 | ///
38 | public static string PROGRAM_DIR { get; } = AppDomain.CurrentDomain.BaseDirectory;
39 |
40 | ///
41 | /// Opens configuration file in default text editor.
42 | ///
43 | public static void OpenConfigFile()
44 | {
45 | try
46 | {
47 | System.Diagnostics.Process.Start(PROGRAM_DIR + Configuration.CONFIG_FILE_NAME);
48 | }
49 | catch
50 | {
51 | Errors.ErrorExit(ErrorCode.CONFIG_OPEN_ERROR);
52 | }
53 | }
54 |
55 | ///
56 | /// Extract project name from .uproject filename
57 | ///
58 | /// Directory which contains sln and uproject file
59 | /// Project Name
60 | public static string ExtractProjectName(string projectDir)
61 | {
62 | string projectName = "";
63 | foreach (string file in Directory.GetFiles(projectDir))
64 | {
65 | if (file.EndsWith(".uproject")) // uproject file found
66 | {
67 | projectName = file.Substring(file.LastIndexOf('\\') + 1).Replace(".uproject", "");
68 | break;
69 | }
70 | }
71 |
72 | if (projectName == "")
73 | {
74 | Errors.ErrorExit(ErrorCode.UPROJECT_NOT_FOUND);
75 | }
76 |
77 | return projectName;
78 | }
79 |
80 | ///
81 | /// Scan working directory for .uproject file
82 | ///
83 | /// Working directory if project file is found, empty string otherwise
84 | public static string LookForProjectInWD()
85 | {
86 | foreach (string file in Directory.GetFiles(Directory.GetCurrentDirectory()))
87 | {
88 | if (file.EndsWith(".uproject"))
89 | return Directory.GetCurrentDirectory();
90 | }
91 |
92 | return "";
93 | }
94 |
95 | ///
96 | /// Terminate program if qtBuildPreset.xml not present
97 | ///
98 | public static void CheckIfPresetFilePresent()
99 | {
100 | if (!File.Exists(PROGRAM_DIR + "qtBuildPreset.xml"))
101 | Errors.ErrorExit(ErrorCode.BUILD_PRESET_MISSING);
102 | }
103 |
104 | ///
105 | /// Recursive method to scan source directory for source and header files
106 | ///
107 | /// List to store source files
108 | /// List to store header files
109 | /// Directory to scan
110 | /// Name of your UE project
111 | public static void ScanDirectoryForFiles(List sourceFiles, List headerFiles, string scanDirectory, string projectName)
112 | {
113 | if (!Directory.Exists(scanDirectory)) // error
114 | {
115 | Console.WriteLine("Directory \"" + scanDirectory + "\" not found.");
116 | return;
117 | }
118 |
119 | // Recursive search
120 | foreach (string dir in Directory.GetDirectories(scanDirectory))
121 | {
122 | ScanDirectoryForFiles(sourceFiles, headerFiles, dir, projectName);
123 | }
124 |
125 | // Scan current directory
126 | foreach (string sfile in Directory.GetFiles(scanDirectory))
127 | {
128 | if (sfile.EndsWith(".cpp"))
129 | sourceFiles.Add("../../" + sfile.Substring(sfile.LastIndexOf("\\Source\\" + projectName)+1).Replace("\\", "/"));
130 | else if (sfile.EndsWith(".h") || sfile.EndsWith(".hpp"))
131 | headerFiles.Add("../../" + sfile.Substring(sfile.LastIndexOf("\\Source\\" + projectName)+1).Replace("\\", "/"));
132 | }
133 | }
134 | }
135 | }
136 |
--------------------------------------------------------------------------------
/GenerateQTProject/src/Generator.cs:
--------------------------------------------------------------------------------
1 | /**
2 | * Unreal Qt Project Generator
3 | *
4 | * Generator.cs
5 | *
6 | * Copyright (c) 2016 N. Baumann
7 | *
8 | * This software is licensed under MIT license
9 | *
10 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
11 | * and associated documentation files (the "Software"), to deal in the Software without restriction,
12 | * including without limitation the rights to use, copy, modify, merge,
13 | * publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
14 | * to whom the Software is furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
21 | * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | using System;
25 | using System.Collections.Generic;
26 | using System.IO;
27 |
28 | namespace GenerateQTProject
29 | {
30 | ///
31 | /// Allows generation of .pro and defines\includes.pri file as well as injection of build/launch targets in proj.pro.user file
32 | ///
33 | class Generator
34 | {
35 | private const string ENTER_QUIT_MSG = " - Press Enter to quit...";
36 |
37 | ///
38 | /// Generates the Qt project file
39 | ///
40 | /// Reference to project parser
41 | /// success
42 | public static void GenerateProFile(ProjectFileParser projData)
43 | {
44 | /* These lists will store all source and header files
45 | which are found in the source directory of your project */
46 | List SourceFilePaths;
47 | List HeaderFilePaths;
48 |
49 | ConsoleActions.PrintHeader();
50 |
51 | Console.WriteLine("Generating .pro file...");
52 | SourceFilePaths = new List();
53 | HeaderFilePaths = new List();
54 |
55 | string sourcePath = projData.projectPath + "Source";
56 |
57 | if (!Directory.Exists(sourcePath))
58 | Errors.ErrorExit(ErrorCode.SOURCE_PATH_NOT_FOUND);
59 |
60 | FileActions.ScanDirectoryForFiles(SourceFilePaths, HeaderFilePaths, sourcePath, projData.projectName);
61 |
62 | // Add some useful configuration options and include all UE defines
63 | string qtProFile = "TEMPLATE = app\n" +
64 | "CONFIG += console\n" +
65 | "CONFIG -= app_bundle\n" +
66 | "CONFIG -= qt\n" +
67 | "CONFIG += c++11\n" +
68 | " \n" +
69 | "# All the defines of your project will go in this file\n" +
70 | "# You can put this file on your repository, but you will need to remake it once you upgrade the engine.\n" +
71 | "include(defines.pri)\n" +
72 | " \n" +
73 | "# Qt Creator will automatically add headers and source files if you add them via Qt Creator.\n" +
74 | "HEADERS += ";
75 |
76 | // Add all found header files
77 | foreach (string headerFile in HeaderFilePaths)
78 | {
79 | qtProFile += headerFile + " \\\n\t";
80 | }
81 |
82 | qtProFile += "\nSOURCES += ";
83 |
84 | // Add all found source files
85 | foreach (string sourceFile in SourceFilePaths)
86 | {
87 | qtProFile += sourceFile + " \\\n\t";
88 | }
89 |
90 | // Add UE includes
91 | qtProFile = qtProFile + "\n# All your generated includes will go in this file\n" +
92 | "# You can not put this on the repository as this contains hard coded paths\n" +
93 | "# and is dependent on your windows install and engine version\n" +
94 | "include(includes.pri)";
95 |
96 | // Add additional files to project
97 | List distFiles = new List();
98 |
99 | // build.cs
100 | if (File.Exists(sourcePath + "\\" + projData.projectName + "\\" + projData.projectName + ".Build.cs"))
101 | distFiles.Add("../../Source/" + projData.projectName + "/" + projData.projectName + ".Build.cs");
102 |
103 | // target.cs files
104 | string[] files = Directory.GetFiles(projData.projectPath + "\\Source\\");
105 | foreach (string file in files)
106 | {
107 | if (file.EndsWith(".Target.cs"))
108 | distFiles.Add("../../Source/" + Path.GetFileName(file));
109 | }
110 |
111 | if (distFiles.Count > 0)
112 | {
113 | qtProFile += "\n\nDISTFILES += ";
114 | foreach (string distFile in distFiles)
115 | {
116 | qtProFile += distFile + " \\\n\t";
117 | }
118 | }
119 |
120 | try
121 | {
122 | File.WriteAllText(projData.projectPath + "Intermediate\\ProjectFiles\\" + projData.projectName + ".pro", qtProFile);
123 | }
124 | catch
125 | {
126 | Errors.ErrorExit(ErrorCode.PROJECT_FILE_WRITE_FAILED);
127 | }
128 | }
129 |
130 | ///
131 | /// Generates defines.pri and includes.pri files (with data from YourProject.vcxproj)
132 | ///
133 | /// Reference to project parser
134 | /// success
135 | public static void GenerateDefinesAndInclude(ProjectFileParser projData)
136 | {
137 | Console.WriteLine("Generating defines.pri and includes.pri...\n");
138 | // Write files
139 | try
140 | {
141 | File.WriteAllText(projData.projectPath + "Intermediate\\ProjectFiles\\defines.pri", projData.GetEngineDefines());
142 | File.WriteAllText(projData.projectPath + "Intermediate\\ProjectFiles\\includes.pri", projData.GetEngineIncludes());
143 | }
144 | catch
145 | {
146 | Errors.ErrorExit(ErrorCode.DEFINES_AND_INCLUDES_WRITE_FAILED);
147 | }
148 | }
149 |
150 |
151 | ///
152 | /// This method will generate and apply a modified qt.pro.user file, which contains build presets for UE4
153 | ///
154 | /// Reference to project parser
155 | /// success
156 | public static void GenerateQtBuildPreset(ProjectFileParser projData)
157 | {
158 | // Helper variable which stores the retrieved Unreal Engine Version (currently not needed)
159 | //string UnrealVersion;
160 |
161 | // These variables are used to replace parts of the qtBuildPreset.xml file to match your project and Unreal Engine installation
162 | string UPROJ_FILE,
163 | UNREAL_PATH,
164 | PROJECT_DIR,
165 | PROJECT_NAME,
166 | QT_ENV_ID,
167 | QT_CONF_ID;
168 |
169 | QT_ENV_ID = Configuration.data.qtCreatorEnvironmentId;
170 | QT_CONF_ID = Configuration.data.qtCreatorUnrealConfigurationId;
171 |
172 | // Set project name
173 | PROJECT_NAME = projData.projectName;
174 |
175 | // Set project directory
176 | PROJECT_DIR = projData.projectPath;
177 |
178 | // Set project file path
179 | UPROJ_FILE = projData.uprojectFilePath;
180 |
181 | // set engine path
182 | UNREAL_PATH = projData.GetEnginePath();
183 |
184 | // Load user file preset
185 | String qtBuildPreset = "";
186 | try
187 | {
188 | qtBuildPreset = File.ReadAllText(FileActions.PROGRAM_DIR + "qtBuildPreset.xml");
189 | }
190 | catch
191 | {
192 | Errors.ErrorExit(ErrorCode.BUILD_PRESET_READ_FAILED);
193 | }
194 |
195 |
196 | // Replace preset variables with actual values
197 | qtBuildPreset = qtBuildPreset.Replace("$PROJECT_NAME", PROJECT_NAME);
198 | qtBuildPreset = qtBuildPreset.Replace("$PROJECT_DIR", PROJECT_DIR);
199 | qtBuildPreset = qtBuildPreset.Replace("$UPROJ_FILE", UPROJ_FILE);
200 | qtBuildPreset = qtBuildPreset.Replace("$UNREAL_PATH", UNREAL_PATH);
201 |
202 | qtBuildPreset = qtBuildPreset.Replace("$QT_ENV_ID", QT_ENV_ID);
203 | qtBuildPreset = qtBuildPreset.Replace("$QT_CONF_ID", QT_CONF_ID);
204 |
205 | // remove -rocket for custom engine builds
206 | if (!projData.IsLauncherBuild())
207 | {
208 | qtBuildPreset = qtBuildPreset.Replace("-rocket", "");
209 | }
210 |
211 | // Write new user file
212 | try
213 | {
214 | File.WriteAllText(projData.projectPath + "Intermediate\\ProjectFiles\\" + projData.projectName + ".pro.user", qtBuildPreset);
215 | }
216 | catch
217 | {
218 | Errors.ErrorExit(ErrorCode.QT_PRO_USERFILE_WRITE_FAILED);
219 | }
220 |
221 | Console.WriteLine("User file written successfully.");
222 | }
223 | }
224 | }
225 |
--------------------------------------------------------------------------------
/GenerateQTProject/src/Program.cs:
--------------------------------------------------------------------------------
1 | /**
2 | * Unreal Qt Project Generator
3 | *
4 | * Program.cs
5 | *
6 | * Copyright (c) 2016 N. Baumann
7 | *
8 | * This software is licensed under MIT license
9 | *
10 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
11 | * and associated documentation files (the "Software"), to deal in the Software without restriction,
12 | * including without limitation the rights to use, copy, modify, merge,
13 | * publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
14 | * to whom the Software is furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
21 | * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | using System;
25 | using System.Diagnostics;
26 |
27 | namespace GenerateQTProject
28 | {
29 | class Program
30 | {
31 | static void Main(string[] args)
32 | {
33 | // program cannot run without qtBuildPreset.xml
34 | FileActions.CheckIfPresetFilePresent();
35 |
36 | ConsoleActions.DisplayFirstRunDisclaimer();
37 |
38 | string projectDir = "";
39 | string projectName = "";
40 |
41 | if (!Configuration.HasConfigurationFile())
42 | {
43 | ConsoleActions.StartConfigWizard();
44 | ConsoleActions.PrintHeader();
45 | Console.WriteLine("Configuration file written successfully.\n");
46 | Console.WriteLine("From now on you have two options to create project files:\n");
47 | Console.WriteLine("1. Run the tool from anywhere and enter the path to the project folder manually");
48 | Console.WriteLine("2. Run it from the command-line inside the project folder. (tool will detect everything from the working directory)");
49 | Console.WriteLine("\n\nIf you prefer the second option, I recommend adding the uProGen folder\nto the PATH variable.");
50 | Console.WriteLine("\n\n\t-Press Enter to quit...");
51 | Console.ReadLine();
52 | return;
53 | }
54 | else if (!Configuration.LoadConfiguration())
55 | {
56 | ConsoleActions.PrintHeader();
57 | Console.WriteLine("Invalid configuration found.\nThe configuration file will now open so you can fix the values.\nYou can also delete the file and rerun the tool (this will reinvoke the wizard).");
58 | Console.ReadLine();
59 | FileActions.OpenConfigFile();
60 | Environment.Exit(0);
61 | }
62 |
63 | // search working directory for project files
64 | projectDir = FileActions.LookForProjectInWD();
65 | projectDir += "\\";
66 |
67 | if (projectDir == "\\") // working directory isn't a project directory
68 | {
69 | ConsoleActions.PrintHeader();
70 |
71 | projectDir = ConsoleActions.InputProjectPath();
72 | Console.WriteLine();
73 | }
74 |
75 | projectName = FileActions.ExtractProjectName(projectDir);
76 |
77 | ProjectFileParser projectParser = new VCX_Parser(projectDir, projectName);
78 |
79 | Generator.GenerateProFile(projectParser);
80 |
81 | Generator.GenerateDefinesAndInclude(projectParser);
82 |
83 | Generator.GenerateQtBuildPreset(projectParser);
84 |
85 | Console.WriteLine("\nQt Project generation successful.\n");
86 | Console.WriteLine("Do you want to open your project now (y/n)?");
87 | string answer = Console.ReadLine();
88 | if (answer.ToLower() == "y" || answer.ToLower() == "yes")
89 | {
90 | // opens your newly generated project (if .pro is associated with QtCreator)
91 | Process.Start(projectDir + "\\Intermediate\\ProjectFiles\\" + projectName + ".pro");
92 | }
93 | }
94 | }
95 | }
--------------------------------------------------------------------------------
/GenerateQTProject/src/ProjectFileParsers/ProjectFileParser.cs:
--------------------------------------------------------------------------------
1 | /**
2 | * Unreal Qt Project Generator
3 | *
4 | * ProjectFileParser.cs
5 | *
6 | * Copyright (c) 2016 N. Baumann
7 | *
8 | * This software is licensed under MIT license
9 | *
10 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
11 | * and associated documentation files (the "Software"), to deal in the Software without restriction,
12 | * including without limitation the rights to use, copy, modify, merge,
13 | * publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
14 | * to whom the Software is furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
21 | * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | using System.IO;
25 | using System.Text.RegularExpressions;
26 |
27 | namespace GenerateQTProject
28 | {
29 | ///
30 | /// This class provides an abstract interface to load defines, includes and engine path from a project file
31 | ///
32 | public abstract class ProjectFileParser
33 | {
34 | protected string projectFileContent;
35 |
36 | public string projectPath { get; private set; }
37 | public string projectName { get; private set; }
38 | public string uprojectFilePath { get; private set; }
39 |
40 | ///
41 | /// Loads content of the code project file into projectFileContent
42 | ///
43 | /// Path to the project folder
44 | /// Name of .uproject file
45 | public ProjectFileParser(string projectPath, string projectName)
46 | {
47 | this.projectPath = projectPath;
48 | this.projectName = projectName;
49 |
50 | try
51 | {
52 | projectFileContent = LoadProjectFile(projectPath, projectName);
53 |
54 | uprojectFilePath = projectPath + projectName + ".uproject";
55 |
56 | if (!File.Exists(uprojectFilePath))
57 | Errors.ErrorExit(ErrorCode.UPROJECT_NOT_FOUND);
58 | }
59 | catch
60 | {
61 | Errors.ErrorExit(ErrorCode.CODE_PROJECT_FILE_READ_FAILED);
62 | }
63 | }
64 |
65 | ///
66 | /// Loads the project file content
67 | ///
68 | /// Path to the Unreal Engine project folder
69 | /// Name of the .uproject file
70 | /// project file content
71 | protected abstract string LoadProjectFile(string path, string projectName);
72 |
73 | ///
74 | /// Retrieve engine defines in QtCreator format
75 | ///
76 | /// Qt formatted defines list
77 | public string GetEngineDefines()
78 | {
79 | string defines = "";
80 | try
81 | {
82 | defines = ExtractEngineDefines();
83 | }
84 | catch
85 | {
86 | Errors.ErrorExit(ErrorCode.DEFINES_AND_INCLUDES_READ_FAILED);
87 | }
88 |
89 | return ConvertDefinesToQtFormat(defines);
90 | }
91 |
92 | ///
93 | /// Retrieve engine includes in QtCreator format
94 | ///
95 | /// Qt formatted includes list
96 | public string GetEngineIncludes()
97 | {
98 | string includes = "";
99 | try
100 | {
101 | includes = ExtractEngineIncludes();
102 | }
103 | catch
104 | {
105 | Errors.ErrorExit(ErrorCode.DEFINES_AND_INCLUDES_READ_FAILED);
106 | }
107 |
108 | return ConvertIncludesToQtFormat(includes);
109 | }
110 |
111 |
112 | ///
113 | /// Read engine defines from project file (can be implemented with Regex or String operations)
114 | ///
115 | /// Defines in original format
116 | protected abstract string ExtractEngineDefines();
117 |
118 | ///
119 | /// Converts defines to Qt format
120 | ///
121 | /// Defines in original format
122 | /// Defines in Qt format
123 | protected abstract string ConvertDefinesToQtFormat(string defines);
124 |
125 | ///
126 | /// Read engine includes from project file (can be implemented with Regex or String operations)
127 | ///
128 | /// Includes in original format
129 | protected abstract string ExtractEngineIncludes();
130 |
131 | ///
132 | /// Converts includes to Qt format
133 | ///
134 | /// Includes in original format
135 | /// Includes in Qt format
136 | protected abstract string ConvertIncludesToQtFormat(string includes);
137 |
138 | ///
139 | /// Retrieve engine path from project file
140 | ///
141 | ///
142 | public string GetEnginePath()
143 | {
144 | var match = Regex.Match(projectFileContent, GetUnrealPathRegexPattern());
145 |
146 | if (!match.Success || match.Groups["path"] == null)
147 | Errors.ErrorExit(ErrorCode.ENGINE_PATH_NOT_FOUND_IN_PROJECT_FILE);
148 |
149 | string path = match.Groups["path"].Value;
150 |
151 | if (!File.Exists(path + @"\Engine\Build\BatchFiles\build.bat"))
152 | Errors.ErrorExit(ErrorCode.INVALID_ENGINE_PATH_FOUND);
153 |
154 | path = path.Replace("\\", "/");
155 |
156 | return path;
157 | }
158 |
159 | ///
160 | /// Is the engine build which is associated with this project a launcher build?
161 | ///
162 | /// True if launcher build, false if git build
163 | public bool IsLauncherBuild()
164 | {
165 | return projectFileContent.Contains("-rocket");
166 | }
167 |
168 | ///
169 | /// Stores a regex which matches the Unreal Engine path in the project file.
170 | /// IMPORTANT: The part of the matching pattern which contains the actual string needs to be in the matching group "path"
171 | ///
172 | /// Unreal Engine path pattern
173 | protected abstract string GetUnrealPathRegexPattern();
174 | }
175 | }
176 |
--------------------------------------------------------------------------------
/GenerateQTProject/src/ProjectFileParsers/VCX_Parser.cs:
--------------------------------------------------------------------------------
1 | /**
2 | * Unreal Qt Project Generator
3 | *
4 | * VCX_Parser.cs
5 | *
6 | * Copyright (c) 2016 N. Baumann
7 | *
8 | * This software is licensed under MIT license
9 | *
10 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
11 | * and associated documentation files (the "Software"), to deal in the Software without restriction,
12 | * including without limitation the rights to use, copy, modify, merge,
13 | * publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
14 | * to whom the Software is furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
21 | * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | using System.IO;
25 |
26 | namespace GenerateQTProject
27 | {
28 | ///
29 | /// Implementation of ProjectFileParser for Visual Studio project files
30 | /// Error handling is done in base class
31 | ///
32 | public class VCX_Parser : ProjectFileParser
33 | {
34 | public VCX_Parser(string projectFile, string projectName) : base(projectFile, projectName) { }
35 |
36 | protected override string ConvertDefinesToQtFormat(string defines)
37 | {
38 | defines = "DEFINES += \"" + defines;
39 | defines = defines.Replace(";", "\"\nDEFINES += \"");
40 | defines = defines + "\"";
41 |
42 | return defines;
43 | }
44 |
45 | protected override string ConvertIncludesToQtFormat(string includes)
46 | {
47 | includes = "INCLUDEPATH += \"" + includes;
48 | includes = includes.Replace(";", "\"\nINCLUDEPATH += \"");
49 | includes = includes + "\"";
50 |
51 | return includes;
52 | }
53 |
54 | protected override string ExtractEngineDefines()
55 | {
56 | string definesString = projectFileContent;
57 | definesString = definesString.Substring(definesString.IndexOf("$(NMakePreprocessorDefinitions);") + "$(NMakePreprocessorDefinitions);".Length);
58 | definesString = definesString.Remove(definesString.LastIndexOf(""));
59 |
60 | return definesString;
61 | }
62 |
63 | protected override string ExtractEngineIncludes()
64 | {
65 | string includesString = projectFileContent;
66 | includesString = includesString.Substring(includesString.IndexOf("$(NMakeIncludeSearchPath);") + "$(NMakeIncludeSearchPath);".Length);
67 | includesString = includesString.Remove(includesString.LastIndexOf(""));
68 |
69 | return includesString;
70 | }
71 |
72 | protected override string GetUnrealPathRegexPattern()
73 | {
74 | return "\\\\\"?(?.*)\\\\Engine\\\\Build\\\\BatchFiles\\\\Build.bat";
75 | }
76 |
77 | protected override string LoadProjectFile(string path, string projectName)
78 | {
79 | return File.ReadAllText(path + "Intermediate\\ProjectFiles\\" + projectName + ".vcxproj");
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 NAlphaDev
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Unreal Qt project generator (uProGen)
2 | Overview
3 | This small console utility generates QtCreator (qmake) projects for Unreal Engine 4 game development.
4 | It should work with any version of Unreal Engine 4.
5 |
6 | The tool can generate .pro files with:
7 |
8 | - Configuration for Unreal Engine development (C++11 support, no Qt)
9 | - All your current source and header files included
10 | - All Unreal Engine defines and includes added
11 | - 5 different build and launch targets (the same which are included in the Visual Studio project: Debug game, Development Editor, Shipping, etc...)
12 | - Additional Cooking target (allows to cook content for standalone builds directly from within QtCreator)
13 |
14 |
15 | Usage information
16 | Before you can use the tool you should configure your QtCreator installation for Unreal Engine development.
17 | Just follow the tutorial in my post: https://forums.unrealengine.com/development-discussion/c-gameplay-programming/30348-tool-tut-win-unreal-qt-creator-project-generator-v0-3.
18 |
19 | Installation:
20 |
21 | - Download the latest version from https://github.com/nibau/Unreal-Qt-project-generator/releases/latest
22 | - Extract the contents of the zip file to your preferred location
23 | - First make sure that .pro files are associated with QtCreator, then execute uProGen for the initial configuration
24 | - (Optional) Add the uProGen folder to your PATH variable, so you can launch uProGen from any location
25 |
26 |
27 | Usage:
28 |
29 | - Open a cmd window and navigate to your project folder (where .uproject file is located)
30 | - Run uProGen (the resulting .pro file is stored in the Intermediate\ProjectFiles subdirectory)
31 |
32 |
33 | Additional information
34 |
35 | Unreal Engine projects can only be debugged with CDB on Windows (GDB not supported).
36 |
37 | Since QtCreator 4.7, [Clang code model](https://blog.qt.io/blog/2018/06/05/qt-creators-clang-code-model/) is enabled by default. If you experience slow or unreliable auto-completion with UE projects, I recommend switching to the built-in code model by disabling "ClangCodeModel" under Help -> About Plugins -> C++.
38 |
39 | Important: I have tested the tool on my computers with Windows 8.1 64bit, Qt 5.4/5.5/5.7, QtCreator 3.3.0/3.5.0/4.1.0 and Unreal Engine 4.4/4.5/4.8/4.9/4.13.
40 |
41 | How to build
42 | Just open the .sln file with Visual Studio 2013/2015 and hit build (.NET Framework 4.0 required, no other dependencies).
43 | The qtBuildPreset.xml file needs to be in the same folder as the executable when you want to run the tool.
44 |
--------------------------------------------------------------------------------