|
1 | 1 | using EnvDTE; |
2 | 2 | using Microsoft.VisualStudio.VCProjectEngine; |
| 3 | +using VCProjectUtils.Base; |
3 | 4 |
|
4 | 5 | #if VC14 |
5 | 6 | namespace VCProjectUtils.VS14 |
6 | 7 | #elif VC15 |
7 | 8 | namespace VCProjectUtils.VS15 |
8 | 9 | #endif |
9 | 10 | { |
10 | | - public class VCHelper : VCProjectUtils.Base.IVCHelper |
| 11 | + public class VCHelper : IVCHelper |
11 | 12 | { |
12 | 13 | public bool IsVCProject(Project project) |
13 | 14 | { |
@@ -82,6 +83,34 @@ public static VCCLCompilerTool GetCompilerTool(Project project, out string reaso |
82 | 83 | return compilerTool; |
83 | 84 | } |
84 | 85 |
|
| 86 | + public static VCLinkerTool GetLinkerTool(Project project, out string reasonForFailure) |
| 87 | + { |
| 88 | + VCProject vcProject = project?.Object as VCProject; |
| 89 | + if (vcProject == null) |
| 90 | + { |
| 91 | + reasonForFailure = "Failed to retrieve VCLinkerTool since project is not a VCProject."; |
| 92 | + return null; |
| 93 | + } |
| 94 | + VCConfiguration activeConfiguration = vcProject.ActiveConfiguration; |
| 95 | + var tools = activeConfiguration.Tools; |
| 96 | + VCLinkerTool linkerTool = null; |
| 97 | + foreach (var tool in activeConfiguration.Tools) |
| 98 | + { |
| 99 | + linkerTool = tool as VCLinkerTool; |
| 100 | + if (linkerTool != null) |
| 101 | + break; |
| 102 | + } |
| 103 | + |
| 104 | + if (linkerTool == null) |
| 105 | + { |
| 106 | + reasonForFailure = "Couldn't file a VCLinkerTool in VC++ Project."; |
| 107 | + return null; |
| 108 | + } |
| 109 | + |
| 110 | + reasonForFailure = ""; |
| 111 | + return linkerTool; |
| 112 | + } |
| 113 | + |
85 | 114 | public bool IsCompilableFile(Document document, out string reasonForFailure) |
86 | 115 | { |
87 | 116 | return GetVCFileConfigForCompilation(document, out reasonForFailure) != null; |
@@ -121,5 +150,14 @@ public string GetCompilerSetting_PreprocessorDefinitions(Project project, out st |
121 | 150 | VCCLCompilerTool compilerTool = GetCompilerTool(project, out reasonForFailure); |
122 | 151 | return compilerTool?.PreprocessorDefinitions; |
123 | 152 | } |
| 153 | + |
| 154 | + public TargetMachineType? GetLinkerSetting_TargetMachine(EnvDTE.Project project, out string reasonForFailure) |
| 155 | + { |
| 156 | + var linkerTool = GetLinkerTool(project, out reasonForFailure); |
| 157 | + if (linkerTool == null) |
| 158 | + return null; |
| 159 | + else |
| 160 | + return (TargetMachineType)linkerTool.TargetMachine; |
| 161 | + } |
124 | 162 | } |
125 | 163 | } |
0 commit comments