public CompilerToolWrapper(VCPropertySheet sheet) { compilerTool = ((IVCCollection)sheet.Tools).Item("VCCLCompilerTool") as VCCLCompilerTool; if (compilerTool == null) { compilerObj = ((IVCCollection)sheet.Tools).Item("VCCLCompilerTool"); compilerType = compilerObj.GetType(); } }
/// <summary> /// Parses the configuration (e.g. Debug, Release) passed in. /// </summary> private void parseConfiguration(VCConfiguration vcConfiguration) { ProjectConfigurationInfo_CPP configurationInfo = new ProjectConfigurationInfo_CPP(); configurationInfo.ParentProjectInfo = m_projectInfo; IVCCollection sheets = Utils.call(() => (vcConfiguration.PropertySheets as IVCCollection)); int numSheets = Utils.call(() => (sheets.Count)); for (int i = 1; i <= numSheets; ++i) { VCPropertySheet sheet = Utils.call(() => (sheets.Item(i) as VCPropertySheet)); // 1. The thing is that VCPropertySheet and VCConfiguration have more-or-less // identical interfaces. So we should be able to merge them fairly easily. // // 2. We should try multiple layers of inheritance IVCCollection tools = Utils.call(() => (sheet.Tools as IVCCollection)); VCCLCompilerTool compilerTool = Utils.call(() => (tools.Item("VCCLCompilerTool") as VCCLCompilerTool)); } // The configuration name... configurationInfo.Name = Utils.call(() => (vcConfiguration.ConfigurationName)); // The project type. // Note: we are assuming that all the configurations for the project build the // same type of target. m_projectInfo.ProjectType = parseConfiguration_Type(vcConfiguration); // We get the intermediates folder and output folder... configurationInfo.IntermediateFolder = parseConfiguration_Folder(vcConfiguration, () => (vcConfiguration.IntermediateDirectory)); configurationInfo.OutputFolder = parseConfiguration_Folder(vcConfiguration, () => (vcConfiguration.OutputDirectory)); // We get compiler settings, such as the include path and // preprocessor definitions... parseConfiguration_CompilerSettings(vcConfiguration, configurationInfo); // We get linker settings, such as any libs to link and the library path... parseConfiguration_LinkerSettings(vcConfiguration, configurationInfo); // We parse librarian settings (how libraries are linked)... parseConfiguration_LibrarianSettings(vcConfiguration, configurationInfo); // We see if there are any pre- or post- build events set up for this // configuration. The only types of events we know how to deal with are // ones that invoke a .cmd file. For these we convert them to invoke // a .sh file with the same name. parseConfiguration_PreBuildEvent(vcConfiguration, configurationInfo); parseConfiguration_PostBuildEvent(vcConfiguration, configurationInfo); // We add the configuration to the collection of them for the project... m_projectInfo.addConfigurationInfo(configurationInfo); }
public static CompilerToolWrapper Create(VCPropertySheet sheet) { CompilerToolWrapper wrapper = null; try { wrapper = new CompilerToolWrapper(((IVCCollection)sheet.Tools) .Item("VCCLCompilerTool")); } catch { } return(wrapper.IsNull() ? null : wrapper); }
/// <summary> /// Finds the linker settings, such as the collection of libraries to link, /// for the configuration passed in. /// </summary> private void parseConfiguration_LinkerSettings(VCConfiguration vcConfiguration, ProjectConfigurationInfo_CPP configurationInfo) { // We get the linker-settings 'tool'... IVCCollection tools = Utils.call(() => (vcConfiguration.Tools as IVCCollection)); VCLinkerTool linkerTool = Utils.call(() => (tools.Item("VCLinkerTool") as VCLinkerTool)); if (linkerTool == null) { // Not all projects have a linker tools... return; } // And extract various details from it... parseLinkerSettings_LibraryPath(vcConfiguration, linkerTool, configurationInfo); parseLinkerSettings_Libraries(vcConfiguration, linkerTool, configurationInfo); parseLinkerSettings_Misc(vcConfiguration, linkerTool, configurationInfo); IVCCollection sheets = Utils.call(() => (vcConfiguration.PropertySheets as IVCCollection)); int numSheets = Utils.call(() => (sheets.Count)); for (int i = 1; i <= numSheets; ++i) { VCPropertySheet sheet = Utils.call(() => (sheets.Item(i) as VCPropertySheet)); if (!sheet.IsSystemPropertySheet) { // 1. The thing is that VCPropertySheet and VCConfiguration have more-or-less // identical interfaces. So we should be able to merge them fairly easily. // // 2. We should try multiple layers of inheritance IVCCollection toolsInSheet = Utils.call(() => (sheet.Tools as IVCCollection)); VCLinkerTool linkerToolInSheet = Utils.call(() => (toolsInSheet.Item("VCLinkerTool") as VCLinkerTool)); // And extract various details from it... if (linkerToolInSheet != null) { parseLinkerSettings_LibraryPath(vcConfiguration, linkerToolInSheet, configurationInfo); parseLinkerSettings_Libraries(vcConfiguration, linkerToolInSheet, configurationInfo); } } } }
/// <summary> /// Finds compiler settings, such as the include path, for the configuration /// passed in. /// </summary> private void parseConfiguration_CompilerSettings(VCConfiguration vcConfiguration, ProjectConfigurationInfo_CPP configurationInfo) { // We get the compiler-settings 'tool'... IVCCollection tools = Utils.call(() => (vcConfiguration.Tools as IVCCollection)); VCCLCompilerTool compilerTool = Utils.call(() => (tools.Item("VCCLCompilerTool") as VCCLCompilerTool)); // And extract various details from it... parseCompilerSettings_IncludePath(vcConfiguration, compilerTool, configurationInfo); parseCompilerSettings_PreprocessorDefinitions(vcConfiguration, compilerTool, configurationInfo); parseCompilerSettings_CompilerFlags(vcConfiguration, compilerTool, configurationInfo); IVCCollection sheets = Utils.call(() => (vcConfiguration.PropertySheets as IVCCollection)); int numSheets = Utils.call(() => (sheets.Count)); for (int i = 1; i <= numSheets; ++i) { VCPropertySheet sheet = Utils.call(() => (sheets.Item(i) as VCPropertySheet)); if (!sheet.IsSystemPropertySheet) { // 1. The thing is that VCPropertySheet and VCConfiguration have more-or-less // identical interfaces. So we should be able to merge them fairly easily. // // 2. We should try multiple layers of inheritance IVCCollection toolsInSheet = Utils.call(() => (sheet.Tools as IVCCollection)); VCCLCompilerTool compilerToolInSheet = Utils.call(() => (toolsInSheet.Item("VCCLCompilerTool") as VCCLCompilerTool)); // And extract various details from it... if (compilerToolInSheet != null) { parseCompilerSettings_IncludePath(vcConfiguration, compilerToolInSheet, configurationInfo); parseCompilerSettings_PreprocessorDefinitions(vcConfiguration, compilerToolInSheet, configurationInfo); //parseCompilerSettings_CompilerFlags(vcConfiguration, compilerToolInSheet, configurationInfo); } } } }
public List <IVCPropertySheetWrapper> GetPropertySheets() { List <IVCPropertySheetWrapper> propertySheetsWrappers = new List <IVCPropertySheetWrapper>(); try { IEnumerable wrappedPropertySheets = _wrapped.PropertySheets; foreach (Object wrappedPropertySheet in wrappedPropertySheets) { VCPropertySheet vcPropertySheet = wrappedPropertySheet as VCPropertySheet; if (vcPropertySheet != null) { IVCPropertySheetWrapper wrapper = new #if (VS2012) VCPropertySheetWrapperVs2012 #elif (VS2013) VCPropertySheetWrapperVs2013 #elif (VS2015) VCPropertySheetWrapperVs2015 #elif (VS2017) VCPropertySheetWrapperVs2017 #endif (vcPropertySheet); if (wrapper != null && wrapper.isValid()) { propertySheetsWrappers.Add(wrapper); } } } } catch (Exception e) { Logging.LogError("Configuration failed to retreive property sheets: " + e.Message); } return(propertySheetsWrappers); }
/// <summary> /// Helper method that gets the tool object. /// </summary> static private object GetTool(ArgData data, int sheetIndex) { if (sheetIndex >= data.numSheets) { return(null); // reached the last sheet } else { IVCCollection tools; if (sheetIndex == 0) { // get the tools of the VCConfiguration itself (top level) tools = Utils.call(() => (data.conf.Tools as IVCCollection)); } else { // get the tools of the Nth property sheet VCPropertySheet sheet = Utils.call(() => (data.sheets.Item(sheetIndex) as VCPropertySheet)); tools = Utils.call(() => (sheet.Tools as IVCCollection)); } return(Utils.call(() => tools.Item(data.toolName))); } }
VCPropertySheetWrapperVs2017 #endif (object wrapped) { _wrapped = wrapped as VCPropertySheet; }
private List<string> GetIncludesFromPropertySheet(VCPropertySheet sheet) { List<string> includeList = GetIncludesFromCompilerTool(CompilerToolWrapper.Create(sheet)); IVCCollection propertySheets = sheet.PropertySheets as IVCCollection; if (propertySheets != null) foreach (VCPropertySheet subSheet in propertySheets) includeList.AddRange(GetIncludesFromPropertySheet(subSheet)); return includeList; }
private List<string> GetDefinesFromPropertySheet(VCPropertySheet sheet) { List<string> defines = CompilerToolWrapper.Create(sheet).PreprocessorDefinitions; IVCCollection propertySheets = sheet.PropertySheets as IVCCollection; if (propertySheets != null) foreach (VCPropertySheet subSheet in propertySheets) defines.AddRange(GetDefinesFromPropertySheet(subSheet)); return defines; }
public void CreateTestCocoonConfig(String config, string project, List <string> additionalParamsList, List <string> additiona_includes, bool QtConfiguration) { bool foundProject = false; IEnumerator ProjectsEnumaror = GetVCProjectRefs(); ProjectsEnumaror.Reset(); // traverse all projects to find the right one while (ProjectsEnumaror.MoveNext()) { VCProject actVCP = (VCProject)ProjectsEnumaror.Current; if (actVCP.Name == project) { foundProject = true; VCConfiguration vcC = null; //vcC = (VCConfiguration)(((IVCCollection)actVCP.Configurations).Item(config)); IEnumerator ConfigurationEnumarator = ((IVCCollection)actVCP.Configurations).GetEnumerator(); for (ConfigurationEnumarator.Reset(); ConfigurationEnumarator.MoveNext();) { vcC = ConfigurationEnumarator.Current as VCConfiguration; if ((vcC != null) && (vcC.ConfigurationName == config)) { Log("Modifying configuration '" + config + "' for the project '" + project + "' for the platform '" + vcC.Name + "'"); // change settings for sepcified compiler IVCCollection ctools = (IVCCollection)vcC.Tools; VCActiveXReference cVCActiveXReference = ctools.Item("VCActiveXReference") as VCActiveXReference; VCALinkTool cVCALinkTool = ctools.Item("VCALinkTool") as VCALinkTool; VCAppVerifierTool cVCAppVerifierTool = ctools.Item("VCAppVerifierTool") as VCAppVerifierTool; VCAssemblyReference cVCAssemblyReference = ctools.Item("VCAssemblyReference") as VCAssemblyReference; VCBscMakeTool cVCBscMakeTool = ctools.Item("VCBscMakeTool") as VCBscMakeTool; VCCLCompilerTool cVCCLCompilerTool = ctools.Item("VCCLCompilerTool") as VCCLCompilerTool; VCConfiguration cVCConfiguration = ctools.Item("VCConfiguration") as VCConfiguration; VCCustomBuildRule cVCCustomBuildRule = ctools.Item("VCCustomBuildRule") as VCCustomBuildRule; VCCustomBuildTool cVCCustomBuildTool = ctools.Item("VCCustomBuildTool") as VCCustomBuildTool; VCDebugSettings cVCDebugSettings = ctools.Item("VCDebugSettings") as VCDebugSettings; VCFile cVCFile = ctools.Item("VCFile") as VCFile; VCFileConfiguration cVCFileConfiguration = ctools.Item("VCFileConfiguration") as VCFileConfiguration; VCFilter cVCFilter = ctools.Item("VCFilter") as VCFilter; VCFxCopTool cVCFxCopTool = ctools.Item("VCFxCopTool") as VCFxCopTool; VCLibrarianTool cVCLibrarianTool = ctools.Item("VCLibrarianTool") as VCLibrarianTool; VCLinkerTool cVCLinkerTool = ctools.Item("VCLinkerTool") as VCLinkerTool; VCManagedResourceCompilerTool cVCManagedResourceCompilerTool = ctools.Item("VCManagedResourceCompilerTool") as VCManagedResourceCompilerTool; VCManifestTool cVCManifestTool = ctools.Item("VCManifestTool") as VCManifestTool; VCMidlTool cVCMidlTool = ctools.Item("VCMidlTool") as VCMidlTool; VCNMakeTool cVCNMakeTool = ctools.Item("VCNMakeTool") as VCNMakeTool; VCPlatform cVCPlatform = ctools.Item("VCPlatform") as VCPlatform; VCPostBuildEventTool cVCPostBuildEventTool = ctools.Item("VCPostBuildEventTool") as VCPostBuildEventTool; VCPreBuildEventTool cVCPreBuildEventTool = ctools.Item("VCPreBuildEventTool") as VCPreBuildEventTool; VCPreLinkEventTool cVCPreLinkEventTool = ctools.Item("VCPreLinkEventTool") as VCPreLinkEventTool; VCProject cVCProject = ctools.Item("VCProject") as VCProject; VCProjectEngine cVCProjectEngine = ctools.Item("VCProjectEngine") as VCProjectEngine; VCProjectEngineEvents cVCProjectEngineEvents = ctools.Item("VCProjectEngineEvents") as VCProjectEngineEvents; VCProjectEngineObject cVCProjectEngineObject = ctools.Item("VCProjectEngineObject") as VCProjectEngineObject; VCProjectItem cVCProjectItem = ctools.Item("VCProjectItem") as VCProjectItem; VCProjectReference cVCProjectReference = ctools.Item("VCProjectReference") as VCProjectReference; VCPropertySheet cVCPropertySheet = ctools.Item("VCPropertySheet") as VCPropertySheet; VCReference cVCReference = ctools.Item("VCReference") as VCReference; VCReferences cVCReferences = ctools.Item("VCReferences") as VCReferences; VCResourceCompilerTool cVCResourceCompilerTool = ctools.Item("VCResourceCompilerTool") as VCResourceCompilerTool; VCRuntimeBooleanProperty cVCRuntimeBooleanProperty = ctools.Item("VCRuntimeBooleanProperty") as VCRuntimeBooleanProperty; VCRuntimeEnumProperty cVCRuntimeEnumProperty = ctools.Item("VCRuntimeEnumProperty") as VCRuntimeEnumProperty; VCRuntimeEnumValue cVCRuntimeEnumValue = ctools.Item("VCRuntimeEnumValue") as VCRuntimeEnumValue; VCRuntimeIntegerProperty cVCRuntimeIntegerProperty = ctools.Item("VCRuntimeIntegerProperty") as VCRuntimeIntegerProperty; VCRuntimeProperty cVCRuntimeProperty = ctools.Item("VCRuntimeProperty") as VCRuntimeProperty; VCRuntimeStringProperty cVCRuntimeStringProperty = ctools.Item("VCRuntimeStringProperty") as VCRuntimeStringProperty; VCToolFile cVCToolFile = ctools.Item("VCToolFile") as VCToolFile; VCUserMacro cVCUserMacro = ctools.Item("VCUserMacro") as VCUserMacro; VCWebDeploymentTool cVCWebDeploymentTool = ctools.Item("VCWebDeploymentTool") as VCWebDeploymentTool; VCWebServiceProxyGeneratorTool cVCWebServiceProxyGeneratorTool = ctools.Item("VCWebServiceProxyGeneratorTool") as VCWebServiceProxyGeneratorTool; VCXDCMakeTool cVCXDCMakeTool = ctools.Item("VCXDCMakeTool") as VCXDCMakeTool; VCXMLDataGeneratorTool cVCXMLDataGeneratorTool = ctools.Item("VCXMLDataGeneratorTool") as VCXMLDataGeneratorTool; VCLinkerTool linkerTool = ctools.Item("VCLinkerTool") as VCLinkerTool; VCLibrarianTool librarianTool = ctools.Item("VCLibrarianTool") as VCLibrarianTool; VCCLCompilerTool compilerTool = ctools.Item("VCCLCompilerTool") as VCCLCompilerTool; VCCustomBuildTool customBuildTool = ctools.Item("VCCustomBuildTool") as VCCustomBuildTool; string libgen = FindCslibConfig(ref compilerTool); List <string> additionalParamsListLink = new List <string>(additionalParamsList); List <string> additionalParamsListLibrarian = new List <string>(additionalParamsList); if (libgen != null) { additionalParamsListLink.Add("--cs-libgen=" + libgen); additionalParamsListLibrarian.Add("--cs-libgen=" + libgen); } if (compilerTool != null) { CreateClConfig(ref compilerTool, additionalParamsList, additiona_includes, actVCP.ProjectDirectory, config); } if (linkerTool != null) { CreateLinkConfig(ref linkerTool, additionalParamsListLink, config); } if (customBuildTool != null) { CreateCustomBuildConfig(ref customBuildTool, additionalParamsList, config); } if (librarianTool != null) { CreateLibrarianConfig(ref librarianTool, additionalParamsListLibrarian, config); } if (actVCP != null) { CreateConfigForEachFile(ref actVCP, additionalParamsList, config); } } } } } if (!foundProject) { ShowMessageBox("Could not find the project", "Warning"); } }
public static CompilerToolWrapper Create(VCPropertySheet sheet) { CompilerToolWrapper wrapper = null; try { wrapper = new CompilerToolWrapper(((IVCCollection)sheet.Tools).Item("VCCLCompilerTool")); } catch { } return wrapper.IsNull() ? null : wrapper; }
public VCPropertySheetWrapper(VCPropertySheet propertySheet) { _propertySheet = propertySheet; }