Browse Source

Added --log-std to the AtomicEditor's player app so can get output in VSCode, only copy the D3DCompiler dll when necessary

JoshEngebretson 10 years ago
parent
commit
4778b661d9

+ 1 - 1
Source/AtomicEditor/CMakeLists.txt

@@ -43,7 +43,7 @@ else()
     # pre-Windows 8 can't count on D3DCompiler_47.dll being on system
     add_custom_command (TARGET AtomicEditor POST_BUILD
     COMMAND ${CMAKE_COMMAND}
-    ARGS -E copy \"${D3DCOMPILER_47_DLL}\" \"$<TARGET_FILE_DIR:AtomicEditor>/D3DCompiler_47.dll\")
+    ARGS -E copy_if_different \"${D3DCOMPILER_47_DLL}\" \"$<TARGET_FILE_DIR:AtomicEditor>/D3DCompiler_47.dll\")
 
 endif()
 

+ 30 - 0
Source/AtomicEditor/Source/Player/AEPlayerApplication.cpp

@@ -24,6 +24,7 @@
 #include <Atomic/Engine/Engine.h>
 #include <Atomic/IO/FileSystem.h>
 #include <Atomic/IO/Log.h>
+#include <Atomic/IO/IOEvents.h>
 #include <Atomic/Core/Main.h>
 #include <Atomic/Core/ProcessUtils.h>
 #include <Atomic/Resource/ResourceCache.h>
@@ -64,6 +65,7 @@ AEPlayerApplication::AEPlayerApplication(Context* context) :
 #ifdef ATOMIC_3D
     RegisterEnvironmentLibrary(context_);
 #endif
+
 }
 
 void AEPlayerApplication::Setup()
@@ -108,6 +110,11 @@ void AEPlayerApplication::Setup()
             String argument = arguments[i].ToLower();
             String value = i + 1 < arguments.Size() ? arguments[i + 1] : String::EMPTY;
 
+            if (argument == "--log-std")
+            {
+                SubscribeToEvent(E_LOGMESSAGE, HANDLER(AEPlayerApplication, HandleLogMessage));
+            }
+
             if (argument.StartsWith("--ipc-server=") || argument.StartsWith("--ipc-client="))
             {
                 LOGINFOF("Starting IPCWorker %s", argument.CString());
@@ -241,4 +248,27 @@ void AEPlayerApplication::HandleScriptReloadFailed(StringHash eventType, Variant
     ErrorExit();
 }
 
+void AEPlayerApplication::HandleLogMessage(StringHash eventType, VariantMap& eventData)
+{
+    using namespace LogMessage;
+
+    int level = eventData[P_LEVEL].GetInt();
+    // The message may be multi-line, so split to rows in that case
+    Vector<String> rows = eventData[P_MESSAGE].GetString().Split('\n');
+
+    for (unsigned i = 0; i < rows.Size(); ++i)
+    {
+        if (level == LOG_ERROR)
+        {
+            fprintf(stderr, "%s\n", rows[i].CString());
+        }
+        else
+        {
+            fprintf(stdout, "%s\n", rows[i].CString());
+        }
+    }
+        
+}
+
+
 }

+ 3 - 0
Source/AtomicEditor/Source/Player/AEPlayerApplication.h

@@ -53,6 +53,9 @@ private:
     /// Handle reload failure of the script file.
     void HandleScriptReloadFailed(StringHash eventType, VariantMap& eventData);
 
+    void HandleLogMessage(StringHash eventType, VariantMap& eventData);
+
+
     void HandleHelloFromBroker(StringHash eventType, VariantMap& eventData);
 
     IPCHandle fd_[2];

+ 1 - 1
Source/AtomicJS/JSBind/CMakeLists.txt

@@ -16,7 +16,7 @@ if (MSVC)
     # TODO: Remove this dependency
     add_custom_command (TARGET JSBind POST_BUILD
     COMMAND ${CMAKE_COMMAND}
-    ARGS -E copy \"${D3DCOMPILER_47_DLL}\" \"$<TARGET_FILE_DIR:JSBind>/D3DCompiler_47.dll\")
+    ARGS -E copy_if_different \"${D3DCOMPILER_47_DLL}\" \"$<TARGET_FILE_DIR:JSBind>/D3DCompiler_47.dll\")
 endif()
 
 #TODO: finer grained dependencies

+ 1 - 1
Source/AtomicTool/CMakeLists.txt

@@ -17,7 +17,7 @@ if (MSVC)
     # TODO: Remove this dependency
     add_custom_command (TARGET AtomicTool POST_BUILD
     COMMAND ${CMAKE_COMMAND}
-    ARGS -E copy \"${D3DCOMPILER_47_DLL}\" \"$<TARGET_FILE_DIR:AtomicTool>/D3DCompiler_47.dll\")
+    ARGS -E copy_if_different \"${D3DCOMPILER_47_DLL}\" \"$<TARGET_FILE_DIR:AtomicTool>/D3DCompiler_47.dll\")
     
 else()
     target_link_libraries(AtomicTool curl)