@@ -32,6 +32,8 @@ interface
32
32
' s' , ' t' , ' u' , ' v' , ' w' , ' x' , ' y' , ' z' );
33
33
34
34
type
35
+ TCompilerType = (ctGCC,ctClang);
36
+
35
37
// the comments are an example of the record
36
38
PCompilerOption = ^TCompilerOption;
37
39
TCompilerOption = record
@@ -70,6 +72,7 @@ TdevCompilerSet = class(TPersistent)
70
72
fDefInclude: TStringList; // default include dir
71
73
fDefines: TStringList; // list of predefined constants
72
74
fTarget: AnsiString; // 'X86_64' / 'i686'
75
+ fCompilerType: TCompilerType; // 'Clang'/ 'GCC'
73
76
74
77
// User settings
75
78
fCompAdd: boolean;
@@ -136,6 +139,7 @@ TdevCompilerSet = class(TPersistent)
136
139
property Target: AnsiString read fTarget;
137
140
property DefInclude: TStringList read fDefInclude;
138
141
property Defines: TStringList read fDefines;
142
+ property CompilerType: TCompilerType read fCompilerType;
139
143
140
144
// Options
141
145
property Options: TList read fOptions write fOptions;
@@ -1305,6 +1309,7 @@ procedure TdevCompilerSet.Assign(Source: TPersistent);
1305
1309
fType := input.fType;
1306
1310
fName := input.fName;
1307
1311
fFolder := input.fFolder;
1312
+ fCompilerType := input.fCompilerType;
1308
1313
fDefInclude.Assign(input.fDefInclude);
1309
1314
fDefines.Assign(input.fDefines);
1310
1315
@@ -1346,41 +1351,60 @@ procedure TdevCompilerSet.SetProperties(const BinDir, BinFile: AnsiString);
1346
1351
else
1347
1352
fTarget := ' i686' ;
1348
1353
1349
- // version
1350
- DelimPos1 := Pos(' gcc version ' , output);
1351
- if DelimPos1 = 0 then
1352
- Exit; // unknown binary
1353
-
1354
- // Find version number
1355
- Inc(DelimPos1, Length(' gcc version ' ));
1356
- DelimPos2 := DelimPos1;
1357
- while (DelimPos2 <= Length(output)) and not (output[DelimPos2] in [#0 ..#32 ]) do
1358
- Inc(DelimPos2);
1359
- fVersion := Copy(output, DelimPos1, DelimPos2 - DelimPos1);
1360
-
1361
- // Set compiler folder
1362
- DelimPos1 := RPos(pd, BinDir);
1363
- if DelimPos1 > 0 then
1364
- fFolder := Copy(BinDir, 1 , DelimPos1 - 1 );
1365
-
1366
- // Find compiler builder
1367
- DelimPos1 := DelimPos2;
1368
- while (DelimPos1 <= Length(output)) and not (output[DelimPos1] = ' (' ) do
1369
- Inc(DelimPos1);
1370
- while (DelimPos2 <= Length(output)) and not (output[DelimPos2] = ' )' ) do
1371
- Inc(DelimPos2);
1372
- fType := Copy(output, DelimPos1 + 1 , DelimPos2 - DelimPos1 - 1 );
1373
-
1374
- // Assemble user friendly name if we don't have one yet
1375
- if fName = ' ' then begin
1376
- if ContainsStr(fType, ' tdm64' ) then
1377
- fName := ' TDM-GCC ' + fVersion
1378
- else if ContainsStr(fType, ' tdm' ) then
1379
- fName := ' TDM-GCC ' + fVersion
1380
- else if ContainsStr(fType, ' GCC' ) then
1381
- fName := ' MinGW GCC ' + fVersion
1382
- else
1383
- fName := ' MinGW GCC' + fVersion;
1354
+ // Compiler Type
1355
+ DelimPos1 := Pos(' clang version ' , output);
1356
+ if (DelimPos1 <> 0 ) then begin
1357
+ fCompilerType := ctClang;
1358
+ Inc(DelimPos1, Length(' clang version ' ));
1359
+ DelimPos2 := DelimPos1;
1360
+ while (DelimPos2 <= Length(output)) and not (output[DelimPos2] in [#0 ..#32 ]) do
1361
+ Inc(DelimPos2);
1362
+ fVersion := Copy(output, DelimPos1, DelimPos2 - DelimPos1);
1363
+
1364
+ // Set compiler folder
1365
+ DelimPos1 := RPos(pd, BinDir);
1366
+ if DelimPos1 > 0 then
1367
+ fFolder := Copy(BinDir, 1 , DelimPos1 - 1 );
1368
+ if fName = ' ' then
1369
+ fName := ' Clang ' + fVersion;
1370
+ end else begin
1371
+ fCompilerType := ctGCC;
1372
+ // version
1373
+ DelimPos1 := Pos(' gcc version ' , output);
1374
+ if DelimPos1 = 0 then
1375
+ Exit; // unknown binary
1376
+
1377
+ // Find version number
1378
+ Inc(DelimPos1, Length(' gcc version ' ));
1379
+ DelimPos2 := DelimPos1;
1380
+ while (DelimPos2 <= Length(output)) and not (output[DelimPos2] in [#0 ..#32 ]) do
1381
+ Inc(DelimPos2);
1382
+ fVersion := Copy(output, DelimPos1, DelimPos2 - DelimPos1);
1383
+
1384
+ // Set compiler folder
1385
+ DelimPos1 := RPos(pd, BinDir);
1386
+ if DelimPos1 > 0 then
1387
+ fFolder := Copy(BinDir, 1 , DelimPos1 - 1 );
1388
+
1389
+ // Find compiler builder
1390
+ DelimPos1 := DelimPos2;
1391
+ while (DelimPos1 <= Length(output)) and not (output[DelimPos1] = ' (' ) do
1392
+ Inc(DelimPos1);
1393
+ while (DelimPos2 <= Length(output)) and not (output[DelimPos2] = ' )' ) do
1394
+ Inc(DelimPos2);
1395
+ fType := Copy(output, DelimPos1 + 1 , DelimPos2 - DelimPos1 - 1 );
1396
+
1397
+ // Assemble user friendly name if we don't have one yet
1398
+ if fName = ' ' then begin
1399
+ if ContainsStr(fType, ' tdm64' ) then
1400
+ fName := ' TDM-GCC ' + fVersion
1401
+ else if ContainsStr(fType, ' tdm' ) then
1402
+ fName := ' TDM-GCC ' + fVersion
1403
+ else if ContainsStr(fType, ' GCC' ) then
1404
+ fName := ' MinGW GCC ' + fVersion
1405
+ else
1406
+ fName := ' MinGW GCC' + fVersion;
1407
+ end ;
1384
1408
end ;
1385
1409
1386
1410
// Obtain compiler target
@@ -1421,12 +1445,82 @@ procedure TdevCompilerSet.SetExecutables;
1421
1445
end ;
1422
1446
1423
1447
procedure TdevCompilerSet.SetDirectories ;
1448
+ var
1449
+ DelimPos1,DelimPos2: integer;
1450
+ output,s: string;
1451
+ sl: TStringList;
1452
+ i:integer;
1424
1453
procedure AddExistingDirectory (var list: TStringList; const Directory: AnsiString);
1425
1454
begin
1426
1455
if DirectoryExists(Directory) then
1427
1456
list.Add(Directory);
1428
1457
end ;
1429
1458
begin
1459
+
1460
+ // Find default directories
1461
+ // C include dirs
1462
+ output := GetCompilerOutput(IncludeTrailingPathDelimiter(fFolder) + ' bin' + pd, fgccName, ' -xc -v -E NUL' );
1463
+ // Target
1464
+ DelimPos1 := Pos(' #include <...> search starts here:' ,output);
1465
+ DelimPos2 := Pos(' End of search list.' , output);
1466
+ if (delimPos1 >0 ) and ( delimPos2>0 ) then begin
1467
+ Inc(DelimPos1,Length(' #include <...> search starts here:' ));
1468
+ output := Copy(output, DelimPos1, DelimPos2 - DelimPos1);
1469
+ sl := TStringList.Create;
1470
+ try
1471
+ ExtractStrings([#10 ], [], PAnsiChar(output), sl);
1472
+ for i:=0 to sl.Count -1 do begin
1473
+ s := Trim(sl[i]);
1474
+ if (s <> ' ' ) then
1475
+ addExistingDirectory(fCDir,s);
1476
+ end ;
1477
+ finally
1478
+ sl.Destroy;
1479
+ end ;
1480
+ end ;
1481
+ // Find default directories
1482
+ // C++ include dirs
1483
+ output := GetCompilerOutput(IncludeTrailingPathDelimiter(fFolder) + ' bin' + pd, fgccName, ' -xc++ -v -E NUL' );
1484
+ // Target
1485
+ DelimPos1 := Pos(' #include <...> search starts here:' ,output);
1486
+ DelimPos2 := Pos(' End of search list.' , output);
1487
+ if (delimPos1 >0 ) and ( delimPos2>0 ) then begin
1488
+ Inc(DelimPos1,Length(' #include <...> search starts here:' ));
1489
+ output := Copy(output, DelimPos1, DelimPos2 - DelimPos1);
1490
+ sl := TStringList.Create;
1491
+ try
1492
+ ExtractStrings([#10 ], [], PAnsiChar(output), sl);
1493
+ for i:=0 to sl.Count -1 do begin
1494
+ s := Trim(sl[i]);
1495
+ if (s <> ' ' ) then
1496
+ addExistingDirectory(fCppDir,s);
1497
+ end ;
1498
+ finally
1499
+ sl.Destroy;
1500
+ end ;
1501
+ end ;
1502
+ // Find default directories
1503
+ // lib dirs
1504
+ output := GetCompilerOutput(IncludeTrailingPathDelimiter(fFolder) + ' bin' + pd, fgccName, ' -print-search-dirs' );
1505
+ DelimPos1 := Pos(' libraries: =' ,output);
1506
+ if (delimPos1 >0 ) then begin
1507
+ Inc(DelimPos1,Length(' libraries: =' ));
1508
+ DelimPos2 := DelimPos1;
1509
+ while (DelimPos2 <= Length(output)) and not (output[DelimPos2] in [#0 ..#32 ]) do
1510
+ Inc(DelimPos2);
1511
+ output := Copy(output, DelimPos1, DelimPos2 - DelimPos1);
1512
+ sl := TStringList.Create;
1513
+ try
1514
+ ExtractStrings([' ;' ], [], PAnsiChar(output), sl);
1515
+ for i:=0 to sl.Count -1 do begin
1516
+ s := Trim(sl[i]);
1517
+ if (s <> ' ' ) then
1518
+ addExistingDirectory(fLibDir,s);
1519
+ end ;
1520
+ finally
1521
+ sl.Destroy;
1522
+ end
1523
+ end ;
1430
1524
// Add both the default and the autoconf directories
1431
1525
AddExistingDirectory(fBinDir, fFolder + pd + ' bin' );
1432
1526
AddExistingDirectory(fLibDir, fFolder + pd + ' lib' );
@@ -1865,9 +1959,11 @@ function TdevCompilerSet.ValidateExes(var msg:string): boolean;
1865
1959
if not FindFile(fBinDir, fgdbName) then begin
1866
1960
msg := msg + Format(Lang[ID_COMPVALID_BINNOTFOUND], [Lang[ID_COMPVALID_DEBUGGER], fgdbName]) + #13 #10 ;
1867
1961
end ;
1962
+ {
1868
1963
if not FindFile(fBinDir, fgprofName) then begin
1869
1964
msg := msg + Format(Lang[ID_COMPVALID_BINNOTFOUND], [Lang[ID_COMPVALID_PROFILER], fgprofName]) + #13#10;
1870
1965
end;
1966
+ }
1871
1967
if not FindFile(fBinDir, fmakeName) then begin
1872
1968
msg := msg + Format(Lang[ID_COMPVALID_BINNOTFOUND], [Lang[ID_COMPVALID_MAKE], fmakeName]) + #13 #10 ;
1873
1969
end ;
@@ -2388,6 +2484,10 @@ procedure TdevCompilerSets.FindSets;
2388
2484
AddSets(devDirs.Exec + ' MinGW32' );
2389
2485
// Assume 64bit compilers are put in the MinGW64 folder
2390
2486
AddSets(devDirs.Exec + ' MinGW64' );
2487
+ // Assume 32bit clang compilers are put in the Clang32 folder
2488
+ AddSets(devDirs.Exec + ' Clang32' );
2489
+ // Assume 64bit clang compilers are put in the Clang64 folder
2490
+ AddSets(devDirs.Exec + ' Clang64' );
2391
2491
end ;
2392
2492
2393
2493
procedure TdevCompilerSets.ClearSets ;
0 commit comments