From 0113ce71153050245b8aab24b62ee35b1ddbef41 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Fri, 15 May 2020 08:52:48 -0700 Subject: [PATCH] Improved handling of platform configs --- IDE/src/IDEApp.bf | 18 ----- IDE/src/Workspace.bf | 105 +++++++++++++++++++++++++----- IDE/src/ui/ProjectProperties.bf | 27 +++----- IDE/src/ui/WorkspaceProperties.bf | 38 ++--------- 4 files changed, 103 insertions(+), 85 deletions(-) diff --git a/IDE/src/IDEApp.bf b/IDE/src/IDEApp.bf index 43347e00..9da6e015 100644 --- a/IDE/src/IDEApp.bf +++ b/IDE/src/IDEApp.bf @@ -1686,12 +1686,6 @@ namespace IDE sd.Add(recentFile); } - using (sd.CreateArray("UserPlatforms")) - { - for (var platformName in gApp.mWorkspace.mUserPlatforms) - sd.Add(platformName); - } - using (sd.CreateArray("Breakpoints")) { for (var breakpoint in mDebugger.mBreakpointList) @@ -2844,18 +2838,6 @@ namespace IDE mRecentlyDisplayedFiles.Add(fileStr); } - DeleteAndClearItems!(gApp.mWorkspace.mUserPlatforms); - for (data.Enumerate("UserPlatforms")) - { - String platformName = scope String(); - data.GetCurString(platformName); - if (!gApp.mWorkspace.mUserPlatforms.Contains(platformName)) - { - gApp.mWorkspace.mUserPlatforms.Add(new String(platformName)); - gApp.mWorkspace.FixOptionsForPlatform(platformName); - } - } - for (var _breakpoint in data.Enumerate("Breakpoints")) { String fileName = scope String(); diff --git a/IDE/src/Workspace.bf b/IDE/src/Workspace.bf index 4bca90bb..e249190b 100644 --- a/IDE/src/Workspace.bf +++ b/IDE/src/Workspace.bf @@ -103,16 +103,11 @@ namespace IDE case Microsoft; case LLVM; - public static ToolsetType Default + public static ToolsetType GetDefaultFor(PlatformType platformType) { - get - { -#if BF_PLATFORM_WINDOWS + if (platformType == .Windows) return Microsoft; -#else - return .GNU; -#endif - } + return .GNU; } } @@ -313,6 +308,7 @@ namespace IDE public BeefGlobalOptions mBeefGlobalOptions = new BeefGlobalOptions() ~ delete _; public Dictionary mConfigs = new Dictionary() ~ DeleteDictionaryAndKeysAndItems!(_); + public HashSet mExtraPlatforms = new .() ~ DeleteContainerAndItems!(_); public class ProjectSourceCompileInstance { @@ -378,7 +374,6 @@ namespace IDE public bool mForceNextCompile; public List mCompileInstanceList = new List() ~ DeleteContainerAndItems!(_); // First item is primary compile, secondaries are hot reloads public List mPlatforms = new List() ~ DeleteContainerAndItems!(_); - public List mUserPlatforms = new List() ~ DeleteContainerAndItems!(_); public bool mIsDebugSession; public int32 HotCompileIdx @@ -458,6 +453,9 @@ namespace IDE } }*/ + for (let extraPlatform in mExtraPlatforms) + Add(extraPlatform); + mPlatforms.Sort(scope (a, b) => String.Compare(a, b, true)); } @@ -567,6 +565,20 @@ namespace IDE } } + HashSet seenPlatforms = scope .(); + HashSet writtenPlatforms = scope .(); + writtenPlatforms.Add(IDEApp.sPlatform32Name); + writtenPlatforms.Add(IDEApp.sPlatform64Name); + for (let platformName in mExtraPlatforms) + seenPlatforms.Add(platformName); + + HashSet seenConfigs = scope .(); + HashSet writtenConfigs = scope .(); + writtenConfigs.Add("Debug"); + writtenConfigs.Add("Release"); + writtenConfigs.Add("Paranoid"); + writtenConfigs.Add("Test"); + using (data.CreateObject("Configs")) { for (var configKeyValue in mConfigs) @@ -598,7 +610,7 @@ namespace IDE data.RemoveIfEmpty(); } - data.ConditionalAdd("Toolset", options.mToolsetType, ToolsetType.Default); + data.ConditionalAdd("Toolset", options.mToolsetType, ToolsetType.GetDefaultFor(platformType)); data.ConditionalAdd("BuildKind", options.mBuildKind, isTest ? .Test : .Normal); data.ConditionalAdd("BfSIMDSetting", options.mBfSIMDSetting, .SSE2); if (platformType == .Windows) @@ -619,9 +631,9 @@ namespace IDE data.ConditionalAdd("EmitDynamicCastCheck", options.mEmitDynamicCastCheck, !isRelease); data.ConditionalAdd("EnableObjectDebugFlags", options.mEnableObjectDebugFlags, !isRelease); data.ConditionalAdd("EmitObjectAccessCheck", options.mEmitObjectAccessCheck, !isRelease); - data.ConditionalAdd("EnableRealtimeLeakCheck", options.mEnableRealtimeLeakCheck, !isRelease); - data.ConditionalAdd("EnableSideStack", options.mEnableSideStack, isParanoid); - data.ConditionalAdd("AllowHotSwapping", options.mAllowHotSwapping, !isRelease); + data.ConditionalAdd("EnableRealtimeLeakCheck", options.mEnableRealtimeLeakCheck, (platformType == .Windows) && !isRelease); + data.ConditionalAdd("EnableSideStack", options.mEnableSideStack, (platformType == .Windows) && isParanoid); + data.ConditionalAdd("AllowHotSwapping", options.mAllowHotSwapping, (platformType == .Windows) && !isRelease); data.ConditionalAdd("AllocStackTraceDepth", options.mAllocStackTraceDepth, 1); data.ConditionalAdd("IncrementalBuild", options.mIncrementalBuild, !isRelease); @@ -655,11 +667,44 @@ namespace IDE } WriteDistinctOptions(options.mDistinctBuildOptions); + + if (!data.IsEmpty) + writtenPlatforms.Add(platformName); + seenPlatforms.Add(platformName); } } + + + if (!data.IsEmpty) + writtenConfigs.Add(configName); + seenConfigs.Add(configName); } } } + + void WriteExtra(String name, HashSet seenSet, HashSet writtenSet) + { + List extraList = scope .(); + for (let platformName in seenSet) + { + if (!writtenSet.Contains(platformName)) + { + extraList.Add(platformName); + } + } + if (!extraList.IsEmpty) + { + extraList.Sort(); + using (data.CreateArray(name)) + { + for (let platformName in extraList) + data.Add(platformName); + } + } + } + + WriteExtra("ExtraConfigs", seenConfigs, writtenConfigs); + WriteExtra("ExtraPlatforms", seenPlatforms, writtenPlatforms); } public void ClearProjectNameCache() @@ -759,13 +804,15 @@ namespace IDE { options.mEnableRealtimeLeakCheck = !isRelease; options.mEnableSideStack = isParanoid; + options.mAllowHotSwapping = !isRelease; } else { options.mEnableRealtimeLeakCheck = false; options.mEnableSideStack = false; + options.mAllowHotSwapping = false; } - options.mAllowHotSwapping = !isRelease; + options.mIncrementalBuild = !isRelease; options.mAllocStackTraceDepth = 1; @@ -829,7 +876,7 @@ namespace IDE options.mPreprocessorMacros.Add(str); } - options.mToolsetType = data.GetEnum("Toolset", ToolsetType.Default); + options.mToolsetType = data.GetEnum("Toolset", ToolsetType.GetDefaultFor(platformType)); options.mBuildKind = data.GetEnum("BuildKind", isTest ? .Test : .Normal); options.mBfSIMDSetting = data.GetEnum("BfSIMDSetting", .SSE2); if (platformType == .Windows) @@ -851,9 +898,9 @@ namespace IDE options.mEmitDynamicCastCheck = data.GetBool("EmitDynamicCastCheck", !isRelease); options.mEnableObjectDebugFlags = data.GetBool("EnableObjectDebugFlags", !isRelease); options.mEmitObjectAccessCheck = data.GetBool("EmitObjectAccessCheck", !isRelease); - options.mEnableRealtimeLeakCheck = data.GetBool("EnableRealtimeLeakCheck", !isRelease); - options.mEnableSideStack = data.GetBool("EnableSideStack", isParanoid); - options.mAllowHotSwapping = data.GetBool("AllowHotSwapping", !isRelease); + options.mEnableRealtimeLeakCheck = data.GetBool("EnableRealtimeLeakCheck", (platformType == .Windows) && !isRelease); + options.mEnableSideStack = data.GetBool("EnableSideStack", (platformType == .Windows) && isParanoid); + options.mAllowHotSwapping = data.GetBool("AllowHotSwapping", (platformType == .Windows) && !isRelease); options.mAllocStackTraceDepth = data.GetInt("AllocStackTraceDepth", 1); options.mIncrementalBuild = data.GetBool("IncrementalBuild", !isRelease); @@ -892,6 +939,28 @@ namespace IDE } } } + + for (var configNameSV in data.Enumerate("ExtraConfigs")) + { + String configName = new String(configNameSV); + bool added = mConfigs.TryAdd(configName) case .Added(let keyPtr, let valuePtr); + if (!added) + { + delete configName; + continue; + } + + Config config = new Config(); + *valuePtr = config; + } + + for (data.Enumerate("ExtraPlatforms")) + { + String platformName = scope .(); + data.GetCurString(platformName); + if (mExtraPlatforms.TryAdd(platformName, var entryPtr)) + *entryPtr = new String(platformName); + } } public void FinishDeserialize(StructuredData data) diff --git a/IDE/src/ui/ProjectProperties.bf b/IDE/src/ui/ProjectProperties.bf index 90118612..0cbb7b6c 100644 --- a/IDE/src/ui/ProjectProperties.bf +++ b/IDE/src/ui/ProjectProperties.bf @@ -166,17 +166,7 @@ namespace IDE.ui public override void GetPlatformList(List platformNames) { - /*var configName = mConfigNames[0]; - for (var platformName in mProject.mConfigs[configName].mPlatforms.Keys) - platformNames.Add(platformName);*/ - - HashSet platformSet = scope .(); - for (var config in mProject.mConfigs.Values) - { - for (var platform in config.mPlatforms.Keys) - if (platformSet.Add(platform)) - platformNames.Add(platform); - } + gApp.mWorkspace.GetPlatformList(platformNames); } public override bool CreateNewConfig(String name, String copiedFromConfig) @@ -307,6 +297,9 @@ namespace IDE.ui if ((!entry.mDelete) && (entry.mNewName == null)) continue; + if (entry.mDelete) + gApp.mWorkspace.mExtraPlatforms.Remove(entry.mOrigName); + ConfigLoop: for (var configName in mConfigNames) { Project.Config config; @@ -392,14 +385,12 @@ namespace IDE.ui name.Trim(); if (name.Length > 0) { - for (var projectConfig in mProject.mConfigs.Values) - { - Project.Options projectOptions = new Project.Options(); - projectConfig.mPlatforms[new String(name)] = projectOptions; - } - - mProject.SetChanged(); SelectPlatform(name); + if (gApp.mWorkspace.mExtraPlatforms.TryAdd(name, var entryPtr)) + { + *entryPtr = new String(name); + gApp.mWorkspace.SetChanged(); + } gApp.mWorkspace.MarkPlatformNamesDirty(); } } diff --git a/IDE/src/ui/WorkspaceProperties.bf b/IDE/src/ui/WorkspaceProperties.bf index bd638c52..7140b123 100644 --- a/IDE/src/ui/WorkspaceProperties.bf +++ b/IDE/src/ui/WorkspaceProperties.bf @@ -141,11 +141,6 @@ namespace IDE.ui public override void GetPlatformList(List platformNames) { - /*var configName = mConfigNames[0]; - for (var platformName in gApp.mWorkspace.mConfigs[configName].mPlatforms.Keys) - platformNames.Add(platformName); - if (platformNames.IsEmpty) - platformNames.Add(IDEApp.sPlatform64Name);*/ gApp.mWorkspace.GetPlatformList(platformNames); } @@ -358,36 +353,17 @@ namespace IDE.ui String platformName = scope String(name); platformName.Trim(); if (!platformName.IsEmpty) - { - /*for (var workspaceConfig in workspace.mConfigs) - { - if (!workspaceConfig.value.mPlatforms.ContainsKey(useName)) - { - Workspace.Options workspaceOptions = new Workspace.Options(); - workspace.SetupDefault(workspaceOptions, workspaceConfig.key, useName); - workspaceConfig.value.mPlatforms[new String(useName)] = workspaceOptions; - } - } - - for (var project in workspace.mProjects) - { - for (var projectConfigKV in project.mConfigs) - { - let projectConfig = projectConfigKV.value; - if (!projectConfig.mPlatforms.ContainsKey(useName)) - { - project.CreateConfig(projectConfigKV.key, useName); - } - } - }*/ - - //IDEApp.sApp.mWorkspace.SetChanged(); + { gApp.mWorkspace.FixOptionsForPlatform(platformName); + gApp.mWorkspace.SetChanged(); SelectPlatform(platformName); gApp.mWorkspace.MarkPlatformNamesDirty(); - if (!gApp.mWorkspace.mUserPlatforms.Contains(platformName)) - gApp.mWorkspace.mUserPlatforms.Add(new String(platformName)); + if (gApp.mWorkspace.mExtraPlatforms.TryAdd(platformName, var entryPtr)) + { + *entryPtr = new String(platformName); + gApp.mWorkspace.SetChanged(); + } } } }