Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for compiling multi contracts in single csproj #953

Merged
merged 2 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Neo.Compiler.CSharp/CompilationEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,9 @@ public Compilation GetCompilation(string csproj)
{
string folder = Path.GetDirectoryName(csproj)!;
string obj = Path.Combine(folder, "obj");
string binSc = Path.Combine(Path.Combine(folder, "bin"), "sc");
HashSet<string> sourceFiles = Directory.EnumerateFiles(folder, "*.cs", SearchOption.AllDirectories)
.Where(p => !p.StartsWith(obj))
.Where(p => !p.StartsWith(obj) && !p.StartsWith(binSc))
.GroupBy(Path.GetFileName)
.Select(g => g.First())
.ToHashSet(StringComparer.OrdinalIgnoreCase);
Expand Down
17 changes: 16 additions & 1 deletion src/Neo.Compiler.CSharp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,22 @@ private static int ProcessSources(Options options, string folder, string[] sourc

private static int ProcessOutputs(Options options, string folder, List<CompilationContext> contexts)
{
return contexts.Select(p => ProcessOutput(options, folder, p)).Any(p => p != 1) ? 0 : 1;
int result = 0;
List<Exception> exceptions = new();
foreach (CompilationContext context in contexts)
try
{
if (ProcessOutput(options, folder, context) != 0)
result = 1;
}
catch (Exception e)
{
result = 1;
exceptions.Add(e);
}
foreach (Exception e in exceptions)
Console.Error.WriteLine(e.ToString());
return result;
}

private static int ProcessOutput(Options options, string folder, CompilationContext context)
Expand Down
Loading