Skip to content

Commit

Permalink
Fix separate compilation for ConstantsGen (#5630)
Browse files Browse the repository at this point in the history
A combination of commands triggered separate compilation that only recompiled part of builtins. A mechanism that workaround annotation processor's problems with separate compilation was updated to include changes from #4111. This was pretty tough to find given the rather unusual circumstances in CI.

# Important Notes
This eliminates the _random_ failures in CI related to separate compilation.
To reproduce a specific set of steps has to be executed:
```
sbt> all buildEngineDistribution engine-runner/assembly runtime/Benchmark/compile language-server/Benchmark/compile searcher/Benchmark/compile
(exit sbt)
sbt> test
```
  • Loading branch information
hubertp authored Feb 10, 2023
1 parent d1af257 commit 9ea9fd5
Showing 1 changed file with 17 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,19 +115,7 @@ protected void storeMetadata(Writer writer, Map<String, TypeMetadataEntry> pastE
for (Map.Entry<String, BuiltinTypeConstr> entry : builtinTypes.get(f).entrySet()) {
BuiltinTypeConstr constr = entry.getValue();
if (!constr.getFullName().isEmpty()) {
out.println(
" public static final String "
+ entry.getKey().toUpperCase()
+ " = \""
+ constr.getFullName()
+ "\";");

out.println(
" public static final String "
+ entry.getKey().toUpperCase() + "_BUILTIN"
+ " = "
+ toBuiltinName(constr.getFullName())
+ ";");
generateEntry(entry.getKey().toUpperCase(), constr.getFullName(), out);
}
}
}
Expand All @@ -136,21 +124,29 @@ protected void storeMetadata(Writer writer, Map<String, TypeMetadataEntry> pastE
.values()
.forEach(
entry ->
entry.stdlibName().ifPresent(n ->
out.println(
" public static final String "
+ entry.ensoName().toUpperCase()
+ " = \""
+ n
+ "\";")
)
entry.stdlibName().ifPresent(n -> generateEntry(entry.ensoName().toUpperCase(), n, out))
);

out.println();
out.println("}");
}
}

public void generateEntry(String name, String value, PrintWriter out) {
out.println(
" public static final String "
+ name
+ " = \""
+ value
+ "\";");
out.println(
" public static final String "
+ name + "_BUILTIN"
+ " = "
+ toBuiltinName(value)
+ ";");
}

private String toBuiltinName(String name) {
return "Constants.BUILTIN_NAMESPACE + \"." + name.substring(name.lastIndexOf('.') + 1) + "\"";
}
Expand Down

0 comments on commit 9ea9fd5

Please sign in to comment.