Skip to content

Commit d91f99c

Browse files
committed
Moved the inlines for GPL-only/commercial-only modules to a separate library.
This way people who don't want to use GPL-ed code can safely do so. Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
1 parent f3f5b1c commit d91f99c

File tree

5 files changed

+51
-12
lines changed

5 files changed

+51
-12
lines changed

CHANGELOG

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
0.6.2 - 1.10.2016
2+
BREAKING: The helping libraries with inlines are no longer separated per module.
3+
Instead, there are just two of them, Qt-inlines for the LGPL modules and Qt-GPL-inlines for the rest.
4+
Fixed:
5+
- Removed all sealed overrides in the bindings;
6+
- Removed the double name-space from QtDataVisualization.
7+
18
0.6.1 - 17.9.2016
29
Fixed:
310
- Removed all mappings to C# structures because their empty constructors are not correctly wrapped yet.

LICENSE

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ IMPORTANT: The Apache License below does not include the
44
following bindings:
55
- QtCharts.Sharp;
66
- QtDataVisualization.Sharp;
7-
They are licensed under GPLv3 instead as they link GPLv3 code.
7+
along with Qt-GPL-inlines. These are licensed under GPLv3 instead
8+
as they link GPLv3 code.
89
You may obtain a copy of GPLv3 at
910

1011
https://www.gnu.org/licenses/gpl-3.0.en.html

QtSharp.CLI/Program.cs

+2
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ public static int Main(string[] args)
241241
var extension = Platform.IsWindows ? "dll" : Platform.IsMacOS ? "dylib" : "so";
242242
var inlines = string.Format("Qt-inlines.{0}", extension);
243243
zipArchive.CreateEntryFromFile(string.Format("release/{0}", inlines), inlines);
244+
var gplInlines = string.Format("Qt-GPL-inlines.{0}", extension);
245+
zipArchive.CreateEntryFromFile(string.Format("release/{0}", gplInlines), gplInlines);
244246
}
245247
}
246248
Console.WriteLine("Done in: " + s.Elapsed);

QtSharp/CompileInlinesPass.cs

+37-9
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using CppSharp.Passes;
77
using CppSharp;
88
using CppSharp.Parser;
9+
using System.Collections.Generic;
910

1011
namespace QtSharp
1112
{
@@ -33,14 +34,19 @@ public override bool VisitLibrary(ASTContext context)
3334
File.WriteAllText(qtVersionFile, qtVersion);
3435
qtVersionFileInfo = new FileInfo(qtVersionFile);
3536
}
37+
return CompileInlines(qtVersionFileInfo, "Qt-inlines") && CompileInlines(qtVersionFileInfo, "Qt-GPL-inlines", true);
38+
}
39+
40+
private bool CompileInlines(FileInfo qtVersionFileInfo, string qtInlines, bool isGpl = false)
41+
{
3642
var dir = Platform.IsMacOS ? this.Context.Options.OutputDir : Path.Combine(this.Context.Options.OutputDir, "release");
37-
var inlines = Path.GetFileName(string.Format("{0}Qt-inlines.{1}", Platform.IsWindows ? string.Empty : "lib",
38-
Platform.IsWindows ? "dll" : Platform.IsMacOS ? "dylib" : "so"));
43+
var inlines = Path.GetFileName(string.Format("{0}{2}.{1}", Platform.IsWindows ? string.Empty : "lib",
44+
Platform.IsWindows ? "dll" : Platform.IsMacOS ? "dylib" : "so", qtInlines));
3945
var libFile = Path.Combine(dir, inlines);
4046
var inlinesFileInfo = new FileInfo(libFile);
4147
if (!inlinesFileInfo.Exists || qtVersionFileInfo.LastWriteTimeUtc > inlinesFileInfo.LastWriteTimeUtc)
4248
{
43-
if (!this.CompileInlines())
49+
if (!this.CompileInlines(qtInlines, isGpl))
4450
{
4551
return false;
4652
}
@@ -61,24 +67,46 @@ public override bool VisitLibrary(ASTContext context)
6167
return true;
6268
}
6369

64-
private bool CompileInlines()
70+
private bool CompileInlines(string qtInlines, bool isGpl = false)
6571
{
66-
var pro = string.Format("Qt-inlines.pro");
72+
var pro = string.Format("{0}.pro", qtInlines);
6773
var path = Path.Combine(this.Context.Options.OutputDir, pro);
6874
var proBuilder = new StringBuilder();
69-
var qtModules = string.Join(" ", from module in this.Context.Options.Modules
75+
string qtModules;
76+
if (isGpl)
77+
{
78+
qtModules = "charts datavisualization";
79+
}
80+
else
81+
{
82+
qtModules = string.Join(" ", from module in this.Context.Options.Modules
7083
from header in module.Headers
71-
where !header.EndsWith(".h", StringComparison.Ordinal)
84+
where header != "QtCharts" && header != "QtDataVisualization" &&
85+
!header.EndsWith(".h", StringComparison.Ordinal)
7286
select header.Substring("Qt".Length).ToLowerInvariant());
87+
}
7388
// QtTest is only library which has a "lib" suffix to its module alias for qmake
7489
qtModules = qtModules.Replace(" test ", " testlib ");
7590

7691
proBuilder.AppendFormat("QT += {0}\n", qtModules);
7792
proBuilder.Append("CONFIG += c++11\n");
7893
proBuilder.Append("QMAKE_CXXFLAGS += -fkeep-inline-functions\n");
79-
proBuilder.AppendFormat("TARGET = Qt-inlines\n");
94+
proBuilder.AppendFormat("TARGET = {0}\n", qtInlines);
8095
proBuilder.Append("TEMPLATE = lib\n");
81-
proBuilder.AppendFormat("SOURCES += {0}\n", string.Join(" ", this.Context.Options.Modules.Select(m => m.InlinesLibraryName + ".cpp")));
96+
IEnumerable<string> sources;
97+
if (isGpl)
98+
{
99+
sources = from module in this.Context.Options.Modules
100+
where module.Headers.Contains("QtCharts") || module.Headers.Contains("QtDataVisualization")
101+
select module.InlinesLibraryName + ".cpp";
102+
}
103+
else
104+
{
105+
sources = from module in this.Context.Options.Modules
106+
where !module.Headers.Contains("QtCharts") && ! module.Headers.Contains("QtDataVisualization")
107+
select module.InlinesLibraryName + ".cpp";
108+
}
109+
proBuilder.AppendFormat("SOURCES += {0}\n", string.Join(" ", sources));
82110
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
83111
{
84112
proBuilder.Append("LIBS += -loleaut32 -lole32");

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ Qt for OS X and Linux are planned, Qt for VC++ has not been planned for now.
1414
The source code is separated into a library that contains the settings and passes the generator needs, and a command-line client.
1515
In the future a GUI client, constructed with Qt# itself, is planned as well.
1616

17-
The are binary releases for Windows and Qt MinGW at https://github.com/ddobrev/QtSharp/releases. They are in an alpha stage.
17+
There are binary releases for Windows and Qt MinGW at https://github.com/ddobrev/QtSharp/releases. They are in an alpha stage.
1818
As they get more stable, binaries for other operating systems will be added as well.
1919

2020
## Getting started
2121

2222
You need to deploy Qt itself by following http://doc.qt.io/qt-5/windows-deployment.html#application-dependencies .
23-
In addition, for each Qt module you use you also need Qt<module>-inlines.dll deployed alongside your executable.
23+
In addition, you need to deploy Qt-inlines alongside your executable. If you use QtCharts or QtDataVisualization,
24+
you also need Qt-GPL-inlines.
2425
You can use QtSharp with any C# IDE, including Visual Studio, but make sure your executable is 32-bit by either using the
2526
x86 configuration or AnyCPU with "Prefer 32-bit" checked.
2627

0 commit comments

Comments
 (0)