string GetOutputDirectoryNotTrimmed() { var outputPath = generalRule.GetEvaluatedPropertyValue( ProjectPropertyName.OutputDirectory); // Support project relative path: if the output directory is not rooted, treat it as a // path under project directory. if (!Path.IsPathRooted(outputPath)) { return(FileUtil.GetFullPath(outputPath, GetAbsoluteRootPathNotTrimmed())); } return(outputPath); }
private ProjectProperties.StandardVersion GetStandardVersion(VCConfiguration config) { IVCRulePropertyStorage generalRule = config.Rules.Item("ConfigurationGeneral"); string value = null; try { value = generalRule == null ? null : generalRule.GetEvaluatedPropertyValue("LanguageStandard"); } catch (Exception) { } if (value == "Default") { return(ProjectProperties.StandardVersion.Default); } else if (value == "stdcpp14") { return(ProjectProperties.StandardVersion.Cpp14); } else if (value == "stdcpp17") { return(ProjectProperties.StandardVersion.Cpp17); } else if (value == "stdcpplatest") { return(ProjectProperties.StandardVersion.Latest); } return(ProjectProperties.StandardVersion.Latest); }
/// <summary> /// Tests that a given property contains a specific string in a certain VCConfiguration /// </summary> /// <param name="configuration">Gives the platform and configuration type</param> /// <param name="pageName">Property page name where property resides.</param> /// <param name="propertyName">Name of the property to check.</param> /// <param name="expectedValue">Expected string to contain.</param> /// <param name="ignoreCase">Ignore case when comparing the expected and actual values.</param> public static void AssertPropertyContains( VCConfiguration configuration, string pageName, string propertyName, string expectedValue, bool ignoreCase, bool expand = false) { StringComparison caseSensitive = ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal; IVCRulePropertyStorage rule = configuration.Rules.Item(pageName); string propertyValue; if (expand) { propertyValue = rule.GetEvaluatedPropertyValue(propertyName); } else { propertyValue = rule.GetUnevaluatedPropertyValue(propertyName); } string message = string.Format( "{0} should be contained in {1}. Page: {2}, Property: {3}, Configuration: {4}", expectedValue, propertyValue, pageName, propertyName, configuration.ConfigurationName); Assert.IsTrue(propertyValue.Contains(expectedValue, caseSensitive), message); }
public string GetLanguageStandard() { try { string rawStandardString = _wrappedRules.GetEvaluatedPropertyValue("LanguageStandard"); if (rawStandardString != "stdcpplatest" && rawStandardString.IndexOf("stdcpp") == 0) { return(rawStandardString.Replace("stdcpp", "c++")); } } catch (Exception e) { Logging.LogInfo("Unable to fetch language standard from project configuration, using default standard instead."); } return(""); }
/// <summary> /// Returns the value of a property that might not be supported by the current version of the compiler. /// If the property is not supported the default value is returned. /// </summary> /// <remarks>e.g. LanguageStandard is not supported by VS2015 so attempting to fetch the property will throw. /// We don't want the analysis to fail in that case so we'll catch the exception and return the default.</remarks> internal /* for testing */ static string GetPotentiallyUnsupportedPropertyValue(IVCRulePropertyStorage settings, string propertyName, string defaultValue) { try { return(settings.GetEvaluatedPropertyValue(propertyName)); } catch (Exception ex) when(!ErrorHandler.IsCriticalException(ex)) { // Property was not found return(defaultValue); } }
private static string GetInstallationDirectoryImpl(ISettingsService settingsService, VCConfiguration configuration) { string installPath = ".conan"; if (settingsService != null && settingsService.GetConanGenerator() == ConanGeneratorType.visual_studio) { IVCRulePropertyStorage generalSettings = configuration.Rules.Item("ConfigurationGeneral"); string outputDirectory = generalSettings.GetEvaluatedPropertyValue("OutDir"); return(Path.Combine(outputDirectory, installPath)); } return(Path.Combine(configuration.project.ProjectDirectory, installPath)); }
private static ConanConfiguration ExtractConanConfiguration(VCConfiguration configuration) { var x = configuration.Platform; IVCRulePropertyStorage generalSettings = configuration.Rules.Item("ConfigurationGeneral"); var toolset = generalSettings.GetEvaluatedPropertyValue("PlatformToolset"); return(new ConanConfiguration { Architecture = GetArchitecture(configuration.Platform.Name), BuildType = GetBuildType(configuration.ConfigurationName), CompilerToolset = toolset, CompilerVersion = "15" }); }
/// <summary> /// </summary> protected string GetPropertyValue(string pageRule, string propertyName, bool evaluated = true, object configName = null) { if (configName == null) { configName = 1; } IVCCollection configs = Project.Configurations; VCConfiguration config = configs.Item(configName); IVCRulePropertyStorage storage = config.Rules.Item(pageRule); return(evaluated ? storage.GetEvaluatedPropertyValue(propertyName) : storage.GetUnevaluatedPropertyValue(propertyName)); }
private static Dictionary <string, string> getParametersFromFakeProperties(IVCRulePropertyStorage vcfprop, System.Reflection.PropertyInfo[] props) { var parameters = new Dictionary <string, string>(); foreach (var p in props) { var val = vcfprop.GetEvaluatedPropertyValue(p.Name); if (!string.IsNullOrEmpty(val)) { parameters[p.Name] = val; } } return(parameters); }
private static ConanConfiguration ExtractConanConfiguration(ISettingsService settingsService, VCConfiguration configuration) { IVCRulePropertyStorage generalSettings = configuration.Rules.Item("ConfigurationGeneral"); var toolset = generalSettings.GetEvaluatedPropertyValue("PlatformToolset"); string installPath = GetInstallationDirectoryImpl(settingsService, configuration); var VCCLCompilerTool = configuration.Tools.Item("VCCLCompilerTool"); return(new ConanConfiguration { Architecture = GetArchitecture(configuration.Platform.Name), BuildType = GetBuildType(configuration.ConfigurationName), CompilerToolset = toolset, CompilerVersion = "15", InstallPath = installPath, RuntimeLibrary = runtimeLibraryToString(VCCLCompilerTool.RuntimeLibrary) }); }
/// <summary> /// Returns the target file name. This can be a relative path. /// </summary> string GetTargetFileNameProperty() { // TODO: Refactor to remove conditonal logic based on project type. // Unknown configuration type maps to Makefile projects. string fileName; if (vcProject.ActiveConfiguration.ConfigurationType == ConfigurationTypes.typeUnknown) { fileName = nmakeRule.GetEvaluatedPropertyValue(ProjectPropertyName.NMakeOutput); } else { fileName = generalRule.GetEvaluatedPropertyValue( ProjectPropertyName.TargetFileName); } if (fileName == null) { fileName = ""; } return(fileName); }
/// <summary> /// Reads any generic property from the current target properties. /// </summary> /// <param name="page">Name of the page where the property is located.</param> /// <param name="name">Name of the property.</param> /// <returns>The property requested.</returns> public virtual string GetProperty(string page, string name) { IVCRulePropertyStorage pageStorage = configuration_.Rules.Item(page); return(pageStorage.GetEvaluatedPropertyValue(name)); }
protected override bool BeforeTraverseProject(Project project) { try { var projInfo = FindProjectInfo(project.UniqueName); // Skip unselected projects if (m_onlySelectedProjects) { var projectID = project.UniqueName; if (!m_selectedProjID.Contains(projectID)) { return(false); } } Logger.Debug("Traversing Project:" + project.Name); var codeModel = project.CodeModel; if (codeModel != null) { if (codeModel.Language == CodeModelLanguageConstants.vsCMLanguageCSharp) { projInfo.m_language = "csharp"; } else if (codeModel.Language == CodeModelLanguageConstants.vsCMLanguageVC) { projInfo.m_language = "cpp"; } else { projInfo.m_language = ""; } } //var configMgr = project.ConfigurationManager; //var config = configMgr.ActiveConfiguration as Configuration; var vcProject = project.Object as VCProject; Logger.Debug("check vc project"); if (vcProject != null) { var vccon = vcProject.ActiveConfiguration as VCConfiguration; IVCRulePropertyStorage generalRule = vccon.Rules.Item("ConfigurationDirectories"); IVCRulePropertyStorage cppRule = vccon.Rules.Item("CL"); // Parsing include path string addIncPath = cppRule.GetEvaluatedPropertyValue("AdditionalIncludeDirectories"); string incPath = generalRule.GetEvaluatedPropertyValue("IncludePath"); string allIncPath = incPath + ";" + addIncPath; string[] pathList = allIncPath.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); var projectInc = new HashSet <string>(); var projectPath = Path.GetDirectoryName(project.FileName); foreach (var item in pathList) { string path = item.Trim(); if (!path.Contains(":")) { // relative path path = Path.Combine(projectPath, path); path = Path.GetFullPath((new Uri(path)).LocalPath); } if (!Directory.Exists(path)) { continue; } path = path.Replace('\\', '/').Trim(); projectInc.Add(path); Logger.Debug("include path:" + path); } projInfo.m_includePath = projectInc; // Parsing define string defines = cppRule.GetEvaluatedPropertyValue("PreprocessorDefinitions"); string[] defineList = defines.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); var defineSet = new HashSet <string>(); foreach (var item in defineList) { defineSet.Add(item); } projInfo.m_defines = defineSet; } } catch { Logger.Debug("project error-------------"); } return(true); }
protected override bool BeforeTraverseProject(Project project) { //var propertyIter = project.Properties.GetEnumerator(); //while (propertyIter.MoveNext() && false) //{ // var item = propertyIter.Current as Property; // if (item == null) // { // continue; // } // string propName = item.Name; // string propValue = ""; // try // { // propValue = item.Value.ToString(); // } // catch // { // } // Logger.WriteLine(" " + propName + ":" + propValue); //} try { // Skip unselected projects if (m_onlySelectedProjects) { var projectID = project.UniqueName; if (!m_selectedProjID.Contains(projectID)) { return(false); } } Logger.Debug("Traversing Project:" + project.Name); var codeModel = project.CodeModel; if (codeModel != null) { var projInfo = FindProjectInfo(project.UniqueName); if (codeModel.Language == CodeModelLanguageConstants.vsCMLanguageCSharp) { projInfo.m_language = "csharp"; } else if (codeModel.Language == CodeModelLanguageConstants.vsCMLanguageVC) { projInfo.m_language = "cpp"; } else { projInfo.m_language = ""; } } //var configMgr = project.ConfigurationManager; //var config = configMgr.ActiveConfiguration as Configuration; var vcProject = project.Object as VCProject; Logger.Debug("check vc project"); if (vcProject != null) { var vccon = vcProject.ActiveConfiguration as VCConfiguration; IVCRulePropertyStorage generalRule = vccon.Rules.Item("ConfigurationDirectories"); IVCRulePropertyStorage cppRule = vccon.Rules.Item("CL"); // Parsing include path string addIncPath = cppRule.GetEvaluatedPropertyValue("AdditionalIncludeDirectories"); string incPath = generalRule.GetEvaluatedPropertyValue("IncludePath"); string allIncPath = incPath + ";" + addIncPath; string[] pathList = allIncPath.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); var projectInc = new HashSet <string>(); var projectPath = Path.GetDirectoryName(project.FileName); foreach (var item in pathList) { string path = item.Trim(); if (!path.Contains(":")) { // relative path path = Path.Combine(projectPath, path); path = Path.GetFullPath((new Uri(path)).LocalPath); } if (!Directory.Exists(path)) { continue; } path = path.Replace('\\', '/').Trim(); projectInc.Add(path); Logger.Debug("include path:" + path); } var projInfo = FindProjectInfo(project.UniqueName); projInfo.m_includePath = projectInc; // Parsing define string defines = cppRule.GetEvaluatedPropertyValue("PreprocessorDefinitions"); string[] defineList = defines.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); var defineSet = new HashSet <string>(); foreach (var item in defineList) { defineSet.Add(item); } projInfo.m_defines = defineSet; } //foreach (VCConfiguration vccon in vcProject.Configurations) //{ // string ruleStr = "ConfigurationDirectories"; // IVCRulePropertyStorage generalRule = vccon.Rules.Item(ruleStr); // IVCRulePropertyStorage cppRule = vccon.Rules.Item("CL"); // string addIncPath = cppRule.GetEvaluatedPropertyValue("AdditionalIncludeDirectories"); // string incPath = generalRule.GetEvaluatedPropertyValue("IncludePath"); // string outputPath = vccon.OutputDirectory; // //vccon.OutputDirectory = "$(test)"; // //string test1 = generalRule.GetEvaluatedPropertyValue(2); // //string incPath = generalRule.GetEvaluatedPropertyValue("IncludePath"); // //string name = generalRule.GetEvaluatedPropertyValue("TargetName"); // Logger.WriteLine("include path:" + incPath); //} //dynamic propertySheet = vcConfig.PropertySheets; //IVCCollection propertySheetCollection = propertySheet as IVCCollection; //foreach (var item in propertySheetCollection) //{ // var vcPropertySheet = item as VCPropertySheet; // if (vcPropertySheet != null) // { // foreach(var rule in vcPropertySheet.Rules) // { // var vcRule = rule as IVCRulePropertyStorage; // if (vcRule != null) // { // vcRule.GetEvaluatedPropertyValue() // } // } // } //} //var config = vcProject.ActiveConfiguration; //if (config != null) //{ // var configProps = config.Properties; // var configPropIter = configProps.GetEnumerator(); // while (configPropIter.MoveNext()) // { // var configProp = configPropIter.Current as Property; // var configName = configProp.Name; // var configVal = ""; // try // { // configVal = configProp.Value.ToString(); // } // catch // { // } // Logger.WriteLine(" " + configName + ":" + configVal); // } // //Logger.WriteLine("group----------------------------"); // //var groups = config.OutputGroups; // //var groupIter = groups.GetEnumerator(); // //while (groupIter.MoveNext()) // //{ // // var group = groupIter.Current as OutputGroup; // // group. // //} //} } catch { Logger.Debug("project error-------------"); } return(true); }
public string[] GetAdditionalIncludeDirectories() { return(_wrappedRules.GetEvaluatedPropertyValue("AdditionalIncludeDirectories").SplitPaths()); }
public string[] GetIncludeSearchPaths() { return(_wrappedRules.GetEvaluatedPropertyValue("NMakeIncludeSearchPath").SplitPaths()); }
public LaunchConfiguration GetLaunchConfigurationFromProjectProperties(IDictionary <string, string> projectProperties) #endif { LoggingUtils.PrintFunction(); // // Retrieve standard project macro values, and determine the preferred debugger configuration. // string projectTargetName = EvaluateProjectProperty(projectProperties, "ConfigurationGeneral", "TargetName"); string projectProjectDir = EvaluateProjectProperty(projectProperties, "ConfigurationGeneral", "ProjectDir"); string debuggerMode = EvaluateProjectProperty(projectProperties, "AndroidPlusPlusDebugger", "DebuggerConfigMode"); string debuggerTargetApk = EvaluateProjectProperty(projectProperties, "AndroidPlusPlusDebugger", "DebuggerConfigTargetApk"); string debuggerUpToDateCheck = EvaluateProjectProperty(projectProperties, "AndroidPlusPlusDebugger", "DebuggerConfigUpToDateCheck"); string debuggerLaunchActivity = EvaluateProjectProperty(projectProperties, "AndroidPlusPlusDebugger", "DebuggerConfigLaunchActivity"); string debuggerDebugMode = EvaluateProjectProperty(projectProperties, "AndroidPlusPlusDebugger", "DebuggerConfigDebugMode"); string debuggerOpenGlTrace = EvaluateProjectProperty(projectProperties, "AndroidPlusPlusDebugger", "DebuggerConfigOpenGlTrace"); string debuggerKeepAppData = EvaluateProjectProperty(projectProperties, "AndroidPlusPlusDebugger", "DebuggerConfigKeepAppData"); string debuggerInstallerPackage = EvaluateProjectProperty(projectProperties, "AndroidPlusPlusDebugger", "DebuggerConfigInstallerPackage"); if (string.IsNullOrEmpty(debuggerMode)) { debuggerMode = "Custom"; } else if (debuggerMode.Equals("vs-android")) { // // Support for vs-android. Rather hacky for VS2010. // #if VS2010 VCConfiguration activeConfiguration = GetActiveConfiguration(startupProject); IVCRulePropertyStorage rulesAntBuild = activeConfiguration.Rules.Item("AntBuild"); string antBuildPath = rulesAntBuild.GetEvaluatedPropertyValue("AntBuildPath"); string antBuildType = rulesAntBuild.GetEvaluatedPropertyValue("AntBuildType"); #else string antBuildPath = EvaluateProjectProperty(projectProperties, "AntBuild", "AntBuildPath"); string antBuildType = EvaluateProjectProperty(projectProperties, "AntBuild", "AntBuildType"); #endif string antBuildXml = Path.Combine(antBuildPath, "build.xml"); XmlDocument buildXmlDocument = new XmlDocument(); buildXmlDocument.Load(antBuildXml); string antBuildXmlProjectName = buildXmlDocument.DocumentElement.GetAttribute("name"); debuggerTargetApk = Path.Combine(antBuildPath, "bin", antBuildXmlProjectName + "-" + antBuildType.ToLower() + ".apk"); } // // Ensure the provided target APK is found and absolute. // if (string.IsNullOrEmpty(debuggerTargetApk)) { throw new FileNotFoundException("Could not locate target application. Empty path provided."); } else if (!Path.IsPathRooted(debuggerTargetApk) && !string.IsNullOrWhiteSpace(projectProjectDir)) { debuggerTargetApk = Path.Combine(projectProjectDir, debuggerTargetApk); } if (!Path.IsPathRooted(debuggerTargetApk)) { throw new InvalidOperationException("Could not evaluate an absolute path to the target application. Tried: " + debuggerTargetApk); } debuggerTargetApk = Path.GetFullPath(debuggerTargetApk); // normalises relative paths. if (!File.Exists(debuggerTargetApk)) { throw new FileNotFoundException("Could not find required target application. Expected: " + debuggerTargetApk); } // // Find the selected Android SDK (and associated build-tools) deployment. // string androidSdkRoot = EvaluateProjectProperty(projectProperties, "ConfigurationGeneral", "AndroidSdkRoot"); if (string.IsNullOrWhiteSpace(androidSdkRoot)) { throw new DirectoryNotFoundException("Could not locate Android SDK. 'AndroidSdkRoot' property is empty."); } else if (!Directory.Exists(androidSdkRoot)) { throw new DirectoryNotFoundException("Could not locate Android SDK. 'AndroidSdkRoot' property references a directory which does not exist. Expected: " + androidSdkRoot); } string androidSdkBuildToolsVersion = EvaluateProjectProperty(projectProperties, "ConfigurationGeneral", "AndroidSdkBuildToolsVersion"); string androidSdkBuildToolsPath = Path.Combine(androidSdkRoot, "build-tools", androidSdkBuildToolsVersion); if (!Directory.Exists(androidSdkBuildToolsPath)) { throw new DirectoryNotFoundException(string.Format("Could not locate Android SDK build-tools (v{0}). Expected: {1}", androidSdkBuildToolsVersion, androidSdkBuildToolsPath)); } // // Spawn a AAPT.exe instance to gain some extra information about the APK we are trying to load. // string applicationPackageName = string.Empty; string applicationLaunchActivity = string.Empty; string aaptToolPath = Path.Combine(androidSdkBuildToolsPath, "aapt.exe"); if (!File.Exists(aaptToolPath)) { throw new FileNotFoundException("Could not locate AAPT tool (under Android SDK build-tools).", aaptToolPath); } using (SyncRedirectProcess getApkDetails = new SyncRedirectProcess(aaptToolPath, "dump --values badging " + PathUtils.SantiseWindowsPath(debuggerTargetApk))) { int exitCode = getApkDetails.StartAndWaitForExit(); if (exitCode != 0) { throw new InvalidOperationException("AAPT failed to dump required application badging information. Exit-code: " + exitCode); } string [] apkDetails = getApkDetails.StandardOutput.Replace("\r", "").Split(new char [] { '\n' }); foreach (string singleLine in apkDetails) { if (singleLine.StartsWith("package: ")) { // // Retrieve package name from format: "package: name='com.example.hellogdbserver' versionCode='1' versionName='1.0'" // string [] packageData = singleLine.Substring("package: ".Length).Split(' '); foreach (string data in packageData) { if (data.StartsWith("name=")) { applicationPackageName = data.Substring("name=".Length).Trim('\''); } } } else if (singleLine.StartsWith("launchable-activity: ")) { string [] launchActivityData = singleLine.Substring("launchable-activity: ".Length).Split(' '); foreach (string data in launchActivityData) { if (data.StartsWith("name=")) { applicationLaunchActivity = data.Substring("name=".Length).Trim('\''); } } } } } // // If a specific launch activity was not requested, ensure that the default one is referenced. // if (string.IsNullOrEmpty(debuggerLaunchActivity)) { debuggerLaunchActivity = applicationLaunchActivity; } LaunchConfiguration launchConfig = new LaunchConfiguration(); launchConfig ["TargetApk"] = debuggerTargetApk; launchConfig ["UpToDateCheck"] = debuggerUpToDateCheck; launchConfig ["PackageName"] = applicationPackageName; launchConfig ["LaunchActivity"] = debuggerLaunchActivity; launchConfig ["DebugMode"] = debuggerDebugMode; launchConfig ["OpenGlTrace"] = debuggerOpenGlTrace; launchConfig ["KeepAppData"] = debuggerKeepAppData; launchConfig ["InstallerPackage"] = debuggerInstallerPackage; return(launchConfig); }