Skip to content

Commit

Permalink
Merge branch 'stenzek:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
yeager authored Feb 7, 2025
2 parents 848481b + e099e47 commit 3e3c29c
Show file tree
Hide file tree
Showing 148 changed files with 23,121 additions and 10,312 deletions.
21 changes: 13 additions & 8 deletions .github/workflows/linux-flatpak-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@ on:

jobs:
linux-flatpak-build:
name: "x64"
runs-on: ubuntu-22.04
name: "Build"
strategy:
fail-fast: true
matrix:
setup: [{arch: "x86_64", runner: "ubuntu-22.04"}, {arch: "aarch64", runner: "ubuntu-24.04-arm"}]

runs-on: ${{ matrix.setup.runner }}
container:
image: ghcr.io/flathub-infra/flatpak-github-actions:kde-6.8
options: --privileged
timeout-minutes: 120
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -72,17 +77,17 @@ jobs:
- name: Build Flatpak
uses: flathub-infra/flatpak-github-actions/flatpak-builder@23796715b3dfa4c86ddf50cf29c3cc8b3c82dca8
with:
bundle: duckstation-x64.flatpak
bundle: duckstation-${{ matrix.setup.arch }}.flatpak
upload-artifact: false
manifest-path: scripts/packaging/flatpak/org.duckstation.DuckStation.yaml
arch: x86_64
arch: ${{ matrix.setup.arch }}
build-bundle: true
verbose: true
mirror-screenshots-url: https://dl.flathub.org/media
branch: stable
cache: true
restore-cache: true
cache-key: flatpak-x64-${{ hashFiles('scripts/packaging/flatpak/**/*.yaml') }}
cache-key: flatpak-${{ hashFiles('scripts/packaging/flatpak/**/*.yaml') }}

- name: Validate Build
run: |
Expand All @@ -109,5 +114,5 @@ jobs:
- name: Upload Flatpak
uses: actions/upload-artifact@v4
with:
name: "linux-flatpak"
path: "duckstation-x64.flatpak"
name: "linux-flatpak-${{ matrix.setup.arch }}"
path: "duckstation-${{ matrix.setup.arch }}.flatpak"
6 changes: 4 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ jobs:
./artifacts/windows-arm64/duckstation-windows-arm64-release-symbols.zip
./artifacts/linux-x64-appimage/DuckStation-x64.AppImage
./artifacts/linux-x64-sse2-appimage/DuckStation-x64-SSE2.AppImage
./artifacts/linux-flatpak/duckstation-x64.flatpak
./artifacts/linux-flatpak-x86_64/duckstation-x86_64.flatpak
./artifacts/linux-flatpak-aarch64/duckstation-aarch64.flatpak
./artifacts/macos/duckstation-mac-release.zip
- name: Create Rolling Release
Expand All @@ -83,6 +84,7 @@ jobs:
./artifacts/windows-arm64/duckstation-windows-arm64-release-symbols.zip
./artifacts/linux-x64-appimage/DuckStation-x64.AppImage
./artifacts/linux-x64-sse2-appimage/DuckStation-x64-SSE2.AppImage
./artifacts/linux-flatpak/duckstation-x64.flatpak
./artifacts/linux-flatpak-x86_64/duckstation-x86_64.flatpak
./artifacts/linux-flatpak-aarch64/duckstation-aarch64.flatpak
./artifacts/macos/duckstation-mac-release.zip
11 changes: 2 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.16)
cmake_minimum_required(VERSION 3.19)
project(duckstation C CXX)

# Policy settings.
Expand All @@ -16,10 +16,6 @@ if(NOT CMAKE_BUILD_TYPE MATCHES "Debug|Devel|MinSizeRel|RelWithDebInfo|Release")
set(CMAKE_BUILD_TYPE "Release")
endif()

message(STATUS "CMake Version: ${CMAKE_VERSION}")
message(STATUS "CMake System Name: ${CMAKE_SYSTEM_NAME}")
message(STATUS "Build Type: ${CMAKE_BUILD_TYPE}")

# Pull in modules.
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMakeModules/")
include(DuckStationUtils)
Expand All @@ -34,6 +30,7 @@ detect_cache_line_size()
# Build options. Depends on system attributes.
include(DuckStationBuildOptions)
include(DuckStationDependencies)
include(DuckStationCompilerRequirement)

# Enable PIC on Linux, otherwise the builds do not support ASLR.
if(LINUX OR BSD)
Expand Down Expand Up @@ -120,10 +117,6 @@ endif()
# Prevent fmt from being built with exceptions, or being thrown at call sites.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DFMT_EXCEPTIONS=0")

# Use C++20.
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Recursively include the source tree.
add_subdirectory(dep)
add_subdirectory(src)
Expand Down
2 changes: 2 additions & 0 deletions CMakeModules/DuckStationBuildSummary.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
message(STATUS "Build Type: ${CMAKE_BUILD_TYPE}")

if(ENABLE_OPENGL)
message(STATUS "Building with OpenGL support.")
endif()
Expand Down
16 changes: 16 additions & 0 deletions CMakeModules/DuckStationCompilerRequirement.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Use C++20.
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# C++20 feature checks. Some Linux environments are incomplete.
check_cpp20_feature("__cpp_structured_bindings" 201606)
check_cpp20_feature("__cpp_constinit" 201907)
check_cpp20_feature("__cpp_designated_initializers" 201707)
check_cpp20_feature("__cpp_using_enum" 201907)
check_cpp20_feature("__cpp_lib_bit_cast" 201806)
check_cpp20_feature("__cpp_lib_bitops" 201907)
check_cpp20_feature("__cpp_lib_int_pow2" 202002)
check_cpp20_feature("__cpp_lib_starts_ends_with" 201711)
check_cpp20_attribute("likely" 201803)
check_cpp20_attribute("unlikely" 201803)
check_cpp20_attribute("no_unique_address" 201803)
2 changes: 1 addition & 1 deletion CMakeModules/DuckStationDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ endif()
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)

find_package(SDL2 2.30.8 REQUIRED)
find_package(SDL3 3.2.0 REQUIRED)
find_package(Zstd 1.5.6 REQUIRED)
find_package(WebP REQUIRED) # v1.4.0, spews an error on Linux because no pkg-config.
find_package(ZLIB REQUIRED) # 1.3, but Mac currently doesn't use it.
Expand Down
47 changes: 47 additions & 0 deletions CMakeModules/DuckStationUtils.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
include(CheckSourceCompiles)

function(disable_compiler_warnings_for_target target)
if(MSVC)
target_compile_options(${target} PRIVATE "/W0")
Expand Down Expand Up @@ -245,3 +247,48 @@ function(install_imported_dep_library name)
get_target_property(LOCATION "${name}" IMPORTED_LOCATION_RELEASE)
install(FILES "${LOCATION}" RENAME "${SONAME}" DESTINATION "${CMAKE_INSTALL_LIBDIR}")
endfunction()

function(check_cpp20_feature MACRO MINIMUM_VALUE)
set(CACHE_VAR "CHECK_CPP20_FEATURE_${MACRO}")
if(NOT DEFINED ${CACHE_VAR})
# Create a small source code snippet that fails to compile if the feature is not available.
set(TEMP_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cpp")
file(WRITE "${TEMP_FILE}" "#include <version>
#if !defined(${MACRO}) || ${MACRO} < ${MINIMUM_VALUE}L
#error Missing feature
#endif
")
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
try_compile(HAS_FEATURE
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY} "${TEMP_FILE}"
CXX_STANDARD 20
CXX_STANDARD_REQUIRED TRUE
)
set(${CACHE_VAR} ${HAS_FEATURE} CACHE INTERNAL "Cached feature test result for ${MACRO}")
endif()
if(NOT HAS_FEATURE)
message(FATAL_ERROR "${MACRO} is not supported by your compiler, at least ${MINIMUM_VALUE} is required.")
endif()
endfunction()

function(check_cpp20_attribute ATTRIBUTE MINIMUM_VALUE)
set(CACHE_VAR "CHECK_CPP20_ATTRIBUTE_${MACRO}")
if(NOT DEFINED ${CACHE_VAR})
set(TEMP_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cpp")
file(WRITE "${TEMP_FILE}" "#include <version>
#if !defined(__has_cpp_attribute) || __has_cpp_attribute(${ATTRIBUTE}) < ${MINIMUM_VALUE}L
#error Missing feature
#endif
")
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
try_compile(HAS_FEATURE
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY} "${TEMP_FILE}"
CXX_STANDARD 20
CXX_STANDARD_REQUIRED TRUE
)
set(${CACHE_VAR} ${HAS_FEATURE} CACHE INTERNAL "Cached attribute test result for ${MACRO}")
endif()
if(NOT HAS_FEATURE)
message(FATAL_ERROR "${ATTRIBUTE} is not supported by your compiler, at least ${MINIMUM_VALUE} is required.")
endif()
endfunction()
Loading

0 comments on commit 3e3c29c

Please sign in to comment.