GP-4235: Adding the means to build and find native components on FreeBSD

This commit is contained in:
Ryan Kurtz 2024-01-16 08:26:46 -05:00
parent 1281fb979b
commit d16747cf6c
8 changed files with 42 additions and 7 deletions

View File

@ -81,6 +81,7 @@ model {
targetPlatform "linux_arm_64"
targetPlatform "mac_x86_64"
targetPlatform "mac_arm_64"
targetPlatform "freebsd_x86_64"
sources {
c {
source {
@ -102,6 +103,7 @@ model {
targetPlatform "linux_arm_64"
targetPlatform "mac_x86_64"
targetPlatform "mac_arm_64"
targetPlatform "freebsd_x86_64"
sources {
c {
source {

View File

@ -52,6 +52,11 @@ model {
}
}
}
if (isCurrentFreeBSD()) {
gcc(Gcc) {
target("freebsd_x86_64")
}
}
if (isCurrentWindows() && VISUAL_STUDIO_INSTALL_DIR) {
// specify installDir because Gradle doesn't find VS Build Tools.
// See https://github.com/gradle/gradle-native/issues/617#issuecomment-575735288

View File

@ -24,7 +24,8 @@ project.ext.PLATFORMS = [
[name: "linux_x86_64", os: "linux", arch: "x86_64"],
[name: "linux_arm_64", os: "linux", arch: "arm64"],
[name: "mac_x86_64", os: "osx", arch: "x86_64"],
[name: "mac_arm_64", os: "osx", arch: "arm64"]
[name: "mac_arm_64", os: "osx", arch: "arm64"],
[name: "freebsd_x86_64", os: "freebsd", arch: "x86_64"]
]
/*********************************************************************************
@ -51,6 +52,9 @@ ext.getCurrentPlatformName = {
case ~/Mac OS X.*/:
os = "mac"
break
case ~/FreeBSD.*/:
os = "freebsd"
break
default:
throw new GradleException("Unrecognized platform operating system: $os")
}
@ -112,6 +116,20 @@ ext.isCurrentMac = {
return isMac(getCurrentPlatformName())
}
/*********************************************************************************
* Returns true if the given platform is FreeBSD.
*********************************************************************************/
ext.isFreeBSD = { platform_name ->
return platform_name.startsWith("freebsd")
}
/*********************************************************************************
* Returns true if the current platform is FreeBSD.
*********************************************************************************/
ext.isCurrentFreeBSD = {
return isFreeBSD(getCurrentPlatformName())
}
/*********************************************************************************
* Returns true if the given platform is Windows.
*********************************************************************************/

View File

@ -43,6 +43,7 @@ model {
targetPlatform "linux_arm_64"
targetPlatform "mac_x86_64"
targetPlatform "mac_arm_64"
targetPlatform "freebsd_x86_64"
sources {
cpp {
// NOTE: The bison/flex generated files are assumed to be up-to-date.
@ -148,6 +149,7 @@ model {
targetPlatform "linux_arm_64"
targetPlatform "mac_x86_64"
targetPlatform "mac_arm_64"
targetPlatform "freebsd_x86_64"
sources {
cpp {
// NOTE: The bison/flex generated files are assumed to be up-to-date.

View File

@ -65,6 +65,11 @@ public enum Platform {
*/
MAC_ARM_64(OperatingSystem.MAC_OS_X, Architecture.ARM_64, "mac_arm_64", ".dylib", ""),
/**
* Identifies a FreeBSD x86 64-bit OS.
*/
FREEBSD_X86_64(OperatingSystem.FREE_BSD, Architecture.X86_64, "freebsd_x86_64", ".so", ""),
/**
* Identifies an unsupported OS.
*/
@ -199,7 +204,8 @@ public enum Platform {
*/
public List<String> getAdditionalLibraryPaths() {
List<String> paths = new ArrayList<String>();
if (operatingSystem == OperatingSystem.LINUX) {
if (operatingSystem == OperatingSystem.LINUX ||
operatingSystem == OperatingSystem.FREE_BSD) {
paths.add("/bin");
paths.add("/lib");
paths.add("/lib64");

View File

@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -20,6 +19,7 @@ public enum OperatingSystem {
WINDOWS("Windows"),
LINUX("Linux"),
MAC_OS_X("Mac OS X"),
FREE_BSD("FreeBSD"),
UNSUPPORTED("Unsupported Operating System");
/**

View File

@ -225,6 +225,7 @@ public class ApplicationUtilities {
return createDir(switch (OperatingSystem.CURRENT_OPERATING_SYSTEM) {
case WINDOWS -> new File(getEnvFile("LOCALAPPDATA", true), appName);
case LINUX -> new File("/var/tmp/" + userDirName);
case FREE_BSD -> new File("/var/tmp/" + userDirName);
case MAC_OS_X -> new File("/var/tmp/" + userDirName);
default -> throw new FileNotFoundException(
"Failed to find the user cache directory: Unsupported operating system.");
@ -281,6 +282,7 @@ public class ApplicationUtilities {
return createDir(switch (OperatingSystem.CURRENT_OPERATING_SYSTEM) {
case WINDOWS -> new File(getEnvFile("APPDATA", true), versionedSubdir);
case LINUX -> new File(userHomeDir, ".config/" + versionedSubdir);
case FREE_BSD -> new File(userHomeDir, ".config/" + versionedSubdir);
case MAC_OS_X -> new File(userHomeDir, "Library/" + versionedSubdir);
default -> throw new FileNotFoundException(
"Failed to find the user settings directory: Unsupported operating system.");

View File

@ -18,7 +18,7 @@
<h1>Ghidra Installation Guide</h1>
<p>
The installation information provided is effective as of Ghidra 10.2 and is subject to change with
The installation information provided is effective as of Ghidra 11.1 and is subject to change with
future releases.
</p>
@ -310,20 +310,20 @@ Ghidra release includes native binaries for the following platforms:</p>
<li>Windows x86 64-bit</li>
<li>Linux x86 64-bit</li>
<li>macOS x86 64-bit</li>
<li>macOS ARM 64-bit (x86 using Rosetta translation)</li>
<li>macOS ARM 64-bit</li>
</ul>
<p>Ghidra supports running on the following additional platforms with user-built native binaries:
</p>
<ul>
<li>Linux ARM 64-bit</li>
<li>macOS ARM 64-bit (Apple silicon)</li>
<li>FreeBSD x86 64-bit (no debugger support)</li>
</ul>
<p>In order to build native binaries for your platform, you will need the following installed on your
system:</p>
<ul>
<li>A <a href="#Requirements">supported</a> version of a Java Development Kit</li>
<li><a href="https://gradle.org/releases/">Gradle 7.3+</a></li>
<li>make, gcc, and g++ (Linux/macOS-only)</li>
<li>make, gcc, and g++ (Linux/macOS/FreeBSD-only)</li>
<li>
<a href="https://visualstudio.microsoft.com/vs/community/">Microsoft Visual Studio</a>
2017 or later, or <a href="https://visualstudio.microsoft.com/visual-cpp-build-tools/">