Skip to content

Commit

Permalink
Support for Android platform on redistibutable editor builds: Build_A…
Browse files Browse the repository at this point in the history
…tomicEditor.bat --with-android
  • Loading branch information
JoshEngebretson committed Sep 9, 2016
1 parent 088705b commit 401b3b4
Show file tree
Hide file tree
Showing 10 changed files with 139 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Build/Scripts/BuildAndroid.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var buildDir = host.artifactsRoot + "Build/Android/";

namespace('build', function() {

task('android_player', ["build:atomiceditor"], {
task('android_native', {
async: true
}, function() {

Expand Down
36 changes: 28 additions & 8 deletions Build/Scripts/BuildWindows.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ namespace('build', function() {
// Builds a standalone Atomic Editor, which can be distributed out of build tree
task('atomiceditor', {
async: true
}, function() {
}, function(android) {

android = android == "android" ? true : false;

// Clean build
var cleanBuild = true;
Expand All @@ -27,6 +29,17 @@ namespace('build', function() {

// Build the AtomicEditor
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() {

Expand Down Expand Up @@ -56,17 +69,24 @@ namespace('build', function() {
fs.copySync(buildDir + "Source/AtomicPlayer/Application/Release/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
Expand Down
1 change: 0 additions & 1 deletion Build/Scripts/Windows/CompileAtomicEditor.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
call "%VS140COMNTOOLS%..\..\VC\bin\amd64\vcvars64.bat"
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 Source/AtomicTool/GenerateAtomicNET.vcxproj /p:Configuration=Release /p:Platform=x64
30 changes: 28 additions & 2 deletions Build_AtomicEditor.bat
Original file line number Diff line number Diff line change
@@ -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 Building Atomic Editor, this process will take a few minutes
@echo:
@echo:
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:
PAUSE

endlocal
Original file line number Diff line number Diff line change
Expand Up @@ -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("Compile Project", `${this.name}.compileproject`));
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`);
menu.addItem(this.compileOnSaveMenuItem);
Expand Down Expand Up @@ -201,6 +202,9 @@ export default class CSharpLanguageExtension implements Editor.HostExtensions.Re
case "generatesolution":
this.generateSolution();
return true;
case "packageresources":
this.packageResources();
return true;
case "compileonsave":
let isCompileOnSave = this.serviceRegistry.projectServices.getUserPreference(this.name, "CompileOnSave", false);
// Toggle
Expand Down Expand Up @@ -243,5 +247,15 @@ export default class CSharpLanguageExtension implements Editor.HostExtensions.Re

}

/**
* Generate Solution
*/
packageResources() {

if (ToolCore.netProjectSystem) {
ToolCore.netProjectSystem.generateResourcePak();
}

}

}
3 changes: 3 additions & 0 deletions Source/ToolCore/Build/BuildBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ friend class AndroidProjectGenerator;
bool GetResourcesOnly() const { return resourcesOnly_; }
void SetResourcesOnly(bool resourcesOnly = true) { resourcesOnly_ = resourcesOnly; }

bool GetBuildFailed() const { return buildFailed_; }
const Vector<String>& GetBuildErrors() const { return buildErrors_; }

protected:

bool BuildClean(const String& path);
Expand Down
16 changes: 13 additions & 3 deletions Source/ToolCore/Build/BuildWindows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,25 +173,35 @@ void BuildWindows::Build(const String& buildPath)
ToolSystem* tsystem = GetSubsystem<ToolSystem>();
Project* project = tsystem->GetProject();

buildPath_ = AddTrailingSlash(buildPath) + GetBuildSubfolder();
buildPath_ = AddTrailingSlash(buildPath);

if (!resourcesOnly_)
buildPath_ += GetBuildSubfolder();

BuildLog("Starting Windows Deployment");

Initialize();

if (!BuildClean(buildPath_))
if (!resourcesOnly_ && !BuildClean(buildPath_))
return;

String rootSourceDir = tenv->GetRootSourceDir();

if (!BuildCreateDirectory(buildPath_))
return;

if (!BuildCreateDirectory(buildPath_ + "/AtomicPlayer_Resources"))
if (!resourcesOnly_ && !BuildCreateDirectory(buildPath_ + "/AtomicPlayer_Resources"))
return;

String resourcePackagePath = buildPath_ + "/AtomicPlayer_Resources/AtomicResources" + PAK_EXTENSION;

if (resourcesOnly_)
{
resourcePackagePath = buildPath_ + "/AtomicResources" + PAK_EXTENSION;
}

GenerateResourcePackage(resourcePackagePath);

if (buildFailed_)
return;

Expand Down
9 changes: 7 additions & 2 deletions Source/ToolCore/NETTools/NETProjectGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,20 +219,25 @@ namespace ToolCore
{
if (GetIsPCL())
{
ref = "AtomicNET";
platform = "Portable";
}
else if (SupportsDesktop())
{
ref = "AtomicNET";
platform = "Desktop";
}
else if (SupportsPlatform("android"))
{
if (ref != "AtomicNET.Android.SDL")
ref = "AtomicNET";

platform = "Android";
}

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.SetAttribute("Include", atomicNETAssembly);
}
Expand Down Expand Up @@ -617,7 +622,7 @@ namespace ToolCore
#endif

// 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");
nativeLibrary.SetAttribute("Include", nativePath);
Expand Down
44 changes: 44 additions & 0 deletions Source/ToolCore/NETTools/NETProjectSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
#include "../Project/ProjectSettings.h"
#include "../Project/ProjectEvents.h"

#include "../Build/BuildSystem.h"

#include "../Subprocess/SubprocessSystem.h"

#include "NETProjectGen.h"
Expand Down Expand Up @@ -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()
{
ToolSystem* tsystem = GetSubsystem<ToolSystem>();
Expand All @@ -210,6 +240,20 @@ namespace ToolCore
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_));

if (!gen->LoadAtomicProject(project->GetProjectPath()))
Expand Down
1 change: 1 addition & 0 deletions Source/ToolCore/NETTools/NETProjectSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ namespace ToolCore
void OpenSourceFile(const String& sourceFilePath);

bool GenerateSolution();
bool GenerateResourcePak();

private:

Expand Down

0 comments on commit 401b3b4

Please sign in to comment.