Skip to content

Commit

Permalink
added resources, generatedSources and verbose configuration flags to …
Browse files Browse the repository at this point in the history
…enable new checker
  • Loading branch information
jurgenvinju committed Mar 12, 2024
1 parent d2e503c commit 411aca8
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions src/main/java/org/rascalmpl/maven/CompileRascalMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ public class CompileRascalMojo extends AbstractMojo
@Parameter(defaultValue = "${project.build.outputDirectory}", property = "bin", required = true )
private String bin;

@Parameter(defaultValue = "${project.build.outputDirectory}", property = "resources", required = true)
private String resources;

// generatedSources
@Parameter(defaultValue = "${project.basedir}/generated-sources", property = "generatedSources", required = true)
private String generatedSources;

@Parameter(property = "srcs", required = true )
private List<String> srcs;

Expand All @@ -106,6 +113,9 @@ public class CompileRascalMojo extends AbstractMojo
@Parameter(property = "libs", required = false )
private List<String> libs;

@Parameter(defaultValue="false", property= "verbose", required=true)
private boolean verbose;

@Parameter(property = "errorsAsWarnings", required = false, defaultValue = "false" )
private boolean errorsAsWarnings;

Expand Down Expand Up @@ -133,6 +143,16 @@ private Evaluator makeEvaluator(OutputStream err, OutputStream out) throws URISy
public void execute() throws MojoExecutionException {
try {
ISourceLocation binLoc = MojoUtils.location(bin);
ISourceLocation resourcesLoc = MojoUtils.location(resources);

if (!binLoc.equals(resourcesLoc)) {
getLog().info("bin : " + binLoc);
getLog().info("resources: " + resourcesLoc);
getLog().error(new IllegalArgumentException("resources target must be equal to bin"));
throw new MojoExecutionException("Rascal compiler detected configuration errors");
}

ISourceLocation generatedSourcesLoc = MojoUtils.location(generatedSources);
List<ISourceLocation> srcLocs = MojoUtils.locations(srcs);
List<ISourceLocation> ignoredLocs = MojoUtils.locations(srcIgnores);
List<ISourceLocation> libLocs = MojoUtils.locations(libs);
Expand Down Expand Up @@ -182,7 +202,7 @@ public void execute() throws MojoExecutionException {

PathConfig pcfg = new PathConfig(srcLocs, libLocs, binLoc);

IList messages = runChecker(monitor, todoList, pcfg);
IList messages = runChecker(monitor, verbose, todoList, pcfg, resourcesLoc, generatedSourcesLoc);


getLog().info("checker is done, reporting errors now.");
Expand Down Expand Up @@ -269,12 +289,21 @@ public void write(int b) throws IOException {
}


private IList runChecker(IRascalMonitor monitor, IList todoList, PathConfig pcfg)
private IList runChecker(IRascalMonitor monitor, boolean verbose, IList todoList, PathConfig pcfg, ISourceLocation resourcesLoc, ISourceLocation generatedSourcesLoc)
throws IOException, URISyntaxException {
if (!parallel || todoList.size() <= 10 || parallelAmount() <= 1) {
getLog().info("Running checker in single threaded mode");
Evaluator eval = makeEvaluator(System.err, System.out);
IConstructor singleConfig = (IConstructor) eval.call("rascalCompilerConfig", pcfg.asConstructor());

IConstructor pcfgCons = pcfg.asConstructor()
.asWithKeywordParameters().setParameter("resources", resourcesLoc)
.asWithKeywordParameters().setParameter("generatedSources", generatedSourcesLoc);

IConstructor singleConfig = (IConstructor) eval.call("rascalCompilerConfig", pcfgCons);

singleConfig = singleConfig
.asWithKeywordParameters().setParameter("verbose", VF.bool(verbose));

return runCheckerSingle(monitor, todoList, eval, singleConfig);
}
ConcurrentSoftReferenceObjectPool<Evaluator> evaluators = createEvaluatorPool();
Expand Down

0 comments on commit 411aca8

Please sign in to comment.