Improve build tool api for deps modules

This commit is contained in:
Wojtek Figat
2023-12-24 22:46:30 +01:00
parent 3c6ed303fe
commit f2d1b75d1f
7 changed files with 44 additions and 29 deletions

View File

@@ -147,7 +147,7 @@ namespace Flax.Deps.Dependencies
// Build
RunCmake(buildDir, platform, TargetArchitecture.ARM64, ".. -DLIBTYPE=STATIC -DCMAKE_BUILD_TYPE=Release " + config);
Utilities.Run("cmake", "--build .", null, buildDir, Utilities.RunOptions.ConsoleLogOutput);
BuildCmake(buildDir);
var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64);
foreach (var file in binariesToCopy)
Utilities.FileCopy(Path.Combine(buildDir, file), Path.Combine(depsFolder, file));
@@ -176,7 +176,7 @@ namespace Flax.Deps.Dependencies
{
SetupDirectory(buildDir, true);
RunCmake(buildDir, platform, architecture, ".. -DLIBTYPE=STATIC -DCMAKE_BUILD_TYPE=Release " + config);
Utilities.Run("cmake", "--build .", null, buildDir, Utilities.RunOptions.ConsoleLogOutput);
BuildCmake(buildDir);
var depsFolder = GetThirdPartyFolder(options, platform, architecture);
foreach (var file in binariesToCopy)
Utilities.FileCopy(Path.Combine(buildDir, file), Path.Combine(depsFolder, file));
@@ -206,7 +206,7 @@ namespace Flax.Deps.Dependencies
// Build for iOS
SetupDirectory(buildDir, true);
RunCmake(buildDir, platform, TargetArchitecture.ARM64, ".. -DCMAKE_SYSTEM_NAME=iOS -DALSOFT_OSX_FRAMEWORK=ON -DLIBTYPE=STATIC -DCMAKE_BUILD_TYPE=Release " + config);
Utilities.Run("cmake", "--build .", null, buildDir, Utilities.RunOptions.ConsoleLogOutput);
BuildCmake(buildDir);
var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64);
foreach (var file in binariesToCopy)
Utilities.FileCopy(Path.Combine(buildDir, file), Path.Combine(depsFolder, file));

View File

@@ -49,7 +49,7 @@ namespace Flax.Deps.Dependencies
var lib = architecture == TargetArchitecture.ARM64 ? "libastcenc-neon-static.a" : "libastcenc-sse2-static.a";
SetupDirectory(buildDir, true);
RunCmake(buildDir, platform, architecture, ".. -DCMAKE_BUILD_TYPE=Release -DASTCENC_UNIVERSAL_BUILD=OFF -DASTCENC_UNIVERSAL_BINARY=OFF " + isa);
Utilities.Run("cmake", "--build .", null, buildDir, Utilities.RunOptions.ConsoleLogOutput);
BuildCmake(buildDir);
var depsFolder = GetThirdPartyFolder(options, platform, architecture);
Utilities.FileCopy(Path.Combine(buildDir, "Source", lib), Path.Combine(depsFolder, "libastcenc.a"));
}

View File

@@ -229,7 +229,7 @@ namespace Flax.Deps.Dependencies
// Build for Android
SetupDirectory(buildDir, true);
RunCmake(buildDir, TargetPlatform.Android, TargetArchitecture.ARM64, ".. -DFT_WITH_BZIP2=OFF -DFT_WITH_ZLIB=OFF -DFT_WITH_PNG=OFF -DCMAKE_BUILD_TYPE=Release");
Utilities.Run("cmake", "--build .", null, buildDir, Utilities.RunOptions.ConsoleLogOutput);
BuildCmake(buildDir);
var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64);
Utilities.FileCopy(Path.Combine(buildDir, libraryFileName), Path.Combine(depsFolder, libraryFileName));
break;
@@ -239,7 +239,7 @@ namespace Flax.Deps.Dependencies
// Build for Switch
SetupDirectory(buildDir, true);
RunCmake(buildDir, platform, TargetArchitecture.ARM64, ".. -DCMAKE_BUILD_TYPE=Release");
Utilities.Run("cmake", "--build .", null, buildDir, Utilities.RunOptions.ConsoleLogOutput);
BuildCmake(buildDir);
var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64);
Utilities.FileCopy(Path.Combine(buildDir, libraryFileName), Path.Combine(depsFolder, libraryFileName));
break;
@@ -251,7 +251,7 @@ namespace Flax.Deps.Dependencies
{
SetupDirectory(buildDir, true);
RunCmake(buildDir, platform, architecture, ".. -DCMAKE_BUILD_TYPE=Release");
Utilities.Run("cmake", "--build .", null, buildDir, Utilities.RunOptions.ConsoleLogOutput);
BuildCmake(buildDir);
var depsFolder = GetThirdPartyFolder(options, platform, architecture);
Utilities.FileCopy(Path.Combine(buildDir, libraryFileName), Path.Combine(depsFolder, libraryFileName));
}
@@ -268,7 +268,7 @@ namespace Flax.Deps.Dependencies
// Build for iOS
SetupDirectory(buildDir, true);
RunCmake(buildDir, platform, TargetArchitecture.ARM64, ".. -DIOS_PLATFORM=OS -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_BUILD_TYPE=Release -DFT_WITH_BZIP2=OFF -DFT_WITH_ZLIB=OFF -DFT_WITH_PNG=OFF");
Utilities.Run("cmake", "--build .", null, buildDir, Utilities.RunOptions.ConsoleLogOutput);
BuildCmake(buildDir);
var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64);
Utilities.FileCopy(Path.Combine(buildDir, libraryFileName), Path.Combine(depsFolder, libraryFileName));
break;

View File

@@ -196,7 +196,7 @@ namespace Flax.Deps.Dependencies
// Build for Android
SetupDirectory(buildDir, true);
RunCmake(buildDir, platform, TargetArchitecture.ARM64, ".. -DCMAKE_BUILD_TYPE=Release");
Utilities.Run("cmake", "--build .", null, buildDir, Utilities.RunOptions.ConsoleLogOutput);
BuildCmake(buildDir);
var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64);
Utilities.FileCopy(Path.Combine(buildDir, libraryFileName), Path.Combine(depsFolder, libraryFileName));
break;
@@ -209,7 +209,7 @@ namespace Flax.Deps.Dependencies
// Build for Switch
SetupDirectory(buildDir, true);
RunCmake(buildDir, platform, TargetArchitecture.ARM64, ".. -DCMAKE_BUILD_TYPE=Release");
Utilities.Run("cmake", "--build .", null, buildDir, Utilities.RunOptions.ConsoleLogOutput);
BuildCmake(buildDir);
var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64);
Utilities.FileCopy(Path.Combine(buildDir, libraryFileName), Path.Combine(depsFolder, libraryFileName));
break;
@@ -221,7 +221,7 @@ namespace Flax.Deps.Dependencies
{
SetupDirectory(buildDir, true);
RunCmake(buildDir, platform, architecture, ".. -DCMAKE_BUILD_TYPE=Release");
Utilities.Run("cmake", "--build .", null, buildDir, Utilities.RunOptions.ConsoleLogOutput);
BuildCmake(buildDir);
var depsFolder = GetThirdPartyFolder(options, platform, architecture);
Utilities.FileCopy(Path.Combine(buildDir, libraryFileName), Path.Combine(depsFolder, libraryFileName));
}
@@ -231,7 +231,7 @@ namespace Flax.Deps.Dependencies
{
SetupDirectory(buildDir, true);
RunCmake(buildDir, platform, TargetArchitecture.ARM64, ".. -DCMAKE_BUILD_TYPE=Release");
Utilities.Run("cmake", "--build .", null, buildDir, Utilities.RunOptions.ConsoleLogOutput);
BuildCmake(buildDir);
var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64);
Utilities.FileCopy(Path.Combine(buildDir, libraryFileName), Path.Combine(depsFolder, libraryFileName));
break;

View File

@@ -331,7 +331,7 @@ namespace Flax.Deps.Dependencies
Utilities.Run("cmake", "--build . --target install", null, oggBuildDir, Utilities.RunOptions.ConsoleLogOutput);
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.ConsoleLogOutput);
BuildCmake(buildDir);
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));
@@ -358,7 +358,7 @@ namespace Flax.Deps.Dependencies
Utilities.FileCopy(Path.Combine(GetBinariesFolder(options, platform), "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.ConsoleLogOutput);
BuildCmake(buildDir);
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));
@@ -383,7 +383,7 @@ namespace Flax.Deps.Dependencies
Utilities.Run("cmake", "--build . --target install", null, oggBuildDir, Utilities.RunOptions.ConsoleLogOutput);
SetupDirectory(buildDir, true);
RunCmake(buildDir, platform, architecture, 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.ConsoleLogOutput);
BuildCmake(buildDir);
var depsFolder = GetThirdPartyFolder(options, platform, architecture);
foreach (var file in binariesToCopyUnix)
Utilities.FileCopy(Path.Combine(buildDir, file.SrcFolder, file.Filename), Path.Combine(depsFolder, file.Filename));
@@ -407,7 +407,7 @@ namespace Flax.Deps.Dependencies
Utilities.Run("cmake", "--build . --target install", null, oggBuildDir, Utilities.RunOptions.ConsoleLogOutput);
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.ConsoleLogOutput);
BuildCmake(buildDir);
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));

View File

@@ -136,14 +136,14 @@ namespace Flax.Deps
if (submodules)
cmdLine += " --recurse-submodules";
Utilities.Run("git", cmdLine, null, null, Utilities.RunOptions.ConsoleLogOutput);
Utilities.Run("git", cmdLine, null, null, Utilities.RunOptions.DefaultTool);
if (submodules)
Utilities.Run("git", "submodule update --init --recursive", null, null, Utilities.RunOptions.ConsoleLogOutput);
Utilities.Run("git", "submodule update --init --recursive", null, null, Utilities.RunOptions.DefaultTool);
}
if (commit != null)
{
Utilities.Run("git", string.Format("reset --hard {0}", commit), null, null, Utilities.RunOptions.ConsoleLogOutput);
Utilities.Run("git", string.Format("reset --hard {0}", commit), null, null, Utilities.RunOptions.DefaultTool);
}
}
@@ -164,9 +164,9 @@ namespace Flax.Deps
if (submodules)
cmdLine += " --recurse-submodules";
Utilities.Run("git", cmdLine, null, null, Utilities.RunOptions.ConsoleLogOutput);
Utilities.Run("git", cmdLine, null, null, Utilities.RunOptions.DefaultTool);
if (submodules)
Utilities.Run("git", "submodule update --init --recursive", null, null, Utilities.RunOptions.ConsoleLogOutput);
Utilities.Run("git", "submodule update --init --recursive", null, null, Utilities.RunOptions.DefaultTool);
}
}
@@ -191,14 +191,14 @@ namespace Flax.Deps
if (submodules)
cmdLine += " --recurse-submodules";
Utilities.Run("git", cmdLine, null, null, Utilities.RunOptions.ConsoleLogOutput);
Utilities.Run("git", cmdLine, null, null, Utilities.RunOptions.DefaultTool);
if (submodules)
Utilities.Run("git", "submodule update --init --recursive", null, null, Utilities.RunOptions.ConsoleLogOutput);
Utilities.Run("git", "submodule update --init --recursive", null, null, Utilities.RunOptions.DefaultTool);
}
if (commit != null)
{
Utilities.Run("git", string.Format("reset --hard {0}", commit), null, path, Utilities.RunOptions.ConsoleLogOutput);
Utilities.Run("git", string.Format("reset --hard {0}", commit), null, path, Utilities.RunOptions.DefaultTool);
}
}
@@ -218,13 +218,13 @@ namespace Flax.Deps
if (submodules)
cmdLine += " --recurse-submodules";
Utilities.Run("git", cmdLine, null, path, Utilities.RunOptions.ConsoleLogOutput);
Utilities.Run("git", cmdLine, null, path, Utilities.RunOptions.DefaultTool);
if (submodules)
Utilities.Run("git", "submodule update --init --recursive", null, null, Utilities.RunOptions.ConsoleLogOutput);
Utilities.Run("git", "submodule update --init --recursive", null, null, Utilities.RunOptions.DefaultTool);
if (commit != null)
{
Utilities.Run("git", string.Format("reset --hard {0}", commit), null, path, Utilities.RunOptions.ConsoleLogOutput);
Utilities.Run("git", string.Format("reset --hard {0}", commit), null, path, Utilities.RunOptions.DefaultTool);
}
}
@@ -234,7 +234,17 @@ namespace Flax.Deps
/// <param name="path">The local path that contains git repository.</param>
public static void GitResetLocalChanges(string path)
{
Utilities.Run("git", "reset --hard", null, path, Utilities.RunOptions.ConsoleLogOutput);
Utilities.Run("git", "reset --hard", null, path, Utilities.RunOptions.DefaultTool);
}
/// <summary>
/// Builds the cmake project.
/// </summary>
/// <param name="path">The path.</param>
/// <param name="envVars">Custom environment variables to pass to the child process.</param>
public static void BuildCmake(string path, Dictionary<string, string> envVars = null)
{
Utilities.Run("cmake", "--build .", null, path, Utilities.RunOptions.DefaultTool, envVars);
}
/// <summary>
@@ -313,7 +323,7 @@ namespace Flax.Deps
if (customArgs != null)
cmdLine += " " + customArgs;
Utilities.Run("cmake", cmdLine, null, path, Utilities.RunOptions.ConsoleLogOutput, envVars);
Utilities.Run("cmake", cmdLine, null, path, Utilities.RunOptions.DefaultTool, envVars);
}
/// <summary>