|
@@ -1,5 +1,7 @@
|
|
|
using System;
|
|
using System;
|
|
|
|
|
+using System.IO;
|
|
|
using System.Runtime.CompilerServices;
|
|
using System.Runtime.CompilerServices;
|
|
|
|
|
+using System.Threading;
|
|
|
using BansheeEngine;
|
|
using BansheeEngine;
|
|
|
|
|
|
|
|
namespace BansheeEditor
|
|
namespace BansheeEditor
|
|
@@ -91,6 +93,15 @@ namespace BansheeEditor
|
|
|
set { Internal_SetResolution(mCachedPtr, WindowedWidth, value); }
|
|
set { Internal_SetResolution(mCachedPtr, WindowedWidth, value); }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
|
+ /// Determines should the scripts be output in debug mode (worse performance but better error reporting).
|
|
|
|
|
+ /// </summary>
|
|
|
|
|
+ public bool Debug
|
|
|
|
|
+ {
|
|
|
|
|
+ get { return Internal_GetDebug(mCachedPtr); }
|
|
|
|
|
+ set { Internal_SetDebug(mCachedPtr, value); }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// A set of semicolon separated defines to use when compiling scripts for this platform.
|
|
/// A set of semicolon separated defines to use when compiling scripts for this platform.
|
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -126,6 +137,12 @@ namespace BansheeEditor
|
|
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
|
static extern void Internal_SetResolution(IntPtr thisPtr, int width, int height);
|
|
static extern void Internal_SetResolution(IntPtr thisPtr, int width, int height);
|
|
|
|
|
+
|
|
|
|
|
+ [MethodImpl(MethodImplOptions.InternalCall)]
|
|
|
|
|
+ static extern bool Internal_GetDebug(IntPtr thisPtr);
|
|
|
|
|
+
|
|
|
|
|
+ [MethodImpl(MethodImplOptions.InternalCall)]
|
|
|
|
|
+ static extern void Internal_SetDebug(IntPtr thisPtr, bool fullscreen);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -247,29 +264,182 @@ namespace BansheeEditor
|
|
|
get { return Internal_GetActivePlatformInfo(); }
|
|
get { return Internal_GetActivePlatformInfo(); }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
|
+ /// Returns a path to a specific folder used in the build process. See entries of BuildFolder enum for explanations
|
|
|
|
|
+ /// of individual folder types.
|
|
|
|
|
+ /// </summary>
|
|
|
|
|
+ /// <param name="folder">Type of folder to retrieve the path for.</param>
|
|
|
|
|
+ /// <param name="platform">Platform to retrieve the path for.</param>
|
|
|
|
|
+ /// <returns>Path for the requested folder. This can be absolute or relative, see <see cref="BuildFolder"/> enum
|
|
|
|
|
+ /// for details.</returns>
|
|
|
|
|
+ private static string GetBuildFolder(BuildFolder folder, PlatformType platform)
|
|
|
|
|
+ {
|
|
|
|
|
+ return Internal_GetBuildFolder(folder, platform);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /// <summary>
|
|
|
|
|
+ /// Returns a list of names of all native binaries required for a specific platform.
|
|
|
|
|
+ /// </summary>
|
|
|
|
|
+ /// <param name="platform">Platform type for which to get the binaries for.</param>
|
|
|
|
|
+ /// <returns>Array of names of native binary files.</returns>
|
|
|
|
|
+ private static string[] GetNativeBinaries(PlatformType platform)
|
|
|
|
|
+ {
|
|
|
|
|
+ return Internal_GetNativeBinaries(platform);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// Builds the executable and packages the game.
|
|
/// Builds the executable and packages the game.
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
public static void Build()
|
|
public static void Build()
|
|
|
{
|
|
{
|
|
|
- // TODO
|
|
|
|
|
|
|
+ PlatformType activePlatform = ActivePlatform;
|
|
|
|
|
+ PlatformInfo platformInfo = ActivePlatformInfo;
|
|
|
|
|
+
|
|
|
|
|
+ string srcRoot = GetBuildFolder(BuildFolder.SourceRoot, activePlatform);
|
|
|
|
|
+ string destRoot = GetBuildFolder(BuildFolder.DestinationRoot, activePlatform);
|
|
|
|
|
+
|
|
|
|
|
+ // Prepare clean destination folder
|
|
|
|
|
+ Directory.Delete(destRoot, true);
|
|
|
|
|
+ Directory.CreateDirectory(destRoot);
|
|
|
|
|
+
|
|
|
|
|
+ // Compile game assembly
|
|
|
|
|
+ string bansheeAssemblyFolder = GetBuildFolder(BuildFolder.BansheeAssemblies, activePlatform);
|
|
|
|
|
+ string srcBansheeAssemblyFolder = Path.Combine(srcRoot, bansheeAssemblyFolder);
|
|
|
|
|
+ string destBansheeAssemblyFolder = Path.Combine(destRoot, bansheeAssemblyFolder);
|
|
|
|
|
+
|
|
|
|
|
+ Directory.CreateDirectory(destBansheeAssemblyFolder);
|
|
|
|
|
+ CompilerInstance ci = ScriptCompiler.CompileAsync(ScriptAssemblyType.Game, ActivePlatform, platformInfo.Debug, destBansheeAssemblyFolder);
|
|
|
|
|
+
|
|
|
|
|
+ // Copy engine assembly
|
|
|
|
|
+ // TODO - Copy Release version of engine assembly if not in debug mode, and Debug otherwise
|
|
|
|
|
+ {
|
|
|
|
|
+ string srcFile = Path.Combine(srcBansheeAssemblyFolder, EditorApplication.EngineAssemblyName);
|
|
|
|
|
+ string destFile = Path.Combine(destBansheeAssemblyFolder, EditorApplication.EngineAssemblyName);
|
|
|
|
|
+
|
|
|
|
|
+ File.Copy(srcFile, destFile);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // Copy builtin data
|
|
|
|
|
+ string dataFolder = GetBuildFolder(BuildFolder.Data, activePlatform);
|
|
|
|
|
+ string srcData = Path.Combine(srcRoot, dataFolder);
|
|
|
|
|
+ string destData = Path.Combine(destRoot, dataFolder);
|
|
|
|
|
+
|
|
|
|
|
+ DirectoryEx.Copy(srcData, destData);
|
|
|
|
|
+
|
|
|
|
|
+ // Copy native binaries
|
|
|
|
|
+ string binaryFolder = GetBuildFolder(BuildFolder.NativeBinaries, activePlatform);
|
|
|
|
|
+ string srcBin = Path.Combine(srcRoot, binaryFolder);
|
|
|
|
|
+ string destBin = Path.Combine(destRoot, binaryFolder);
|
|
|
|
|
+
|
|
|
|
|
+ Directory.CreateDirectory(destBin);
|
|
|
|
|
+
|
|
|
|
|
+ string[] nativeBinaries = GetNativeBinaries(activePlatform);
|
|
|
|
|
+ foreach (var entry in nativeBinaries)
|
|
|
|
|
+ {
|
|
|
|
|
+ string srcFile = Path.Combine(srcBin, entry);
|
|
|
|
|
+ string destFile = Path.Combine(destBin, entry);
|
|
|
|
|
+
|
|
|
|
|
+ File.Copy(srcFile, destFile);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // Copy .NET framework assemblies
|
|
|
|
|
+ string frameworkAssemblyFolder = GetBuildFolder(BuildFolder.FrameworkAssemblies, activePlatform);
|
|
|
|
|
+ string srcFrameworkAssemblyFolder = Path.Combine(srcRoot, frameworkAssemblyFolder);
|
|
|
|
|
+ string destFrameworkAssemblyFolder = Path.Combine(destRoot, frameworkAssemblyFolder);
|
|
|
|
|
+
|
|
|
|
|
+ Directory.CreateDirectory(destFrameworkAssemblyFolder);
|
|
|
|
|
+
|
|
|
|
|
+ string[] frameworkAssemblies = GetFrameworkAssemblies(activePlatform);
|
|
|
|
|
+ foreach (var entry in frameworkAssemblies)
|
|
|
|
|
+ {
|
|
|
|
|
+ string srcFile = Path.Combine(srcFrameworkAssemblyFolder, entry + ".dll");
|
|
|
|
|
+ string destFile = Path.Combine(destFrameworkAssemblyFolder, entry + ".dll");
|
|
|
|
|
+
|
|
|
|
|
+ File.Copy(srcFile, destFile);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // Copy Mono
|
|
|
|
|
+ string monoFolder = GetBuildFolder(BuildFolder.Mono, activePlatform);
|
|
|
|
|
+ string srcMonoFolder = Path.Combine(srcRoot, monoFolder);
|
|
|
|
|
+ string destMonoFolder = Path.Combine(destRoot, monoFolder);
|
|
|
|
|
+
|
|
|
|
|
+ DirectoryEx.Copy(srcMonoFolder, destMonoFolder);
|
|
|
|
|
+
|
|
|
|
|
+ string srcExecFile = GetMainExecutable(activePlatform);
|
|
|
|
|
+ string destExecFile = Path.Combine(destBin, Path.GetFileName(srcExecFile));
|
|
|
|
|
+
|
|
|
|
|
+ File.Copy(srcExecFile, destExecFile);
|
|
|
|
|
+
|
|
|
|
|
+ InjectIcons(destExecFile, platformInfo);
|
|
|
|
|
+ PackageResources(destRoot, platformInfo);
|
|
|
|
|
+ CreateStartupSettings(destRoot, platformInfo);
|
|
|
|
|
+
|
|
|
|
|
+ // Wait until compile finishes
|
|
|
|
|
+ while (!ci.IsDone)
|
|
|
|
|
+ Thread.Sleep(200);
|
|
|
|
|
+
|
|
|
|
|
+ ci.Dispose();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /// <summary>
|
|
|
|
|
+ /// Injects icons specified in <see cref="PlatformInfo"/> into an executable at the specified path.
|
|
|
|
|
+ /// </summary>
|
|
|
|
|
+ /// <param name="filePath">Absolute path to the executable to inject icons in.</param>
|
|
|
|
|
+ /// <param name="info">Object containing references to icons to inject.</param>
|
|
|
|
|
+ private static void InjectIcons(string filePath, PlatformInfo info)
|
|
|
|
|
+ {
|
|
|
|
|
+ IntPtr infoPtr = IntPtr.Zero;
|
|
|
|
|
+ if (info != null)
|
|
|
|
|
+ infoPtr = info.GetCachedPtr();
|
|
|
|
|
+
|
|
|
|
|
+ Internal_InjectIcons(filePath, infoPtr);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /// <summary>
|
|
|
|
|
+ /// Finds all used resources by the build and packages them into an output folder.
|
|
|
|
|
+ /// </summary>
|
|
|
|
|
+ /// <param name="buildFolder">Absolute path to the root folder of the build. This is where the packaged resource
|
|
|
|
|
+ /// folder be placed.</param>
|
|
|
|
|
+ /// <param name="info">Platform information about the current build.</param>
|
|
|
|
|
+ private static void PackageResources(string buildFolder, PlatformInfo info)
|
|
|
|
|
+ {
|
|
|
|
|
+ IntPtr infoPtr = IntPtr.Zero;
|
|
|
|
|
+ if (info != null)
|
|
|
|
|
+ infoPtr = info.GetCachedPtr();
|
|
|
|
|
+
|
|
|
|
|
+ Internal_PackageResources(buildFolder, infoPtr);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /// <summary>
|
|
|
|
|
+ /// Creates a game settings asset that contains necessary data for starting up the game (e.g. initial scene).
|
|
|
|
|
+ /// </summary>
|
|
|
|
|
+ /// <param name="buildFolder">Absolute path to the root folder of the build. This is where the settings assets
|
|
|
|
|
+ /// will be output.</param>
|
|
|
|
|
+ /// <param name="info">Platform information about the current build.</param>
|
|
|
|
|
+ private static void CreateStartupSettings(string buildFolder, PlatformInfo info)
|
|
|
|
|
+ {
|
|
|
|
|
+ IntPtr infoPtr = IntPtr.Zero;
|
|
|
|
|
+ if (info != null)
|
|
|
|
|
+ infoPtr = info.GetCachedPtr();
|
|
|
|
|
+
|
|
|
|
|
+ Internal_CreateStartupSettings(buildFolder, infoPtr);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
- /// Returns a list of .NET framework managed assemblies to be included for the specified platform.
|
|
|
|
|
|
|
+ /// Returns a list of .NET framework managed assemblies (without extension) to be included for the specified platform.
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
/// <param name="type">Platform type to retrieve the list of assemblies for.</param>
|
|
/// <param name="type">Platform type to retrieve the list of assemblies for.</param>
|
|
|
- /// <returns>A list of .NET framework managed assemblies that will be included with the build.</returns>
|
|
|
|
|
|
|
+ /// <returns>A list of .NET framework managed assemblies (without extension) that will be included with the build.</returns>
|
|
|
internal static string[] GetFrameworkAssemblies(PlatformType type)
|
|
internal static string[] GetFrameworkAssemblies(PlatformType type)
|
|
|
{
|
|
{
|
|
|
return Internal_GetFrameworkAssemblies(type);
|
|
return Internal_GetFrameworkAssemblies(type);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
- /// Returns the location of the executable for the provided platform.
|
|
|
|
|
|
|
+ /// Returns the absolute path to the executable for the provided platform.
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
/// <param name="type">Platform type to retrieve the executable location for.</param>
|
|
/// <param name="type">Platform type to retrieve the executable location for.</param>
|
|
|
- /// <returns>Path to the executable in the editor install folder.</returns>
|
|
|
|
|
|
|
+ /// <returns>Absolute path to the executable.</returns>
|
|
|
internal static string GetMainExecutable(PlatformType type)
|
|
internal static string GetMainExecutable(PlatformType type)
|
|
|
{
|
|
{
|
|
|
return Internal_GetMainExecutable(type);
|
|
return Internal_GetMainExecutable(type);
|
|
@@ -296,6 +466,27 @@ namespace BansheeEditor
|
|
|
return Internal_GetPlatformInfo(type);
|
|
return Internal_GetPlatformInfo(type);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
|
+ /// Types of various folders used by the build manager.
|
|
|
|
|
+ /// </summary>
|
|
|
|
|
+ private enum BuildFolder // Note: Must match C++ enum ScriptBuildFolder
|
|
|
|
|
+ {
|
|
|
|
|
+ /// <summary>Absolute path to the root folder where all the prebuilt binaries and data exist.</summary>
|
|
|
|
|
+ SourceRoot,
|
|
|
|
|
+ /// <summary>Absolute path to the root folder for a build for a specific platform.</summary>
|
|
|
|
|
+ DestinationRoot,
|
|
|
|
|
+ /// <summary>Folder where native binaries are stored. Relative to root.</summary>
|
|
|
|
|
+ NativeBinaries,
|
|
|
|
|
+ /// <summary>Folder where Banshee specific assemblies are stored. Relative to root.</summary>
|
|
|
|
|
+ BansheeAssemblies,
|
|
|
|
|
+ /// <summary>Folder where .NET framework assemblies are stored. Relative to root.</summary>
|
|
|
|
|
+ FrameworkAssemblies,
|
|
|
|
|
+ /// <summary>Folder where miscelaneous Mono files are stored. Relative to root.</summary>
|
|
|
|
|
+ Mono,
|
|
|
|
|
+ /// <summary>Folder where builtin data is stored. Relative to root.</summary>
|
|
|
|
|
+ Data
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
|
private static extern PlatformType[] Internal_GetAvailablePlatforms();
|
|
private static extern PlatformType[] Internal_GetAvailablePlatforms();
|
|
|
|
|
|
|
@@ -319,5 +510,20 @@ namespace BansheeEditor
|
|
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
|
private static extern string Internal_GetDefines(PlatformType type);
|
|
private static extern string Internal_GetDefines(PlatformType type);
|
|
|
|
|
+
|
|
|
|
|
+ [MethodImpl(MethodImplOptions.InternalCall)]
|
|
|
|
|
+ private static extern string[] Internal_GetNativeBinaries(PlatformType type);
|
|
|
|
|
+
|
|
|
|
|
+ [MethodImpl(MethodImplOptions.InternalCall)]
|
|
|
|
|
+ private static extern string Internal_GetBuildFolder(BuildFolder folder, PlatformType platform);
|
|
|
|
|
+
|
|
|
|
|
+ [MethodImpl(MethodImplOptions.InternalCall)]
|
|
|
|
|
+ private static extern void Internal_InjectIcons(string filePath, IntPtr info);
|
|
|
|
|
+
|
|
|
|
|
+ [MethodImpl(MethodImplOptions.InternalCall)]
|
|
|
|
|
+ private static extern void Internal_PackageResources(string buildFolder, IntPtr info);
|
|
|
|
|
+
|
|
|
|
|
+ [MethodImpl(MethodImplOptions.InternalCall)]
|
|
|
|
|
+ private static extern void Internal_CreateStartupSettings(string buildFolder, IntPtr info);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|