Skip to content

Commit

Permalink
Switch metang to python implementation as temp-fix for native Windows…
Browse files Browse the repository at this point in the history
… builds
  • Loading branch information
lhearachel committed Jan 24, 2025
1 parent 08b09b8 commit 6c46f2e
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 93 deletions.
223 changes: 131 additions & 92 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -1,65 +1,33 @@
# Installation Instructions

<!--toc:start-->
- [Installation Instructions](#installation-instructions)
- [0. Preliminaries](#0-preliminaries)
- [1. Setting Up Your Development Environment](#1-setting-up-your-development-environment)
- [Windows with MSYS2](#windows-with-msys2)
- [Windows Subsystem for Linux](#windows-subsystem-for-linux)
- [New Installs](#new-installs)
- [Existing Installs](#existing-installs)
- [Install Build Dependencies](#install-build-dependencies)
- [MacOS](#macos)
- [Linux](#linux)
- [Ubuntu (and other Debian derivatives)](#ubuntu-and-other-debian-derivatives)
- [Arch Linux (and derivatives)](#arch-linux-and-derivatives)
- [Fedora (and derivatives)](#fedora-and-derivatives)
- [Docker](#docker)
- [2. Downloading the Repository](#2-downloading-the-repository)
- [3. Specifying a Compiler License](#3-specifying-a-compiler-license)
- [Windows (including WSL 1)](#windows-including-wsl-1)
- [Unix Systems](#unix-systems)
- [4. Building the Repository](#4-building-the-repository)
- [5. Debugger Support](#5-debugger-support)
- [Troubleshooting FAQ](#troubleshooting-faq)
- [My Build is Failing After Merging from Main](#my-build-is-failing-after-merging-from-main)
<!--toc:end-->

This document details the steps necessary to build a copy of Pokémon Platinum
(EN-US) using this repository.

## 0. Preliminaries
## Table of Contents

- [1. Setting Up Your Development Environment](#1-setting-up-your-development-environment)
- [Windows Subsystem for Linux](#windows-subsystem-for-linux)
- [New Installs](#new-installs)
- [Existing Installs](#existing-installs)
- [Install Build Dependencies](#install-build-dependencies)
- [Windows with MSYS2](#windows-with-msys2)
- [MacOS](#macos)
- [Linux](#linux)
- [Ubuntu (and other Debian derivatives)](#ubuntu-and-other-debian-derivatives)
- [Arch Linux (and derivatives)](#arch-linux-and-derivatives)
- [Fedora (and derivatives)](#fedora-and-derivatives)
- [Docker](#docker)
- [2. Downloading the Repository](#2-downloading-the-repository)
- [3. Specifying a Compiler License](#3-specifying-a-compiler-license)
- [Windows (including WSL 1)](#windows-including-wsl-1)
- [Unix Systems](#unix-systems)
- [4. Building the Repository](#4-building-the-repository)
- [5. Debugger Support](#5-debugger-support)
- [Troubleshooting FAQ](#troubleshooting-faq)
- [My Build is Failing After Merging from Main](#my-build-is-failing-after-merging-from-main)

## 1. Setting Up Your Development Environment

### Windows with MSYS2

1. Download the MSYS2 installer from [the official website](https://www.msys2.org/)
and install it on your system.

2. Once the installation is complete, a terminal should automatically pop up.
To update your package registry, enter the following command:

```bash
pacman -Syu
```

Press 'Y' when prompted to confirm the update. This process may take a few
minutes. Once completed, the terminal will automatically close.

3. Re-open an MSYS terminal (the pink icon) from your Start Menu, then enter
the following commands to install necessary build dependencies:

```bash
echo 'export PATH=${PATH}:/mingw64/bin' >> ~/.bashrc
source ~/.bashrc
pacman -S git meson gcc flex bison base-devel mingw-w64-x86_64-arm-none-eabi-{binutils,gcc}
```

Press 'Y' when prompted to confirm the installation.

4. [Download the repository](#2-downloading-the-repository).

### Windows Subsystem for Linux

> [!IMPORTANT]
Expand All @@ -73,29 +41,29 @@ the following commands to install necessary build dependencies:
Follow these instructions if you do not have an existing install of WSL.

1. Open [Windows PowerShell as Administrator](https://i.imgur.com/QKmVbP9.png).
Paste (Right Click or Shift+Insert) the following command:
Paste (Right Click or Shift+Insert) the following command:

```powershell
wsl --install -d Ubuntu
```
2. Once the process finishes, you will be prompted to restart your machine.
Accept.
Accept.
3. After rebooting, reopen PowerShell and run the following command to downgrade
WSL to version 1:
WSL to version 1:
```powershell
wsl --set-version Ubuntu 1
```
WSL version 1 is preferred for most WSL users due to its increased performance
when accessing files in the Windows file system.
when accessing files in the Windows file system.
4. Open `Ubuntu` from your Start menu.
5. `Ubuntu` will set up its own installation when it runs for the first time. Once
finished, it will ask for a username and password as input.
finished, it will ask for a username and password as input.
> [!NOTE]
> When typing the password, there will be no visible response; this is normal,
Expand All @@ -120,16 +88,16 @@ install to a more recent version of `Ubuntu`:
1. Run the following inside `Ubuntu`:
```bash
sudo apt upgrade && sudo apt full-upgrade
```
```bash
sudo apt upgrade && sudo apt full-upgrade
```

2. Open PowerShell and run the following commands to restart `Ubuntu`:

```powershell
wsl -t Ubuntu
wsl -d Ubuntu
```
```powershell
wsl -t Ubuntu
wsl -d Ubuntu
```

3. Re-open `Ubuntu` and run the following to start a system upgrade:

Expand All @@ -150,7 +118,7 @@ install to a more recent version of `Ubuntu`:
#### Install Build Dependencies
1. Run the following to install build dependencies from the `Ubuntu` package
registry:
registry:
```bash
sudo apt install git flex bison build-essential binutils-arm-none-eabi gcc-arm-none-eabi ninja-build
Expand All @@ -164,9 +132,9 @@ registry:
```
You may see `pip` respond with a warning saying `"The script meson is
installed in '/home/<YOUR_USER>/.local/bin', which is not on PATH.` To resolve
this issue, run the following commands, filling `<path/to/install/directory>`
with the path reported by `pip` above:
installed in '/home/<YOUR_USER>/.local/bin', which is not on PATH.`To resolve
this issue, run the following commands, filling `<path/to/install/directory>`
with the path reported by `pip` above:
```bash
echo 'export PATH="<path/to/install/directory>:$PATH"' >> ~/.bashrc
Expand All @@ -175,18 +143,54 @@ with the path reported by `pip` above:
3. [Download the repository](#2-downloading-the-repository).
### Windows with MSYS2
> [!CAUTION]
> `MSYS2 is known to currently produce a non-matching ROM; proceed at your own
> risk, and heavily prefer to build using Windows Subsystem for Linux, if at all
> possible.
If you are unable to run Windows Subsystem for Linux due to performance reasons
or lacking virtualization requirements, then MSYS2 may be an option for you.
1. Download the MSYS2 installer from [the official website](https://www.msys2.org/)
and install it on your system.
2. Once the installation is complete, a terminal should automatically pop up.
To update your package registry, enter the following command:
```bash
pacman -Syu
```
Press 'Y' when prompted to confirm the update. This process may take a few
minutes. Once completed, the terminal will automatically close.[]
3. Re-open an MSYS terminal (the pink icon) from your Start Menu, then enter
the following commands to install necessary build dependencies:
```bash
echo 'export PATH=${PATH}:/mingw64/bin' >> ~/.bashrc
source ~/.bashrc
pacman -S git meson gcc flex bison base-devel mingw-w64-x86_64-arm-none-eabi-{binutils,gcc}
```
Press 'Y' when prompted to confirm the installation.
4. [Download the repository](#2-downloading-the-repository).
### MacOS
1. Apple bundles a number of the requisite utilities into Xcode Command Line Tools;
to install these, run:
to install these, run:
```zsh
xcode-select --install
```
2. Additional packages can be installed using Homebrew; if you do not already have
Homebrew installed, [do so](https://brew.sh/). Once Homebrew is installed, run
the following commands:
Homebrew installed, [do so](https://brew.sh/). Once Homebrew is installed, run
the following commands:
```zsh
brew update
Expand All @@ -195,7 +199,7 @@ the following commands:
```
3. If your MacOS installation is Monterey (12) or earlier, then you may also need
GNU `coreutils` installed to run the build scripts:
GNU `coreutils` installed to run the build scripts:
```zsh
brew install coreutils
Expand All @@ -209,7 +213,7 @@ GNU `coreutils` installed to run the build scripts:
> Precise packages to be installed will vary by Linux distribution and
> package registry. A handful of common distributions are listed below for
> convenience.
>
> [!IMPORTANT]
> This project requires `meson` version `1.5.0` or higher. If the version of
> `meson` provided by your package manager is out of date, then follow
Expand All @@ -223,27 +227,27 @@ the repository](#2-downloading-the-repository).
1. Install `wine`:
```bash
sudo dpkg --add-architecture i386
sudo mkdir -pm755 /etc/apt/keyrings
sudo wget -O /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key
sudo apt update
sudo apt install --install-recommends wine-stable
```
```bash
sudo dpkg --add-architecture i386
sudo mkdir -pm755 /etc/apt/keyrings
sudo wget -O /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key
sudo apt update
sudo apt install --install-recommends wine-stable
```
2. Install the following packages via `apt`:
```bash
sudo apt install git flex bison ninja-build build-essential binutils-arm-none-eabi gcc-arm-none-eabi pkg-config
```
```bash
sudo apt install git flex bison ninja-build build-essential binutils-arm-none-eabi gcc-arm-none-eabi pkg-config
```
3. Install `meson` via `pip`:
```bash
pip3 install --user meson
echo "export PATH=~/.local/bin:$PATH" >> ~/.bashrc
source ~/.bashrc
```
```bash
pip3 install --user meson
echo "export PATH=~/.local/bin:$PATH" >> ~/.bashrc
source ~/.bashrc
```
#### Arch Linux (and derivatives)
Expand All @@ -261,6 +265,11 @@ sudo yum install git flex bison gcc make arm-none-eabi-bintuils-cs arm-none-eabi
### Docker
> [!CAUTION]
> The Docker build method is currently unmaintained and unsupported. Proceed at
> your own risk, and know that you may not receive much support from repository
> maintainers.
A `Dockerfile` is provided with the repository should you choose to build the
project as a container. If you do not have `docker` installed on your machine
and wish to make use of this feature, follow the instructions [here](https://docs.docker.com/desktop/).
Expand Down Expand Up @@ -306,10 +315,10 @@ then the value would be `C:\Users\myuser\Desktop\pokeplatinum\tools\cw\license.d
### Windows (including WSL 1)
1. Search for "environment variables" in the Start menu. Click the option which
says "Edit the system environment variables".
says "Edit the system environment variables".
2. In the window that opens, click the button that says "Environment Variables..."
in the lower right corner.
in the lower right corner.
3. In the window that opens, click "New..." in the lower right corner.
Expand Down Expand Up @@ -375,3 +384,33 @@ make update
```
And then try rebuilding.
### Meson Replies With `ERROR: Unknown compiler(s)`
Example error message:
```
meson.build:1:0: ERROR: Unknown compiler(s): [['/mnt/c/pokeplatinum/tools/cw/mwrap', 'mwccarm']]
```
Meson provides some basic logging for its configuration process in
`build/meson-logs/meson-log.txt`. In that file, you should see some entries that
begin with `Detecting compiler via: ...`, which will give some insight into the
root of the error. For example:
```
Detecting compiler via: `/mnt/c/pokeplatinum/tools/cw/mwrap mwccarm --version` -> 1
stderr:
wine: '/home/<USER>/.wine' is a 64-bit installation, it cannot be used with a 32-bit wineserver.
-----------
meson.build:1:0: ERROR: Unknown compiler(s): [['/mnt/c/pokeplatinum/tools/cw/mwrap', 'mwccarm']]
```
In this instance, the user has installed 64-bit `wine`. Ensure that you have
installed 32-bit `wine`, then rebuild _after_ removing the prefix directory
using the following command:
```
rm -rf ~/.wine
```
2 changes: 2 additions & 0 deletions generated/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

# This must be declared here instead of in tools/meson.build, as some tools depend
# on metang-generated constants.
subproject('metang')

metang_exe = find_program('metang', native: true)

enum_generators = {
Expand Down
2 changes: 1 addition & 1 deletion subprojects/metang.wrap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[wrap-git]
url = https://github.com/lhearachel/metang.git
revision = main
revision = python
depth = 1

[provide]
Expand Down

0 comments on commit 6c46f2e

Please sign in to comment.