Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
build/
/out
/lib/nnsdk
toolchain/nx-*
toolchain/musl
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ Usage of the materials here outside of matching decompilation is not supported.

# Development
For running commands please install [task](https://taskfile.dev), CMake, Ninja and Clang/LLVM.
The Clang/LLVM toolchain version should match the [image used in the PR](https://github.com/open-ead/containers/blob/main/ubuntu-builder/Dockerfile)

The Clang/LLVM toolchain is only used for formatting and running `clang-tidy`.
The version should match the [image used in the PR](https://github.com/open-ead/containers/blob/main/ubuntu-builder/Dockerfile)

Before you begin, run `task clone-deps` to clone dependencies.

Expand Down
44 changes: 15 additions & 29 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ version: '3'
# https://taskfile.dev

vars:
NX_AARCH64: 22.1.8-1
# Modules to check with clang-format/clang-tidy;
MODULES: atk,font,g3d,ui2d,vfx
_MODULES1: ',{{.MODULES}}'
_MODULES2: '^{{.MODULES}}$'
SOURCES: '{{._MODULES1 | replace "," " lib/"}}'
CLANG_TIDY_LIBS: '{{.MODULES | replace " " "" | replace "," "|" }}'

env:
NX_AARCH64: '{{.NX_AARCH64}}'

tasks:
clone-deps:
desc: Clone dependencies for development
Expand All @@ -27,35 +31,17 @@ tasks:
configure:
desc: Configure CMake
cmds:
- task: cmake
vars:
CMAKE_ARGS: -DNNSDK_DIR=$(pwd)/lib/nnsdk
- >
cmake -G Ninja -B test/header_check/build -S test/header_check
-DNN_SDK=1.2.3
-DNN_WARE=4.5.6
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
-DCMAKE_CXX_STANDARD=17
-DCMAKE_C_COMPILER=clang
-DCMAKE_CXX_COMPILER=clang++
-DCMAKE_C_FLAGS='-D__aarch64__'
-DCMAKE_CXX_FLAGS='-D__aarch64__'
-DNNSDK_DIR=$(pwd)/lib/nnsdk
cmake:
cmds:
- >
cmake -G Ninja -B build -S .
-DNN_SDK=1.2.3
-DNN_WARE=4.5.6
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
-DCMAKE_CXX_STANDARD=17
-DCMAKE_C_COMPILER=clang
-DCMAKE_CXX_COMPILER=clang++
-DCMAKE_C_FLAGS='-D__aarch64__'
-DCMAKE_CXX_FLAGS='-D__aarch64__'
{{.CMAKE_ARGS}}
{{.CLI_ARGS}}

- silent: true
cmd: |
if [ -z "$CI" ]; then
[ -d "toolchain/musl" ] || git clone https://github.com/open-ead/botw-lib-musl toolchain/musl
VERSION={{.NX_AARCH64}}
OUTPUT=toolchain
[ -d "$OUTPUT/nx-aarch64-$VERSION" ] || curl -fsSL https://raw.githubusercontent.com/Pistonight/nx-aarch64/main/install.sh | VERSION="$VERSION" OUTPUT="$OUTPUT" sh
fi
- cmake -G Ninja -DCMAKE_TOOLCHAIN_FILE="$PWD/toolchain/Toolchain.cmake" -B build
- cmake -G Ninja -DCMAKE_TOOLCHAIN_FILE="$PWD/toolchain/Toolchain.cmake" -B test/header_check/build -S test/header_check


build:
desc: Check the project builds
Expand Down
75 changes: 75 additions & 0 deletions toolchain/Toolchain.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Toolchain file used to do verification build tests. Adopted from BOTW

if (DEFINED ENV{NNSDK_DIR})
message(STATUS "Using NNSDK_DIR: $ENV{NNSDK_DIR}")
set(NNSDK_DIR "$ENV{NNSDK_DIR}")
else()
set(NNSDK_DIR "${CMAKE_CURRENT_LIST_DIR}/../lib/nnsdk")
endif()
if (DEFINED ENV{NX_CLANG})
message(STATUS "Using NX_CLANG: $ENV{NX_CLANG}")
set(NX_CLANG "$ENV{NX_CLANG}")
else()
if (NOT DEFINED ENV{NX_AARCH64})
message(FATAL_ERROR "please define NX_CLANG or NX_AARCH64")
endif()
message(STATUS "Using NX_AARCH64: $ENV{NX_AARCH64}")
set(NX_CLANG "${CMAKE_CURRENT_LIST_DIR}/nx-aarch64-$ENV{NX_AARCH64}")
endif()
if (DEFINED ENV{NX_MUSL})
message(STATUS "Using NX_MUSL: $ENV{NX_MUSL}")
set(NX_MUSL "$ENV{NX_MUSL}")
else()
set(NX_MUSL "${CMAKE_CURRENT_LIST_DIR}/musl")
endif()


# no need for optimization or debug info for testing
# set(NX64_OPT_FLAGS "-O3 -g")
set(NX64_TRIPLE aarch64-linux-elf)

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR aarch64)

set(CMAKE_SYSROOT ${NX_MUSL})
set(CMAKE_C_COMPILER "${NX_CLANG}/bin/clang")
set(CMAKE_C_COMPILER_TARGET ${NX64_TRIPLE})
set(CMAKE_CXX_COMPILER "${NX_CLANG}/bin/clang++")
set(CMAKE_CXX_COMPILER_TARGET ${NX64_TRIPLE})

set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

# Target options
add_compile_options(-mcpu=cortex-a57+fp+simd+crypto+crc)
add_compile_options(-mno-implicit-float)
# Environment
add_compile_options(-stdlib=libc++)
add_compile_options(-fPIC)
# Helps with matching as this causes Clang to emit debug type info even for dynamic classes
# with undefined vtables.
add_compile_options(-fstandalone-debug)

add_definitions(-D SWITCH)
add_definitions(-D NNSDK)
add_definitions(-D MATCHING_HACK_NX_CLANG)

add_link_options(
# Use lld for performance reasons (and because we don't want a dependency on GNU tools)
-fuse-ld=lld
# We are not linking executables so these aren't needed
# (technically we are not linking at all but CMake will always ensure linking is possible)
-nostartfiles -nodefaultlibs
)

# TODO: Currently, we only build for a stub versions
# this means we might not catch errors that only happen
# in one of the versions. This is partially mitigated
# by building SMO and BOTW in CI
set(NN_SDK 1.2.3)
set(NN_WARE 4.5.6)
Loading