Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add workflow #12

Merged
merged 3 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build
on:
pull_request:
push:
jobs:
gradle:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Install Ghidra
run: |
curl -L "$GHIDRA_URL" -o ghidra.zip
mkdir ~/ghidra
unzip ghidra.zip -d ~/ghidra
rm ghidra.zip
env:
GHIDRA_URL: https://github.com/NationalSecurityAgency/ghidra/releases/download/Ghidra_10.3.2_build/ghidra_10.3.2_PUBLIC_20230711.zip
- name: Execute Gradle build
run: ./gradlew
env:
GHIDRA_INSTALL_DIR: /home/runner/ghidra/ghidra_10.3.2_PUBLIC/
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
./dist/*.zip
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ dist/
.classpath
.antProperties.xml
/bin/
.idea/
lib/lz4-java-1.5.1.jar
36 changes: 19 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,28 @@ https://github.com/aldelaro5/ghidra-gekko-broadway-lang

The loader will fallback to the default PowerPC processor if the Gekko/Broadway language is not found, but do not expect good results if the program uses any paired single instructions.

# Usage

Install the extension using the `Install Extensions` option inside Ghidra.

Once the extension is installed, you can import a .rpx/.rpl file via `File->Import File...`.

# Building

```
cd /path/to/extension
export GHIDRA_INSTALL_DIR=/path/to/ghidra
gradle
```

Output goes into `dist`
## Building
- Ensure you have ``JAVA_HOME`` set to the path of your JDK 17 installation.
- Set ``GHIDRA_INSTALL_DIR`` to your Ghidra install directory. This can be done in one of the following ways:
- **Windows**: Running ``set GHIDRA_INSTALL_DIR=<Absolute path to Ghidra without quotations>``
- **macos/Linux**: Running ``export GHIDRA_INSTALL_DIR=<Absolute path to Ghidra>``
- Using ``-PGHIDRA_INSTALL_DIR=<Absolute path to Ghidra>`` when running ``./gradlew``
- Adding ``GHIDRA_INSTALL_DIR`` to your Windows environment variables.
- Run ``./gradlew``
- You'll find the output zip file inside `/dist`

## Installation
- Copy the zip file to ``<Ghidra install directory>/Extensions/Ghidra``.
- Start Ghidra and use the "Install Extensions" dialog to finish the installation. (``File -> Install Extensions...``).

## Usage
- Choose the `Gekko/Broadway/Espresso` language if asked

# Eclipse

To be able open this module in eclipse, you need to create a new Ghidra Module and copy the `.classpath`, `.project` and `.settings` to copy of this repository.
To be able open this module in eclipse, you need to create a new Ghidra Module and copy the `.classpath`, `.project` and `.settings` to the root of this repository.

# Credits

Based on https://github.com/Relys/rpl2elf
- Based on https://github.com/Relys/rpl2elf
- https://github.com/Cuyler36/Ghidra-GameCube-Loader
109 changes: 84 additions & 25 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
/* ###
* 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.
*/
// Builds a Ghidra Extension for a given Ghidra installation.
//
// An absolute path to the Ghidra installation directory must be supplied either by setting the
Expand Down Expand Up @@ -46,20 +31,94 @@ else {
throw new GradleException("GHIDRA_INSTALL_DIR is not defined!")
}
//----------------------END "DO NOT MODIFY" SECTION-------------------------------
jar {
duplicatesStrategy 'exclude'

def DISTRIBUTION_DIR = file("dist")
def PATH_IN_ZIP = "${project.name}"

def getGitHash = {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-parse', '--short', 'HEAD'
standardOutput = stdout
}
return stdout.toString().trim()
}

wrapper {
gradleVersion = '7.5.1'
distributionType = Wrapper.DistributionType.BIN
}

repositories {
// Declare dependency repositories here. This is not needed if dependencies are manually
// dropped into the lib/ directory.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html for more info.
// Ex: mavenCentral()
mavenCentral()
}

configurations {
localDeps
}

dependencies {
// Any external dependencies added here will automatically be copied to the lib/ directory when
// this extension is built.
implementation fileTree(dir: ghidraInstallDir + '/Ghidra/Processors', include: "**/*.jar")
localDeps group: 'org.lz4', name: 'lz4-java', version: '1.5.1'
implementation configurations.localDeps
}

buildExtension {
baseName "${project.name}-${project.version}-${getGitHash()}-Ghidra_${ghidra_version}".replace(' ', '_')
extension 'zip'
destinationDir DISTRIBUTION_DIR
version ''

// Make sure that we don't try to copy the same file with the same path into the
// zip (this can happen!)
duplicatesStrategy 'exclude'

// This filtered property file copy must appear before the general
// copy to ensure that it is prefered over the unmodified file
File propFile = new File(project.projectDir, "extension.properties")
from (propFile) {
String version = "${ghidra_version}"
String name = "${project.name}"
filter (org.apache.tools.ant.filters.ReplaceTokens, tokens: [extversion: version])
filter (org.apache.tools.ant.filters.ReplaceTokens, tokens: [extname: name])
into PATH_IN_ZIP
}

from (project.jar) {
into PATH_IN_ZIP + "/lib"
}

// Copy lz4 and any other dependencies that only we rely on
from (configurations.localDeps) {
into PATH_IN_ZIP + "/lib"
}

from (project.projectDir) {
exclude 'build/**'
exclude '*.gradle'
exclude 'certification.manifest'
exclude 'dist/**'
exclude 'bin/**'
exclude 'src/**'
exclude '.gradle/**'
exclude 'gradle/**'
exclude 'gradlew'
exclude 'gradlew.bat'
exclude '.classpath'
exclude '.project'
exclude '.settings/**'
exclude 'developer_scripts'
exclude '.antProperties.xml'
exclude 'eclipse/**'

into PATH_IN_ZIP
}

doLast {
println "\nCreated " + baseName + "." + extension + " in " + destinationDir
}
}

// Exclude additional files from the built extension
// Ex: buildExtension.exclude '.idea/**'
jar {
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
}
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version=0.8.1
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 5 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading