mirror of
https://github.com/devkitPro/wut.git
synced 2026-03-21 17:34:47 -05:00
Move CMake machinery to devkitPro CMake
This commit is contained in:
parent
432c895f75
commit
4fcda4bd56
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
|
|
@ -27,7 +27,7 @@ jobs:
|
|||
run: |
|
||||
cd tests
|
||||
mkdir build && cd build
|
||||
cmake -DCMAKE_TOOLCHAIN_FILE=$DEVKITPRO/wut/share/wut.toolchain.cmake ../
|
||||
/opt/devkitpro/portlibs/wiiu/bin/powerpc-eabi-cmake ../
|
||||
make -j2
|
||||
|
||||
- name: Build Samples (Make)
|
||||
|
|
@ -39,5 +39,5 @@ jobs:
|
|||
run: |
|
||||
cd samples/cmake
|
||||
mkdir build && cd build
|
||||
cmake -DCMAKE_TOOLCHAIN_FILE=$DEVKITPRO/wut/share/wut.toolchain.cmake ../
|
||||
/opt/devkitpro/portlibs/wiiu/bin/powerpc-eabi-cmake ../
|
||||
make -j2
|
||||
|
|
|
|||
64
README.md
64
README.md
|
|
@ -1,79 +1,63 @@
|
|||
[](https://github.com/devkitPro/wut/actions?workflow=C%2FC%2B%2B+CI)
|
||||
|
||||
# wut
|
||||
Let's try make a Wii U Toolchain / SDK for creating rpx/rpl.
|
||||
Let's try to make a Wii U Toolchain / SDK for creating rpx/rpl.
|
||||
|
||||
Licensed under the terms of the GNU General Public License, version 2 or later (GPLv2+).
|
||||
|
||||
## Install
|
||||
|
||||
It is recommended to install wut by using the [devkitPro package manager](https://devkitpro.org/wiki/devkitPro_pacman)
|
||||
It is recommended to follow [devkitPro's Getting Started guide](https://devkitpro.org/wiki/Getting_Started),
|
||||
which will guide you through setting up a suitable homebrew development environment.
|
||||
[devkitPro Pacman](https://devkitpro.org/wiki/devkitPro_pacman) is exclusively used to manage installed
|
||||
homebrew development components.
|
||||
|
||||
For example you might do:
|
||||
The following command installs all necessary packages for Wii U homebrew development, including wut:
|
||||
```
|
||||
sudo dkp-pacman -Syu devkitPPC wut-tools wut
|
||||
(sudo) (dkp-)pacman -Syu --needed wiiu-dev
|
||||
```
|
||||
|
||||
## Usage
|
||||
See [samples](samples) for examples of how to use wut.
|
||||
|
||||
The [share/wut.cmake](share/wut.cmake) file provides some helpers for your build:
|
||||
devkitPro CMake provides some helpers for your build:
|
||||
- `wut_create_rpx(target)` - Will create an .rpx file from your CMake target generated by `add_executable`
|
||||
- `wut_create_rpl(target)` - Will create an .rpl file from your CMake target generated by `add_executable`
|
||||
- `wut_add_exports(target exports.def)` - Will add exports specified in exports.def for the given target
|
||||
|
||||
## Building from source
|
||||
Requires:
|
||||
- [devkitPPC](https://devkitpro.org/wiki/Getting_Started)
|
||||
- [wut-tools](https://github.com/devkitPro/wut-tools)
|
||||
|
||||
### Building with devkitPPC
|
||||
Ensure you have the devkitPPC and wut-tools packages provided by [devkitPro](https://devkitpro.org/wiki/Getting_Started):
|
||||
```
|
||||
sudo dkp-pacman -Syu devkitPPC wut-tools
|
||||
export DEVKITPRO=/opt/devkitpro
|
||||
export DEVKITPPC=/opt/devkitpro/devkitPPC
|
||||
```
|
||||
|
||||
Then it's as simple as running make or make install:
|
||||
```
|
||||
make
|
||||
make install
|
||||
```
|
||||
|
||||
### Building with a locally built wut-tools
|
||||
If you have locally built wut-tools then just add the directory containing the built binaries to PATH and they should be used instead:
|
||||
```
|
||||
export PATH=/path/to/wut-tools/bin:$PATH
|
||||
make
|
||||
```
|
||||
|
||||
## Building wut projects
|
||||
|
||||
### Building wut projects with make
|
||||
Simply export the required variables and call make.
|
||||
You can easily build any devkitPro Makefile based wut project with the following commands:
|
||||
```
|
||||
export DEVKITPRO=/opt/devkitpro
|
||||
export DEVKITPPC=/opt/devkitpro/devkitPPC
|
||||
cd samples/make/helloworld
|
||||
make
|
||||
```
|
||||
|
||||
### Building wut projects with CMake
|
||||
For any wut project you want to build with CMake you must use the wut.toolchain.cmake toolchain file:
|
||||
You can easily build any devkitPro CMake based wut project with the following commands:
|
||||
```
|
||||
export DEVKITPRO=/opt/devkitpro
|
||||
cd samples/cmake/helloworld
|
||||
mkdir build && cd build
|
||||
cmake -DCMAKE_TOOLCHAIN_FILE=$DEVKITPRO/wut/share/wut.toolchain.cmake ../
|
||||
/opt/devkitpro/portlibs/wiiu/bin/powerpc-eabi-cmake ../
|
||||
make
|
||||
```
|
||||
|
||||
A minimal CMakeLists.txt file for a C++ project might look like:
|
||||
```
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
cmake_minimum_required(VERSION 3.7)
|
||||
project(helloworld_cpp CXX)
|
||||
include("${DEVKITPRO}/wut/share/wut.cmake" REQUIRED)
|
||||
|
||||
add_executable(helloworld_cpp main.cpp)
|
||||
wut_create_rpx(helloworld_cpp.rpx helloworld_cpp)
|
||||
wut_create_rpx(helloworld_cpp)
|
||||
```
|
||||
|
||||
## Building from source
|
||||
|
||||
**It is strongly recommended to stick to stable released packages installed with devkitPro Pacman.**
|
||||
|
||||
Building wut is simple as running the following commands:
|
||||
```
|
||||
make
|
||||
(sudo -E) make install
|
||||
```
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
cmake_minimum_required(VERSION 3.2)
|
||||
set(CMAKE_TOOLCHAIN_FILE $ENV{DEVKITPRO}/wut/share/wut.toolchain.cmake)
|
||||
project(samples)
|
||||
include("${DEVKITPRO}/wut/share/wut.cmake" REQUIRED)
|
||||
|
||||
add_subdirectory(custom_default_heap)
|
||||
add_subdirectory(erreula)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
cmake_minimum_required(VERSION 3.2)
|
||||
project(custom_default_heap C)
|
||||
include("${DEVKITPRO}/wut/share/wut.cmake" REQUIRED)
|
||||
|
||||
add_executable(custom_default_heap
|
||||
main.c)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
cmake_minimum_required(VERSION 3.2)
|
||||
project(erreula CXX)
|
||||
include("${DEVKITPRO}/wut/share/wut.cmake" REQUIRED)
|
||||
|
||||
add_executable(erreula
|
||||
main.cpp)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
cmake_minimum_required(VERSION 3.2)
|
||||
project(gx2_triangle C)
|
||||
include("${DEVKITPRO}/wut/share/wut.cmake" REQUIRED)
|
||||
|
||||
add_executable(gx2_triangle
|
||||
main.c)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
cmake_minimum_required(VERSION 3.2)
|
||||
project(helloworld C)
|
||||
include("${DEVKITPRO}/wut/share/wut.cmake" REQUIRED)
|
||||
|
||||
add_executable(helloworld
|
||||
main.c)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
cmake_minimum_required(VERSION 3.2)
|
||||
project(helloworld_cpp CXX)
|
||||
include("${DEVKITPRO}/wut/share/wut.cmake" REQUIRED)
|
||||
|
||||
add_executable(helloworld_cpp
|
||||
main.cpp)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
cmake_minimum_required(VERSION 3.2)
|
||||
project(my_first_rpl C)
|
||||
include("${DEVKITPRO}/wut/share/wut.cmake" REQUIRED)
|
||||
|
||||
add_executable(my_first_rpl my_first_rpl.c)
|
||||
wut_add_exports(my_first_rpl exports.def)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
cmake_minimum_required(VERSION 3.2)
|
||||
project(swkbd CXX)
|
||||
include("${DEVKITPRO}/wut/share/wut.cmake" REQUIRED)
|
||||
|
||||
add_executable(swkbd
|
||||
main.cpp)
|
||||
|
|
|
|||
|
|
@ -1,59 +1,7 @@
|
|||
cmake_minimum_required(VERSION 3.2)
|
||||
|
||||
# Generates ${target}_exports.s from an exports file and adds it to the build
|
||||
function(wut_add_exports target exports_file)
|
||||
set(RPL_EXPORTS_FILE ${exports_file})
|
||||
if(NOT IS_ABSOLUTE ${exports_file})
|
||||
set(RPL_EXPORTS_FILE "${CMAKE_CURRENT_SOURCE_DIR}/${exports_file}")
|
||||
endif()
|
||||
|
||||
set(RPL_EXPORT_GEN_OUTPUT ${target}_exports.s)
|
||||
add_custom_command(
|
||||
OUTPUT ${RPL_EXPORT_GEN_OUTPUT}
|
||||
COMMAND ${WUT_RPLEXPORTGEN} ${RPL_EXPORTS_FILE} ${RPL_EXPORT_GEN_OUTPUT}
|
||||
DEPENDS ${RPL_EXPORTS_FILE})
|
||||
target_sources(${target} PRIVATE ${RPL_EXPORT_GEN_OUTPUT})
|
||||
set_source_files_properties(${RPL_EXPORT_GEN_OUTPUT} PROPERTIES LANGUAGE C)
|
||||
|
||||
set(RPL_IMPORT_GEN_OUTPUT ${target}_imports.s)
|
||||
set(RPL_IMPORT_GEN_LD ${target}_imports.ld)
|
||||
add_custom_command(
|
||||
OUTPUT ${RPL_IMPORT_GEN_OUTPUT} ${RPL_IMPORT_GEN_LD}
|
||||
COMMAND ${WUT_RPLIMPORTGEN} ${RPL_EXPORTS_FILE} ${RPL_IMPORT_GEN_OUTPUT} ${RPL_IMPORT_GEN_LD}
|
||||
DEPENDS ${RPL_EXPORTS_FILE})
|
||||
set_source_files_properties(${RPL_IMPORT_GEN_OUTPUT} PROPERTIES LANGUAGE C)
|
||||
add_library(${target}_imports STATIC ${RPL_IMPORT_GEN_OUTPUT})
|
||||
set_target_properties(${target}_imports PROPERTIES PREFIX "")
|
||||
get_filename_component(RPL_IMPORT_LINKER_SCRIPT ${target}_imports.ld REALPATH BASE_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
target_link_libraries(${target}_imports INTERFACE "-T${RPL_IMPORT_LINKER_SCRIPT}")
|
||||
endfunction()
|
||||
|
||||
function(wut_link_rpl target source)
|
||||
target_link_libraries(${target} ${source}_imports)
|
||||
endfunction()
|
||||
|
||||
function(wut_create_rpl target)
|
||||
set(RPL_OPTIONS IS_RPX)
|
||||
set(RPL_SINGLE_ARGS "")
|
||||
set(RPL_MULTI_ARGS "")
|
||||
cmake_parse_arguments(RPL "${RPL_OPTIONS}" "${RPL_SINGLE_ARGS}" "${RPL_MULTI_ARGS}" "${ARGN}")
|
||||
|
||||
if(RPL_IS_RPX)
|
||||
# Do nothing - the defaults are good for RPX
|
||||
set(RPL_SUFFIX "rpx")
|
||||
else()
|
||||
set(ELF2RPL_FLAGS ${ELF2RPL_FLAGS} --rpl)
|
||||
set_property(TARGET ${target} APPEND_STRING PROPERTY
|
||||
LINK_FLAGS "-specs=${WUT_ROOT}/share/rpl.specs")
|
||||
set(RPL_SUFFIX "rpl")
|
||||
endif()
|
||||
|
||||
add_custom_command(TARGET ${target} POST_BUILD
|
||||
COMMAND ${CMAKE_STRIP} -g $<TARGET_FILE:${target}>
|
||||
COMMAND ${WUT_ELF2RPL} ${ELF2RPL_FLAGS} $<TARGET_FILE:${target}> $<TARGET_FILE_DIR:${target}>/${target}.${RPL_SUFFIX}
|
||||
COMMENT "Creating ${target}.${RPL_SUFFIX}")
|
||||
endfunction()
|
||||
|
||||
function(wut_create_rpx)
|
||||
wut_create_rpl(${ARGV} IS_RPX)
|
||||
endfunction()
|
||||
message(DEPRECATION
|
||||
"The functionality provided by wut.cmake has moved to devkitPro CMake. "
|
||||
"Please remove the corresponding include() in your CMakeLists.txt. "
|
||||
"devkitPro CMake for Wii U can be invoked with the following wrapper script:\n"
|
||||
""
|
||||
"/opt/devkitpro/portlibs/wiiu/bin/powerpc-eabi-cmake"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,122 +1,8 @@
|
|||
cmake_minimum_required(VERSION 3.2)
|
||||
message(DEPRECATION
|
||||
"This toolchain file has been superseded by devkitPro CMake. "
|
||||
"devkitPro CMake for Wii U can be invoked with the following wrapper script:\n"
|
||||
""
|
||||
"/opt/devkitpro/portlibs/wiiu/bin/powerpc-eabi-cmake"
|
||||
)
|
||||
|
||||
set(CMAKE_SYSTEM_NAME Generic)
|
||||
set(CMAKE_SYSTEM_VERSION 1)
|
||||
set(CMAKE_SYSTEM_PROCESSOR "ppc")
|
||||
set(CMAKE_CROSSCOMPILING 1)
|
||||
|
||||
# Find DEVKITPRO
|
||||
if(NOT DEFINED ENV{DEVKITPRO})
|
||||
message(FATAL_ERROR "You must have defined DEVKITPRO before calling cmake.")
|
||||
endif()
|
||||
|
||||
set(DEVKITPRO $ENV{DEVKITPRO})
|
||||
|
||||
if(NOT DEFINED ENV{DEVKITPPC})
|
||||
set(DEVKITPPC $ENV{DEVKITPRO}/devkitPPC)
|
||||
else()
|
||||
set(DEVKITPPC $ENV{DEVKITPPC})
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED ENV{WUT_ROOT})
|
||||
set(WUT_ROOT $ENV{DEVKITPRO}/wut)
|
||||
else()
|
||||
set(WUT_ROOT $ENV{WUT_ROOT})
|
||||
endif()
|
||||
|
||||
# Setup root to exclude host system headers + libraries
|
||||
set(CMAKE_FIND_ROOT_PATH
|
||||
"${DEVKITPPC}"
|
||||
"${DEVKITPPC}/powerpc-eabi"
|
||||
"${DEVKITPRO}/tools"
|
||||
"${DEVKITPRO}/portlibs/wiiu"
|
||||
"${DEVKITPRO}/portlibs/ppc"
|
||||
"${WUT_ROOT}/share")
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||
|
||||
# Set pkg-config for the same
|
||||
find_program(PKG_CONFIG_EXECUTABLE NAMES powerpc-eabi-pkg-config HINTS "${DEVKITPRO}/portlibs/wiiu/bin")
|
||||
if (NOT PKG_CONFIG_EXECUTABLE)
|
||||
message(WARNING "Could not find powerpc-eabi-pkg-config: try installing wiiu-pkg-config")
|
||||
endif()
|
||||
|
||||
# Find compilers
|
||||
find_program(DEVKITPPC_GCC NAMES powerpc-eabi-gcc HINTS "${DEVKITPPC}/bin")
|
||||
if(NOT DEVKITPPC_GCC)
|
||||
message(FATAL_ERROR "Could not find powerpc-eabi-gcc")
|
||||
endif()
|
||||
|
||||
find_program(DEVKITPPC_GPP NAMES powerpc-eabi-g++ HINTS "${DEVKITPPC}/bin")
|
||||
if(NOT DEVKITPPC_GPP)
|
||||
message(FATAL_ERROR "Could not find powerpc-eabi-g++")
|
||||
endif()
|
||||
|
||||
find_program(DEVKITPPC_LD NAMES powerpc-eabi-ld HINTS "${DEVKITPPC}/bin")
|
||||
if(NOT DEVKITPPC_LD)
|
||||
message(FATAL_ERROR "Could not find powerpc-eabi-ld")
|
||||
endif()
|
||||
|
||||
find_program(DEVKITPPC_AR NAMES powerpc-eabi-ar HINTS "${DEVKITPPC}/bin")
|
||||
if(NOT DEVKITPPC_AR)
|
||||
message(FATAL_ERROR "Could not find powerpc-eabi-ar")
|
||||
endif()
|
||||
|
||||
find_program(DEVKITPPC_STRIP NAMES powerpc-eabi-strip HINTS "${DEVKITPPC}/bin")
|
||||
if(NOT DEVKITPPC_STRIP)
|
||||
message(FATAL_ERROR "Could not find powerpc-eabi-strip")
|
||||
endif()
|
||||
|
||||
set(CMAKE_ASM_COMPILER "${DEVKITPPC_GCC}" CACHE PATH "")
|
||||
set(CMAKE_C_COMPILER "${DEVKITPPC_GCC}" CACHE PATH "")
|
||||
set(CMAKE_CXX_COMPILER "${DEVKITPPC_GPP}" CACHE PATH "")
|
||||
set(CMAKE_LINKER "${DEVKITPPC_LD}" CACHE PATH "")
|
||||
set(CMAKE_AR "${DEVKITPPC_AR}" CACHE PATH "")
|
||||
set(CMAKE_STRIP "${DEVKITPPC_STRIP}" CACHE PATH "")
|
||||
|
||||
set(WUT_C_FLAGS "-mcpu=750 -meabi -mhard-float -Wl,-q -D__WIIU__ -D__WUT__")
|
||||
set(CMAKE_C_FLAGS "${WUT_C_FLAGS}" CACHE STRING "")
|
||||
set(CMAKE_CXX_FLAGS "${WUT_C_FLAGS}" CACHE STRING "")
|
||||
set(CMAKE_ASM_FLAGS "${WUT_C_FLAGS}" CACHE STRING "")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "\"-L${WUT_ROOT}/lib/stubs\" -specs=${WUT_ROOT}/share/wut.specs" CACHE STRING "")
|
||||
|
||||
set(WUT_STANDARD_LIBRARIES "\"${WUT_ROOT}/lib/libwut.a\"")
|
||||
set(CMAKE_C_STANDARD_LIBRARIES "${WUT_STANDARD_LIBRARIES}" CACHE STRING "")
|
||||
set(CMAKE_CXX_STANDARD_LIBRARIES "${WUT_STANDARD_LIBRARIES}" CACHE STRING "")
|
||||
set(CMAKE_ASM_STANDARD_LIBRARIES "${WUT_STANDARD_LIBRARIES}" CACHE STRING "")
|
||||
|
||||
#for some reason cmake (3.14.3) doesn't appreciate having \" here
|
||||
set(WUT_STANDARD_INCLUDE_DIRECTORIES "${WUT_ROOT}/include")
|
||||
set(CMAKE_C_STANDARD_INCLUDE_DIRECTORIES "${WUT_STANDARD_INCLUDE_DIRECTORIES}" CACHE STRING "")
|
||||
set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES "${WUT_STANDARD_INCLUDE_DIRECTORIES}" CACHE STRING "")
|
||||
set(CMAKE_ASM_STANDARD_INCLUDE_DIRECTORIES "${WUT_STANDARD_INCLUDE_DIRECTORIES}" CACHE STRING "")
|
||||
|
||||
# Find tools
|
||||
find_program(ELF2RPL_BIN NAMES elf2rpl HINTS "${DEVKITPRO}/tools/bin")
|
||||
if(NOT ELF2RPL_BIN)
|
||||
message(FATAL_ERROR "Could not find elf2rpl")
|
||||
endif()
|
||||
|
||||
find_program(RPLEXPORTGEN_BIN NAMES rplexportgen HINTS "${DEVKITPRO}/tools/bin")
|
||||
if(NOT RPLEXPORTGEN_BIN)
|
||||
message(FATAL_ERROR "Could not find rplexportgen")
|
||||
endif()
|
||||
|
||||
find_program(RPLIMPORTGEN_BIN NAMES rplimportgen HINTS "${DEVKITPRO}/tools/bin")
|
||||
if(NOT RPLIMPORTGEN_BIN)
|
||||
message(FATAL_ERROR "Could not find rplimportgen")
|
||||
endif()
|
||||
|
||||
# Tools
|
||||
set(WUT_ELF2RPL "${ELF2RPL_BIN}" CACHE PATH "")
|
||||
set(WUT_RPLEXPORTGEN "${RPLEXPORTGEN_BIN}" CACHE PATH "")
|
||||
set(WUT_RPLIMPORTGEN "${RPLIMPORTGEN_BIN}" CACHE PATH "")
|
||||
|
||||
# Flags
|
||||
set(WUT TRUE)
|
||||
set(WIIU TRUE)
|
||||
|
||||
# There is no shared lib support in devkitPPC
|
||||
set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "Shared libs not available")
|
||||
include(/opt/devkitpro/cmake/WiiU.cmake)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
cmake_minimum_required(VERSION 3.2)
|
||||
project(tests)
|
||||
include("${DEVKITPRO}/wut/share/wut.cmake" REQUIRED)
|
||||
|
||||
include_directories("test_compile_headers_common")
|
||||
add_subdirectory(test_compile_headers_as_c11)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
cmake_minimum_required(VERSION 3.2)
|
||||
project(test_compile_headers_as_c11 C)
|
||||
include("${DEVKITPRO}/wut/share/wut.cmake" REQUIRED)
|
||||
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
cmake_minimum_required(VERSION 3.2)
|
||||
project(test_compile_headers_as_c99 C)
|
||||
include("${DEVKITPRO}/wut/share/wut.cmake" REQUIRED)
|
||||
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
cmake_minimum_required(VERSION 3.2)
|
||||
project(test_compile_headers_as_cpp CXX)
|
||||
include("${DEVKITPRO}/wut/share/wut.cmake" REQUIRED)
|
||||
|
||||
add_executable(test_compile_headers_as_cpp
|
||||
main.cpp)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user