Skip to content

Commit

Permalink
Merge pull request #58 from ioo0s/master
Browse files Browse the repository at this point in the history
fix Decompiler build error
  • Loading branch information
ioo0s authored Oct 10, 2021
2 parents 55a5086 + 4fff8f4 commit 1ca1205
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 312 deletions.
195 changes: 0 additions & 195 deletions Ghidra/Features/Decompiler/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -365,201 +365,6 @@ task buildDecompilerDocumentationHtml(type: Exec) {
}
}

def getTargetArch() {

def arch = System.getenv("TARGET_ARCH")

if (arch == null) {
arch = System.getProperty("os.arch")
}

if (arch == "aarch64") {
return arch
} else if (arch == "amd64" || arch == "x86_64") {
return "x86_64"
} else {
throw new Exception("unsupported architecture ${arch}")
}
}

task win64BuildDecompilerRust(type: Exec) {
if (isCurrentWindows()) {
exec {
workingDir "./src/decompile"

def arch = null

try {
arch = getTargetArch()
} catch (Exception e) {
throw new TaskExecutionException(it, e)
}

def target = "${arch}-pc-windows-msvc"
commandLine 'cargo', 'build', '--release', '--target', target, '-Z', 'unstable-options', '--out-dir', '../../build/os/win_x86_64'
}
}
}

task linux64BuildDecompilerRust(type: Exec) {
if (isCurrentLinux()) {
exec {
workingDir "./src/decompile"

def out_path = null
def arch = null

try {
arch = getTargetArch()
} catch (Exception e) {
throw new TaskExecutionException(it, e)
}

if (arch == "aarch64") {
out_path = "../../build/os/linux_arm_64"
} else {
out_path = "../../build/os/linux_x86_64"
}

def target = "${arch}-unknown-linux-gnu"
commandLine 'cargo', 'build', '--release', '--target', target, '-Z', 'unstable-options', '--out-dir', out_path
}
}
}

task osx64BuildDecompilerRust(type: Exec) {
if (isCurrentMac()) {
exec {
workingDir "./src/decompile"
def out_path = null
def arch = null

try {
arch = getTargetArch()
} catch (Exception e) {
throw new TaskExecutionException(it, e)
}

if (arch == "aarch64") {
out_path = "../../build/os/mac_arm_64"
} else {
out_path = "../../build/os/mac_x86_64"
}

def target = "${arch}-apple-darwin"
commandLine 'cargo', 'build', '--release', '--target', target, '-Z', 'unstable-options', '--out-dir', out_path
}
}
}

model {

// Define the source files that are compiled and linked to become the decompiler.
// The decompiler source is a bit weird in that all the cpp and headers all live in
// the same directory with other files that are not used by the decompiler.
// That is why we have to list every cpp file that makes up the decomplier.
components {
sleigh(NativeExecutableSpec) {
targetPlatform "win_x86_64"
targetPlatform "linux_x86_64"
targetPlatform "linux_arm_64"
targetPlatform "mac_x86_64"
targetPlatform "mac_arm_64"
sources {
cpp {
// NOTE: The bison/flex generated files are assumed to be up-to-date.
// The task `generateParsers` should be executed if needed.
// builtBy lexSleigh
source {
srcDir "src/decompile/cpp"

include "space.cc"
include "float.cc"
include "address.cc"
include "pcoderaw.cc"
include "translate.cc"
include "opcodes.cc"
include "globalcontext.cc"
include "sleigh.cc"
include "pcodecompile.cc"
include "sleighbase.cc"
include "slghsymbol.cc"
include "slghpatexpress.cc"
include "slghpattern.cc"
include "semantics.cc"
include "context.cc"
include "filemanage.cc"
include "slgh_compile.cc"

// generated source files

include "xml.cc"
include "pcodeparse.cc"
include "slghparse.cc"
include "slghscan.cc"
}
exportedHeaders {
srcDir "src/decompile/cpp"
}
} // end cpp
} // end sources (sleigh)
} // end sleigh

} // end components

binaries {
all{ b ->
if (b.toolChain in Gcc) {
b.cppCompiler.define "GHIDRA_MAIN"

b.cppCompiler.args "-std=c++14"
b.cppCompiler.args "-Wall"
b.cppCompiler.args "-O2" // for DEBUG, comment this line out
// b.cppCompiler.args "-g" // for DEBUG, uncomment this line
b.cppCompiler.args "-Wno-sign-compare"
if (b.targetPlatform.operatingSystem.linux) {
// b.linker.args "-static"
b.cppCompiler.define "LINUX"
b.cppCompiler.define "_LINUX"
}
}
else if (b.toolChain in VisualCpp) {
b.cppCompiler.define "GHIDRA_MAIN"

b.cppCompiler.args "/EHsc"
b.cppCompiler.define "_SECURE_SCL=0"
b.cppCompiler.define "_HAS_ITERATOR_DEBUGGING=0"
// b.cppCompiler.args "/Zi" // for DEBUG, uncomment this line
// b.cppCompiler.args "/FS" // for DEBUG, uncomment this line
// b.linker.args "/DEBUG" // for DEBUG, uncomment this line
if (b.targetPlatform.operatingSystem.windows) {
b.cppCompiler.define "WINDOWS"
b.cppCompiler.define "_WINDOWS"
b.cppCompiler.define "WIN32"
b.cppCompiler.define "_WIN32"
if (b.targetPlatform.name == "win_x86_64") {
b.cppCompiler.define "WIN64"
b.cppCompiler.define "_WIN64"
}
}
}
else if (b.toolChain in Clang) {
b.cppCompiler.define "GHIDRA_MAIN"

b.cppCompiler.args "-std=c++14"
b.cppCompiler.args "-Wall"
b.cppCompiler.args "-O2" // for DEBUG, comment this line out
// b.cppCompiler.args "-g" // for DEBUG, uncomment this line
b.cppCompiler.args "-Wno-sign-compare"
b.cppCompiler.args "-w"
if (b.targetPlatform.operatingSystem.linux) {
// b.linker.args "-static"
}
}
}
}
} // end model

// Perform simple dependency change detection for generated files
// produced by bison or flex. A 5-second tolerance is used
// to avoid arbitrary last-modified times which may be produced
Expand Down
Loading

0 comments on commit 1ca1205

Please sign in to comment.