mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-22 04:05:39 +00:00
77 lines
3.1 KiB
Groovy
77 lines
3.1 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/support/ip.gradle"
|
|
|
|
// all application tests depend on all the sleigh processors to be built
|
|
tasks.withType(Test).all {
|
|
it.dependsOn ":allSleighCompile"
|
|
}
|
|
|
|
plugins.withType(JavaPlugin) {
|
|
task zipSourceSubproject (type: Zip) { t ->
|
|
|
|
// Define some metadata about the zip (name, location, version, etc....)
|
|
t.group 'private'
|
|
t.description "Creates the source zips for java modules"
|
|
t.archiveFileName = project.name + "-src.zip"
|
|
t.destinationDirectory = file(projectDir.path + "/build/tmp/src")
|
|
// Without this we get duplicate files but it's unclear why. It doesn't seem that this
|
|
// task is being executed multiple times, and sourceSets.main.java contains the
|
|
// correct elements. Whatever the cause, this fixes the problem.
|
|
duplicatesStrategy 'exclude'
|
|
|
|
from sourceSets.main.java
|
|
}
|
|
}
|
|
/*********************************************************************************
|
|
* Takes the given file and returns a string representing the file path with everything
|
|
* up-to and including 'src/global' removed, as well as the filename.
|
|
*
|
|
* eg: If the file path is '/Ghidra/Configurations/Common/src/global/docs/hello.html',
|
|
* the returned string will be at /docs
|
|
*
|
|
* Note: We have to use 'File.separator' instead of a slash ('/') because of how
|
|
* windows/unix handle slashes ('/' vs. '\'). We only need to do this in cases where we're
|
|
* using java string manipulation libraries (eg String.replace); Gradle already
|
|
* understands how to use the proper slash.
|
|
*********************************************************************************/
|
|
String getGlobalFilePathSubDirName(File file) {
|
|
|
|
// First strip off everything before 'src/global/ in the file path.
|
|
def slashIndex = file.path.indexOf('src' + File.separator + 'global')
|
|
String filePath = file.path.substring(slashIndex);
|
|
|
|
// Now remove 'src/global/' from the string.
|
|
filePath = filePath.replace('src' + File.separator + 'global' + File.separator, "");
|
|
|
|
// Now we need to strip off the filename itself, which we do by finding the last
|
|
// instance of a slash ('/') in the string.
|
|
//
|
|
// Note that it's possible there is no slash (all we have is a filename), meaning
|
|
// this file will be placed at the root level.
|
|
//
|
|
slashIndex = filePath.lastIndexOf(File.separator)
|
|
if (slashIndex != -1) {
|
|
filePath = filePath.substring(0, slashIndex+1) // +1 for the slash
|
|
}
|
|
else {
|
|
filePath = ""
|
|
}
|
|
|
|
return filePath
|
|
}
|
|
ext.getGlobalFilePathSubDirName = this.&getGlobalFilePathSubDirName
|