Skip to content

Commit

Permalink
CMake Support
Browse files Browse the repository at this point in the history
- Add CMake toolchain file
- Add example for CMake
  • Loading branch information
SuperDude88 committed Aug 7, 2024
1 parent 74205ee commit 50f5556
Show file tree
Hide file tree
Showing 11 changed files with 515 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
run: |
docker run --rm -v ${PWD}:/src ghcr.io/wiiu-env/clang-format:13.0.0-2 -r ./plugins/example_plugin/src
docker run --rm -v ${PWD}:/src ghcr.io/wiiu-env/clang-format:13.0.0-2 -r ./plugins/example_plugin_cpp/src
docker run --rm -v ${PWD}:/src ghcr.io/wiiu-env/clang-format:13.0.0-2 -r ./plugins/example_plugin_cmake/src
docker run --rm -v ${PWD}:/src ghcr.io/wiiu-env/clang-format:13.0.0-2 -r ./plugins/storage_test_plugin/src --exclude ./plugins/storage_test_plugin/src/catch2
build-examples:
runs-on: ubuntu-22.04
Expand All @@ -44,6 +45,8 @@ jobs:
docker run --rm -v ${PWD}:/project builder make
cd ../example_plugin_cpp
docker run --rm -v ${PWD}:/project builder make
cd ../example_plugin_cmake
docker run --rm -v ${PWD}:/project builder /bin/bash -c "/opt/devkitpro/portlibs/wiiu/bin/powerpc-eabi-cmake -S . -B build && cd build && make"
cd ../storage_test_plugin
docker run --rm -v ${PWD}:/project builder make
- uses: actions/upload-artifact@master
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/push_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
docker run --rm -v ${PWD}:/src ghcr.io/wiiu-env/clang-format:13.0.0-2 -r ./plugins/storage_test_plugin/src --exclude ./plugins/storage_test_plugin/src/catch2
docker run --rm -v ${PWD}:/src ghcr.io/wiiu-env/clang-format:13.0.0-2 -r ./plugins/example_plugin/src
docker run --rm -v ${PWD}:/src ghcr.io/wiiu-env/clang-format:13.0.0-2 -r ./plugins/example_plugin_cpp/src
docker run --rm -v ${PWD}:/src ghcr.io/wiiu-env/clang-format:13.0.0-2 -r ./plugins/example_plugin_cmake/src
build-examples:
runs-on: ubuntu-22.04
needs: clang-format-examples
Expand All @@ -47,6 +48,8 @@ jobs:
docker run --rm -v ${PWD}:/project builder make
cd ../example_plugin_cpp
docker run --rm -v ${PWD}:/project builder make
cd ../example_plugin_cmake
docker run --rm -v ${PWD}:/project builder /bin/bash -c "/opt/devkitpro/portlibs/wiiu/bin/powerpc-eabi-cmake -S . -B build && cd build && make"
cd ../storage_test_plugin
docker run --rm -v ${PWD}:/project builder make
build-and-push-image:
Expand Down
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
loader/build/*
loader/WiiUPluginLoader.cbp
loader/*.elf
example_plugin/bin/*
example_plugin/build/*
example_plugin_pic/*
portlib_repos/*
plugins/*/bin/*
plugins/*/build/*
Expand All @@ -29,5 +26,4 @@ debug/
*.cbp
lib/
cmake-build-debug/
CMakeLists.txt
_site/
16 changes: 16 additions & 0 deletions plugins/example_plugin_cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
cmake_minimum_required(VERSION 3.2)

set(CMAKE_CXX_STANDARD 20)

include("$ENV{DEVKITPRO}/wups/share/wups.cmake" REQUIRED)

project(example_cmake C CXX)

if(DEFINED DEBUG)
add_compile_definitions(DEBUG)
endif()

add_executable(example_cmake src/main.cpp)
add_subdirectory("src/utils")

wups_create_plugin(example_cmake)
5 changes: 5 additions & 0 deletions plugins/example_plugin_cmake/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM ghcr.io/wiiu-env/devkitppc:20230218

COPY --from=ghcr.io/wiiu-env/wiiupluginsystem:20230215 /artifacts $DEVKITPRO

WORKDIR project
53 changes: 53 additions & 0 deletions plugins/example_plugin_cmake/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Example plugin

This is just a simple example plugin which can be used as a template.
The plugin logs the FSOpenFile calls via UDP (**Only when CMake is passed `-DDEBUG=1`**).

The logging can be enabled/disabled via the WUPS Config menu (press L, DPAD Down and Minus on the GamePad, Pro Controller or Classic Controller).

## Installation

(`[ENVIRONMENT]` is a placeholder for the actual environment name.)

1. Copy the file `ExamplePlugin.wps` into `sd:/wiiu/environments/[ENVIRONMENT]/plugins`.
2. Requires the [WiiUPluginLoaderBackend](https://github.com/wiiu-env/WiiUPluginLoaderBackend) in `sd:/wiiu/environments/[ENVIRONMENT]/modules`.

Start the environment (e.g Aroma) and the backend should load the plugin.

## Building

For building you need:

- [wups](https://github.com/Maschell/WiiUPluginSystem)
- [wut](https://github.com/devkitpro/wut)

Install them (in this order) according to their README's. Don't forget the dependencies of the libs itself.

Then you should be able to configure via `${DEVKITPRO}/portlibs/wiiu/bin/powerpc-eabi-cmake -S . -B build` (with no logging) or `${DEVKITPRO}/portlibs/wiiu/bin/powerpc-eabi-cmake -S . -B build -DDEBUG=1` (with logging), and build with `cd build && make`.

## Buildflags

### Logging

Building only logs errors by default (via OSReport). To enable logging via the [LoggingModule](https://github.com/wiiu-env/LoggingModule) set `DEBUG` to `1` or `VERBOSE`.

`DEBUG=1` Enables information and error logging via [LoggingModule](https://github.com/wiiu-env/LoggingModule).
`DEBUG=VERBOSE` Enables verbose information and error logging via [LoggingModule](https://github.com/wiiu-env/LoggingModule).

If the [LoggingModule](https://github.com/wiiu-env/LoggingModule) is not present, it'll fallback to UDP (Port 4405) and [CafeOS](https://github.com/wiiu-env/USBSerialLoggingModule) logging.

## Building using the Dockerfile

It's possible to use a docker image for building. This way you don't need anything installed on your host system.

```
# Build docker image (only needed once)
docker build . -t example-plugin-builder
# Configure + Build
docker run -it --rm -v ${PWD}:/project example-plugin-builder /bin/bash -c "/opt/devkitpro/portlibs/wiiu/bin/powerpc-eabi-cmake -S . -B build && cd build && make"
```

## Format the code via docker

`docker run --rm -v ${PWD}:/src ghcr.io/wiiu-env/clang-format:13.0.0-2 -r ./src -i`
Loading

0 comments on commit 50f5556

Please sign in to comment.