@@ -7,19 +7,37 @@ namespace VSPackage.CPPCheckPlugin
77{
88 class SourceFile
99 {
10- public SourceFile ( string fullPath , string projectBasePath )
10+ public enum VCCompilerVersion { vc2010 , vc2012 , vc2013 , vcFuture } ;
11+
12+ public SourceFile ( string fullPath , string projectBasePath , string vcCompilerName )
1113 {
1214 _fullPath = cleanPath ( fullPath ) ;
1315 _projectBasePath = cleanPath ( projectBasePath ) ;
16+
17+ if ( vcCompilerName . Contains ( "2010" ) )
18+ _compilerVersion = VCCompilerVersion . vc2010 ;
19+ else if ( vcCompilerName . Contains ( "2012" ) )
20+ _compilerVersion = VCCompilerVersion . vc2012 ;
21+ else if ( vcCompilerName . Contains ( "2013" ) )
22+ _compilerVersion = VCCompilerVersion . vc2013 ;
23+ else
24+ _compilerVersion = VCCompilerVersion . vcFuture ;
1425 }
1526
1627 // All include paths being added are resolved against projectBasePath
1728 public void addIncludePath ( string path )
1829 {
19- if ( ! String . IsNullOrEmpty ( _projectBasePath ) && ! String . IsNullOrEmpty ( path ) )
30+ if ( ! String . IsNullOrEmpty ( _projectBasePath ) && ! String . IsNullOrEmpty ( path ) && ! path . Equals ( "." ) && ! path . Equals ( " \\ \" . \\ \" " ) )
2031 {
21- Debug . WriteLine ( "Processing path: " + path ) ;
22- _includePaths . Add ( cleanPath ( path . Contains ( ":" ) ? path : Path . Combine ( _projectBasePath , path ) ) ) ;
32+ Debug . WriteLine ( "Processing path: " + path ) ;
33+ if ( path . Contains ( "\\ :" ) ) // absolute path
34+ _includePaths . Add ( cleanPath ( path ) ) ;
35+ else
36+ {
37+ // Relative path - converting to absolute
38+ String pathForCombine = path . Replace ( "\" " , String . Empty ) . TrimStart ( '\\ ' , '/' ) ;
39+ _includePaths . Add ( cleanPath ( Path . GetFullPath ( Path . Combine ( _projectBasePath , pathForCombine ) ) ) ) ; // Workaround for Path.Combine bugs
40+ }
2341 }
2442 }
2543
@@ -71,6 +89,11 @@ public List<string> Macros
7189 get { return _activeMacros ; }
7290 }
7391
92+ public VCCompilerVersion vcCompilerVersion
93+ {
94+ get { return _compilerVersion ; }
95+ }
96+
7497 private static string cleanPath ( string path )
7598 {
7699 string result = path . Replace ( "\" " , "" ) . Replace ( "\\ \\ " , "\\ " ) ;
@@ -85,5 +108,6 @@ private static string cleanPath(string path)
85108 private string _projectBasePath = null ;
86109 private List < string > _includePaths = new List < string > ( ) ;
87110 private List < string > _activeMacros = new List < string > ( ) ;
111+ private VCCompilerVersion _compilerVersion ;
88112 }
89113}
0 commit comments