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

Enforce Python venv usage, install meson and ninja via venv pip #329

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
17 changes: 3 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,14 @@ on:

env:
LM_LICENSE_FILE: "${{ github.workspace }}/tools/cw/license.dat"
CALCROM_DISCORD_WEBHOOK_AVATAR_URL: "https://i.imgur.com/38BQHdd.png"
CALCROM_DISCORD_WEBHOOK_USERNAME: "OK"
CALCROM_WEBHOOK_URL: "${{ secrets.WEBHOOKURL }}"
BUILD: /var/tmp/pokeplatinum
WINEARCH: win32

jobs:
build:
permissions:
contents: write
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- name: Install Software
run: |
Expand All @@ -29,8 +27,7 @@ jobs:
sudo wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/$(lsb_release -cs)/winehq-$(lsb_release -cs).sources
sudo dpkg --add-architecture i386
sudo apt-get update -y
sudo apt-get install -y --install-recommends python3-pip ninja-build winehq-stable binutils-arm-none-eabi gcc-arm-none-eabi flex bison
pip install --user meson pyelftools
sudo apt-get install -y --install-recommends python3-pip wine32:i386 binutils-arm-none-eabi gcc-arm-none-eabi flex bison

- name: Checkout Repo
uses: actions/checkout@v2
Expand All @@ -41,14 +38,6 @@ jobs:
- name: Build Repo
run: make check

- name: Webhook
if: ${{ github.event_name == 'push' }}
env:
arm9name: ${{ vars.BUILD }}
run: |
.github/calcrom/webhook.sh "$CALCROM_WEBHOOK_URL" "$BUILD"
continue-on-error: true

- name: Checkout xMAP
if: ${{ github.event_name == 'push' }}
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ RUN apt-get update -y
RUN apt-get install -y --install-recommends winehq-stable
RUN python -m venv .venv
RUN . .venv/bin/activate
RUN pip install meson ninja
RUN pip install -r requirements.txt
COPY tools/cw/license.dat /etc/mwerks/license.dat
ENV LM_LICENSE_FILE=/etc/mwerks/license.dat
RUN hash -r
Expand Down
45 changes: 7 additions & 38 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ 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}
pacman -S git gcc flex bison base-devel mingw-w64-x86_64-arm-none-eabi-{binutils,gcc}
```

Press 'Y' when prompted to confirm the installation.
Expand Down Expand Up @@ -153,27 +153,10 @@ install to a more recent version of `Ubuntu`:
registry:

```bash
sudo apt install git flex bison build-essential binutils-arm-none-eabi gcc-arm-none-eabi ninja-build
sudo apt install git flex bison build-essential binutils-arm-none-eabi gcc-arm-none-eabi
```

2. Run the following to install additional dependencies via `pip`:

```bash
sudo apt install pip
pip install --user meson
```

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:

```bash
echo 'export PATH="<path/to/install/directory>:$PATH"' >> ~/.bashrc
source ~/.bashrc
```

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

### MacOS

Expand All @@ -190,7 +173,7 @@ the following commands:

```zsh
brew update
brew install gcc@14 meson libpng pkg-config arm-none-eabi-binutils arm-none-eabi-gcc
brew install gcc@14 libpng pkg-config arm-none-eabi-binutils arm-none-eabi-gcc
brew install --cask wine-stable
```

Expand All @@ -209,12 +192,6 @@ 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.3.0` or higher. If the version of
> `meson` provided by your package manager is out of date, then follow
> [these instructions](https://mesonbuild.com/Getting-meson.html) to get the
> most recent version.

Once you have installed all the above dependencies, proceed to [downloading
the repository](#2-downloading-the-repository).
Expand All @@ -234,29 +211,21 @@ the repository](#2-downloading-the-repository).
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
```

3. Install `meson` via `pip`:

```bash
pip3 install --user meson
echo "export PATH=~/.local/bin:$PATH" >> ~/.bashrc
source ~/.bashrc
sudo apt install git flex bison build-essential binutils-arm-none-eabi gcc-arm-none-eabi pkg-config
```

#### Arch Linux (and derivatives)

Install dependencies via `pacman`:

```bash
sudo pacman -S git flex bison build-essentials arm-none-eabi-binutils arm-none-eabi-gcc pkg-config wine meson
sudo pacman -S git flex bison build-essentials arm-none-eabi-binutils arm-none-eabi-gcc pkg-config wine
```

#### Fedora (and derivatives)

```bash
sudo yum install git flex bison gcc make arm-none-eabi-bintuils-cs arm-none-eabi-gcc-cs pkg-config wine meson ninja-build
sudo yum install git flex bison gcc make arm-none-eabi-bintuils-cs arm-none-eabi-gcc-cs pkg-config wine
```

### Docker
Expand Down
48 changes: 32 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: all release debug check rom target format clean distclean setup_release setup_debug configure
.PHONY: all release debug check rom target format clean distclean setup_release setup_debug configure venv

MESON ?= meson
NINJA ?= ninja
Expand All @@ -17,6 +17,14 @@ UNAME_R := $(shell uname -r)
UNAME_S := $(shell uname -s)
CWD := $(shell pwd)

VENV ?= .venv
VENV_ACTIVATE := $(VENV)/bin/activate
VENV_MESON := . $(VENV_ACTIVATE) ; $(MESON)
VENV_NINJA := . $(VENV_ACTIVATE) ; $(NINJA)
VENV_PIP := . $(VENV_ACTIVATE) ; pip

PIP_REQUIREMENTS := requirements.txt

ifneq (,$(findstring Microsoft,$(UNAME_R)))
ifneq (,$(filter /mnt/%,$(CWD)))
WSL_ACCESSING_WINDOWS := 0
Expand Down Expand Up @@ -56,39 +64,47 @@ release: setup_release rom

.NOTPARALLEL: debug
debug: setup_debug rom
$(MESON) compile -C $(BUILD) debug.nef overlay.map
$(VENV_MESON) compile -C $(BUILD) debug.nef overlay.map

check: rom
$(MESON) test -C $(BUILD)
$(VENV_MESON) test -C $(BUILD)

rom: $(BUILD)/build.ninja
$(MESON) compile -C $(BUILD) pokeplatinum.us.nds
$(VENV_MESON) compile -C $(BUILD) pokeplatinum.us.nds

target: $(BUILD)/build.ninja
$(MESON) compile -C $(BUILD) $(MESON_TARGET)
$(VENV_MESON) compile -C $(BUILD) $(MESON_TARGET)

format: $(BUILD)/build.ninja
$(NINJA) -C $(BUILD) clang-format
$(VENV_NINJA) -C $(BUILD) clang-format

clean: $(BUILD)/build.ninja
$(MESON) compile -C $(BUILD) --clean
$(VENV_MESON) compile -C $(BUILD) --clean

update: $(BUILD)/build.ninja
$(MESON) subprojects update
$(VENV_PIP) install --upgrade pip
$(VENV_PIP) install --upgrade -r $(PIP_REQUIREMENTS)
$(VENV_MESON) subprojects update

distclean:
rm -rf $(BUILD) $(MWRAP)
rm -rf $(BUILD) $(MWRAP) $(VENV)

setup_release: $(BUILD)/build.ninja
$(MESON) configure build -Dgdb_debugging=false
$(VENV_MESON) configure build -Dgdb_debugging=false

setup_debug: $(BUILD)/build.ninja
$(MESON) configure build -Dgdb_debugging=true
$(VENV_MESON) configure build -Dgdb_debugging=true

configure: $(BUILD)/build.ninja

$(BUILD)/build.ninja: $(ROOT_INI) $(DOT_MWCONFIG) | $(BUILD)
MWCONFIG=$(abspath $(DOT_MWCONFIG)) $(MESON) setup \
venv: $(VENV_ACTIVATE)

$(VENV_ACTIVATE):
python3 -m venv $(VENV)
. $(VENV_ACTIVATE) ; pip install -r $(PIP_REQUIREMENTS)

$(BUILD)/build.ninja: $(ROOT_INI) $(DOT_MWCONFIG) $(VENV_ACTIVATE) | $(BUILD)
. $(VENV_ACTIVATE) ; MWCONFIG=$(abspath $(DOT_MWCONFIG)) $(MESON) setup \
--wrap-mode=nopromote \
--native-file=meson/$(NATIVE) \
--native-file=$(ROOT_INI) \
Expand Down Expand Up @@ -124,9 +140,9 @@ endif
$(BUILD):
mkdir -p -- $(BUILD)

$(MWRAP):
$(MWRAP): $(VENV_ACTIVATE)
rm -rf $(MWRAP) $(WRAP_BUILD)
$(MESON) setup $(WRAP_BUILD) $(WRAP)
$(MESON) compile -C $(WRAP_BUILD)
$(VENV_MESON) setup $(WRAP_BUILD) $(WRAP)
$(VENV_MESON) compile -C $(WRAP_BUILD)
install -m755 $(WRAP_BUILD)/$(@F) $@
rm -rf $(WRAP_BUILD)
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
meson >= 1.3.0
ninja >= 1.11.0