From 92cedbe684d5a9ac2ea5aa66d0c8a2787a822747 Mon Sep 17 00:00:00 2001 From: James Date: Wed, 20 Nov 2019 12:23:22 +0000 Subject: [PATCH] Update README.md --- README.md | 81 +++++++++++++++++++++++++------------------------------ 1 file changed, 36 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index 9d4abc8..ecb2e38 100644 --- a/README.md +++ b/README.md @@ -19,37 +19,13 @@ See [samples](samples) for examples of how to use wut. The [share/wut.cmake](share/wut.cmake) file provides several helpers for your build: - `wut_create_rpx(target.rpx executable)` - Will create an .rpx file from your CMake target generated by `add_executable` -- `wut_enable_newlib(target)` - Links against the wut implementation of newlib, this is useful for using any function from the C standard library -- `wut_enable_stdcpp(target)` - Links against the wut implementation of stdcpp, this is useful for using any function from the C++ standard library. This will call wut_enable_newlib if you have not already done so. -- `wut_default_malloc(target)` - By default newlib will allocate 90% of the default heap for use with sbrk & malloc, if this is unacceptable to you then you should use this as it replaces the newlib malloc functions which ones which redirect to the CafeOS default heap functions such as MEMAllocFromDefaultHeap. -- `wut_enable_devoptab(target)` - This links in wutdevoptab which is useful for using the libc file functions with paths such as `fopen("sd:/file.txt", "r")` to read files from the sd card +- `wut_create_rpl(target.rpl executable)` - 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 target -A minimal CMakeLists.txt file for a C++ project might look like: -``` -cmake_minimum_required(VERSION 3.2) -project(helloworld_cpp CXX) -include("${WUT_ROOT}/share/wut.cmake" REQUIRED) - -add_executable(helloworld_cpp - main.cpp) - -wut_enable_stdcpp(helloworld_cpp) -wut_create_rpx(helloworld_cpp.rpx helloworld_cpp) -``` - -Which you would compile with -``` -export DEVKITPPC=/opt/devkitpro/devkitPPC -export WUT_ROOT= -mkdir build && cd build -cmake -DCMAKE_TOOLCHAIN_FILE=$WUT_ROOT/share/wut.toolchain.cmake ../ -make -``` - -## Building +## Building from source Requires: -- CMake - [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): @@ -59,30 +35,45 @@ export DEVKITPRO=/opt/devkitpro export DEVKITPPC=/opt/devkitpro/devkitPPC ``` -Then you can build wut like any other CMake project: +Then it's as simple as running make or make install: ``` -git clone --recursive https://github.com/devkitPro/wut.git -cd wut -mkdir build && cd build -cmake -DCMAKE_INSTALL_PREFIX= ../ -make install -export WUT_ROOT= -``` - -Then for any wut project you want to build you must use the wut.toolchain.cmake script: -``` -cd ../samples/helloworld -mkdir build && cd build -cmake -DCMAKE_TOOLCHAIN_FILE=$WUT_ROOT/share/wut.toolchain.cmake ../ 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 -cd wut -mkdir build && cd build -cmake ../ make ``` + +## Building wut projects + +### Building wut projects with make +Simply export the required variables and call make. +``` +export DEVKITPRO=/opt/devkitpro +export DEVKITPPC=/opt/devkitpro/devkitPPC +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: +``` +export DEVKITPRO=/opt/devkitpro +cd samples/cmake/helloworld +mkdir build && cd build +cmake -DCMAKE_TOOLCHAIN_FILE=$DEVKITPRO/wut/share/wut.toolchain.cmake ../ +make +``` + +A minimal CMakeLists.txt file for a C++ project might look like: +``` +cmake_minimum_required(VERSION 3.2) +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) +```