Browse Source

Adding revision info to build (CI only atm)

Josh Engebretson 9 years ago
parent
commit
ef79bab593

+ 2 - 1
Build/CMake/Modules/AtomicCommon.cmake

@@ -2,9 +2,10 @@
 set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DATOMIC_DEBUG")
 set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DATOMIC_DEBUG")
 set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DATOMIC_DEBUG")
 set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DATOMIC_DEBUG")
 
 
+set (ATOMIC_LINK_LIBRARIES ${ATOMIC_LINK_LIBRARIES} AtomicBuildInfo)
+
 if(CMAKE_SIZEOF_VOID_P MATCHES 8)
 if(CMAKE_SIZEOF_VOID_P MATCHES 8)
   set(ATOMIC_PROJECT_ARCH "x86_64")
   set(ATOMIC_PROJECT_ARCH "x86_64")
 else()
 else()
   set(ATOMIC_PROJECT_ARCH "x86")
   set(ATOMIC_PROJECT_ARCH "x86")
 endif()
 endif()
-

+ 2 - 2
Script/AtomicEditor/ui/modal/About.ts

@@ -86,8 +86,8 @@ class About extends ModalWindow {
         var text = "";
         var text = "";
 
 
         text += "<widget TBImageWidget: filename: 'AtomicEditor/editor/images/atomic_logo.png'>\n\n";
         text += "<widget TBImageWidget: filename: 'AtomicEditor/editor/images/atomic_logo.png'>\n\n";
-        text += "<color #D4FB79>Version  0.1.p0</color>\n\n";
-        text += "(c) 2014-2015 THUNDERBEAST GAMES LLC\n\n\n";
+        text += "<color #D4FB79>Git SHA: " + Atomic.getGitRevision() +"</color>\n\n";
+        text += "(c) 2014-2016 THUNDERBEAST GAMES LLC\n\n\n";
 
 
         text += "<color #D4FB79>Installed platforms and modules:</color>\n\n";
         text += "<color #D4FB79>Installed platforms and modules:</color>\n\n";
 
 

+ 1 - 0
Script/TypeScript/AtomicWork.d.ts

@@ -7,6 +7,7 @@
 declare module Atomic {
 declare module Atomic {
 
 
     export function print(...args: any[]);
     export function print(...args: any[]);
+    export function getGitRevision():string;
 
 
     export var platform: string;
     export var platform: string;
 
 

+ 1 - 0
Source/AtomicBuildInfo/.gitignore

@@ -0,0 +1 @@
+_*.*

+ 14 - 0
Source/AtomicBuildInfo/AtomicBuildInfo.cpp

@@ -0,0 +1,14 @@
+
+
+#include "_GeneratedRevision.h"
+#include "AtomicBuildInfo.h"
+
+namespace Atomic
+{
+
+const char* GetGitSHA()
+{
+    return atomicBuildRevision;
+}
+
+}

+ 33 - 0
Source/AtomicBuildInfo/AtomicBuildInfo.h

@@ -0,0 +1,33 @@
+
+//
+// Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+
+#pragma once
+
+namespace Atomic
+{
+
+/// Get the Git SHA of the Build, currently only valid for a binary release off CI
+const char* GetGitSHA();
+
+}

+ 33 - 0
Source/AtomicBuildInfo/CMakeLists.txt

@@ -0,0 +1,33 @@
+
+set (ATOMIC_GIT_SHA "Unversioned Build")
+
+if (DEFINED ENV{ATOMIC_BUILD_SHA})
+    set (ATOMIC_GIT_SHA $ENV{ATOMIC_BUILD_SHA})
+endif ()
+
+set (WRITE_REVISION "")
+
+if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/_GeneratedRevision.h OR NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/_GeneratedRevision.cache)
+    set (WRITE_REVISION "TRUE")
+else()
+
+    file (READ ${CMAKE_CURRENT_SOURCE_DIR}/_GeneratedRevision.cache ATOMIC_CACHE_SHA)
+
+    if (NOT ATOMIC_GIT_SHA STREQUAL ATOMIC_CACHE_SHA)
+        set (WRITE_REVISION "TRUE")
+    endif()
+
+endif()
+
+if (${WRITE_REVISION})
+    #message ("Writing Git Revision: ${WRITE_REVISION} : ATOMIC_GIT_SHA:${ATOMIC_GIT_SHA} ATOMIC_CACHE_SHA:${ATOMIC_CACHE_SHA}")
+    file (WRITE ${CMAKE_CURRENT_SOURCE_DIR}/_GeneratedRevision.h "const char* atomicBuildRevision=\"${ATOMIC_GIT_SHA}\";\n")
+    file (WRITE ${CMAKE_CURRENT_SOURCE_DIR}/_GeneratedRevision.cache "${ATOMIC_GIT_SHA}")
+else()
+    #message ("Using Cached Git Revision: ${WRITE_REVISION} : ATOMIC_GIT_SHA:${ATOMIC_GIT_SHA} ATOMIC_CACHE_SHA:${ATOMIC_CACHE_SHA}")
+endif()
+
+
+file (GLOB SOURCE_FILES *.cpp *.h)
+
+add_library(AtomicBuildInfo ${SOURCE_FILES})

+ 12 - 0
Source/AtomicJS/Javascript/JSAtomic.cpp

@@ -63,6 +63,8 @@
 #include <Atomic/Scene/Scene.h>
 #include <Atomic/Scene/Scene.h>
 #include <Atomic/Environment/ProcSky.h>
 #include <Atomic/Environment/ProcSky.h>
 
 
+#include <AtomicBuildInfo/AtomicBuildInfo.h>
+
 namespace Atomic
 namespace Atomic
 {
 {
 
 
@@ -197,6 +199,13 @@ static int js_atomic_GetUI(duk_context* ctx)
     return 1;
     return 1;
 }
 }
 
 
+static int js_atomic_GetGitRevision(duk_context* ctx)
+{
+    duk_push_string(ctx, GetGitSHA());
+    return 1;
+}
+
+
 
 
 static int js_atomic_script(duk_context* ctx)
 static int js_atomic_script(duk_context* ctx)
 {
 {
@@ -291,6 +300,7 @@ static int js_atomic_destroy(duk_context* ctx)
     return 0;
     return 0;
 }
 }
 
 
+
 void jsapi_init_atomic(JSVM* vm)
 void jsapi_init_atomic(JSVM* vm)
 {
 {
     // core modules
     // core modules
@@ -423,6 +433,8 @@ void jsapi_init_atomic(JSVM* vm)
     duk_put_prop_string(ctx, -2, "ui");
     duk_put_prop_string(ctx, -2, "ui");
 
 
     // end subsystems
     // end subsystems
+    duk_push_c_function(ctx, js_atomic_GetGitRevision, 0);
+    duk_put_prop_string(ctx, -2, "getGitRevision");
 
 
     duk_push_c_function(ctx, js_atomic_script, 1);
     duk_push_c_function(ctx, js_atomic_script, 1);
     duk_put_prop_string(ctx, -2, "script");
     duk_put_prop_string(ctx, -2, "script");

+ 1 - 0
Source/CMakeLists.txt

@@ -1,5 +1,6 @@
 
 
 add_subdirectory(ThirdParty)
 add_subdirectory(ThirdParty)
+add_subdirectory(AtomicBuildInfo)
 add_subdirectory(Atomic)
 add_subdirectory(Atomic)
 add_subdirectory(AtomicJS)
 add_subdirectory(AtomicJS)