ReXGlue SDK Documentation

repository·main·Indexed 20 days ago

https://github.com/rexglue/rexglue-sdk

An SDK designed to convert Xbox 360 PowerPC (PPC) code into portable C++ source code for native execution on modern hardware via ahead-of-time static recompilation. The SDK includes a filesystem API with the Entry class, application logic bases like XamApp, XgiApp, and XmpApp, and vendored components such as AES-128 and DirectXShaderCompiler (DXC) API headers.

Tokens
12.4K
Snippets
39
Records
56
Agent score
72%

What's inside ReXGlue SDK

  1. Overview of ReXGlue

    main
    ReXGlue is a tool that converts Xbox 360 PowerPC (PPC) code into portable C++ code. This allows the code to run natively on modern platforms. Unlike traditional emulators that use interpretation or JIT (Just-In-Time) compilation at runtime, ReXGlue uses a static recompilation approach: it generates C++ source code ahead of time. This methodology is inspired by projects like XenonRecomp and rexdex's recompiler.
  2. AES-128 Implementation Overview

    main

    This is a C implementation of the AES-128 algorithm. It provides several implementation styles within the repository:

    • Reference implementation (./aes.c): The primary implementation to read first.
    • Full unroll implementation (./unroll/aes.c): An unrolled version that is easier to understand after reading the reference.
    • Look up table (LUT) implementation (./lut/aes.c): A widely used software implementation style. This version requires a little-endian machine. It includes utility files for generating tables: gen_dec_key_table.c, gen_enc_table.c, and gen_dec_table.c.
  3. Understand ReXGlue SDK versioning and stability

    main

    The ReXGlue SDK uses an automated versioning system based on CMake's CMAKE_VERSION convention: MAJOR.MINOR[.PATCH[.TWEAK]][-id].

    Stability Rules:

    • Stable: Only versions without an -id trailer (e.g., 0.7.5) are considered stable and covered by the public API.
    • Unstable: Versions containing -dev or -rc trailers are unstable pre-releases.

    Version Derivation:

    • Tagged commits: The version is the tag verbatim (minus the leading v).
    • release/* branches: MAJOR.<floor-minor>.<tag-patch>.<commit-count>-rc.g<sha>.
    • development branch: MAJOR.<floor-minor>.<tag-patch>.<commit-count>-dev.g<sha>.

    Note on the 'API Floor': The CMakeLists.txt file defines the PROJECT VERSION MAJOR.MINOR.0. This 'floor' represents the minimum versioned API. The patch field in CMakeLists.txt is a placeholder and should not be used for routine releases.

  4. Perform a standard release of ReXGlue SDK

    main

    Follow these steps to cut and publish a standard release from the development branch:

    1. Cut the release branch

    Determine the next version (usually MAJOR.MINOR.<last-tag-patch + 1>). If the API floor was recently bumped, the next release is MAJOR.<new-floor-minor>.0.

    git fetch origin
    git checkout -b release/X.Y.Z origin/development
    git push -u origin release/X.Y.Z

    2. Open a Pull Request

    Open a PR from release/X.Y.Z into main.

    3. Merge and Tag

    Once the release is ready, merge the release branch into development first to ensure fixes flow back, then merge into main using a non-fast-forward merge commit.

    # Merge into development
    git checkout development
    git pull
    git merge --no-ff release/X.Y.Z -m "Merge release/X.Y.Z into development"
    git push origin development
    
    # Merge into main
    git checkout main
    git pull
    git merge --no-ff release/X.Y.Z -m "Release vX.Y.Z"
    git push origin main
    
    # Tag the release branch tip
    git tag vX.Y.Z release/X.Y.Z
    git push origin vX.Y.Z

    4. Cleanup

    Delete the release branch locally and remotely.

    git push origin --delete release/X.Y.Z
    git branch -d release/X.Y.Z
  5. How to bump the public API floor

    main

    The API floor should only be bumped when introducing a public API change. This is done via a single commit on the development branch:

    1. Edit CMakeLists.txt (specifically line 6) to update the PROJECT VERSION from 0.<old>.0 to 0.<new>.0.
    2. Use the commit message: chore: bump API floor to 0.<new>.

    After a floor bump, the next release branch will be release/0.<new>.0 and the corresponding tag will be v0.<new>.0.

    # In CMakeLists.txt
    PROJECT VERSION 0.8.0
  6. Download ReXGlue SDK builds

    main

    You can download the ReXGlue SDK through the official GitHub Releases page. There are two main channels available:

    • Release: The latest stable builds.
    • Nightly: The latest pre-release builds (experimental).

    Check the GitHub Releases page to select the appropriate version for your platform (Windows amd64, Linux amd64, or Linux arm64).

    # To find the latest stable release:
    # Visit https://github.com/rexglue/rexglue-sdk/releases/latest
  7. Perform a hotfix release

    main

    Hotfixes are used to fix issues in the current stable version without including new features from development.

    1. Branch from main: Unlike a normal release, a hotfix branch starts from the last stable tag (main) rather than the development tip.
    git fetch origin
    git checkout -b release/X.Y.Z origin/main
    1. Apply fix and merge: Apply the fix on the branch, open a PR into main, and merge into development first, then main (using --no-ff), following the standard release flow.

    2. Constraint: Only one release branch may exist at a time. If a regular release branch is currently open, you must close it without merging before cutting a hotfix. Re-cut the regular release from development after the hotfix is released.

  8. Test specification syntax in assembly files

    main

    The recompiler parses test specifications directly from .s assembly files using specific comment directives. A test spec is identified by a label followed by a colon, and its inputs/outputs are defined using REGISTER_IN, MEMORY_IN, REGISTER_OUT, and MEMORY_OUT directives.

    Directive Formats

    Registers

    • REGISTER_IN <reg> <value>
    • REGISTER_OUT <reg> <value>

    Supported register types include:

    • GPR: General Purpose Registers (e.g., r1 0x10)
    • Float: Floating point values (e.g., f1 1.5)
    • Vector: Vector registers using bracket notation (e.g., v1 [val0, val1, val2, val3])
    • Control: Control registers (e.g., cr 0)

    Memory

    • MEMORY_IN <address> <hex_bytes>
    • MEMORY_OUT <address> <hex_bytes>

    Example Assembly Test Spec

    my_test_label:
    # REGISTER_IN r1 0x10
    # REGISTER_IN v1 [1, 2, 3, 4]
    # MEMORY_IN 0x82010000 AA BB CC DD
    #
    # REGISTER_OUT r1 0x20
    # REGISTER_OUT v1 [5, 6, 7, 8]
    # MEMORY_OUT 0x82010000 EE FF
  9. Use migration scanning to upgrade SDK projects

    main

    The rexglue::cli namespace provides tools for scanning project trees to identify necessary changes when migrating to a newer version of the ReXGlue SDK. These scanners detect breaking changes, stale includes, template drift, and CMake reference mismatches.

    Key scanning capabilities include:

    • Breaking Change Detection: Identifies legacy tokens that must be replaced.
    • Call Site Pattern Matching: Scans for specific code patterns that require manual attention or updates.
    • Template Drift: Compares current project files against SDK templates to find discrepancies.
    • CMake & Include Analysis: Scans for outdated CMake references and stale #include directives.
  10. Scan for SDK migration breaking changes

    main

    The migration_scan logic provides tools to identify and automate the migration of projects when upgrading the ReXGlue SDK. It scans project trees for legacy identifiers, broken call sites, and stale includes, and can automatically generate rewrites for CMake files and source code headers.

    Key scanning capabilities include:

    • Legacy Identifier Replacement: Automatically replaces old macros/identifiers (e.g., PPC_HOOK $\rightarrow$ REX_HOOK) with their new counterparts.
    • Call Site Pattern Matching: Identifies problematic code patterns that require manual intervention (e.g., changes in function signatures or argument counts).
    • CMake Reference Updates: Updates CMakeLists.txt or .cmake files when filenames have changed.
    • Source Include Rewrites: Automatically updates #include statements when header files are renamed (e.g., *_config.h $\rightarrow$ *_init.h).
    • Stale Include Detection: Warns when a project includes headers that are no longer emitted by the SDK codegen.