1
1
package org .eclipse .linuxtools .internal .cdt .autotools .ui .wizards ;
2
2
3
+ import java .util .Map ;
4
+
5
+ import org .eclipse .cdt .build .core .scannerconfig .CfgInfoContext ;
6
+ import org .eclipse .cdt .build .core .scannerconfig .ICfgScannerConfigBuilderInfo2Set ;
7
+ import org .eclipse .cdt .build .internal .core .scannerconfig2 .CfgScannerConfigProfileManager ;
8
+ import org .eclipse .cdt .core .model .CoreModel ;
3
9
import org .eclipse .cdt .core .settings .model .ICConfigurationDescription ;
10
+ import org .eclipse .cdt .core .settings .model .ICProjectDescription ;
11
+ import org .eclipse .cdt .core .settings .model .ICProjectDescriptionManager ;
12
+ import org .eclipse .cdt .make .core .scannerconfig .IScannerConfigBuilderInfo2 ;
13
+ import org .eclipse .cdt .make .core .scannerconfig .IScannerConfigBuilderInfo2Set ;
14
+ import org .eclipse .cdt .make .core .scannerconfig .InfoContext ;
15
+ import org .eclipse .cdt .make .internal .core .scannerconfig2 .ScannerConfigProfileManager ;
4
16
import org .eclipse .cdt .managedbuilder .core .IConfiguration ;
17
+ import org .eclipse .cdt .managedbuilder .core .IInputType ;
5
18
import org .eclipse .cdt .managedbuilder .core .IManagedBuildInfo ;
6
19
import org .eclipse .cdt .managedbuilder .core .IProjectType ;
20
+ import org .eclipse .cdt .managedbuilder .core .IResourceInfo ;
7
21
import org .eclipse .cdt .managedbuilder .core .ManagedBuildManager ;
8
22
import org .eclipse .cdt .managedbuilder .ui .wizards .MBSWizardHandler ;
9
23
import org .eclipse .core .resources .IProject ;
@@ -23,6 +37,46 @@ public AutotoolsBuildWizardHandler(IProjectType pt, Composite parent, IWizard wi
23
37
super (pt , parent , wizard );
24
38
}
25
39
40
+ @ SuppressWarnings ("restriction" )
41
+ @ Override
42
+ public void createProject (IProject project , boolean defaults , boolean onFinish , IProgressMonitor monitor ) throws CoreException {
43
+ super .createProject (project , defaults , onFinish , monitor );
44
+ // Fix for bug #312298
45
+ // Following is required to get around the fact that the Scanner Discovery BuildInfo isn't
46
+ // created at this point. This is due to some complications caused by us superclassing the
47
+ // gnu gcc compiler or gnu g++ compiler as tools in our toolchain. We are essentially
48
+ // copying the logic from the Discovery Tab of the C/C++ Properties when the Ok button
49
+ // gets pushed. We reset the project description and this causes the Scanner Discovery
50
+ // BuildInfo to be written to the .cproject file. Without this fix, a new project
51
+ // will require rebuilding upon startup of Eclipse each time to recreate the Scanner
52
+ // Discovery info and avoid warnings regarding header files and errors regarding missing
53
+ // macro definitions. This code will likely go away when the Scanner Discovery mechanism
54
+ // gets rewritten in CDT (post 8.0).
55
+ ICProjectDescriptionManager mngr = CoreModel .getDefault ().getProjectDescriptionManager ();
56
+ ICProjectDescription des = mngr .getProjectDescription (project );
57
+ ICConfigurationDescription cfgd = des .getActiveConfiguration ();
58
+ IConfiguration cfg = ManagedBuildManager .getConfigurationForDescription (cfgd );
59
+ ICfgScannerConfigBuilderInfo2Set cbi = CfgScannerConfigProfileManager .getCfgScannerConfigBuildInfo (cfg );
60
+ IScannerConfigBuilderInfo2Set baseCbi = ScannerConfigProfileManager .createScannerConfigBuildInfo2Set (project );
61
+ Map <InfoContext , IScannerConfigBuilderInfo2 > baseInfoMap = baseCbi .getInfoMap ();
62
+ Map <CfgInfoContext , IScannerConfigBuilderInfo2 > infoMap = cbi .getInfoMap ();
63
+ for (CfgInfoContext cfgInfoContext : infoMap .keySet ()) {
64
+ @ SuppressWarnings ("unused" )
65
+ String s = null ;
66
+ IResourceInfo rcInfo = cfgInfoContext .getResourceInfo ();
67
+ if (rcInfo == null ) { // per configuration
68
+ s = cfgInfoContext .getConfiguration ().getName ();
69
+ } else { // per resource
70
+ IInputType typ = cfgInfoContext .getInputType ();
71
+ s = typ .getName ();
72
+ }
73
+ IScannerConfigBuilderInfo2 bi2 = infoMap .get (cfgInfoContext );
74
+ String profileId = bi2 .getSelectedProfileId ();
75
+ bi2 .setSelectedProfileId (profileId );
76
+ }
77
+ CoreModel .getDefault ().setProjectDescription (project , des );
78
+ }
79
+
26
80
@ Override
27
81
public void convertProject (IProject proj , IProgressMonitor monitor ) throws CoreException {
28
82
super .convertProject (proj , monitor );
0 commit comments