Browse Source

Merge pull request #1129 from AtomicGameEngine/JME-ATOMIC-SUBEXAMPLES

Adding AtomicExamples as a submodule, improved handling of not having submodules initialized
JoshEngebretson 9 years ago
parent
commit
d6df5b470a

+ 3 - 0
.gitmodules

@@ -1,3 +1,6 @@
 [submodule "Submodules/CEF"]
 	path = Submodules/CEF
 	url = https://github.com/AtomicGameEngine/CEF3Binaries
+[submodule "Submodules/AtomicExamples"]
+	path = Submodules/AtomicExamples
+	url = https://github.com/AtomicGameEngine/AtomicExamples

+ 27 - 0
Build/CMake/Modules/AtomicGit.cmake

@@ -0,0 +1,27 @@
+
+# If submodules aren't initialized, look for git and initialize
+if (NOT EXISTS ${CMAKE_SOURCE_DIR}/Submodules/CEF/.git OR NOT EXISTS ${CMAKE_SOURCE_DIR}/Submodules/AtomicExamples/.git)
+
+    find_package(Git)
+
+    if(GIT_FOUND)
+
+        message ("\n\nUpdating submodules, please wait...\n\n")
+
+        execute_process( COMMAND ${GIT_EXECUTABLE} submodule update --init
+                         WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+                         RESULT_VARIABLE ATOMIC_GIT_STATUS )
+
+        # check return status
+        if(NOT ATOMIC_GIT_STATUS EQUAL 0)
+            message( FATAL_ERROR "BUILD ERROR:\n\nError initializing submodules: git submodule update --init returned ${ATOMIC_GIT_STATUS}\n")
+        endif()
+
+    else()
+
+        # Git not found
+        message( FATAL_ERROR "BUILD ERROR:\n\Submodules not initialized, please run: git submodule update --init\n")
+
+    endif()
+
+endif()

+ 1 - 9
Build/Scripts/Bootstrap.js

@@ -31,7 +31,7 @@ function printHelp() {
     console.log("--noclean       : Do not clean before building, useful during development");
     console.log("--nonet         : Build without AtomicNET C# scripting support");
     console.log("--with-docs     : Build and install API documents into the editor (requires npm on path)");
-    console.log("--with-examples : Install examples into the editor (require git on path)");
+    console.log("--noexamples    : Don't include examples with editor");
     console.log("--task=name     : Build the specified task (for development)");
     console.log("--package       : packages the editor to Artifacts/Dist");
     console.log("--------------------------")
@@ -64,14 +64,6 @@ if (config["task"]) {
 // Atomic Editor Build
 if (cmd == "buildeditor") {
 
-    // simple build check for submodules not being initialized
-
-    if (!fs.existsSync(config.atomicRoot + "Submodules/CEF/Windows")) {
-
-        console.log("\nBUILD ERROR:\n\nSubmodules not initialized.  When cloning repository, please use:\ngit clone --recursive https://github.com/AtomicGameEngine/AtomicGameEngine\n")
-        process.exit(1);
-    }
-
     console.log("\n\nBuilding Atomic Editor, this process will take a few minutes\n");
 
     var buildTask = jake.Task['build:atomiceditor'];

+ 8 - 15
Build/Scripts/BuildCommon.js

@@ -256,25 +256,18 @@ namespace('build', function() {
 
     console.log( "Generating Examples..." );
 
-    common.cleanCreateDir( config.toolDataFolder + "AtomicExamples");
+    // TODO: support pulling examples from a specific branch/commit/etc
+    var exampleSrc = atomicRoot + "Submodules/AtomicExamples/";
+    var exampleDst = config.toolDataFolder + "AtomicExamples/";
 
-    cmds = [
-      "git clone https://github.com/AtomicGameEngine/AtomicExamples " + config.toolDataFolder + "AtomicExamples",
-    ];
-
-    jake.exec(cmds, function() {
-
-      fs.removeSync( config.toolDataFolder + "AtomicExamples/.git" );
+    common.testRemoveDir( exampleDst);
 
-      complete();
-
-      console.log( "completed installing example programs" )
+    fs.copySync(exampleSrc, exampleDst);
 
-        }, {
+    // remove the .git file/folder and save some space
+    fs.removeSync( exampleDst + ".git" );
 
-      printStdout: true
-
-    });
+    complete();
 
   });
 

+ 1 - 1
Build/Scripts/BuildConfig.js

@@ -64,7 +64,7 @@ exports = module.exports = processOptions(require('minimist')(process.argv.slice
         "with-android" : false,
         "with-ios" : false,
         "with-docs" : false,
-        "with-examples" : false,
+        "noexamples" : false,
         "package" : false
     }
 }));

+ 1 - 1
Build/Scripts/BuildTasks.js

@@ -17,7 +17,7 @@ function installBuildTasks(rootTask) {
         task = docTask;
     }
 
-    if (config["with-examples"]) {
+    if (!config["noexamples"]) {
         var examplesTask = jake.Task['build:genexamples'];
         task.prereqs.push("build:genexamples")
         task = examplesTask;

+ 1 - 4
CMakeLists.txt

@@ -5,6 +5,7 @@ cmake_minimum_required(VERSION 2.8.12.1)
 
 set (CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/Build/CMake/Modules)
 
+include(AtomicGit)
 include(AtomicUtils)
 
 add_definitions(-DATOMIC_ROOT_SOURCE_DIR="${CMAKE_SOURCE_DIR}" -DATOMIC_ROOT_BUILD_DIR="${CMAKE_BINARY_DIR}")
@@ -48,10 +49,6 @@ endif()
 
 if (ATOMIC_WEBVIEW)
 
-  if (NOT EXISTS ${CMAKE_SOURCE_DIR}/Submodules/CEF/Windows)
-    message( FATAL_ERROR "\nBUILD ERROR:\nSubmodules not initialized.  When cloning repository, please use:\ngit clone --recursive https://github.com/AtomicGameEngine/AtomicGameEngine\n" )
-  endif()
-
   if(APPLE)
     if(POLICY CMP0037)
       # new cmake doesn't like creating framework whose name has spaces

+ 6 - 0
Script/AtomicEditor/resources/ProjectTemplates.ts

@@ -107,6 +107,12 @@ export function getExampleProjectTemplateDefinitions(): [ProjectTemplateDefiniti
     exampleFolders.forEach(exampleFolder => {
 
         let folder = Atomic.addTrailingSlash(env.toolDataDir + "AtomicExamples/" + exampleFolder);
+
+        // if we're building from source tree, adjust the path
+        if (Atomic.AtomicBuildInfo.getDevBuild()) {
+            folder = Atomic.addTrailingSlash(env.rootSourceDir + "Submodules/AtomicExamples/" + exampleFolder);
+        }
+
         let screenshot = folder + "Screenshot.png";
 
         if (!fileSystem.dirExists(folder)) {

+ 9 - 0
Source/Atomic/BuildInfo/AtomicBuildInfo.cpp

@@ -35,6 +35,15 @@ String AtomicBuildInfo::GetBuildName()
 #endif
 }
 
+bool AtomicBuildInfo::GetDevBuild()
+{
+#ifdef ATOMIC_DEV_BUILD
+    return true;
+#else
+    return false;
+#endif
+}
+
 bool AtomicBuildInfo::GetDistBuild()
 {
 #ifdef ATOMIC_BUILD_DIST

+ 4 - 1
Source/Atomic/BuildInfo/AtomicBuildInfo.h

@@ -52,7 +52,10 @@ class AtomicBuildInfo : public RefCounted
     /// Get the build string in form (BuildName): BuildDate BuildTime Git:SHA
     static String GetBuildString();
 
-    /// Get whether this is a dist build
+    /// Get whether this is binary or source tree development build
+    static bool GetDevBuild();
+
+    /// Get whether this is a distibution/installer binary build
     static bool GetDistBuild();
 
 };

+ 1 - 0
Source/Atomic/CMakeLists.txt

@@ -92,6 +92,7 @@ GroupSources("Scene")
 GroupSources("UI")
 GroupSources("Web")
 GroupSources("Script")
+GroupSources("BuildInfo")
 
 # Handle Git Revision
 include(GetGitRevisionDescription)

+ 1 - 0
Submodules/AtomicExamples

@@ -0,0 +1 @@
+Subproject commit 99cf8f6c51ad2702899d44e236ae9765b562970d