Skip to content

Commit 829e3a5

Browse files
committed
Updated to the latest C++# in order to reduce the code for compiling inlines.
Signed-off-by: Dimitar Dobrev <[email protected]>
1 parent 8836d7a commit 829e3a5

18 files changed

+253
-413
lines changed

QtSharp.CLI/Program.cs

+14-32
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Reflection;
88
using System.Text.RegularExpressions;
99
using CppSharp;
10+
using CppSharp.Utils;
1011

1112
namespace QtSharp.CLI
1213
{
@@ -88,18 +89,19 @@ static bool QueryQt(QtInfo qt, bool debug)
8889
path = Path.GetDirectoryName(qt.Make) + Path.PathSeparator + path;
8990
Environment.SetEnvironmentVariable("Path", path, EnvironmentVariableTarget.Process);
9091

91-
string error;
92-
qt.Bins = ProcessHelper.Run(qt.QMake, "-query QT_INSTALL_BINS", out error);
93-
if (!string.IsNullOrEmpty(error))
92+
int error;
93+
string errorMessage;
94+
qt.Bins = ProcessHelper.Run(qt.QMake, "-query QT_INSTALL_BINS", out error, out errorMessage);
95+
if (!string.IsNullOrEmpty(errorMessage))
9496
{
95-
Console.WriteLine(error);
97+
Console.WriteLine(errorMessage);
9698
return false;
9799
}
98100

99-
qt.Libs = ProcessHelper.Run(qt.QMake, "-query QT_INSTALL_LIBS", out error);
100-
if (!string.IsNullOrEmpty(error))
101+
qt.Libs = ProcessHelper.Run(qt.QMake, "-query QT_INSTALL_LIBS", out error, out errorMessage);
102+
if (!string.IsNullOrEmpty(errorMessage))
101103
{
102-
Console.WriteLine(error);
104+
Console.WriteLine(errorMessage);
103105
return false;
104106
}
105107

@@ -112,10 +114,10 @@ static bool QueryQt(QtInfo qt, bool debug)
112114
return false;
113115
}
114116
qt.LibFiles = GetLibFiles(libsInfo, debug);
115-
qt.Headers = ProcessHelper.Run(qt.QMake, "-query QT_INSTALL_HEADERS", out error);
116-
if (!string.IsNullOrEmpty(error))
117+
qt.Headers = ProcessHelper.Run(qt.QMake, "-query QT_INSTALL_HEADERS", out error, out errorMessage);
118+
if (!string.IsNullOrEmpty(errorMessage))
117119
{
118-
Console.WriteLine(error);
120+
Console.WriteLine(errorMessage);
119121
return false;
120122
}
121123
DirectoryInfo headersInfo = new DirectoryInfo(qt.Headers);
@@ -126,11 +128,11 @@ static bool QueryQt(QtInfo qt, bool debug)
126128
headersInfo.Name);
127129
return false;
128130
}
129-
qt.Docs = ProcessHelper.Run(qt.QMake, "-query QT_INSTALL_DOCS", out error);
131+
qt.Docs = ProcessHelper.Run(qt.QMake, "-query QT_INSTALL_DOCS", out error, out errorMessage);
130132

131133
string emptyFile = Platform.IsWindows ? "NUL" : "/dev/null";
132134
string output;
133-
ProcessHelper.Run("gcc", string.Format("-v -E -x c++ {0}", emptyFile), out output);
135+
ProcessHelper.Run("gcc", $"-v -E -x c++ {emptyFile}", out error, out output);
134136
qt.Target = Regex.Match(output, @"Target:\s*(?<target>[^\r\n]+)").Groups["target"].Value;
135137

136138
const string includeDirsRegex = @"#include <\.\.\.> search starts here:(?<includes>.+)End of search list";
@@ -150,24 +152,6 @@ static bool QueryQt(QtInfo qt, bool debug)
150152
return true;
151153
}
152154

153-
static void ProcessGeneratedInlines ()
154-
{
155-
if (!Platform.IsWindows)
156-
return;
157-
158-
#if DEBUG
159-
if (File.Exists("../../../QtSharp.Tests/bin/Debug/QtCore-inlines.dll"))
160-
File.Delete("../../../QtSharp.Tests/bin/Debug/QtCore-inlines.dll");
161-
162-
File.Copy("release/QtCore-inlines.dll", "../../../QtSharp.Tests/bin/Debug/QtCore-inlines.dll");
163-
#else
164-
if (File.Exists("../../../QtSharp.Tests/bin/Release/QtCore-inlines.dll"))
165-
File.Delete("../../../QtSharp.Tests/bin/Release/QtCore-inlines.dll");
166-
167-
File.Copy ("release/QtCore-inlines.dll", "../../../QtSharp.Tests/bin/Release/QtCore-inlines.dll");
168-
#endif
169-
}
170-
171155
public static int Main(string[] args)
172156
{
173157
Stopwatch s = Stopwatch.StartNew();
@@ -213,8 +197,6 @@ public static int Main(string[] args)
213197
ConsoleDriver.Run(qtSharp);
214198
var wrappedModules = qtSharp.GetVerifiedWrappedModules();
215199

216-
ProcessGeneratedInlines();
217-
218200
if (wrappedModules.Count == 0)
219201
{
220202
Console.WriteLine("Generation failed.");

QtSharp.CLI/QtSharp.CLI.csproj

+7-7
Original file line numberDiff line numberDiff line change
@@ -63,27 +63,27 @@
6363
</PropertyGroup>
6464
<ItemGroup>
6565
<Reference Include="CppSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
66-
<HintPath>..\packages\CppSharp.0.8.4\lib\CppSharp.dll</HintPath>
66+
<HintPath>..\packages\CppSharp.0.8.6\lib\CppSharp.dll</HintPath>
6767
<Private>True</Private>
6868
</Reference>
6969
<Reference Include="CppSharp.AST, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
70-
<HintPath>..\packages\CppSharp.0.8.4\lib\CppSharp.AST.dll</HintPath>
70+
<HintPath>..\packages\CppSharp.0.8.6\lib\CppSharp.AST.dll</HintPath>
7171
<Private>True</Private>
7272
</Reference>
7373
<Reference Include="CppSharp.Generator, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
74-
<HintPath>..\packages\CppSharp.0.8.4\lib\CppSharp.Generator.dll</HintPath>
74+
<HintPath>..\packages\CppSharp.0.8.6\lib\CppSharp.Generator.dll</HintPath>
7575
<Private>True</Private>
7676
</Reference>
7777
<Reference Include="CppSharp.Parser, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
78-
<HintPath>..\packages\CppSharp.0.8.4\lib\CppSharp.Parser.dll</HintPath>
78+
<HintPath>..\packages\CppSharp.0.8.6\lib\CppSharp.Parser.dll</HintPath>
7979
<Private>True</Private>
8080
</Reference>
81-
<Reference Include="CppSharp.Parser.CLI, Version=0.0.0.0, Culture=neutral, processorArchitecture=AMD64">
82-
<HintPath>..\packages\CppSharp.0.8.4\lib\CppSharp.Parser.CLI.dll</HintPath>
81+
<Reference Include="CppSharp.Parser.CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
82+
<HintPath>..\packages\CppSharp.0.8.6\lib\CppSharp.Parser.CSharp.dll</HintPath>
8383
<Private>True</Private>
8484
</Reference>
8585
<Reference Include="CppSharp.Runtime, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
86-
<HintPath>..\packages\CppSharp.0.8.4\lib\CppSharp.Runtime.dll</HintPath>
86+
<HintPath>..\packages\CppSharp.0.8.6\lib\CppSharp.Runtime.dll</HintPath>
8787
<Private>True</Private>
8888
</Reference>
8989
<Reference Include="Mono.Cecil, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">

QtSharp.CLI/packages.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
33
<package id="Baseclass.Contrib.Nuget.Output" version="2.1.0" targetFramework="net451" />
4-
<package id="CppSharp" version="0.8.4" targetFramework="net461" developmentDependency="true" />
4+
<package id="CppSharp" version="0.8.6" targetFramework="net461" developmentDependency="true" />
55
<package id="Mono.Cecil" version="0.9.6.4" targetFramework="net461" />
66
</packages>

QtSharp.Tests/Manual/QtCore/IO/QFileInfoTests.cs

+14-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.IO;
22
using System.Linq;
3+
using System.Reflection;
34
using NUnit.Framework;
45
using QtCore;
56

@@ -8,11 +9,20 @@ namespace QtSharp.Tests.Manual.QtCore.IO
89
[TestFixture]
910
public class QFileInfoTests
1011
{
11-
private readonly FileInfo _testFilePath1 = new FileInfo("./TestData/TextFile1.txt");
12-
private readonly FileInfo _testFilePath2 = new FileInfo("./TestData/TextFile2_1000words.txt");
13-
private readonly FileInfo _testFilePath3 = new FileInfo("./TestData/TextFile3_50bytes.txt");
14-
private readonly FileInfo _testFilePath4 = new FileInfo("./TestData/DoubleExtension.ext.txt");
12+
private readonly FileInfo _testFilePath1;
13+
private readonly FileInfo _testFilePath2;
14+
private readonly FileInfo _testFilePath3;
15+
private readonly FileInfo _testFilePath4;
1516

17+
public QFileInfoTests()
18+
{
19+
var dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
20+
Directory.SetCurrentDirectory(dir);
21+
_testFilePath1 = new FileInfo($"./TestData/TextFile1.txt");
22+
_testFilePath2 = new FileInfo($"./TestData/TextFile2_1000words.txt");
23+
_testFilePath3 = new FileInfo($"./TestData/TextFile3_50bytes.txt");
24+
_testFilePath4 = new FileInfo($"./TestData/DoubleExtension.ext.txt");
25+
}
1626

1727
private QFileInfo _fileInfo;
1828

QtSharp.Tests/Manual/QtCore/IO/QUrlTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public void TestAuthority()
7979
QUrl.ComponentFormattingOption formatting in Enum.GetValues(typeof(QUrl.ComponentFormattingOption)))
8080
{
8181
var s = this.qUrl.Authority(formatting);
82-
Assert.IsNotNullOrEmpty(s, "Problem in enum: " + formatting.ToString());
82+
Assert.That(s, Is.Not.Null.Or.Empty, "Problem in enum: " + formatting.ToString());
8383
}
8484
}
8585

@@ -95,7 +95,7 @@ public void TestFragment()
9595
{
9696
var s = this.qUrl.Fragment();
9797

98-
Assert.IsNotNullOrEmpty(s);
98+
Assert.That(s, Is.Not.Null.Or.Empty);
9999
}
100100

101101
[Test]

QtSharp.Tests/Manual/QtCore/Kernel/QObjectTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ public void TestObjectName()
247247
{
248248
var isW = _qObject.ObjectName;
249249

250-
Assert.IsNullOrEmpty(isW);
250+
Assert.That(isW, Is.Not.Null.Or.Empty);
251251

252252
_qObject.ObjectName = "MyObject";
253253

QtSharp.Tests/Manual/QtCore/QSysInfoTests.cs

+4-6
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,18 @@ public class QSysInfoTests
1111
[Test]
1212
public void TestWinVersion()
1313
{
14-
var s = QSysInfo.WindowsVersion;
14+
var s = QSysInfo.windowsVersion;
1515

16-
Assert.IsNotNullOrEmpty(s.ToString());
16+
Assert.That(s.ToString(), Is.Not.Null.Or.Empty);
1717
}
1818

1919
[Platform(Exclude = "Win,Linux")]
2020
[Test]
2121
public void TestMacintoshVersion()
2222
{
23-
throw new NotImplementedException("Add in QtCore");
23+
var s = QSysInfo.macVersion;
2424

25-
//var s = QSysInfo.MacintoshVersion;
26-
27-
//Assert.IsNotNullOrEmpty(s.ToString());
25+
Assert.That(s.ToString(), Is.Not.Null.Or.Empty);
2826
}
2927
}
3028
}

0 commit comments

Comments
 (0)