Skip to content

Commit

Permalink
Enforce Python venv usage, install meson and ninja via venv pip
Browse files Browse the repository at this point in the history
  • Loading branch information
lhearachel committed Jan 2, 2025
1 parent 2f374fa commit de818fc
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 55 deletions.
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
42 changes: 26 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,10 @@ 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)

ifneq (,$(findstring Microsoft,$(UNAME_R)))
ifneq (,$(filter /mnt/%,$(CWD)))
WSL_ACCESSING_WINDOWS := 0
Expand Down Expand Up @@ -56,39 +60,45 @@ 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_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 requirements.txt

$(BUILD)/build.ninja: $(ROOT_INI) $(DOT_MWCONFIG) $(VENV_ACTIVATE) | $(BUILD)
MWCONFIG=$(abspath $(DOT_MWCONFIG)) $(VENV_MESON) setup \
--wrap-mode=nopromote \
--native-file=meson/$(NATIVE) \
--native-file=$(ROOT_INI) \
Expand Down Expand Up @@ -124,9 +134,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.*
ninja >= 1.11.*

0 comments on commit de818fc

Please sign in to comment.