ghidra/Ghidra/Framework/SoftwareModeling/build.gradle

91 lines
3.1 KiB
Groovy

apply from: "$rootProject.projectDir/gradle/distributableGhidraModule.gradle"
apply from: "$rootProject.projectDir/gradle/javaProject.gradle"
apply from: "$rootProject.projectDir/gradle/jacocoProject.gradle"
apply from: "$rootProject.projectDir/gradle/javaTestProject.gradle"
apply plugin: 'eclipse'
eclipse.project.name = 'Framework SoftwareModeling'
apply plugin: 'antlr'
// make sure antlr code gets built during prepdev so that the directories are created and
// eclipse doesn't complain about missing src directories.
rootProject.prepDev.dependsOn compileJava
dependencies {
compile project(':Generic')
compile project(':FileSystem')
compile project(':Project')
compile project(':Graph')
compile "msv:msv:20050913"
compile "msv:xsdlib:20050913"
compile "org.antlr:antlr-runtime:3.5.2"
runtime "msv:relaxngDatatype:20050913"
compile "msv:isorelax:20050913"
testCompile "org.jmockit:jmockit:1.44"
// Must specify the specific antlr implementation to use or it will default to trying to find
// version 2.7.7 (which we don't have)
antlr "org.antlr:antlr:3.5.2"
// need to add in the antlr dependencies for when we build from flat jar dirs
antlr "org.antlr:antlr-runtime:3.5.2"
antlr "org.antlr:ST4:4.0.8"
}
def genSrcDir = 'generated-src/antlr/main'
generateGrammarSource {
// This one stands alone, it looks like
include "ghidra/sleigh/grammar/BooleanExpression.g"
include "ghidra/sleigh/grammar/SleighLexer.g" // Dummy, and must compile first
include "ghidra/sleigh/grammar/BaseLexer.g"
include "ghidra/sleigh/grammar/DisplayLexer.g"
include "ghidra/sleigh/grammar/SemanticLexer.g"
// This is the root parser, it will import its children without building them individually.
include "ghidra/sleigh/grammar/SleighParser.g"
// This is a debug tree parser
include "ghidra/sleigh/grammar/SleighEcho.g"
// This is the real compiler tree parser
include "ghidra/sleigh/grammar/SleighCompiler.g"
// README: See src/main/antlr/ghidra/sleigh/grammar/README.txt for an explanation of this.
doFirst {
// Ensure that SleighLexar.tokens is rebuilt by removing it if any of the
// contributing grammar files have changed. Antlr plugin does not know
// about the SleighLexar.tokens dependency on changes to BaseLexer.g,
// DisplayLexer.g or SemanticLexer.g
delete file("$buildDir/${genSrcDir}/ghidra/sleigh/grammar/SleighLexer.tokens")
}
doLast {
// SleighLexar.g is only needed to produce SleighLexar.tokens.
// Remove its generated java artifacts which may conflict
delete fileTree("$buildDir/${genSrcDir}/ghidra/sleigh/grammar") {
include "SleighLexer*.java"
}
// antlr src directories cause generated java files to output
// into the correct package directories, however we need to add
// the appropriate java package statement which is missing.
fileTree("$buildDir/${genSrcDir}/ghidra/sleigh/grammar") {
include "*.java"
}.each { File src ->
def lines = src.readLines()
if (lines.get(0) != 'package ghidra.sleigh.grammar;') {
src.withWriter { wr ->
wr.println('package ghidra.sleigh.grammar;');
lines.each { line ->
wr.println line
}
}
}
}
}
}