From cf1dec6667bc83789c7289636da318c0a9bec09e Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Tue, 7 Jul 2020 19:14:00 +1000 Subject: [PATCH 1/4] CI: Use cmake for Windows libretro builds --- .github/workflows/rolling-release.yml | 53 +++++++++++++++++++-------- 1 file changed, 37 insertions(+), 16 deletions(-) diff --git a/.github/workflows/rolling-release.yml b/.github/workflows/rolling-release.yml index 1a9c54908..d5ae9dde3 100644 --- a/.github/workflows/rolling-release.yml +++ b/.github/workflows/rolling-release.yml @@ -30,21 +30,8 @@ jobs: del /Q bin\x64\*.iobj del /Q bin\x64\*.ipdb del /Q bin\x64\common-tests* - - - name: Create libretro core archive - shell: cmd - run: | - rename bin\x64\duckstation-libretro-* duckstation_libretro.dll del /Q bin\x64\duckstation-libretro-* - "C:\Program Files\7-Zip\7z.exe" a -r duckstation_libretro.dll.zip ./bin/x64/duckstation_libretro.dll - del /Q bin\x64\duckstation_libretro.dll - - - name: Upload release artifact - uses: actions/upload-artifact@v1 - with: - name: "windows-x64" - path: "duckstation_libretro.dll.zip" - + - name: Create release archive shell: cmd run: | @@ -57,6 +44,35 @@ jobs: path: "duckstation-windows-x64-release.7z" + windows-libretro-build: + runs-on: windows-2019 + steps: + - uses: actions/checkout@v2.3.1 + with: + fetch-depth: 0 + + - name: Compile release build + shell: cmd + run: | + call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + mkdir build + cd build + cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_LIBRETRO_CORE=ON -DCMAKE_C_COMPILER:FILEPATH="%VCToolsInstallDir%\bin\HostX64\x64\cl.exe" -DCMAKE_CXX_COMPILER:FILEPATH="%VCToolsInstallDir%\bin\HostX64\x64\cl.exe" .. + ninja + + - name: Create libretro core archive + shell: cmd + run: | + cd build + "C:\Program Files\7-Zip\7z.exe" a -r duckstation_libretro.dll.zip ./duckstation_libretro.dll + + - name: Upload release artifact + uses: actions/upload-artifact@v1 + with: + name: "windows-libretro-x64" + path: "build/duckstation_libretro.dll.zip" + + linux-build: runs-on: ubuntu-20.04 steps: @@ -139,7 +155,7 @@ jobs: create-release: - needs: [windows-build, linux-build, linux-libretro-build] + needs: [windows-build, windows-libretro-build, linux-build, linux-libretro-build] runs-on: "ubuntu-latest" if: github.ref == 'refs/heads/master' steps: @@ -148,6 +164,11 @@ jobs: with: name: "windows-x64" + - name: Download Windows libretro x64 Artifact + uses: actions/download-artifact@v1 + with: + name: "windows-libretro-x64" + - name: Download SDL AppImage Artifact uses: actions/download-artifact@v1 with: @@ -181,7 +202,7 @@ jobs: title: "Latest Development Build" files: | windows-x64/duckstation-windows-x64-release.7z - windows-x64/duckstation_libretro.dll.zip + windows-libretro-x64/duckstation_libretro.dll.zip linux-x64-appimage-sdl/duckstation-sdl-x64.AppImage linux-x64-appimage-sdl-zsync/duckstation-sdl-x64.AppImage.zsync linux-x64-appimage-qt/duckstation-qt-x64.AppImage From 70184c13c7affb598669a6a019431541b1e99035 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Tue, 7 Jul 2020 19:17:45 +1000 Subject: [PATCH 2/4] Update libretro core build instructions --- README.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b8770c791..5dcfef5ee 100644 --- a/README.md +++ b/README.md @@ -204,11 +204,18 @@ Prebuilt binaries for Windows and 64-bit Linux can be found on the releases page - 64-bit Windows: https://github.com/stenzek/duckstation/releases/download/latest/duckstation_libretro.dll.zip - 64-bit Linux: https://github.com/stenzek/duckstation/releases/download/latest/duckstation_libretro.so.zip +To use, extract the `dll` or `so` into your RetroArch or other libretro frontend's `cores` directory, load the DuckStation core, and pick any bin/cue/chd-format image as content. + To build on Windows, simply compile in the same manner as the normal frontend build. A libretro DLL will be built automatically and placed in the output directory. This will be based on the configuration you selected, you can load it directly into RetroArch, or rename it to `duckstation_libretro.dll`. -To build on Linux, follow the same instructions as for a normal build, but for cmake use `cmake -DBUILD_LIBRETRO_CORE=ON ..`. The shared library can be found in `bin/duckstation_libretro.so`. +Alternatively, you can build via cmake using the following commands from a `x64 Native Tools Command Prompt for VS 2019`: +- mkdir build +- cd build +- cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_LIBRETRO_CORE=ON .. -Currently there is no core info file for DuckStation, so if you want to use it with RetroArch, you must manually load the core, and then content via the File menu. Hopefully we can change this in the future. +You should then have a file named `duckstation_libretro.dll` which can be loaded as a core. + +To build on Linux, follow the same instructions as for a normal build, but for cmake use `cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_LIBRETRO_CORE=ON ..`. The shared library will be named `duckstation_libretro.so` in the current directory. ## Tests - Passes amidog's CPU and GTE tests in both interpreter and recompiler modes, partial passing of CPX tests From c242d4707fcebcb4405fca95ae7ad8e73f2d33cd Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Tue, 7 Jul 2020 20:26:56 +1000 Subject: [PATCH 3/4] build: Drop Linux libretro core in current directory too --- src/duckstation-libretro/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/duckstation-libretro/CMakeLists.txt b/src/duckstation-libretro/CMakeLists.txt index ba00b1b61..7b6c34e3a 100644 --- a/src/duckstation-libretro/CMakeLists.txt +++ b/src/duckstation-libretro/CMakeLists.txt @@ -28,4 +28,5 @@ set_target_properties(duckstation_libretro PROPERTIES PREFIX "") # drop in the build directory set_target_properties(duckstation_libretro PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") +set_target_properties(duckstation_libretro PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") From 01287cb7da3f74064701311fe787542092b35728 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Tue, 7 Jul 2020 20:27:06 +1000 Subject: [PATCH 4/4] build: Support building libretro core for Android --- CMakeLists.txt | 4 ++-- src/common/CMakeLists.txt | 2 +- src/common/gl/context.cpp | 4 +++- src/duckstation-libretro/CMakeLists.txt | 4 ++++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c98a72fa..19693ea93 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,7 +50,7 @@ if(BUILD_LIBRETRO_CORE) if(USE_X11) set(USE_X11 OFF) endif() - if(USE_EGL) + if(BUILD_LIBRETRO_CORE AND USE_EGL) set(USE_EGL OFF) endif() @@ -187,6 +187,6 @@ enable_testing() add_subdirectory(dep) add_subdirectory(src) -if(ANDROID) +if(ANDROID AND NOT BUILD_LIBRETRO_CORE) add_subdirectory(android/app/src/cpp) endif() diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 74d73722b..5ca16a2f2 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -141,7 +141,7 @@ if(USE_EGL) gl/context_egl_x11.h ) endif() - if(ANDROID) + if(ANDROID AND USE_EGL) target_sources(common PRIVATE gl/context_egl_android.cpp gl/context_egl_android.h diff --git a/src/common/gl/context.cpp b/src/common/gl/context.cpp index 20c65b760..1c6fdbd1a 100644 --- a/src/common/gl/context.cpp +++ b/src/common/gl/context.cpp @@ -75,8 +75,10 @@ std::unique_ptr Context::Create(const WindowInfo& wi, const Version #elif defined(__APPLE__) context = ContextAGL::Create(wi, versions_to_try, num_versions_to_try); #elif defined(ANDROID) +#ifdef USE_EGL context = ContextEGLAndroid::Create(wi, versions_to_try, num_versions_to_try); -#else +#endif +#elif defined(USE_X11) if (wi.type == WindowInfo::Type::X11) { #ifdef USE_EGL diff --git a/src/duckstation-libretro/CMakeLists.txt b/src/duckstation-libretro/CMakeLists.txt index 7b6c34e3a..ebb1ff3a7 100644 --- a/src/duckstation-libretro/CMakeLists.txt +++ b/src/duckstation-libretro/CMakeLists.txt @@ -30,3 +30,7 @@ set_target_properties(duckstation_libretro PROPERTIES PREFIX "") set_target_properties(duckstation_libretro PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") set_target_properties(duckstation_libretro PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") +# for android, suffix _android +if(ANDROID) + set_target_properties(duckstation_libretro PROPERTIES OUTPUT_NAME "duckstation_libretro_android") +endif()