6
6
using CppSharp . Passes ;
7
7
using CppSharp ;
8
8
using CppSharp . Parser ;
9
+ using System . Collections . Generic ;
9
10
10
11
namespace QtSharp
11
12
{
@@ -33,14 +34,19 @@ public override bool VisitLibrary(ASTContext context)
33
34
File . WriteAllText ( qtVersionFile , qtVersion ) ;
34
35
qtVersionFileInfo = new FileInfo ( qtVersionFile ) ;
35
36
}
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
+ {
36
42
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 ) ) ;
39
45
var libFile = Path . Combine ( dir , inlines ) ;
40
46
var inlinesFileInfo = new FileInfo ( libFile ) ;
41
47
if ( ! inlinesFileInfo . Exists || qtVersionFileInfo . LastWriteTimeUtc > inlinesFileInfo . LastWriteTimeUtc )
42
48
{
43
- if ( ! this . CompileInlines ( ) )
49
+ if ( ! this . CompileInlines ( qtInlines , isGpl ) )
44
50
{
45
51
return false ;
46
52
}
@@ -61,24 +67,46 @@ public override bool VisitLibrary(ASTContext context)
61
67
return true ;
62
68
}
63
69
64
- private bool CompileInlines ( )
70
+ private bool CompileInlines ( string qtInlines , bool isGpl = false )
65
71
{
66
- var pro = string . Format ( "Qt-inlines .pro" ) ;
72
+ var pro = string . Format ( "{0} .pro" , qtInlines ) ;
67
73
var path = Path . Combine ( this . Context . Options . OutputDir , pro ) ;
68
74
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
70
83
from header in module . Headers
71
- where ! header . EndsWith ( ".h" , StringComparison . Ordinal )
84
+ where header != "QtCharts" && header != "QtDataVisualization" &&
85
+ ! header . EndsWith ( ".h" , StringComparison . Ordinal )
72
86
select header . Substring ( "Qt" . Length ) . ToLowerInvariant ( ) ) ;
87
+ }
73
88
// QtTest is only library which has a "lib" suffix to its module alias for qmake
74
89
qtModules = qtModules . Replace ( " test " , " testlib " ) ;
75
90
76
91
proBuilder . AppendFormat ( "QT += {0}\n " , qtModules ) ;
77
92
proBuilder . Append ( "CONFIG += c++11\n " ) ;
78
93
proBuilder . Append ( "QMAKE_CXXFLAGS += -fkeep-inline-functions\n " ) ;
79
- proBuilder . AppendFormat ( "TARGET = Qt-inlines \n " ) ;
94
+ proBuilder . AppendFormat ( "TARGET = {0} \n " , qtInlines ) ;
80
95
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 ) ) ;
82
110
if ( Environment . OSVersion . Platform == PlatformID . Win32NT )
83
111
{
84
112
proBuilder . Append ( "LIBS += -loleaut32 -lole32" ) ;
0 commit comments