Skip to content

Commit

Permalink
update to current state of master
Browse files Browse the repository at this point in the history
modified String to integrate with the u32char_t changes and copied over existing project with current state of master
  • Loading branch information
khatharr committed Apr 13, 2023
1 parent 83779bd commit b383a3d
Show file tree
Hide file tree
Showing 71 changed files with 1,873 additions and 682 deletions.
3 changes: 3 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Checks: >
clang-analyzer-*,
misc-*,
modernize-*,
performance-*,
portability-*,
readability-*,
-clang-analyzer-nullability.NullablePassedToNonnull,
Expand All @@ -20,6 +21,8 @@ Checks: >
-modernize-return-braced-init-list,
-modernize-use-nodiscard,
-modernize-use-trailing-return-type,
-performance-inefficient-string-concatenation,
-performance-no-int-to-ptr,
-readability-braces-around-statements,
-readability-container-contains,
-readability-convert-member-functions-to-static,
Expand Down
130 changes: 97 additions & 33 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: CI

on: [push, pull_request]
on: [push, pull_request, workflow_dispatch]

env:
DISPLAY: ":99" # Display number to use for the X server
GALLIUM_DRIVER: llvmpipe # Use Mesa 3D software OpenGL renderer

jobs:
build:
Expand All @@ -11,34 +15,46 @@ jobs:
fail-fast: false
matrix:
platform:
- { name: Windows VS2019 x86, os: windows-2019, flags: -A Win32 }
- { name: Windows VS2019 x64, os: windows-2019, flags: -A x64 }
- { name: Windows VS2022 x86, os: windows-2022, flags: -A Win32 }
- { name: Windows VS2022 x64, os: windows-2022, flags: -A x64 }
- { name: Windows VS2022 ClangCL, os: windows-2022, flags: -T ClangCL }
- { name: Windows VS2022 Clang, os: windows-2022, flags: -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -GNinja }
- { name: Linux GCC, os: ubuntu-latest, prefix: xvfb-run -a, flags: -DSFML_RUN_DISPLAY_TESTS=ON -GNinja }
- { name: Linux Clang, os: ubuntu-latest, prefix: xvfb-run -a, flags: -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DSFML_RUN_DISPLAY_TESTS=ON -GNinja , gcovr_options: '--gcov-executable="llvm-cov-$CLANG_VERSION gcov"' }
- { name: Windows VS2019 x86, os: windows-2019, flags: -DSFML_USE_MESA3D=TRUE -A Win32 }
- { name: Windows VS2019 x64, os: windows-2019, flags: -DSFML_USE_MESA3D=TRUE -A x64 }
- { name: Windows VS2022 x86, os: windows-2022, flags: -DSFML_USE_MESA3D=TRUE -A Win32 }
- { name: Windows VS2022 x64, os: windows-2022, flags: -DSFML_USE_MESA3D=TRUE -A x64 }
- { name: Windows VS2022 ClangCL, os: windows-2022, flags: -DSFML_USE_MESA3D=TRUE -T ClangCL }
- { name: Windows VS2022 Clang, os: windows-2022, flags: -DSFML_USE_MESA3D=TRUE -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -GNinja }
- { name: Linux GCC, os: ubuntu-latest, flags: -DSFML_RUN_DISPLAY_TESTS=ON -GNinja }
- { name: Linux Clang, os: ubuntu-latest, flags: -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DSFML_RUN_DISPLAY_TESTS=ON -GNinja , gcovr_options: '--gcov-executable="llvm-cov-$CLANG_VERSION gcov"' }
- { name: MacOS, os: macos-11, flags: -GNinja }
- { name: MacOS Xcode, os: macos-11, flags: -GXcode }
- { name: iOS, os: macos-11, flags: -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_ARCHITECTURES=arm64 }
- { name: iOS Xcode, os: macos-11, flags: -DCMAKE_SYSTEM_NAME=iOS -GXcode -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED=NO }
config:
- { name: Shared, flags: -DBUILD_SHARED_LIBS=TRUE }
- { name: Static, flags: -DBUILD_SHARED_LIBS=FALSE }
type:
- { name: Release }
- { name: Debug, flags: -DCMAKE_BUILD_TYPE=Debug -DSFML_ENABLE_COVERAGE=TRUE }

exclude:
- platform: { name: iOS }
config: { name: Shared }
- platform: { name: iOS Xcode }
config: { name: Shared }

include:
- platform: { name: Windows VS2022, os: windows-2022 }
config: { name: Unity, flags: -DBUILD_SHARED_LIBS=TRUE -DCMAKE_UNITY_BUILD=ON }
config: { name: Unity, flags: -DSFML_USE_MESA3D=TRUE -DBUILD_SHARED_LIBS=TRUE -DCMAKE_UNITY_BUILD=ON }
type: { name: Release }
- platform: { name: Windows VS2022, os: windows-2022 }
config: { name: Unity, flags: -DSFML_USE_MESA3D=TRUE -DBUILD_SHARED_LIBS=TRUE -DCMAKE_UNITY_BUILD=ON }
type: { name: Debug, flags: -DCMAKE_BUILD_TYPE=Debug -DSFML_ENABLE_COVERAGE=TRUE }
- platform: { name: Windows VS2022, os: windows-2022 }
config: { name: OpenGL ES, flags: -DSFML_USE_MESA3D=TRUE -DBUILD_SHARED_LIBS=TRUE -DSFML_OPENGL_ES=ON }
type: { name: Release }
- platform: { name: Windows VS2022, os: windows-2022 }
config: { name: Unity, flags: -DBUILD_SHARED_LIBS=TRUE -DCMAKE_UNITY_BUILD=ON }
config: { name: OpenGL ES, flags: -DSFML_USE_MESA3D=TRUE -DBUILD_SHARED_LIBS=TRUE -DSFML_OPENGL_ES=ON }
type: { name: Debug, flags: -DCMAKE_BUILD_TYPE=Debug -DSFML_ENABLE_COVERAGE=TRUE }
- platform: { name: MacOS, os: macos-11 }
config: { name: Frameworks, flags: -GNinja -DSFML_BUILD_FRAMEWORKS=TRUE -DBUILD_SHARED_LIBS=TRUE }
- platform: { name: MacOS, os: macos-11 }
config: { name: iOS, flags: -DCMAKE_TOOLCHAIN_FILE=$GITHUB_WORKSPACE/cmake/toolchains/iOS.toolchain.cmake -DIOS_PLATFORM=SIMULATOR }
- platform: { name: Android, os: ubuntu-latest }
config: { name: x86, flags: -GNinja -DCMAKE_ANDROID_ARCH_ABI=x86 -DCMAKE_SYSTEM_NAME=Android -DSFML_BUILD_TEST_SUITE=FALSE -DCMAKE_ANDROID_NDK=$GITHUB_WORKSPACE/android-ndk-r23b -DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=clang -DCMAKE_ANDROID_STL_TYPE=c++_shared -DCMAKE_ANDROID_API=26 }
- platform: { name: Android, os: ubuntu-latest }
Expand All @@ -57,7 +73,7 @@ jobs:

- name: Install Linux Dependencies
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install ninja-build xorg-dev libxrandr-dev libxcursor-dev libudev-dev libopenal-dev libflac-dev libvorbis-dev libgl1-mesa-dev libegl1-mesa-dev libdrm-dev libgbm-dev
run: sudo apt-get update && sudo apt-get install ninja-build xorg-dev libxrandr-dev libxcursor-dev libudev-dev libopenal-dev libflac-dev libvorbis-dev libgl1-mesa-dev libegl1-mesa-dev libdrm-dev libgbm-dev xvfb fluxbox

- name: Install Android Components
if: matrix.platform.name == 'Android'
Expand All @@ -74,7 +90,9 @@ jobs:
- name: Install macOS Tools
if: runner.os == 'macOS'
run: brew install gcovr ninja
run: |
brew update
brew install gcovr ninja || true
- name: Install OpenCppCoverage and add to PATH
uses: nick-fields/retry@v2
Expand All @@ -93,36 +111,81 @@ jobs:
- name: Build
shell: bash
run: cmake --build $GITHUB_WORKSPACE/build --config ${{ matrix.type.name == 'Debug' && 'Debug' || 'Release' }} --target install

- name: Test
if: runner.os == 'Windows'

- name: Prepare Test
shell: bash
run: cmake --build $GITHUB_WORKSPACE/build --target runtests --config ${{ matrix.type.name == 'Debug' && 'Debug' || 'Release' }}
run: |
set -e
# Start up Xvfb and fluxbox to host display tests
if [ "${{ runner.os }}" == "Linux" ]; then
Xvfb $DISPLAY -screen 0 1920x1080x24 &
sleep 5
fluxbox > /dev/null 2>&1 &
sleep 5
fi
# Make sure the build/bin directory exists so that the find command does not fail if no executables are built
mkdir -p $GITHUB_WORKSPACE/build/bin
- name: Test
if: runner.os != 'Windows'
uses: nick-fields/retry@v2
with:
max_attempts: 10
timeout_minutes: 3
retry_wait_seconds: 5
warning_on_retry: false
shell: bash
command: |
set -e
if [ "${{ runner.os }}" == "Windows" ]; then
# Make use of a test to print OpenGL vendor/renderer/version info to the console
find $GITHUB_WORKSPACE/build/bin -name test-sfml-window.exe -exec sh -c "{} --test-case=\"[Window] sf::Context\" --subcase=\"Version String\" | grep OpenGL" \;
# Run the tests
cmake --build $GITHUB_WORKSPACE/build --target runtests --config ${{ matrix.type.name == 'Debug' && 'Debug' || 'Release' }}
# Coverage is already generated on Windows when running tests.
else
# Make use of a test to print OpenGL vendor/renderer/version info to the console
find $GITHUB_WORKSPACE/build/bin -name test-sfml-window -exec sh -c "{} --test-case=\"[Window] sf::Context\" --subcase=\"Version String\" | grep OpenGL" \;
# Run the tests
ctest --test-dir $GITHUB_WORKSPACE/build --output-on-failure -C ${{ matrix.type.name == 'Debug' && 'Debug' || 'Release' }}
# Run gcovr to extract coverage information from the test run
if [ "${{ matrix.type.name }}" == "Debug" ]; then
gcovr -r $GITHUB_WORKSPACE -x $GITHUB_WORKSPACE/build/coverage.out -s -f 'src/SFML/.*' -f 'include/SFML/.*' ${{ matrix.platform.gcovr_options }} $GITHUB_WORKSPACE
fi
fi
- name: Download Codecov Uploader
if: matrix.type.name == 'Debug' && github.repository == 'SFML/SFML' # Disable upload in forks
shell: bash
run: ${{matrix.platform.prefix}} ctest --test-dir $GITHUB_WORKSPACE/build --output-on-failure --config ${{ matrix.type.name == 'Debug' && 'Debug' || 'Release' }}

- name: Generate Coverage Report
if: matrix.type.name == 'Debug' && runner.os != 'Windows' # Coverage is already generated on Windows when running tests.
run: gcovr -r $GITHUB_WORKSPACE -x $GITHUB_WORKSPACE/build/coverage.out -s -f 'src/SFML/.*' -f 'include/SFML/.*' ${{ matrix.platform.gcovr_options }} $GITHUB_WORKSPACE
run: |
platform=$(echo "${{ runner.os }}" | tr '[:upper:]' '[:lower:]')
if [ "$platform" == "windows" ]; then CODECOV_BINARY="codecov.exe"; else CODECOV_BINARY="codecov"; fi
curl https://keybase.io/codecovsecurity/pgp_keys.asc | gpg --no-default-keyring --keyring trustedkeys.gpg --import
curl -s --remote-name-all "https://uploader.codecov.io/latest/$platform/{$CODECOV_BINARY,$CODECOV_BINARY.SHA256SUM,$CODECOV_BINARY.SHA256SUM.sig}"
gpgv "$CODECOV_BINARY.SHA256SUM.sig" "$CODECOV_BINARY.SHA256SUM"
if [ "$platform" == "windows" ]; then powershell 'If ($(Compare-Object -ReferenceObject $(($(certUtil -hashfile codecov.exe SHA256)[1], "codecov.exe") -join " ") -DifferenceObject $(Get-Content codecov.exe.SHA256SUM)).length -eq 0) {echo "codecov: OK"} Else {exit 1}';
else shasum -a 256 -c codecov.SHA256SUM; fi
chmod +x "$CODECOV_BINARY"
echo "CODECOV_BINARY=$CODECOV_BINARY" >> $GITHUB_ENV
- name: Upload Coverage Report to Codecov
if: matrix.type.name == 'Debug' && github.repository == 'SFML/SFML' # Disable upload in forks
uses: codecov/codecov-action@v3
uses: nick-fields/retry@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ./build
files: ./build/coverage.out
fail_ci_if_error: true
timeout_seconds: 30
max_attempts: 10
retry_wait_seconds: 60
warning_on_retry: false
shell: bash
command: |
if [[ "${{ github.event_name }}" == "pull_request" || "${{ github.event_name }}" == "pull_request_target" ]]; then COMMIT_OVERRIDE="-C ${{ github.event.pull_request.head.sha }}"; fi
./${{ env.CODECOV_BINARY }} -n "${{ matrix.platform.name }} ${{ matrix.config.name }} ${{ matrix.type.name }}" -Z -f ./build/coverage.out $COMMIT_OVERRIDE -s ./build -e GITHUB_ACTION,GITHUB_RUN_ID,GITHUB_REF,GITHUB_REPOSITORY,GITHUB_SHA,GITHUB_HEAD_REF
- name: Test Install Interface
if: matrix.platform.name != 'Android' && matrix.config.name != 'iOS'
if: matrix.platform.name != 'Android'
shell: bash
run: |
cmake -S $GITHUB_WORKSPACE/test/install -B $GITHUB_WORKSPACE/test/install/build -DSFML_ROOT=$GITHUB_WORKSPACE/install -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=${{ matrix.type.name == 'Debug' && 'Debug' || 'Release' }} ${{matrix.platform.flags}} ${{matrix.config.flags}} ${{matrix.type.flags}}
cmake --build $GITHUB_WORKSPACE/test/install/build --config ${{ matrix.type.name == 'Debug' && 'Debug' || 'Release' }}
cmake --build $GITHUB_WORKSPACE/test/install/build --config ${{ matrix.type.name == 'Debug' && 'Debug' || 'Release' }} ${{matrix.platform.suffix}}
format:
name: Formatting with clang-format-${{ matrix.version }}
Expand Down Expand Up @@ -174,7 +237,8 @@ jobs:
- name: Install macOS Dependencies
if: runner.os == 'macOS'
run: |
brew install llvm
brew update
brew install llvm || true
echo /usr/local/opt/llvm/bin >> $GITHUB_PATH
- name: Configure
Expand Down
43 changes: 16 additions & 27 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,7 @@ endmacro()

# determine whether to create a debug or release build
sfml_set_option(CMAKE_BUILD_TYPE Release STRING "Choose the type of build (Debug or Release)")

if(NOT CMAKE_OSX_SYSROOT)
# query the path to the default SDK, will fail on non-macOS, but it's okay.
execute_process(COMMAND xcodebuild -sdk macosx -version Path
COMMAND head -n 1
COMMAND tr -d '\n'
OUTPUT_VARIABLE CMAKE_OSX_SYSROOT
ERROR_QUIET)
endif()
sfml_set_option(CMAKE_OSX_DEPLOYMENT_TARGET "13.0" STRING "The minimal iOS version that will be able to run the built binaries. Cannot be lower than 13.0")

# project name
project(SFML VERSION 3.0.0)
Expand All @@ -43,14 +35,10 @@ include(cmake/Config.cmake)
include(GNUInstallDirs)

# add an option for choosing the build type (shared or static)
if(NOT (SFML_OS_IOS OR SFML_OS_ANDROID))
if(NOT SFML_OS_ANDROID)
sfml_set_option(BUILD_SHARED_LIBS TRUE BOOL "TRUE to build SFML as shared libraries, FALSE to build it as static libraries")
else()
if(SFML_OS_IOS)
set(BUILD_SHARED_LIBS FALSE)
elseif(SFML_OS_ANDROID)
set(BUILD_SHARED_LIBS TRUE)
endif()
set(BUILD_SHARED_LIBS TRUE)
endif()

# add options to select which modules to build
Expand All @@ -70,22 +58,18 @@ if(SFML_BUILD_WINDOW)
endif()

# macOS specific options
if(SFML_OS_MACOSX)
if(SFML_OS_MACOSX OR SFML_OS_IOS)
# add an option to build frameworks instead of dylibs (release only)
sfml_set_option(SFML_BUILD_FRAMEWORKS FALSE BOOL "TRUE to build SFML as frameworks libraries (release only), FALSE to build according to BUILD_SHARED_LIBS")

if (SFML_OS_IOS AND NOT SFML_BUILD_FRAMEWORKS AND BUILD_SHARED_LIBS)
message(FATAL_ERROR "Naked dynamic libs not supported for iOS, build static or frameworks instead")
endif()

# add an option to automatically install Xcode templates
sfml_set_option(SFML_INSTALL_XCODE_TEMPLATES FALSE BOOL "TRUE to automatically install the Xcode templates, FALSE to do nothing about it. The templates are compatible with Xcode 4 and 5.")
endif()

# iOS specific options
if(SFML_OS_IOS)
# At the moment the minimal deployement target version is 10.2 only because the externals for iOS were built with that requirement.
sfml_set_option(SFML_IOS_DEPLOYMENT_TARGET "13.0" STRING "The minimal iOS version that will be able to run the built binaries. Cannot be lower than 10.2.")

sfml_set_option(SFML_CODE_SIGN_IDENTITY "iPhone Developer" STRING "The code signing identity to use when building for a real device")
endif()

# Android options
if(SFML_OS_ANDROID)
sfml_set_option(SFML_ANDROID_USE_SUSPEND_AWARE_CLOCK FALSE BOOL "TRUE to use an sf::Clock implementation which takes system sleep time into account (keeps advancing during suspension), FALSE to default to another available monotonic clock")
Expand Down Expand Up @@ -196,6 +180,10 @@ if(SFML_OS_WINDOWS)
if(BUILD_SHARED_LIBS AND SFML_USE_STATIC_STD_LIBS)
message(FATAL_ERROR "BUILD_SHARED_LIBS and SFML_USE_STATIC_STD_LIBS cannot be used together")
endif()

sfml_set_option(SFML_USE_MESA3D FALSE BOOL "TRUE to use the Mesa 3D graphics library for rendering, FALSE to use the system provided library for rendering")

include(cmake/Mesa3D.cmake)
endif()

# setup Mac OS X stuff
Expand Down Expand Up @@ -282,6 +270,10 @@ else()
# find only "root" headers
file(GLOB SFML_HEADERS RELATIVE ${PROJECT_SOURCE_DIR} "include/SFML/*")

# Because we use generator expressions in the post build scripts we need to
# suppress the generation of "EFFECTIVE_PLATFORM_NAME" as it will fail
set_property(GLOBAL PROPERTY XCODE_EMIT_EFFECTIVE_PLATFORM_NAME OFF)

# in fact we have to fool cmake to copy all the headers in subdirectories
# to do that we have to add the "root" headers to the PUBLIC_HEADER
# then we can run a post script to copy the remaining headers
Expand Down Expand Up @@ -448,9 +440,6 @@ elseif(SFML_OS_MACOSX)

elseif(SFML_OS_IOS)

# fix CMake install rules broken for iOS (see http://public.kitware.com/Bug/view.php?id=12506)
install(DIRECTORY "${PROJECT_BINARY_DIR}/lib/\$ENV{CONFIGURATION}/" DESTINATION ${CMAKE_INSTALL_LIBDIR})

if(NOT SFML_USE_SYSTEM_DEPS)
# since the iOS libraries are built as static, we must install the SFML dependencies
# too so that the end user can easily link them to its final application
Expand Down
25 changes: 13 additions & 12 deletions cmake/Config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,22 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "^NetBSD$")
set(SFML_OS_NETBSD 1)
# don't use the OpenGL ES implementation on NetBSD
set(OPENGL_ES 0)
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "iOS")
set(SFML_OS_IOS 1)
# As we want to find packages in our extlibs folder too
# we need to tell CMake we want to search there instead
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# use the OpenGL ES implementation on iOS
set(OPENGL_ES 1)
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
if(IOS)
set(SFML_OS_IOS 1)

# use the OpenGL ES implementation on iOS
set(OPENGL_ES 1)
else()
set(SFML_OS_MACOSX 1)

# don't use the OpenGL ES implementation on Mac OS X
set(OPENGL_ES 0)
endif()
set(SFML_OS_MACOSX 1)
# don't use the OpenGL ES implementation on Mac OS X
set(OPENGL_ES 0)
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Android")
set(SFML_OS_ANDROID 1)

# use the OpenGL ES implementation on Android
set(OPENGL_ES 1)
# comparing CMAKE_SYSTEM_NAME with "CYGWIN" generates a false warning depending on the CMake version
Expand Down

0 comments on commit b383a3d

Please sign in to comment.