/* ### * 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(':SoftwareModeling') api project(':Emulation') api 'org.apache.felix:org.apache.felix.framework:7.0.5' api 'com.github.rotty3000:phidias:0.3.7' api 'biz.aQute.bnd:biz.aQute.bnd.util:7.0.0' api ('biz.aQute.bnd:biz.aQute.bndlib:7.0.0') {exclude group: 'org.osgi'} api ('org.osgi:org.osgi.util.promise:1.3.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.13.2" // 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 tasks.register('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('build/help/main/help/topics/Misc/Tips.htm') outputs.file(htmlTipsFile) doLast { createTipsHelpFile(rawTipsFile, htmlTipsFile) } } tasks.named('buildHelpFiles') { dependsOn(tasks.named('generateExtraHelpFiles')) inputs.files tasks.named('generateExtraHelpFiles').get().outputs doFirst { // Add the generated help path to the args passed to GHelpBuilder. Add the build dir that // contains the file generated in 'generateExtraHelpFiles': // def htmlTipsFile = file('build/help/main/help/topics/Misc/Tips.htm') // This file is needed to correctly generate help ID -> file mappings. args "-hpg" args file('build/help/main/help').toString() } } def createTipsHelpFile(input, output) { // transform original contents - wrap each line in
  • tags def buffy = new StringBuilder() def rawLines = input.eachLine { line -> def htmlized = line.replaceAll(/^(.*\w+.*)$/) { fullMatch, text -> "
  • $text

  • \n" } buffy.append(htmlized) } // final output - wrap the updated content in the following HTML def htmlContent = """\ Ghidra Tips

    Ghidra Tips of the Day

    """ output.text = htmlContent logger.info '\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