Переглянути джерело

WIP: Linux port
- Compilation of managed assemblies integrated into the build

Marko Pintera 8 роки тому
батько
коміт
1536286d25

+ 10 - 7
Documentation/GitHub/compiling.md

@@ -21,7 +21,7 @@ Use the guide below to get Banshee up and running as quickly as possible. Scroll
 	  - `Xcode`
 	- See all valid generators: [cmake-generators](https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html)
 - Build the project using your chosen tool
-  - Build files are in `BansheeEngine\Build` folder
+  - Build files will be placed in `BansheeEngine\Build` folder
 	 
 ## Customizing the build
 
@@ -49,7 +49,7 @@ You can choose to use a different *CMake* generator than those specified above,
 
 ### <a name="dependencies"></a>Third party dependencies
 Banshee relies on a variety of third party dependencies. A set of pre-compiled dependencies are provided for every supported platform/compiler. These will be fetched automatically by the build process, but you may also download them manually or compile them from source:
- * [Download dependencies (VS2015)](http://data.banshee3d.com/BansheeDependencies_VS2015_Master.zip)
+ * [Download dependencies (VS2015/VS2017)](http://data.banshee3d.com/BansheeDependencies_VS2015_Master.zip)
  * [Compiling dependencies manually](dependencies.md)
  
 For older versions of pre-compiled dependencies check the git release tag descriptions for links.
@@ -66,10 +66,13 @@ The following dependencies will need to be installed manually. Which ones are re
   - **DirectX Debug Layer** (Required by default on Windows 10)
     - Optional if you have choosen a different RenderAPI in *CMake* options
     - Go to Settings panel (type "Settings" in Start)->System->Apps & features->Manage optional Features->Add a feature->Select "Graphics Tools"
+  - **Mono 4.2** (Optional)
+    - If you wish to compile managed assemblies using a Microsoft compiler (e.g. using Visual Studio) yet still be able to debug the generated assemblies, you must install Mono 4.2. and set up an environment variable MONO_INSTALL_DIR pointing to the Mono installation directory. When this is set up "pdb2mdb" script will trigger on next compile generating the needed debug symbols.
+    - http://www.mono-project.com/download/
  
 **Linux**
-  - **OpenGL** (Required by default)
-    - Optional if you have choosen a different RenderAPI in *CMake* options
+  - **OpenGL**
+    - Required by default, but optional if you have choosen a different RenderAPI in *CMake* options
     - Debian/Ubuntu: *apt-get install libgl1-mesa-dev libglu1-mesa-dev mesa-common-dev*
   - **X11**
     - Debian/Ubuntu: *apt-get install libx11-dev libxcursor-dev libxrandr-dev*
@@ -78,6 +81,9 @@ The following dependencies will need to be installed manually. Which ones are re
   - **GTK+ 3.0** (Editor only)
     - Optional if not building the editor
     - Debian/Ubuntu: *apt-get install libgtk-3-dev*
+  - **Mono** (Editor only)
+    - Required for compilation of C# code. Optional if not building the editor.
+    - Debian/Ubuntu: *apt-get install mono-complete*
   - (Or equivalent packages for your distribution)
 
 **All OS**
@@ -94,6 +100,3 @@ The following dependencies will need to be installed manually. Which ones are re
     - If CMake complains it cannot find FMOD, manually set the FMOD_INSTALL_DIRS to your installation directory 
     - Copy the dynamic libraries (.dll) from {INSTALLDIR}/api/lowlevel/lib into /bin folder in Banshee source code folder
       - Use logging libraries for the Debug builds, and non-logging for OptimizedDebug and Release builds
-  - **Mono 4.2** (Optional)
-    - If you wish to compile managed assemblies using a Microsoft compiler (e.g. using Visual Studio) yet still be able to debug the generated assemblies, you must install Mono 4.2. and set up an environment variable MONO_INSTALL_DIR pointing to the Mono installation directory. When this is set up "pdb2mdb" script will trigger on next compile generating the needed debug symbols.
-    - http://www.mono-project.com/download/

+ 3 - 1
Source/BansheeEditorExec/CMakeLists.txt

@@ -30,4 +30,6 @@ add_engine_dependencies(BansheeEditorExec)
 add_dependencies(BansheeEditorExec BansheeFBXImporter BansheeFontImporter BansheeFreeImgImporter SBansheeEditor)
 
 # Compiler flags
-target_compile_options(BansheeEditorExec PUBLIC /wd4509)
+if(MSVC)
+	target_compile_options(BansheeEditorExec PUBLIC /wd4509)
+endif()

+ 29 - 0
Source/CMake/Modules/Findmcs.cmake

@@ -0,0 +1,29 @@
+# Find Mono compiler (mcs) & build system installation
+#
+# This module defines
+#  mcs_EXECUTABLE
+#  xbuild_EXECUTABLE
+#  mcs_FOUND
+
+message(STATUS "Looking for Mono compiler (mcs) and xbuild installation...")
+find_program(mcs_EXECUTABLE NAMES mcs)
+find_program(xbuild_EXECUTABLE NAMES xbuild)
+
+if(mcs_EXECUTABLE AND xbuild_EXECUTABLE)
+	set(mcs_FOUND TRUE)
+else()
+	set(mcs_FOUND FALSE)
+endif()
+
+if(NOT mcs_FOUND)
+	if(mcs_FIND_REQUIRED)
+		message(FATAL_ERROR "Cannot find mcs and/or xbuild installation. Make sure Mono runtime and xbuild are installed.")
+		return()
+	else()
+		message(WARNING "Cannot find mcs and/or xbuild installation. Make sure Mono runtime and xbuild are installed.")
+	endif()
+else()
+	message(STATUS "...mcs and xbuild OK.")
+endif()
+
+mark_as_advanced(mcs_EXECUTABLE xbuild_EXECUTABLE)

+ 24 - 8
Source/CMakeLists.txt

@@ -320,10 +320,13 @@ add_subdirectory_optional(Experimental/PBS)
 add_subdirectory_optional(Experimental/Shadows)
 
 ## Managed projects
-if(MSVC)
-	if(BUILD_EDITOR)
-		include_external_msproject(MBansheeEngine ${PROJECT_SOURCE_DIR}/MBansheeEngine/MBansheeEngine.csproj)
-		include_external_msproject(MBansheeEditor ${PROJECT_SOURCE_DIR}/MBansheeEditor/MBansheeEditor.csproj)
+if(BUILD_EDITOR)
+	set(CS_ENGINE_PROJ ${PROJECT_SOURCE_DIR}/MBansheeEngine/MBansheeEngine.csproj)
+	set(CS_EDITOR_PROJ ${PROJECT_SOURCE_DIR}/MBansheeEditor/MBansheeEditor.csproj)
+
+	if(MSVC)
+		include_external_msproject(MBansheeEngine ${CS_ENGINE_PROJ})
+		include_external_msproject(MBansheeEditor ${CS_EDITOR_PROJ})
 		
 		set_target_properties(MBansheeEngine PROPERTIES
 		  MAP_IMPORTED_CONFIG_RELEASE OptimizedDebug
@@ -334,12 +337,25 @@ if(MSVC)
 		
 		set_property(TARGET MBansheeEngine PROPERTY FOLDER Script)
 		set_property(TARGET MBansheeEditor PROPERTY FOLDER Script)
-		
+
 		add_dependencies(BansheeEditorExec MBansheeEngine MBansheeEditor)
 		add_dependencies(Game MBansheeEngine)
-		
+
 		set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT BansheeEditorExec)
+	else()
+		find_package(mcs)
+
+		if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
+			set(CS_PROJ_CONFIG Debug)
+		else()
+			set(CS_PROJ_CONFIG Release)
+		endif()
+
+		add_custom_target(BuildManaged
+				COMMAND xbuild /p:Configuration=${CS_PROJ_CONFIG} ${CS_EDITOR_PROJ}
+				COMMENT "Building managed assemblies")
+
+		add_dependencies(BansheeEditorExec BuildManaged)
+		add_dependencies(Game BuildManaged)
 	endif()
-else()
-# TODO - Use Mono compiler to build the managed code as a pre-build step
 endif()

+ 27 - 4
Source/Game/CMakeLists.txt

@@ -25,9 +25,30 @@ if(WIN32)
 		set(BS_COPY_FOLDER Win32)
 	endif()
 
-	add_custom_command(TARGET Game POST_BUILD 
-		COMMAND xcopy /Y /I \"$(TargetDir)$(TargetName).exe\" \"$(SolutionDir)..\\..\\Data\\Binaries\\${BS_COPY_FOLDER}\\\"
-)
+	if(MSVC)
+		add_custom_command(
+			TARGET Game POST_BUILD
+			COMMAND xcopy /Y /I \"$(TargetDir)$(TargetName).exe\" \"$(SolutionDir)..\\..\\Data\\Binaries\\${BS_COPY_FOLDER}\\\")
+	else()
+		set(SRC_FILE ${BS_BINARY_OUTPUT_DIR}/Game)
+		set(DST_FOLDER ../${PROJECT_SOURCE_DIR}/Data/Binaries/${BS_COPY_FOLDER})
+		add_custom_command(TARGET Game POST_BUILD COMMAND xcopy /Y /I ${SRC_FILE} ${DST_FOLDER})
+	endif()
+
+elseif(LINUX)
+	if(BS_64BIT)
+		set(BS_COPY_FOLDER Linux64)
+	else()
+		set(BS_COPY_FOLDER Linux32)
+	endif()
+
+	set(SRC_FILE ${BS_BINARY_OUTPUT_DIR}/Game)
+	set(DST_FOLDER ../${PROJECT_SOURCE_DIR}/Data/Binaries/${BS_COPY_FOLDER})
+	add_custom_command(
+		TARGET Game POST_BUILD
+		COMMAND rm -rf ${DST_FOLDER}
+		COMMAND mkdir ${DST_FOLDER}
+		COMMAND cp ${SRC_FILE} ${DST_FOLDER})
 else()
 # TODO_OTHER_PLATFORMS_GO_HERE
 endif()
@@ -43,4 +64,6 @@ set_property(TARGET Game PROPERTY FOLDER Executable)
 add_engine_dependencies(Game)
 
 # Compiler flags
-target_compile_options(Game PUBLIC /wd4509)
+if(MSVC)
+	target_compile_options(Game PUBLIC /wd4509)
+endif()

+ 4 - 1
Source/MBansheeEditor/General/EditorApplication.cs

@@ -242,13 +242,16 @@ namespace BansheeEditor
         internal static VirtualButton DuplicateKey = new VirtualButton(DuplicateBinding);
         internal static VirtualButton DeleteKey = new VirtualButton(DeleteBinding);
 
-        private static EditorApplication instance;
         private static FolderMonitor monitor;
         private static ScriptCodeManager codeManager;
         private static bool sceneDirty;
         private static bool unitTestsExecuted;
         private static EditorPersistentData persistentData;
 
+        #pragma warning disable 0414
+        private static EditorApplication instance;
+        #pragma warning restore 0414
+
         /// <summary>
         /// Constructs a new editor application. Called at editor start-up by the runtime, and any time assembly refresh
         /// occurrs.

+ 2 - 2
Source/MBansheeEditor/MBansheeEditor.csproj

@@ -237,7 +237,7 @@
   <ItemGroup />
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <PropertyGroup>
-    <PostBuildEvent>"$(ProjectDir)..\..\Scripts\pdb2mdb.bat" "$(TargetPath)" "$(ConfigurationName)"</PostBuildEvent>
+    <PostBuildEvent Condition=" '$(OS)' != 'Unix' ">"$(ProjectDir)..\..\Scripts\pdb2mdb.bat" "$(TargetPath)" "$(ConfigurationName)"</PostBuildEvent>
   </PropertyGroup>
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
        Other similar extension points exist, see Microsoft.Common.targets.
@@ -246,4 +246,4 @@
   <Target Name="AfterBuild">
   </Target>
   -->
-</Project>
+</Project>

+ 2 - 0
Source/MBansheeEditor/Tests/UnitTestTypes.cs

@@ -5,6 +5,7 @@ using BansheeEngine;
 
 namespace BansheeEditor
 {
+    #pragma warning disable 0649
     /** @addtogroup Tests
      *  @{
      */
@@ -138,4 +139,5 @@ namespace BansheeEditor
     }
 
     /** @} */
+    #pragma warning restore 0649
 }

+ 2 - 2
Source/MBansheeEditor/Tests/UnitTests.cs

@@ -244,6 +244,8 @@ namespace BansheeEditor
                 return;
             }
 
+            // Disabled because it's a slow test, enable only when relevant (or when a build machine is set up)
+            /*
             Action PrintSceneState = () =>
             {
                 SceneObject root = Scene.Root;
@@ -269,8 +271,6 @@ namespace BansheeEditor
                 Debug.Log(output);
             };
 
-            // Disabled because it's a slow test, enable only when relevant (or when a build machine is set up)
-            /*
             string oldScene = Scene.ActiveSceneUUID;
             Scene.Clear();
 

+ 2 - 0
Source/MBansheeEditor/Window/DefaultSize.cs

@@ -14,8 +14,10 @@ namespace BansheeEditor
     [AttributeUsage(AttributeTargets.Class)]
     public sealed class DefaultSize : Attribute
     {
+        #pragma warning disable 0414
         private int width = 400;
         private int height = 400;
+        #pragma warning restore 0414
 
         public DefaultSize(int width, int height)
         {

+ 2 - 0
Source/MBansheeEditor/Window/MenuItem.cs

@@ -64,11 +64,13 @@ namespace BansheeEditor
             this.contextCallback = contextCallback;
         }
 
+        #pragma warning disable 0414
         private string path;
         private ShortcutKey shortcut;
         private int priority;
         private bool separator;
         private string contextCallback;
+        #pragma warning restore 0414
     }
 
     /** @} */

+ 2 - 0
Source/MBansheeEditor/Window/ToolbarItem.cs

@@ -57,12 +57,14 @@ namespace BansheeEditor
             this.builtinIcon = (int)icon;
         }
 
+        #pragma warning disable 0414
         private string name;
         private string icon;
         private int builtinIcon;
         private string tooltip;
         private int priority;
         private bool separator;
+        #pragma warning restore 0414
     }
 
     /** @} */

+ 0 - 1
Source/MBansheeEditor/Windows/AboutBox.cs

@@ -155,7 +155,6 @@ namespace BansheeEditor
         {
             GUILabel label = new GUILabel(new LocEdString(name), GUIOption.FixedWidth(150));
             GUIButton linkBtn = new GUIButton(new LocEdString("Website"), GUIOption.FixedWidth(50));
-            GUIButton licenseBtn = new GUIButton(new LocEdString("License"), GUIOption.FixedWidth(50));
 
             GUILayoutX horzLayout = layout.AddLayoutX();
             horzLayout.AddSpace(10);

+ 0 - 2
Source/MBansheeEditor/Windows/Animation/GUIGraphValues.cs

@@ -133,8 +133,6 @@ namespace BansheeEditor
                
                 if (ticks.Length > 0)
                 {
-                    float valuePerTick = (rangeEnd - rangeStart)/ticks.Length;
-
                     for (int j = 0; j < ticks.Length; j++)
                     {
                         int yPos = (int) ((ticks[j] - yOffset) * pixelsPerHeight);

+ 2 - 0
Source/MBansheeEditor/Windows/Inspector/CustomInspector.cs

@@ -19,7 +19,9 @@ namespace BansheeEditor
     [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)]
     public sealed class CustomInspector : Attribute
     {
+        #pragma warning disable 0414
         private Type type;
+        #pragma warning restore 0414
 
         /// <summary>
         /// Creates a new custom inspector attribute.

+ 1 - 2
Source/MBansheeEditor/Windows/Library/LibraryGUIEntry.cs

@@ -49,7 +49,7 @@ namespace BansheeEditor
         private UnderlayState underlayState;
         private GUITextBox renameTextBox;
 
-        private int width, height;
+        private int width;
         private LibraryGUIEntryType type;
         private bool delayedSelect;
         private float delayedSelectTime;
@@ -146,7 +146,6 @@ namespace BansheeEditor
             this.underlay = null;
             this.type = type;
             this.width = width;
-            this.height = height;
         }
 
         /// <summary>

+ 2 - 0
Source/MBansheeEditor/Windows/Scene/Gizmos/DrawGizmo.cs

@@ -34,7 +34,9 @@ namespace BansheeEditor
     [AttributeUsage(AttributeTargets.Method)]
     public sealed class DrawGizmo : Attribute
     {
+        #pragma warning disable 0414
         private DrawGizmoFlags flags;
+        #pragma warning restore 0414
 
         /// <summary>
         /// Creates a new draw gizmos attribute.

+ 2 - 0
Source/MBansheeEditor/Windows/Scene/Handles/CustomHandle.cs

@@ -20,7 +20,9 @@ namespace BansheeEditor
     [AttributeUsage(AttributeTargets.Class)]
     public sealed class CustomHandle : Attribute
     {
+        #pragma warning disable 0414
         private Type type;
+        #pragma warning restore 0414
 
         /// <summary>
         /// Creates a new custom handle attribute.

+ 1 - 0
Source/MBansheeEditor/Windows/Scene/SceneCamera.cs

@@ -509,6 +509,7 @@ namespace BansheeEditor
             ///                 start and target states.</param>
             public void Update(float t)
             {
+                interpolated = new CameraState();
                 interpolated.Position = start.Position * (1.0f - t) + target.Position * t;
                 interpolated.Rotation = Quaternion.Slerp(start.Rotation, target.Rotation, t);
                 interpolated.OrtographicPct = start.OrtographicPct * (1.0f - t) + target.OrtographicPct * t;

+ 3 - 3
Source/MBansheeEngine/MBansheeEngine.csproj

@@ -9,7 +9,7 @@
     <AppDesignerFolder>Properties</AppDesignerFolder>
     <RootNamespace>BansheeEngine</RootNamespace>
     <AssemblyName>MBansheeEngine</AssemblyName>
-    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
     <FileAlignment>512</FileAlignment>
     <TargetFrameworkProfile />
     <ProductVersion>10.0.0</ProductVersion>
@@ -155,7 +155,7 @@
   <ItemGroup />
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <PropertyGroup>
-    <PostBuildEvent>"$(ProjectDir)..\..\Scripts\pdb2mdb.bat" "$(TargetPath)" "$(ConfigurationName)"</PostBuildEvent>
+    <PostBuildEvent Condition=" '$(OS)' != 'Unix' ">"$(ProjectDir)..\..\Scripts\pdb2mdb.bat" "$(TargetPath)" "$(ConfigurationName)"</PostBuildEvent>
   </PropertyGroup>
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
        Other similar extension points exist, see Microsoft.Common.targets.
@@ -164,4 +164,4 @@
   <Target Name="AfterBuild">
   </Target>
   -->
-</Project>
+</Project>

+ 2 - 0
Source/MBansheeEngine/Serialization/Range.cs

@@ -27,9 +27,11 @@ namespace BansheeEngine
             this.slider = slider;
         }
 
+        #pragma warning disable 0414
         private float min;
         private float max;
         private bool slider;
+        #pragma warning restore 0414
     }
 
     /** @} */

+ 2 - 0
Source/MBansheeEngine/Serialization/Step.cs

@@ -23,6 +23,8 @@ namespace BansheeEngine
             this.step = step;
         }
 
+        #pragma warning disable 0414
         private float step;
+        #pragma warning restore 0414
     }
 }