Skip to content

Compilation

Splendide Imaginarius edited this page Jan 13, 2024 · 5 revisions

Windows

You must install MSYS2. Afterwards:

  1. Launch any of the MSYS2 command prompts from your Start Screen.
  2. Type pacman -Syuu to begin updating MSYS. When the process is over, it will ask you to close the window.
  3. Open the MSYS2 MinGW 64-bit command prompt from your Start Screen. Type pacman -Syuu again, and allow it to finish updating.
pacman -S git ruby vim base-devel \
          mingw-w64-x86_64-cmake \
          mingw-w64-x86_64-meson \
          mingw-w64-x86_64-autotools \
          mingw-w64-x86_64-gcc

Next, clone mkxp-z's git repository, cd into your platform-specific directory, and run the build script:

git clone https://github.com/mkxp-z/mkxp-z
cd mkxp-z/windows
make

If everything succeeded, all you should need to do now is build mkxp-z itself.

# Export the variables necessary to find the stuff we built
source vars.sh

# Configure the build
cd ..; meson build

# Build the thing
cd build && ninja

# Copy dependent libraries to the same folder
# for fun and profit
cp ${MKXPZ_PREFIX}/bin/x64-msvcrt-ruby310.dll $PWD
cp /mingw64/bin/zlib1.dll $PWD

# (Remember you also need Steam's DLL if you configured with that)

# Strip it to save space
strip mkxp-z.exe

# Feast your eyes upon your work
start .

Linux

First, install the tools necessary to build all the dependencies:

Fedora 38

sudo dnf install git @development-tools gcc g++ libstdc++-static cmake meson autoconf automake libtool pkg-config ruby bison zlib-devel bzip2-devel xorg-x11-server-devel libXext-devel mesa-libGL-devel alsa-lib-devel pulseaudio-libs-devel perl-FindBin vim-common

Ubuntu

  • 18.04
sudo apt install git build-essential cmake autoconf automake libtool pkg-config ruby bison zlib1g-dev libbz2-dev xorg-dev lib32z1 libgl1-mesa-dev libasound2-dev python3-pip libpulse-dev xxd

# Meson from apt is too old, but also be sure not to get one too new
sudo python3 -m pip install meson==0.57.2 ninja==1.10.2
  • 20.04
sudo apt install git build-essential cmake autoconf automake libtool pkg-config ruby bison zlib1g-dev libbz2-dev xorg-dev libgl1-mesa-dev libasound2-dev libpulse-dev python3-pip xxd

# Meson from apt is too old, but also be sure not to get one too new
sudo python3 -m pip install meson==0.57.2 ninja==1.10.2
  • 22.04
sudo apt install git build-essential cmake meson autoconf automake libtool pkg-config ruby bison zlib1g-dev libbz2-dev xorg-dev libgl1-mesa-dev libasound2-dev libpulse-dev xxd

Next, clone mkxp-z's git repository, cd into your platform-specific directory, and run the build script:

git clone https://github.com/mkxp-z/mkxp-z
cd mkxp-z/linux
make

All you should need to do now is build mkxp-z itself.

# Export the variables necessary to find the stuff we built
source vars.sh

# Configure the build
cd ..; meson build

# Build the thing
cd build && ninja

# Feast your eyes upon your work
xdg-open .

Packaging

You have two options for grouping everything together to distribute: loose files or AppImage.

Loose

This will set up the executable to load dependencies from an adjacent lib/lib64 folder, so that it is easier to distribute.

# Set up the build to install everything locally
meson configure --bindir=. --prefix=$PWD/local

# Do the thing
ninja install

# See the thing
xdg-open $PWD/local

AppImage

This will package everything into an AppImage, making it so that the executable and all of its dependencies are contained within a single file (imagine if you had a completely static executable).

Firstly, you need to download AppImageTool. Keep note of where you stored it. Afterwards:

# Mark AppImageTool as executable
chmod +x PATH_TO_APPIMAGETOOL

# I wanna make an AppImage
meson configure --prefix=`mktemp -d` --bindir=usr/bin \
    -Dappimage=true -Dappimagekit_path=PATH_TO_APPIMAGETOOL

# Do the thing
ninja install

# See the thing
xdg-open .

macOS

Preparation

Follow this process to set up the Xcode project:

  1. Get Xcode. The full thing, not just the command line tools. You can get the current version from the App Store, or you can get an older version from Apple's archives if your machine does not support the newest version.
  2. Get Homebrew.
  3. After Xcode has been installed, open it and open the preferences window through either the menu bar or the ⌘+, keyboard shortcut.
  4. Move to the Locations tab and set Command Line Tools to your current version of Xcode.

To clone the repository, open up your terminal and run:

cd $HOME/Documents
git clone https://github.com/mkxp-z/mkxp-z
cd mkxp-z/macos/Dependencies
brew bundle

This will install the tools necessary to build the rest of mkxp-z's dependencies.

Next, you should only need to run the setup script:

./setup

There is also a script named setup.command in the parent directory. Running that or opening it through the Finder achieves the same effect.

Now you've got all that done, the rest is pretty simple. The repository has been cloned into your Documents folder, so you can either go there yourself, or type this last thing into the terminal: open ~/Documents/mkxp-z.

Building mkxp-z

for Debugging

  1. Open the Xcode project, and open the Schemes menu in the title bar.
  2. Select the scheme that is most relevant to you, as described on the Build Configuration page.
  3. Now, you can run the app by clicking the debug icon on either Xcode's sidebar, or your Touch Bar (if you have one).

for Release

  1. Select Product -> Archive from the menu bar.
  2. Once it has finished building the program, click Distribute App in the right sidebar, followed by Copy App in the prompt that appears. Save it anywhere you like.
  3. That's it. You can find the app wherever you told Xcode to export it.

Where do I put my files?

Game files should go into the Contents/Game subfolder of the app.

If you just wish to test the game without needing the files within the bundle, run:

export MKXPZ_FOLDER_SELECT=1
open -a path/to/the.app --args debug