Skip to content

Commit

Permalink
GP-1209: Support for building natives from a release.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanmkurtz committed Sep 27, 2021
1 parent af2d461 commit 3c07ca2
Show file tree
Hide file tree
Showing 22 changed files with 541 additions and 349 deletions.
23 changes: 3 additions & 20 deletions DevGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,33 +262,16 @@ You may see build path errors until the environment is properly prepared, as des
### Building the natives

Some of Ghidra's components are built for the native platform.
We currently support Linux, macOS, and Windows 64-bit x86 systems.
Others should be possible, but we do not test on them.
We currently support 64-bit Linux x86/ARM, macOS x86/ARM, and Windows x86.

Now build using Gradle:

On Linux:

```bash
gradle buildNatives_linux_x86_64
```

On macOS:
Build the natives for your current platform using Gradle:

```bash
gradle buildNatives_mac_x86_64
```

On Windows:

```bash
gradle buildNatives_win_x86_64
gradle buildNatives
```

This will build the decompiler, the demangler for GNU toolchains, the sleigh compiler, and (on Windows only) the PDB parser.

**NOTE:** `buildNatives_linux_arm_64` and `buildNatives_mac_arm_64` are also supported.

### Pre-compile Language Modules (optional)

Optionally, to pre-compile all the language modules, you may also execute:
Expand Down
3 changes: 0 additions & 3 deletions GPL/DMG/settings.gradle

This file was deleted.

3 changes: 0 additions & 3 deletions GPL/DemanglerGnu/settings.gradle

This file was deleted.

63 changes: 41 additions & 22 deletions GPL/nativeBuildProperties.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,27 @@ def shouldSkipNative(task) {
}

/*******************************************************************************************
* Task Rule : builds all the natives in this module for a given platform.
* Task Rule : buildNatives[_PlatformName]
*
* Example : gradle buildNatives_win_x86_64 will build all win_x86_64 native executables and shared libraries.
*
* NOTE: you must be on the appropriate platform for this to work.
* Summary: Builds all the natives in this module for a given platform.
*
* Args: PlatformName - The name of the platform. If not specified, the current platform is used.
*
* Example: gradle buildNatives_win_x86_64 will build all win_x86_64 native executables and shared libraries.
*
* NOTE: you must be on the appropriate platform for this to work.
******************************************************************************************/
tasks.addRule("Pattern: buildNatives_<platform name>]: build all natives for given platform") { String taskName ->
tasks.addRule("Pattern: buildNatives[_PlatformName]: build all natives for given platform") { String taskName ->

if (taskName.startsWith("buildNatives_")) {
String platform = taskName - "buildNatives_"
if (taskName.startsWith("buildNatives")) {
String currentPlatform = getCurrentPlatformName()
String platform = taskName - "buildNatives"
if (platform.length() == 0) {
platform = currentPlatform
}
if (platform.startsWith("_")) {
platform = platform - "_"
}

task(taskName) { myTask ->

Expand Down Expand Up @@ -157,20 +167,30 @@ tasks.addRule("Pattern: buildNatives_<platform name>]: build all natives for giv
}
}

/*******************************************************************************************
* Task Rule : builds all the natives in this module for a given platform and copies the
* results to the bin repo.
/*******************************************************************************************
* Task Rule : prebuildNatives[_PlatformName]
*
* Summary: Builds all the natives in this module for a given platform and copies the results
* to the bin repo.
*
* Example : gradle prebuildNatives_win_x86_64 will build all win_x86_64 native executables and shared
* libraries and copy the results to the appropriate project/os directory in the bin
* repo.
*
* NOTE: you must be on the appropriate platform for this to work.
* Args: PlatformName - The name of the platform. If not specified, the current platform is used.
*
* Example: gradle prebuildNatives_win_x86_64 will build all win_x86_64 native executables and
* shared libraries and copy the results to the appropriate project/os directory in
* the bin repo.
*
* NOTE: you must be on the appropriate platform for this to work.
******************************************************************************************/
tasks.addRule("Pattern: prebuildNatives_<platform name>]: build all natives for given platform") { String taskName ->
if (taskName.startsWith("prebuildNatives_")) {
String platform = taskName - "prebuildNatives_"
tasks.addRule("Pattern: prebuildNatives<_platform name>]: build all natives for given platform") { String taskName ->
if (taskName.startsWith("prebuildNatives")) {
def currentPlatform = getCurrentPlatformName()
def platform = taskName - "prebuildNatives"
if (platform.length() == 0) {
platform = currentPlatform
}
if (platform.startsWith("_")) {
platform = platform - "_"
}

task(taskName) { myTask ->
dependsOn "buildNatives_$platform"
Expand Down Expand Up @@ -214,8 +234,7 @@ gradle.taskGraph.whenReady {
}

/*****************************************************************************************
* The following block of code ensures that the buildNatives_<platform> task is used
* during assembly to ensure that missing toolchain generates an appropriate error
* The following block of code ensures that the buildNatives (for current plaform) task is
* used during assembly to ensure that missing toolchain generates an appropriate error
****************************************************************************************/
def currentPlatform = getCurrentPlatformName()
assemble.dependsOn "buildNatives_$currentPlatform"
assemble.dependsOn "buildNatives"
12 changes: 12 additions & 0 deletions GPL/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* ###
* IP: Public Domain
*/
// Recurse root project subdirectories and include all discovered projects
// (directories containing a build.gradle file)
fileTree(rootProject.projectDir) {
exclude 'build.gradle' // exclude root project
include '**/build.gradle'
}.each {
include it.parentFile.name;
project(":$it.parentFile.name").projectDir = it.parentFile;
}
14 changes: 1 addition & 13 deletions GPL/vsconfig.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
/* ###
* 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.
* IP: Public Domain
*/
/****************************************************************************
* Establish Visual Studio configuration environment for Windows native builds
Expand Down
Loading

0 comments on commit 3c07ca2

Please sign in to comment.