Sfoglia il codice sorgente

Build systems appears functional

BearishSun 10 anni fa
parent
commit
625b2afd34

+ 2 - 0
BansheeCore/Include/BsCoreThread.h

@@ -136,6 +136,8 @@ private:
 	BS_THREAD_SYNCHRONISER(mCommandReadyCondition)
 	BS_MUTEX(mCommandNotifyMutex)
 	BS_THREAD_SYNCHRONISER(mCommandCompleteCondition)
+	BS_MUTEX(mThreadStartedMutex)
+	BS_THREAD_SYNCHRONISER(mCoreThreadStartedCondition)
 
 	CommandQueue<CommandQueueSync>* mCommandQueue;
 

+ 2 - 1
BansheeCore/Include/BsVideoModeInfo.h

@@ -120,7 +120,8 @@ namespace BansheeEngine
 		UINT32 getNumOutputs() const { return (UINT32)mOutputs.size(); }
 
 		/**
-		 * @brief	Returns video mode information about a specific output device.
+		 * @brief	Returns video mode information about a specific output device. 0th index always 
+		 * 			represents the primary device while order of others is undefined.
 		 */
 		const VideoOutputInfo& getOutputInfo(UINT32 idx) const { return *mOutputs[idx]; }
 

+ 5 - 0
BansheeCore/Source/BsCoreThread.cpp

@@ -65,6 +65,10 @@ namespace BansheeEngine
 #if !BS_FORCE_SINGLETHREADED_RENDERING
 #if BS_THREAD_SUPPORT
 		mCoreThread = ThreadPool::instance().run("Core", std::bind(&CoreThread::runCoreThread, this));
+		
+		// Need to wait to unsure thread ID is correctly set before continuing
+		BS_LOCK_MUTEX_NAMED(mThreadStartedMutex, lock)
+		BS_THREAD_WAIT(mCoreThreadStartedCondition, mThreadStartedMutex, lock)
 #else
 		BS_EXCEPT(InternalErrorException, "Attempting to start a core thread but application isn't compiled with thread support.");
 #endif
@@ -78,6 +82,7 @@ namespace BansheeEngine
 
 		mCoreThreadId = BS_THREAD_CURRENT_ID;
 		mSyncedCoreAccessor = bs_new<CoreThreadAccessor<CommandQueueSync>>(BS_THREAD_CURRENT_ID);
+		BS_THREAD_NOTIFY_ONE(mCoreThreadStartedCondition);
 
 		while(true)
 		{

+ 3 - 0
BansheeCore/Source/BsResources.cpp

@@ -359,6 +359,9 @@ namespace BansheeEngine
 
 	void Resources::save(HResource resource, const Path& filePath, bool overwrite)
 	{
+		if (resource == nullptr)
+			return;
+
 		if(!resource.isLoaded())
 			resource.blockUntilLoaded();
 

+ 2 - 2
BansheeEditor/Source/BsBuildManager.cpp

@@ -67,7 +67,7 @@ namespace BansheeEngine
 		{
 		case PlatformType::Windows:
 		default:
-			return { L"System", L"System.Core" };
+			return { L"mscorlib", L"System", L"System.Core" };
 		}
 	}
 
@@ -82,7 +82,7 @@ namespace BansheeEngine
 		case PlatformType::Windows:
 		{
 			for (auto& lib : libs)
-				lib.setExtension(".dll");
+				lib.setExtension(lib.getExtension() + ".dll");
 		}
 		}
 

+ 9 - 6
BansheeEngine/Source/BsBuiltinResources.cpp

@@ -218,15 +218,18 @@ namespace BansheeEngine
 		gResources().registerResourceManifest(mResourceManifest);
 
 #if BS_DEBUG_MODE
-		if (BuiltinResourcesHelper::checkForModifications(BuiltinRawDataFolder, BuiltinDataFolder + L"Timestamp.asset"))
+		if (FileSystem::exists(BuiltinRawDataFolder))
 		{
-			preprocess();
-			BuiltinResourcesHelper::writeTimestamp(BuiltinDataFolder + L"Timestamp.asset");
+			if (BuiltinResourcesHelper::checkForModifications(BuiltinRawDataFolder, BuiltinDataFolder + L"Timestamp.asset"))
+			{
+				preprocess();
+				BuiltinResourcesHelper::writeTimestamp(BuiltinDataFolder + L"Timestamp.asset");
 
-			Path absoluteDataPath = FileSystem::getWorkingDirectoryPath();
-			absoluteDataPath.append(BuiltinDataFolder);
+				Path absoluteDataPath = FileSystem::getWorkingDirectoryPath();
+				absoluteDataPath.append(BuiltinDataFolder);
 
-			ResourceManifest::save(mResourceManifest, ResourceManifestPath, absoluteDataPath);
+				ResourceManifest::save(mResourceManifest, ResourceManifestPath, absoluteDataPath);
+			}
 		}
 #endif
 		

+ 3 - 3
BansheeUtility/Source/Win32/BsWin32FileSystem.cpp

@@ -560,10 +560,10 @@ namespace BansheeEngine
 		{
 			if (lastFailed || fileHandle == INVALID_HANDLE_VALUE)
 			{
-				if (GetLastError() == ERROR_NO_MORE_FILES)
-					break;
-				else
+				if (GetLastError() != ERROR_NO_MORE_FILES)
 					win32_handleError(GetLastError(), findPath);
+
+				break;
 			}
 			else
 			{

+ 6 - 2
Game/Source/Main.cpp

@@ -64,7 +64,7 @@ void runApplication()
 	renderWindowDesc.videoMode = VideoMode(resolutionWidth, resolutionHeight);
 	renderWindowDesc.title = toString(gameSettings->titleBarText);
 	renderWindowDesc.fullscreen = false;
-	renderWindowDesc.hideUntilSwap = true;
+	renderWindowDesc.hidden = gameSettings->fullscreen;
 
 	Application::startUp(renderWindowDesc, RenderAPIPlugin::DX11);
 
@@ -84,9 +84,13 @@ void runApplication()
 		}
 		else
 		{
+			resolutionWidth = gameSettings->resolutionWidth;
+			resolutionHeight = gameSettings->resolutionHeight;
+
 			VideoMode videoMode(resolutionWidth, resolutionHeight);
 
 			RenderWindowPtr window = gApplication().getPrimaryWindow();
+			window->show(gCoreAccessor());
 			window->setFullscreen(gCoreAccessor(), videoMode);
 		}
 	}
@@ -106,7 +110,7 @@ void runApplication()
 	if (FileSystem::exists(resourceManifestPath))
 	{
 		Path resourcesPath = FileSystem::getWorkingDirectoryPath();
-		resourcesPath.append(GAME_RESOURCES_PATH);
+		resourcesPath.append(APP_ROOT);
 
 		manifest = ResourceManifest::load(resourceManifestPath, resourcesPath);
 

+ 11 - 1
MBansheeEditor/BuildManager.cs

@@ -264,6 +264,14 @@ namespace BansheeEditor
             get { return Internal_GetActivePlatformInfo(); }
         }
 
+        /// <summary>
+        /// Returns absolute path to the folder where builds for the currently active platform are output.
+        /// </summary>
+        public static string OutputFolder
+        {
+            get { return GetBuildFolder(BuildFolder.DestinationRoot, ActivePlatform); }
+        }
+
         /// <summary>
         /// Returns a path to a specific folder used in the build process. See entries of BuildFolder enum for explanations 
         /// of individual folder types.
@@ -299,7 +307,9 @@ namespace BansheeEditor
             string destRoot = GetBuildFolder(BuildFolder.DestinationRoot, activePlatform);
 
             // Prepare clean destination folder
-            Directory.Delete(destRoot, true);
+            if(Directory.Exists(destRoot))
+                Directory.Delete(destRoot, true);
+
             Directory.CreateDirectory(destRoot);
 
             // Compile game assembly

+ 57 - 11
MBansheeEditor/BuildWindow.cs

@@ -7,17 +7,21 @@ namespace BansheeEditor
     /// Provides options for customizing and activating the build process which will output an executable of the game for a 
     /// specific platform, as well as any required resources.
     /// </summary>
-    [DefaultSize(300, 200)]
+    [DefaultSize(500, 200)]
     internal sealed class BuildWindow : EditorWindow
     {
+        private static readonly Color PLATFORM_BG_COLOR = new Color(33.0f / 255.0f, 33.0f / 255.0f, 33.0f / 255.0f);
+
         private PlatformType selectedPlatform;
         private GUIScrollArea optionsScrollArea;
         private bool buildScheduled;
 
+        private GUIToggle[] platformButtons;
+
         /// <summary>
         /// Opens the build window if its not open already.
         /// </summary>
-        [MenuItem("Tools/Build", 9296)]
+        [MenuItem("Tools/Build", ButtonModifier.CtrlAlt, ButtonCode.B, 9296)]
         private static void OpenBuildWindow()
         {
             OpenWindow<BuildWindow>();
@@ -32,22 +36,41 @@ namespace BansheeEditor
         private void OnInitialize()
         {
             GUILayoutX splitLayout = GUI.AddLayoutX();
-            GUILayoutY platformLayout = splitLayout.AddLayoutY();
+            GUIPanel platformPanel = splitLayout.AddPanel();
+            GUIPanel platformForeground = platformPanel.AddPanel();
+            GUILayoutY platformLayout = platformForeground.AddLayoutY();
+            GUIPanel platformBackground = platformPanel.AddPanel(1);
+            GUITexture background = new GUITexture(Builtin.WhiteTexture);
+            background.SetTint(PLATFORM_BG_COLOR);
+
+            splitLayout.AddSpace(5);
             GUILayoutY optionsLayout = splitLayout.AddLayoutY();
 
+            GUILabel platformsLabel = new GUILabel(new LocEdString("Platforms"), EditorStyles.LabelCentered);
+            platformLayout.AddSpace(5);
+            platformLayout.AddElement(platformsLabel);
+            platformLayout.AddSpace(5);
+
             GUIToggleGroup platformToggleGroup = new GUIToggleGroup();
 
             PlatformType[] availablePlatforms = BuildManager.AvailablePlatforms;
+            platformButtons = new GUIToggle[availablePlatforms.Length];
             for (int i = 0; i < availablePlatforms.Length; i++)
             {
                 PlatformType currentPlatform = availablePlatforms[i];
+                bool isActive = currentPlatform == BuildManager.ActivePlatform;
+
                 string platformName = Enum.GetName(typeof(PlatformType), currentPlatform);
+                if (isActive)
+                    platformName += " (Active)";
 
                 GUIToggle platformToggle = new GUIToggle(new LocEdString(platformName), platformToggleGroup, EditorStyles.Button);
                 platformToggle.OnToggled += x => OnSelectedPlatformChanged(currentPlatform, x);
                 platformLayout.AddElement(platformToggle);
 
-                if (currentPlatform == BuildManager.ActivePlatform)
+                platformButtons[i] = platformToggle;
+
+                if (isActive)
                 {
                     platformToggle.Value = true;
                     selectedPlatform = currentPlatform;
@@ -60,9 +83,17 @@ namespace BansheeEditor
             platformLayout.AddElement(changePlatformBtn);
             changePlatformBtn.OnClick += ChangeActivePlatform;
 
+            platformBackground.AddElement(background);
+
             optionsScrollArea = new GUIScrollArea();
             optionsLayout.AddElement(optionsScrollArea);
 
+            GUIButton buildButton = new GUIButton(new LocEdString("Build"));
+            optionsLayout.AddFlexibleSpace();
+            optionsLayout.AddElement(buildButton);
+
+            buildButton.OnClick += TryStartBuild;
+
             BuildPlatformOptionsGUI();
         }
 
@@ -72,6 +103,9 @@ namespace BansheeEditor
             {
                 BuildManager.Build();
                 ProgressBar.Hide();
+
+                EditorApplication.OpenExternally(BuildManager.OutputFolder);
+                DialogBox.Open(new LocEdString("Build complete"), new LocEdString("Build complete"), DialogBox.Type.OK);
                 buildScheduled = false;
             }
         }
@@ -97,6 +131,19 @@ namespace BansheeEditor
         private void ChangeActivePlatform()
         {
             BuildManager.ActivePlatform = selectedPlatform;
+
+            PlatformType[] availablePlatforms = BuildManager.AvailablePlatforms;
+            for (int i = 0; i < availablePlatforms.Length; i++)
+            {
+                PlatformType currentPlatform = availablePlatforms[i];
+                bool isActive = currentPlatform == BuildManager.ActivePlatform;
+
+                string platformName = Enum.GetName(typeof (PlatformType), currentPlatform);
+                if (isActive)
+                    platformName += " (Active)";
+
+                platformButtons[i].SetContent(new LocEdString(platformName));
+            }
         }
 
         /// <summary>
@@ -109,16 +156,19 @@ namespace BansheeEditor
 
             PlatformInfo platformInfo = BuildManager.GetPlatformInfo(selectedPlatform);
 
+            GUILabel options = new GUILabel(new LocEdString("Platform options"), EditorStyles.LabelCentered);
+
             GUIResourceField sceneField = new GUIResourceField(typeof(Prefab), new LocEdString("Startup scene"));
             GUIToggleField debugToggle = new GUIToggleField(new LocEdString("Debug"));
             
-
             GUIToggleField fullscreenField = new GUIToggleField(new LocEdString("Fullscreen"));
             GUIIntField widthField = new GUIIntField(new LocEdString("Window width"));
             GUIIntField heightField = new GUIIntField(new LocEdString("Window height"));
 
             GUITextField definesField = new GUITextField(new LocEdString("Defines"));
 
+            layout.AddSpace(5);
+            layout.AddElement(options);
             layout.AddSpace(5);
             layout.AddElement(sceneField);
             layout.AddElement(debugToggle);
@@ -165,6 +215,8 @@ namespace BansheeEditor
                     GUIToggle iconsFoldout = new GUIToggle(new LocEdString("Icons"), EditorStyles.Foldout);
 
                     layout.AddElement(titleField);
+                    layout.AddSpace(5);
+
                     layout.AddElement(iconsFoldout);
                     GUILayoutY iconsLayout = layout.AddLayoutY();
 
@@ -195,12 +247,6 @@ namespace BansheeEditor
                     break;
             }
 
-            GUIButton buildButton = new GUIButton(new LocEdString("Build"));
-            layout.AddFlexibleSpace();
-            layout.AddElement(buildButton);
-
-            buildButton.OnClick += TryStartBuild;
-
             // TODO - Different background for platform selection bit
         }
 

+ 10 - 2
SBansheeEditor/Source/BsScriptBuildManager.cpp

@@ -193,6 +193,9 @@ namespace BansheeEngine
 
 			for (auto& entry : textures)
 			{
+				if (!entry.texture.isLoaded())
+					continue;
+
 				auto& texProps = entry.texture->getProperties();
 
 				entry.pixels = texProps.allocateSubresourceBuffer(0);
@@ -264,7 +267,7 @@ namespace BansheeEngine
 						if (usedResources.find(resourcePath) == usedResources.end())
 						{
 							allDependencies.push_back(resourcePath);
-							newResources.push_back(resourcePath);
+							usedResources.insert(resourcePath);
 						}
 					}
 				}
@@ -285,6 +288,9 @@ namespace BansheeEngine
 			BS_ASSERT(gResources().getUUIDFromFilePath(entry, uuid));
 
 			Path sourcePath = gProjectLibrary().uuidToPath(uuid);
+			if (sourcePath.isEmpty()) // Resource not part of library, meaning its built-in and we don't need to copy those here
+				continue;
+
 			ProjectLibrary::LibraryEntry* libEntry = gProjectLibrary().findEntry(sourcePath);
 			assert(libEntry != nullptr && libEntry->type == ProjectLibrary::LibraryEntryType::File);
 
@@ -351,7 +357,8 @@ namespace BansheeEngine
 		{
 			SPtr<WinPlatformInfo> winPlatformInfo = std::static_pointer_cast<WinPlatformInfo>(platformInfo);
 
-			gResources().save(winPlatformInfo->taskbarIcon, destIconFile, false);
+			if (winPlatformInfo->taskbarIcon != nullptr)
+				gResources().save(winPlatformInfo->taskbarIcon, destIconFile, false);
 		}
 		};
 
@@ -376,6 +383,7 @@ namespace BansheeEngine
 		SPtr<GameSettings> gameSettings;
 		if (platformInfo != nullptr)
 		{
+			gameSettings = bs_shared_ptr_new<GameSettings>();
 			gameSettings->mainSceneUUID = platformInfo->mainScene.getUUID();
 			gameSettings->fullscreen = platformInfo->fullscreen;
 			gameSettings->resolutionWidth = platformInfo->windowedWidth;

+ 1 - 1
SBansheeEditor/Source/BsScriptPlatformInfo.cpp

@@ -144,7 +144,7 @@ namespace BansheeEngine
 	MonoObject* ScriptWinPlatformInfo::create(const SPtr<WinPlatformInfo>& platformInfo)
 	{
 		MonoObject* managedInstance = metaData.scriptClass->createInstance();
-		ScriptWinPlatformInfo* scriptObj = ScriptWinPlatformInfo::toNative(managedInstance);
+		ScriptWinPlatformInfo* scriptObj = new (bs_alloc<ScriptWinPlatformInfo>()) ScriptWinPlatformInfo(managedInstance);
 		scriptObj->mPlatformInfo = platformInfo;
 
 		return managedInstance;

+ 0 - 26
TODO.txt

@@ -71,32 +71,6 @@ Inspector persistance
 	- Will need to extend inspectable fields so they know their parent inspector so they have access to the dictionar
    - Custom inspectors can get rid of manual "isExpanded" bools and use the dictionary instead
 
-----------------------------------------------------------------------
-Build system
- - Test Resources (if loading works and if they're properly packaged in build)
- - Game/Editor assemblies in editor are compiled with debug information, add a toggle for this in build settings and recompile without it if needed
-  - Will also need to compile a different version of the built-in BansheeEngine assembly
- - The final build procedure for the game should be:
-   - Copy all the prebuilt binaries (Banshee libraries, Banshee assemblies, 3rd party libraries and prebuilt executable) from Editor install folder to output folder
-    - Which set of binaries is used depends on selected platform (e.g. win/mac/linux or 32/64bit)
-   - Recompile script assemblies if needed and copy them from project Internal folder to output folder
-   - Copy the Builtin resources for engine from Editor install folder to output folder
-   - Copy all the resources marked with the flag mentioned above to \Data subfolder in the output folder, preserving the same asset structure
-     - Also all dependencies of those resources (add C# method FindDependantResources?)
-   - Make sure to go over texture resources and ensure they are saved in the valid format
-     as we don't want to do format conversion at runtime (Not cruical, but it should be done eventually - Add a TODO in code for now)
-     - This should something similar to Unity where when changing the platform all resources get reimported
-   - Make sure to clear all prefab diffs (possibly store them elsewhere in the first place)
-	 - And all prefab instances should have updateFromPrefab called on them.
-  - Need to create an executable that creates a fullscreen window, loads main scene and renders the main camera to it
-   - Might need a way to load fullscreen & resolution state on start-up (so it can be modified internally and loaded immediately next time)
-    - Add GameSettings.asset that is generated on build
-	 - Has "firstStart" turned off
-	 - Contains wanted video mode and initial scene to load
-	 - This file is loaded by the application initially
-	 - Similar to project/editor settings this can contain user data as needed
-  - Game.exe shouldn't need to include importer .dlls
-
 /*********************************************************************/
 /************************ LESS IMPORTANT *****************************/
 /*********************************************************************/