ghidra/Ghidra/Features/Base/build.gradle
ghidra1 8f0589a6d8 GP-1403 Improved support for auto-named typedefs. Updated create
typedef action from pointer to use auto-naming.  Replaced old
ImageBaseOffsetDataType 32/64-bit BuiltIn types with new pointer-typedef
based implementations. Improved settings modification
restrictions.  Resolved various bugs.
2022-04-15 13:12:40 -04:00

192 lines
5.6 KiB
Groovy

/* ###
* IP: GHIDRA
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
apply from: "$rootProject.projectDir/gradle/distributableGhidraModule.gradle"
apply from: "$rootProject.projectDir/gradle/javaProject.gradle"
apply from: "$rootProject.projectDir/gradle/helpProject.gradle"
apply from: "$rootProject.projectDir/gradle/jacocoProject.gradle"
apply from: "$rootProject.projectDir/gradle/javaTestProject.gradle"
apply from: "$rootProject.projectDir/gradle/javadoc.gradle"
apply plugin: 'eclipse'
eclipse.project.name = 'Features Base'
rootProject.createJavadocs.exclude '**/ghidra/app/plugin/core/**'
rootProject.createJsondocs.exclude '**/ghidra/app/plugin/core/**'
/*
This build file is a bit different than most project build files, as it initializes
tools needed for the system to compile some of the code. Also, this module has
a bit of custom help file generation.
*/
configurations {
javacc
}
dependencies {
api project(':Utility')
api project(':Generic')
api project(':Docking')
api project(':Graph')
api project(':SoftwareModeling')
api project(':DB')
api project(':Help')
api 'org.apache.felix:org.apache.felix.framework:7.0.3'
api 'com.github.rotty3000:phidias:0.3.7'
api 'biz.aQute.bnd:biz.aQute.bnd.util:6.2.0'
api ('biz.aQute.bnd:biz.aQute.bndlib:6.2.0') {exclude group: 'org.osgi'}
api ('org.osgi:org.osgi.util.promise:1.2.0') {exclude group: 'org.osgi'}
api 'org.slf4j:slf4j-api:1.7.25'
runtimeOnly "org.slf4j:slf4j-nop:1.7.25"
// use this if you want slf4j log messages sent to log4j
// runtimeOnly "org.apache.logging.log4j:log4j-slf4j-impl:2.17.1"
compileOnly "junit:junit:4.12"
// These have abstract test classes and stubs needed by this module
testImplementation project(path: ':Docking', configuration: 'testArtifacts')
testImplementation project(path: ':Generic', configuration: 'testArtifacts')
testImplementation project(path: ':Project', configuration: 'testArtifacts')
testImplementation project(path: ':SoftwareModeling', configuration: 'testArtifacts')
testImplementation project(path: ':DB', configuration: 'testArtifacts')
javacc 'net.java.dev.javacc:javacc:5.0'
}
// add in the output of the javacc tasks to the java source
sourceSets {
main {
java {
srcDirs 'build/generated-src/javacc'
}
}
}
task buildCParser(type: JavaExec) {
group 'private'
description " Compiles the JavaCC files for the C parser\n"
def inputFile = "C.jj"
def packagePath = 'ghidra/app/util/cparser/C'
def srcDir = "src/main/javacc/${packagePath}"
inputs.files files("${srcDir}/${inputFile}")
def outputDir = "${projectDir}/build/generated-src/javacc/${packagePath}"
outputs.dir file("${outputDir}")
classpath = configurations.javacc
mainClass = 'javacc'
workingDir = "${srcDir}"
args "-OUTPUT_DIRECTORY=${outputDir}"
// args "-DEBUG_PARSER=true"
args "${inputFile}"
}
task buildCPPParser(type: JavaExec) {
group 'private'
description " Compiles the JavaCC files for the CPP parser\n"
def inputFile = "CPP.jj"
def packagePath = 'ghidra/app/util/cparser/CPP'
def srcDir = "src/main/javacc/${packagePath}"
inputs.files files("${srcDir}/${inputFile}")
def outputDir = "${projectDir}/build/generated-src/javacc/${packagePath}"
outputs.dir file("${outputDir}")
classpath = configurations.javacc
mainClass = 'javacc'
workingDir = "${srcDir}"
args "-OUTPUT_DIRECTORY=${outputDir}"
// args "-DEBUG_PARSER=true"
args "${inputFile}"
}
// A public task to tie together private sub-tasks
task buildJavacc {
dependsOn buildCParser, buildCPPParser
group rootProject.GHIDRA_GROUP
description " Compiles the JavaCC files\n"
}
// Note: this must happen before the standard buildHelp for Base
task generateExtraHelpFiles {
group = 'private'
description " Creates any extra help files for Base not covered by the standard build help system"
def rawTipsFile = file('src/main/resources/ghidra/app/plugin/core/totd/tips.txt')
inputs.file(rawTipsFile)
def htmlTipsFile = file('src/main/help/help/topics/Misc/Tips.htm')
outputs.file(htmlTipsFile)
doLast {
createTipsHelpFile(rawTipsFile, htmlTipsFile)
}
}
def createTipsHelpFile(input, output) {
// transform original contents - wrap each line in <li> tags
def buffy = new StringBuilder()
def rawLines = input.eachLine { line ->
def htmlized = line.replaceAll(/^(.*\w+.*)$/) { fullMatch, text -> "<li>$text</li><br>\n" }
buffy.append(htmlized)
}
// final output - wrap the updated content in the following HTML
def htmlContent = """\
<html>
<head>
<title>Ghidra Tips</title>
<link rel="stylesheet" type="text/css" href="../../shared/Frontpage.css" />
</head>
<body>
<h1><a name="Tips"></a>Ghidra Tips of the Day</h1>
<ul>
${buffy.toString()}
</ul>
</body>
</html>
"""
output.text = htmlContent
println '\n\n\nwrote file ' + output + '\n\n\n'
}
/*
Dependency Setup
*/
compileJava.dependsOn buildJavacc
rootProject.prepDev.dependsOn buildJavacc
// 'indexHelp' is defined in the buildHelp.gradle 'script plugin'
indexHelp.dependsOn generateExtraHelpFiles
zipSourceSubproject.dependsOn buildCPPParser
zipSourceSubproject.dependsOn buildCParser