Просмотр исходного кода

Fixes around the CacheCmd after introduction of CSComponentAssembly cache data.

-Add optional .NET service initialization for AtomicTool.
-Enable this service initialization for CacheCmd.
-Have AssetDatabase ensure existence of cache path when generating the cache.
Matt Benic 8 лет назад
Родитель
Сommit
dc57bd512b

+ 25 - 1
Source/AtomicTool/AtomicTool.cpp

@@ -34,6 +34,10 @@
 #include <ToolCore/Command/Command.h>
 #include <ToolCore/Command/CommandParser.h>
 
+#include <Atomic/IPC/IPC.h>
+#include <AtomicNET/NETScript/NETScript.h>
+#include <ToolCore/NETTools/AtomicNETService.h>
+
 #include "AtomicTool.h"
 
 ATOMIC_DEFINE_APPLICATION_MAIN(AtomicTool::AtomicTool);
@@ -254,6 +258,22 @@ void AtomicTool::Start()
 
     }
 
+    if (cmd->RequiresNETService())
+    {
+        context_->RegisterSubsystem(new IPC(context_));
+        RegisterNETScriptLibrary(context_);
+        SharedPtr<AtomicNETService> netService(new AtomicNETService(context_));
+
+        if (!netService->Start())
+        {
+            netService = nullptr;
+            ErrorExit(ToString("Unable to start AtomicNETService"));
+            return;
+        }
+
+        context_->RegisterSubsystem(netService);
+    }
+
     command_ = cmd;
 
     // BEGIN LICENSE MANAGEMENT
@@ -277,7 +297,11 @@ void AtomicTool::Start()
 
 void AtomicTool::Stop()
 {
-
+    IPC* ipc = GetSubsystem<IPC>();
+    if (ipc)
+    {
+        ipc->Shutdown();
+    }
 }
 
 void AtomicTool::ErrorExit(const String& message)

+ 9 - 0
Source/ToolCore/Assets/AssetDatabase.cpp

@@ -754,6 +754,15 @@ bool AssetDatabase::GenerateCache(bool clean)
         if (!CleanCache())
             return false;
     }
+    else
+    {
+        FileSystem* fileSystem = GetSubsystem<FileSystem>();
+        String cachePath = GetCachePath();
+        if (!fileSystem->DirExists(cachePath))
+        {
+            fileSystem->CreateDir(cachePath);
+        }
+    }
 
     ReimportAllAssets();
 

+ 2 - 0
Source/ToolCore/Command/CacheCmd.h

@@ -48,6 +48,8 @@ public:
 
     void Run();
 
+    bool RequiresNETService() { return true; }
+
 protected:
 
     bool ParseInternal(const Vector<String>& arguments, unsigned startIndex, String& errorMsg);

+ 2 - 0
Source/ToolCore/Command/Command.h

@@ -62,6 +62,8 @@ public:
 
     virtual bool RequiresProjectLoad() { return true; }
 
+    virtual bool RequiresNETService() { return false; }
+
     /// Loads project into ToolSystem returning true on success
     bool LoadProject();