From 3ff52f05b155de76f85541e1c4d3cc6ac71a4479 Mon Sep 17 00:00:00 2001 From: Ryan Kurtz Date: Mon, 18 Aug 2025 10:51:56 -0400 Subject: [PATCH] GP-5855: Always use TLB prebuild --- .../Debug/Debugger-agent-dbgeng/build.gradle | 97 +++++++++---------- 1 file changed, 45 insertions(+), 52 deletions(-) diff --git a/Ghidra/Debug/Debugger-agent-dbgeng/build.gradle b/Ghidra/Debug/Debugger-agent-dbgeng/build.gradle index 73e479bc74..c458d51fa1 100644 --- a/Ghidra/Debug/Debugger-agent-dbgeng/build.gradle +++ b/Ghidra/Debug/Debugger-agent-dbgeng/build.gradle @@ -28,63 +28,56 @@ dependencies { api project(':Debugger-rmi-trace') } -ext.tlb = file("build/os/win_x86_64/dbgmodel.tlb") +def tlb = file("build/os/win_x86_64/dbgmodel.tlb") +def depsFile = file("${DEPS_DIR}/Debugger-agent-dbgeng/dbgmodel.tlb") +def binRepoFile = file("${BIN_REPO}/${getGhidraRelativePath(project)}/os/win_x86_64/dbgmodel.tlb") -if ("win_x86_64".equals(getCurrentPlatformName())) { - - String makeName = "win_x86_64DbgmodelTlbMake" - task(type: Exec, makeName) { - ext.tmpBatch = file("build/buildTlb.bat") - ext.idl = file("src/main/py/src/ghidradbg/dbgmodel/DbgModel.idl") - inputs.file(idl) - outputs.file(tlb) - - doFirst { - file(tlb).parentFile.mkdirs() - def midlCmd = "midl /tlb \"${tlb}\" \"${idl}\"" - println "Executing: " + midlCmd - - tmpBatch.withWriter { out -> - out.println "call " + VISUAL_STUDIO_VCVARS_CMD - out.println midlCmd - } - } - doLast { - assert file(tlb).exists() : "Failed to build dbgmodel.tlb" - } - - commandLine "cmd", "/c", tmpBatch - } - - tasks.assemblePyPackage { - from(tasks."$makeName") { - into("src/ghidradbg/dbgmodel/tlb") - } - } -} -else if (file(tlb).exists()) { - // required for multi-platform build - tasks.assemblePyPackage { - from(tlb) { - println "Copying existing tlb build artifact: " + tlb - into("src/ghidradbg/dbgmodel/tlb") - } - } -} -else { - def depsFile = file("${DEPS_DIR}/Debugger-agent-dbgeng/dbgmodel.tlb") - def binRepoFile = file("${BIN_REPO}/${getGhidraRelativePath(project)}/os/win_x86_64/dbgmodel.tlb") +tasks.assemblePyPackage { def prebuiltTlb = depsFile.exists() ? depsFile : (binRepoFile.exists() ? binRepoFile : null) + assert prebuiltTlb != null : "Failed to locate prebuilt TLB file" - if (prebuiltTlb) { - tasks.assemblePyPackage { - from(prebuiltTlb) { - into("src/ghidradbg/dbgmodel/tlb") - } + from(prebuiltTlb) { + into("src/ghidradbg/dbgmodel/tlb") + } +} + +task buildTlb(type: Exec) { + assert isCurrentX86_64() && isCurrentWindows() : "Can only build TLB on Windows x86" + + def tmpBatch = file("build/buildTlb.bat") + def idl = file("src/main/py/src/ghidradbg/dbgmodel/DbgModel.idl") + + inputs.file(idl) + outputs.file(tlb) + + doFirst { + file(tlb).parentFile.mkdirs() + def midlCmd = "midl /tlb \"${tlb}\" \"${idl}\"" + println "Executing: " + midlCmd + + tmpBatch.withWriter { out -> + out.println "call " + VISUAL_STUDIO_VCVARS_CMD + out.println midlCmd } } - else { - println "****WARNING:**** dbgmodel.tlb omitted from ghidradbg python package" + + doLast { + assert file(tlb).exists() : "Failed to build dbgmodel.tlb" + } + + commandLine "cmd", "/c", tmpBatch +} + +task prebuildTlb(type: Copy) { + assert file(BIN_REPO).exists() : "Bin repo doesn't exist" + + dependsOn buildTlb + + from tlb + into binRepoFile.parentFile + + doFirst { + file(binRepoFile).parentFile.mkdirs() } }