Compare commits
3 Commits
7a81026ca5
...
cce6e00960
Author | SHA1 | Date | |
---|---|---|---|
cce6e00960 | |||
1096597161 | |||
d45f7c3b8c |
@ -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";
|
||||
|
Loading…
Reference in New Issue
Block a user