Skip to content

Commit

Permalink
use cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher committed Oct 16, 2024
1 parent 67ddd72 commit 9c9a8f1
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 4 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,21 @@ jobs:
- name: Build
run: |
eval "$(./third-party/nxdk/bin/activate -s)"
make
nxdk_dir="$(pwd)/third-party/nxdk"
eval "$(${nxdk_dir}/bin/activate -s)"
cd ${nxdk_dir}
make NXDK_ONLY=y
make tools
cd ${GITHUB_WORKSPACE}
mkdir -p build
cmake -DCMAKE_TOOLCHAIN_FILE=${nxdk_dir}/share/toolchain-nxdk.cmake -B build -S .
cmake --build build
# move artifacts
mkdir -p artifacts
mv ./build/default.xbe ./artifacts
mv ./Moonlight.iso ./artifacts
mv ./build/Moonlight/default.xbe ./artifacts
mv ./build/Moonlight/Moonlight.iso ./artifacts
- name: Upload Artifacts
uses: actions/upload-artifact@v4
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,8 @@

# VSCode IDE
.vscode/

# build directories
build/
cmake-*/
docs/doxyconfig*
58 changes: 58 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
cmake_minimum_required(VERSION 3.14)
# much of this file is borrowed from https://github.com/Ryzee119/Xenium-Tools/blob/master/CMakeLists.txt

project(Moonlight C CXX)
set(XBE_TITLE ${CMAKE_PROJECT_NAME})
message(STATUS "XBE_TITLE: ${XBE_TITLE}")

set(NXDK_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third-party/nxdk")
message(STATUS "NXDK_DIR: ${NXDK_DIR}")

set(XBOX_ISO_DIR "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}")
message(STATUS "XBOX_ISO_DIR: ${XBOX_ISO_DIR}")

# create the xiso directory if it doesn't exist
file(MAKE_DIRECTORY ${XBOX_ISO_DIR})

include(FindPkgConfig)

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
set(CMAKE_C_FLAGS_RELEASE "-O2")

# Stop lots of warning spam
add_compile_options(-Wno-builtin-macro-redefined)
add_definitions(-DXBOX -DNXDK)

set(MOONLIGHT_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp"
)

add_executable(${CMAKE_PROJECT_NAME}
${MOONLIGHT_SOURCES}
)
include_directories("${NXDK_DIR}/lib")
target_link_libraries(${CMAKE_PROJECT_NAME} PUBLIC ${NXDK_DIR}/lib/libpbkit.lib)

target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE "")

#Post-build exe to xbe conversion
add_custom_target(cxbe_convert ALL
VERBATIM COMMAND "${CMAKE_COMMAND}" -E env ./tools/cxbe/cxbe -OUT:${XBOX_ISO_DIR}/default.xbe -TITLE:${XBE_TITLE} ${CMAKE_CURRENT_BINARY_DIR}/${XBE_TITLE}.exe
WORKING_DIRECTORY ${NXDK_DIR}
COMMENT "CXBE Conversion: [EXE -> XBE]"
)
add_dependencies(cxbe_convert ${CMAKE_PROJECT_NAME})

#Post-build xbe to xiso conversion
add_custom_target(xbe_iso ALL
VERBATIM COMMAND "${CMAKE_COMMAND}" -E env ${NXDK_DIR}/tools/extract-xiso/build/extract-xiso -c ${XBOX_ISO_DIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "CXBE Conversion: [XBE -> XISO]"
)
add_dependencies(xbe_iso cxbe_convert)

set_target_properties(cxbe_convert PROPERTIES OUTPUT_QUIET ON)
set_target_properties(xbe_iso PROPERTIES OUTPUT_QUIET ON)

0 comments on commit 9c9a8f1

Please sign in to comment.