|
|
@@ -29,10 +29,6 @@
|
|
|
#include <Atomic/IO/FileSystem.h>
|
|
|
#include <Atomic/Resource/ResourceEvents.h>
|
|
|
|
|
|
-#include <Atomic/UI/UIEvents.h>
|
|
|
-#include <Atomic/Input/InputEvents.h>
|
|
|
-#include <AtomicEditor/EditorMode/AEEditorEvents.h>
|
|
|
-
|
|
|
#include "../ToolSystem.h"
|
|
|
#include "../ToolEnvironment.h"
|
|
|
#include "../Assets/AssetEvents.h"
|
|
|
@@ -192,24 +188,11 @@ namespace ToolCore
|
|
|
|
|
|
ATOMIC_LOGERRORF("\n%s\n", errorText.CString());
|
|
|
ATOMIC_LOGERRORF("NETBuild Error for project");
|
|
|
-
|
|
|
- String myerror; // too much error for the dialog! scrape off just the error summary
|
|
|
- unsigned where = errorText.Find("Errors:", 0, true);
|
|
|
- if ( where != String::NPOS)
|
|
|
- myerror = errorText.Substring (where, errorText.Length() - where);
|
|
|
- else myerror = errorText; // failed to find summary, send the whole text
|
|
|
-
|
|
|
- using namespace AtomicEditor;
|
|
|
- VariantMap errorData;
|
|
|
- errorData[EditorModal::P_TYPE] = EDITOR_MODALERROR;
|
|
|
- errorData[EditorModal::P_TITLE] = String("NETBuild Errors");
|
|
|
- errorData[EditorModal::P_MESSAGE] = myerror;
|
|
|
- SendEvent(E_EDITORMODAL, errorData);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
- void NETProjectSystem::BuildAtomicProject()
|
|
|
+ NETBuild* NETProjectSystem::BuildAtomicProject()
|
|
|
{
|
|
|
FileSystem* fileSystem = GetSubsystem<FileSystem>();
|
|
|
|
|
|
@@ -218,7 +201,7 @@ namespace ToolCore
|
|
|
if (!GenerateSolution())
|
|
|
{
|
|
|
ATOMIC_LOGERRORF("NETProjectSystem::BuildAtomicProject - solutionPath does not exist: %s", solutionPath_.CString());
|
|
|
- return;
|
|
|
+ return nullptr;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -234,7 +217,10 @@ namespace ToolCore
|
|
|
build->SubscribeToEvent(E_NETBUILDRESULT, ATOMIC_HANDLER(NETProjectSystem, HandleNETBuildResult));
|
|
|
}
|
|
|
|
|
|
+ return build;
|
|
|
}
|
|
|
+
|
|
|
+ return nullptr;
|
|
|
}
|
|
|
|
|
|
bool NETProjectSystem::GenerateResourcePak()
|
|
|
@@ -375,8 +361,7 @@ namespace ToolCore
|
|
|
if (!fileSystem->FileExists(solutionPath_))
|
|
|
solutionDirty_ = true;
|
|
|
|
|
|
- if (!fileSystem->FileExists(projectAssemblyPath_))
|
|
|
- projectAssemblyDirty_ = true;
|
|
|
+ CheckProjectAssembly();
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -438,100 +423,69 @@ namespace ToolCore
|
|
|
|
|
|
}
|
|
|
|
|
|
- /// handle the results of a recompile, and auto play the project if successful
|
|
|
- void NETProjectSystem::HandleNETBuildPlay(StringHash eventType, VariantMap& eventData)
|
|
|
+ bool NETProjectSystem::GetProjectAssemblyDirty()
|
|
|
{
|
|
|
- using namespace NETBuildResult;
|
|
|
-
|
|
|
- if (eventData[P_SUCCESS].GetBool())
|
|
|
+ if (projectAssemblyDirty_)
|
|
|
+ return true;
|
|
|
+
|
|
|
+ CheckProjectAssembly();
|
|
|
+
|
|
|
+ return projectAssemblyDirty_;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ void NETProjectSystem::CheckProjectAssembly()
|
|
|
+ {
|
|
|
+ FileSystem* fileSystem = GetSubsystem<FileSystem>();
|
|
|
+ ToolSystem* tsystem = GetSubsystem<ToolSystem>();
|
|
|
+ Project* project = tsystem->GetProject();
|
|
|
+
|
|
|
+ if (!project || !projectAssemblyPath_.Length())
|
|
|
{
|
|
|
- ATOMIC_LOGINFOF("NETBuild Success for project, now playing.");
|
|
|
- VariantMap shortcutData; // encode a shortcut event to send a play
|
|
|
- shortcutData[UIShortcut::P_KEY] = KEY_P;
|
|
|
- shortcutData[UIShortcut::P_QUALIFIERS] = QUAL_CTRL;
|
|
|
- SendEvent(E_UISHORTCUT, shortcutData);
|
|
|
+ ATOMIC_LOGERROR("NETProjectSystem::CheckProjectAssembly() - Called with no project loaded or an empty project assembly path");
|
|
|
+ projectAssemblyDirty_ = false;
|
|
|
+ return;
|
|
|
}
|
|
|
- else
|
|
|
+
|
|
|
+ if (projectAssemblyDirty_)
|
|
|
+ return;
|
|
|
+
|
|
|
+ // If we don't have a project or the project assembly is missing, we must rebuild
|
|
|
+ if (!fileSystem->FileExists(projectAssemblyPath_))
|
|
|
{
|
|
|
- const String& errorText = eventData[P_ERRORTEXT].GetString();
|
|
|
+ projectAssemblyDirty_ = true;
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- ATOMIC_LOGERRORF("\n%s\n", errorText.CString());
|
|
|
- ATOMIC_LOGERRORF("NETBuild Error for project, will not play.");
|
|
|
-
|
|
|
- String myerror; // too much error for the dialog! scrape off just the error summary
|
|
|
- unsigned where = errorText.Find("Errors:", 0, true);
|
|
|
- if ( where != String::NPOS)
|
|
|
- myerror = errorText.Substring (where, errorText.Length() - where);
|
|
|
- else myerror = errorText; // failed to find summary, send the whole text
|
|
|
-
|
|
|
- using namespace AtomicEditor;
|
|
|
- VariantMap errorData;
|
|
|
- errorData[EditorModal::P_TYPE] = EDITOR_MODALERROR;
|
|
|
- errorData[EditorModal::P_TITLE] = String("NETBuild Error for project");
|
|
|
- errorData[EditorModal::P_MESSAGE] = myerror;
|
|
|
- SendEvent(E_EDITORMODAL, errorData);
|
|
|
+ StringVector results;
|
|
|
+
|
|
|
+ // timestamps for present assemblies, use the filesystem and not asset db as the later is cached
|
|
|
+ PODVector<unsigned> assemblyTimestamps;
|
|
|
+
|
|
|
+ fileSystem->ScanDir(results, project->GetResourcePath(), "*.dll", SCAN_FILES, true);
|
|
|
+
|
|
|
+ for (unsigned i = 0; i < results.Size(); i++)
|
|
|
+ {
|
|
|
+ assemblyTimestamps.Push(fileSystem->GetLastModifiedTime(project->GetResourcePath() + results[i]));
|
|
|
}
|
|
|
|
|
|
- }
|
|
|
+ fileSystem->ScanDir(results, project->GetResourcePath(), "*.cs", SCAN_FILES, true);
|
|
|
|
|
|
- /// used to ensure the project can be run from the editor
|
|
|
- bool NETProjectSystem::BuildAndRun()
|
|
|
- {
|
|
|
- bool shouldRebuild = CheckForRebuild();
|
|
|
- if (shouldRebuild)
|
|
|
+ for (unsigned i = 0; i < results.Size(); i++)
|
|
|
{
|
|
|
- FileSystem* fileSystem = GetSubsystem<FileSystem>();
|
|
|
- if (!fileSystem->FileExists(solutionPath_))
|
|
|
+ unsigned timestamp = fileSystem->GetLastModifiedTime(project->GetResourcePath() + results[i]);
|
|
|
+
|
|
|
+ for (unsigned j = 0; j < assemblyTimestamps.Size(); j++)
|
|
|
{
|
|
|
- if (!GenerateSolution())
|
|
|
+ if (timestamp > assemblyTimestamps[j])
|
|
|
{
|
|
|
- ATOMIC_LOGERRORF("NETProjectSystem::BuildAtomicProject - solutionPath does not exist: %s", solutionPath_.CString());
|
|
|
- return false;
|
|
|
+ projectAssemblyDirty_ = true;
|
|
|
+ return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- Project* project = GetSubsystem<ToolSystem>()->GetProject();
|
|
|
- NETBuildSystem* buildSystem = GetSubsystem<NETBuildSystem>();
|
|
|
- if (buildSystem)
|
|
|
- {
|
|
|
- NETBuild* build = buildSystem->BuildAtomicProject(project);
|
|
|
- if (build)
|
|
|
- {
|
|
|
- build->SubscribeToEvent(E_NETBUILDRESULT, ATOMIC_HANDLER(NETProjectSystem, HandleNETBuildPlay));
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
-
|
|
|
- return shouldRebuild;
|
|
|
- }
|
|
|
-
|
|
|
- /// interrogate sources to see if any are dirty compared to the editor project.dll
|
|
|
- bool NETProjectSystem::CheckForRebuild()
|
|
|
- {
|
|
|
- FileSystem* fileSystem = GetSubsystem<FileSystem>();
|
|
|
- AssetDatabase* db = GetSubsystem<AssetDatabase>();
|
|
|
- Project* project = GetSubsystem<ToolSystem>()->GetProject();
|
|
|
- unsigned dllTimestamp = 0;
|
|
|
-
|
|
|
- String mydll = project->GetResourcePath() + project->GetProjectSettings()->GetName() + ".dll";
|
|
|
- Asset* myasset = db->GetAssetByPath(mydll);
|
|
|
- if (myasset)
|
|
|
- dllTimestamp = myasset->GetFileTimestamp();
|
|
|
- else
|
|
|
- return true; // dll not there, needs to be built, or the sources dont compile, or some other error
|
|
|
-
|
|
|
- int nn=0;
|
|
|
- Asset* filex = NULL;
|
|
|
- StringVector results;
|
|
|
- String tdir = AddTrailingSlash(project->GetResourcePath());
|
|
|
- fileSystem->ScanDir(results, tdir, "*.cs", SCAN_FILES, true);
|
|
|
- for (nn=0; nn<results.Size(); nn++)
|
|
|
- {
|
|
|
- filex = db->GetAssetByPath(tdir + results[nn]);
|
|
|
- if (filex && filex->GetFileTimestamp() > dllTimestamp )
|
|
|
- return true; // some file is younger or dirtier, dll needs to be rebuilt
|
|
|
- }
|
|
|
- return false; // the dll is up to date, no need to recompile
|
|
|
+
|
|
|
}
|
|
|
|
|
|
void NETProjectSystem::Initialize()
|
|
|
@@ -648,12 +602,9 @@ namespace ToolCore
|
|
|
|
|
|
if (srcModifiedTime == fileSystem->GetLastModifiedTime(dstFile))
|
|
|
{
|
|
|
- ATOMIC_LOGDEBUGF("NETProjectSystem::CopyAtomicAssemblies - Skipping AtomicNET %s as %s exists and has same modified time", srcFile.CString(), dstFile.CString());
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- ATOMIC_LOGDEBUGF("NETProjectSystem::CopyAtomicAssemblies - %u %u", srcModifiedTime, fileSystem->GetLastModifiedTime(dstFile));
|
|
|
-
|
|
|
}
|
|
|
|
|
|
String dstPath = GetPath(dstFile);
|
|
|
@@ -674,7 +625,6 @@ namespace ToolCore
|
|
|
if (srcModifiedTime)
|
|
|
fileSystem->SetLastModifiedTime(dstFile, srcModifiedTime);
|
|
|
|
|
|
- ATOMIC_LOGDEBUGF(" NETProjectSystem::CopyAtomicAssemblies - Copied AtomicNET %s to %s", srcFile.CString(), dstPath.CString());
|
|
|
}
|
|
|
|
|
|
return true;
|