Skip to content
Snippets Groups Projects
Commit bc4f5979 authored by dgelessus's avatar dgelessus
Browse files

Allow passing extra arguments to SableCC

parent 684be05f
No related branches found
No related tags found
No related merge requests found
Pipeline #149078 passed
...@@ -50,6 +50,7 @@ You normally don't need to do this - all of these options have reasonable defaul ...@@ -50,6 +50,7 @@ You normally don't need to do this - all of these options have reasonable defaul
tasks.named("generateSableCCSource").configure { tasks.named("generateSableCCSource").configure {
sableCCClasspath = sourceSets.something.runtimeClasspath sableCCClasspath = sourceSets.something.runtimeClasspath
maxHeapSize = "512M" maxHeapSize = "512M"
arguments = ["--no-inline"]
// WARNING: The destination dirs will be DELETED every time the SableCC task runs! // WARNING: The destination dirs will be DELETED every time the SableCC task runs!
destinationJavaDir = "my/custom/out/java" destinationJavaDir = "my/custom/out/java"
destinationResourcesDir = "my/custom/out/resources" destinationResourcesDir = "my/custom/out/resources"
...@@ -62,6 +63,7 @@ tasks.named("generateSableCCSource").configure { ...@@ -62,6 +63,7 @@ tasks.named("generateSableCCSource").configure {
## Version 1.2.0 (not released yet) ## Version 1.2.0 (not released yet)
* Add ability to pass extra arguments to SableCC using the new `arguments` property of `SableCCTask`.
* Fix deprecation warnings on Gradle 8.12 about accessing `Project` at execution time. * Fix deprecation warnings on Gradle 8.12 about accessing `Project` at execution time.
## Version 1.1.0 ## Version 1.1.0
......
...@@ -6,6 +6,7 @@ import java.nio.file.Files; ...@@ -6,6 +6,7 @@ import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
import javax.inject.Inject; import javax.inject.Inject;
...@@ -35,6 +36,7 @@ public abstract class SableCCTask extends SourceTask { ...@@ -35,6 +36,7 @@ public abstract class SableCCTask extends SourceTask {
private FileCollection sableCCClasspath; private FileCollection sableCCClasspath;
private String maxHeapSize; private String maxHeapSize;
private List<String> arguments;
private final DirectoryProperty destinationJavaDir; private final DirectoryProperty destinationJavaDir;
private final DirectoryProperty destinationResourcesDir; private final DirectoryProperty destinationResourcesDir;
...@@ -47,6 +49,7 @@ public abstract class SableCCTask extends SourceTask { ...@@ -47,6 +49,7 @@ public abstract class SableCCTask extends SourceTask {
this.sableCCClasspath = null; this.sableCCClasspath = null;
this.maxHeapSize = null; this.maxHeapSize = null;
this.arguments = new ArrayList<>();
this.destinationJavaDir = objectFactory.directoryProperty(); this.destinationJavaDir = objectFactory.directoryProperty();
this.destinationResourcesDir = objectFactory.directoryProperty(); this.destinationResourcesDir = objectFactory.directoryProperty();
} }
...@@ -84,6 +87,15 @@ public abstract class SableCCTask extends SourceTask { ...@@ -84,6 +87,15 @@ public abstract class SableCCTask extends SourceTask {
this.maxHeapSize = maxHeapSize; this.maxHeapSize = maxHeapSize;
} }
@Input
public List<String> getArguments() {
return this.arguments;
}
public void setArguments(List<String> arguments) {
this.arguments = Objects.requireNonNull(arguments, "arguments");
}
@OutputDirectory @OutputDirectory
public Directory getDestinationJavaDir() { public Directory getDestinationJavaDir() {
return this.destinationJavaDir.get(); return this.destinationJavaDir.get();
...@@ -120,6 +132,7 @@ public abstract class SableCCTask extends SourceTask { ...@@ -120,6 +132,7 @@ public abstract class SableCCTask extends SourceTask {
List<String> args = new ArrayList<>(); List<String> args = new ArrayList<>();
args.add("-d"); args.add("-d");
args.add(destinationJavaPath.toString()); args.add(destinationJavaPath.toString());
args.addAll(this.getArguments());
for (File file : this.getSource().getFiles()) { for (File file : this.getSource().getFiles()) {
args.add(file.getPath()); args.add(file.getPath());
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment