Skip to content

Commit

Permalink
Fixes for compiling multi contracts in single csproj (neo-project#953)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hecate2 authored and cschuchardt88 committed Mar 21, 2024
1 parent 64979c1 commit 5953f76
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
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

0 comments on commit 5953f76

Please sign in to comment.