From 3ba8d533b8329649c79e143ce2a4217821ac9e69 Mon Sep 17 00:00:00 2001 From: Mitch Andrews Date: Sun, 25 Jun 2023 01:54:48 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9D=20Mono=20Optional=20Linking?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Engine.sharpmake.cs | 42 +++++++++++++++++++--------------- Tools/BaseProject.sharpmake.cs | 6 ++--- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/Engine.sharpmake.cs b/Engine.sharpmake.cs index 270412f7..624f6243 100644 --- a/Engine.sharpmake.cs +++ b/Engine.sharpmake.cs @@ -141,7 +141,7 @@ public override void ConfigureAll(Project.Configuration conf, CommonTarget targe // #TODO This shouldn't be a sharpmake class //conf.AddPublicDependency(target, DependencySetting.Default | DependencySetting.Defines | DependencySetting.IncludePaths); - if (target.Platform != Platform.mac) + if (target.Platform != Platform.mac && (Directory.Exists(Globals.MONO_macOS_Dir) || Directory.Exists(Globals.MONO_Win64_Dir))) { conf.AddPublicDependency(target); conf.AddPublicDependency(target); @@ -217,18 +217,18 @@ public override void ConfigureWin64(Configuration conf, CommonTarget target) } // #TODO Read path from Globals / Move to own class again - if( Directory.Exists("C:/Program Files/Mono/include/mono-2.0") ) + if( Directory.Exists(Globals.MONO_Win64_Dir) ) { - conf.IncludePaths.Add("C:/Program Files/Mono/include/mono-2.0"); - conf.LibraryPaths.Add("C:/Program Files/Mono/lib"); + conf.IncludePaths.Add(Path.Combine(Globals.MONO_Win64_Dir, "include/mono-2.0")); + conf.LibraryPaths.Add(Path.Combine(Globals.MONO_Win64_Dir, "lib")); conf.LibraryFiles.Add("mono-2.0-sgen"); - conf.Defines.Add("MONO_HOME=\"C:/Program Files/Mono/\""); - conf.Defines.Add("MONO_PATH=\"C:/Program Files/Mono/lib/mono/4.5\""); + conf.Defines.Add($"MONO_HOME=\"{Globals.MONO_Win64_Dir}\""); + conf.Defines.Add($"MONO_PATH=\"{Globals.MONO_Win64_Dir}lib/mono/4.5\""); // MONO DLL { var copyDirBuildStep = new Configuration.BuildStepCopy( - "C:/Program Files/Mono/lib", + Path.Combine(Globals.MONO_Win64_Dir, "lib"), Globals.RootDir + "/.build/[target.Name]"); // TODO: Copy mono-2.0sgen dll copyDirBuildStep.IsFileCopy = false; @@ -267,18 +267,18 @@ public override void ConfigureUWP(Configuration conf, CommonTarget target) } // #TODO Read path from Globals / Move to own class again - if (Directory.Exists("C:/Program Files/Mono/include/mono-2.0")) + if (Directory.Exists(Globals.MONO_Win64_Dir)) { - conf.IncludePaths.Add("C:/Program Files/Mono/include/mono-2.0"); - conf.LibraryPaths.Add("C:/Program Files/Mono/lib"); + conf.IncludePaths.Add(Path.Combine(Globals.MONO_Win64_Dir, "include/mono-2.0")); + conf.LibraryPaths.Add(Path.Combine(Globals.MONO_Win64_Dir, "lib")); conf.LibraryFiles.Add("mono-2.0-sgen"); - conf.Defines.Add("MONO_HOME=\"C:/Program Files/Mono/\""); - conf.Defines.Add("MONO_PATH=\"C:/Program Files/Mono/lib/mono/4.5\""); + conf.Defines.Add($"MONO_HOME=\"{Globals.MONO_Win64_Dir}\""); + conf.Defines.Add($"MONO_PATH=\"{Globals.MONO_Win64_Dir}lib/mono/4.5\""); // MONO DLL { var copyDirBuildStep = new Configuration.BuildStepCopy( - "C:/Program Files/Mono/lib", + Path.Combine(Globals.MONO_Win64_Dir, "lib"), Globals.RootDir + "/.build/[target.Name]"); // TODO: Copy mono-2.0sgen dll copyDirBuildStep.IsFileCopy = false; @@ -308,13 +308,13 @@ public override void ConfigureMac(Configuration conf, CommonTarget target) conf.Options.Add(new Options.XCode.Compiler.UserFrameworks("Mono")); // #TODO Read path from Globals / Move to own class again - if (Directory.Exists("/Library/Frameworks/Mono.framework/Headers/mono-2.0/")) + if (Directory.Exists(Globals.MONO_macOS_Dir)) { - conf.IncludePaths.Add("/Library/Frameworks/Mono.framework/Headers/mono-2.0/"); - conf.LibraryPaths.Add("/Library/Frameworks/Mono.framework/Libraries/"); + conf.IncludePaths.Add($"{Globals.MONO_macOS_Dir}Headers/mono-2.0/"); + conf.LibraryPaths.Add($"{Globals.MONO_macOS_Dir}Libraries/"); conf.LibraryFiles.Add("monosgen-2.0"); - conf.Defines.Add("MONO_HOME=\"/Library/Frameworks/Mono.framework/Home\""); - conf.Defines.Add("MONO_PATH=\"/Library/Frameworks/Mono.framework/Home/lib/mono/4.5\""); + conf.Defines.Add($"MONO_HOME=\"{Globals.MONO_macOS_Dir}Home\""); + conf.Defines.Add($"MONO_PATH=\"{Globals.MONO_macOS_Dir}Home/lib/mono/4.5\""); // MONO DLL { @@ -377,7 +377,8 @@ public virtual void ConfigureAll(Solution.Configuration conf, CommonTarget targe } conf.AddProject(target); - if (target.Platform != Platform.mac) + // Disabled on mac atm since xcode doesn't have mono support that I know of + if (target.Platform != Platform.mac && (Directory.Exists(Globals.MONO_macOS_Dir) || Directory.Exists(Globals.MONO_Win64_Dir))) { conf.AddProject(target); conf.AddProject(target); @@ -390,6 +391,9 @@ public class Globals public static string RootDir = string.Empty; public static string FMOD_Win64_Dir = string.Empty; public static string FMOD_UWP_Dir = string.Empty; + + public static string MONO_Win64_Dir = "C:/Program Files/Mono/"; + public static string MONO_macOS_Dir = "/Library/Frameworks/Mono.framework/"; } diff --git a/Tools/BaseProject.sharpmake.cs b/Tools/BaseProject.sharpmake.cs index bf057430..3cc81865 100644 --- a/Tools/BaseProject.sharpmake.cs +++ b/Tools/BaseProject.sharpmake.cs @@ -88,7 +88,7 @@ public virtual void ConfigureWin64(Configuration conf, CommonTarget target) ) ); - if (Directory.Exists("C:/Program Files/Mono/include/mono-2.0")) + if (Directory.Exists(Globals.MONO_Win64_Dir)) { conf.Defines.Add("DEFINE_ME_MONO"); } @@ -113,7 +113,7 @@ public virtual void ConfigureUWP(Configuration conf, CommonTarget target) ) ); - if (Directory.Exists("C:/Program Files/Mono/include/mono-2.0")) + if (Directory.Exists(Globals.MONO_Win64_Dir)) { conf.Defines.Add("DEFINE_ME_MONO"); } @@ -139,7 +139,7 @@ public virtual void ConfigureMac(Configuration conf, CommonTarget target) conf.Defines.Add("DEFINE_ME_PLATFORM_MACOS"); - if (Directory.Exists("/Library/Frameworks/Mono.framework/Headers/mono-2.0/")) + if (Directory.Exists(Globals.MONO_macOS_Dir)) { conf.Defines.Add("DEFINE_ME_MONO"); }