Skip to content

Commit bf52419

Browse files
committed
Added a -d/--debug option for wrapping the Qt debug libraries.
Signed-off-by: Dimitar Dobrev <[email protected]>
1 parent f105b06 commit bf52419

File tree

2 files changed

+28
-12
lines changed

2 files changed

+28
-12
lines changed

QtSharp.CLI/Program.cs

+27-11
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,15 @@ public static int Main(string[] args)
2424
if (!File.Exists(qmake))
2525
{
2626
Console.WriteLine("The specified qmake does not exist.");
27-
return -1;
27+
return 1;
2828
}
2929
string make = args[1];
3030
if (!File.Exists(make))
3131
{
3232
Console.WriteLine("The specified make does not exist.");
33-
return -1;
33+
return 1;
3434
}
35+
var debug = args.Length > 2 && (args[2] == "d" || args[2] == "debug");
3536

3637
ConsoleLogger logredirect = new ConsoleLogger();
3738
logredirect.CreateLogDirectory();
@@ -45,30 +46,30 @@ public static int Main(string[] args)
4546
if (!string.IsNullOrEmpty(error))
4647
{
4748
Console.WriteLine(error);
48-
return -1;
49+
return 1;
4950
}
5051
DirectoryInfo libsInfo = new DirectoryInfo(libs);
5152
if (!libsInfo.Exists)
5253
{
5354
Console.WriteLine(
5455
"The directory \"{0}\" that qmake returned as the lib direcory of the Qt installation, does not exist.",
5556
libsInfo.Name);
56-
return -1;
57+
return 1;
5758
}
58-
ICollection<string> libFiles = GetLibFiles(libsInfo);
59+
ICollection<string> libFiles = GetLibFiles(libsInfo, debug);
5960
string headers = ProcessHelper.Run(qmake, "-query QT_INSTALL_HEADERS", out error);
6061
if (!string.IsNullOrEmpty(error))
6162
{
6263
Console.WriteLine(error);
63-
return -1;
64+
return 1;
6465
}
6566
DirectoryInfo headersInfo = new DirectoryInfo(headers);
6667
if (!headersInfo.Exists)
6768
{
6869
Console.WriteLine(
6970
"The directory \"{0}\" that qmake returned as the header direcory of the Qt installation, does not exist.",
7071
headersInfo.Name);
71-
return -1;
72+
return 1;
7273
}
7374
string docs = ProcessHelper.Run(qmake, "-query QT_INSTALL_DOCS", out error);
7475
string emptyFile = Environment.OSVersion.Platform == PlatformID.Win32NT ? "NUL" : "/dev/null";
@@ -95,6 +96,13 @@ public static int Main(string[] args)
9596
}
9697
}
9798
var modules = new List<string> { "Qt5Core", "Qt5Gui", "Qt5Widgets", "Qt5Xml", "Qt5Designer" };
99+
if (debug)
100+
{
101+
for (var i = 0; i < modules.Count; i++)
102+
{
103+
modules[i] += "d";
104+
}
105+
}
98106
libFiles = libFiles.TopologicalSort(l => dependencies.ContainsKey(l) ? dependencies[l] : Enumerable.Empty<string>());
99107
var wrappedModules = new List<KeyValuePair<string, string>>(modules.Count);
100108
var astContexts = new List<ASTContext>(libFiles.Count);
@@ -130,7 +138,7 @@ public static int Main(string[] args)
130138
if (wrappedModules.Count == 0)
131139
{
132140
Console.WriteLine("Generation failed.");
133-
return 0;
141+
return 1;
134142
}
135143

136144
var qtSharpZip = "QtSharp.zip";
@@ -156,14 +164,22 @@ public static int Main(string[] args)
156164
return 0;
157165
}
158166

159-
private static IList<string> GetLibFiles(DirectoryInfo libsInfo)
167+
private static IList<string> GetLibFiles(DirectoryInfo libsInfo, bool debug)
160168
{
161169
List<string> modules = (from file in libsInfo.EnumerateFiles()
162170
where Regex.IsMatch(file.Name, @"^Qt\d?\w+\.\w+$")
163171
select file.Name).ToList();
164-
for (int i = modules.Count - 1; i >= 0; i--)
172+
for (var i = modules.Count - 1; i >= 0; i--)
165173
{
166-
modules.Remove(Path.GetFileNameWithoutExtension(modules[i]) + "d" + Path.GetExtension(modules[i]));
174+
var module = Path.GetFileNameWithoutExtension(modules[i]);
175+
if (debug && module != null && !module.EndsWith("d"))
176+
{
177+
modules.Remove(module + Path.GetExtension(modules[i]));
178+
}
179+
else
180+
{
181+
modules.Remove(module + "d" + Path.GetExtension(modules[i]));
182+
}
167183
}
168184
return modules;
169185
}

QtSharp/QtSharp.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public QtSharp(QtModuleInfo qtModuleInfo, List<ASTContext> dependencies)
1919
this.dependencies = dependencies;
2020
this.qmake = qtModuleInfo.Qmake;
2121
this.includePath = qtModuleInfo.IncludePath.Replace('/', Path.DirectorySeparatorChar);
22-
this.module = Regex.Match(qtModuleInfo.Library, @"Qt\d?(?<module>\w+)\.\w+$").Groups["module"].Value;
22+
this.module = Regex.Match(qtModuleInfo.Library, @"Qt\d?(?<module>\w+?)d?\.\w+$").Groups["module"].Value;
2323
this.libraryPath = qtModuleInfo.LibraryPath.Replace('/', Path.DirectorySeparatorChar);
2424
this.library = qtModuleInfo.Library;
2525
this.target = qtModuleInfo.Target;

0 commit comments

Comments
 (0)