Mac impl progress

This commit is contained in:
Wojtek Figat
2022-01-03 13:59:52 +01:00
parent 9b991bcfdf
commit ca62cd2661
16 changed files with 294 additions and 20 deletions

View File

@@ -29,6 +29,11 @@ namespace Flax.Deps.Dependencies
{
TargetPlatform.Linux,
};
case TargetPlatform.Mac:
return new[]
{
TargetPlatform.Mac,
};
default: return new TargetPlatform[0];
}
}
@@ -100,9 +105,9 @@ namespace Flax.Deps.Dependencies
// Build for Win64
File.Delete(Path.Combine(root, "CMakeCache.txt"));
RunCmake(root, TargetPlatform.Windows, TargetArchitecture.x64);
RunCmake(root, platform, TargetArchitecture.x64);
Deploy.VCEnvironment.BuildSolution(solutionPath, configuration, "x64");
var depsFolder = GetThirdPartyFolder(options, TargetPlatform.Windows, TargetArchitecture.x64);
var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64);
foreach (var file in binariesWin)
{
Utilities.FileCopy(file, Path.Combine(depsFolder, Path.GetFileName(file)));
@@ -113,9 +118,19 @@ namespace Flax.Deps.Dependencies
case TargetPlatform.Linux:
{
// Build for Linux
RunCmake(root, TargetPlatform.Linux, TargetArchitecture.x64, " -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF " + globalConfig);
RunCmake(root, platform, TargetArchitecture.x64, " -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF " + globalConfig);
Utilities.Run("make", null, null, root, Utilities.RunOptions.None);
var depsFolder = GetThirdPartyFolder(options, TargetPlatform.Linux, TargetArchitecture.x64);
var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64);
Utilities.FileCopy(Path.Combine(root, "lib", "libassimp.a"), Path.Combine(depsFolder, "libassimp.a"));
Utilities.FileCopy(Path.Combine(root, "lib", "libIrrXML.a"), Path.Combine(depsFolder, "libIrrXML.a"));
break;
}
case TargetPlatform.Mac:
{
// Build for Mac
RunCmake(root, platform, TargetArchitecture.x64, " -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF " + globalConfig);
Utilities.Run("make", null, null, root, Utilities.RunOptions.None);
var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64);
Utilities.FileCopy(Path.Combine(root, "lib", "libassimp.a"), Path.Combine(depsFolder, "libassimp.a"));
Utilities.FileCopy(Path.Combine(root, "lib", "libIrrXML.a"), Path.Combine(depsFolder, "libIrrXML.a"));
break;

View File

@@ -31,6 +31,11 @@ namespace Flax.Deps.Dependencies
{
TargetPlatform.Linux,
};
case TargetPlatform.Mac:
return new[]
{
TargetPlatform.Mac,
};
default: return new TargetPlatform[0];
}
}
@@ -54,10 +59,12 @@ namespace Flax.Deps.Dependencies
};
// Get the source
Downloader.DownloadFileFromUrlToPath("https://curl.haxx.se/download/curl-7.64.1.zip", packagePath);
if (!File.Exists(packagePath))
Downloader.DownloadFileFromUrlToPath("https://curl.haxx.se/download/curl-7.64.1.zip", packagePath);
using (ZipArchive archive = ZipFile.Open(packagePath, ZipArchiveMode.Read))
{
archive.ExtractToDirectory(root);
if (!Directory.Exists(root))
archive.ExtractToDirectory(root);
root = Path.Combine(root, archive.Entries.First().FullName);
}
@@ -78,7 +85,7 @@ namespace Flax.Deps.Dependencies
{
// Build for Win64
Deploy.VCEnvironment.BuildSolution(vsSolutionPath, configuration, "x64");
var depsFolder = GetThirdPartyFolder(options, TargetPlatform.Windows, TargetArchitecture.x64);
var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64);
foreach (var filename in binariesToCopyWin)
Utilities.FileCopy(Path.Combine(root, "build", "Win64", vcVersion, configuration, filename), Path.Combine(depsFolder, Path.GetFileName(filename)));
}
@@ -89,7 +96,7 @@ namespace Flax.Deps.Dependencies
// Build for Linux
var settings = new []
{
"-without-librtmp",
"--without-librtmp",
"--without-ssl",
"--with-gnutls",
"--disable-ipv6",
@@ -102,7 +109,7 @@ namespace Flax.Deps.Dependencies
var envVars = new Dictionary<string, string>
{
{ "CC", "clang-7" },
{ "CC_FOR_BUILD", "clang-7" }
{ "CC_FOR_BUILD", "clang-7" },
};
var buildDir = Path.Combine(root, "build");
SetupDirectory(buildDir, true);
@@ -110,7 +117,45 @@ namespace Flax.Deps.Dependencies
Utilities.Run(Path.Combine(root, "configure"), string.Join(" ", settings) + " --prefix=\"" + buildDir + "\"", null, root, Utilities.RunOptions.None, envVars);
Utilities.Run("make", null, null, root, Utilities.RunOptions.None);
Utilities.Run("make", "install", null, root, Utilities.RunOptions.None);
var depsFolder = GetThirdPartyFolder(options, TargetPlatform.Linux, TargetArchitecture.x64);
var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64);
var filename = "libcurl.a";
Utilities.FileCopy(Path.Combine(buildDir, "lib", filename), Path.Combine(depsFolder, filename));
break;
}
case TargetPlatform.Mac:
{
// Build for Mac
var settings = new []
{
"--with-secure-transport",
"--without-librtmp",
"--disable-ipv6",
"--disable-manual",
"--disable-verbose",
"--disable-shared",
"--enable-static",
"-disable-ldap --disable-sspi --disable-ftp --disable-file --disable-dict --disable-telnet --disable-tftp --disable-rtsp --disable-pop3 --disable-imap --disable-smtp --disable-gopher --disable-smb",
};
var arch = "x86_64";
var archName = arch + "-apple-darwin18";
var compilerFlags = string.Format("-mmacosx-version-min={0} -arch {1}", Configuration.MacOSXMinVer, arch);
var envVars = new Dictionary<string, string>
{
{ "CFLAGS", compilerFlags },
{ "CXXFLAGS", compilerFlags },
{ "CPPFLAGS", compilerFlags },
{ "ARCH", arch },
{ "SDK", "macosx" },
{ "DEPLOYMENT_TARGET", Configuration.MacOSXMinVer },
};
var buildDir = Path.Combine(root, "build");
SetupDirectory(buildDir, true);
Utilities.Run("chmod", "+x configure", null, root, Utilities.RunOptions.None);
Utilities.Run("chmod", "+x install-sh", null, root, Utilities.RunOptions.None);
Utilities.Run(Path.Combine(root, "configure"), string.Join(" ", settings) + " --host=" + archName + " --prefix=\"" + buildDir + "\"", null, root, Utilities.RunOptions.None, envVars);
Utilities.Run("make", null, null, root, Utilities.RunOptions.None);
Utilities.Run("make", "install", null, root, Utilities.RunOptions.None);
var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64);
var filename = "libcurl.a";
Utilities.FileCopy(Path.Combine(buildDir, "lib", filename), Path.Combine(depsFolder, filename));
break;

View File

@@ -570,6 +570,8 @@ namespace Flax.Deps.Dependencies
var editoBinOutput = Path.Combine(options.PlatformsFolder, "Editor", "Linux", "Mono", "bin");
Utilities.FileCopy(Path.Combine(buildDir, "bin", "mono-sgen"), Path.Combine(editoBinOutput, "mono"));
Utilities.Run("strip", "mono", null, editoBinOutput, Utilities.RunOptions.None);
Utilities.DirectoryCopy(Path.Combine(buildDir, "etc"), Path.Combine(options.PlatformsFolder, platform.ToString(), "Binaries", "Mono", "etc"), true, true);
Utilities.DirectoryCopy(Path.Combine(buildDir, "etc"), Path.Combine(options.PlatformsFolder, "Editor", platform.ToString(), "Binaries", "Mono", "etc"), true, true);
var srcMonoLibs = Path.Combine(buildDir, "lib", "mono");
var dstMonoLibs = Path.Combine(options.PlatformsFolder, platform.ToString(), "Binaries", "Mono", "lib", "mono");
var dstMonoEditorLibs = Path.Combine(options.PlatformsFolder, "Editor", platform.ToString(), "Mono", "lib", "mono");
@@ -770,6 +772,8 @@ namespace Flax.Deps.Dependencies
Directory.CreateDirectory(editoBinOutput);
Utilities.FileCopy(Path.Combine(buildDir, "bin", "mono-sgen"), Path.Combine(editoBinOutput, "mono"));
Utilities.Run("strip", "mono", null, editoBinOutput, Utilities.RunOptions.None);
Utilities.DirectoryCopy(Path.Combine(buildDir, "etc"), Path.Combine(options.PlatformsFolder, platform.ToString(), "Binaries", "Mono", "etc"), true, true);
Utilities.DirectoryCopy(Path.Combine(buildDir, "etc"), Path.Combine(options.PlatformsFolder, "Editor", platform.ToString(), "Binaries", "Mono", "etc"), true, true);
var srcMonoLibs = Path.Combine(buildDir, "lib", "mono");
var dstMonoLibs = Path.Combine(options.PlatformsFolder, platform.ToString(), "Binaries", "Mono", "lib", "mono");
var dstMonoEditorLibs = Path.Combine(options.PlatformsFolder, "Editor", platform.ToString(), "Mono", "lib", "mono");