Compare commits

...

3 Commits

Author SHA1 Message Date
cce6e00960 - Merge 2024-07-12 23:11:47 +02:00
1096597161 - Fixed bug in builder when no content files exist 2024-07-12 23:10:44 +02:00
d45f7c3b8c - Fixed bug in builder when no content files exist 2024-07-12 23:08:52 +02:00
2 changed files with 54 additions and 50 deletions

View File

@ -37,65 +37,69 @@ public void Run(BuildArgs args)
CollectAssetFiles(absContentPath, absContentPath, ref contentFiles);
}
string importPath = $"{args.ProjectPath}/{PathUtil.ImportFolderName}";
ParallelOptions parallelOptions = new ParallelOptions
if (contentFiles.Count > 0)
{
MaxDegreeOfParallelism = contentFiles.Count
};
Parallel.ForEach(contentFiles, parallelOptions, relativeFile =>
{
try
string importPath = $"{args.ProjectPath}/{PathUtil.ImportFolderName}";
ParallelOptions parallelOptions = new ParallelOptions
{
string inFile = $"{args.ProjectPath}/{PathUtil.ContentFolderName}/{relativeFile}";
MaxDegreeOfParallelism = contentFiles.Count
};
if (!File.Exists(inFile))
{
Console.Error.WriteLine($"Asset file '{relativeFile}' not found");
return;
}
string outFile = $"{importPath}/{relativeFile}{PathUtil.ImportedFileExtension}";
FileInfo inFileInfo = new FileInfo(inFile);
FileInfo outFileInfo = new FileInfo(outFile);
if (!FileUtil.IsNewer(inFileInfo, outFileInfo))
{
// File has not changed since last build, no need to build this one.
return;
}
string outDir = Path.GetDirectoryName(outFile);
if (!Directory.Exists(outDir))
{
Directory.CreateDirectory(outDir);
}
string ext = Path.GetExtension(inFile).ToLower();
if (importers.TryGetValue(ext, out IImporter importer))
{
importer.Import(inFile, outFile);
}
else
{
rawFileImporter.Import(inFile, outFile);
}
Console.WriteLine(relativeFile);
}
catch (Exception e)
Parallel.ForEach(contentFiles, parallelOptions, relativeFile =>
{
Console.Error.WriteLine($"Import error on asset '{relativeFile}': {e.Message}");
}
});
try
{
string inFile = $"{args.ProjectPath}/{PathUtil.ContentFolderName}/{relativeFile}";
if (!File.Exists(inFile))
{
Console.Error.WriteLine($"Asset file '{relativeFile}' not found");
return;
}
string outFile = $"{importPath}/{relativeFile}{PathUtil.ImportedFileExtension}";
FileInfo inFileInfo = new FileInfo(inFile);
FileInfo outFileInfo = new FileInfo(outFile);
if (!FileUtil.IsNewer(inFileInfo, outFileInfo))
{
// File has not changed since last build, no need to build this one.
return;
}
string outDir = Path.GetDirectoryName(outFile);
if (!Directory.Exists(outDir))
{
Directory.CreateDirectory(outDir);
}
string ext = Path.GetExtension(inFile).ToLower();
if (importers.TryGetValue(ext, out IImporter importer))
{
importer.Import(inFile, outFile);
}
else
{
rawFileImporter.Import(inFile, outFile);
}
Console.WriteLine(relativeFile);
}
catch (Exception e)
{
Console.Error.WriteLine($"Import error on asset '{relativeFile}': {e.Message}");
}
});
}
Console.WriteLine($"Build content completed in {stopwatch.Elapsed.TotalSeconds:F2} seconds");
}
private void CopyLibs(string projectPath)
{
string libDir = $"{Directory.GetCurrentDirectory()}/../../Native/";
string libDir = $"{AppDomain.CurrentDomain.BaseDirectory}/../../Native/";
if (OperatingSystem.IsWindows())
{
libDir += "x64";

View File

@ -27,4 +27,4 @@
</ItemGroup>
<Import Project=".\CopyLibs.targets" />
</Project>
</Project>