Skip to content

Commit 3c07ca2

Browse files
committed
GP-1209: Support for building natives from a release.
1 parent af2d461 commit 3c07ca2

File tree

22 files changed

+541
-349
lines changed

22 files changed

+541
-349
lines changed

DevGuide.md

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -262,33 +262,16 @@ You may see build path errors until the environment is properly prepared, as des
262262
### Building the natives
263263

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

268-
Now build using Gradle:
269-
270-
On Linux:
271-
272-
```bash
273-
gradle buildNatives_linux_x86_64
274-
```
275-
276-
On macOS:
267+
Build the natives for your current platform using Gradle:
277268

278269
```bash
279-
gradle buildNatives_mac_x86_64
280-
```
281-
282-
On Windows:
283-
284-
```bash
285-
gradle buildNatives_win_x86_64
270+
gradle buildNatives
286271
```
287272

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

290-
**NOTE:** `buildNatives_linux_arm_64` and `buildNatives_mac_arm_64` are also supported.
291-
292275
### Pre-compile Language Modules (optional)
293276

294277
Optionally, to pre-compile all the language modules, you may also execute:

GPL/DMG/settings.gradle

Lines changed: 0 additions & 3 deletions
This file was deleted.

GPL/DemanglerGnu/settings.gradle

Lines changed: 0 additions & 3 deletions
This file was deleted.

GPL/nativeBuildProperties.gradle

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,27 @@ def shouldSkipNative(task) {
108108
}
109109

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

120-
if (taskName.startsWith("buildNatives_")) {
121-
String platform = taskName - "buildNatives_"
123+
if (taskName.startsWith("buildNatives")) {
124+
String currentPlatform = getCurrentPlatformName()
125+
String platform = taskName - "buildNatives"
126+
if (platform.length() == 0) {
127+
platform = currentPlatform
128+
}
129+
if (platform.startsWith("_")) {
130+
platform = platform - "_"
131+
}
122132

123133
task(taskName) { myTask ->
124134

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

160-
/*******************************************************************************************
161-
* Task Rule : builds all the natives in this module for a given platform and copies the
162-
* results to the bin repo.
170+
/*******************************************************************************************
171+
* Task Rule : prebuildNatives[_PlatformName]
172+
*
173+
* Summary: Builds all the natives in this module for a given platform and copies the results
174+
* to the bin repo.
163175
*
164-
* Example : gradle prebuildNatives_win_x86_64 will build all win_x86_64 native executables and shared
165-
* libraries and copy the results to the appropriate project/os directory in the bin
166-
* repo.
167-
*
168-
* NOTE: you must be on the appropriate platform for this to work.
176+
* Args: PlatformName - The name of the platform. If not specified, the current platform is used.
169177
*
178+
* Example: gradle prebuildNatives_win_x86_64 will build all win_x86_64 native executables and
179+
* shared libraries and copy the results to the appropriate project/os directory in
180+
* the bin repo.
181+
*
182+
* NOTE: you must be on the appropriate platform for this to work.
170183
******************************************************************************************/
171-
tasks.addRule("Pattern: prebuildNatives_<platform name>]: build all natives for given platform") { String taskName ->
172-
if (taskName.startsWith("prebuildNatives_")) {
173-
String platform = taskName - "prebuildNatives_"
184+
tasks.addRule("Pattern: prebuildNatives<_platform name>]: build all natives for given platform") { String taskName ->
185+
if (taskName.startsWith("prebuildNatives")) {
186+
def currentPlatform = getCurrentPlatformName()
187+
def platform = taskName - "prebuildNatives"
188+
if (platform.length() == 0) {
189+
platform = currentPlatform
190+
}
191+
if (platform.startsWith("_")) {
192+
platform = platform - "_"
193+
}
174194

175195
task(taskName) { myTask ->
176196
dependsOn "buildNatives_$platform"
@@ -214,8 +234,7 @@ gradle.taskGraph.whenReady {
214234
}
215235

216236
/*****************************************************************************************
217-
* The following block of code ensures that the buildNatives_<platform> task is used
218-
* during assembly to ensure that missing toolchain generates an appropriate error
237+
* The following block of code ensures that the buildNatives (for current plaform) task is
238+
* used during assembly to ensure that missing toolchain generates an appropriate error
219239
****************************************************************************************/
220-
def currentPlatform = getCurrentPlatformName()
221-
assemble.dependsOn "buildNatives_$currentPlatform"
240+
assemble.dependsOn "buildNatives"

GPL/settings.gradle

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/* ###
2+
* IP: Public Domain
3+
*/
4+
// Recurse root project subdirectories and include all discovered projects
5+
// (directories containing a build.gradle file)
6+
fileTree(rootProject.projectDir) {
7+
exclude 'build.gradle' // exclude root project
8+
include '**/build.gradle'
9+
}.each {
10+
include it.parentFile.name;
11+
project(":$it.parentFile.name").projectDir = it.parentFile;
12+
}

GPL/vsconfig.gradle

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
11
/* ###
2-
* IP: GHIDRA
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
2+
* IP: Public Domain
153
*/
164
/****************************************************************************
175
* Establish Visual Studio configuration environment for Windows native builds

0 commit comments

Comments
 (0)