Skip to content

Commit

Permalink
Fix crash if compilation fails the first time and passes the second t…
Browse files Browse the repository at this point in the history
…ime.
  • Loading branch information
sarahelsaig committed Sep 25, 2023
1 parent aae6d24 commit 9c25b9f
Showing 1 changed file with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ private async Task BuildKernelAsync(
var emConfigExecutable = await GetExecutablePathAsync("emconfigutil");
var emConfigArguments = new[] { "--platform", device, "--od", tmpDirectoryPath, };
await _buildLogger.ExecuteWithLoggingAsync(emConfigExecutable, emConfigArguments, rtlDirectoryPath);
File.Copy(Path.Combine(tmpDirectoryPath, "emconfig.json"), "emconfig.json");
Copy(Path.Combine(tmpDirectoryPath, "emconfig.json"), "emconfig.json", overwrite: false);
ProgressMajor("Emulation configuration (emconfig) setup is finished.");
}
}
Expand Down Expand Up @@ -401,8 +401,8 @@ private void CopyBinaries(
if (binaryDirectoryPath != null) EnsureDirectoryExists(binaryDirectoryPath);

var builtFilePath = Path.Combine(GetTmpDirectoryPath(hashId), $"hastip.{target}.xclbin");
File.Copy(builtFilePath, binaryPath);
File.Copy(builtFilePath + InfoFileExtension, binaryPath + InfoFileExtension);
Copy(builtFilePath, binaryPath, overwrite: true);
Copy(builtFilePath + InfoFileExtension, binaryPath + InfoFileExtension, overwrite: true);
if (disableHbm) File.Create(binaryPath + NoHbmFlagExtension).Dispose();
ProgressMajor($"Files copied to binary folder ({builtFilePath}).");
}
Expand All @@ -427,7 +427,7 @@ private async Task CollectReportsAsync(
var reportFiles = Directory.GetFiles(reportPath, "*.rpt");
foreach (var reportFile in reportFiles)
{
File.Copy(reportFile, Path.Combine(reportSavePath, Path.GetFileName(reportFile)));
Copy(reportFile, Path.Combine(reportSavePath, Path.GetFileName(reportFile)), overwrite: true);
}

var reportFilePath =
Expand Down Expand Up @@ -635,7 +635,7 @@ private static async Task ApplyTemplatesAsync(
if (file.EndsWith(".template", StringComparison.OrdinalIgnoreCase)) continue;

var targetFilePath = Path.Combine(targetDirectoryPath, "IP", Path.GetFileName(file));
if (!File.Exists(targetFilePath)) File.Copy(file, targetFilePath);
Copy(file, targetFilePath, overwrite: false);
}
}

Expand Down Expand Up @@ -686,4 +686,15 @@ private static string GetXilinxDirectoryPathOrThrow()

return xilinxDirectoryPath;
}

private static void Copy(string from, string to, bool overwrite)
{
ArgumentNullException.ThrowIfNull(from);
ArgumentNullException.ThrowIfNull(to);

if (overwrite || !File.Exists(to))
{
File.Copy(from, to, overwrite: true);
}
}
}

0 comments on commit 9c25b9f

Please sign in to comment.