Skip to content

Commit

Permalink
Use devkitpro installed wut-tools.
Browse files Browse the repository at this point in the history
  • Loading branch information
exjam committed Jan 27, 2019
1 parent 7495a99 commit edd0753
Show file tree
Hide file tree
Showing 31 changed files with 69 additions and 3,926 deletions.
9 changes: 0 additions & 9 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +0,0 @@
[submodule "tools/libraries/fmt"]
path = tools/libraries/fmt
url = https://github.com/fmtlib/fmt.git
[submodule "tools/libraries/excmd"]
path = tools/libraries/excmd
url = https://github.com/exjam/excmd.git
[submodule "tools/libraries/zlib"]
path = tools/libraries/zlib
url = https://github.com/madler/zlib.git
27 changes: 8 additions & 19 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,31 @@ language: cpp
matrix:
include:
- os: linux
dist: xenial
sudo: required
dist: trusty
env: DEPLOY_FILE=wut.linux64.7z
- os: osx
osx_image: xcode9.3
env: DEPLOY_FILE=wut.macos.7z
env: DEPLOY_FILE=wut.7z

addons:
apt:
sources:
- ubuntu-toolchain-r-test
- sourceline: 'ppa:cginternals/backports-ppa'
packages:
- gcc-7
- g++-7
- zlib1g-dev
- p7zip-full

cache:
directories:
- "$HOME/.local"
- "/opt/devkitpro"

git:
submodules: true

install:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 90; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 90; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then wget https://github.com/devkitPro/pacman/releases/download/devkitpro-pacman-1.0.1/devkitpro-pacman.deb -O /tmp/devkitpro-pacman.deb; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo dpkg -i /tmp/devkitpro-pacman.deb; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install p7zip; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then wget https://github.com/devkitPro/pacman/releases/download/devkitpro-pacman-1.0.1/devkitpro-pacman-installer.pkg -O /tmp/devkitpro-pacman-installer.pkg; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then sudo installer -pkg /tmp/devkitpro-pacman-installer.pkg -target /; fi
- yes | sudo dkp-pacman -Syu devkitPPC
- wget https://github.com/devkitPro/pacman/releases/download/devkitpro-pacman-1.0.1/devkitpro-pacman.deb -O /tmp/devkitpro-pacman.deb
- sudo dpkg -i /tmp/devkitpro-pacman.deb
- yes | sudo dkp-pacman -Syu devkitPPC wut-tools
- export DEVKITPRO=/opt/devkitpro
- export DEVKITPPC=/opt/devkitpro/devkitPPC

script:
Expand All @@ -48,7 +38,6 @@ script:
- make -j4 install
- export WUT_ROOT=$PWD/wut_install
- cd ../
- chmod +x $WUT_ROOT/bin/elf2rpl
# Build tests
- cd tests
- mkdir build && cd build
Expand All @@ -73,5 +62,5 @@ deploy:
file_glob: true
file: $WUT_ROOT/$DEPLOY_FILE
on:
repo: decaf-emu/wut
repo: devkitPro/wut
tags: true
50 changes: 9 additions & 41 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
cmake_minimum_required(VERSION 3.2)
project(wut)
include(ExternalProject)
set(WUT_ROOT "${CMAKE_CURRENT_SOURCE_DIR}")
set(ENV{WUT_ROOT} "${WUT_ROOT}")
set(CMAKE_TOOLCHAIN_FILE "${WUT_ROOT}/share/wut.toolchain.cmake")

project(wut)
option(WUT_BUILD_DOCS "Build documentation" OFF)
option(WUT_BUILD_TOOLS "Build tools" ON)
option(WUT_BUILD_PPC "Build PPC code using devkitPPC" ON)

set(WUT_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
set(WUT_STAGING "${CMAKE_BINARY_DIR}/staging")

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/lib")
Expand All @@ -25,46 +22,17 @@ if(WUT_BUILD_DOCS)
add_subdirectory(docs)
endif()

if(WUT_BUILD_TOOLS)
add_subdirectory(tools)
find_program(WUT_RPLIMPORTGEN NAMES rplimportgen PATHS "${DEVKITPRO}/tools/bin")
if(NOT WUT_RPLIMPORTGEN)
message(FATAL_ERROR "Could not find rplimportgen.")
endif()

if(WUT_BUILD_PPC)
if(NOT WUT_BUILD_TOOLS)
message(FATAL_ERROR "WUT_BUILD_PPC requires WUT_BUILD_TOOLS.")
endif()

set(WUT_TOOLCHAIN "${CMAKE_CURRENT_SOURCE_DIR}/share/wut.toolchain.cmake")

externalproject_add(cafe
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cafe"
CMAKE_GENERATOR "Unix Makefiles"
INSTALL_DIR "${WUT_STAGING}"
CMAKE_CACHE_ARGS
-DWUT_ROOT:filepath=${WUT_ROOT}
-DWUT_RPLIMPORTGEN:filepath=$<TARGET_FILE:rplimportgen>
-DCMAKE_TOOLCHAIN_FILE:filepath=${WUT_TOOLCHAIN}
-DCMAKE_INSTALL_PREFIX:string=<INSTALL_DIR>
DEPENDS rplimportgen
BUILD_ALWAYS 1)

externalproject_add(libraries
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libraries"
CMAKE_GENERATOR "Unix Makefiles"
INSTALL_DIR "${WUT_STAGING}"
CMAKE_CACHE_ARGS
-DWUT_ROOT:filepath=${WUT_ROOT}
-DCMAKE_TOOLCHAIN_FILE:filepath=${WUT_TOOLCHAIN}
-DCMAKE_INSTALL_PREFIX:string=<INSTALL_DIR>
BUILD_ALWAYS 1)
endif()
add_subdirectory(cafe)
add_subdirectory(libraries)

install(DIRECTORY "${CMAKE_SOURCE_DIR}/include/"
DESTINATION "${CMAKE_INSTALL_PREFIX}/include"
FILES_MATCHING PATTERN "*.h*")

install(DIRECTORY "${CMAKE_SOURCE_DIR}/share/"
DESTINATION "${CMAKE_INSTALL_PREFIX}/share")

install(DIRECTORY "${CMAKE_BINARY_DIR}/staging/"
DESTINATION "${CMAKE_INSTALL_PREFIX}")
52 changes: 20 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Build Status](https://travis-ci.org/decaf-emu/wut.svg?branch=rewrite)](https://travis-ci.org/decaf-emu/wut)
[![Build Status](https://travis-ci.org/devkitPro/wut.svg?branch=rewrite)](https://travis-ci.org/devkitPro/wut)

# wut
Let's try make a Wii U Toolchain / SDK for creating rpx/rpl.
Expand All @@ -7,11 +7,11 @@ Licensed under the terms of the GNU General Public License, version 2 or later (

## Install

Grab the latest [release](https://github.com/decaf-emu/wut/releases) extract to a folder, then export that folder as WUT_ROOT.
Grab the latest [release](https://github.com/devkitPro/wut/releases) extract to a folder, then export that folder as WUT_ROOT.

For example:
```
wget https://github.com/decaf-emu/wut/releases/download/1.0.0-alpha/wut.linux64.7z
wget https://github.com/devkitPro/wut/releases/download/1.0.0-alpha/wut.linux64.7z
mkdir wut && cd wut
7z x ../wut.linux64.7z
export WUT_ROOT=$PWD
Expand Down Expand Up @@ -51,41 +51,20 @@ make

## Building
Requires:
- A modern compiler with C++14/17 support
- CMake
- zlib
- [devkitPPC r31+](https://devkitpro.org/wiki/Getting_Started)
- [devkitPro](https://devkitpro.org/wiki/Getting_Started)

### Building on Windows
If you are using devkitPro then you can build wut using the provided msys2 environment:
### Building with devkitPro
Ensure you have the devkitPPC and wut-tools packages from [devkitPro](https://devkitpro.org/wiki/Getting_Started):
```
export PATH=$PATH:/opt/devkitpro/devkitPPC/bin
sudo dkp-pacman -Syu devkitPPC wut-tools
export DEVKITPRO=/opt/devkitpro
export DEVKITPPC=/opt/devkitpro/devkitPPC
pacman -S gcc cmake zlib-devel
git clone --recursive https://github.com/decaf-emu/wut.git
cd wut
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=/opt/wut ../
make install
export WUT_ROOT=/opt/wut
```

Or use [WSL](https://docs.microsoft.com/en-us/windows/wsl/install-win10) and then follow the Linux instructions after preparing your environment.

For example, if you installed Ubuntu 18.04 then you might setup your environment like:

```
sudo apt install cmake zlib1g-dev gcc g++ build-essential
wget https://github.com/devkitPro/pacman/releases/download/devkitpro-pacman-1.0.1/devkitpro-pacman.deb
sudo dpkg -i devkitpro-pacman.deb
sudo ln -s /proc/mounts /etc/mtab
sudo dkp-pacman -S devkitPPC wiiload
```

### Building on Linux / MacOS
Then you can build wut like any other CMake project:
```
export DEVKITPPC=/opt/devkitpro/devkitPPC
git clone --recursive https://github.com/decaf-emu/wut.git
git clone --recursive https://github.com/devkitPro/wut.git
cd wut
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=<path/to/install> ../
Expand All @@ -94,10 +73,19 @@ export WUT_ROOT=<path/to/install>
```

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
```

### 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
```
36 changes: 32 additions & 4 deletions share/wut.toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,18 @@ set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR "ppc")
set(CMAKE_CROSSCOMPILING 1)

find_program(DEVKITPPC_GCC NAMES powerpc-eabi-gcc)
# Find DEVKITPRO
if(NOT DEFINED ENV{DEVKITPRO})
message(FATAL_ERROR "You must have defined DEVKITPRO before calling cmake.")
endif()

set(DEVKITPRO $ENV{DEVKITPRO})

# Find DEVKITPPC
find_program(DEVKITPPC_GCC
NAMES powerpc-eabi-gcc
PATHS "${DEVKITPRO}/devkitPPC/bin")

if(DEVKITPPC_GCC)
get_filename_component(DEVKITPPC_BIN ${DEVKITPPC_GCC} DIRECTORY)
get_filename_component(DEVKITPPC ${DEVKITPPC_BIN} DIRECTORY)
Expand All @@ -17,12 +28,29 @@ else()
set(DEVKITPPC_BIN "${DEVKITPPC}/bin")
endif()

# Find WUT
if(NOT DEFINED ENV{WUT_ROOT})
message(FATAL_ERROR "You must have defined WUT_ROOT before calling cmake.")
endif()

set(WUT_ROOT $ENV{WUT_ROOT})

# Find elf2rpl
find_program(ELF2RPL_BIN
NAMES elf2rpl
PATHS "${DEVKITPRO}/tools/bin")
if(NOT ELF2RPL_BIN)
message(FATAL_ERROR "Could not find elf2rpl")
endif()

# Find rplexportgen
find_program(RPLEXPORTGEN_BIN
NAMES rplexportgen
PATHS "${DEVKITPRO}/tools/bin")
if(NOT RPLEXPORTGEN_BIN)
message(FATAL_ERROR "Could not find rplexportgen")
endif()

set(CMAKE_ASM_COMPILER "${DEVKITPPC_BIN}/powerpc-eabi-gcc" CACHE PATH "")
set(CMAKE_C_COMPILER "${DEVKITPPC_BIN}/powerpc-eabi-gcc" CACHE PATH "")
set(CMAKE_CXX_COMPILER "${DEVKITPPC_BIN}/powerpc-eabi-g++" CACHE PATH "")
Expand All @@ -40,15 +68,15 @@ set(CMAKE_EXE_LINKER_FLAGS "-Wl,-z,nocopyreloc -T \"${WUT_ROOT}/share/wut.ld\" \
include_directories(BEFORE SYSTEM "${WUT_ROOT}/include")

# Setup root to exclude host system headers + libraries
set(CMAKE_FIND_ROOT_PATH "${DEVKITPPC}" "${WUT_ROOT}/bin" "${CMAKE_INSTALL_PREFIX}" "${CMAKE_INSTALL_PREFIX}/share")
set(CMAKE_FIND_ROOT_PATH "${DEVKITPPC}" "${DEVKITPRO}/tools/bin" "${CMAKE_INSTALL_PREFIX}" "${CMAKE_INSTALL_PREFIX}/share")
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

# Tools
set(WUT_ELF2RPL "${WUT_ROOT}/bin/elf2rpl" CACHE PATH "")
set(WUT_RPLEXPORTGEN "${WUT_ROOT}/bin/rplexportgen" CACHE PATH "")
set(WUT_ELF2RPL "${ELF2RPL_BIN}" CACHE PATH "")
set(WUT_RPLEXPORTGEN "${RPLEXPORTGEN_BIN}" CACHE PATH "")

# Flags
set(WUT TRUE)
Expand Down
14 changes: 0 additions & 14 deletions tools/CMakeLists.txt

This file was deleted.

Loading

0 comments on commit edd0753

Please sign in to comment.