1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-17 07:44:09 +02:00

Improved handling of platform configs

This commit is contained in:
Brian Fiete 2020-05-15 08:52:48 -07:00
parent e8fd27fb0c
commit 0113ce7115
4 changed files with 103 additions and 85 deletions

View file

@ -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();

View file

@ -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
}
}
}
@ -313,6 +308,7 @@ namespace IDE
public BeefGlobalOptions mBeefGlobalOptions = new BeefGlobalOptions() ~ delete _;
public Dictionary<String, Config> mConfigs = new Dictionary<String, Config>() ~ DeleteDictionaryAndKeysAndItems!(_);
public HashSet<String> mExtraPlatforms = new .() ~ DeleteContainerAndItems!(_);
public class ProjectSourceCompileInstance
{
@ -378,7 +374,6 @@ namespace IDE
public bool mForceNextCompile;
public List<CompileInstance> mCompileInstanceList = new List<CompileInstance>() ~ DeleteContainerAndItems!(_); // First item is primary compile, secondaries are hot reloads
public List<String> mPlatforms = new List<String>() ~ DeleteContainerAndItems!(_);
public List<String> mUserPlatforms = new List<String>() ~ 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<String> seenPlatforms = scope .();
HashSet<String> writtenPlatforms = scope .();
writtenPlatforms.Add(IDEApp.sPlatform32Name);
writtenPlatforms.Add(IDEApp.sPlatform64Name);
for (let platformName in mExtraPlatforms)
seenPlatforms.Add(platformName);
HashSet<String> seenConfigs = scope .();
HashSet<String> 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<String> seenSet, HashSet<String> writtenSet)
{
List<String> 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<ToolsetType>("Toolset", ToolsetType.Default);
options.mToolsetType = data.GetEnum<ToolsetType>("Toolset", ToolsetType.GetDefaultFor(platformType));
options.mBuildKind = data.GetEnum<BuildKind>("BuildKind", isTest ? .Test : .Normal);
options.mBfSIMDSetting = data.GetEnum<BuildOptions.SIMDSetting>("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)

View file

@ -166,17 +166,7 @@ namespace IDE.ui
public override void GetPlatformList(List<String> platformNames)
{
/*var configName = mConfigNames[0];
for (var platformName in mProject.mConfigs[configName].mPlatforms.Keys)
platformNames.Add(platformName);*/
HashSet<String> 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();
}
}

View file

@ -141,11 +141,6 @@ namespace IDE.ui
public override void GetPlatformList(List<String> 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);
}
@ -359,35 +354,16 @@ namespace IDE.ui
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();
}
}
}
}