1
- using System . IO ;
1
+ using System ;
2
+ using System . IO ;
2
3
using System . Linq ;
3
4
using System . Reflection ;
5
+ using System . Text . RegularExpressions ;
4
6
using CppSharp ;
5
7
using CppSharp . AST ;
6
8
using CppSharp . Generators ;
@@ -17,24 +19,28 @@ public class QtSharp : ILibrary
17
19
private readonly string module ;
18
20
private readonly string libraryPath ;
19
21
private readonly string library ;
22
+ private readonly string target ;
23
+ private readonly string compilerVersion ;
20
24
private readonly string docs ;
21
25
22
- public QtSharp ( string qmake , string make , string includePath , string module , string libraryPath , string library , string docs )
26
+ public QtSharp ( string qmake , string make , string includePath , string libraryPath , string library , string target , string compilerVersion , string docs )
23
27
{
24
28
this . qmake = qmake ;
25
29
this . includePath = includePath ;
26
- this . module = module ;
30
+ this . module = Regex . Match ( library , @"Qt\d?(?< module>\w+)\.\w+$" ) . Groups [ "module" ] . Value ;
27
31
this . libraryPath = libraryPath ;
28
32
this . library = library ;
29
- this . make = make ;
33
+ this . target = target ;
34
+ this . compilerVersion = compilerVersion ;
35
+ this . make = make ;
30
36
this . docs = docs ;
31
37
}
32
38
33
39
public void Preprocess ( Driver driver , ASTContext lib )
34
40
{
35
41
string qtModule = "Qt" + this . module ;
36
42
string moduleIncludes = Path . Combine ( this . includePath , qtModule ) ;
37
- foreach ( TranslationUnit unit in lib . TranslationUnits )
43
+ foreach ( TranslationUnit unit in lib . TranslationUnits . Where ( u => u . FilePath != "<invalid>" ) )
38
44
{
39
45
if ( Path . GetDirectoryName ( unit . FilePath ) != moduleIncludes )
40
46
{
@@ -147,6 +153,9 @@ public void Setup(Driver driver)
147
153
driver . Options . GeneratorKind = GeneratorKind . CSharp ;
148
154
string qtModule = "Qt" + this . module ;
149
155
driver . Options . Is32Bit = true ;
156
+ driver . Options . NoBuiltinIncludes = true ;
157
+ driver . Options . MicrosoftMode = false ;
158
+ driver . Options . TargetTriple = this . target ;
150
159
driver . Options . Abi = CppAbi . Itanium ;
151
160
driver . Options . LibraryName = string . Format ( "{0}Sharp" , qtModule ) ;
152
161
driver . Options . OutputNamespace = qtModule ;
@@ -158,11 +167,15 @@ public void Setup(Driver driver)
158
167
driver . Options . IgnoreParseWarnings = true ;
159
168
driver . Options . CheckSymbols = true ;
160
169
driver . Options . Headers . Add ( qtModule ) ;
161
- driver . Options . IncludeDirs . Add ( this . includePath ) ;
170
+ string gccPath = Path . GetDirectoryName ( Path . GetDirectoryName ( this . make ) ) ;
171
+ driver . Options . IncludeDirs . Add ( Path . Combine ( gccPath , this . target , "include" ) ) ;
172
+ driver . Options . IncludeDirs . Add ( Path . Combine ( gccPath , "lib" , "gcc" , this . target , this . compilerVersion , "include" ) ) ;
173
+ driver . Options . IncludeDirs . Add ( Path . Combine ( gccPath , "lib" , "gcc" , this . target , this . compilerVersion , "include" , "c++" ) ) ;
174
+ driver . Options . IncludeDirs . Add ( Path . Combine ( gccPath , "lib" , "gcc" , this . target , this . compilerVersion , "include" , "c++" , this . target ) ) ;
175
+ driver . Options . IncludeDirs . Add ( this . includePath ) ;
162
176
driver . Options . IncludeDirs . Add ( Path . Combine ( this . includePath , qtModule ) ) ;
163
177
driver . Options . LibraryDirs . Add ( this . libraryPath ) ;
164
178
driver . Options . Libraries . Add ( this . library ) ;
165
- driver . Options . Defines . Add ( "_MSC_FULL_VER=170050215" ) ;
166
179
if ( this . module == "Core" )
167
180
{
168
181
string dir = Path . GetDirectoryName ( Assembly . GetExecutingAssembly ( ) . Location ) ;
0 commit comments