Skip to content

Commit

Permalink
🐝 Mono Optional Linking
Browse files Browse the repository at this point in the history
  • Loading branch information
wobbier committed Jun 25, 2023
1 parent 49dcd08 commit 3ba8d53
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 22 deletions.
42 changes: 23 additions & 19 deletions Engine.sharpmake.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public override void ConfigureAll(Project.Configuration conf, CommonTarget targe

// #TODO This shouldn't be a sharpmake class
//conf.AddPublicDependency<Mono>(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<ScriptCore>(target);
conf.AddPublicDependency<UserGameScript>(target);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -377,7 +377,8 @@ public virtual void ConfigureAll(Solution.Configuration conf, CommonTarget targe
}

conf.AddProject<SharpGameProject>(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<UserGameScript>(target);
conf.AddProject<ScriptCore>(target);
Expand All @@ -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/";
}


Expand Down
6 changes: 3 additions & 3 deletions Tools/BaseProject.sharpmake.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand All @@ -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");
}
Expand All @@ -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");
}
Expand Down

0 comments on commit 3ba8d53

Please sign in to comment.