mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 12:32:20 +02:00
Refactored code to resolve custom build properties in Beef projects.
This commit is contained in:
parent
803b9890e2
commit
b55f980531
4 changed files with 585 additions and 77 deletions
|
@ -229,7 +229,6 @@ namespace IDE
|
|||
public HashSet<String> mWantUpdateVersionLocks ~ DeleteContainerAndItems!(_);
|
||||
public Settings mSettings = new Settings() ~ delete _;
|
||||
public Workspace mWorkspace = new Workspace() ~ delete _;
|
||||
public Dictionary<String, String> mCustomProperties = new .() ~ DeleteDictionaryAndValues!(_);
|
||||
public FileWatcher mFileWatcher = new FileWatcher() ~ delete _;
|
||||
#if !CLI
|
||||
public FileRecovery mFileRecovery = new FileRecovery() ~ delete _;
|
||||
|
@ -895,8 +894,6 @@ namespace IDE
|
|||
mExecutionPaused = false;
|
||||
}
|
||||
|
||||
ClearProperties();
|
||||
|
||||
base.Shutdown();
|
||||
}
|
||||
|
||||
|
@ -990,7 +987,6 @@ namespace IDE
|
|||
mWorkspace.mName = new String();
|
||||
Path.GetFileName(mWorkspace.mDir, mWorkspace.mName);
|
||||
|
||||
LoadProperties(true);
|
||||
LoadWorkspace(.OpenOrNew);
|
||||
FinishShowingNewWorkspace();
|
||||
}
|
||||
|
@ -2267,16 +2263,11 @@ namespace IDE
|
|||
String workspaceDir = scope String();
|
||||
|
||||
if (mWorkspace.mDir == null)
|
||||
{
|
||||
Directory.GetCurrentDirectory(workspaceDir);
|
||||
}
|
||||
else
|
||||
{
|
||||
workspaceDir = mWorkspace.mDir;
|
||||
}
|
||||
|
||||
outResult.Append(workspaceDir, "/BeefProperties.toml");
|
||||
IDEUtils.FixFilePath(outResult);
|
||||
}
|
||||
|
||||
bool GetWorkspaceFileName(String outResult)
|
||||
|
@ -2978,69 +2969,12 @@ namespace IDE
|
|||
FlushDeferredLoadProjects();
|
||||
}
|
||||
|
||||
public void ClearProperties()
|
||||
{
|
||||
for (var entry in mCustomProperties)
|
||||
{
|
||||
delete entry.key;
|
||||
delete entry.value;
|
||||
}
|
||||
|
||||
mCustomProperties.Clear();
|
||||
}
|
||||
|
||||
public void LoadProperties(bool clear = false)
|
||||
{
|
||||
const char8* PROPERTIES_STR = "Properties";
|
||||
|
||||
if (clear)
|
||||
{
|
||||
ClearProperties();
|
||||
}
|
||||
|
||||
String propertiesFileName = scope String();
|
||||
GetPropertiesFileName(propertiesFileName);
|
||||
|
||||
if (!File.Exists(propertiesFileName))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
StructuredData data = scope StructuredData();
|
||||
if (StructuredLoad(data, propertiesFileName) case .Err(let err))
|
||||
{
|
||||
OutputErrorLine("Failed to load properties '{0}'", propertiesFileName);
|
||||
LoadFailed();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.Contains(PROPERTIES_STR))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (var propertyName in data.Enumerate(PROPERTIES_STR))
|
||||
{
|
||||
String propertyKey = new String();
|
||||
propertyName.ToString(propertyKey);
|
||||
|
||||
if (mCustomProperties.ContainsKey(propertyKey))
|
||||
{
|
||||
delete propertyKey;
|
||||
continue;
|
||||
}
|
||||
|
||||
String propertyValue = new String();
|
||||
data.GetCurString(propertyValue);
|
||||
|
||||
mCustomProperties.Add(propertyKey, propertyValue);
|
||||
}
|
||||
}
|
||||
|
||||
protected void LoadWorkspace(BeefVerb verb)
|
||||
{
|
||||
scope AutoBeefPerf("IDEApp.LoadWorkspace");
|
||||
|
||||
CustomBuildProperties.Load();
|
||||
|
||||
AddRecentFile(.OpenedWorkspace, mWorkspace.mDir);
|
||||
|
||||
StructuredData data = null;
|
||||
|
@ -3273,7 +3207,6 @@ namespace IDE
|
|||
CloseWorkspace();
|
||||
mWorkspace.mDir = new String(workspaceDir);
|
||||
mWorkspace.mName = new String(workspaceName);
|
||||
LoadProperties(true);
|
||||
LoadWorkspace(.Open);
|
||||
FinishShowingNewWorkspace();
|
||||
}
|
||||
|
@ -11009,13 +10942,6 @@ namespace IDE
|
|||
}
|
||||
case "BeefPath":
|
||||
newString = gApp.mInstallDir;
|
||||
default:
|
||||
// Check if any custom properties match the string.
|
||||
if (mCustomProperties.ContainsKey(replaceStr))
|
||||
{
|
||||
newString = scope:ReplaceBlock String();
|
||||
newString.Append(mCustomProperties[replaceStr]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue