Browse Source

Support for Android platform on redistibutable editor builds: Build_AtomicEditor.bat --with-android

Josh Engebretson 9 years ago
parent
commit
401b3b42b9

+ 1 - 1
Build/Scripts/BuildAndroid.js

@@ -8,7 +8,7 @@ var buildDir = host.artifactsRoot + "Build/Android/";
 
 
 namespace('build', function() {
 namespace('build', function() {
 
 
-  task('android_player', ["build:atomiceditor"], {
+  task('android_native', {
     async: true
     async: true
   }, function() {
   }, function() {
 
 

+ 28 - 8
Build/Scripts/BuildWindows.js

@@ -11,7 +11,9 @@ namespace('build', function() {
   // Builds a standalone Atomic Editor, which can be distributed out of build tree
   // Builds a standalone Atomic Editor, which can be distributed out of build tree
   task('atomiceditor', {
   task('atomiceditor', {
     async: true
     async: true
-  }, function() {
+}, function(android) {
+
+    android = android == "android" ? true : false;
 
 
     // Clean build
     // Clean build
     var cleanBuild = true;
     var cleanBuild = true;
@@ -27,6 +29,17 @@ namespace('build', function() {
 
 
     // Build the AtomicEditor
     // Build the AtomicEditor
     cmds.push(atomicRoot + "Build/Scripts/Windows/CompileAtomicEditor.bat");
     cmds.push(atomicRoot + "Build/Scripts/Windows/CompileAtomicEditor.bat");
+    cmds.push(host.atomicTool + " net compile " + atomicRoot + "Script/AtomicNET/AtomicNETProject.json " + (android ? "ANDROID" : "WINDOWS") + " Release");
+
+    function copyAtomicNET() {
+
+        fs.copySync(atomicRoot + "Artifacts/AtomicNET/Release",
+          editorAppFolder + "Resources/ToolData/AtomicNET/Release");
+
+        fs.copySync(atomicRoot + "Script/AtomicNET/AtomicProject.json",
+          editorAppFolder + "Resources/ToolData/AtomicNET/Build/Projects/AtomicProject.json");
+
+    }
 
 
     jake.exec(cmds, function() {
     jake.exec(cmds, function() {
 
 
@@ -56,17 +69,24 @@ namespace('build', function() {
       fs.copySync(buildDir +  "Source/AtomicPlayer/Application/Release/D3DCompiler_47.dll",
       fs.copySync(buildDir +  "Source/AtomicPlayer/Application/Release/D3DCompiler_47.dll",
         editorAppFolder + "Resources/ToolData/Deployment/Windows/x64/D3DCompiler_47.dll");
         editorAppFolder + "Resources/ToolData/Deployment/Windows/x64/D3DCompiler_47.dll");
 
 
-      // AtomicNET
+      if (android) {
 
 
-      fs.copySync(atomicRoot + "Artifacts/AtomicNET/Release",
-        editorAppFolder + "Resources/ToolData/AtomicNET/Release");
+          var androidNativeTask = jake.Task['build:android_native'];
 
 
-      fs.copySync(atomicRoot + "Script/AtomicNET/AtomicProject.json",
-        editorAppFolder + "Resources/ToolData/AtomicNET/Build/Projects/AtomicProject.json");
+          androidNativeTask.addListener('complete', function () {
+              copyAtomicNET();
+              console.log("\nAtomic Editor build to ", editorAppFolder);
+              complete();
+          });
 
 
-      console.log("Atomic Editor build to ", editorAppFolder);
+          androidNativeTask.invoke();
 
 
-      complete();
+      }
+      else {
+          copyAtomicNET();
+          console.log("\nAtomic Editor build to ", editorAppFolder);
+          complete();
+      }
 
 
     }, {
     }, {
       printStdout: true
       printStdout: true

+ 0 - 1
Build/Scripts/Windows/CompileAtomicEditor.bat

@@ -1,4 +1,3 @@
 call "%VS140COMNTOOLS%..\..\VC\bin\amd64\vcvars64.bat"
 call "%VS140COMNTOOLS%..\..\VC\bin\amd64\vcvars64.bat"
 cmake ..\\..\\..\\ -DATOMIC_DEV_BUILD=0 -G "Visual Studio 14 2015 Win64"
 cmake ..\\..\\..\\ -DATOMIC_DEV_BUILD=0 -G "Visual Studio 14 2015 Win64"
 msbuild /m Atomic.sln /t:AtomicEditor /t:AtomicPlayer /t:AtomicNETNative /p:Configuration=Release /p:Platform=x64
 msbuild /m Atomic.sln /t:AtomicEditor /t:AtomicPlayer /t:AtomicNETNative /p:Configuration=Release /p:Platform=x64
-msbuild Source/AtomicTool/GenerateAtomicNET.vcxproj /p:Configuration=Release /p:Platform=x64

+ 28 - 2
Build_AtomicEditor.bat

@@ -1,11 +1,37 @@
-@ECHO OFF
+@echo OFF
+setlocal enabledelayedexpansion
+
+set ATOMICEDITOR_BUILD_CMD=Build\Windows\node\node.exe Build\node_modules\jake\bin\cli.js -f ./Build/Scripts/Bootstrap.js build:atomiceditor
+
+for %%a in (%*) do (
+  if /I "%%a"=="--with-android" (set ATOMICEDITOR_ANDROID=YES)
+)
+
+:: If we're building in android support, make sure ANDROID_NDK is defined
+if "%ATOMICEDITOR_ANDROID%" == "YES" (
+
+    if "%ANDROID_NDK%" == "" (
+        @echo:
+        echo ANDROID_NDK not set, exiting
+        @echo:
+        exit /B
+    )
+
+    @echo:
+    echo Building Atomic Editor with Android support
+    @echo:
+    set ATOMICEDITOR_BUILD_CMD=!ATOMICEDITOR_BUILD_CMD!["android"]
+)
+
 @echo:
 @echo:
 @echo:
 @echo:
 ECHO Building Atomic Editor, this process will take a few minutes
 ECHO Building Atomic Editor, this process will take a few minutes
 @echo:
 @echo:
 @echo:
 @echo:
 PAUSE
 PAUSE
-Build\Windows\node\node.exe Build\node_modules\jake\bin\cli.js -f ./Build/Scripts/Bootstrap.js build:atomiceditor
+%ATOMICEDITOR_BUILD_CMD%
 @echo:
 @echo:
 @echo:
 @echo:
 PAUSE
 PAUSE
+
+endlocal

+ 14 - 0
Script/AtomicEditor/hostExtensions/languageExtensions/CSharpLanguageExtension.ts

@@ -67,6 +67,7 @@ export default class CSharpLanguageExtension implements Editor.HostExtensions.Re
             menu.addItem(new Atomic.UIMenuItem("Open Solution", `${this.name}.opensolution`));
             menu.addItem(new Atomic.UIMenuItem("Open Solution", `${this.name}.opensolution`));
             menu.addItem(new Atomic.UIMenuItem("Compile Project", `${this.name}.compileproject`));
             menu.addItem(new Atomic.UIMenuItem("Compile Project", `${this.name}.compileproject`));
             menu.addItem(new Atomic.UIMenuItem("Generate Solution", `${this.name}.generatesolution`));
             menu.addItem(new Atomic.UIMenuItem("Generate Solution", `${this.name}.generatesolution`));
+            menu.addItem(new Atomic.UIMenuItem("Package Resources", `${this.name}.packageresources`));
 
 
             this.compileOnSaveMenuItem = new Atomic.UIMenuItem(`Compile on Save: ${isCompileOnSave ? "On" : "Off"}`, `${this.name}.compileonsave`);
             this.compileOnSaveMenuItem = new Atomic.UIMenuItem(`Compile on Save: ${isCompileOnSave ? "On" : "Off"}`, `${this.name}.compileonsave`);
             menu.addItem(this.compileOnSaveMenuItem);
             menu.addItem(this.compileOnSaveMenuItem);
@@ -201,6 +202,9 @@ export default class CSharpLanguageExtension implements Editor.HostExtensions.Re
                 case "generatesolution":
                 case "generatesolution":
                     this.generateSolution();
                     this.generateSolution();
                     return true;
                     return true;
+                case "packageresources":
+                    this.packageResources();
+                    return true;
                 case "compileonsave":
                 case "compileonsave":
                     let isCompileOnSave = this.serviceRegistry.projectServices.getUserPreference(this.name, "CompileOnSave", false);
                     let isCompileOnSave = this.serviceRegistry.projectServices.getUserPreference(this.name, "CompileOnSave", false);
                     // Toggle
                     // Toggle
@@ -243,5 +247,15 @@ export default class CSharpLanguageExtension implements Editor.HostExtensions.Re
 
 
     }
     }
 
 
+    /**
+    * Generate Solution
+    */
+    packageResources() {
+
+        if (ToolCore.netProjectSystem) {
+            ToolCore.netProjectSystem.generateResourcePak();
+        }
+
+    }
 
 
 }
 }

+ 3 - 0
Source/ToolCore/Build/BuildBase.h

@@ -81,6 +81,9 @@ public:
 	bool GetResourcesOnly() const { return resourcesOnly_; }
 	bool GetResourcesOnly() const { return resourcesOnly_; }
 	void SetResourcesOnly(bool resourcesOnly = true) { resourcesOnly_ = resourcesOnly;  }
 	void SetResourcesOnly(bool resourcesOnly = true) { resourcesOnly_ = resourcesOnly;  }
 
 
+	bool GetBuildFailed() const { return buildFailed_; }
+	const Vector<String>& GetBuildErrors() const { return buildErrors_; }
+
 protected:
 protected:
 
 
     bool BuildClean(const String& path);
     bool BuildClean(const String& path);

+ 13 - 3
Source/ToolCore/Build/BuildWindows.cpp

@@ -173,13 +173,16 @@ void BuildWindows::Build(const String& buildPath)
     ToolSystem* tsystem = GetSubsystem<ToolSystem>();
     ToolSystem* tsystem = GetSubsystem<ToolSystem>();
     Project* project = tsystem->GetProject();
     Project* project = tsystem->GetProject();
 
 
-    buildPath_ = AddTrailingSlash(buildPath) + GetBuildSubfolder();
+	buildPath_ = AddTrailingSlash(buildPath);
 
 
+	if (!resourcesOnly_)
+		buildPath_ += GetBuildSubfolder();
+		
     BuildLog("Starting Windows Deployment");
     BuildLog("Starting Windows Deployment");
 
 
     Initialize();
     Initialize();
 
 
-    if (!BuildClean(buildPath_))
+    if (!resourcesOnly_ && !BuildClean(buildPath_))
         return;
         return;
 
 
     String rootSourceDir = tenv->GetRootSourceDir();        
     String rootSourceDir = tenv->GetRootSourceDir();        
@@ -187,11 +190,18 @@ void BuildWindows::Build(const String& buildPath)
     if (!BuildCreateDirectory(buildPath_))
     if (!BuildCreateDirectory(buildPath_))
         return;
         return;
 
 
-    if (!BuildCreateDirectory(buildPath_ + "/AtomicPlayer_Resources"))
+    if (!resourcesOnly_ && !BuildCreateDirectory(buildPath_ + "/AtomicPlayer_Resources"))
         return;
         return;
 
 
     String resourcePackagePath = buildPath_ + "/AtomicPlayer_Resources/AtomicResources" + PAK_EXTENSION;
     String resourcePackagePath = buildPath_ + "/AtomicPlayer_Resources/AtomicResources" + PAK_EXTENSION;
+
+	if (resourcesOnly_)
+	{
+		resourcePackagePath = buildPath_ + "/AtomicResources" + PAK_EXTENSION;
+	}
+
     GenerateResourcePackage(resourcePackagePath);
     GenerateResourcePackage(resourcePackagePath);
+
     if (buildFailed_)
     if (buildFailed_)
         return;
         return;
 
 

+ 7 - 2
Source/ToolCore/NETTools/NETProjectGen.cpp

@@ -219,20 +219,25 @@ namespace ToolCore
 			{
 			{
 				if (GetIsPCL())
 				if (GetIsPCL())
 				{
 				{
+					ref = "AtomicNET";
 					platform = "Portable";
 					platform = "Portable";
 				}
 				}
 				else if (SupportsDesktop())
 				else if (SupportsDesktop())
 				{
 				{
+					ref = "AtomicNET";
 					platform = "Desktop";
 					platform = "Desktop";
 				}
 				}
 				else if (SupportsPlatform("android"))
 				else if (SupportsPlatform("android"))
 				{
 				{
+					if (ref != "AtomicNET.Android.SDL")
+						ref = "AtomicNET";
+
 					platform = "Android";
 					platform = "Android";
 				}
 				}
 
 
 				if (platform.Length())
 				if (platform.Length())
 				{					
 				{					
-					String atomicNETAssembly = tenv->GetAtomicNETCoreAssemblyDir() + ToString("%s/AtomicNET.dll", platform.CString(), ref.CString());
+					String atomicNETAssembly = tenv->GetAtomicNETCoreAssemblyDir() + ToString("%s/%s.dll", platform.CString(), ref.CString());
 					xref = igroup.CreateChild("Reference");
 					xref = igroup.CreateChild("Reference");
 					xref.SetAttribute("Include", atomicNETAssembly);
 					xref.SetAttribute("Include", atomicNETAssembly);
 				}
 				}
@@ -617,7 +622,7 @@ namespace ToolCore
 #endif
 #endif
 
 
 			// TODO: more than armeabi-v7a (which this is)
 			// TODO: more than armeabi-v7a (which this is)
-			String nativePath = AddTrailingSlash(tenv->GetAtomicNETRootDir()) + config + "/Android/Native/libAtomicNETNative.so";
+			String nativePath = AddTrailingSlash(tenv->GetAtomicNETRootDir()) + config + "/Native/Android/libAtomicNETNative.so";
 
 
 			XMLElement nativeLibrary =  projectRoot.CreateChild("ItemGroup").CreateChild("AndroidNativeLibrary"); 
 			XMLElement nativeLibrary =  projectRoot.CreateChild("ItemGroup").CreateChild("AndroidNativeLibrary"); 
 			nativeLibrary.SetAttribute("Include", nativePath);
 			nativeLibrary.SetAttribute("Include", nativePath);

+ 44 - 0
Source/ToolCore/NETTools/NETProjectSystem.cpp

@@ -35,6 +35,8 @@
 #include "../Project/ProjectSettings.h"
 #include "../Project/ProjectSettings.h"
 #include "../Project/ProjectEvents.h"
 #include "../Project/ProjectEvents.h"
 
 
+#include "../Build/BuildSystem.h"
+
 #include "../Subprocess/SubprocessSystem.h"
 #include "../Subprocess/SubprocessSystem.h"
 
 
 #include "NETProjectGen.h"
 #include "NETProjectGen.h"
@@ -199,6 +201,34 @@ namespace ToolCore
         }
         }
     }
     }
 
 
+	bool NETProjectSystem::GenerateResourcePak()
+	{
+		ToolSystem* tsystem = GetSubsystem<ToolSystem>();
+		Project* project = tsystem->GetProject();
+		BuildSystem* buildSystem = GetSubsystem<BuildSystem>();
+
+		// TODO: We just use WINDOWS platform for PAK generation for now
+		Platform* platform = tsystem->GetPlatformByName("WINDOWS");
+
+		buildSystem->SetBuildPath(project->GetProjectPath() + "AtomicNET/Resources/");
+
+		SharedPtr<BuildBase> buildBase(platform->NewBuild(project));
+		buildBase->SetResourcesOnly(true);
+		buildBase->SetVerbose(true);
+		buildSystem->QueueBuild(buildBase);
+		buildSystem->StartNextBuild();
+
+		if (buildBase->GetBuildFailed())
+		{
+			const StringVector& errors = buildBase->GetBuildErrors();
+			ATOMIC_LOGERRORF("NETProjectSystem::GenerateSolution - Unable to Build Resources.pak: %s", errors.Size() ? errors[0].CString() : "Unknown Error");
+			return false;
+		}
+
+		return true;
+
+	}
+
     bool NETProjectSystem::GenerateSolution()
     bool NETProjectSystem::GenerateSolution()
     {
     {
         ToolSystem* tsystem = GetSubsystem<ToolSystem>();
         ToolSystem* tsystem = GetSubsystem<ToolSystem>();
@@ -210,6 +240,20 @@ namespace ToolCore
             return false;
             return false;
         }
         }
 
 
+		// TODO: Generalize and move me
+		if (project->GetSupportsPlatform("android"))
+		{
+			FileSystem* fileSystem = GetSubsystem<FileSystem>();
+
+			if (!fileSystem->FileExists(project->GetProjectPath() + "AtomicNET/Resources/AtomicResources.pak"))
+			{
+				if (!GenerateResourcePak())
+					return false;
+
+			}
+
+		}
+
         SharedPtr<NETProjectGen> gen(new NETProjectGen(context_));
         SharedPtr<NETProjectGen> gen(new NETProjectGen(context_));
 
 
         if (!gen->LoadAtomicProject(project->GetProjectPath()))
         if (!gen->LoadAtomicProject(project->GetProjectPath()))

+ 1 - 0
Source/ToolCore/NETTools/NETProjectSystem.h

@@ -63,6 +63,7 @@ namespace ToolCore
         void OpenSourceFile(const String& sourceFilePath);
         void OpenSourceFile(const String& sourceFilePath);
 
 
         bool GenerateSolution();
         bool GenerateSolution();
+		bool GenerateResourcePak();
 
 
     private:
     private: