summaryrefslogtreecommitdiffstats
path: root/qmake/generators/win32/msbuild_objectmodel.cpp
blob: 522d5174e7b1d1009c55d1e9936ca41d7e58be09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the qmake application of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights.  These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/

#include "msvc_objectmodel.h"
#include "msbuild_objectmodel.h"
#include "msvc_vcproj.h"
#include "msvc_vcxproj.h"
#include <qstringlist.h>
#include <qfileinfo.h>

QT_BEGIN_NAMESPACE

// XML Tags ---------------------------------------------------------
const char _CLCompile[]                         = "ClCompile";
const char _Configuration[]                     = "Configuration";
const char _Configurations[]                    = "Configurations";
const char q_File[]                             = "File";
const char _FileConfiguration[]                 = "FileConfiguration";
const char q_Files[]                            = "Files";
const char _Filter[]                            = "Filter";
const char _Globals[]                           = "Globals";
const char _ItemGroup[]                         = "ItemGroup";
const char _Link[]                              = "Link";
const char _Midl[]                              = "Midl";
const char _Platform[]                          = "Platform";
const char _Platforms[]                         = "Platforms";
const char _ResourceCompile[]                   = "ResourceCompile";
const char _Tool[]                              = "Tool";
const char _VisualStudioProject[]               = "VisualStudioProject";

// XML Properties ---------------------------------------------------
const char _AddModuleNamesToAssembly[]          = "AddModuleNamesToAssembly";
const char _AdditionalDependencies[]            = "AdditionalDependencies";
const char _AdditionalFiles[]                   = "AdditionalFiles";
const char _AdditionalIncludeDirectories[]      = "AdditionalIncludeDirectories";
const char _AdditionalLibraryDirectories[]      = "AdditionalLibraryDirectories";
const char _AdditionalManifestDependencies[]    = "AdditionalManifestDependencies";
const char _AdditionalOptions[]                 = "AdditionalOptions";
const char _AdditionalUsingDirectories[]        = "AdditionalUsingDirectories";
const char _AllowIsolation[]                    = "AllowIsolation";
const char _AlwaysAppend[]                      = "AlwaysAppend";
const char _ApplicationConfigurationMode[]      = "ApplicationConfigurationMode";
const char _AssemblerListingLocation[]          = "AssemblerListingLocation";
const char _AssemblerOutput[]                   = "AssemblerOutput";
const char _AssemblyDebug[]                     = "AssemblyDebug";
const char _AssemblyLinkResource[]              = "AssemblyLinkResource";
const char _ATLMinimizesCRunTimeLibraryUsage[]  = "ATLMinimizesCRunTimeLibraryUsage";
const char _BaseAddress[]                       = "BaseAddress";
const char _BasicRuntimeChecks[]                = "BasicRuntimeChecks";
const char _BrowseInformation[]                 = "BrowseInformation";
const char _BrowseInformationFile[]             = "BrowseInformationFile";
const char _BufferSecurityCheck[]               = "BufferSecurityCheck";
const char _BuildBrowserInformation[]           = "BuildBrowserInformation";
const char _CallingConvention[]                 = "CallingConvention";
const char _CharacterSet[]                      = "CharacterSet";
const char _ClientStubFile[]                    = "ClientStubFile";
const char _CLRImageType[]                      = "CLRImageType";
const char _CLRSupportLastError[]               = "CLRSupportLastError";
const char _CLRThreadAttribute[]                = "CLRThreadAttribute";
const char _CLRUnmanagedCodeCheck[]             = "CLRUnmanagedCodeCheck";
const char _Command[]                           = "Command";
const char _CommandLine[]                       = "CommandLine";
const char _CompileAs[]                         = "CompileAs";
const char _CompileAsManaged[]                  = "CompileAsManaged";
const char _CompileForArchitecture[]            = "CompileForArchitecture";
const char _CompileOnly[]                       = "CompileOnly";
const char _ConfigurationType[]                 = "ConfigurationType";
const char _CPreprocessOptions[]                = "CPreprocessOptions";
const char _CreateHotpatchableImage[]           = "CreateHotpatchableImage";
const char _CreateHotPatchableImage[]           = "CreateHotPatchableImage";
const char _Culture[]                           = "Culture";
const char _DataExecutionPrevention[]           = "DataExecutionPrevention";
const char _DebugInformationFormat[]            = "DebugInformationFormat";
const char _DefaultCharIsUnsigned[]             = "DefaultCharIsUnsigned";
const char _DefaultCharType[]                   = "DefaultCharType";
const char _DelayLoadDLLs[]                     = "DelayLoadDLLs";
const char _DelaySign[]                         = "DelaySign";
const char _DeleteExtensionsOnClean[]           = "DeleteExtensionsOnClean";
const char _Description[]                       = "Description";
const char _Detect64BitPortabilityProblems[]    = "Detect64BitPortabilityProblems";
const char _DisableLanguageExtensions[]         = "DisableLanguageExtensions";
const char _DisableSpecificWarnings[]           = "DisableSpecificWarnings";
const char _DisplayLibrary[]                    = "DisplayLibrary";
const char _DLLDataFileName[]                   = "DLLDataFileName";
const char _Driver[]                            = "Driver";
const char _EmbedManagedResourceFile[]          = "EmbedManagedResourceFile";
const char _EnableCOMDATFolding[]               = "EnableCOMDATFolding";
const char _EnableUAC[]                         = "EnableUAC";
const char _EnableErrorChecks[]                 = "EnableErrorChecks";
const char _EnableEnhancedInstructionSet[]      = "EnableEnhancedInstructionSet";
const char _EnableFiberSafeOptimizations[]      = "EnableFiberSafeOptimizations";
const char _EnableFunctionLevelLinking[]        = "EnableFunctionLevelLinking";
const char _EnableIntrinsicFunctions[]          = "EnableIntrinsicFunctions";
const char _EnablePREfast[]                     = "EnablePREfast";
const char _EntryPointSymbol[]                  = "EntryPointSymbol";
const char _ErrorCheckAllocations[]             = "ErrorCheckAllocations";
const char _ErrorCheckBounds[]                  = "ErrorCheckBounds";
const char _ErrorCheckEnumRange[]               = "ErrorCheckEnumRange";
const char _ErrorCheckRefPointers[]             = "ErrorCheckRefPointers";
const char _ErrorCheckStubData[]                = "ErrorCheckStubData";
const char _ErrorReporting[]                    = "ErrorReporting";
const char _ExceptionHandling[]                 = "ExceptionHandling";
const char _ExcludedFromBuild[]                 = "ExcludedFromBuild";
const char _ExpandAttributedSource[]            = "ExpandAttributedSource";
const char _ExportNamedFunctions[]              = "ExportNamedFunctions";
const char _FavorSizeOrSpeed[]                  = "FavorSizeOrSpeed";
const char _FixedBaseAddress[]                  = "FixedBaseAddress";
const char _FloatingPointModel[]                = "FloatingPointModel";
const char _FloatingPointExceptions[]           = "FloatingPointExceptions";
const char _ForceConformanceInForLoopScope[]    = "ForceConformanceInForLoopScope";
const char _ForceFileOutput[]                   = "ForceFileOutput";
const char _ForceSymbolReferences[]             = "ForceSymbolReferences";
const char _ForcedIncludeFiles[]                = "ForcedIncludeFiles";
const char _ForcedUsingFiles[]                  = "ForcedUsingFiles";
const char _FullIncludePath[]                   = "FullIncludePath";
const char _FunctionLevelLinking[]              = "FunctionLevelLinking";
const char _FunctionOrder[]                     = "FunctionOrder";
const char _GenerateClientFiles[]               = "GenerateClientFiles";
const char _GenerateDebugInformation[]          = "GenerateDebugInformation";
const char _GenerateManifest[]                  = "GenerateManifest";
const char _GenerateMapFile[]                   = "GenerateMapFile";
const char _GeneratePreprocessedFile[]          = "GeneratePreprocessedFile";
const char _GenerateServerFiles[]               = "GenerateServerFiles";
const char _GenerateStublessProxies[]           = "GenerateStublessProxies";
const char _GenerateTypeLibrary[]               = "GenerateTypeLibrary";
const char _GenerateXMLDocumentationFiles[]     = "GenerateXMLDocumentationFiles";
const char _GlobalOptimizations[]               = "GlobalOptimizations";
const char _HeaderFileName[]                    = "HeaderFileName";
const char _HeapCommitSize[]                    = "HeapCommitSize";
const char _HeapReserveSize[]                   = "HeapReserveSize";
const char _IgnoreAllDefaultLibraries[]         = "IgnoreAllDefaultLibraries";
const char _IgnoreDefaultLibraryNames[]         = "IgnoreDefaultLibraryNames";
const char _IgnoreEmbeddedIDL[]                 = "IgnoreEmbeddedIDL";
const char _IgnoreImportLibrary[]               = "IgnoreImportLibrary";
const char _IgnoreSpecificDefaultLibraries[]    = "IgnoreSpecificDefaultLibraries";
const char _IgnoreStandardIncludePath[]         = "IgnoreStandardIncludePath";
const char _ImageHasSafeExceptionHandlers[]     = "ImageHasSafeExceptionHandlers";
const char _ImportLibrary[]                     = "ImportLibrary";
const char _ImproveFloatingPointConsistency[]   = "ImproveFloatingPointConsistency";
const char _InlineFunctionExpansion[]           = "InlineFunctionExpansion";
const char _IntrinsicFunctions[]                = "IntrinsicFunctions";
const char _InterfaceIdentifierFileName[]       = "InterfaceIdentifierFileName";
const char _IntermediateDirectory[]             = "IntermediateDirectory";
const char _InterworkCalls[]                    = "InterworkCalls";
const char _KeyContainer[]                      = "KeyContainer";
const char _KeyFile[]                           = "KeyFile";
const char _Keyword[]                           = "Keyword";
const char _KeepComments[]                      = "KeepComments";
const char _LargeAddressAware[]                 = "LargeAddressAware";
const char _LinkDLL[]                           = "LinkDLL";
const char _LinkErrorReporting[]                = "LinkErrorReporting";
const char _LinkIncremental[]                   = "LinkIncremental";
const char _LinkStatus[]                        = "LinkStatus";
const char _LinkTimeCodeGeneration[]            = "LinkTimeCodeGeneration";
const char _LinkToManagedResourceFile[]         = "LinkToManagedResourceFile";
const char _LocaleID[]                          = "LocaleID";
const char _ManifestFile[]                      = "ManifestFile";
const char _MapExports[]                        = "MapExports";
const char _MapFileName[]                       = "MapFileName";
const char _MapLines[]                          = "MapLines ";
const char _MergedIDLBaseFileName[]             = "MergedIDLBaseFileName";
const char _MergeSections[]                     = "MergeSections";
const char _Message[]                           = "Message";
const char _MidlCommandFile[]                   = "MidlCommandFile";
const char _MinimalRebuild[]                    = "MinimalRebuild";
const char _MkTypLibCompatible[]                = "MkTypLibCompatible";
const char _ModuleDefinitionFile[]              = "ModuleDefinitionFile";
const char _MSDOSStubFileName[]                 = "MSDOSStubFileName";
const char _MultiProcessorCompilation[]         = "MultiProcessorCompilation";
const char _Name[]                              = "Name";
const char _NoEntryPoint[]                      = "NoEntryPoint";
const char _NullTerminateStrings[]              = "NullTerminateStrings";
const char _ObjectFile[]                        = "ObjectFile";
const char _ObjectFiles[]                       = "ObjectFiles";
const char _ObjectFileName[]                    = "ObjectFileName";
const char _OmitDefaultLibName[]                = "OmitDefaultLibName";
const char _OmitFramePointers[]                 = "OmitFramePointers";
const char _OpenMP[]                            = "OpenMP";
const char _OpenMPSupport[]                     = "OpenMPSupport";
const char _Optimization[]                      = "Optimization";
const char _OptimizeForProcessor[]              = "OptimizeForProcessor";
const char _OptimizeForWindows98[]              = "OptimizeForWindows98";
const char _OptimizeForWindowsApplication[]     = "OptimizeForWindowsApplication";
const char _OptimizeReferences[]                = "OptimizeReferences";
const char _OutputDirectory[]                   = "OutputDirectory";
const char _OutputFile[]                        = "OutputFile";
const char _Outputs[]                           = "Outputs";
const char _ParseFiles[]                        = "ParseFiles";
const char _Path[]                              = "Path";
const char _PrecompiledHeader[]                 = "PrecompiledHeader";
const char _PrecompiledHeaderFile[]             = "PrecompiledHeaderFile";
const char _PrecompiledHeaderOutputFile[]       = "PrecompiledHeaderOutputFile";
const char _PrecompiledHeaderThrough[]          = "PrecompiledHeaderThrough";
const char _PreprocessorDefinitions[]           = "PreprocessorDefinitions";
const char _PreprocessKeepComments[]            = "PreprocessKeepComments";
const char _PreprocessOutputPath[]              = "PreprocessOutputPath";
const char _PreprocessSuppressLineNumbers[]     = "PreprocessSuppressLineNumbers";
const char _PreprocessToFile[]                  = "PreprocessToFile";
const char _PreventDllBinding[]                 = "PreventDllBinding";
const char _PrimaryOutput[]                     = "PrimaryOutput";
const char _Profile[]                           = "Profile";
const char _ProfileGuidedDatabase[]             = "ProfileGuidedDatabase";
const char _ProjectGUID[]                       = "ProjectGUID";
const char _ProcessorNumber[]                   = "ProcessorNumber";
const char _ProjectType[]                       = "ProjectType";
const char _ProgramDatabase[]                   = "ProgramDatabase";
const char _ProgramDataBaseFileName[]           = "ProgramDataBaseFileName";
const char _ProgramDatabaseFile[]               = "ProgramDatabaseFile";
const char _ProxyFileName[]                     = "ProxyFileName";
const char _RandomizedBaseAddress[]             = "RandomizedBaseAddress";
const char _RedirectOutputAndErrors[]           = "RedirectOutputAndErrors";
const char _RegisterOutput[]                    = "RegisterOutput";
const char _RelativePath[]                      = "RelativePath";
const char _RemoteDirectory[]                   = "RemoteDirectory";
const char _RemoveObjects[]                     = "RemoveObjects";
const char _ResourceOnlyDLL[]                   = "ResourceOnlyDLL";
const char _ResourceOutputFileName[]            = "ResourceOutputFileName";
const char _RuntimeLibrary[]                    = "RuntimeLibrary";
const char _RuntimeTypeInfo[]                   = "RuntimeTypeInfo";
const char _SccProjectName[]                    = "SccProjectName";
const char _SccLocalPath[]                      = "SccLocalPath";
const char _SectionAlignment[]                  = "SectionAlignment";
const char _ServerStubFile[]                    = "ServerStubFile";
const char _SetChecksum[]                       = "SetChecksum";
const char _ShowIncludes[]                      = "ShowIncludes";
const char _ShowProgress[]                      = "ShowProgress";
const char _SmallerTypeCheck[]                  = "SmallerTypeCheck";
const char _SpecifySectionAttributes[]          = "SpecifySectionAttributes";
const char _StackCommitSize[]                   = "StackCommitSize";
const char _StackReserveSize[]                  = "StackReserveSize";
const char _StringPooling[]                     = "StringPooling";
const char _StripPrivateSymbols[]               = "StripPrivateSymbols";
const char _StructMemberAlignment[]             = "StructMemberAlignment";
const char _SubSystem[]                         = "SubSystem";
const char _SupportNobindOfDelayLoadedDLL[]     = "SupportNobindOfDelayLoadedDLL";
const char _SupportUnloadOfDelayLoadedDLL[]     = "SupportUnloadOfDelayLoadedDLL";
const char _SuppressCompilerWarnings[]          = "SuppressCompilerWarnings";
const char _SuppressStartupBanner[]             = "SuppressStartupBanner";
const char _SwapRunFromCD[]                     = "SwapRunFromCD";
const char _SwapRunFromNet[]                    = "SwapRunFromNet";
const char _TargetEnvironment[]                 = "TargetEnvironment";
const char _TargetMachine[]                     = "TargetMachine";
const char _TerminalServerAware[]               = "TerminalServerAware";
const char _TrackerLogDirectory[]               = "TrackerLogDirectory";
const char _TreatLibWarningAsErrors[]           = "TreatLibWarningAsErrors";
const char _TreatLinkerWarningAsErrors[]        = "TreatLinkerWarningAsErrors";
const char _TreatSpecificWarningsAsErrors[]     = "TreatSpecificWarningsAsErrors";
const char _TreatWarningAsError[]               = "TreatWarningAsError";
const char _TreatWChar_tAsBuiltInType[]         = "TreatWChar_tAsBuiltInType";
const char _TurnOffAssemblyGeneration[]         = "TurnOffAssemblyGeneration";
const char _TypeLibFormat[]                     = "TypeLibFormat";
const char _TypeLibraryFile[]                   = "TypeLibraryFile";
const char _TypeLibraryName[]                   = "TypeLibraryName";
const char _TypeLibraryResourceID[]             = "TypeLibraryResourceID";
const char _UACExecutionLevel[]                 = "UACExecutionLevel";
const char _UACUIAccess[]                       = "UACUIAccess";
const char _UndefineAllPreprocessorDefinitions[]= "UndefineAllPreprocessorDefinitions";
const char _UndefinePreprocessorDefinitions[]   = "UndefinePreprocessorDefinitions";
const char _UniqueIdentifier[]                  = "UniqueIdentifier";
const char _UseFullPaths[]                      = "UseFullPaths";
const char _UseOfATL[]                          = "UseOfATL";
const char _UseOfMfc[]                          = "UseOfMfc";
const char _UsePrecompiledHeader[]              = "UsePrecompiledHeader";
const char _UseUnicodeForAssemblerListing[]     = "UseUnicodeForAssemblerListing";
const char _ValidateAllParameters[]             = "ValidateAllParameters";
const char _VCCLCompilerTool[]                  = "VCCLCompilerTool";
const char _VCLibrarianTool[]                   = "VCLibrarianTool";
const char _VCLinkerTool[]                      = "VCLinkerTool";
const char _VCCustomBuildTool[]                 = "VCCustomBuildTool";
const char _VCResourceCompilerTool[]            = "VCResourceCompilerTool";
const char _VCMIDLTool[]                        = "VCMIDLTool";
const char _Verbose[]                           = "Verbose";
const char _Version[]                           = "Version";
const char _WarnAsError[]                       = "WarnAsError";
const char _WarningLevel[]                      = "WarningLevel";
const char _WholeProgramOptimization[]          = "WholeProgramOptimization";
const char _XMLDocumentationFileName[]          = "XMLDocumentationFileName";


// XmlOutput stream functions ------------------------------
inline XmlOutput::xml_output attrTagT(const char *name, const triState v)
{
    if(v == unset)
        return noxml();
    return tagValue(name, (v == _True ? "true" : "false"));
}

inline XmlOutput::xml_output attrTagL(const char *name, qint64 v)
{
    return tagValue(name, QString::number(v));
}

/*ifNot version*/
inline XmlOutput::xml_output attrTagL(const char *name, qint64 v, qint64 ifn)
{
    if (v == ifn)
        return noxml();
    return tagValue(name, QString::number(v));
}

inline XmlOutput::xml_output attrTagS(const char *name, const QString &v)
{
    if(v.isEmpty())
        return noxml();
    return tagValue(name, v);
}


inline XmlOutput::xml_output attrTagX(const char *name, const QStringList &v, const char *s = ",")
{
    if(v.isEmpty())
        return noxml();
    QStringList temp = v;
    temp.append(QString("%(%1)").arg(name));
    return tagValue(name, temp.join(s));
}

inline XmlOutput::xml_output valueTagX(const QStringList &v, const char *s = " ")
{
    if(v.isEmpty())
        return noxml();
    return valueTag(v.join(s));
}

inline XmlOutput::xml_output valueTagDefX(const QStringList &v, const QString &tagName, const char *s = " ")
{
    if(v.isEmpty())
        return noxml();
    QStringList temp = v;
    temp.append(QString("%(%1)").arg(tagName));
    return valueTag(temp.join(s));
}

inline XmlOutput::xml_output valueTagT( const triState v)
{
    if(v == unset)
        return noxml();
    return valueTag(v == _True ? "true" : "false");
}


// VCXCLCompilerTool -------------------------------------------------
VCXCLCompilerTool::VCXCLCompilerTool()
    :   BrowseInformation(_False),
        BufferSecurityCheck(_False),
        CreateHotpatchableImage(unset),
        DisableLanguageExtensions(unset),
        EnableFiberSafeOptimizations(unset),
        EnablePREfast(unset),
        ExpandAttributedSource(unset),
        FloatingPointExceptions(unset),
        ForceConformanceInForLoopScope(unset),
        FunctionLevelLinking(unset),
        GenerateXMLDocumentationFiles(unset),
        IgnoreStandardIncludePath(unset),
        IntrinsicFunctions(unset),
        MinimalRebuild(unset),
        MultiProcessorCompilation(unset),
        OmitDefaultLibName(unset),
        OmitFramePointers(unset),
        OpenMPSupport(unset),
        PreprocessKeepComments(unset),
        PreprocessSuppressLineNumbers(unset),
        RuntimeTypeInfo(unset),
        ShowIncludes(unset),
        SmallerTypeCheck(unset),
        StringPooling(unset),
        SuppressStartupBanner(unset),
        TreatWarningAsError(unset),
        TreatWChar_tAsBuiltInType(unset),
        UndefineAllPreprocessorDefinitions(unset),
        UseFullPaths(unset),
        UseUnicodeForAssemblerListing(unset),
        WholeProgramOptimization(unset)
{
}

XmlOutput &operator<<(XmlOutput &xml, const VCXCLCompilerTool &tool)
{
    return xml
        << tag(_CLCompile)
            << attrTagX(_AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories, ";")
            << attrTagX(_AdditionalOptions, tool.AdditionalOptions, " ")
            << attrTagX(_AdditionalUsingDirectories, tool.AdditionalUsingDirectories, ";")
            << attrTagS(_AlwaysAppend, tool.AlwaysAppend)
            << attrTagS(_AssemblerListingLocation, tool.AssemblerListingLocation)
            << attrTagS(_AssemblerOutput, tool.AssemblerOutput)
            << attrTagS(_BasicRuntimeChecks, tool.BasicRuntimeChecks)
            << attrTagT(_BrowseInformation, tool.BrowseInformation)
            << attrTagS(_BrowseInformationFile, tool.BrowseInformationFile)
            << attrTagT(_BufferSecurityCheck, tool.BufferSecurityCheck)
            << attrTagS(_CallingConvention, tool.CallingConvention)
            << attrTagS(_CompileAs, tool.CompileAs)
            << attrTagS(_CompileAsManaged, tool.CompileAsManaged)
            << attrTagT(_CreateHotpatchableImage, tool.CreateHotpatchableImage)
            << attrTagS(_DebugInformationFormat, tool.DebugInformationFormat)
            << attrTagT(_DisableLanguageExtensions, tool.DisableLanguageExtensions)
            << attrTagX(_DisableSpecificWarnings, tool.DisableSpecificWarnings, ";")
            << attrTagS(_EnableEnhancedInstructionSet, tool.EnableEnhancedInstructionSet)
            << attrTagT(_EnableFiberSafeOptimizations, tool.EnableFiberSafeOptimizations)
            << attrTagT(_EnablePREfast, tool.EnablePREfast)
            << attrTagS(_ErrorReporting, tool.ErrorReporting)
            << attrTagS(_ExceptionHandling, tool.ExceptionHandling)
            << attrTagT(_ExpandAttributedSource, tool.ExpandAttributedSource)
            << attrTagS(_FavorSizeOrSpeed, tool.FavorSizeOrSpeed)
            << attrTagT(_FloatingPointExceptions, tool.FloatingPointExceptions)
            << attrTagS(_FloatingPointModel, tool.FloatingPointModel)
            << attrTagT(_ForceConformanceInForLoopScope, tool.ForceConformanceInForLoopScope)
            << attrTagX(_ForcedIncludeFiles, tool.ForcedIncludeFiles, ";")
            << attrTagX(_ForcedUsingFiles, tool.ForcedUsingFiles, ";")
            << attrTagT(_FunctionLevelLinking, tool.FunctionLevelLinking)
            << attrTagT(_GenerateXMLDocumentationFiles, tool.GenerateXMLDocumentationFiles)
            << attrTagT(_IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath)
            << attrTagS(_InlineFunctionExpansion, tool.InlineFunctionExpansion)
            << attrTagT(_IntrinsicFunctions, tool.IntrinsicFunctions)
            << attrTagT(_MinimalRebuild, tool.MinimalRebuild)
            << attrTagT(_MultiProcessorCompilation, tool.MultiProcessorCompilation)
            << attrTagS(_ObjectFileName, tool.ObjectFileName)
            << attrTagX(_ObjectFiles, tool.ObjectFiles, ";")
            << attrTagT(_OmitDefaultLibName, tool.OmitDefaultLibName)
            << attrTagT(_OmitFramePointers, tool.OmitFramePointers)
            << attrTagT(_OpenMPSupport, tool.OpenMPSupport)
            << attrTagS(_Optimization, tool.Optimization)
            << attrTagS(_PrecompiledHeader, tool.PrecompiledHeader)
            << attrTagS(_PrecompiledHeaderFile, tool.PrecompiledHeaderFile)
            << attrTagS(_PrecompiledHeaderOutputFile, tool.PrecompiledHeaderOutputFile)
            << attrTagT(_PreprocessKeepComments, tool.PreprocessKeepComments)
            << attrTagX(_PreprocessorDefinitions, tool.PreprocessorDefinitions, ";")
            << attrTagS(_PreprocessOutputPath, tool.PreprocessOutputPath)
            << attrTagT(_PreprocessSuppressLineNumbers, tool.PreprocessSuppressLineNumbers)
            << attrTagT(_PreprocessToFile, tool.PreprocessToFile)
            << attrTagS(_ProgramDataBaseFileName, tool.ProgramDataBaseFileName)
            << attrTagS(_ProcessorNumber, tool.ProcessorNumber)
            << attrTagS(_RuntimeLibrary, tool.RuntimeLibrary)
            << attrTagT(_RuntimeTypeInfo, tool.RuntimeTypeInfo)
            << attrTagT(_ShowIncludes, tool.ShowIncludes)
            << attrTagT(_SmallerTypeCheck, tool.SmallerTypeCheck)
            << attrTagT(_StringPooling, tool.StringPooling)
            << attrTagS(_StructMemberAlignment, tool.StructMemberAlignment)
            << attrTagT(_SuppressStartupBanner, tool.SuppressStartupBanner)
            << attrTagS(_TreatSpecificWarningsAsErrors, tool.TreatSpecificWarningsAsErrors)
            << attrTagT(_TreatWarningAsError, tool.TreatWarningAsError)
            << attrTagT(_TreatWChar_tAsBuiltInType, tool.TreatWChar_tAsBuiltInType)
            << attrTagT(_UndefineAllPreprocessorDefinitions, tool.UndefineAllPreprocessorDefinitions)
            << attrTagX(_UndefinePreprocessorDefinitions, tool.UndefinePreprocessorDefinitions, ";")
            << attrTagT(_UseFullPaths, tool.UseFullPaths)
            << attrTagT(_UseUnicodeForAssemblerListing, tool.UseUnicodeForAssemblerListing)
            << attrTagS(_WarningLevel, tool.WarningLevel)
            << attrTagT(_WholeProgramOptimization, tool.WholeProgramOptimization)
            << attrTagS(_XMLDocumentationFileName, tool.XMLDocumentationFileName)
        << closetag(_CLCompile);
}

bool VCXCLCompilerTool::parseOption(const char* option)
{
    // skip index 0 ('/' or '-')
    char first  = option[1];
    char second = option[2];
    char third  = option[3];
    char fourth = option[4];
    bool found = true;

    switch (first) {
    case '?':
        qWarning("Generator: Option '/?' : MSVC.NET projects do not support outputting help info");
        found = false;
        break;
    case '@':
        qWarning("Generator: Option '/@': MSVC.NET projects do not support the use of a response file");
        found = false;
        break;
    case 'l':
        qWarning("Generator: Option '/link': qmake generator does not support passing link options through the compiler tool");
        found = false;
        break;
    case 'A':
        if(second != 'I') {
            found = false;
            break;
        }
        AdditionalUsingDirectories += option+3;
        break;
    case 'C':
        PreprocessKeepComments = _True;
        break;
    case 'D':
        PreprocessorDefinitions += option+2;
        break;
    case 'E':
        if(second == 'H') {
            QString opt(option);
            if (opt.endsWith("EHa"))
                ExceptionHandling = "Async";
            else if (opt.endsWith("EHsc"))
                ExceptionHandling = "Sync";
            else if (opt.endsWith("EHs"))
                ExceptionHandling = "SyncCThrow";
            else {
                ExceptionHandling = "false";
            }
            break;
        }else if(second == 'P') {
            PreprocessSuppressLineNumbers = _True;
        }
        found = false;
        break;
    case 'F':
        if(second <= '9' && second >= '0') {
            AdditionalOptions += option;
            break;
        } else {
            switch (second) {
            case 'A':
                if(third == 'c') {
                    AssemblerOutput = "AssemblyAndMachineCode";
                    if(fourth == 's')
                        AssemblerOutput = "All";
                } else if(third == 's') {
                    AssemblerOutput = "AssemblyAndSourceCode";
                } else if(third == 'u') {
                    UseUnicodeForAssemblerListing = _True;
                } else {
                    AssemblerOutput = "AssemblyCode";
                }
                break;
            case 'a':
                AssemblerListingLocation = option+3;
                break;
            case 'C':
                UseFullPaths = _True;
                break;
            case 'd':
                ProgramDataBaseFileName += option+3;
            case 'I':
                ForcedIncludeFiles += option+3;
                break;
            case 'i':
                PreprocessOutputPath += option+3;
                break;
            case 'm':
                AdditionalOptions += option;
                break;
            case 'R':
                BrowseInformation = _True;
                BrowseInformationFile = option+3;
                break;
            case 'r':
                BrowseInformation = _True;
                BrowseInformationFile = option+3;
                break;
            case 'U':
                ForcedUsingFiles += option+3;
                break;
            case 'o':
                ObjectFileName = option+3;
                break;
            case 'p':
                PrecompiledHeaderOutputFile = option+3;
                break;
            case 'x':
                ExpandAttributedSource = _True;
                break;
            default:
                found = false;
                break;
            }
        }
        break;
    case 'G':
        switch (second) {
        case 'F':
            StringPooling = _True;
            break;
        case 'L':
            WholeProgramOptimization = _True;
            if(third == '-')
                WholeProgramOptimization = _False;
            break;
        case 'R':
            RuntimeTypeInfo = _True;
            if(third == '-')
                RuntimeTypeInfo = _False;
            break;
        case 'S':
            BufferSecurityCheck = _True;
            if(third == '-')
                BufferSecurityCheck = _False;
            break;
        case 'T':
            EnableFiberSafeOptimizations = _True;
            break;
        case 'd':
            CallingConvention = "Cdecl";
            break;
        case 'm':
            MinimalRebuild = _True;
            if(third == '-')
                MinimalRebuild = _False;
            break;
        case 'r':
            CallingConvention = "FastCall";
            break;
        case 'y':
            FunctionLevelLinking = _True;
            break;
        case 'z':
            CallingConvention = "StdCall";
            break;
        default:
            found = false;
            break;
        }
        break;
    case 'H':
        AdditionalOptions += option;
        break;
    case 'I':
        AdditionalIncludeDirectories += option+2;
        break;
    case 'L':
        if(second == 'D') {
            AdditionalOptions += option;
            break;
        }
        found = false;
        break;
    case 'M':
        if(second == 'D') {
            RuntimeLibrary = "MultiThreadedDLL";
            if(third == 'd')
                RuntimeLibrary = "MultiThreadedDebugDLL";
            break;
        } else if(second == 'P') {
            MultiProcessorCompilation = _True;
            ProcessorNumber = option+3;
            break;
        } else if(second == 'T') {
            RuntimeLibrary = "MultiThreaded";
            if(third == 'd')
                RuntimeLibrary = "MultiThreadedDebug";
            break;
        }
        found = false;
        break;
    case 'O':
        switch (second) {
        case '1':
            Optimization = "MinSpace";
            break;
        case '2':
            Optimization = "MaxSpeed";
            break;
        case 'b':
            if(third == '0')
                InlineFunctionExpansion = "Disabled";
            else if(third == '1')
                InlineFunctionExpansion = "OnlyExplicitInline";
            else if(third == '2')
                InlineFunctionExpansion = "AnySuitable";
            else
                found = false;
            break;
        case 'd':
            Optimization = "Disabled";
            break;
        case 'i':
            IntrinsicFunctions = _True;
            break;
        case 'p':
            if(third == 'e')
                OpenMPSupport = _True;
            else
                found = false;
            break;
        case 's':
            FavorSizeOrSpeed = "Size";
            break;
        case 't':
            FavorSizeOrSpeed = "Speed";
            break;
        case 'x':
            Optimization = "Full";
            break;
        case 'y':
            OmitFramePointers = _True;
            if(third == '-')
                OmitFramePointers = _False;
            break;
        default:
            found = false;
            break;
        }
        break;
    case 'P':
        PreprocessToFile = _True;
        break;
    case 'Q':
        if(second == 'I') {
            AdditionalOptions += option;
            break;
        }
        found = false;
        break;
    case 'R':
        if(second == 'T' && third == 'C') {
            if(fourth == '1')
                BasicRuntimeChecks = "EnableFastChecks";
            else if(fourth == 'c')
                SmallerTypeCheck = _True;
            else if(fourth == 's')
                BasicRuntimeChecks = "StackFrameRuntimeCheck";
            else if(fourth == 'u')
                BasicRuntimeChecks = "UninitializedLocalUsageCheck";
            else
                found = false; break;
        }
        break;
    case 'T':
        if(second == 'C') {
            CompileAs = "CompileAsC";
        } else if(second == 'P') {
            CompileAs = "CompileAsCpp";
        } else {
            qWarning("Generator: Options '/Tp<filename>' and '/Tc<filename>' are not supported by qmake");
            found = false; break;
        }
        break;
    case 'U':
        UndefinePreprocessorDefinitions += option+2;
        break;
    case 'V':
        AdditionalOptions += option;
        break;
    case 'W':
        switch (second) {
        case 'a':
            WarningLevel = "EnableAllWarnings";
            break;
        case '4':
            WarningLevel = "Level4";
            break;
        case '3':
            WarningLevel = "Level3";
            break;
        case '2':
            WarningLevel = "Level2";
            break;
        case '1':
            WarningLevel = "Level1";
            break;
        case '0':
            WarningLevel = "TurnOffAllWarnings";
            break;
        case 'L':
            AdditionalOptions += option;
            break;
        case 'X':
            TreatWarningAsError = _True;
            break;
        case 'p':
            if(third == '6' && fourth == '4') {
                // Deprecated for VS2010 but can be used under Additional Options.
                AdditionalOptions += option;
                break;
            }
            // Fallthrough
        default:
            found = false; break;
        }
        break;
    case 'X':
        IgnoreStandardIncludePath = _True;
        break;
    case 'Y':
        switch (second) {
        case '\0':
        case '-':
            AdditionalOptions += option;
            break;
        case 'c':
            PrecompiledHeader = "Create";
            PrecompiledHeaderFile = option+3;
            break;
        case 'd':
        case 'l':
            AdditionalOptions += option;
            break;
        case 'u':
            PrecompiledHeader = "Use";
            PrecompiledHeaderFile = option+3;
            break;
        default:
            found = false; break;
        }
        break;
    case 'Z':
        switch (second) {
        case '7':
            DebugInformationFormat = "OldStyle";
            break;
        case 'I':
            DebugInformationFormat = "EditAndContinue";
            break;
        case 'i':
            DebugInformationFormat = "ProgramDatabase";
            break;
        case 'l':
            OmitDefaultLibName = _True;
            break;
        case 'a':
            DisableLanguageExtensions = _True;
            break;
        case 'e':
            DisableLanguageExtensions = _False;
            break;
        case 'c':
            if(third == ':') {
                const char *c = option + 4;
                // Go to the end of the option
                while ( *c != '\0' && *c != ' ' && *c != '-')
                    ++c;
                if(fourth == 'f')
                    ForceConformanceInForLoopScope = ((*c) == '-' ? _False : _True);
                else if(fourth == 'w')
                    TreatWChar_tAsBuiltInType = ((*c) == '-' ? _False : _True);
                else
                    found = false;
            } else {
                found = false; break;
            }
            break;
        case 'g':
        case 'm':
        case 's':
            AdditionalOptions += option;
            break;
        case 'p':
            switch (third)
            {
            case '\0':
            case '1':
                StructMemberAlignment = "1Byte";
                if(fourth == '6')
                    StructMemberAlignment = "16Bytes";
                break;
            case '2':
                StructMemberAlignment = "2Bytes";
                break;
            case '4':
                StructMemberAlignment = "4Bytes";
                break;
            case '8':
                StructMemberAlignment = "8Bytes";
                break;
            default:
                found = false; break;
            }
            break;
        default:
            found = false; break;
        }
        break;
    case 'a':
        if (second == 'r' && third == 'c' && fourth == 'h') {
            if (option[5] == ':') {
                const char *o = option;
                if (o[6] == 'S' && o[7] == 'S' && o[8] == 'E') {
                    EnableEnhancedInstructionSet = o[9] == '2' ? "StreamingSIMDExtensions2" : "StreamingSIMDExtensions";
                    break;
                }
            }
        } else if (second == 'n' && third == 'a' && fourth == 'l') {
            EnablePREfast = _True;
            break;
        }
        found = false;
        break;
    case 'b':   // see http://msdn.microsoft.com/en-us/library/fwkeyyhe%28VS.100%29.aspx
        if (second == 'i' && third == 'g' && fourth == 'o') {
            const char *o = option;
            if (o[5] == 'b' && o[6] == 'j') {
                AdditionalOptions += option;
                break;
            }
        }
        found = false;
        break;
    case 'c':
        if(second == 'l') {
            if(*(option+5) == 'p') {
                CompileAsManaged = "Pure";
            } else if(*(option+5) == 's') {
                CompileAsManaged = "Safe";
            } else if(*(option+5) == 'o') {
                CompileAsManaged = "OldSyntax";
            } else {
                CompileAsManaged = "true";
            }
        } else {
            found = false;
            break;
        }
        break;
    case 'd':
        if(second != 'o' && third == 'c') {
            GenerateXMLDocumentationFiles = _True;
            XMLDocumentationFileName += option+4;
            break;
        }
        found = false;
        break;
    case 'e':
        if (second == 'r' && third == 'r' && fourth == 'o') {
            if (option[12] == ':') {
                if ( option[13] == 'n') {
                    ErrorReporting = "None";
                } else if (option[13] == 'p') {
                    ErrorReporting = "Prompt";
                } else if (option[13] == 'q') {
                    ErrorReporting = "Queue";
                } else if (option[13] == 's') {
                    ErrorReporting = "Send";
                } else {
                    found = false;
                }
                break;
            }
        }
        found = false;
        break;
    case 'f':
        if(second == 'p' && third == ':') {
            // Go to the end of the option
            const char *c = option + 4;
            while (*c != '\0' && *c != ' ' && *c != '-')
                ++c;
            switch (fourth) {
            case 'e':
                FloatingPointExceptions = ((*c) == '-' ? _False : _True);
                break;
            case 'f':
                FloatingPointModel = "Fast";
                break;
            case 'p':
                FloatingPointModel = "Precise";
                break;
            case 's':
                FloatingPointModel = "Strict";
                break;
            default:
                found = false;
                break;
            }
        }
        break;
    case 'h':
        if(second == 'o' && third == 't' && fourth == 'p') {
            CreateHotpatchableImage = _True;
            break;
        }
        qWarning("Generator: Option '/help': MSVC.NET projects do not support outputting help info");
        found = false;
        break;
    case 'n':
        if(second == 'o' && third == 'l' && fourth == 'o') {
            SuppressStartupBanner = _True;
            break;
        }
        found = false;
        break;
    case 'o':
        if (second == 'p' && third == 'e' && fourth == 'n') {
            OpenMPSupport = _True;
            break;
        }
        found = false;
        break;
    case 's':
        if(second == 'h' && third == 'o' && fourth == 'w') {
            ShowIncludes = _True;
            break;
        }
        found = false;
        break;
    case 'u':
        UndefineAllPreprocessorDefinitions = _True;
        break;
    case 'v':
        if(second == 'd' || second == 'm') {
            AdditionalOptions += option;
            break;
        }
        found = false;
        break;
    case 'w':
        switch (second) {
        case 'd':
            DisableSpecificWarnings += option+3;
            break;
        case 'e':
            TreatSpecificWarningsAsErrors = option+3;
            break;
        default:
            AdditionalOptions += option;
        }
        break;
    default:
        AdditionalOptions += option;
        break;
    }
    if(!found) {
        warn_msg(WarnLogic, "Could not parse Compiler option: %s, added as AdditionalOption", option);
        AdditionalOptions += option;
    }
    return true;
}

// VCLinkerTool -----------------------------------------------------
VCXLinkerTool::VCXLinkerTool()
    :        AllowIsolation(unset),
        AssemblyDebug(unset),
        DataExecutionPrevention(unset),
        DelaySign(unset),
        EnableCOMDATFolding(unset),
        EnableUAC(unset),
        FixedBaseAddress(unset),
        GenerateDebugInformation(unset),
        GenerateManifest(unset),
        GenerateMapFile(unset),
        HeapCommitSize(-1),
        HeapReserveSize(-1),
        IgnoreAllDefaultLibraries(unset),
        IgnoreEmbeddedIDL(unset),
        IgnoreImportLibrary(_True),
        ImageHasSafeExceptionHandlers(unset),
        LargeAddressAware(unset),
        LinkDLL(unset),
        LinkIncremental(unset),
        LinkStatus(unset),
        MapExports(unset),
        NoEntryPoint(unset),
        OptimizeReferences(unset),
        PreventDllBinding(unset),
        RandomizedBaseAddress(unset),
        RegisterOutput(unset),
        SectionAlignment(-1),
        SetChecksum(unset),
        //StackCommitSize(-1),
        //StackReserveSize(-1),
        SupportNobindOfDelayLoadedDLL(unset),
        SupportUnloadOfDelayLoadedDLL(unset),
        SuppressStartupBanner(unset),
        SwapRunFromCD(unset),
        SwapRunFromNet(unset),
        TerminalServerAware(unset),
        TreatLinkerWarningAsErrors(unset),
        TurnOffAssemblyGeneration(unset),
        TypeLibraryResourceID(0),
        UACUIAccess(unset)
{
}

XmlOutput &operator<<(XmlOutput &xml, const VCXLinkerTool &tool)
{
    return xml
        << tag(_Link)
            << attrTagX(_AdditionalDependencies, tool.AdditionalDependencies, ";")
            << attrTagX(_AdditionalLibraryDirectories, tool.AdditionalLibraryDirectories, ";")
            << attrTagX(_AdditionalManifestDependencies, tool.AdditionalManifestDependencies, ";")
            << attrTagX(_AdditionalOptions, tool.AdditionalOptions, " ")
            << attrTagX(_AddModuleNamesToAssembly, tool.AddModuleNamesToAssembly, ";")
            << attrTagT(_AllowIsolation, tool.AllowIsolation)
            << attrTagT(_AssemblyDebug, tool.AssemblyDebug)
            << attrTagX(_AssemblyLinkResource, tool.AssemblyLinkResource, ";")
            << attrTagS(_BaseAddress, tool.BaseAddress)
            << attrTagS(_CLRImageType, tool.CLRImageType)
            << attrTagS(_CLRSupportLastError, tool.CLRSupportLastError)
            << attrTagS(_CLRThreadAttribute, tool.CLRThreadAttribute)
            << attrTagS(_CLRUnmanagedCodeCheck, tool.CLRUnmanagedCodeCheck)
            << attrTagS(_CreateHotPatchableImage, tool.CreateHotPatchableImage)
            << attrTagT(_DataExecutionPrevention, tool.DataExecutionPrevention)
            << attrTagX(_DelayLoadDLLs, tool.DelayLoadDLLs, ";")
            << attrTagT(_DelaySign, tool.DelaySign)
            << attrTagS(_Driver, tool.Driver)
            << attrTagX(_EmbedManagedResourceFile, tool.EmbedManagedResourceFile, ";")
            << attrTagT(_EnableCOMDATFolding, tool.EnableCOMDATFolding)
            << attrTagT(_EnableUAC, tool.EnableUAC)
            << attrTagS(_EntryPointSymbol, tool.EntryPointSymbol)
            << attrTagT(_FixedBaseAddress, tool.FixedBaseAddress)
            << attrTagS(_ForceFileOutput, tool.ForceFileOutput)
            << attrTagX(_ForceSymbolReferences, tool.ForceSymbolReferences, ";")
            << attrTagS(_FunctionOrder, tool.FunctionOrder)
            << attrTagT(_GenerateDebugInformation, tool.GenerateDebugInformation)
            << attrTagT(_GenerateManifest, tool.GenerateManifest)
            << attrTagT(_GenerateMapFile, tool.GenerateMapFile)
            << attrTagL(_HeapCommitSize, tool.HeapCommitSize, /*ifNot*/ -1)
            << attrTagL(_HeapReserveSize, tool.HeapReserveSize, /*ifNot*/ -1)
            << attrTagT(_IgnoreAllDefaultLibraries, tool.IgnoreAllDefaultLibraries)
            << attrTagT(_IgnoreEmbeddedIDL, tool.IgnoreEmbeddedIDL)
            << attrTagT(_IgnoreImportLibrary, tool.IgnoreImportLibrary)
            << attrTagX(_IgnoreSpecificDefaultLibraries, tool.IgnoreSpecificDefaultLibraries, ";")
            << attrTagT(_ImageHasSafeExceptionHandlers, tool.ImageHasSafeExceptionHandlers)
            << attrTagS(_ImportLibrary, tool.ImportLibrary)
            << attrTagS(_KeyContainer, tool.KeyContainer)
            << attrTagS(_KeyFile, tool.KeyFile)
            << attrTagT(_LargeAddressAware, tool.LargeAddressAware)
            << attrTagT(_LinkDLL, tool.LinkDLL)
            << attrTagS(_LinkErrorReporting, tool.LinkErrorReporting)
            << attrTagT(_LinkIncremental, tool.LinkIncremental)
            << attrTagT(_LinkStatus, tool.LinkStatus)
            << attrTagS(_LinkTimeCodeGeneration, tool.LinkTimeCodeGeneration)
            << attrTagS(_ManifestFile, tool.ManifestFile)
            << attrTagT(_MapExports, tool.MapExports)
            << attrTagS(_MapFileName, tool.MapFileName)
            << attrTagS(_MergedIDLBaseFileName, tool.MergedIDLBaseFileName)
            << attrTagS(_MergeSections, tool.MergeSections)
            << attrTagS(_MidlCommandFile, tool.MidlCommandFile)
            << attrTagS(_ModuleDefinitionFile, tool.ModuleDefinitionFile)
            << attrTagS(_MSDOSStubFileName, tool.MSDOSStubFileName)
            << attrTagT(_NoEntryPoint, tool.NoEntryPoint)
            << attrTagT(_OptimizeReferences, tool.OptimizeReferences)
            << attrTagS(_OutputFile, tool.OutputFile)
            << attrTagT(_PreventDllBinding, tool.PreventDllBinding)
            << attrTagS(_Profile, tool.Profile)
            << attrTagS(_ProfileGuidedDatabase, tool.ProfileGuidedDatabase)
            << attrTagS(_ProgramDatabaseFile, tool.ProgramDatabaseFile)
            << attrTagT(_RandomizedBaseAddress, tool.RandomizedBaseAddress)
            << attrTagT(_RegisterOutput, tool.RegisterOutput)
            << attrTagL(_SectionAlignment, tool.SectionAlignment, /*ifNot*/ -1)
            << attrTagT(_SetChecksum, tool.SetChecksum)
            << attrTagS(_ShowProgress, tool.ShowProgress)
            << attrTagS(_SpecifySectionAttributes, tool.SpecifySectionAttributes)
            << attrTagS(_StackCommitSize, tool.StackCommitSize)
            << attrTagS(_StackReserveSize, tool.StackReserveSize)
            << attrTagS(_StripPrivateSymbols, tool.StripPrivateSymbols)
            << attrTagS(_SubSystem, tool.SubSystem)
            << attrTagT(_SupportNobindOfDelayLoadedDLL, tool.SupportNobindOfDelayLoadedDLL)
            << attrTagT(_SupportUnloadOfDelayLoadedDLL, tool.SupportUnloadOfDelayLoadedDLL)
            << attrTagT(_SuppressStartupBanner, tool.SuppressStartupBanner)
            << attrTagT(_SwapRunFromCD, tool.SwapRunFromCD)
            << attrTagT(_SwapRunFromNet, tool.SwapRunFromNet)
            << attrTagS(_TargetMachine, tool.TargetMachine)
            << attrTagT(_TerminalServerAware, tool.TerminalServerAware)
            << attrTagT(_TreatLinkerWarningAsErrors, tool.TreatLinkerWarningAsErrors)
            << attrTagT(_TurnOffAssemblyGeneration, tool.TurnOffAssemblyGeneration)
            << attrTagS(_TypeLibraryFile, tool.TypeLibraryFile)
            << attrTagL(_TypeLibraryResourceID, tool.TypeLibraryResourceID, /*ifNot*/ 0)
            << attrTagS(_UACExecutionLevel, tool.UACExecutionLevel)
            << attrTagT(_UACUIAccess, tool.UACUIAccess)
            << attrTagS(_Version, tool.Version)
        << closetag(_Link);
}

// Hashing routine to do fast option lookups ----
// Slightly rewritten to stop on ':' ',' and '\0'
// Original routine in qtranslator.cpp ----------
static uint elfHash(const char* name)
{
    const uchar *k;
    uint h = 0;
    uint g;

    if(name) {
        k = (const uchar *) name;
        while((*k) &&
                (*k)!= ':' &&
                (*k)!=',' &&
                (*k)!=' ') {
            h = (h << 4) + *k++;
            if((g = (h & 0xf0000000)) != 0)
                h ^= g >> 24;
            h &= ~g;
        }
    }
    if(!h)
        h = 1;
    return h;
}

//#define USE_DISPLAY_HASH
#ifdef USE_DISPLAY_HASH
static void displayHash(const char* str)
{
    printf("case 0x%07x: // %s\n    break;\n", elfHash(str), str);
}
#endif

bool VCXLinkerTool::parseOption(const char* option)
{
#ifdef USE_DISPLAY_HASH
    // Main options
    displayHash("/ALIGN"); displayHash("/ALLOWBIND"); displayHash("/ASSEMBLYMODULE");
    displayHash("/ASSEMBLYRESOURCE"); displayHash("/BASE"); displayHash("/DEBUG");
    displayHash("/DEF"); displayHash("/DEFAULTLIB"); displayHash("/DELAY");
    displayHash("/DELAYLOAD"); displayHash("/DLL"); displayHash("/DRIVER");
    displayHash("/ENTRY"); displayHash("/EXETYPE"); displayHash("/EXPORT");
    displayHash("/FIXED"); displayHash("/FORCE"); displayHash("/HEAP");
    displayHash("/IDLOUT"); displayHash("/IGNORE"); displayHash("/IGNOREIDL"); displayHash("/IMPLIB");
    displayHash("/INCLUDE"); displayHash("/INCREMENTAL"); displayHash("/LARGEADDRESSAWARE");
    displayHash("/LIBPATH"); displayHash("/LTCG"); displayHash("/MACHINE");
    displayHash("/MAP"); displayHash("/MAPINFO"); displayHash("/MERGE");
    displayHash("/MIDL"); displayHash("/NOASSEMBLY"); displayHash("/NODEFAULTLIB");
    displayHash("/NOENTRY"); displayHash("/NOLOGO"); displayHash("/OPT");
    displayHash("/ORDER"); displayHash("/OUT"); displayHash("/PDB");
    displayHash("/PDBSTRIPPED"); displayHash("/RELEASE"); displayHash("/SECTION");
    displayHash("/STACK"); displayHash("/STUB"); displayHash("/SUBSYSTEM");
    displayHash("/SWAPRUN"); displayHash("/TLBID"); displayHash("/TLBOUT");
    displayHash("/TSAWARE"); displayHash("/VERBOSE"); displayHash("/VERSION");
    displayHash("/VXD"); displayHash("/WS "); displayHash("/libpath");

#endif
#ifdef USE_DISPLAY_HASH
    // Sub options
    displayHash("UNLOAD"); displayHash("NOBIND"); displayHash("no"); displayHash("NOSTATUS"); displayHash("STATUS");
    displayHash("AM33"); displayHash("ARM"); displayHash("CEE"); displayHash("EBC"); displayHash("IA64"); displayHash("X86"); displayHash("X64"); displayHash("M32R");
    displayHash("MIPS"); displayHash("MIPS16"); displayHash("MIPSFPU"); displayHash("MIPSFPU16"); displayHash("MIPSR41XX"); displayHash("PPC");
    displayHash("SH3"); displayHash("SH3DSP"); displayHash("SH4"); displayHash("SH5"); displayHash("THUMB"); displayHash("TRICORE"); displayHash("EXPORTS");
    displayHash("LINES"); displayHash("REF"); displayHash("NOREF"); displayHash("ICF"); displayHash("WIN98"); displayHash("NOWIN98");
    displayHash("CONSOLE"); displayHash("EFI_APPLICATION"); displayHash("EFI_BOOT_SERVICE_DRIVER"); displayHash("EFI_ROM"); displayHash("EFI_RUNTIME_DRIVER"); displayHash("NATIVE");
    displayHash("POSIX"); displayHash("WINDOWS"); displayHash("WINDOWSCE"); displayHash("NET"); displayHash("CD"); displayHash("NO");
#endif
    bool found = true;
    switch (elfHash(option)) {
    case 0x6b21972: // /DEFAULTLIB:library
    case 0xaca9d75: // /EXETYPE[:DYNAMIC | :DEV386]
    case 0x3ad5444: // /EXPORT:entryname[,@ordinal[,NONAME]][,DATA]
    case 0x3dc3455: // /IGNORE:number,number,number,number  ### NOTE: This one is undocumented, but it is even used by Microsoft.
                    //                                      In recent versions of the Microsoft linker they have disabled this undocumented feature.
    case 0x0034bc4: // /VXD
        AdditionalOptions += option;
        break;
    case 0x3360dbe: // /ALIGN[:number]
        SectionAlignment = QString(option+7).toLongLong();
        break;
    case 0x1485c34: // /ALLOWBIND[:NO]
        if(*(option+10) == ':' && (*(option+11) == 'n' || *(option+11) == 'N'))
            PreventDllBinding = _False;
        else
            PreventDllBinding = _True;
        break;
    case 0x312011e: // /ALLOWISOLATION[:NO]
        if(*(option+15) == ':' && (*(option+16) == 'n' || *(option+16) == 'N'))
            AllowIsolation = _False;
        else
            AllowIsolation = _True;
        break;
    case 0x679c075: // /ASSEMBLYMODULE:filename
        AddModuleNamesToAssembly += option+15;
        break;
    case 0x75f35f7: // /ASSEMBLYDEBUG[:DISABLE]
        if(*(option+14) == ':' && (*(option+15) == 'D'))
            AssemblyDebug = _False;
        else
            AssemblyDebug = _True;
        break;
    case 0x43294a5: // /ASSEMBLYLINKRESOURCE:filename
            AssemblyLinkResource += option+22;
        break;
    case 0x062d065: // /ASSEMBLYRESOURCE:filename
        EmbedManagedResourceFile += option+18;
        break;
    case 0x0336675: // /BASE:{address | @filename,key}
        // Do we need to do a manual lookup when '@filename,key'?
        // Seems BaseAddress only can contain the location...
        // We don't use it in Qt, so keep it simple for now
        BaseAddress = option+6;
        break;
    case 0x63bf065: // /CLRIMAGETYPE:{IJW|PURE|SAFE}
        if(*(option+14) == 'I')
            CLRImageType = "ForceIJWImage";
        else if(*(option+14) == 'P')
            CLRImageType = "ForcePureILImage";
        else if(*(option+14) == 'S')
            CLRImageType = "ForceSafeILImage";
        break;
    case 0x5f2a6a2: // /CLRSUPPORTLASTERROR{:NO | SYSTEMDLL}
        if(*(option+20) == ':') {
            if(*(option+21) == 'N') {
                CLRSupportLastError = "Disabled";
            } else if(*(option+21) == 'S') {
                CLRSupportLastError = "SystemDlls";
            }
        } else {
            CLRSupportLastError = "Enabled";
        }
        break;
    case 0xc7984f5: // /CLRTHREADATTRIBUTE:{STA|MTA|NONE}
        if(*(option+20) == 'N')
            CLRThreadAttribute = "DefaultThreadingAttribute";
        else if(*(option+20) == 'M')
            CLRThreadAttribute = "MTAThreadingAttribute";
        else if(*(option+20) == 'S')
            CLRThreadAttribute = "STAThreadingAttribute";
        break;
    case 0xa8c637b: // /CLRUNMANAGEDCODECHECK[:NO]
        if(*(option+23) == 'N')
            CLRUnmanagedCodeCheck = _False;
        else
            CLRUnmanagedCodeCheck = _True;
        break;
    case 0x3389797: // /DEBUG
        GenerateDebugInformation = _True;
        break;
    case 0x0033896: // /DEF:filename
        ModuleDefinitionFile = option+5;
        break;
    case 0x338a069: // /DELAY:{UNLOAD | NOBIND}
        if(*(option+7) == 'U')
            SupportNobindOfDelayLoadedDLL = _True;
        else if(*(option+7) == 'N')
            SupportUnloadOfDelayLoadedDLL = _True;
        break;
    case 0x06f4bf4: // /DELAYLOAD:dllname
        DelayLoadDLLs += option+11;
        break;
    case 0x06d451e: // /DELAYSIGN[:NO]
        if(*(option+10) == ':' && (*(option+11) == 'n' || *(option+11) == 'N'))
            DelaySign = _False;
        else
            DelaySign = _True;
        break;
    case 0x003390c: // /DLL
        LinkDLL = _True;
        break;
    case 0x396ea92: // /DRIVER[:UPONLY | :WDM]
        if((*(option+7) == ':') && (*(option+8) == 'U'))
            Driver = "UpOnly";
        else if((*(option+7) == ':') && (*(option+8) == 'W'))
            Driver = "WDM";
        else
            Driver = "Driver";
        break;
    case 0x2ee8415: // /DYNAMICBASE[:NO]
        if(*(option+12) == ':' && (*(option+13) == 'n' || *(option+13) == 'N'))
            RandomizedBaseAddress = _False;
        else
            RandomizedBaseAddress = _True;
        break;
    case 0x33a3979: // /ENTRY:function
        EntryPointSymbol = option+7;
        break;
    case 0x4504334: // /ERRORREPORT:[ NONE | PROMPT | QUEUE | SEND ]
        if(*(option+12) == ':' ) {
            if(*(option+13) == 'N')
                LinkErrorReporting = "NoErrorReport";
            else if(*(option+13) == 'P')
                LinkErrorReporting = "PromptImmediately";
            else if(*(option+13) == 'Q')
                LinkErrorReporting = "QueueForNextLogin";
            else if(*(option+13) == 'S')
                LinkErrorReporting = "SendErrorReport";
        }
        break;
    case 0x33aec94: // /FIXED[:NO]
        if(*(option+6) == ':' && (*(option+7) == 'n' || *(option+7) == 'N'))
            FixedBaseAddress = _False;
        else
            FixedBaseAddress = _True;
        break;
    case 0x33b4675: // /FORCE:[MULTIPLE|UNRESOLVED]
        if(*(option+6) == ':' && *(option+7) == 'M' )
            ForceFileOutput = "MultiplyDefinedSymbolOnly";
        else if(*(option+6) == ':' && *(option+7) == 'U' )
            ForceFileOutput = "UndefinedSymbolOnly";
        else
            ForceFileOutput = "Enabled";
        break;
    case 0x96d4e4e: // /FUNCTIONPADMIN[:space]
        if(*(option+15) == ':') {
            if(*(option+16) == '5')
                CreateHotPatchableImage = "X86Image";
            else if(*(option+16) == '6')
                CreateHotPatchableImage = "X64Image";
            else if((*(option+16) == '1') && (*(option+17) == '6'))
                CreateHotPatchableImage = "ItaniumImage";
        } else {
            CreateHotPatchableImage = "Enabled";
        }
        break;
    case 0x033c960: // /HEAP:reserve[,commit]
        {
            QStringList both = QString(option+6).split(",");
            HeapReserveSize = both[0].toLongLong();
            if(both.count() == 2)
                HeapCommitSize = both[1].toLongLong();
        }
        break;
    case 0x3d91494: // /IDLOUT:[path\]filename
        MergedIDLBaseFileName = option+8;
        break;
    case 0x345a04c: // /IGNOREIDL
        IgnoreEmbeddedIDL = _True;
        break;
    case 0x3e250e2: // /IMPLIB:filename
        ImportLibrary = option+8;
        break;
    case 0xe281ab5: // /INCLUDE:symbol
        ForceSymbolReferences += option+9;
        break;
    case 0xb28103c: // /INCREMENTAL[:no]
        if(*(option+12) == ':' &&
             (*(option+13) == 'n' || *(option+13) == 'N'))
            LinkIncremental = _False;
        else
            LinkIncremental = _True;
        break;
    case 0x07f1ab2: // /KEYCONTAINER:name
        KeyContainer = option+14;
        break;
    case 0xfadaf35: // /KEYFILE:filename
        KeyFile = option+9;
        break;
    case 0x26e4675: // /LARGEADDRESSAWARE[:no]
        if(*(option+18) == ':' &&
             *(option+19) == 'n')
            LargeAddressAware = _False;
        else
            LargeAddressAware = _True;
        break;
    case 0x2f96bc8: // /libpath:dir
    case 0x0d745c8: // /LIBPATH:dir
        AdditionalLibraryDirectories += option+9;
        break;
    case 0x0341877: // /LTCG[:NOSTATUS|:STATUS]
        config->WholeProgramOptimization = _True;
        LinkTimeCodeGeneration = "UseLinkTimeCodeGeneration";
        if(*(option+5) == ':') {
            const char* str = option+6;
            if (*str == 'S')
                LinkStatus = _True;
            else if (*str == 'N')
                LinkStatus = _False;
#ifndef Q_OS_WIN
            else if (strncasecmp(str, "pginstrument", 12))
                LinkTimeCodeGeneration = "PGInstrument";
            else if (strncasecmp(str, "pgoptimize", 10))
                LinkTimeCodeGeneration = "PGOptimization";
            else if (strncasecmp(str, "pgupdate", 8 ))
                LinkTimeCodeGeneration = "PGUpdate";
#else

            else if (_stricmp(str, "pginstrument"))
                LinkTimeCodeGeneration = "PGInstrument";
            else if (_stricmp(str, "pgoptimize"))
                LinkTimeCodeGeneration = "PGOptimization";
            else if (_stricmp(str, "pgupdate"))
                LinkTimeCodeGeneration = "PGUpdate";
#endif
        }
        break;
	case 0x379ED25:
    case 0x157cf65: // /MACHINE:{AM33|ARM|CEE|IA64|X86|M32R|MIPS|MIPS16|MIPSFPU|MIPSFPU16|MIPSR41XX|PPC|SH3|SH4|SH5|THUMB|TRICORE}
        switch (elfHash(option+9)) {
        case 0x0005bb6: // X86
            TargetMachine = "MachineX86";
            break;
        case 0x0005b94: // X64
            TargetMachine = "MachineX64";
            break;
        case 0x000466d: // ARM
            TargetMachine = "MachineARM";
            break;
        case 0x0004963: // EBC
            TargetMachine = "MachineEBC";
            break;
        case 0x004d494: // IA64
            TargetMachine = "MachineIA64";
            break;
        case 0x0051e53: // MIPS
            TargetMachine = "MachineMIPS";
            break;
        case 0x51e5646: // MIPS16
            TargetMachine = "MachineMIPS16";
            break;
        case 0x1e57b05: // MIPSFPU
            TargetMachine = "MachineMIPSFPU";
            break;
        case 0x57b09a6: // MIPSFPU16
            TargetMachine = "MachineMIPSFPU16";
            break;
        case 0x00057b4: // SH4
            TargetMachine = "MachineSH4";
            break;
        case 0x058da12: // THUMB
            TargetMachine = "MachineTHUMB";
            break;
        // put the others in AdditionalOptions...
        case 0x0046063: // AM33
        case 0x0004795: // CEE
        case 0x0050672: // M32R
        case 0x5852738: // MIPSR41XX
        case 0x0005543: // PPC
        case 0x00057b3: // SH3
        case 0x57b7980: // SH3DSP
        case 0x00057b5: // SH5
        case 0x96d8435: // TRICORE
        default:
            AdditionalOptions += option;
            break;
        }
        break;
    case 0x62d9e94: // /MANIFEST[:NO]
        if ((*(option+9) == ':' && (*(option+10) == 'N' || *(option+10) == 'n')))
            GenerateManifest = _False;
        else
            GenerateManifest = _True;
        break;
    case 0x8b64559: // /MANIFESTDEPENDENCY:manifest_dependency
        AdditionalManifestDependencies += option+20;
        break;
    case 0xe9e8195: // /MANIFESTFILE:filename
        ManifestFile = option+14;
        break;
    case 0x9e9fb83: // /MANIFESTUAC http://msdn.microsoft.com/en-us/library/bb384691%28VS.100%29.aspx
        if ((*(option+12) == ':' && (*(option+13) == 'N' || *(option+13) == 'n')))
            EnableUAC = _False;
        else if((*(option+12) == ':' && (*(option+13) == 'l' || *(option+14) == 'e'))) { // level
            if(*(option+20) == 'a')
                UACExecutionLevel = "AsInvoker";
            else if(*(option+20) == 'h')
                UACExecutionLevel = "HighestAvailable";
            else if(*(option+20) == 'r')
                UACExecutionLevel = "RequireAdministrator";
        } else if((*(option+12) == ':' && (*(option+13) == 'u' || *(option+14) == 'i'))) { // uiAccess
            if(*(option+22) == 't')
                UACUIAccess = _True;
            else
                UACUIAccess = _False;
        } else if((*(option+12) == ':' && (*(option+13) == 'f' || *(option+14) == 'r'))) { // fragment
            AdditionalOptions += option;
        }else
            EnableUAC = _True;
        break;
    case 0x0034160: // /MAP[:filename]
        GenerateMapFile = _True;
        MapFileName = option+5;
        break;
    case 0x164e1ef: // /MAPINFO:{EXPORTS}
        if(*(option+9) == 'E')
            MapExports = _True;
        break;
    case 0x341a6b5: // /MERGE:from=to
        MergeSections = option+7;
        break;
    case 0x0341d8c: // /MIDL:@file
        MidlCommandFile = option+7;
        break;
    case 0x84e2679: // /NOASSEMBLY
        TurnOffAssemblyGeneration = _True;
        break;
    case 0x2b21942: // /NODEFAULTLIB[:library]
        if(*(option+13) == '\0')
            IgnoreAllDefaultLibraries = _True;
        else
            IgnoreSpecificDefaultLibraries += option+14;
        break;
    case 0x33a3a39: // /NOENTRY
        NoEntryPoint = _True;
        break;
    case 0x434138f: // /NOLOGO
        SuppressStartupBanner = _True;
        break;
    case 0xc841054: // /NXCOMPAT[:NO]
        if ((*(option+9) == ':' && (*(option+10) == 'N' || *(option+10) == 'n')))
            DataExecutionPrevention = _False;
        else
            DataExecutionPrevention = _True;
        break;
    case 0x0034454: // /OPT:{REF | NOREF | ICF[=iterations] | NOICF | WIN98 | NOWIN98}
        {
            char third = *(option+7);
            switch (third) {
            case 'F': // REF
                if(*(option+5) == 'R') {
                    OptimizeReferences = _True;
                } else { // ICF[=iterations]
                    EnableCOMDATFolding = _True;
                    // [=iterations] case is not documented
                }
                break;
            case 'R': // NOREF
                OptimizeReferences = _False;
                break;
            case 'I': // NOICF
                EnableCOMDATFolding = _False;
                break;
            default:
                found = false;
            }
        }
        break;
    case 0x34468a2: // /ORDER:@filename
        FunctionOrder = option+8;
        break;
    case 0x00344a4: // /OUT:filename
        OutputFile = option+5;
        break;
    case 0x0034482: // /PDB:filename
        ProgramDatabaseFile = option+5;
        break;
    case 0xa2ad314: // /PDBSTRIPPED:pdb_file_name
        StripPrivateSymbols = option+13;
        break;
    case 0x00344b4: // /PGD:filename
        ProfileGuidedDatabase = option+5;
        break;
    case 0x573af45: // /PROFILE
        Profile = _True;
        break;
    case 0x6a09535: // /RELEASE
        SetChecksum = _True;
        break;
    case 0x75AA4D8: // /SAFESEH:{NO}
        {
            if(*(option+8) == ':' && *(option+9) == 'N')
                ImageHasSafeExceptionHandlers = _False;
            else
                ImageHasSafeExceptionHandlers = _True;
        }
        break;
    case 0x7988f7e: // /SECTION:name,[E][R][W][S][D][K][L][P][X][,ALIGN=#]
        SpecifySectionAttributes = option+9;
        break;
    case 0x348857b: // /STACK:reserve[,commit]
        {
            QStringList both = QString(option+7).split(",");
            StackReserveSize = both[0].toLongLong();
            if(both.count() == 2)
                StackCommitSize = both[1].toLongLong();
        }
        break;
    case 0x0348992: // /STUB:filename
        MSDOSStubFileName = option+6;
        break;
    case 0x9B3C00D:
    case 0x78dc00d: // /SUBSYSTEM:{CONSOLE|EFI_APPLICATION|EFI_BOOT_SERVICE_DRIVER|EFI_ROM|EFI_RUNTIME_DRIVER|NATIVE|POSIX|WINDOWS|WINDOWSCE}[,major[.minor]]
        {
            // Split up in subsystem, and version number
            QStringList both = QString(option+11).split(",");
            switch (elfHash(both[0].toLatin1())) {
            case 0x8438445: // CONSOLE
                SubSystem = "Console";
                break;
            case 0xbe29493: // WINDOWS
                SubSystem = "Windows";
                break;
            case 0x5268ea5: // NATIVE
                SubSystem = "Native";
                break;
            case 0x240949e: // EFI_APPLICATION
                SubSystem = "EFI Application";
                break;
            case 0xe617652: // EFI_BOOT_SERVICE_DRIVER
                SubSystem = "EFI Boot Service Driver";
                break;
            case 0x9af477d: // EFI_ROM
                SubSystem = "EFI ROM";
                break;
            case 0xd34df42: // EFI_RUNTIME_DRIVER
                SubSystem = "EFI Runtime";
                break;
            case 0x2949c95: // WINDOWSCE
                SubSystem = "WindowsCE";
                break;
            case 0x05547e8: // POSIX
                SubSystem = "POSIX";
                break;
            // The following are undocumented, so add them to AdditionalOptions
            case 0x4B69795: // windowsce
                AdditionalOptions += option;
                break;
            default:
                found = false;
            }
        }
        break;
    case 0x8b654de: // /SWAPRUN:{NET | CD}
        if(*(option+9) == 'N')
            SwapRunFromNet = _True;
        else if(*(option+9) == 'C')
            SwapRunFromCD = _True;
        else
            found = false;
        break;
    case 0x34906d4: // /TLBID:id
        TypeLibraryResourceID = QString(option+7).toLongLong();
        break;
    case 0x4907494: // /TLBOUT:[path\]filename
        TypeLibraryFile = option+8;
        break;
    case 0x976b525: // /TSAWARE[:NO]
        if(*(option+8) == ':')
            TerminalServerAware = _False;
        else
            TerminalServerAware = _True;
        break;
    case 0xaa67735: // /VERBOSE[:ICF |:LIB |:REF |:SAFESEH]
        if(*(option+9) == ':') {
            if (*(option+10) == 'I') {
                ShowProgress = "LinkVerboseICF";
            } else if ( *(option+10) == 'L') {
                ShowProgress = "LinkVerboseLib";
            } else if ( *(option+10) == 'R') {
                ShowProgress = "LinkVerboseREF";
            } else if ( *(option+10) == 'S') {
                ShowProgress = "LinkVerboseSAFESEH";
            } else if ( *(option+10) == 'C') {
                ShowProgress = "LinkVerboseCLR";
            }
        } else {
            ShowProgress = "LinkVerbose";
        }
        break;
    case 0xaa77f7e: // /VERSION:major[.minor]
        Version = option+9;
        break;
    case 0x0034c50: // /WS[:NO]
        if(*(option+3) == ':')
            TreatLinkerWarningAsErrors = _False;
        else
            TreatLinkerWarningAsErrors = _True;
        break;
    default:
        AdditionalOptions += option;
        break;
    }
    if(!found) {
        warn_msg(WarnLogic, "Could not parse Linker options: %s, added as AdditionalOption", option);
        AdditionalOptions += option;
    }
    return found;
}

// VCMIDLTool -------------------------------------------------------
VCXMIDLTool::VCXMIDLTool()
    :   ApplicationConfigurationMode(unset),
        ErrorCheckAllocations(unset),
        ErrorCheckBounds(unset),
        ErrorCheckEnumRange(unset),
        ErrorCheckRefPointers(unset),
        ErrorCheckStubData(unset),
        GenerateStublessProxies(unset),
        GenerateTypeLibrary(unset),
        IgnoreStandardIncludePath(unset),
        LocaleID(-1),
        MkTypLibCompatible(unset),
        SuppressCompilerWarnings(unset),
        SuppressStartupBanner(unset),
        ValidateAllParameters(unset),
        WarnAsError(unset)
{
}

XmlOutput &operator<<(XmlOutput &xml, const VCXMIDLTool &tool)
{
    return xml
        << tag(_Midl)
            << attrTagX(_AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories, ";")
            << attrTagX(_AdditionalOptions, tool.AdditionalOptions, " ")
            << attrTagT(_ApplicationConfigurationMode, tool.ApplicationConfigurationMode)
            << attrTagS(_ClientStubFile, tool.ClientStubFile)
            << attrTagS(_CPreprocessOptions, tool.CPreprocessOptions)
            << attrTagS(_DefaultCharType, tool.DefaultCharType)
            << attrTagS(_DLLDataFileName, tool.DLLDataFileName)
            << attrTagS(_EnableErrorChecks, tool.EnableErrorChecks)
            << attrTagT(_ErrorCheckAllocations, tool.ErrorCheckAllocations)
            << attrTagT(_ErrorCheckBounds, tool.ErrorCheckBounds)
            << attrTagT(_ErrorCheckEnumRange, tool.ErrorCheckEnumRange)
            << attrTagT(_ErrorCheckRefPointers, tool.ErrorCheckRefPointers)
            << attrTagT(_ErrorCheckStubData, tool.ErrorCheckStubData)
            << attrTagS(_GenerateClientFiles, tool.GenerateClientFiles)
            << attrTagS(_GenerateServerFiles, tool.GenerateServerFiles)
            << attrTagT(_GenerateStublessProxies, tool.GenerateStublessProxies)
            << attrTagT(_GenerateTypeLibrary, tool.GenerateTypeLibrary)
            << attrTagS(_HeaderFileName, tool.HeaderFileName)
            << attrTagT(_IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath)
            << attrTagS(_InterfaceIdentifierFileName, tool.InterfaceIdentifierFileName)
            << attrTagL(_LocaleID, tool.LocaleID, /*ifNot*/ -1)
            << attrTagT(_MkTypLibCompatible, tool.MkTypLibCompatible)
            << attrTagS(_OutputDirectory, tool.OutputDirectory)
            << attrTagX(_PreprocessorDefinitions, tool.PreprocessorDefinitions, ";")
            << attrTagS(_ProxyFileName, tool.ProxyFileName)
            << attrTagS(_RedirectOutputAndErrors, tool.RedirectOutputAndErrors)
            << attrTagS(_ServerStubFile, tool.ServerStubFile)
            << attrTagS(_StructMemberAlignment, tool.StructMemberAlignment)
            << attrTagT(_SuppressCompilerWarnings, tool.SuppressCompilerWarnings)
            << attrTagT(_SuppressStartupBanner, tool.SuppressStartupBanner)
            << attrTagS(_TargetEnvironment, tool.TargetEnvironment)
            << attrTagS(_TypeLibFormat, tool.TypeLibFormat)
            << attrTagS(_TypeLibraryName, tool.TypeLibraryName)
            << attrTagX(_UndefinePreprocessorDefinitions, tool.UndefinePreprocessorDefinitions, ";")
            << attrTagT(_ValidateAllParameters, tool.ValidateAllParameters)
            << attrTagT(_WarnAsError, tool.WarnAsError)
            << attrTagS(_WarningLevel, tool.WarningLevel)
        << closetag(_Midl);
}

bool VCXMIDLTool::parseOption(const char* option)
{
#ifdef USE_DISPLAY_HASH
    displayHash("/D name[=def]"); displayHash("/I directory-list"); displayHash("/Oi");
    displayHash("/Oic"); displayHash("/Oicf"); displayHash("/Oif"); displayHash("/Os");
    displayHash("/U name"); displayHash("/WX"); displayHash("/W{0|1|2|3|4}");
    displayHash("/Zp {N}"); displayHash("/Zs"); displayHash("/acf filename");
    displayHash("/align {N}"); displayHash("/app_config"); displayHash("/c_ext");
    displayHash("/char ascii7"); displayHash("/char signed"); displayHash("/char unsigned");
    displayHash("/client none"); displayHash("/client stub"); displayHash("/confirm");
    displayHash("/cpp_cmd cmd_line"); displayHash("/cpp_opt options");
    displayHash("/cstub filename"); displayHash("/dlldata filename"); displayHash("/env win32");
    displayHash("/env win64"); displayHash("/error all"); displayHash("/error allocation");
    displayHash("/error bounds_check"); displayHash("/error enum"); displayHash("/error none");
    displayHash("/error ref"); displayHash("/error stub_data"); displayHash("/h filename");
    displayHash("/header filename"); displayHash("/iid filename"); displayHash("/lcid");
    displayHash("/mktyplib203"); displayHash("/ms_ext"); displayHash("/ms_union");
    displayHash("/msc_ver <nnnn>"); displayHash("/newtlb"); displayHash("/no_cpp");
    displayHash("/no_def_idir"); displayHash("/no_default_epv"); displayHash("/no_format_opt");
    displayHash("/no_warn"); displayHash("/nocpp"); displayHash("/nologo"); displayHash("/notlb");
    displayHash("/o filename"); displayHash("/oldnames"); displayHash("/oldtlb");
    displayHash("/osf"); displayHash("/out directory"); displayHash("/pack {N}");
    displayHash("/prefix all"); displayHash("/prefix client"); displayHash("/prefix server");
    displayHash("/prefix switch"); displayHash("/protocol all"); displayHash("/protocol dce");
    displayHash("/protocol ndr64"); displayHash("/proxy filename"); displayHash("/robust");
    displayHash("/rpcss"); displayHash("/savePP"); displayHash("/server none");
    displayHash("/server stub"); displayHash("/sstub filename"); displayHash("/syntax_check");
    displayHash("/target {system}"); displayHash("/tlb filename"); displayHash("/use_epv");
    displayHash("/win32"); displayHash("/win64");
#endif
    bool found = true;
    int offset = 0;
    switch(elfHash(option)) {
    case 0x0000334: // /D name[=def]
        PreprocessorDefinitions += option+3;
        break;
    case 0x0000339: // /I directory-list
        AdditionalIncludeDirectories += option+3;
        break;
    case 0x0345f96: // /Oicf
    case 0x00345f6: // /Oif
        GenerateStublessProxies = _True;
        break;
    case 0x0000345: // /U name
        UndefinePreprocessorDefinitions += option+3;
        break;
    case 0x00034c8: // /WX
        WarnAsError = _True;
        break;
    case 0x3582fde: // /align {N}
        offset = 3;  // Fallthrough
    case 0x0003510: // /Zp {N}
        switch (*(option+offset+4)) {
        case '1':
            StructMemberAlignment = (*(option+offset+5) == '\0') ? "1" : "16";
            break;
        case '2':
            StructMemberAlignment = "2";
            break;
        case '4':
            StructMemberAlignment = "4";
            break;
        case '8':
            StructMemberAlignment = "8";
            break;
        default:
            found = false;
        }
        break;
    case 0x5b1cb97: // /app_config
        ApplicationConfigurationMode = _True;
        break;
    case 0x0359e82: // /char {ascii7|signed|unsigned}
        switch(*(option+6)) {
        case 'a':
            DefaultCharType = "Ascii";
            break;
        case 's':
            DefaultCharType = "Signed";
            break;
        case 'u':
            DefaultCharType = "Unsigned";
            break;
        default:
            found = false;
        }
        break;
    case 0x5a2fc64: // /client {none|stub}
        if(*(option+8) == 's')
            GenerateClientFiles = "Stub";
        else
            GenerateClientFiles = "None";
        break;
    case 0xa766524: // /cpp_opt options
        CPreprocessOptions += option+9;
        break;
    case 0x35aabb2: // /cstub filename
        ClientStubFile = option+7;
        break;
    case 0xb32abf1: // /dlldata filename
        DLLDataFileName = option + 9;
        break;
    case 0x0035c56: // /env {win32|ia64|x64}
        if(*(option+7) == 'w' && *(option+10) == '3')
            TargetEnvironment = "Win32";
        else if(*(option+7) == 'i')
            TargetEnvironment = "Itanium";
        else if(*(option+7) == 'x')
            TargetEnvironment = "X64";
        else
            AdditionalOptions += option;
        break;
    case 0x35c9962: // /error {all|allocation|bounds_check|enum|none|ref|stub_data}
        EnableErrorChecks = midlEnableCustom;
        switch (*(option+7)) {
        case '\0':
            EnableErrorChecks = "EnableCustom";
            break;
        case 'a':
            if(*(option+10) == '\0')
                EnableErrorChecks = "All";
            else
                ErrorCheckAllocations = _True;
            break;
        case 'b':
            ErrorCheckBounds = _True;
            break;
        case 'e':
            ErrorCheckEnumRange = _True;
            break;
        case 'n':
            EnableErrorChecks = "None";
            break;
        case 'r':
            ErrorCheckRefPointers = _True;
            break;
        case 's':
            ErrorCheckStubData = _True;
            break;
        default:
            found = false;
        }
        break;
    case 0x5eb7af2: // /header filename
        offset = 5;
    case 0x0000358: // /h filename
        HeaderFileName = option + offset + 3;
        break;
    case 0x0035ff4: // /iid filename
        InterfaceIdentifierFileName = option+5;
        break;
    case 0x64b7933: // /mktyplib203
        MkTypLibCompatible = _True;
        break;
    case 0x64ceb12: // /newtlb
        TypeLibFormat = "NewFormat";
        break;
    case 0x8e0b0a2: // /no_def_idir
        IgnoreStandardIncludePath = _True;
        break;
    case 0x65635ef: // /nologo
        SuppressStartupBanner = _True;
        break;
    case 0x695e9f4: // /no_robust
        ValidateAllParameters = _False;
        break;
    case 0x3656b22: // /notlb
        GenerateTypeLibrary = _True;
        break;
    case 0x556dbee: // /no_warn
        SuppressCompilerWarnings = _True;
        break;
    case 0x000035f: // /o filename
        RedirectOutputAndErrors = option+3;
        break;
    case 0x662bb12: // /oldtlb
        TypeLibFormat = "OldFormat";
        break;
    case 0x00366c4: // /out directory
        OutputDirectory = option+5;
        break;
    case 0x36796f9: // /proxy filename
        ProxyFileName = option+7;
        break;
    case 0x6959c94: // /robust
        ValidateAllParameters = _True;
        break;
    case 0x69c9cf2: // /server {none|stub}
        if(*(option+8) == 's')
            GenerateServerFiles = "Stub";
        else
            GenerateServerFiles = "None";
        break;
    case 0x36aabb2: // /sstub filename
        ServerStubFile = option+7;
        break;
    case 0x0036b22: // /tlb filename
        TypeLibraryName = option+5;
        break;
    case 0x36e0162: // /win32
        TargetEnvironment = "Win32";
        break;
    case 0x36e0194: // /win64
        TargetEnvironment = "Itanium";
        break;
    case 0x0003459: // /Oi
    case 0x00345f3: // /Oic
    case 0x0003463: // /Os
    case 0x0003513: // /Zs
    case 0x0035796: // /acf filename
    case 0x3595cf4: // /c_ext
    case 0xa64d3dd: // /confirm
    case 0xa765b64: // /cpp_cmd cmd_line
    case 0x03629f4: // /lcid
    case 0x6495cc4: // /ms_ext
    case 0x96c7a1e: // /ms_union
    case 0x4996fa2: // /msc_ver <nnnn>
    case 0x6555a40: // /no_cpp
    case 0xf64d6a6: // /no_default_epv
    case 0x6dd9384: // /no_format_opt
    case 0x3655a70: // /nocpp
    case 0x2b455a3: // /oldnames
    case 0x0036696: // /osf
    case 0x036679b: // /pack {N}
    case 0x678bd38: // /prefix {all|client|server|switch}
    case 0x96b702c: // /protocol {all|dce|ndr64}
    case 0x3696aa3: // /rpcss
    case 0x698ca60: // /savePP
    case 0xce9b12b: // /syntax_check
    case 0xc9b5f16: // /use_epv
        AdditionalOptions += option;
        break;
    default:
        // /W{0|1|2|3|4} case
        if(*(option+1) == 'W') {
            switch (*(option+2)) {
            case '0':
                WarningLevel = "0";
                break;
            case '1':
                WarningLevel = "1";
                break;
            case '2':
                WarningLevel = "2";
                break;
            case '3':
                WarningLevel = "3";
                break;
            case '4':
                WarningLevel = "4";
                break;
            default:
                found = false;
            }
        }
        break;
    }
    if(!found)
        warn_msg(WarnLogic, "Could not parse MIDL option: %s", option);
    return true;
}

// VCLibrarianTool --------------------------------------------------
VCXLibrarianTool::VCXLibrarianTool()
    :        IgnoreAllDefaultLibraries(unset),
        LinkTimeCodeGeneration(unset),
        SuppressStartupBanner(_True),
        TreatLibWarningAsErrors(unset),
        Verbose(unset)
{
}

XmlOutput &operator<<(XmlOutput &xml, const VCXLibrarianTool &tool)
{
    return xml
        << tag(_Link)
            << attrTagX(_AdditionalDependencies, tool.AdditionalDependencies, ";")
            << attrTagX(_AdditionalLibraryDirectories, tool.AdditionalLibraryDirectories, ";")
            << attrTagX(_AdditionalOptions, tool.AdditionalOptions, " ")
            << attrTagS(_DisplayLibrary, tool.DisplayLibrary)
            << attrTagS(_ErrorReporting, tool.ErrorReporting)
            << attrTagX(_ExportNamedFunctions, tool.ExportNamedFunctions, ";")
            << attrTagX(_ForceSymbolReferences, tool.ForceSymbolReferences, ";")
            << attrTagT(_IgnoreAllDefaultLibraries, tool.IgnoreAllDefaultLibraries)
            << attrTagX(_IgnoreSpecificDefaultLibraries, tool.IgnoreSpecificDefaultLibraries, ";")
            << attrTagT(_LinkTimeCodeGeneration, tool.LinkTimeCodeGeneration)
            << attrTagS(_ModuleDefinitionFile, tool.ModuleDefinitionFile)
            << attrTagS(_Name, tool.Name)
            << attrTagS(_OutputFile, tool.OutputFile)
            << attrTagX(_RemoveObjects, tool.RemoveObjects, ";")
            << attrTagS(_SubSystem, tool.SubSystem)
            << attrTagT(_SuppressStartupBanner, tool.SuppressStartupBanner)
            << attrTagS(_TargetMachine, tool.TargetMachine)
            << attrTagT(_TreatLibWarningAsErrors, tool.TreatLibWarningAsErrors)
            << attrTagT(_Verbose, tool.Verbose)
        << closetag(_Link);
}

// VCCustomBuildTool ------------------------------------------------
VCXCustomBuildTool::VCXCustomBuildTool()
{
    ToolName = "VCXCustomBuildTool";
}

XmlOutput &operator<<(XmlOutput &xml, const VCXCustomBuildTool &tool)
{
    // The code below offers two ways to split custom build step commands.
    // Normally the $$escape_expand(\n\t) is used in a project file, which is correctly translated
    // in all generators. However, if you use $$escape_expand(\n\r) (or \n\h) instead, the VCPROJ
    // generator will instead of binding the commands with " && " will insert a proper newline into
    // the VCPROJ file. We sometimes use this method of splitting commands if the custom buildstep
    // contains a command-line which is too big to run on certain OS.
    QString cmds;
    int end = tool.CommandLine.count();
    for(int i = 0; i < end; ++i) {
        QString cmdl = tool.CommandLine.at(i);
        if (cmdl.contains("\r\t")) {
            if (i == end - 1)
                cmdl = cmdl.trimmed();
            cmdl.replace("\r\t", " && ");
        } else if (cmdl.contains("\r\n")) {
            ;
        } else if (cmdl.contains("\r\\h")) {
            // The above \r\n should work, but doesn't, so we have this hack
            cmdl.replace("\r\\h", "\r\n");
        } else {
            if (i < end - 1)
                cmdl += " && ";
        }
        cmds += cmdl;
    }

    if ( !tool.AdditionalDependencies.isEmpty() )
    {
        xml << tag("AdditionalInputs")
            << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.ConfigName))
            << valueTagDefX(tool.AdditionalDependencies, "AdditionalInputs", ";");
    }

    if( !cmds.isEmpty() )
    {
        xml << tag("Command")
            << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.ConfigName))
            << valueTag(cmds);
    }

    if ( !tool.Description.isEmpty() )
    {
        xml << tag("Message")
            << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.ConfigName))
            << valueTag(tool.Description);
    }

    if ( !tool.Outputs.isEmpty() )
    {
        xml << tag("Outputs")
            << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.ConfigName))
            << valueTagDefX(tool.Outputs, "Outputs", ";");
    }

    return xml;
}

// VCResourceCompilerTool -------------------------------------------
VCXResourceCompilerTool::VCXResourceCompilerTool()
    :   IgnoreStandardIncludePath(unset),
        NullTerminateStrings(unset),
        ShowProgress(unset),
        SuppressStartupBanner(unset)
{
    PreprocessorDefinitions = QStringList("NDEBUG");
}

XmlOutput &operator<<(XmlOutput &xml, const VCXResourceCompilerTool &tool)
{
    return xml
        << tag(_ResourceCompile)
            << attrTagX(_AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories, ";")
            << attrTagS(_AdditionalOptions, tool.AdditionalOptions)
            << attrTagS(_Culture, tool.Culture)
            << attrTagT(_IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath)
            << attrTagT(_NullTerminateStrings, tool.NullTerminateStrings)
            << attrTagX(_PreprocessorDefinitions, tool.PreprocessorDefinitions, ";")
            << attrTagS(_ResourceOutputFileName, tool.ResourceOutputFileName)
            << attrTagT(_ShowProgress, tool.ShowProgress)
            << attrTagT(_SuppressStartupBanner, tool.SuppressStartupBanner)
            << attrTagS(_TrackerLogDirectory, tool.TrackerLogDirectory)
            << attrTagS(_UndefinePreprocessorDefinitions, tool.UndefinePreprocessorDefinitions)
        << closetag(_ResourceCompile);
}

// VCXDeploymentTool --------------------------------------------
VCXDeploymentTool::VCXDeploymentTool()
{
    DeploymentTag = "DeploymentTool";
    RemoteDirectory = "";
}

// http://msdn.microsoft.com/en-us/library/sa69he4t.aspx
XmlOutput &operator<<(XmlOutput &xml, const VCXDeploymentTool &tool)
{
    if (tool.AdditionalFiles.isEmpty())
        return xml;
    return xml
        << tag(tool.DeploymentTag)
        << closetag(tool.DeploymentTag);
}

// VCEventTool -------------------------------------------------
XmlOutput &operator<<(XmlOutput &xml, const VCXEventTool &tool)
{
    return xml
        << tag(tool.EventName)
        << attrTagS(_Command, tool.CommandLine)
        << attrTagS(_Message, tool.Description)
        << closetag(tool.EventName);
}

// VCXPostBuildEventTool ---------------------------------------------
VCXPostBuildEventTool::VCXPostBuildEventTool()
{
    EventName = "PostBuildEvent";
}

// VCXPreBuildEventTool ----------------------------------------------
VCXPreBuildEventTool::VCXPreBuildEventTool()
{
    EventName = "PreBuildEvent";
}

// VCXPreLinkEventTool -----------------------------------------------
VCXPreLinkEventTool::VCXPreLinkEventTool()
{
    EventName = "PreLinkEvent";
}

// VCConfiguration --------------------------------------------------

VCXConfiguration::VCXConfiguration()
    :        ATLMinimizesCRunTimeLibraryUsage(unset),
        BuildBrowserInformation(unset),
        RegisterOutput(unset),
        WholeProgramOptimization(unset)
{
    compiler.config = this;
    linker.config = this;
    idl.config = this;
}

XmlOutput &operator<<(XmlOutput &xml, const VCXConfiguration &tool)
{
        xml << tag("PropertyGroup")
            << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Name))
            << attrTag("Label", "Configuration")
            << attrTagS(_OutputDirectory, tool.OutputDirectory)
            << attrTagT(_ATLMinimizesCRunTimeLibraryUsage, tool.ATLMinimizesCRunTimeLibraryUsage)
            << attrTagT(_BuildBrowserInformation, tool.BuildBrowserInformation)
            << attrTagS(_CharacterSet, tool.CharacterSet)
            << attrTagS(_ConfigurationType, tool.ConfigurationType)
            << attrTagS(_DeleteExtensionsOnClean, tool.DeleteExtensionsOnClean)
            << attrTagS(_ImportLibrary, tool.ImportLibrary)
            << attrTagS(_IntermediateDirectory, tool.IntermediateDirectory)
            << attrTagS(_PrimaryOutput, tool.PrimaryOutput)
            << attrTagS(_ProgramDatabase, tool.ProgramDatabase)
            << attrTagT(_RegisterOutput, tool.RegisterOutput)
            << attrTagS(_UseOfATL, tool.UseOfATL)
            << attrTagS(_UseOfMfc, tool.UseOfMfc)
            << attrTagT(_WholeProgramOptimization, tool.WholeProgramOptimization)
        << closetag();
    return xml;
}
// VCXFilter ---------------------------------------------------------
VCXFilter::VCXFilter()
    :   ParseFiles(unset),
        Config(0)
{
    useCustomBuildTool = false;
    useCompilerTool = false;
}

void VCXFilter::addFile(const QString& filename)
{
    Files += VCXFilterFile(filename);
}

void VCXFilter::addFile(const VCXFilterFile& fileInfo)
{
    Files += VCXFilterFile(fileInfo);
}

void VCXFilter::addFiles(const QStringList& fileList)
{
    for (int i = 0; i < fileList.count(); ++i)
        addFile(fileList.at(i));
}

void VCXFilter::modifyPCHstage(QString str)
{
    bool autogenSourceFile = Project->autogenPrecompCPP;
    bool pchThroughSourceFile = !Project->precompCPP.isEmpty();
    bool isCFile = false;
    for (QStringList::Iterator it = Option::c_ext.begin(); it != Option::c_ext.end(); ++it) {
        if (str.endsWith(*it)) {
            isCFile = true;
            break;
        }
    }
    bool isHFile = str.endsWith(".h") && (str == Project->precompH);
    bool isCPPFile = pchThroughSourceFile && (str == Project->precompCPP);

    if(!isCFile && !isHFile && !isCPPFile)
        return;

    if(isHFile && pchThroughSourceFile) {
        if (autogenSourceFile) {
            useCustomBuildTool = true;
            QString toFile(Project->precompCPP);
            CustomBuildTool.Description = "Generating precompiled header source file '" + toFile + "' ...";
            CustomBuildTool.Outputs += toFile;

            QStringList lines;
            CustomBuildTool.CommandLine +=
                "echo /*-------------------------------------------------------------------- >" + toFile;
            lines << "* Precompiled header source file used by Visual Studio.NET to generate";
            lines << "* the .pch file.";
            lines << "*";
            lines << "* Due to issues with the dependencies checker within the IDE, it";
            lines << "* sometimes fails to recompile the PCH file, if we force the IDE to";
            lines << "* create the PCH file directly from the header file.";
            lines << "*";
            lines << "* This file is auto-generated by qmake since no PRECOMPILED_SOURCE was";
            lines << "* specified, and is used as the common stdafx.cpp. The file is only";
            lines << "* generated when creating .vcxproj project files, and is not used for";
            lines << "* command line compilations by nmake.";
            lines << "*";
            lines << "* WARNING: All changes made in this file will be lost.";
            lines << "--------------------------------------------------------------------*/";
            lines << "#include \"" + Project->precompHFilename + "\"";
            foreach(QString line, lines)
                CustomBuildTool.CommandLine += "echo " + line + ">>" + toFile;
        }
        return;
    }

    useCompilerTool = true;
    // Setup PCH options
    CompilerTool.PrecompiledHeader     = (isCFile ? "NotUsing" : "Create" );
    CompilerTool.PrecompiledHeaderFile = (isCPPFile ? QString("$(INHERIT)") : QString("$(NOINHERIT)"));
    CompilerTool.ForcedIncludeFiles       = QStringList("$(NOINHERIT)");
}

bool VCXFilter::addExtraCompiler(const VCXFilterFile &info)
{
    const QStringList &extraCompilers = Project->extraCompilerSources.value(info.file);
    if (extraCompilers.isEmpty())
        return false;

    QString inFile = info.file;

    // is the extracompiler rule on a file with a built in compiler?
    const QStringList &objectMappedFile = Project->extraCompilerOutputs[inFile];
    bool hasBuiltIn = false;
    if (!objectMappedFile.isEmpty()) {
        hasBuiltIn = Project->hasBuiltinCompiler(objectMappedFile.at(0));
//        qDebug("*** Extra compiler file has object mapped file '%s' => '%s'", qPrintable(inFile), qPrintable(objectMappedFile.join(" ")));
    }

    CustomBuildTool.AdditionalDependencies.clear();
    CustomBuildTool.CommandLine.clear();
    CustomBuildTool.Description.clear();
    CustomBuildTool.Outputs.clear();
    CustomBuildTool.ToolPath.clear();
    CustomBuildTool.ToolName = QLatin1String(_VCCustomBuildTool);

    for (int x = 0; x < extraCompilers.count(); ++x) {
        const QString &extraCompilerName = extraCompilers.at(x);

        if (!Project->verifyExtraCompiler(extraCompilerName, inFile) && !hasBuiltIn)
            continue;

        // All information about the extra compiler
        QString tmp_out = Project->project->first(extraCompilerName + ".output");
        QString tmp_cmd = Project->project->variables()[extraCompilerName + ".commands"].join(" ");
        QString tmp_cmd_name = Project->project->variables()[extraCompilerName + ".name"].join(" ");
        QStringList tmp_dep = Project->project->variables()[extraCompilerName + ".depends"];
        QString tmp_dep_cmd = Project->project->variables()[extraCompilerName + ".depend_command"].join(" ");
        QStringList vars = Project->project->variables()[extraCompilerName + ".variables"];
        QStringList configs = Project->project->variables()[extraCompilerName + ".CONFIG"];
        bool combined = configs.indexOf("combine") != -1;

        QString cmd, cmd_name, out;
        QStringList deps, inputs;
        // Variabel replacement of output name
        out = Option::fixPathToTargetOS(
                    Project->replaceExtraCompilerVariables(tmp_out, inFile, QString()),
                    false);

        // If file has built-in compiler, we've swapped the input and output of
        // the command, as we in Visual Studio cannot have a Custom Buildstep on
        // a file which uses a built-in compiler. We would in this case only get
        // the result from the extra compiler. If 'hasBuiltIn' is true, we know
        // that we're actually on the _output_file_ of the result, and we
        // therefore swap inFile and out below, since the extra-compiler still
        // must see it as the original way. If the result also has a built-in
        // compiler, too bad..
        if (hasBuiltIn) {
            out = inFile;
            inFile = objectMappedFile.at(0);
        }

        // Dependency for the output
        if(!tmp_dep.isEmpty())
            deps = tmp_dep;
        if(!tmp_dep_cmd.isEmpty()) {
            // Execute dependency command, and add every line as a dep
            char buff[256];
            QString dep_cmd = Project->replaceExtraCompilerVariables(tmp_dep_cmd, Option::fixPathToLocalOS(inFile, true, false), out);
            if(Project->canExecute(dep_cmd)) {
                if(FILE *proc = QT_POPEN(dep_cmd.toLatin1().constData(), "r")) {
                    QString indeps;
                    while(!feof(proc)) {
                        int read_in = (int)fread(buff, 1, 255, proc);
                        if(!read_in)
                            break;
                        indeps += QByteArray(buff, read_in);
                    }
                    QT_PCLOSE(proc);
                    if(!indeps.isEmpty()) {
                        QStringList extradeps = indeps.split(QLatin1Char('\n'));
                        for (int i = 0; i < extradeps.count(); ++i) {
                            QString dd = extradeps.at(i).simplified();
                            if (!dd.isEmpty())
                                deps += Project->fileFixify(dd);
                        }
                    }
                }
            }
        }
        for (int i = 0; i < deps.count(); ++i)
            deps[i] = Option::fixPathToTargetOS(
                        Project->replaceExtraCompilerVariables(deps.at(i), inFile, out),
                        false).trimmed();
        // Command for file
        if (combined) {
            // Add dependencies for each file
            QStringList tmp_in = Project->project->variables()[extraCompilerName + ".input"];
            for (int a = 0; a < tmp_in.count(); ++a) {
                const QStringList &files = Project->project->variables()[tmp_in.at(a)];
                for (int b = 0; b < files.count(); ++b) {
                    deps += Project->findDependencies(files.at(b));
                    inputs += Option::fixPathToTargetOS(files.at(b), false);
                }
            }
            deps += inputs; // input files themselves too..

            // Replace variables for command w/all input files
            // ### join gives path issues with directories containing spaces!
            cmd = Project->replaceExtraCompilerVariables(tmp_cmd,
                                                         inputs.join(" "),
                                                         out);
        } else {
            deps += inFile; // input file itself too..
            cmd = Project->replaceExtraCompilerVariables(tmp_cmd,
                                                         inFile,
                                                         out);
        }
        // Name for command
    if(!tmp_cmd_name.isEmpty()) {
        cmd_name = Project->replaceExtraCompilerVariables(tmp_cmd_name, inFile, out);
	} else {
        int space = cmd.indexOf(' ');
        if(space != -1)
        cmd_name = cmd.left(space);
        else
        cmd_name = cmd;
        if((cmd_name[0] == '\'' || cmd_name[0] == '"') &&
        cmd_name[0] == cmd_name[cmd_name.length()-1])
        cmd_name = cmd_name.mid(1,cmd_name.length()-2);
	}

        // Fixify paths
        for (int i = 0; i < deps.count(); ++i)
            deps[i] = Option::fixPathToTargetOS(deps[i], false);


        // Output in info.additionalFile -----------
        if (!CustomBuildTool.Description.isEmpty())
            CustomBuildTool.Description += " & ";
        CustomBuildTool.Description += cmd_name;
        CustomBuildTool.CommandLine += cmd.trimmed().split("\n", QString::SkipEmptyParts);
        int space = cmd.indexOf(' ');
        QFileInfo finf(cmd.left(space));
        if (CustomBuildTool.ToolPath.isEmpty())
            CustomBuildTool.ToolPath += Option::fixPathToTargetOS(finf.path());
        CustomBuildTool.Outputs += out;

        deps += CustomBuildTool.AdditionalDependencies;
        deps += cmd.left(cmd.indexOf(' '));
        // Make sure that all deps are only once
        QMap<QString, bool> uniqDeps;
        for (int c = 0; c < deps.count(); ++c) {
            QString aDep = deps.at(c).trimmed();
            if (!aDep.isEmpty())
                uniqDeps[aDep] = false;
        }
        CustomBuildTool.AdditionalDependencies = uniqDeps.keys();
    }

    // Ensure that none of the output files are also dependencies. Or else, the custom buildstep
    // will be rebuild every time, even if nothing has changed.
    foreach(QString output, CustomBuildTool.Outputs) {
        CustomBuildTool.AdditionalDependencies.removeAll(output);
    }

    useCustomBuildTool = !CustomBuildTool.CommandLine.isEmpty();
    return useCustomBuildTool;
}

bool VCXFilter::outputFileConfig(XmlOutput &xml, XmlOutput &xmlFilter, const QString &filename, const QString &filtername, bool fileAllreadyAdded)
{
    bool fileAdded = false;

    // Clearing each filter tool
    useCustomBuildTool = false;
    useCompilerTool = false;
    CustomBuildTool = VCXCustomBuildTool();
    CompilerTool = VCXCLCompilerTool();

    // Unset some default options
    CompilerTool.BufferSecurityCheck = unset;
    CompilerTool.DebugInformationFormat = "";
    CompilerTool.ExceptionHandling = "";
    //CompilerTool.Optimization = optimizeDefault;
    CompilerTool.ProgramDataBaseFileName.clear();
    CompilerTool.RuntimeLibrary = "";
    //CompilerTool.WarningLevel = warningLevelUnknown;
    CompilerTool.config = Config;

    bool inBuild = false;
    VCXFilterFile info;
    for (int i = 0; i < Files.count(); ++i) {
        if (Files.at(i).file == filename) {
            info = Files.at(i);
            inBuild = true;
        }
    }
    inBuild &= !info.excludeFromBuild;

    if (inBuild) {
        addExtraCompiler(info);
        if(Project->usePCH)
            modifyPCHstage(info.file);
    } else {
        // Excluded files uses an empty compiler stage
        if(info.excludeFromBuild)
            useCompilerTool = true;
    }

    // Actual XML output ----------------------------------
    if(useCustomBuildTool || useCompilerTool || !inBuild) {

        if (useCustomBuildTool)
        {
            CustomBuildTool.ConfigName = (*Config).Name;

            if ( !fileAllreadyAdded ) {

                fileAdded = true;

                xmlFilter << tag("CustomBuild")
                    << attrTag("Include",Option::fixPathToLocalOS(filename))
                    << attrTagS("Filter", filtername);

                xml << tag("CustomBuild")
                    << attrTag("Include",Option::fixPathToLocalOS(filename));

                if ( filtername == "Form Files" || filtername == "Generated Files" || filtername == "Resource Files" )
                    xml << attrTagS("FileType", "Document");
            }

            xml << CustomBuildTool;
        }

        if ( !fileAdded && !fileAllreadyAdded )
        {
            fileAdded = true;

            if (filtername == "Source Files") {

                xmlFilter << tag("ClCompile")
                          << attrTag("Include",Option::fixPathToLocalOS(filename))
                          << attrTagS("Filter", filtername);

                xml << tag("ClCompile")
                    << attrTag("Include",Option::fixPathToLocalOS(filename));

            } else if(filtername == "Header Files") {

                xmlFilter << tag("ClInclude")
                    << attrTag("Include",Option::fixPathToLocalOS(filename))
                    << attrTagS("Filter", filtername);

                xml << tag("ClInclude")
                    << attrTag("Include",Option::fixPathToLocalOS(filename));
            } else if(filtername == "Generated Files" || filtername == "Form Files") {

                if (filename.endsWith(".h")) {

                    xmlFilter << tag("ClInclude")
                              << attrTag("Include",Option::fixPathToLocalOS(filename))
                              << attrTagS("Filter", filtername);

                    xml << tag("ClInclude")
                        << attrTag("Include",Option::fixPathToLocalOS(filename));
                } else if(filename.endsWith(".cpp")) {

                    xmlFilter << tag("ClCompile")
                              << attrTag("Include",Option::fixPathToLocalOS(filename))
                              << attrTagS("Filter", filtername);

                    xml << tag("ClCompile")
                        << attrTag("Include",Option::fixPathToLocalOS(filename));
                } else {

                    xmlFilter << tag("CustomBuild")
                              << attrTag("Include",Option::fixPathToLocalOS(filename))
                              << attrTagS("Filter", filtername);

                    xml << tag("CustomBuild")
                        << attrTag("Include",Option::fixPathToLocalOS(filename));
                }
            }
        }

        if(!inBuild) {

            xml << tag("ExcludedFromBuild")
                << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg((*Config).Name))
                << valueTag("true");
        }

        if (useCompilerTool) {

            if ( !CompilerTool.ForcedIncludeFiles.isEmpty() ) {
                xml << tag("ForcedIncludeFiles")
                    << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg((*Config).Name))
                    << valueTagX(CompilerTool.ForcedIncludeFiles);
            }

            if ( !CompilerTool.PrecompiledHeaderFile.isEmpty() ) {

                xml << tag("PrecompiledHeaderFile")
                    << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg((*Config).Name))
                    << valueTag(CompilerTool.PrecompiledHeaderFile);
            }

            if ( !CompilerTool.PrecompiledHeader.isEmpty() ) {

                xml << tag("PrecompiledHeader")
                    << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg((*Config).Name))
                    << valueTag(CompilerTool.PrecompiledHeader);
            }

            //xml << CompilerTool;
        }
    }

    return fileAdded;
}


// VCXProjectSingleConfig --------------------------------------------
VCXFilter nullVCXFilter;
VCXFilter& VCXProjectSingleConfig::filterForExtraCompiler(const QString &compilerName)
{
    for (int i = 0; i < ExtraCompilersFiles.count(); ++i)
        if (ExtraCompilersFiles.at(i).Name == compilerName)
            return ExtraCompilersFiles[i];
    return nullVCXFilter;
}


XmlOutput &operator<<(XmlOutput &xml, const VCXProjectSingleConfig &tool)
{
    xml.setIndentString("  ");

    xml << decl("1.0", "utf-8")
        << tag("Project")
        << attrTag("DefaultTargets","Build")
        << attrTag("ToolsVersion", "4.0")
        << attrTag("xmlns", "http://schemas.microsoft.com/developer/msbuild/2003")
        << tag("ItemGroup")
        << attrTag("Label", "ProjectConfigurations");

    xml << tag("ProjectConfiguration")
        << attrTag("Include" , tool.Configuration.Name)
        << tagValue("Configuration", tool.Configuration.ConfigurationName)
        << tagValue("Platform", tool.PlatformName)
        << closetag();

    xml << closetag()
        << tag("PropertyGroup")
        << attrTag("Label", "Globals")
        << tagValue("ProjectGuid", tool.ProjectGUID)
        << tagValue("RootNamespace", tool.Name)
        << tagValue("Keyword", tool.Keyword)
        << closetag();

    // config part.
    xml << import("Project", "$(VCTargetsPath)\\Microsoft.Cpp.Default.props");

    xml << tool.Configuration;

    xml << import("Project", "$(VCTargetsPath)\\Microsoft.Cpp.props");

    // Extension settings
    xml << tag("ImportGroup")
        << attrTag("Label", "ExtensionSettings")
        << closetag();

    // PropertySheets
    xml << tag("ImportGroup")
        << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name))
        << attrTag("Label", "PropertySheets");

    xml << tag("Import")
        << attrTag("Project", "$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props")
        << attrTag("Condition", "exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')")
        << closetag()
        << closetag();


    // UserMacros
    xml << tag("PropertyGroup")
        << attrTag("Label", "UserMacros")
        << closetag();

    xml << tag("PropertyGroup");

    if ( !tool.Configuration.OutputDirectory.isEmpty() ) {
        xml<< tag("OutDir")
            << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name))
            << valueTag(tool.Configuration.OutputDirectory);
    }
    if ( !tool.Configuration.IntermediateDirectory.isEmpty() ) {
        xml<< tag("IntDir")
            << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name))
            << valueTag(tool.Configuration.IntermediateDirectory);
    }
    if ( !tool.Configuration.TargetName.isEmpty() ) {
        xml<< tag("TargetName")
            << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name))
            << valueTag(tool.Configuration.TargetName);
    }

    if ( tool.Configuration.linker.IgnoreImportLibrary != unset) {
        xml<< tag("IgnoreImportLibrary")
            << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name))
            << valueTagT(tool.Configuration.linker.IgnoreImportLibrary);
    }

    if ( tool.Configuration.linker.LinkIncremental != unset) {
        xml<< tag("LinkIncremental")
            << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name))
            << valueTagT(tool.Configuration.linker.LinkIncremental);
    }

    if ( tool.Configuration.preBuild.UseInBuild != unset )
    {
        xml<< tag("PreBuildEventUseInBuild")
            << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name))
            << valueTagT(tool.Configuration.preBuild.UseInBuild);
    }

    if ( tool.Configuration.preLink.UseInBuild != unset )
    {
        xml<< tag("PreLinkEventUseInBuild")
            << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name))
            << valueTagT(tool.Configuration.preLink.UseInBuild);
    }

    if ( tool.Configuration.postBuild.UseInBuild != unset )
    {
        xml<< tag("PostBuildEventUseInBuild")
            << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name))
            << valueTagT(tool.Configuration.postBuild.UseInBuild);
    }
    xml << closetag();

    xml << tag("ItemDefinitionGroup")
        << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name));

    // ClCompile
    xml << tool.Configuration.compiler;

    // Link
    xml << tool.Configuration.linker;

    // Midl
    xml << tool.Configuration.idl;

    // ResourceCompiler
    xml << tool.Configuration.resource;

    // Post build event
    if ( tool.Configuration.postBuild.UseInBuild != unset )
        xml << tool.Configuration.postBuild;
    
    // Pre build event
    if ( tool.Configuration.preBuild.UseInBuild != unset )
        xml << tool.Configuration.preBuild;

    // Pre link event
    if ( tool.Configuration.preLink.UseInBuild != unset )
        xml << tool.Configuration.preLink;

    xml << closetag();

    QFile filterFile;
    filterFile.setFileName(Option::output.fileName().append(".filters"));
    filterFile.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate);
    QTextStream ts(&filterFile);
    XmlOutput xmlFilter(ts, XmlOutput::NoConversion);

    xmlFilter.setIndentString("  ");

    xmlFilter << decl("1.0", "utf-8")
              << tag("Project")
              << attrTag("ToolsVersion", "4.0")
              << attrTag("xmlns", "http://schemas.microsoft.com/developer/msbuild/2003");

    xmlFilter << tag("ItemGroup");

    VCXProject tempProj;
    tempProj.SingleProjects += tool;

    tempProj.addFilters(xmlFilter, "Form Files");
    tempProj.addFilters(xmlFilter, "Generated Files");
    tempProj.addFilters(xmlFilter, "Header Files");
    tempProj.addFilters(xmlFilter, "LexYacc Files");
    tempProj.addFilters(xmlFilter, "Resource Files");
    tempProj.addFilters(xmlFilter, "Source Files");
    tempProj.addFilters(xmlFilter, "Translation Files");
    xmlFilter << closetag();

    tempProj.outputFilter(xml, xmlFilter, "Source Files");
    tempProj.outputFilter(xml, xmlFilter, "Header Files");
    tempProj.outputFilter(xml, xmlFilter, "Generated Files");
    tempProj.outputFilter(xml, xmlFilter, "LexYacc Files");
    tempProj.outputFilter(xml, xmlFilter, "Translation Files");
    tempProj.outputFilter(xml, xmlFilter, "Form Files");
    tempProj.outputFilter(xml, xmlFilter, "Resource Files");

    for (int x = 0; x < tempProj.ExtraCompilers.count(); ++x) {
        tempProj.outputFilter(xml, xmlFilter, tempProj.ExtraCompilers.at(x));
    }

    xml << import("Project", "$(VCTargetsPath)\\Microsoft.Cpp.targets");

    xml << tag("ImportGroup")
        << attrTag("Label", "ExtensionTargets")
        << closetag();

    return xml;
}


// Tree file generation ---------------------------------------------
void XTreeNode::generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString &tagName, VCXProject &tool, const QString &filter) {

    if (children.size()) {
        // Filter
        ChildrenMap::ConstIterator it, end = children.constEnd();
        if (!tagName.isEmpty()) {
            xmlFilter << tag("Filter")
                      << attrTag("Include", tagName)
                      << attrTagS("Extensions", "");
        }
        // First round, do nested filters
        for (it = children.constBegin(); it != end; ++it)
            if ((*it)->children.size())
                (*it)->generateXML(xml, xmlFilter, it.key(), tool, filter);
        // Second round, do leafs
        for (it = children.constBegin(); it != end; ++it)
            if (!(*it)->children.size())
                (*it)->generateXML(xml, xmlFilter, it.key(), tool, filter);

        if (!tagName.isEmpty())
            xml << closetag("Filter");
    } else {
        // Leaf
        tool.outputFileConfigs(xml, xmlFilter, info, filter);
    }
}


// Flat file generation ---------------------------------------------
void XFlatNode::generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString &/*tagName*/, VCXProject &tool, const QString &filter) {
    if (children.size()) {
        ChildrenMapFlat::ConstIterator it = children.constBegin();
        ChildrenMapFlat::ConstIterator end = children.constEnd();
        xml << tag(_ItemGroup);
        xmlFilter << tag(_ItemGroup);
        for (; it != end; ++it) {
            tool.outputFileConfigs(xml, xmlFilter, (*it), filter);
        }
        xml << closetag();
        xmlFilter << closetag();
    }
}


// VCXProject --------------------------------------------------------
// Output all configurations (by filtername) for a file (by info)
// A filters config output is in VCXFilter.outputFileConfig()
void VCXProject::outputFileConfigs(XmlOutput &xml,
                                  XmlOutput &xmlFilter,
                                  const VCXFilterFile &info,
                                  const QString &filtername)
{
    // We need to check if the file has any custom build step.
    // If there is one then it has to be included with "CustomBuild Include"
    bool fileAdded = false;

    for (int i = 0; i < SingleProjects.count(); ++i) {
        VCXFilter filter;
        if (filtername == "Root Files") {
            filter = SingleProjects.at(i).RootFiles;
        } else if (filtername == "Source Files") {
            filter = SingleProjects.at(i).SourceFiles;
        } else if (filtername == "Header Files") {
            filter = SingleProjects.at(i).HeaderFiles;
        } else if (filtername == "Generated Files") {
            filter = SingleProjects.at(i).GeneratedFiles;
        } else if (filtername == "LexYacc Files") {
            filter = SingleProjects.at(i).LexYaccFiles;
        } else if (filtername == "Translation Files") {
            filter = SingleProjects.at(i).TranslationFiles;
        } else if (filtername == "Form Files") {
            filter = SingleProjects.at(i).FormFiles;
        } else if (filtername == "Resource Files") {
            filter = SingleProjects.at(i).ResourceFiles;
        } else {
            // ExtraCompilers
            filter = SingleProjects[i].filterForExtraCompiler(filtername);
        }

        if (filter.Config) // only if the filter is not empty
            if (filter.outputFileConfig(xml, xmlFilter, info.file, filtername, fileAdded)) // only add it once.
                fileAdded = true;
    }

    if ( !fileAdded )
    {
        if (filtername == "Source Files") {

            xmlFilter << tag("ClCompile")
                      << attrTag("Include",Option::fixPathToLocalOS(info.file))
                      << attrTagS("Filter", filtername);

            xml << tag("ClCompile")
                << attrTag("Include",Option::fixPathToLocalOS(info.file));

        } else if(filtername == "Header Files") {

            xmlFilter << tag("ClInclude")
                << attrTag("Include",Option::fixPathToLocalOS(info.file))
                << attrTagS("Filter", filtername);

            xml << tag("ClInclude")
                << attrTag("Include",Option::fixPathToLocalOS(info.file));
        } else if(filtername == "Generated Files" || filtername == "Form Files") {

            if (info.file.endsWith(".h")) {

                xmlFilter << tag("ClInclude")
                          << attrTag("Include",Option::fixPathToLocalOS(info.file))
                          << attrTagS("Filter", filtername);

                xml << tag("ClInclude")
                    << attrTag("Include",Option::fixPathToLocalOS(info.file));
            } else if(info.file.endsWith(".cpp")) {

                xmlFilter << tag("ClCompile")
                          << attrTag("Include",Option::fixPathToLocalOS(info.file))
                          << attrTagS("Filter", filtername);

                xml << tag("ClCompile")
                    << attrTag("Include",Option::fixPathToLocalOS(info.file));
            } else {

                xmlFilter << tag("CustomBuild")
                          << attrTag("Include",Option::fixPathToLocalOS(info.file))
                          << attrTagS("Filter", filtername);

                xml << tag("CustomBuild")
                    << attrTag("Include",Option::fixPathToLocalOS(info.file));
            }

        } else {

            xmlFilter << tag("None")
                      << attrTag("Include",Option::fixPathToLocalOS(info.file))
                      << attrTagS("Filter", filtername);

                xml << tag("None")
                    << attrTag("Include",Option::fixPathToLocalOS(info.file));
        }
    }

    xml << closetag();
    xmlFilter << closetag();
}

// outputs a given filter for all existing configurations of a project
void VCXProject::outputFilter(XmlOutput &xml,
                              XmlOutput &xmlFilter,
                              const QString &filtername)
{
    XNode *root;
    if (SingleProjects.at(0).flat_files)
        root = new XFlatNode;
    else
        root = new XTreeNode;

    QString name, extfilter;
    triState parse;

    for (int i = 0; i < SingleProjects.count(); ++i) {
        VCXFilter filter;
        if (filtername == "Root Files") {
            filter = SingleProjects.at(i).RootFiles;
        } else if (filtername == "Source Files") {
            filter = SingleProjects.at(i).SourceFiles;
        } else if (filtername == "Header Files") {
            filter = SingleProjects.at(i).HeaderFiles;
        } else if (filtername == "Generated Files") {
            filter = SingleProjects.at(i).GeneratedFiles;
        } else if (filtername == "LexYacc Files") {
            filter = SingleProjects.at(i).LexYaccFiles;
        } else if (filtername == "Translation Files") {
            filter = SingleProjects.at(i).TranslationFiles;
        } else if (filtername == "Form Files") {
            filter = SingleProjects.at(i).FormFiles;
        } else if (filtername == "Resource Files") {
            filter = SingleProjects.at(i).ResourceFiles;
        } else {
            // ExtraCompilers
            filter = SingleProjects[i].filterForExtraCompiler(filtername);
        }

        // Merge all files in this filter to root tree
        for (int x = 0; x < filter.Files.count(); ++x)
            root->addElement(filter.Files.at(x));

        // Save filter setting from first filter. Next filters
        // may differ but we cannot handle that. (ex. extfilter)
        if (name.isEmpty()) {
            name = filter.Name;
            extfilter = filter.Filter;
            parse = filter.ParseFiles;
        }
    }

    if (!root->hasElements())
        return;

    root->generateXML(xml, xmlFilter, "", *this, filtername); // output root tree
}


void VCXProject::addFilters(XmlOutput &xmlFilter,
                            const QString &filtername)
{
    bool added = false;

    for (int i = 0; i < SingleProjects.count(); ++i) {
        VCXFilter filter;
        if (filtername == "Root Files") {
            filter = SingleProjects.at(i).RootFiles;
        } else if (filtername == "Source Files") {
            filter = SingleProjects.at(i).SourceFiles;
        } else if (filtername == "Header Files") {
            filter = SingleProjects.at(i).HeaderFiles;
        } else if (filtername == "Generated Files") {
            filter = SingleProjects.at(i).GeneratedFiles;
        } else if (filtername == "LexYacc Files") {
            filter = SingleProjects.at(i).LexYaccFiles;
        } else if (filtername == "Translation Files") {
            filter = SingleProjects.at(i).TranslationFiles;
        } else if (filtername == "Form Files") {
            filter = SingleProjects.at(i).FormFiles;
        } else if (filtername == "Resource Files") {
            filter = SingleProjects.at(i).ResourceFiles;
        } else {
            // ExtraCompilers
            filter = SingleProjects[i].filterForExtraCompiler(filtername);
        }

        if(!filter.Files.isEmpty() && !added) {
            added = true;
            xmlFilter << tag("Filter")
                      << attrTag("Include", filtername)
                      << attrTagS("UniqueIdentifier", filter.Guid)
                      << attrTagS("Extensions", filter.Filter)
                      << attrTagT("ParseFiles", filter.ParseFiles)
                      << closetag();
        }
    }
}


XmlOutput &operator<<(XmlOutput &xml, VCXProject &tool)
{

    if (tool.SingleProjects.count() == 0) {
        warn_msg(WarnLogic, "Generator: .NET: no single project in merge project, no output");
        return xml;
    }

    xml.setIndentString("  ");

    xml << decl("1.0", "utf-8")
        << tag("Project")
        << attrTag("DefaultTargets","Build")
        << attrTag("ToolsVersion", "4.0")
        << attrTag("xmlns", "http://schemas.microsoft.com/developer/msbuild/2003")
        << tag("ItemGroup")
        << attrTag("Label", "ProjectConfigurations");

    for (int i = 0; i < tool.SingleProjects.count(); ++i) {
        xml << tag("ProjectConfiguration")
            << attrTag("Include" , tool.SingleProjects.at(i).Configuration.Name)
            << tagValue("Configuration", tool.SingleProjects.at(i).Configuration.ConfigurationName)
            << tagValue("Platform", tool.SingleProjects.at(i).PlatformName)
            << closetag();
    }

    xml << closetag()
        << tag("PropertyGroup")
        << attrTag("Label", "Globals")
        << tagValue("ProjectGuid", tool.ProjectGUID)
        << tagValue("RootNamespace", tool.Name)
        << tagValue("Keyword", tool.Keyword)
        << closetag();

    // config part.
    xml << import("Project", "$(VCTargetsPath)\\Microsoft.Cpp.Default.props");
    for (int i = 0; i < tool.SingleProjects.count(); ++i)
        xml << tool.SingleProjects.at(i).Configuration;
    xml << import("Project", "$(VCTargetsPath)\\Microsoft.Cpp.props");

    // Extension settings
    xml << tag("ImportGroup")
        << attrTag("Label", "ExtensionSettings")
        << closetag();

    // PropertySheets
    for (int i = 0; i < tool.SingleProjects.count(); ++i) {
        xml << tag("ImportGroup")
            << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.SingleProjects.at(i).Configuration.Name))
            << attrTag("Label", "PropertySheets");

        xml << tag("Import")
            << attrTag("Project", "$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props")
            << attrTag("Condition", "exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')")
            << closetag()
            << closetag();
    }

    // UserMacros
    xml << tag("PropertyGroup")
        << attrTag("Label", "UserMacros")
        << closetag();

    xml << tag("PropertyGroup");
    for (int i = 0; i < tool.SingleProjects.count(); ++i) {

        if ( !tool.SingleProjects.at(i).Configuration.OutputDirectory.isEmpty() ) {
            xml << tag("OutDir")
                << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.SingleProjects.at(i).Configuration.Name))
                << valueTag(tool.SingleProjects.at(i).Configuration.OutputDirectory);
        }
        if ( !tool.SingleProjects.at(i).Configuration.IntermediateDirectory.isEmpty() ) {
            xml << tag("IntDir")
                << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.SingleProjects.at(i).Configuration.Name))
                << valueTag(tool.SingleProjects.at(i).Configuration.IntermediateDirectory);
        }
        if ( !tool.SingleProjects.at(i).Configuration.TargetName.isEmpty() ) {
            xml << tag("TargetName")
                << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.SingleProjects.at(i).Configuration.Name))
                << valueTag(tool.SingleProjects.at(i).Configuration.TargetName);
        }

        if ( tool.SingleProjects.at(i).Configuration.linker.IgnoreImportLibrary != unset) {
            xml << tag("IgnoreImportLibrary")
                << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.SingleProjects.at(i).Configuration.Name))
                << valueTagT(tool.SingleProjects.at(i).Configuration.linker.IgnoreImportLibrary);
        }

        if ( tool.SingleProjects.at(i).Configuration.linker.LinkIncremental != unset) {
            xml << tag("LinkIncremental")
                << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.SingleProjects.at(i).Configuration.Name))
                << valueTagT(tool.SingleProjects.at(i).Configuration.linker.LinkIncremental);
        }

        if ( tool.SingleProjects.at(i).Configuration.preBuild.UseInBuild != unset )
        {
            xml << tag("PreBuildEventUseInBuild")
                << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.SingleProjects.at(i).Configuration.Name))
                << valueTagT(tool.SingleProjects.at(i).Configuration.preBuild.UseInBuild);
        }

        if ( tool.SingleProjects.at(i).Configuration.preLink.UseInBuild != unset )
        {
            xml << tag("PreLinkEventUseInBuild")
                << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.SingleProjects.at(i).Configuration.Name))
                << valueTagT(tool.SingleProjects.at(i).Configuration.preLink.UseInBuild);
        }

        if ( tool.SingleProjects.at(i).Configuration.postBuild.UseInBuild != unset )
        {
            xml << tag("PostBuildEventUseInBuild")
                << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.SingleProjects.at(i).Configuration.Name))
                << valueTagT(tool.SingleProjects.at(i).Configuration.postBuild.UseInBuild);
        }
    }
    xml << closetag();

    for (int i = 0; i < tool.SingleProjects.count(); ++i) {
        xml << tag("ItemDefinitionGroup")
            << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.SingleProjects.at(i).Configuration.Name));

        // ClCompile
        xml << tool.SingleProjects.at(i).Configuration.compiler;

        // Link
        xml << tool.SingleProjects.at(i).Configuration.linker;

        // Midl
        xml << tool.SingleProjects.at(i).Configuration.idl;

        // ResourceCompiler
        xml << tool.SingleProjects.at(i).Configuration.resource;

        // Post build event
        if ( tool.SingleProjects.at(i).Configuration.postBuild.UseInBuild != unset )
            xml << tool.SingleProjects.at(i).Configuration.postBuild;
        
        // Pre build event
        if ( tool.SingleProjects.at(i).Configuration.preBuild.UseInBuild != unset )
            xml << tool.SingleProjects.at(i).Configuration.preBuild;

        // Pre link event
        if ( tool.SingleProjects.at(i).Configuration.preLink.UseInBuild != unset )
            xml << tool.SingleProjects.at(i).Configuration.preLink;

        xml << closetag();
    }

    // The file filters are added in a separate file for MSBUILD.
    QFile filterFile;
    filterFile.setFileName(Option::output.fileName().append(".filters"));
    filterFile.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate);
    QTextStream ts(&filterFile);
    XmlOutput xmlFilter(ts, XmlOutput::NoConversion);

    xmlFilter.setIndentString("  ");

    xmlFilter << decl("1.0", "utf-8")
              << tag("Project")
              << attrTag("ToolsVersion", "4.0")
              << attrTag("xmlns", "http://schemas.microsoft.com/developer/msbuild/2003");

    xmlFilter << tag("ItemGroup");

    tool.addFilters(xmlFilter, "Form Files");
    tool.addFilters(xmlFilter, "Generated Files");
    tool.addFilters(xmlFilter, "Header Files");
    tool.addFilters(xmlFilter, "LexYacc Files");
    tool.addFilters(xmlFilter, "Resource Files");
    tool.addFilters(xmlFilter, "Source Files");
    tool.addFilters(xmlFilter, "Translation Files");
    xmlFilter << closetag();

    tool.outputFilter(xml, xmlFilter, "Source Files");
    tool.outputFilter(xml, xmlFilter, "Header Files");
    tool.outputFilter(xml, xmlFilter, "Generated Files");
    tool.outputFilter(xml, xmlFilter, "LexYacc Files");
    tool.outputFilter(xml, xmlFilter, "Translation Files");
    tool.outputFilter(xml, xmlFilter, "Form Files");
    tool.outputFilter(xml, xmlFilter, "Resource Files");
    for (int x = 0; x < tool.ExtraCompilers.count(); ++x) {
        tool.outputFilter(xml, xmlFilter, tool.ExtraCompilers.at(x));
    }

    xml << import("Project", "$(VCTargetsPath)\\Microsoft.Cpp.targets");

    xml << tag("ImportGroup")
        << attrTag("Label", "ExtensionTargets")
        << closetag();

    return xml;
}

QT_END_NAMESPACE