Switch impl progress

This commit is contained in:
Wojtek Figat
2021-03-11 17:22:06 +01:00
parent e09f4eb6dc
commit 4072796e54
7 changed files with 79 additions and 4 deletions

View File

@@ -33,6 +33,7 @@ namespace Flax.Deps.Dependencies
TargetPlatform.PS4,
TargetPlatform.XboxScarlett,
TargetPlatform.Android,
TargetPlatform.Switch,
};
case TargetPlatform.Linux:
return new[]
@@ -166,6 +167,12 @@ namespace Flax.Deps.Dependencies
binariesPrefix = "lib";
suppressBitsPostfix = true;
break;
case TargetPlatform.Switch:
binariesSubDir = "switch64";
buildPlatform = "NX64";
suppressBitsPostfix = true;
binariesPrefix = "lib";
break;
default: throw new InvalidPlatformException(targetPlatform);
}
@@ -354,6 +361,12 @@ namespace Flax.Deps.Dependencies
Build(options, "android", platform, TargetArchitecture.ARM64);
break;
}
case TargetPlatform.Switch:
{
Utilities.DirectoryCopy(Path.Combine(options.PlatformsFolder, "Switch", "Data", "PhysX"), root, true, true);
Build(options, "switch64", platform, TargetArchitecture.ARM64);
break;
}
}
}

View File

@@ -31,6 +31,7 @@ namespace Flax.Deps.Dependencies
TargetPlatform.PS4,
TargetPlatform.XboxScarlett,
TargetPlatform.Android,
TargetPlatform.Switch,
};
case TargetPlatform.Linux:
return new[]
@@ -209,6 +210,17 @@ namespace Flax.Deps.Dependencies
Utilities.FileCopy(Path.Combine(buildDir, libraryFileName), Path.Combine(depsFolder, libraryFileName));
break;
}
case TargetPlatform.Switch:
{
// Build for Switch
var buildDir = Path.Combine(root, "build");
SetupDirectory(buildDir, true);
RunCmake(buildDir, platform, TargetArchitecture.ARM64, ".. -DCMAKE_BUILD_TYPE=Release");
Utilities.Run("cmake", "--build .", null, buildDir, Utilities.RunOptions.None);
var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64);
Utilities.FileCopy(Path.Combine(buildDir, libraryFileName), Path.Combine(depsFolder, libraryFileName));
break;
}
}
}

View File

@@ -30,6 +30,7 @@ namespace Flax.Deps.Dependencies
TargetPlatform.PS4,
TargetPlatform.XboxScarlett,
TargetPlatform.Android,
TargetPlatform.Switch,
};
case TargetPlatform.Linux:
return new[]
@@ -180,6 +181,20 @@ namespace Flax.Deps.Dependencies
Utilities.FileCopy(Path.Combine(buildDir, libraryFileName), Path.Combine(depsFolder, libraryFileName));
break;
}
case TargetPlatform.Switch:
{
// Get the build data files
Utilities.DirectoryCopy(Path.Combine(options.PlatformsFolder, "Switch", "Data", "ogg"), root, true, true);
// Build for Switch
var buildDir = Path.Combine(root, "build");
SetupDirectory(buildDir, true);
RunCmake(buildDir, platform, TargetArchitecture.ARM64, ".. -DCMAKE_BUILD_TYPE=Release");
Utilities.Run("cmake", "--build .", null, buildDir, Utilities.RunOptions.None);
var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64);
Utilities.FileCopy(Path.Combine(buildDir, libraryFileName), Path.Combine(depsFolder, libraryFileName));
break;
}
}
}

View File

@@ -31,6 +31,7 @@ namespace Flax.Deps.Dependencies
TargetPlatform.PS4,
TargetPlatform.XboxScarlett,
TargetPlatform.Android,
TargetPlatform.Switch,
};
case TargetPlatform.Linux:
return new[]
@@ -291,7 +292,8 @@ namespace Flax.Deps.Dependencies
// Get the source
CloneGitRepoFast(root, "https://github.com/xiph/vorbis.git");
CloneGitRepoFast(oggRoot, "https://github.com/xiph/ogg.git");
CloneGitRepo(oggRoot, "https://github.com/xiph/ogg.git");
GitCheckout(oggRoot, "master", "4380566a44b8d5e85ad511c9c17eb04197863ec5");
// Build for Android
SetupDirectory(oggBuildDir, true);
@@ -305,6 +307,33 @@ namespace Flax.Deps.Dependencies
Utilities.FileCopy(Path.Combine(buildDir, file.SrcFolder, file.Filename), Path.Combine(depsFolder, file.Filename));
break;
}
case TargetPlatform.Switch:
{
var oggRoot = Path.Combine(root, "ogg");
var oggBuildDir = Path.Combine(oggRoot, "build");
var buildDir = Path.Combine(root, "build");
// Get the source
CloneGitRepo(root, "https://github.com/xiph/vorbis.git");
GitCheckout(root, "master", "98eddc72d36e3421519d54b101c09b57e4d4d10d");
CloneGitRepo(oggRoot, "https://github.com/xiph/ogg.git");
GitCheckout(oggRoot, "master", "4380566a44b8d5e85ad511c9c17eb04197863ec5");
Utilities.DirectoryCopy(Path.Combine(options.PlatformsFolder, "Switch", "Data", "ogg"), oggRoot, true, true);
Utilities.DirectoryCopy(Path.Combine(options.PlatformsFolder, "Switch", "Data", "vorbis"), buildDir, true, true);
// Build for Switch
SetupDirectory(oggBuildDir, true);
RunCmake(oggBuildDir, platform, TargetArchitecture.ARM64, ".. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=\"../install\"");
Utilities.Run("cmake", "--build . --target install", null, oggBuildDir, Utilities.RunOptions.None);
Utilities.FileCopy(Path.Combine(options.PlatformsFolder, "Switch", "Data", "ogg", "include", "ogg", "config_types.h"), Path.Combine(oggRoot, "install", "include", "ogg", "config_types.h"));
SetupDirectory(buildDir, true);
RunCmake(buildDir, platform, TargetArchitecture.ARM64, string.Format(".. -DCMAKE_BUILD_TYPE=Release -DOGG_INCLUDE_DIR=\"{0}/install/include\" -DOGG_LIBRARY=\"{0}/install/lib\"", oggRoot));
Utilities.Run("cmake", "--build .", null, buildDir, Utilities.RunOptions.None);
var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64);
foreach (var file in binariesToCopyUnix)
Utilities.FileCopy(Path.Combine(buildDir, file.SrcFolder, file.Filename), Path.Combine(depsFolder, file.Filename));
break;
}
}
}

View File

@@ -1,5 +1,6 @@
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
using System;
using System.Collections.Generic;
using System.IO;
using Flax.Build;
@@ -237,11 +238,15 @@ namespace Flax.Deps
}
case TargetPlatform.Linux:
case TargetPlatform.PS4:
case TargetPlatform.Switch:
{
cmdLine = "CMakeLists.txt";
break;
}
case TargetPlatform.Switch:
{
cmdLine = string.Format("-DCMAKE_TOOLCHAIN_FILE=\"{1}\\Source\\Platforms\\Switch\\Data\\Switch.cmake\" -G \"NMake Makefiles\" -DCMAKE_MAKE_PROGRAM=\"{0}..\\..\\VC\\bin\\nmake.exe\"", Environment.GetEnvironmentVariable("VS140COMNTOOLS"), Globals.EngineRoot);
break;
}
case TargetPlatform.Android:
{
var ndk = AndroidNdk.Instance.RootPath;

View File

@@ -85,7 +85,8 @@ namespace Flax.Deps
continue;
}
Dependency.SetupDirectory(options.IntermediateFolder, true);
var forceEmpty = Configuration.ReBuildDeps;
Dependency.SetupDirectory(options.IntermediateFolder, forceEmpty);
dependency.Build(options);
}