Skip to content

Ghidra is a software reverse engineering (SRE) framework

3.7 KB
Raw Blame
/* ###
 * 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.
 */
// Not technically a Java project, but required to be a Help project
apply from: "${rootProject.projectDir}/gradle/javaProject.gradle"
apply from: "${rootProject.projectDir}/gradle/helpProject.gradle"
apply from: "$rootProject.projectDir/gradle/distributableGhidraModule.gradle"
apply from: "$rootProject.projectDir/gradle/nativeProject.gradle"
apply from: "$rootProject.projectDir/gradle/hasPythonPackage.gradle"

apply plugin: 'eclipse'
eclipse.project.name = 'Debug Debugger-agent-dbgeng'

dependencies {
	// Only for Help :/
	api project(':Debugger-rmi-trace')
}

def tlb = file("build/os/win_x86_64/dbgmodel.tlb")
def depsFile = file("${rootProject.DEPS_DIR}/Debugger-agent-dbgeng/dbgmodel.tlb")
def binRepoFile = file("${rootProject.BIN_REPO}/${rootProject.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"

	from(prebuiltTlb) {
		into("src/ghidradbg/dbgmodel/tlb")
	}
}

tasks.typeCheckPyPackage {
	environment("PYTHONPATH", project(":Debugger-rmi-trace").file("build/pypkg/src"))
}

task buildTlb(type: Exec) {

	def tmpBatch = file("build/buildTlb.bat")
	def idl = file("src/main/py/src/ghidradbg/dbgmodel/DbgModel.idl")
	
	inputs.file(idl)
	outputs.file(tlb)

	doFirst {
		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

		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
}

task prebuildTlb(type: Copy) {

	dependsOn buildTlb

	from tlb
	into binRepoFile.parentFile

	doFirst {
		assert file(rootProject.BIN_REPO).exists() : "Bin repo doesn't exist"
		file(binRepoFile).parentFile.mkdirs()
	}
}

distributePyDep("pybag-2.2.16-py3-none-any.whl")
distributePyDep("capstone-5.0.6-py3-none-win_amd64.whl")
distributePyDep("comtypes-1.4.13-py3-none-any.whl")
distributePyDep("pywin32-311-cp39-cp39-win_amd64.whl")
distributePyDep("pywin32-311-cp310-cp310-win_amd64.whl")
distributePyDep("pywin32-311-cp311-cp311-win_amd64.whl")
distributePyDep("pywin32-311-cp312-cp312-win_amd64.whl")
distributePyDep("pywin32-311-cp313-cp313-win_amd64.whl")
distributePyDep("pywin32-311-cp314-cp314-win_amd64.whl")
distributePyDep("win32more-0.7.0-py3-none-any.whl")
distributePyDep("win32more_appsdk-0.7.3-py2.py3-none-any.whl")
distributePyDep("win32more_core-0.7.0-py2.py3-none-any.whl")
distributePyDep("win32more_microsoft_graphics_win2d-0.7.1.3.2-py2.py3-none-any.whl")
distributePyDep("win32more_microsoft_web_webview2-0.7.1.0.3650.58-py2.py3-none-any.whl")
distributePyDep("win32more_microsoft_windows_sdk_contracts-0.7.10.0.26100.6901-py2.py3-none-any.whl")
distributePyDep("win32more_microsoft_windows_sdk_win32metadata-0.7.68.0.4-py2.py3-none-any.whl")
distributePyDep("win32more_microsoft_windowsappsdk-0.7.1.8.251106002-py2.py3-none-any.whl")