protected override void CaptureExtraProperties(ProjectProperties projProperties, IMacroEvaluator evaluator) { ThreadHelper.ThrowIfNotOnUIThread(); if (projProperties == null) { return; } OutputLog.Log("Capturing Extra configuration from Unreal..."); //Basic VS context Document doc = EditorUtils.GetActiveDocument(); Project project = EditorUtils.GetActiveProject(); //Find module path & name for the given file string modulePath = GetModulePath(doc.FullName); string moduleName = modulePath == null ? null : Path.GetFileName(modulePath); OutputLog.Log(moduleName == null ? "Unable to find Unreal Engine Module." : "Unreal Engine Module Name: " + moduleName); //Open project vcxproj as xml //Find the first .cpp file from the given module & steal its configuration AppendFileConfiguration(projProperties, SearchInProjectFile(project, modulePath), evaluator); //Add basic preprocessor definition projProperties.PrepocessorDefinitions.Add("UNREAL_CODE_ANALYZER"); }
static public EditorMode GetEditorMode() { ThreadHelper.ThrowIfNotOnUIThread(); Project project = EditorUtils.GetActiveProject(); if (project == null) { return(EditorMode.None); } if (project.Object == null) { return(EditorMode.CMake); } Solution solution = EditorUtils.GetActiveSolution(); if (solution != null) { //Check for unreal project ( $(SolutionName.uproject) || UE4.sln + Engine/Source/UE4Editor.target ) var uproject = Path.ChangeExtension(solution.FullName, "uproject"); if (File.Exists(uproject)) { return(EditorMode.UnrealEngine); } else if (Path.GetFileNameWithoutExtension(solution.FullName) == "UE4" && File.Exists(GetSolutionPath() + @"Engine/Source/UE4Editor.Target.cs")) { return(EditorMode.UnrealEngine); } else if (Path.GetFileNameWithoutExtension(solution.FullName) == "UE5" && File.Exists(GetSolutionPath() + @"Engine/Source/UnrealEditor.Target.cs")) { return(EditorMode.UnrealEngine); } } return(EditorMode.VisualStudio); }
public override ProjectProperties GetProjectData() { ThreadHelper.ThrowIfNotOnUIThread(); OutputLog.Log("Using manual configuration..."); var ret = new ProjectProperties(); Project project = EditorUtils.GetActiveProject(); VCProject prj = project == null ? null : project.Object as VCProject; VCConfiguration config = prj == null ? null : prj.ActiveConfiguration; VCPlatform platform = config == null ? null : config.Platform; if (platform != null) { AddCustomSettings(ret, new MacroEvaluatorVisualPlatform(platform)); } else { AddCustomSettings(ret, new MacroEvaluatorCMake()); } return(ret); }
public override ProjectProperties GetProjectData() { ThreadHelper.ThrowIfNotOnUIThread(); OutputLog.Log("Capturing configuration from VS projects..."); Project project = EditorUtils.GetActiveProject(); VCProject prj = project.Object as VCProject; if (prj == null) { return(null); } VCConfiguration config = prj.ActiveConfiguration; if (config == null) { return(null); } VCPlatform platform = config.Platform; if (platform == null) { return(null); } var vctools = config.Tools as IVCCollection; if (vctools == null) { return(null); } var midl = vctools.Item("VCMidlTool") as VCMidlTool; var evaluator = new MacroEvaluatorVisualPlatform(platform); ProjectProperties ret = new ProjectProperties(); ret.Target = midl != null && midl.TargetEnvironment == midlTargetEnvironment.midlTargetWin32 ? ProjectProperties.TargetType.x86 : ProjectProperties.TargetType.x64; ret.Standard = GetStandardVersion(config); //Working directory (always local to processed file) ret.WorkingDirectory = Path.GetDirectoryName(project.FullName); //Include dirs / files and preprocessor AppendMSBuildStringToList(ret.IncludeDirectories, evaluator.Evaluate(platform.IncludeDirectories)); AppendProjectProperties(ret, vctools.Item("VCCLCompilerTool") as VCCLCompilerTool, vctools.Item("VCNMakeTool") as VCNMakeTool, evaluator); //Get settings from the single file (this might fail badly if there are no settings to catpure) var applicationObject = EditorUtils.ServiceProvider.GetService(typeof(DTE)) as EnvDTE80.DTE2; Assumes.Present(applicationObject); ProjectItem item = applicationObject.ActiveDocument.ProjectItem; VCFile vcfile = item != null ? item.Object as VCFile : null; IVCCollection fileCfgs = vcfile != null ? (IVCCollection)vcfile.FileConfigurations : null; VCFileConfiguration fileConfig = fileCfgs != null?fileCfgs.Item(config.Name) as VCFileConfiguration : null; VCCLCompilerTool fileToolCL = null; VCNMakeTool fileToolNMake = null; try { fileToolCL = fileConfig.Tool as VCCLCompilerTool; fileToolNMake = fileConfig.Tool as VCNMakeTool; } catch (Exception e) { //If we really need this data we can always parse the vcxproj as an xml OutputLog.Log("File specific properties not found, only project properties used (" + e.Message + ")"); } AppendProjectProperties(ret, fileToolCL, fileToolNMake, evaluator); CaptureExtraProperties(ret, evaluator); AddCustomSettings(ret, evaluator); RemoveMSBuildStringFromList(ret.IncludeDirectories, evaluator.Evaluate(platform.ExcludeDirectories)); //Exclude directories ProcessPostProjectData(ret); return(ret); }