Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-0: Fixing Gradle deprecations

Ryan Kurtzc42735220177
diff --git a/GPL/nativeBuildProperties.gradle b/GPL/nativeBuildProperties.gradle
index 17ee3dfcb4..fcf093b91d 100644
--- a/GPL/nativeBuildProperties.gradle
+++ b/GPL/nativeBuildProperties.gradle
@@ -38,25 +38,25 @@ model {
// scenarios. These checks, can be removed when Gradle fixes them, and we advertise a
// minimum Gradle version that includes the fix.
toolChains {
- def current = getCurrentPlatformName()
- if (isLinux(current)) {
+ def current = rootProject.getCurrentPlatformName()
+ if (rootProject.isLinux(current)) {
// https://github.com/gradle/gradle/issues/17660 (fixed in Gradle 8.11)
gcc(Gcc).target(current)
clang(Clang).target(current)
}
- if (isFreeBSD(current)) {
+ if (rootProject.isFreeBSD(current)) {
// https://github.com/gradle/gradle/issues/32895
gcc(Gcc).target(current)
clang(Clang).target(current)
}
- if (isOpenBSD(current)) {
+ if (rootProject.isOpenBSD(current)) {
gcc(Gcc).target(current)
clang(Clang).target(current)
}
- if (isWindows(current) && VISUAL_STUDIO_INSTALL_DIR) {
+ if (rootProject.isWindows(current) && rootProject.VISUAL_STUDIO_INSTALL_DIR) {
// https://github.com/gradle/gradle-native/issues/617#issuecomment-575735288
visualCpp(VisualCpp) {
- installDir = VISUAL_STUDIO_INSTALL_DIR
+ installDir = rootProject.VISUAL_STUDIO_INSTALL_DIR
}
}
}
@@ -68,9 +68,9 @@ model {
task CheckToolChain {
// Native C/Cpp plugins will trigger failure if no tool chain found
doFirst {
- if (isCurrentWindows()) {
+ if (rootProject.isCurrentWindows()) {
// ensure that required MS Visual Studio is installed
- if (!VISUAL_STUDIO_INSTALL_DIR) {
+ if (!rootProject.VISUAL_STUDIO_INSTALL_DIR) {
throw new GradleException("Supported Windows native toolchain not found!");
}
}
@@ -131,7 +131,7 @@ def shouldSkipNative(task) {
tasks.addRule("Pattern: buildNatives[_PlatformName]: build all natives for given platform") { String taskName ->
if (taskName.startsWith("buildNatives")) {
- String currentPlatform = getCurrentPlatformName()
+ String currentPlatform = rootProject.getCurrentPlatformName()
String platform = taskName - "buildNatives"
if (platform.length() == 0) {
platform = currentPlatform
diff --git a/GPL/vsconfig.gradle b/GPL/vsconfig.gradle
index 25812838d9..d3ce97f742 100644
--- a/GPL/vsconfig.gradle
+++ b/GPL/vsconfig.gradle
@@ -9,7 +9,7 @@
* and SDKs are installed.
****************************************************************************/
-if (!hasProperty("VISUAL_STUDIO_INSTALL_DIR") && isCurrentWindows()) {
+if (!hasProperty("VISUAL_STUDIO_INSTALL_DIR") && rootProject.isCurrentWindows()) {
// Initialize variables
rootProject.ext.VISUAL_STUDIO_INSTALL_DIR = ""
diff --git a/Ghidra/Debug/Debugger-agent-dbgeng/build.gradle b/Ghidra/Debug/Debugger-agent-dbgeng/build.gradle
index 3a5f28b17c..a4398a787a 100644
--- a/Ghidra/Debug/Debugger-agent-dbgeng/build.gradle
+++ b/Ghidra/Debug/Debugger-agent-dbgeng/build.gradle
@@ -54,7 +54,7 @@ task buildTlb(type: Exec) {
outputs.file(tlb)
doFirst {
- assert isCurrentX86_64() && isCurrentWindows() : "Can only build TLB on Windows x86"
+ assert rootProject.isCurrentX86_64() && rootProject.isCurrentWindows() : "Can only build TLB on Windows x86"
file(tlb).parentFile.mkdirs()
def midlCmd = "midl /tlb \"${tlb}\" \"${idl}\""
println "Executing: " + midlCmd
diff --git a/Ghidra/Debug/Debugger-rmi-trace/build.gradle b/Ghidra/Debug/Debugger-rmi-trace/build.gradle
index 9dd8522d88..d8af359ea0 100644
--- a/Ghidra/Debug/Debugger-rmi-trace/build.gradle
+++ b/Ghidra/Debug/Debugger-rmi-trace/build.gradle
@@ -42,7 +42,7 @@ task configureGenerateProtoPy {
doLast {
def exe = configurations.protocArtifact.first()
- if (!isCurrentWindows()) {
+ if (!rootProject.isCurrentWindows()) {
exe.setExecutable(true)
}
generateProtoPy.commandLine exe
diff --git a/Ghidra/Extensions/bundle_examples/build.gradle b/Ghidra/Extensions/bundle_examples/build.gradle
index eb0b31dc45..f33e4d3e01 100644
--- a/Ghidra/Extensions/bundle_examples/build.gradle
+++ b/Ghidra/Extensions/bundle_examples/build.gradle
@@ -137,7 +137,7 @@ task zipExtensions(type: Zip, dependsOn:jarTasks) {
rootProject.createInstallationZip {
from (this.project.zipExtensions) {
into {
- ZIP_DIR_PREFIX + "/Extensions/Ghidra"
+ rootProject.ZIP_DIR_PREFIX + "/Extensions/Ghidra"
}
}
doLast {
diff --git a/Ghidra/Features/PDB/buildNatives.gradle b/Ghidra/Features/PDB/buildNatives.gradle
index ef5984eb81..08e74ec6cc 100644
--- a/Ghidra/Features/PDB/buildNatives.gradle
+++ b/Ghidra/Features/PDB/buildNatives.gradle
@@ -35,13 +35,13 @@ if ("win_x86_64".equals(rootProject.getCurrentPlatformName())) {
doFirst {
file("build/os/win_x86_64").mkdirs()
- def windowsTargetPlatformVersion = VISUAL_STUDIO_SDK_VERSION_OVERRIDE ?: VISUAL_STUDIO_SDK_VERSION_DEFAULT
+ def windowsTargetPlatformVersion = rootProject.VISUAL_STUDIO_SDK_VERSION_OVERRIDE ?: rootProject.VISUAL_STUDIO_SDK_VERSION_DEFAULT
def msbuildCmd = "msbuild ${solutionPathWindows} /p:Configuration=Release /p:WindowsTargetPlatformVersion=${windowsTargetPlatformVersion}"
println "Executing: " + msbuildCmd
new File(solutionBatchFilePath).withWriter { out ->
- out.println "call " + VISUAL_STUDIO_VCVARS_CMD
+ out.println "call " + rootProject.VISUAL_STUDIO_VCVARS_CMD
out.println msbuildCmd
}
}
diff --git a/Ghidra/Test/DebuggerIntegrationTest/build.gradle b/Ghidra/Test/DebuggerIntegrationTest/build.gradle
index 4dc68d4f4c..5cfcb97534 100644
--- a/Ghidra/Test/DebuggerIntegrationTest/build.gradle
+++ b/Ghidra/Test/DebuggerIntegrationTest/build.gradle
@@ -194,7 +194,7 @@ model {
linker.args("/SUBSYSTEM:windows", "/DYNAMICBASE", "/NXCOMPAT")
linker.args("shell32.lib");
}
- if (isWindows(targetPlatform.name)) {
+ if (rootProject.isWindows(targetPlatform.name)) {
cppCompiler.define("WIN32")
cCompiler.define("WIN32")
diff --git a/build.gradle b/build.gradle
index 091d4934f1..1fe84cac2e 100644
--- a/build.gradle
+++ b/build.gradle
@@ -478,7 +478,7 @@ String generateLibraryDependencyMapping() {
libsFile.withWriter { out ->
subprojects { p ->
p.plugins.withType(JavaPlugin) {
- List<String> libs = getExternalRuntimeDependencies(p);
+ List<String> libs = rootProject.getExternalRuntimeDependencies(p);
if (libs != null) {
out.println "Module: $p.name"
libs.each { path ->
diff --git a/gradle/distributableGhidraExtension.gradle b/gradle/distributableGhidraExtension.gradle
index fb029f2782..0e7eea409a 100644
--- a/gradle/distributableGhidraExtension.gradle
+++ b/gradle/distributableGhidraExtension.gradle
@@ -4,9 +4,9 @@
* 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.
@@ -30,7 +30,7 @@ apply from: "$rootProject.projectDir/gradle/support/extensionCommon.gradle"
rootProject.createInstallationZip {
from (this.project.zipExtensions) {
into {
- ZIP_DIR_PREFIX + "/Extensions/Ghidra"
+ rootProject.ZIP_DIR_PREFIX + "/Extensions/Ghidra"
}
}
doLast {
diff --git a/gradle/hasProtobuf.gradle b/gradle/hasProtobuf.gradle
index bc43484aa0..915030dc46 100644
--- a/gradle/hasProtobuf.gradle
+++ b/gradle/hasProtobuf.gradle
@@ -69,7 +69,7 @@ task configureGenerateProto {
doLast {
def exe = configurations.protocArtifact.first()
- if (!isCurrentWindows()) {
+ if (!rootProject.isCurrentWindows()) {
exe.setExecutable(true)
}
generateProto.commandLine exe, "--java_out=${generateProto.outdir}", "-I${generateProto.srcdir}"
diff --git a/gradle/root/venv.gradle b/gradle/root/venv.gradle
index 2074e671de..6deca334a3 100644
--- a/gradle/root/venv.gradle
+++ b/gradle/root/venv.gradle
@@ -20,8 +20,8 @@
******************************************************************************************/
task createPythonVirtualEnvironment(type: Exec) {
def venvDir = "build/venv"
- def binDir = isCurrentWindows() ? "Scripts" : "bin"
- def suffix = isCurrentWindows() ? ".exe" : "3"
+ def binDir = rootProject.isCurrentWindows() ? "Scripts" : "bin"
+ def suffix = rootProject.isCurrentWindows() ? ".exe" : "3"
project.ext.PYTHON3_VENV = "${rootProject.projectDir}/${venvDir}/${binDir}/python${suffix}"
project.ext.PIP3_VENV = "${rootProject.projectDir}/${venvDir}/${binDir}/pip${suffix}"
diff --git a/gradle/support/ip.gradle b/gradle/support/ip.gradle
index db3390049e..13c2b5e25e 100644
--- a/gradle/support/ip.gradle
+++ b/gradle/support/ip.gradle
@@ -115,7 +115,7 @@ def checkExternalLibsInMap(Map<String, String> map, Project project) {
* the map from the Module.manifest file
*********************************************************************************/
def checkExternalPythonWheelsInMap(Map<String, String> map, Project project) {
- PYTHON_DEPS.getOrDefault(project, List.of()).each { dep ->
+ rootProject.PYTHON_DEPS.getOrDefault(project, List.of()).each { dep ->
String name = dep.getName() // get just the filename without the path
String relativePath = "pypkg/dist/"+name;
assert map.containsKey(relativePath) : "No License specified for external python wheel: "+relativePath+ " in module "+project.projectDir