Codestyle fixes
This commit is contained in:
@@ -9,32 +9,30 @@ namespace Flax.Build
|
||||
/// </summary>
|
||||
public static class FileCache
|
||||
{
|
||||
private static Dictionary<string, FileInfo> fileInfoCache = new Dictionary<string, FileInfo>();
|
||||
private static readonly Dictionary<string, FileInfo> _cache = new();
|
||||
|
||||
public static void FileRemoveFromCache(string path)
|
||||
{
|
||||
//fileInfoCache[path].Refresh();
|
||||
fileInfoCache.Remove(path);
|
||||
_cache.Remove(path);
|
||||
}
|
||||
|
||||
|
||||
public static bool Exists(string path)
|
||||
{
|
||||
if (fileInfoCache.TryGetValue(path, out var fileInfo))
|
||||
if (_cache.TryGetValue(path, out var fileInfo))
|
||||
return fileInfo.Exists;
|
||||
|
||||
fileInfo = new FileInfo(path);
|
||||
fileInfoCache.Add(path, fileInfo);
|
||||
_cache.Add(path, fileInfo);
|
||||
return fileInfo.Exists;
|
||||
}
|
||||
|
||||
public static DateTime GetLastWriteTime(string path)
|
||||
{
|
||||
|
||||
if (fileInfoCache.TryGetValue(path, out var fileInfo))
|
||||
if (_cache.TryGetValue(path, out var fileInfo))
|
||||
return fileInfo.LastWriteTime;
|
||||
|
||||
fileInfo = new FileInfo(path);
|
||||
fileInfoCache.Add(path, fileInfo);
|
||||
_cache.Add(path, fileInfo);
|
||||
return fileInfo.LastWriteTime;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -808,11 +808,11 @@ namespace Flax.Build
|
||||
foreach (var moduleName in moduleOptions.PrivateDependencies.Concat(moduleOptions.PublicDependencies))
|
||||
{
|
||||
var dependencyModule = buildData.Rules.GetModule(moduleName);
|
||||
if (dependencyModule != null &&
|
||||
!string.IsNullOrEmpty(dependencyModule.BinaryModuleName) &&
|
||||
dependencyModule.BinaryModuleName != binaryModule.Key &&
|
||||
if (dependencyModule != null &&
|
||||
!string.IsNullOrEmpty(dependencyModule.BinaryModuleName) &&
|
||||
dependencyModule.BinaryModuleName != binaryModule.Key &&
|
||||
!moduleNamesUsed.Contains(dependencyModule.BinaryModuleName) &&
|
||||
GetModuleProject(dependencyModule, project) != null &&
|
||||
GetModuleProject(dependencyModule, project) != null &&
|
||||
buildData.Modules.TryGetValue(dependencyModule, out var dependencyOptions))
|
||||
{
|
||||
// Import symbols from referenced binary module
|
||||
|
||||
@@ -77,14 +77,10 @@ namespace Flax.Build
|
||||
var architectureId = RuntimeInformation.ProcessArchitecture;
|
||||
switch (architectureId)
|
||||
{
|
||||
case Architecture.X86:
|
||||
return TargetArchitecture.x86;
|
||||
case Architecture.X64:
|
||||
return TargetArchitecture.x64;
|
||||
case Architecture.Arm:
|
||||
return TargetArchitecture.ARM;
|
||||
case Architecture.Arm64:
|
||||
return TargetArchitecture.ARM64;
|
||||
case Architecture.X86: return TargetArchitecture.x86;
|
||||
case Architecture.X64: return TargetArchitecture.x64;
|
||||
case Architecture.Arm: return TargetArchitecture.ARM;
|
||||
case Architecture.Arm64: return TargetArchitecture.ARM64;
|
||||
default: throw new NotImplementedException(string.Format("Unsupported build platform {0}.", architectureId));
|
||||
}
|
||||
}
|
||||
@@ -290,12 +286,9 @@ namespace Flax.Build
|
||||
var subdir = "Binaries/Editor/";
|
||||
switch (Platform.BuildTargetPlatform)
|
||||
{
|
||||
case TargetPlatform.Windows:
|
||||
return subdir + "Win64";
|
||||
case TargetPlatform.Linux:
|
||||
return subdir + "Linux";
|
||||
case TargetPlatform.Mac:
|
||||
return subdir + "Mac";
|
||||
case TargetPlatform.Windows: return subdir + "Win64";
|
||||
case TargetPlatform.Linux: return subdir + "Linux";
|
||||
case TargetPlatform.Mac: return subdir + "Mac";
|
||||
}
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace Flax.Deploy
|
||||
DeployFile(src, dst, buildToolExe);
|
||||
CodeSign(Path.Combine(dst, buildToolExe));
|
||||
var buildToolDll = "Flax.Build.dll";
|
||||
DeployFile(src, dst,buildToolDll);
|
||||
DeployFile(src, dst, buildToolDll);
|
||||
CodeSign(Path.Combine(dst, buildToolDll));
|
||||
DeployFile(src, dst, "Flax.Build.xml", true);
|
||||
DeployFile(src, dst, "Flax.Build.pdb");
|
||||
|
||||
@@ -128,7 +128,7 @@ namespace Flax.Deps.Dependencies
|
||||
case TargetPlatform.Mac:
|
||||
{
|
||||
// Build for Mac
|
||||
foreach (var architecture in new []{ TargetArchitecture.x64, TargetArchitecture.ARM64 })
|
||||
foreach (var architecture in new[] { TargetArchitecture.x64, TargetArchitecture.ARM64 })
|
||||
{
|
||||
RunCmake(root, platform, architecture, " -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF " + globalConfig);
|
||||
Utilities.Run("make", null, null, root, Utilities.RunOptions.ThrowExceptionOnError);
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace Flax.Deps.Dependencies
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Build(BuildOptions options)
|
||||
{
|
||||
@@ -185,16 +185,16 @@ namespace Flax.Deps.Dependencies
|
||||
|
||||
// Print the NvCloth version
|
||||
Log.Info($"Building {File.ReadAllLines(Path.Combine(root, "README.md"))[0].Trim()} to {platform} {architecture}");
|
||||
|
||||
|
||||
// Generate project files
|
||||
SetupDirectory(buildFolder, false);
|
||||
Utilities.FileDelete(Path.Combine(cmakeFolder, "CMakeCache.txt"));
|
||||
cmakeArgs += $" -DPX_STATIC_LIBRARIES=1 -DPX_OUTPUT_DLL_DIR=\"{Path.Combine(buildFolder, "bin")}\" -DPX_OUTPUT_LIB_DIR=\"{Path.Combine(buildFolder, "lib")}\" -DPX_OUTPUT_EXE_DIR=\"{Path.Combine(buildFolder, "bin")}\"";
|
||||
RunCmake(cmakeFolder, platform, architecture, " -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF " + cmakeArgs, envVars);
|
||||
|
||||
|
||||
// Run build
|
||||
Utilities.Run("cmake", "--build . --config Release", null, cmakeFolder, Utilities.RunOptions.ThrowExceptionOnError, envVars);
|
||||
|
||||
|
||||
// Deploy binaries
|
||||
var libs = new[]
|
||||
{
|
||||
|
||||
@@ -172,7 +172,7 @@ namespace Flax.Deps.Dependencies
|
||||
var buildDir = Path.Combine(root, "build");
|
||||
|
||||
// Build for Mac
|
||||
foreach (var architecture in new []{ TargetArchitecture.x64, TargetArchitecture.ARM64 })
|
||||
foreach (var architecture in new[] { TargetArchitecture.x64, TargetArchitecture.ARM64 })
|
||||
{
|
||||
SetupDirectory(buildDir, true);
|
||||
RunCmake(buildDir, platform, architecture, ".. -DLIBTYPE=STATIC -DCMAKE_BUILD_TYPE=Release " + config);
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace Flax.Deps.Dependencies
|
||||
case TargetPlatform.Linux:
|
||||
{
|
||||
// Build for Linux
|
||||
var settings = new []
|
||||
var settings = new[]
|
||||
{
|
||||
"--without-librtmp",
|
||||
"--without-ssl",
|
||||
@@ -126,7 +126,7 @@ namespace Flax.Deps.Dependencies
|
||||
case TargetPlatform.Mac:
|
||||
{
|
||||
// Build for Mac
|
||||
var settings = new []
|
||||
var settings = new[]
|
||||
{
|
||||
"--with-secure-transport",
|
||||
"--without-librtmp",
|
||||
@@ -137,7 +137,7 @@ namespace Flax.Deps.Dependencies
|
||||
"--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",
|
||||
};
|
||||
foreach (var architecture in new []{ TargetArchitecture.x64, TargetArchitecture.ARM64 })
|
||||
foreach (var architecture in new[] { TargetArchitecture.x64, TargetArchitecture.ARM64 })
|
||||
{
|
||||
var arch = GetAppleArchName(architecture);
|
||||
var archName = arch + "-apple-darwin19";
|
||||
@@ -146,7 +146,7 @@ namespace Flax.Deps.Dependencies
|
||||
var compilerFlags = string.Format("-mmacosx-version-min={0} -arch {1}", Configuration.MacOSXMinVer, arch);
|
||||
var envVars = new Dictionary<string, string>
|
||||
{
|
||||
{ "CC", "clang" },
|
||||
{ "CC", "clang" },
|
||||
{ "CXX", "clang" },
|
||||
{ "CFLAGS", compilerFlags },
|
||||
{ "CXXFLAGS", compilerFlags },
|
||||
|
||||
@@ -247,7 +247,7 @@ namespace Flax.Deps.Dependencies
|
||||
case TargetPlatform.Mac:
|
||||
{
|
||||
// Build for Mac
|
||||
foreach (var architecture in new []{ TargetArchitecture.x64, TargetArchitecture.ARM64 })
|
||||
foreach (var architecture in new[] { TargetArchitecture.x64, TargetArchitecture.ARM64 })
|
||||
{
|
||||
SetupDirectory(buildDir, true);
|
||||
RunCmake(buildDir, platform, architecture, ".. -DCMAKE_BUILD_TYPE=Release");
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace Flax.Deps.Dependencies
|
||||
};
|
||||
|
||||
// Build for Mac
|
||||
foreach (var architecture in new []{ TargetArchitecture.x64, TargetArchitecture.ARM64 })
|
||||
foreach (var architecture in new[] { TargetArchitecture.x64, TargetArchitecture.ARM64 })
|
||||
{
|
||||
RunCmake(root, platform, architecture, cmakeArgs);
|
||||
Utilities.Run("cmake", string.Format("--build . --config {0} --target install", configuration), null, buildDir, Utilities.RunOptions.None);
|
||||
|
||||
@@ -217,7 +217,7 @@ namespace Flax.Deps.Dependencies
|
||||
case TargetPlatform.Mac:
|
||||
{
|
||||
// Build for Mac
|
||||
foreach (var architecture in new []{ TargetArchitecture.x64, TargetArchitecture.ARM64 })
|
||||
foreach (var architecture in new[] { TargetArchitecture.x64, TargetArchitecture.ARM64 })
|
||||
{
|
||||
SetupDirectory(buildDir, true);
|
||||
RunCmake(buildDir, platform, architecture, ".. -DCMAKE_BUILD_TYPE=Release");
|
||||
|
||||
@@ -376,7 +376,7 @@ namespace Flax.Deps.Dependencies
|
||||
GitCheckout(oggRoot, "master", "4380566a44b8d5e85ad511c9c17eb04197863ec5");
|
||||
|
||||
// Build for Mac
|
||||
foreach (var architecture in new []{ TargetArchitecture.x64, TargetArchitecture.ARM64 })
|
||||
foreach (var architecture in new[] { TargetArchitecture.x64, TargetArchitecture.ARM64 })
|
||||
{
|
||||
SetupDirectory(oggBuildDir, true);
|
||||
RunCmake(oggBuildDir, platform, architecture, ".. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=\"../install\"");
|
||||
|
||||
@@ -105,8 +105,7 @@ namespace Flax.Deps
|
||||
if (totalBytes.HasValue)
|
||||
progress.Update(totalBytesRead, totalBytes.Value);
|
||||
}
|
||||
}
|
||||
while (hasMoreToRead);
|
||||
} while (hasMoreToRead);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace Flax.Deps
|
||||
Console.WriteLine();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Flax.Build.Platforms
|
||||
public static readonly AndroidSdk Instance = new AndroidSdk();
|
||||
|
||||
/// <inheritdoc />
|
||||
public override TargetPlatform[] Platforms => new []
|
||||
public override TargetPlatform[] Platforms => new[]
|
||||
{
|
||||
TargetPlatform.Windows,
|
||||
TargetPlatform.Linux,
|
||||
|
||||
@@ -77,15 +77,15 @@ namespace Flax.Build.Platforms
|
||||
/// Returns true if running an x64 binary an arm64 host machine.
|
||||
/// </summary>
|
||||
public unsafe static bool GetProcessIsTranslated()
|
||||
{
|
||||
int ret = 0;
|
||||
ulong size = sizeof(int);
|
||||
if (sysctlbyname("sysctl.proc_translated", &ret, &size, null, 0) == -1)
|
||||
return false;
|
||||
return ret != 0;
|
||||
}
|
||||
{
|
||||
int ret = 0;
|
||||
ulong size = sizeof(int);
|
||||
if (sysctlbyname("sysctl.proc_translated", &ret, &size, null, 0) == -1)
|
||||
return false;
|
||||
return ret != 0;
|
||||
}
|
||||
|
||||
[DllImport("c")]
|
||||
private static unsafe extern int sysctlbyname(string name, void* oldp, ulong* oldlenp, void* newp, ulong newlen);
|
||||
private static unsafe extern int sysctlbyname(string name, void* oldp, ulong* oldlenp, void* newp, ulong newlen);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -702,7 +702,7 @@ namespace Flax.Build.Projects.VisualStudio
|
||||
{
|
||||
// Build command for the build tool
|
||||
var buildToolPath = Path.ChangeExtension(typeof(Builder).Assembly.Location, null);
|
||||
|
||||
|
||||
var targetsFileContent = new StringBuilder();
|
||||
targetsFileContent.AppendLine("<Project>");
|
||||
targetsFileContent.AppendLine(" <!-- Custom Flax.Build scripts for C# projects. -->");
|
||||
|
||||
@@ -410,8 +410,7 @@ namespace Flax.Build.Projects.VisualStudioCode
|
||||
json.AddField("stopAtEntry", false);
|
||||
json.AddField("externalConsole", true);
|
||||
break;
|
||||
case TargetPlatform.Linux:
|
||||
break;
|
||||
case TargetPlatform.Linux: break;
|
||||
}
|
||||
}
|
||||
json.EndObject();
|
||||
@@ -622,7 +621,7 @@ namespace Flax.Build.Projects.VisualStudioCode
|
||||
json.AddField("**/Output", true);
|
||||
json.AddField("**/*.flax", true);
|
||||
json.EndObject();
|
||||
|
||||
|
||||
// Extension settings
|
||||
json.AddField("omnisharp.useModernNet", true);
|
||||
|
||||
|
||||
@@ -79,8 +79,7 @@ namespace Flax.Build
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new InvalidPlatformException(buildData.Platform.Target);
|
||||
default: throw new InvalidPlatformException(buildData.Platform.Target);
|
||||
}
|
||||
var result = sb.ToString();
|
||||
BindingsGenerator.PutStringBuilder(sb);
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace Flax.Build
|
||||
System = 0x00001000,
|
||||
Task = 0x00002000
|
||||
}
|
||||
|
||||
|
||||
public enum Icon : uint
|
||||
{
|
||||
Warning = 0x00000030,
|
||||
|
||||
Reference in New Issue
Block a user