5
5
using System . Linq ;
6
6
using System . Text . RegularExpressions ;
7
7
using CppSharp ;
8
- using CppSharp . Parser ;
9
- using ClangParser = CppSharp . Parser . ClangParser ;
10
8
11
9
namespace QtSharp . CLI
12
10
{
@@ -43,32 +41,15 @@ static int ParseArgs(string[] args, out string qmake, out string make, out bool
43
41
return 0 ;
44
42
}
45
43
46
- class QtVersion
47
- {
48
- public int MajorVersion ;
49
- public int MinorVersion ;
50
- public string Path ;
51
- public string Target ;
52
- public string Docs ;
53
- public string QMake ;
54
- public string Make ;
55
- public string Bins ;
56
- public string Libs ;
57
- public string Headers ;
58
- public IEnumerable < string > LibFiles ;
59
- public IEnumerable < string > SystemIncludeDirs ;
60
- public IEnumerable < string > FrameworkDirs ;
61
- }
62
-
63
- static List < QtVersion > FindQt ( )
44
+ static List < QtInfo > FindQt ( )
64
45
{
65
46
var home = Environment . GetFolderPath ( Environment . SpecialFolder . Personal ) ;
66
- var qts = new List < QtVersion > ( ) ;
47
+ var qts = new List < QtInfo > ( ) ;
67
48
68
49
var qtPath = Path . Combine ( home , "Qt" ) ;
69
50
if ( ! Directory . Exists ( qtPath ) )
70
51
{
71
- return new List < QtVersion > ( ) ;
52
+ return new List < QtInfo > ( ) ;
72
53
}
73
54
74
55
foreach ( var path in Directory . EnumerateDirectories ( qtPath ) )
@@ -77,7 +58,7 @@ static List<QtVersion> FindQt()
77
58
bool isNumber = dir . All ( c => char . IsDigit ( c ) || c == '.' ) ;
78
59
if ( ! isNumber )
79
60
continue ;
80
- var qt = new QtVersion { Path = path } ;
61
+ var qt = new QtInfo { Path = path } ;
81
62
var match = Regex . Match ( dir , @"([0-9]+)\.([0-9]+)" ) ;
82
63
if ( ! match . Success )
83
64
continue ;
@@ -89,7 +70,7 @@ static List<QtVersion> FindQt()
89
70
return qts ;
90
71
}
91
72
92
- static bool QueryQt ( QtVersion qt , bool debug )
73
+ static bool QueryQt ( QtInfo qt , bool debug )
93
74
{
94
75
// check for OS X
95
76
if ( string . IsNullOrWhiteSpace ( qt . QMake ) )
@@ -167,37 +148,6 @@ static bool QueryQt(QtVersion qt, bool debug)
167
148
return true ;
168
149
}
169
150
170
- static Dictionary < string , IList < string > > GetDependencies ( QtVersion qt )
171
- {
172
- var dependencies = new Dictionary < string , IList < string > > ( ) ;
173
-
174
- var parserOptions = new ParserOptions ( ) ;
175
- parserOptions . addLibraryDirs ( Platform . IsWindows ? qt . Bins : qt . Libs ) ;
176
- if ( Platform . IsMacOS )
177
- {
178
- var libsInfo = new DirectoryInfo ( qt . Libs ) ;
179
- foreach ( var frameworkDir in libsInfo . EnumerateDirectories ( "*.framework" ) . Select ( d => d . FullName ) )
180
- parserOptions . addLibraryDirs ( Path . Combine ( frameworkDir ) ) ;
181
- }
182
-
183
- foreach ( var libFile in qt . LibFiles )
184
- {
185
- dependencies [ libFile ] = Enumerable . Empty < string > ( ) . ToList ( ) ;
186
-
187
- parserOptions . FileName = libFile ;
188
- using ( var parserResult = ClangParser . ParseLibrary ( parserOptions ) )
189
- {
190
- if ( parserResult . Kind == ParserResultKind . Success )
191
- {
192
- dependencies [ libFile ] = CppSharp . ClangParser . ConvertLibrary ( parserResult . Library ) . Dependencies ;
193
- parserResult . Library . Dispose ( ) ;
194
- }
195
- }
196
- }
197
-
198
- return dependencies ;
199
- }
200
-
201
151
static void ProcessGeneratedInlines ( )
202
152
{
203
153
if ( ! Platform . IsWindows )
@@ -221,11 +171,11 @@ public static int Main(string[] args)
221
171
var qts = FindQt ( ) ;
222
172
bool found = qts . Count != 0 ;
223
173
bool debug = false ;
224
- QtVersion qt ;
174
+ QtInfo qt ;
225
175
226
176
if ( ! found )
227
177
{
228
- qt = new QtVersion ( ) ;
178
+ qt = new QtInfo ( ) ;
229
179
230
180
var result = ParseArgs ( args , out qt . QMake , out qt . Make , out debug ) ;
231
181
if ( result != 0 )
@@ -245,27 +195,25 @@ public static int Main(string[] args)
245
195
if ( ! QueryQt ( qt , debug ) )
246
196
return 1 ;
247
197
248
- var dependencies = GetDependencies ( qt ) ;
249
-
250
198
var modules = new List < string >
251
199
{
252
- "Qt5Core " ,
253
- "Qt5Gui " ,
254
- "Qt5Widgets " ,
255
- "Qt5Xml " ,
256
- "Qt5Designer " ,
257
- "Qt5Network " ,
258
- "Qt5Qml " ,
259
- "Qt5Nfc " ,
260
- "Qt5OpenGL " ,
261
- "Qt5ScriptTools " ,
262
- "Qt5Sensors " ,
263
- "Qt5SerialPort " ,
264
- "Qt5Svg " ,
265
- "Qt5Multimedia " ,
266
- "Qt5MultimediaWidgets " ,
267
- "Qt5Quick " ,
268
- "Qt5QuickWidgets "
200
+ "QtCore " ,
201
+ "QtGui " ,
202
+ "QtWidgets " ,
203
+ "QtXml " ,
204
+ "QtDesigner " ,
205
+ "QtNetwork " ,
206
+ "QtQml " ,
207
+ "QtNfc " ,
208
+ "QtOpenGL " ,
209
+ "QtScriptTools " ,
210
+ "QtSensors " ,
211
+ "QtSerialPort " ,
212
+ "QtSvg " ,
213
+ "QtMultimedia " ,
214
+ "QtMultimediaWidgets " ,
215
+ "QtQuick " ,
216
+ "QtQuickWidgets "
269
217
} ;
270
218
if ( debug )
271
219
{
@@ -274,33 +222,16 @@ public static int Main(string[] args)
274
222
modules [ i ] += "d" ;
275
223
}
276
224
}
277
- qt . LibFiles = qt . LibFiles . ToList ( ) . TopologicalSort ( l => dependencies . ContainsKey ( l ) ? dependencies [ l ] : Enumerable . Empty < string > ( ) ) ;
278
- var wrappedModules = new List < KeyValuePair < string , string > > ( modules . Count ) ;
279
- foreach ( var libFile in qt . LibFiles )
225
+ for ( int i = qt . LibFiles . Count - 1 ; i >= 0 ; i -- )
280
226
{
281
- string lib = Path . GetFileNameWithoutExtension ( libFile ) ;
282
- if ( ! Platform . IsWindows )
283
- lib = lib . Replace ( "Qt" , "Qt5" ) ;
284
-
285
- if ( modules . All ( m => m != Path . GetFileNameWithoutExtension ( lib ) ) )
286
- continue ;
287
-
288
- if ( log )
227
+ if ( ! modules . Contains ( QtSharp . GetModuleNameFromLibFile ( qt . LibFiles [ i ] ) ) )
289
228
{
290
- logredirect . SetLogFile ( lib + "Log.txt" ) ;
291
- logredirect . Start ( ) ;
229
+ qt . LibFiles . RemoveAt ( i ) ;
292
230
}
293
-
294
- var qtSharp = new QtSharp ( new QtModuleInfo ( qt . QMake , qt . Make , qt . Headers , Platform . IsWindows ? qt . Bins : qt . Libs ,
295
- libFile , qt . Target , qt . SystemIncludeDirs , qt . FrameworkDirs , qt . Docs ) ) ;
296
- ConsoleDriver . Run ( qtSharp ) ;
297
-
298
- if ( File . Exists ( qtSharp . LibraryName ) && File . Exists ( qtSharp . InlinesLibraryPath ) )
299
- wrappedModules . Add ( new KeyValuePair < string , string > ( qtSharp . LibraryName , qtSharp . InlinesLibraryPath ) ) ;
300
-
301
- if ( log )
302
- logredirect . Stop ( ) ;
303
231
}
232
+ var qtSharp = new QtSharp ( qt ) ;
233
+ ConsoleDriver . Run ( qtSharp ) ;
234
+ var wrappedModules = qtSharp . GetVerifiedWrappedModules ( ) ;
304
235
305
236
ProcessGeneratedInlines ( ) ;
306
237
0 commit comments