2021-03-17 22:22:43 +00:00
|
|
|
/* ###
|
|
|
|
* 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.
|
|
|
|
*/
|
2019-04-09 15:59:17 +00:00
|
|
|
/*****************************************************************************************
|
|
|
|
This file is a "mix-in" gradle script that individual gradle projects should include if they
|
|
|
|
have content for the Ghidra help system. A gradle project can include help support by adding
|
|
|
|
the following to its build.gradle file.
|
2019-03-26 17:45:32 +00:00
|
|
|
|
2019-04-09 15:59:17 +00:00
|
|
|
apply from: "$rootProject.projectDir/gradle/helpProject.gradle"
|
2019-03-26 17:45:32 +00:00
|
|
|
|
2019-04-09 15:59:17 +00:00
|
|
|
Clients can register dependencies on other help modules by using the
|
|
|
|
'helpPath' configuration, like so:
|
2019-03-26 17:45:32 +00:00
|
|
|
|
|
|
|
helpPath project(path: ":Base", configuration: 'helpPath')
|
|
|
|
|
|
|
|
This example will put into the 'helpPath' configuration the project path of
|
|
|
|
'Base', using the value of it's 'helpPath' configuration. This brings us to the next
|
|
|
|
point--'helpPath' gets updated when the jar file is built to include the path of
|
|
|
|
the generated jar file. This allows future clients of a given help module to get
|
|
|
|
the jar file path of that help module's output.
|
|
|
|
|
2019-04-09 15:59:17 +00:00
|
|
|
*****************************************************************************************/
|
|
|
|
// The help modules must be configured first so that we can reference its runtime classpath
|
|
|
|
|
2019-03-26 17:45:32 +00:00
|
|
|
configurations {
|
|
|
|
// The Help Build System takes optional paths to resolve dependencies. Build files
|
|
|
|
// that use this 'script plugin' may put project paths into this variable.
|
|
|
|
helpPath
|
|
|
|
}
|
|
|
|
|
|
|
|
artifacts {
|
|
|
|
// The helpPath is updated to include the jar file output of the help build.
|
|
|
|
helpPath jar
|
|
|
|
}
|
|
|
|
|
|
|
|
sourceSets {
|
|
|
|
helpIndex {
|
|
|
|
java {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
main {
|
|
|
|
resources {
|
|
|
|
srcDir 'src/main/help'
|
|
|
|
srcDir 'build/help/main'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
2021-04-12 15:07:06 +00:00
|
|
|
helpIndexImplementation "javax.help:javahelp:2.0.05"
|
|
|
|
helpIndexImplementation project(':Help')
|
2019-03-26 17:45:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Task for calling the java help indexer, which creates a searchable index of the
|
|
|
|
// help contents.
|
|
|
|
task indexHelp(type: JavaExec) {
|
|
|
|
|
|
|
|
group "private"
|
2019-04-09 15:59:17 +00:00
|
|
|
description "indexes the helps files for this module. [gradle/helpProject.gradle]"
|
2019-03-26 17:45:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
File helpRootDir = file('src/main/help/help')
|
|
|
|
File outputFile = file("build/help/main/help/${project.name}_JavaHelpSearch")
|
|
|
|
|
|
|
|
dependsOn configurations.helpPath
|
|
|
|
|
|
|
|
inputs.dir helpRootDir
|
|
|
|
outputs.dir outputFile
|
|
|
|
|
|
|
|
classpath = sourceSets.helpIndex.runtimeClasspath
|
|
|
|
|
2021-10-22 11:05:09 +00:00
|
|
|
mainClass = 'com.sun.java.help.search.Indexer'
|
2019-03-26 17:45:32 +00:00
|
|
|
|
|
|
|
// tell the indexer where send its output
|
|
|
|
args '-db', outputFile.absolutePath
|
|
|
|
|
|
|
|
// The index has a config file parameter. The only thing we use in the config file
|
|
|
|
// is a root directory path that should be stripped off all the help references to
|
|
|
|
// make them relative instead of absolute
|
|
|
|
File configFile = file('build/helpconfig')
|
|
|
|
|
|
|
|
// gather up all the help files into a file collection
|
|
|
|
FileTree helpFiles = fileTree('src/main/help') {
|
|
|
|
include '**/*.htm'
|
|
|
|
include '**/*.html'
|
|
|
|
}
|
|
|
|
|
|
|
|
// pass the config file we created as an argument to the indexer
|
|
|
|
args '-c',"$configFile"
|
|
|
|
|
|
|
|
|
|
|
|
doFirst {
|
|
|
|
|
|
|
|
if (helpFiles.isEmpty()) {
|
|
|
|
// must have help to index
|
|
|
|
throw new GradleException("No help files found")
|
|
|
|
}
|
|
|
|
|
|
|
|
// create the config file when the task runs and not during configuration.
|
|
|
|
configFile.parentFile.mkdirs();
|
|
|
|
configFile.write "IndexRemove ${helpRootDir.absolutePath}" + File.separator + "\n"
|
|
|
|
|
|
|
|
// for each help file that was found, add it as an argument to the indexer
|
|
|
|
helpFiles.each { File file ->
|
|
|
|
args "${file.absolutePath}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Task for building Ghidra help files
|
|
|
|
// - depends on the output from the help indexer
|
|
|
|
task buildHelp(type: JavaExec, dependsOn: indexHelp) {
|
|
|
|
group rootProject.GHIDRA_GROUP
|
2019-04-09 15:59:17 +00:00
|
|
|
description " Builds the help for this module. [gradle/helpProject.gradle]\n"
|
2019-03-26 17:45:32 +00:00
|
|
|
|
|
|
|
File helpRootDir = file('src/main/help/help')
|
|
|
|
File outputDir = file('build/help/main/help')
|
|
|
|
|
|
|
|
inputs.dir helpRootDir
|
|
|
|
outputs.dir outputDir
|
|
|
|
|
2021-10-22 11:05:09 +00:00
|
|
|
mainClass = 'help.GHelpBuilder'
|
2019-03-26 17:45:32 +00:00
|
|
|
|
|
|
|
args '-n', "${project.name}" // use the module's name for the help file name
|
|
|
|
|
|
|
|
args '-o', "${outputDir.absolutePath}" // set the output directory arg
|
|
|
|
|
|
|
|
|
|
|
|
// args '-debug' // print debug info
|
|
|
|
|
|
|
|
doFirst {
|
2019-04-09 15:59:17 +00:00
|
|
|
// this modules runtime classpath (contains jhall.jar)
|
|
|
|
classpath project(':Help').sourceSets.main.runtimeClasspath
|
2019-03-26 17:45:32 +00:00
|
|
|
|
|
|
|
configurations.helpPath.each {
|
|
|
|
args "-hp"
|
|
|
|
args "${it.absolutePath}"
|
|
|
|
}
|
|
|
|
|
|
|
|
// The help dir to process. This needs to be the last argument to the process,
|
|
|
|
// thus, this is why it is inside of this block
|
|
|
|
args "${helpRootDir.absolutePath}"
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-04-24 21:48:44 +00:00
|
|
|
|
|
|
|
// Task for finding unused images that are not referenced from Ghidra help files
|
|
|
|
task findUnusedHelp(type: JavaExec) {
|
|
|
|
group rootProject.GHIDRA_GROUP
|
|
|
|
description " Finds unused help images for this module. [gradle/helpProject.gradle]\n"
|
|
|
|
|
|
|
|
File helpRootDir = file('src/main/help/help')
|
|
|
|
File outputDir = file('build/help/main/help')
|
|
|
|
|
|
|
|
dependsOn configurations.helpPath
|
|
|
|
|
|
|
|
inputs.dir helpRootDir
|
|
|
|
|
2021-10-22 11:05:09 +00:00
|
|
|
mainClass = 'help.validator.UnusedHelpImageFileFinder'
|
2019-04-24 21:48:44 +00:00
|
|
|
|
2019-04-24 22:01:31 +00:00
|
|
|
// args '-debug' // print debug info
|
2019-04-24 21:48:44 +00:00
|
|
|
|
|
|
|
doFirst {
|
|
|
|
classpath project(':Help').sourceSets.main.runtimeClasspath
|
|
|
|
|
|
|
|
// the current help dir to process
|
|
|
|
args "-hp"
|
|
|
|
args "${helpRootDir.absolutePath}"
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-03-26 17:45:32 +00:00
|
|
|
// include the help into the module's jar
|
|
|
|
jar {
|
2020-08-10 14:50:59 +00:00
|
|
|
duplicatesStrategy 'exclude'
|
2019-03-26 17:45:32 +00:00
|
|
|
from "build/help/main" // include the generated help index files
|
2019-04-24 21:48:44 +00:00
|
|
|
from "src/main/help" // include the help source files
|
2019-03-26 17:45:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// build the help whenever this module's jar file is built
|
2021-04-12 15:07:06 +00:00
|
|
|
processResources.dependsOn buildHelp
|
|
|
|
jar.dependsOn buildHelp
|
2019-04-09 15:59:17 +00:00
|
|
|
|
2019-03-26 17:45:32 +00:00
|
|
|
|
2019-04-09 15:59:17 +00:00
|
|
|
// make sure generated help directories exist during prepdev so that the directories are created and
|
|
|
|
// eclipse doesn't complain about missing src directories.
|
|
|
|
rootProject.prepDev.dependsOn buildHelp
|