|
|
@@ -62,6 +62,23 @@ namespace ToolCore
|
|
|
projectAssemblyDirty_ = false;
|
|
|
}
|
|
|
|
|
|
+ void NETProjectSystem::OpenSolution()
|
|
|
+ {
|
|
|
+ if (!visualStudioPath_.Length())
|
|
|
+ return;
|
|
|
+
|
|
|
+ FileSystem* fileSystem = GetSubsystem<FileSystem>();
|
|
|
+
|
|
|
+ if (!fileSystem->FileExists(solutionPath_))
|
|
|
+ {
|
|
|
+ if (!GenerateSolution())
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ OpenSourceFile(String::EMPTY);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
void NETProjectSystem::OpenSourceFile(const String& sourceFilePath)
|
|
|
{
|
|
|
if (!visualStudioPath_.Length())
|
|
|
@@ -75,7 +92,9 @@ namespace ToolCore
|
|
|
vsSubprocess_ = 0;
|
|
|
|
|
|
args.Push(solutionPath_);
|
|
|
- args.Push(sourceFilePath);
|
|
|
+
|
|
|
+ if (sourceFilePath.Length())
|
|
|
+ args.Push(sourceFilePath);
|
|
|
|
|
|
try
|
|
|
{
|
|
|
@@ -89,6 +108,9 @@ namespace ToolCore
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ if (!sourceFilePath.Length())
|
|
|
+ return;
|
|
|
+
|
|
|
try
|
|
|
{
|
|
|
std::vector<std::string> args;
|
|
|
@@ -105,56 +127,112 @@ namespace ToolCore
|
|
|
|
|
|
}
|
|
|
|
|
|
- void NETProjectSystem::HandleUpdate(StringHash eventType, VariantMap& eventData)
|
|
|
+ void NETProjectSystem::HandleNETBuildResult(StringHash eventType, VariantMap& eventData)
|
|
|
{
|
|
|
- using namespace Update;
|
|
|
+ using namespace NETBuildResult;
|
|
|
|
|
|
- float delta = eventData[P_TIMESTEP].GetFloat();
|
|
|
+ if (eventData[P_SUCCESS].GetBool())
|
|
|
+ {
|
|
|
+ LOGINFOF("NETBuild Success for project");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ const String& errorText = eventData[P_ERRORTEXT].GetString();
|
|
|
|
|
|
- quietPeriod_ -= delta;
|
|
|
+ LOGERRORF("\n%s\n", errorText.CString());
|
|
|
+ LOGERRORF("NETBuild Error for project");
|
|
|
+ }
|
|
|
|
|
|
- if (quietPeriod_ < 0.0f)
|
|
|
- quietPeriod_ = 0.0f;
|
|
|
+ }
|
|
|
|
|
|
- if (quietPeriod_ > 0.0f)
|
|
|
- return;
|
|
|
+ void NETProjectSystem::BuildAtomicProject()
|
|
|
+ {
|
|
|
+ FileSystem* fileSystem = GetSubsystem<FileSystem>();
|
|
|
|
|
|
- if (solutionDirty_)
|
|
|
+ if (!fileSystem->FileExists(solutionPath_))
|
|
|
{
|
|
|
- ToolSystem* tsystem = GetSubsystem<ToolSystem>();
|
|
|
- Project* project = tsystem->GetProject();
|
|
|
-
|
|
|
- SharedPtr<NETProjectGen> gen(new NETProjectGen(context_));
|
|
|
-
|
|
|
- gen->SetScriptPlatform("WINDOWS");
|
|
|
-
|
|
|
- if (!gen->LoadProject(project))
|
|
|
+ if (!GenerateSolution())
|
|
|
{
|
|
|
+ LOGERRORF("NETProjectSystem::BuildAtomicProject - solutionPath does not exist: %s", solutionPath_.CString());
|
|
|
return;
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
+#ifdef ATOMIC_PLATFORM_WINDOWS
|
|
|
+
|
|
|
+ Project* project = GetSubsystem<ToolSystem>()->GetProject();
|
|
|
+ NETBuildSystem* buildSystem = GetSubsystem<NETBuildSystem>();
|
|
|
|
|
|
- if (!gen->Generate())
|
|
|
+ if (buildSystem)
|
|
|
+ {
|
|
|
+ NETBuild* build = buildSystem->BuildAtomicProject(project);
|
|
|
+
|
|
|
+ if (build)
|
|
|
{
|
|
|
- return;
|
|
|
+ build->SubscribeToEvent(E_NETBUILDRESULT, HANDLER(NETProjectSystem, HandleNETBuildResult));
|
|
|
}
|
|
|
|
|
|
- solutionDirty_ = false;
|
|
|
+ }
|
|
|
+#endif
|
|
|
|
|
|
+ }
|
|
|
+
|
|
|
+ bool NETProjectSystem::GenerateSolution()
|
|
|
+ {
|
|
|
+ ToolSystem* tsystem = GetSubsystem<ToolSystem>();
|
|
|
+ Project* project = tsystem->GetProject();
|
|
|
+
|
|
|
+ if (!project)
|
|
|
+ {
|
|
|
+ LOGERRORF("NETProjectSystem::GenerateSolution - No Project Loaded");
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
- if (projectAssemblyDirty_)
|
|
|
+ SharedPtr<NETProjectGen> gen(new NETProjectGen(context_));
|
|
|
+
|
|
|
+ gen->SetScriptPlatform("WINDOWS");
|
|
|
+
|
|
|
+ if (!gen->LoadProject(project))
|
|
|
+ {
|
|
|
+ LOGERRORF("NETProjectSystem::GenerateSolution - Unable to Load Project");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!gen->Generate())
|
|
|
{
|
|
|
- using namespace NETBuildAtomicProject;
|
|
|
+ LOGERRORF("NETProjectSystem::GenerateSolution - Unable to Generate Project");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
- VariantMap eventData;
|
|
|
- Project* project = GetSubsystem<ToolSystem>()->GetProject();
|
|
|
- eventData[P_PROJECT] = project;
|
|
|
+ return true;
|
|
|
|
|
|
- // We need to rebuild the project assembly
|
|
|
- SendEvent(E_NETBUILDATOMICPROJECT, eventData);
|
|
|
+ }
|
|
|
|
|
|
- projectAssemblyDirty_ = false;
|
|
|
|
|
|
+ void NETProjectSystem::HandleUpdate(StringHash eventType, VariantMap& eventData)
|
|
|
+ {
|
|
|
+ using namespace Update;
|
|
|
+
|
|
|
+ float delta = eventData[P_TIMESTEP].GetFloat();
|
|
|
+
|
|
|
+ quietPeriod_ -= delta;
|
|
|
+
|
|
|
+ if (quietPeriod_ < 0.0f)
|
|
|
+ quietPeriod_ = 0.0f;
|
|
|
+
|
|
|
+ if (quietPeriod_ > 0.0f)
|
|
|
+ return;
|
|
|
+
|
|
|
+ if (solutionDirty_)
|
|
|
+ {
|
|
|
+ solutionDirty_ = false;
|
|
|
+ GenerateSolution();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (projectAssemblyDirty_)
|
|
|
+ {
|
|
|
+ BuildAtomicProject();
|
|
|
+ projectAssemblyDirty_ = false;
|
|
|
}
|
|
|
|
|
|
}
|