Skip to content

Commit

Permalink
Xbox NXDK platform
Browse files Browse the repository at this point in the history
  • Loading branch information
glebm committed Jul 1, 2022
1 parent 5a5111f commit cba8b50
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 0 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/xbox_nxdk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Xbox

on:
push:
branches:
- master
pull_request:
types: [ opened, synchronize ]

jobs:
xbox:
runs-on: ubuntu-latest
env:
NXDK_DIR: /opt/nxdk
steps:
- name: Install APT packages
run: sudo apt-get update && sudo apt-get install -y clang llvm lld bison flex cmake git gettext smpq

- name: Clone NXDK Repo
shell: bash
run: git clone --recursive --depth 1 --branch devilutionx https://github.com/glebm/nxdk.git "$NXDK_DIR"

- name: Build NXDK
shell: bash
run: PATH="${NXDK_DIR}/bin:$PATH" make -j $(nproc) -C "$NXDK_DIR" NXDK_ONLY=1

- name: Work around https://github.com/XboxDev/nxdk/issues/467
run: >
mkdir -p "${NXDK_DIR}/lib/xboxrt/libc_extensions/sys" &&
echo "#pragma once // Generated" > "${NXDK_DIR}/lib/xboxrt/libc_extensions/sys/types.h" &&
echo "typedef long off_t;" >> "${NXDK_DIR}/lib/xboxrt/libc_extensions/sys/types.h"
- name: Work around https://github.com/XboxDev/nxdk/issues/464
run: >
mkdir -p "${NXDK_DIR}/lib/xboxrt/libc_extensions/sys" &&
echo "#pragma once // Generated" > "${NXDK_DIR}/lib/xboxrt/libc_extensions/sys/stat.h" &&
echo "#include <stddef.h>" >> "${NXDK_DIR}/lib/xboxrt/libc_extensions/sys/stat.h" &&
echo "struct _stat { size_t st_size; int st_mode; int st_mtime; int st_atime; int st_nlink; };" >> "${NXDK_DIR}/lib/xboxrt/libc_extensions/sys/stat.h" &&
echo "struct _stati64 { size_t st_size; int st_mode; int st_mtime; int st_atime; int st_nlink; };" >> "${NXDK_DIR}/lib/xboxrt/libc_extensions/sys/stat.h" &&
echo "static int _stati64(const char* x, ...) { return 0; };" >> "${NXDK_DIR}/lib/xboxrt/libc_extensions/sys/stat.h"
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Configure CMake
working-directory: ${{github.workspace}}
run: cmake -S. -Bbuild-xbox -DCMAKE_TOOLCHAIN_FILE=/opt/nxdk/share/toolchain-nxdk.cmake

- name: Build
working-directory: ${{github.workspace}}
shell: bash
run: cmake --build build-xbox -j $(nproc) --target package

- name: Upload-Package
if: ${{ !env.ACT }}
uses: actions/upload-artifact@v2
with:
name: devilutionx
path: build-xbox/devilutionx
4 changes: 4 additions & 0 deletions CMake/Platforms.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,7 @@ endif()
if(UWP_LIB)
include(platforms/uwp_lib)
endif()

if(NXDK)
include(platforms/xbox_nxdk)
endif()
12 changes: 12 additions & 0 deletions CMake/platforms/xbox_nxdk.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
set(NONET ON)
set(ASAN OFF)
set(UBSAN OFF)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/xbox_nxdk/finders")

set(DEVILUTIONX_SYSTEM_BZIP2 OFF)

set(CMAKE_THREAD_LIBS_INIT "-lpthread")
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(CMAKE_USE_WIN32_THREADS_INIT 0)
set(CMAKE_USE_PTHREADS_INIT 1)
5 changes: 5 additions & 0 deletions CMake/platforms/xbox_nxdk/finders/FindPNG.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if(NOT TARGET PNG::PNG)
find_package(PkgConfig REQUIRED)
pkg_check_modules(PNG REQUIRED IMPORTED_TARGET libpng)
add_library(PNG::PNG ALIAS PkgConfig::PNG)
endif()
7 changes: 7 additions & 0 deletions CMake/platforms/xbox_nxdk/finders/FindSDL2.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
if(NOT TARGET SDL2::SDL2)
find_package(PkgConfig REQUIRED)
pkg_check_modules(SDL2 REQUIRED IMPORTED_TARGET sdl2)
add_library(SDL2::SDL2 ALIAS PkgConfig::SDL2)
add_library(SDL2_nomain INTERFACE)
add_library(SDL2::SDL2main ALIAS SDL2_nomain)
endif()
5 changes: 5 additions & 0 deletions CMake/platforms/xbox_nxdk/finders/FindZLIB.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if(NOT TARGET ZLIB::ZLIB)
find_package(PkgConfig REQUIRED)
pkg_check_modules(ZLIB REQUIRED IMPORTED_TARGET zlib)
add_library(ZLIB::ZLIB ALIAS PkgConfig::ZLIB)
endif()

0 comments on commit cba8b50

Please sign in to comment.