diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..e72a1e2 --- /dev/null +++ b/.clang-format @@ -0,0 +1,74 @@ +--- +# This file is centrally managed in https://github.com//.github/ +# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in +# the above-mentioned repo. + +# Generated from CLion C/C++ Code Style settings +BasedOnStyle: LLVM +AccessModifierOffset: -2 +AlignAfterOpenBracket: DontAlign +AlignConsecutiveAssignments: false +AlignOperands: Align +AllowAllArgumentsOnNextLine: false +AllowAllConstructorInitializersOnNextLine: false +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: Always +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: WithoutElse +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: true +AlignTrailingComments: false +AlwaysBreakAfterReturnType: All +AlwaysBreakTemplateDeclarations: MultiLine +BreakBeforeBraces: Custom +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: Never + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterUnion: false + BeforeCatch: true + BeforeElse: true + IndentBraces: false + SplitEmptyFunction: false + SplitEmptyRecord: true +BreakBeforeBinaryOperators: None +BreakBeforeTernaryOperators: false +BreakConstructorInitializers: AfterColon +BreakInheritanceList: AfterColon +ColumnLimit: 0 +CompactNamespaces: false +ContinuationIndentWidth: 2 +IndentCaseLabels: true +IndentPPDirectives: BeforeHash +IndentWidth: 2 +KeepEmptyLinesAtTheStartOfBlocks: false +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: All +ObjCSpaceAfterProperty: true +ObjCSpaceBeforeProtocolList: true +PointerAlignment: Right +ReflowComments: true +SpaceAfterCStyleCast: true +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeCpp11BracedList: true +SpaceBeforeCtorInitializerColon: false +SpaceBeforeInheritanceColon: false +SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 2 +SpacesInAngles: Never +SpacesInCStyleCastParentheses: false +SpacesInContainerLiterals: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +TabWidth: 2 +Cpp11BracedListStyle: false +UseTab: Never diff --git a/.codeql-prebuild-cpp-Linux.sh b/.codeql-prebuild-cpp-Linux.sh new file mode 100644 index 0000000..2db2df8 --- /dev/null +++ b/.codeql-prebuild-cpp-Linux.sh @@ -0,0 +1,23 @@ +# install dependencies for C++ analysis +set -e + +# install dependencies +dependencies=( + "bison" + "build-essential" + "clang" + "cmake" + "flex" + "git" + "lld" + "llvm" +) +sudo apt-get update +sudo apt-get install --no-install-recommends -y "${dependencies[@]}" + +# build +./third-party/nxdk/bin/activate +make + +# skip autobuild +echo "skip_autobuild=true" >> "$GITHUB_OUTPUT" diff --git a/.codeql-prebuild-cpp-Windows.sh b/.codeql-prebuild-cpp-Windows.sh new file mode 100644 index 0000000..26c9352 --- /dev/null +++ b/.codeql-prebuild-cpp-Windows.sh @@ -0,0 +1,26 @@ +# install dependencies for C++ analysis +set -e + +# update pacman +pacman --noconfirm -Syu + +# install dependencies +dependencies=( + "make" + "cmake" + "git" + "bison" + "flex" + "mingw-w64-x86_64-gcc" + "mingw-w64-x86_64-llvm" + "mingw-w64-x86_64-clang" + "mingw-w64-x86_64-lld" +) +pacman -S --noconfirm "${dependencies[@]}" + +# build +./third-party/nxdk/bin/activate +make + +# skip autobuild +echo "skip_autobuild=true" >> "$GITHUB_OUTPUT" diff --git a/.codeql-prebuild-cpp-macOS.sh b/.codeql-prebuild-cpp-macOS.sh new file mode 100644 index 0000000..1d4afc6 --- /dev/null +++ b/.codeql-prebuild-cpp-macOS.sh @@ -0,0 +1,17 @@ +# install dependencies for C++ analysis +set -e + +# install dependencies +dependencies=( + "cmake" + "coreutils" + "llvm" +) +brew install "${dependencies[@]}" + +# build +./third-party/nxdk/bin/activate +make + +# skip autobuild +echo "skip_autobuild=true" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..4c00e9f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,159 @@ +--- +name: CI + +on: + pull_request: + branches: + - master + types: + - opened + - synchronize + - reopened + push: + branches: + - master + +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + +jobs: + build: + strategy: + fail-fast: false + matrix: + include: + - os: macos-latest + shell: "bash" + - os: ubuntu-latest + shell: "bash" + - os: windows-latest + shell: "msys2 {0}" + + name: Build (${{ matrix.os }}) + runs-on: ${{ matrix.os }} + defaults: + run: + shell: ${{ matrix.shell }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Setup Dependencies Linux + if: runner.os == 'Linux' + run: | + dependencies=( + "bison" + "build-essential" + "clang" + "cmake" + "flex" + "git" + "lld" + "llvm" + ) + sudo apt-get update + sudo apt-get install --no-install-recommends -y "${dependencies[@]}" + + - name: Setup Dependencies macOS + if: runner.os == 'macOS' + run: | + dependencies=( + "cmake" + "coreutils" + "llvm" + ) + brew install "${dependencies[@]}" + + - name: Setup Dependencies Windows + if: runner.os == 'Windows' + uses: msys2/setup-msys2@v2 + with: + msystem: MINGW64 + update: true + install: >- + make + cmake + git + bison + flex + mingw-w64-x86_64-gcc + mingw-w64-x86_64-llvm + mingw-w64-x86_64-clang + mingw-w64-x86_64-lld + + - name: Setup python + id: setup-python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - name: Python Path + id: python-path + run: | + if [ "${{ runner.os }}" = "Windows" ]; then + # replace backslashes with double backslashes + python_path=$(echo "${{ steps.setup-python.outputs.python-path }}" | sed 's/\\/\\\\/g') + else + python_path=${{ steps.setup-python.outputs.python-path }} + fi + + # step output + echo "python-path=${python_path}" + echo "python-path=${python_path}" >> $GITHUB_OUTPUT + + - name: Build + run: | + source ./third-party/nxdk/bin/activate + make + + cd $GITHUB_WORKSPACE + ls -a build + + - name: Run tests + id: test + if: false + working-directory: build/tests + run: | + ./test_moonlight-xboxog --gtest_color=yes + + - name: Generate gcov report + # any except canceled or skipped + if: always() && (steps.test.outcome == 'success' || steps.test.outcome == 'failure') + id: test_report + working-directory: build + run: | + ${{ steps.python-path.outputs.python-path }} -m pip install gcovr + ${{ steps.python-path.outputs.python-path }} -m gcovr . -r ../src \ + --exclude-noncode-lines \ + --exclude-throw-branches \ + --exclude-unreachable-branches \ + --verbose \ + --xml-pretty \ + -o coverage.xml + + - name: Debug coverage file + if: >- + always() && + steps.test_report.outcome == 'success' + run: | + cat build/coverage.xml + + # todo: upload coverage in separate job similar to LizardByte/libdisplaydevice + - name: Upload coverage + # any except canceled or skipped + if: >- + always() && + steps.test_report.outcome == 'success' && + startsWith(github.repository, 'LizardByte/') + uses: codecov/codecov-action@v4 + with: + disable_search: true + fail_ci_if_error: true + files: ./build/coverage.xml + flags: "${{ runner.os }}" + token: ${{ secrets.CODECOV_TOKEN }} + verbose: true diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b9cce0f --- /dev/null +++ b/.gitignore @@ -0,0 +1,38 @@ +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +# JetBrains IDE +.idea/ + +# VSCode IDE +.vscode/ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..05645c4 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,8 @@ +[submodule "third-party/moonlight-common-c"] + path = third-party/moonlight-common-c + url = https://github.com/moonlight-stream/moonlight-common-c.git + branch = master +[submodule "third-party/nxdk"] + path = third-party/nxdk + url = https://github.com/XboxDev/nxdk.git + branch = master diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1a1c5f0 --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +XBE_TITLE = Moonlight +OUTPUT_DIR = $(CURDIR)/build +GEN_XISO = $(XBE_TITLE).iso +SRCS = $(CURDIR)/src/main.cpp +NXDK_DIR ?= $(CURDIR)/third-party/nxdk +NXDK_CXX = y + +include $(NXDK_DIR)/Makefile diff --git a/README.md b/README.md index fd3e658..3499796 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ -# template-base -Base repository template for LizardByte. +# Moonlight-XboxOG +Port of Moonlight for the Original Xbox. Unlikely to ever actually work. Do NOT use. diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..174a22f --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,24 @@ +#include +#include +#include +#include +#include + +int main(void) { + XVideoSetMode(640, 480, 32, REFRESH_DEFAULT); + + std::vector words; + words.emplace_back("Hello"); + words.emplace_back(" "); + words.emplace_back("nxdk!"); + words.emplace_back("\n"); + + while (true) { + for (auto& word : words) { + debugPrint("%s", word.c_str()); + } + Sleep(2000); + } + + return 0; +} diff --git a/third-party/moonlight-common-c b/third-party/moonlight-common-c new file mode 160000 index 0000000..8599b60 --- /dev/null +++ b/third-party/moonlight-common-c @@ -0,0 +1 @@ +Subproject commit 8599b6042a4ba27749b0f94134dd614b4328a9bc diff --git a/third-party/nxdk b/third-party/nxdk new file mode 160000 index 0000000..56cdc3d --- /dev/null +++ b/third-party/nxdk @@ -0,0 +1 @@ +Subproject commit 56cdc3d89e6a6ab00e6d7d6ecfcb533e96678107