mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-03-22 16:51:07 +01:00
Compare commits
38 Commits
release-2.
...
release-2.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
79ec168f3c | ||
|
|
40a3a80d45 | ||
|
|
025fc35c87 | ||
|
|
e9f5f3ac1f | ||
|
|
235c87dc92 | ||
|
|
b6535836aa | ||
|
|
5e90dd3507 | ||
|
|
d9139ff3de | ||
|
|
5669b97fd7 | ||
|
|
6f0fae7432 | ||
|
|
1c4dd015ac | ||
|
|
e9efcfb428 | ||
|
|
d32189918b | ||
|
|
38d3b1b6d6 | ||
|
|
1df907b1ba | ||
|
|
00a7191f67 | ||
|
|
d53b22e8f0 | ||
|
|
e5bb4fa90f | ||
|
|
ba9b075eba | ||
|
|
85b2733324 | ||
|
|
9519b9916c | ||
|
|
00494df2f1 | ||
|
|
948196448f | ||
|
|
7ca3d26e7a | ||
|
|
f79d28085d | ||
|
|
74a005f73f | ||
|
|
6f7aa1e755 | ||
|
|
847a6cce96 | ||
|
|
95aed34a69 | ||
|
|
21e0382edd | ||
|
|
0cdfdb9970 | ||
|
|
f75b0aa814 | ||
|
|
403f87340f | ||
|
|
07cfc34a2e | ||
|
|
4222cebef6 | ||
|
|
1e2aa2363b | ||
|
|
0b25cd2196 | ||
|
|
b7457ff61b |
62
.github/actions/setup-ninja/action.yml
vendored
Normal file
62
.github/actions/setup-ninja/action.yml
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
name: 'Setup ninja'
|
||||
description: 'Download ninja and add it to the PATH environment variable'
|
||||
inputs:
|
||||
version:
|
||||
description: 'Ninja version'
|
||||
default: '1.12.1'
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- name: 'Calculate variables'
|
||||
id: calc
|
||||
shell: sh
|
||||
run: |
|
||||
case "${{ runner.os }}-${{ runner.arch }}" in
|
||||
"Linux-X86" | "Linux-X64")
|
||||
archive="ninja-linux.zip"
|
||||
;;
|
||||
"Linux-ARM64")
|
||||
archive="ninja-linux-aarch64.zip"
|
||||
;;
|
||||
"macOS-X86" | "macOS-X64" | "macOS-ARM64")
|
||||
archive="ninja-mac.zip"
|
||||
;;
|
||||
"Windows-X86" | "Windows-X64")
|
||||
archive="ninja-win.zip"
|
||||
;;
|
||||
"Windows-ARM64")
|
||||
archive="ninja-winarm64.zip"
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported ${{ runner.os }}-${{ runner.arch }}"
|
||||
exit 1;
|
||||
;;
|
||||
esac
|
||||
echo "archive=${archive}" >> ${GITHUB_OUTPUT}
|
||||
echo "cache-key=${archive}-${{ inputs.version }}-${{ runner.os }}-${{ runner.arch }}" >> ${GITHUB_OUTPUT}
|
||||
- name: 'Restore cached ${{ steps.calc.outputs.archive }}'
|
||||
id: cache-restore
|
||||
uses: actions/cache/restore@v4
|
||||
with:
|
||||
path: '${{ runner.temp }}/${{ steps.calc.outputs.archive }}'
|
||||
key: ${{ steps.calc.outputs.cache-key }}
|
||||
- name: 'Download ninja ${{ inputs.version }} for ${{ runner.os }} (${{ runner.arch }})'
|
||||
if: ${{ !steps.cache-restore.outputs.cache-hit }}
|
||||
shell: pwsh
|
||||
run: |
|
||||
Invoke-WebRequest "https://github.com/ninja-build/ninja/releases/download/v${{ inputs.version }}/${{ steps.calc.outputs.archive }}" -OutFile "${{ runner.temp }}/${{ steps.calc.outputs.archive }}"
|
||||
- name: 'Cache ${{ steps.calc.outputs.archive }}'
|
||||
if: ${{ !steps.cache-restore.outputs.cache-hit }}
|
||||
uses: actions/cache/save@v4
|
||||
with:
|
||||
path: '${{ runner.temp }}/${{ steps.calc.outputs.archive }}'
|
||||
key: ${{ steps.calc.outputs.cache-key }}
|
||||
- name: 'Extract libusb'
|
||||
shell: pwsh
|
||||
run: |
|
||||
7z "-o${{ runner.temp }}/ninja-${{ inputs.version }}-${{ runner.arch }}" x "${{ runner.temp }}/${{ steps.calc.outputs.archive }}"
|
||||
- name: 'Set output variables'
|
||||
id: final
|
||||
shell: pwsh
|
||||
run: |
|
||||
echo "${{ runner.temp }}/ninja-${{ inputs.version }}-${{ runner.arch }}" >> $env:GITHUB_PATH
|
||||
406
.github/workflows/release.yml
vendored
Normal file
406
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,406 @@
|
||||
name: 'release'
|
||||
run-name: 'Create SDL release artifacts for ${{ inputs.commit }}'
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
commit:
|
||||
description: 'Commit of SDL'
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
|
||||
src:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
project: ${{ steps.releaser.outputs.project }}
|
||||
version: ${{ steps.releaser.outputs.version }}
|
||||
src-tar-gz: ${{ steps.releaser.outputs.src-tar-gz }}
|
||||
src-tar-xz: ${{ steps.releaser.outputs.src-tar-xz }}
|
||||
src-zip: ${{ steps.releaser.outputs.src-zip }}
|
||||
steps:
|
||||
- name: 'Set up Python'
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.11'
|
||||
- name: 'Fetch build-release.py'
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
sparse-checkout: 'build-scripts/build-release.py'
|
||||
- name: 'Set up SDL sources'
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: 'SDL'
|
||||
fetch-depth: 0
|
||||
- name: 'Build Source archive'
|
||||
id: releaser
|
||||
shell: bash
|
||||
run: |
|
||||
python build-scripts/build-release.py \
|
||||
--create source \
|
||||
--commit ${{ inputs.commit }} \
|
||||
--project SDL2 \
|
||||
--root "${{ github.workspace }}/SDL" \
|
||||
--github \
|
||||
--debug
|
||||
- name: 'Store source archives'
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: sources
|
||||
path: '${{ github.workspace}}/dist'
|
||||
|
||||
linux-verify:
|
||||
needs: [src]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 'Download source archives'
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: sources
|
||||
path: '${{ github.workspace }}'
|
||||
- name: 'Unzip ${{ needs.src.outputs.src-zip }}'
|
||||
id: zip
|
||||
run: |
|
||||
mkdir /tmp/zipdir
|
||||
cd /tmp/zipdir
|
||||
unzip "${{ github.workspace }}/${{ needs.src.outputs.src-zip }}"
|
||||
echo "path=/tmp/zipdir/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$GITHUB_OUTPUT
|
||||
- name: 'Untar ${{ needs.src.outputs.src-tar-gz }}'
|
||||
id: tar
|
||||
run: |
|
||||
mkdir -p /tmp/tardir
|
||||
tar -C /tmp/tardir -v -x -f "${{ github.workspace }}/${{ needs.src.outputs.src-tar-gz }}"
|
||||
echo "path=/tmp/tardir/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$GITHUB_OUTPUT
|
||||
- name: 'Compare contents of ${{ needs.src.outputs.src-zip }} and ${{ needs.src.outputs.src-tar-gz }}'
|
||||
run: |
|
||||
diff /tmp/zipdir /tmp/tardir
|
||||
- name: 'Test versioning'
|
||||
shell: bash
|
||||
run: |
|
||||
${{ steps.tar.outputs.path }}/build-scripts/test-versioning.sh
|
||||
- name: 'CMake (configure + build + tests + examples)'
|
||||
run: |
|
||||
cmake -S ${{ steps.tar.outputs.path }} -B /tmp/build -DSDL_TEST_LIBRARY=TRUE -DSDL_TESTS=TRUE -DSDL_EXAMPLES=TRUE
|
||||
cmake --build /tmp/build --verbose
|
||||
ctest --test-dir /tmp/build --no-tests=error --output-on-failure
|
||||
|
||||
dmg:
|
||||
needs: [src]
|
||||
runs-on: macos-latest
|
||||
outputs:
|
||||
dmg: ${{ steps.releaser.outputs.dmg }}
|
||||
steps:
|
||||
- name: 'Set up Python'
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.10'
|
||||
- name: 'Fetch build-release.py'
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
sparse-checkout: 'build-scripts/build-release.py'
|
||||
- name: 'Download source archives'
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: sources
|
||||
path: '${{ github.workspace }}'
|
||||
- name: 'Untar ${{ needs.src.outputs.src-tar-gz }}'
|
||||
id: tar
|
||||
run: |
|
||||
mkdir -p "${{ github.workspace }}/tardir"
|
||||
tar -C "${{ github.workspace }}/tardir" -v -x -f "${{ github.workspace }}/${{ needs.src.outputs.src-tar-gz }}"
|
||||
echo "path=${{ github.workspace }}/tardir/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$GITHUB_OUTPUT
|
||||
- name: 'Build SDL2.dmg'
|
||||
id: releaser
|
||||
shell: bash
|
||||
run: |
|
||||
python build-scripts/build-release.py \
|
||||
--create framework \
|
||||
--commit ${{ inputs.commit }} \
|
||||
--project SDL2 \
|
||||
--root "${{ steps.tar.outputs.path }}" \
|
||||
--github \
|
||||
--debug
|
||||
- name: 'Store DMG image file'
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: dmg
|
||||
path: '${{ github.workspace }}/dist'
|
||||
|
||||
dmg-verify:
|
||||
needs: [dmg, src]
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- name: 'Download source archives'
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: sources
|
||||
path: '${{ github.workspace }}'
|
||||
- name: 'Download ${{ needs.dmg.outputs.dmg }}'
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: dmg
|
||||
path: '${{ github.workspace }}'
|
||||
- name: 'Untar ${{ needs.src.outputs.src-tar-gz }}'
|
||||
id: src
|
||||
run: |
|
||||
mkdir -p /tmp/tardir
|
||||
tar -C /tmp/tardir -v -x -f "${{ github.workspace }}/${{ needs.src.outputs.src-tar-gz }}"
|
||||
echo "path=/tmp/tardir/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$GITHUB_OUTPUT
|
||||
- name: 'Mount ${{ needs.dmg.outputs.dmg }}'
|
||||
id: mount
|
||||
run: |
|
||||
hdiutil attach '${{ github.workspace }}/${{ needs.dmg.outputs.dmg }}'
|
||||
mount_point="/Volumes/${{ needs.src.outputs.project }}"
|
||||
if [ ! -d "$mount_point/${{ needs.src.outputs.project }}.framework" ]; then
|
||||
echo "Cannot find ${{ needs.src.outputs.project }}.framework!"
|
||||
exit 1
|
||||
fi
|
||||
echo "mount_point=$mount_point">>$GITHUB_OUTPUT
|
||||
- name: 'CMake (configure + build) Darwin'
|
||||
run: |
|
||||
set -e
|
||||
cmake -S "${{ steps.src.outputs.path }}/cmake/test" \
|
||||
-DTEST_FULL=FALSE \
|
||||
-DTEST_STATIC=FALSE \
|
||||
-DTEST_TEST=FALSE \
|
||||
-DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount_point }}" \
|
||||
-DCMAKE_SYSTEM_NAME=Darwin \
|
||||
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \
|
||||
-Werror=dev \
|
||||
-B build_darwin
|
||||
cmake --build build_darwin --config Release --verbose
|
||||
|
||||
cmake -S "${{ steps.src.outputs.path }}/cmake/test" \
|
||||
-DTEST_FULL=FALSE \
|
||||
-DTEST_STATIC=FALSE \
|
||||
-DTEST_TEST=FALSE \
|
||||
-DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount_point }}" \
|
||||
-DCMAKE_SYSTEM_NAME=Darwin \
|
||||
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \
|
||||
-Werror=dev \
|
||||
-B build_darwin_2
|
||||
cmake --build build_darwin --config Release --verbose
|
||||
|
||||
msvc:
|
||||
needs: [src]
|
||||
runs-on: windows-2019
|
||||
outputs:
|
||||
VC-x86: ${{ steps.releaser.outputs.VC-x86 }}
|
||||
VC-x64: ${{ steps.releaser.outputs.VC-x64 }}
|
||||
VC-devel: ${{ steps.releaser.outputs.VC-devel }}
|
||||
steps:
|
||||
- name: 'Set up Python'
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.10'
|
||||
- name: 'Fetch build-release.py'
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
sparse-checkout: 'build-scripts/build-release.py'
|
||||
- name: 'Download source archives'
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: sources
|
||||
path: '${{ github.workspace }}'
|
||||
- name: 'Unzip ${{ needs.src.outputs.src-zip }}'
|
||||
id: zip
|
||||
run: |
|
||||
New-Item C:\temp -ItemType Directory -ErrorAction SilentlyContinue
|
||||
cd C:\temp
|
||||
unzip "${{ github.workspace }}/${{ needs.src.outputs.src-zip }}"
|
||||
echo "path=C:\temp\${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$Env:GITHUB_OUTPUT
|
||||
- name: 'Build MSVC binary archives'
|
||||
id: releaser
|
||||
run: |
|
||||
python build-scripts/build-release.py `
|
||||
--create win32 `
|
||||
--commit ${{ inputs.commit }} `
|
||||
--project SDL2 `
|
||||
--root "${{ steps.zip.outputs.path }}" `
|
||||
--github `
|
||||
--debug
|
||||
- name: 'Store MSVC archives'
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: win32
|
||||
path: '${{ github.workspace }}/dist'
|
||||
|
||||
msvc-verify:
|
||||
needs: [msvc, src]
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: 'Fetch .github/actions/setup-ninja/action.yml'
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
sparse-checkout: '.github/actions/setup-ninja/action.yml'
|
||||
- name: 'Download source archives'
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: sources
|
||||
path: '${{ github.workspace }}'
|
||||
- name: 'Download MSVC binaries'
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: win32
|
||||
path: '${{ github.workspace }}'
|
||||
- name: 'Unzip ${{ needs.src.outputs.src-zip }}'
|
||||
id: src
|
||||
run: |
|
||||
mkdir '${{ github.workspace }}/sources'
|
||||
cd '${{ github.workspace }}/sources'
|
||||
unzip "${{ github.workspace }}/${{ needs.src.outputs.src-zip }}"
|
||||
echo "path=${{ github.workspace }}/sources/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$env:GITHUB_OUTPUT
|
||||
- name: 'Unzip ${{ needs.msvc.outputs.VC-devel }}'
|
||||
id: bin
|
||||
run: |
|
||||
mkdir '${{ github.workspace }}/vc'
|
||||
cd '${{ github.workspace }}/vc'
|
||||
unzip "${{ github.workspace }}/${{ needs.msvc.outputs.VC-devel }}"
|
||||
echo "path=${{ github.workspace }}/vc/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$env:GITHUB_OUTPUT
|
||||
- name: Set up ninja
|
||||
uses: ./.github/actions/setup-ninja
|
||||
- name: 'Configure vcvars x86'
|
||||
uses: ilammy/msvc-dev-cmd@v1
|
||||
with:
|
||||
arch: x64_x86
|
||||
- name: 'CMake (configure + build + tests) x86'
|
||||
run: |
|
||||
cmake -S "${{ steps.src.outputs.path }}/cmake/test" `
|
||||
-B build_x86 `
|
||||
-GNinja `
|
||||
-DCMAKE_BUILD_TYPE=Debug `
|
||||
-Werror=dev `
|
||||
-DTEST_FULL=FALSE `
|
||||
-DTEST_STATIC=FALSE `
|
||||
-DTEST_SHARED=TRUE `
|
||||
-DTEST_TEST=TRUE `
|
||||
-DCMAKE_SUPPRESS_REGENERATION=TRUE `
|
||||
-DCMAKE_PREFIX_PATH="${{ steps.bin.outputs.path }}"
|
||||
Start-Sleep -Seconds 2
|
||||
cmake --build build_x86 --config Release --verbose
|
||||
#ctest --test-dir build_x86 --no-tests=error -C Release --output-on-failure
|
||||
- name: 'Configure vcvars x64'
|
||||
uses: ilammy/msvc-dev-cmd@v1
|
||||
with:
|
||||
arch: x64
|
||||
- name: 'CMake (configure + build + tests) x64'
|
||||
run: |
|
||||
cmake -S "${{ steps.src.outputs.path }}/cmake/test" `
|
||||
-B build_x64 `
|
||||
-GNinja `
|
||||
-DCMAKE_BUILD_TYPE=Debug `
|
||||
-Werror=dev `
|
||||
-DTEST_FULL=FALSE `
|
||||
-DTEST_STATIC=FALSE `
|
||||
-DTEST_SHARED=TRUE `
|
||||
-DTEST_TEST=TRUE `
|
||||
-DCMAKE_SUPPRESS_REGENERATION=TRUE `
|
||||
-DCMAKE_PREFIX_PATH="${{ steps.bin.outputs.path }}"
|
||||
Start-Sleep -Seconds 2
|
||||
cmake --build build_x64 --config Release --verbose
|
||||
#ctest --test-dir build_x64 --no-tests=error -C Release --output-on-failure
|
||||
|
||||
mingw:
|
||||
needs: [src]
|
||||
runs-on: ubuntu-24.04 # FIXME: current ubuntu-latest ships an outdated mingw, replace with ubuntu-latest once 24.04 becomes the new default
|
||||
outputs:
|
||||
mingw-devel-tar-gz: ${{ steps.releaser.outputs.mingw-devel-tar-gz }}
|
||||
mingw-devel-tar-xz: ${{ steps.releaser.outputs.mingw-devel-tar-xz }}
|
||||
steps:
|
||||
- name: 'Set up Python'
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.10'
|
||||
- name: 'Fetch build-release.py'
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
sparse-checkout: 'build-scripts/build-release.py'
|
||||
- name: 'Install Mingw toolchain'
|
||||
run: |
|
||||
sudo apt-get update -y
|
||||
sudo apt-get install -y gcc-mingw-w64 g++-mingw-w64 ninja-build
|
||||
- name: 'Download source archives'
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: sources
|
||||
path: '${{ github.workspace }}'
|
||||
- name: 'Untar ${{ needs.src.outputs.src-tar-gz }}'
|
||||
id: tar
|
||||
run: |
|
||||
mkdir -p /tmp/tardir
|
||||
tar -C /tmp/tardir -v -x -f "${{ github.workspace }}/${{ needs.src.outputs.src-tar-gz }}"
|
||||
echo "path=/tmp/tardir/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$GITHUB_OUTPUT
|
||||
- name: 'Build MinGW binary archives'
|
||||
id: releaser
|
||||
run: |
|
||||
python build-scripts/build-release.py \
|
||||
--create mingw \
|
||||
--commit ${{ inputs.commit }} \
|
||||
--project SDL2 \
|
||||
--root "${{ steps.tar.outputs.path }}" \
|
||||
--github \
|
||||
--debug
|
||||
- name: 'Store MinGW archives'
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: mingw
|
||||
path: '${{ github.workspace }}/dist'
|
||||
|
||||
mingw-verify:
|
||||
needs: [mingw, src]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 'Install Mingw toolchain'
|
||||
run: |
|
||||
sudo apt-get update -y
|
||||
sudo apt-get install -y gcc-mingw-w64 g++-mingw-w64 ninja-build
|
||||
- name: 'Download source archives'
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: sources
|
||||
path: '${{ github.workspace }}'
|
||||
- name: 'Download MinGW binaries'
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: mingw
|
||||
path: '${{ github.workspace }}'
|
||||
- name: 'Untar ${{ needs.src.outputs.src-tar-gz }}'
|
||||
id: src
|
||||
run: |
|
||||
mkdir -p /tmp/tardir
|
||||
tar -C /tmp/tardir -v -x -f "${{ github.workspace }}/${{ needs.src.outputs.src-tar-gz }}"
|
||||
echo "path=/tmp/tardir/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$GITHUB_OUTPUT
|
||||
- name: 'Untar ${{ needs.mingw.outputs.mingw-devel-tar-gz }}'
|
||||
id: bin
|
||||
run: |
|
||||
mkdir -p /tmp/mingw-tardir
|
||||
tar -C /tmp/mingw-tardir -v -x -f "${{ github.workspace }}/${{ needs.mingw.outputs.mingw-devel-tar-gz }}"
|
||||
echo "path=/tmp/mingw-tardir/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$GITHUB_OUTPUT
|
||||
- name: 'CMake (configure + build) i686'
|
||||
run: |
|
||||
set -e
|
||||
cmake -S "${{ steps.src.outputs.path }}/cmake/test" \
|
||||
-DCMAKE_BUILD_TYPE="Release" \
|
||||
-DTEST_FULL=FALSE \
|
||||
-DTEST_STATIC=TRUE \
|
||||
-DTEST_TEST=TRUE \
|
||||
-DCMAKE_PREFIX_PATH="${{ steps.bin.outputs.path }}" \
|
||||
-DCMAKE_TOOLCHAIN_FILE="${{ steps.src.outputs.path }}/build-scripts/cmake-toolchain-mingw64-i686.cmake" \
|
||||
-DCMAKE_C_FLAGS="-DSDL_DISABLE_SSE4_2" \
|
||||
-Werror=dev \
|
||||
-B build_x86
|
||||
cmake --build build_x86 --config Release --verbose
|
||||
- name: 'CMake (configure + build) x86_64'
|
||||
run: |
|
||||
set -e
|
||||
cmake -S "${{ steps.src.outputs.path }}/cmake/test" \
|
||||
-DCMAKE_BUILD_TYPE="Release" \
|
||||
-DTEST_FULL=FALSE \
|
||||
-DTEST_STATIC=TRUE \
|
||||
-DTEST_TEST=TRUE \
|
||||
-DCMAKE_PREFIX_PATH="${{ steps.bin.outputs.path }}" \
|
||||
-DCMAKE_TOOLCHAIN_FILE="${{ steps.src.outputs.path }}/build-scripts/cmake-toolchain-mingw64-x86_64.cmake" \
|
||||
-DCMAKE_C_FLAGS="-DSDL_DISABLE_SSE4_2" \
|
||||
-Werror=dev \
|
||||
-B build_x64
|
||||
cmake --build build_x64 --config Release --verbose
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -16,6 +16,7 @@ gen
|
||||
Build
|
||||
buildbot
|
||||
/VERSION.txt
|
||||
dist
|
||||
|
||||
*.so
|
||||
*.so.*
|
||||
|
||||
@@ -87,7 +87,7 @@ endif()
|
||||
# See docs/release_checklist.md
|
||||
set(SDL_MAJOR_VERSION 2)
|
||||
set(SDL_MINOR_VERSION 30)
|
||||
set(SDL_MICRO_VERSION 6)
|
||||
set(SDL_MICRO_VERSION 8)
|
||||
set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}")
|
||||
|
||||
# Set defaults preventing destination file conflicts
|
||||
@@ -3520,7 +3520,10 @@ if(SDL_TEST)
|
||||
endif()
|
||||
|
||||
if(MSVC AND NOT SDL_LIBC)
|
||||
set(targets SDL2)
|
||||
set(targets )
|
||||
if(TARGET SDL2)
|
||||
list(APPEND targets SDL2)
|
||||
endif()
|
||||
if(TARGET SDL2-static)
|
||||
list(APPEND targets SDL2-static)
|
||||
endif()
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
LIBNAME = SDL2
|
||||
MAJOR_VERSION = 2
|
||||
MINOR_VERSION = 30
|
||||
MICRO_VERSION = 6
|
||||
MICRO_VERSION = 8
|
||||
VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)
|
||||
DESCRIPTION = Simple DirectMedia Layer 2
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
LIBNAME = SDL2
|
||||
MAJOR_VERSION = 2
|
||||
MINOR_VERSION = 30
|
||||
MICRO_VERSION = 6
|
||||
MICRO_VERSION = 8
|
||||
VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)
|
||||
|
||||
LIBHOME = .
|
||||
|
||||
@@ -44,22 +44,6 @@
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>
|
||||
|
||||
@@ -79,6 +79,8 @@ endif()
|
||||
unset(_sdl2_library)
|
||||
unset(_sdl2_dll_library)
|
||||
|
||||
set(SDL2_SDL2-static_FOUND FALSE)
|
||||
|
||||
set(_sdl2main_library "${SDL2_LIBDIR}/SDL2main.lib")
|
||||
if(EXISTS "${_sdl2main_library}")
|
||||
if(NOT TARGET SDL2::SDL2main)
|
||||
@@ -110,7 +112,7 @@ if(EXISTS "${_sdl2test_library}")
|
||||
endif()
|
||||
set(SDL2_SDL2test_FOUND TRUE)
|
||||
else()
|
||||
set(SDL2_SDL2_FOUND FALSE)
|
||||
set(SDL2_SDL2test_FOUND FALSE)
|
||||
endif()
|
||||
unset(_sdl2test_library)
|
||||
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>2.30.6</string>
|
||||
<string>2.30.8</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>SDLX</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>2.30.6</string>
|
||||
<string>2.30.8</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
@@ -9729,7 +9729,7 @@
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
DEPLOYMENT_POSTPROCESSING = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 3001.0.0;
|
||||
DYLIB_CURRENT_VERSION = 3001.6.0;
|
||||
DYLIB_CURRENT_VERSION = 3001.8.0;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_ALTIVEC_EXTENSIONS = YES;
|
||||
@@ -9770,7 +9770,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_LINK_OBJC_RUNTIME = NO;
|
||||
MARKETING_VERSION = 2.30.6;
|
||||
MARKETING_VERSION = 2.30.8;
|
||||
OTHER_LDFLAGS = "-liconv";
|
||||
};
|
||||
name = Release;
|
||||
@@ -9814,7 +9814,7 @@
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
DYLIB_COMPATIBILITY_VERSION = 3001.0.0;
|
||||
DYLIB_CURRENT_VERSION = 3001.6.0;
|
||||
DYLIB_CURRENT_VERSION = 3001.8.0;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
@@ -9856,7 +9856,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_LINK_OBJC_RUNTIME = NO;
|
||||
MARKETING_VERSION = 2.30.6;
|
||||
MARKETING_VERSION = 2.30.8;
|
||||
OTHER_LDFLAGS = "-liconv";
|
||||
};
|
||||
name = Debug;
|
||||
@@ -10063,7 +10063,7 @@
|
||||
DEFINES_MODULE = YES;
|
||||
DEVELOPMENT_TEAM = "";
|
||||
DYLIB_COMPATIBILITY_VERSION = 3001.0.0;
|
||||
DYLIB_CURRENT_VERSION = 3001.6.0;
|
||||
DYLIB_CURRENT_VERSION = 3001.8.0;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
@@ -10115,7 +10115,7 @@
|
||||
DEFINES_MODULE = YES;
|
||||
DEVELOPMENT_TEAM = "";
|
||||
DYLIB_COMPATIBILITY_VERSION = 3001.0.0;
|
||||
DYLIB_CURRENT_VERSION = 3001.6.0;
|
||||
DYLIB_CURRENT_VERSION = 3001.8.0;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Title SDL 2.30.6
|
||||
Title SDL 2.30.8
|
||||
Version 1
|
||||
Description SDL Library for Mac OS X (http://www.libsdl.org)
|
||||
DefaultLocation /Library/Frameworks
|
||||
|
||||
@@ -61,7 +61,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
||||
private static final String TAG = "SDL";
|
||||
private static final int SDL_MAJOR_VERSION = 2;
|
||||
private static final int SDL_MINOR_VERSION = 30;
|
||||
private static final int SDL_MICRO_VERSION = 6;
|
||||
private static final int SDL_MICRO_VERSION = 8;
|
||||
/*
|
||||
// Display InputType.SOURCE/CLASS of events and devices
|
||||
//
|
||||
@@ -89,7 +89,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
||||
| InputDevice.SOURCE_CLASS_POSITION
|
||||
| InputDevice.SOURCE_CLASS_TRACKBALL);
|
||||
|
||||
if (s2 != 0) cls += "Some_Unkown";
|
||||
if (s2 != 0) cls += "Some_Unknown";
|
||||
|
||||
s2 = s_copy & InputDevice.SOURCE_ANY; // keep source only, no class;
|
||||
|
||||
@@ -163,7 +163,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
||||
if (s == FLAG_TAINTED) src += " FLAG_TAINTED";
|
||||
s2 &= ~FLAG_TAINTED;
|
||||
|
||||
if (s2 != 0) src += " Some_Unkown";
|
||||
if (s2 != 0) src += " Some_Unknown";
|
||||
|
||||
Log.v(TAG, prefix + "int=" + s_copy + " CLASS={" + cls + " } source(s):" + src);
|
||||
}
|
||||
|
||||
642
build-scripts/build-release.py
Executable file
642
build-scripts/build-release.py
Executable file
@@ -0,0 +1,642 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import argparse
|
||||
import collections
|
||||
import contextlib
|
||||
import datetime
|
||||
import glob
|
||||
import io
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
from pathlib import Path
|
||||
import platform
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tarfile
|
||||
import tempfile
|
||||
import textwrap
|
||||
import typing
|
||||
import zipfile
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
VcArchDevel = collections.namedtuple("VcArchDevel", ("dll", "pdb", "imp", "main", "test"))
|
||||
GIT_HASH_FILENAME = ".git-hash"
|
||||
|
||||
ANDROID_AVAILABLE_ABIS = [
|
||||
"armeabi-v7a",
|
||||
"arm64-v8a",
|
||||
"x86",
|
||||
"x86_64",
|
||||
]
|
||||
ANDROID_MINIMUM_API = 19
|
||||
ANDROID_TARGET_API = 29
|
||||
ANDROID_MINIMUM_NDK = 21
|
||||
|
||||
|
||||
class Executer:
|
||||
def __init__(self, root: Path, dry: bool=False):
|
||||
self.root = root
|
||||
self.dry = dry
|
||||
|
||||
def run(self, cmd, stdout=False, dry_out=None, force=False):
|
||||
sys.stdout.flush()
|
||||
logger.info("Executing args=%r", cmd)
|
||||
if self.dry and not force:
|
||||
if stdout:
|
||||
return subprocess.run(["echo", "-E", dry_out or ""], stdout=subprocess.PIPE if stdout else None, text=True, check=True, cwd=self.root)
|
||||
else:
|
||||
return subprocess.run(cmd, stdout=subprocess.PIPE if stdout else None, text=True, check=True, cwd=self.root)
|
||||
|
||||
|
||||
class SectionPrinter:
|
||||
@contextlib.contextmanager
|
||||
def group(self, title: str):
|
||||
print(f"{title}:")
|
||||
yield
|
||||
|
||||
|
||||
class GitHubSectionPrinter(SectionPrinter):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.in_group = False
|
||||
|
||||
@contextlib.contextmanager
|
||||
def group(self, title: str):
|
||||
print(f"::group::{title}")
|
||||
assert not self.in_group, "Can enter a group only once"
|
||||
self.in_group = True
|
||||
yield
|
||||
self.in_group = False
|
||||
print("::endgroup::")
|
||||
|
||||
|
||||
class VisualStudio:
|
||||
def __init__(self, executer: Executer, year: typing.Optional[str]=None):
|
||||
self.executer = executer
|
||||
self.vsdevcmd = self.find_vsdevcmd(year)
|
||||
self.msbuild = self.find_msbuild()
|
||||
|
||||
@property
|
||||
def dry(self) -> bool:
|
||||
return self.executer.dry
|
||||
|
||||
VS_YEAR_TO_VERSION = {
|
||||
"2022": 17,
|
||||
"2019": 16,
|
||||
"2017": 15,
|
||||
"2015": 14,
|
||||
"2013": 12,
|
||||
}
|
||||
|
||||
def find_vsdevcmd(self, year: typing.Optional[str]=None) -> typing.Optional[Path]:
|
||||
vswhere_spec = ["-latest"]
|
||||
if year is not None:
|
||||
try:
|
||||
version = self.VS_YEAR_TO_VERSION[year]
|
||||
except KeyError:
|
||||
logger.error("Invalid Visual Studio year")
|
||||
return None
|
||||
vswhere_spec.extend(["-version", f"[{version},{version+1})"])
|
||||
vswhere_cmd = ["vswhere"] + vswhere_spec + ["-property", "installationPath"]
|
||||
vs_install_path = Path(self.executer.run(vswhere_cmd, stdout=True, dry_out="/tmp").stdout.strip())
|
||||
logger.info("VS install_path = %s", vs_install_path)
|
||||
assert vs_install_path.is_dir(), "VS installation path does not exist"
|
||||
vsdevcmd_path = vs_install_path / "Common7/Tools/vsdevcmd.bat"
|
||||
logger.info("vsdevcmd path = %s", vsdevcmd_path)
|
||||
if self.dry:
|
||||
vsdevcmd_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
vsdevcmd_path.touch(exist_ok=True)
|
||||
assert vsdevcmd_path.is_file(), "vsdevcmd.bat batch file does not exist"
|
||||
return vsdevcmd_path
|
||||
|
||||
def find_msbuild(self) -> typing.Optional[Path]:
|
||||
vswhere_cmd = ["vswhere", "-latest", "-requires", "Microsoft.Component.MSBuild", "-find", r"MSBuild\**\Bin\MSBuild.exe"]
|
||||
msbuild_path = Path(self.executer.run(vswhere_cmd, stdout=True, dry_out="/tmp/MSBuild.exe").stdout.strip())
|
||||
logger.info("MSBuild path = %s", msbuild_path)
|
||||
if self.dry:
|
||||
msbuild_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
msbuild_path.touch(exist_ok=True)
|
||||
assert msbuild_path.is_file(), "MSBuild.exe does not exist"
|
||||
return msbuild_path
|
||||
|
||||
def build(self, arch: str, platform: str, configuration: str, projects: list[Path]):
|
||||
assert projects, "Need at least one project to build"
|
||||
|
||||
vsdev_cmd_str = f"\"{self.vsdevcmd}\" -arch={arch}"
|
||||
msbuild_cmd_str = " && ".join([f"\"{self.msbuild}\" \"{project}\" /m /p:BuildInParallel=true /p:Platform={platform} /p:Configuration={configuration}" for project in projects])
|
||||
bat_contents = f"{vsdev_cmd_str} && {msbuild_cmd_str}\n"
|
||||
bat_path = Path(tempfile.gettempdir()) / "cmd.bat"
|
||||
with bat_path.open("w") as f:
|
||||
f.write(bat_contents)
|
||||
|
||||
logger.info("Running cmd.exe script (%s): %s", bat_path, bat_contents)
|
||||
cmd = ["cmd.exe", "/D", "/E:ON", "/V:OFF", "/S", "/C", f"CALL {str(bat_path)}"]
|
||||
self.executer.run(cmd)
|
||||
|
||||
|
||||
class Releaser:
|
||||
def __init__(self, project: str, commit: str, root: Path, dist_path: Path, section_printer: SectionPrinter, executer: Executer, cmake_generator: str):
|
||||
self.project = project
|
||||
self.version = self.extract_sdl_version(root=root, project=project)
|
||||
self.root = root
|
||||
self.commit = commit
|
||||
self.dist_path = dist_path
|
||||
self.section_printer = section_printer
|
||||
self.executer = executer
|
||||
self.cmake_generator = cmake_generator
|
||||
|
||||
self.artifacts: dict[str, Path] = {}
|
||||
|
||||
@property
|
||||
def dry(self) -> bool:
|
||||
return self.executer.dry
|
||||
|
||||
def prepare(self):
|
||||
logger.debug("Creating dist folder")
|
||||
self.dist_path.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
TreeItem = collections.namedtuple("TreeItem", ("path", "mode", "data", "time"))
|
||||
def _get_file_times(self, paths: tuple[str, ...]) -> dict[str, datetime.datetime]:
|
||||
dry_out = textwrap.dedent("""\
|
||||
time=2024-03-14T15:40:25-07:00
|
||||
|
||||
M\tCMakeLists.txt
|
||||
""")
|
||||
git_log_out = self.executer.run(["git", "log", "--name-status", '--pretty=time=%cI', self.commit], stdout=True, dry_out=dry_out).stdout.splitlines(keepends=False)
|
||||
current_time = None
|
||||
set_paths = set(paths)
|
||||
path_times: dict[str, datetime.datetime] = {}
|
||||
for line in git_log_out:
|
||||
if not line:
|
||||
continue
|
||||
if line.startswith("time="):
|
||||
current_time = datetime.datetime.fromisoformat(line.removeprefix("time="))
|
||||
continue
|
||||
mod_type, file_paths = line.split(maxsplit=1)
|
||||
assert current_time is not None
|
||||
for file_path in file_paths.split("\t"):
|
||||
if file_path in set_paths and file_path not in path_times:
|
||||
path_times[file_path] = current_time
|
||||
assert set(path_times.keys()) == set_paths
|
||||
return path_times
|
||||
|
||||
@staticmethod
|
||||
def _path_filter(path: str):
|
||||
if path.startswith(".git"):
|
||||
return False
|
||||
return True
|
||||
|
||||
def _get_git_contents(self) -> dict[str, TreeItem]:
|
||||
contents_tgz = subprocess.check_output(["git", "archive", "--format=tar.gz", self.commit, "-o", "/dev/stdout"], text=False)
|
||||
contents = tarfile.open(fileobj=io.BytesIO(contents_tgz), mode="r:gz")
|
||||
filenames = tuple(m.name for m in contents if m.isfile())
|
||||
assert "src/SDL.c" in filenames
|
||||
assert "include/SDL.h" in filenames
|
||||
file_times = self._get_file_times(filenames)
|
||||
git_contents = {}
|
||||
for ti in contents:
|
||||
if not ti.isfile():
|
||||
continue
|
||||
if not self._path_filter(ti.name):
|
||||
continue
|
||||
contents_file = contents.extractfile(ti.name)
|
||||
assert contents_file, f"{ti.name} is not a file"
|
||||
git_contents[ti.name] = self.TreeItem(path=ti.name, mode=ti.mode, data=contents_file.read(), time=file_times[ti.name])
|
||||
return git_contents
|
||||
|
||||
def create_source_archives(self) -> None:
|
||||
archive_base = f"{self.project}-{self.version}"
|
||||
|
||||
git_contents = self._get_git_contents()
|
||||
git_files = list(git_contents.values())
|
||||
assert len(git_contents) == len(git_files)
|
||||
|
||||
latest_mod_time = max(item.time for item in git_files)
|
||||
|
||||
git_files.append(self.TreeItem(path="VERSION.txt", data=f"{self.version}\n".encode(), mode=0o100644, time=latest_mod_time))
|
||||
git_files.append(self.TreeItem(path=GIT_HASH_FILENAME, data=f"{self.commit}\n".encode(), mode=0o100644, time=latest_mod_time))
|
||||
|
||||
git_files.sort(key=lambda v: v.time)
|
||||
|
||||
zip_path = self.dist_path / f"{archive_base}.zip"
|
||||
logger.info("Creating .zip source archive (%s)...", zip_path)
|
||||
if self.dry:
|
||||
zip_path.touch()
|
||||
else:
|
||||
with zipfile.ZipFile(zip_path, "w", compression=zipfile.ZIP_DEFLATED) as zip_object:
|
||||
for git_file in git_files:
|
||||
file_data_time = (git_file.time.year, git_file.time.month, git_file.time.day, git_file.time.hour, git_file.time.minute, git_file.time.second)
|
||||
zip_info = zipfile.ZipInfo(filename=f"{archive_base}/{git_file.path}", date_time=file_data_time)
|
||||
zip_info.external_attr = git_file.mode << 16
|
||||
zip_info.compress_type = zipfile.ZIP_DEFLATED
|
||||
zip_object.writestr(zip_info, data=git_file.data)
|
||||
self.artifacts["src-zip"] = zip_path
|
||||
|
||||
tar_types = (
|
||||
(".tar.gz", "gz"),
|
||||
(".tar.xz", "xz"),
|
||||
)
|
||||
for ext, comp in tar_types:
|
||||
tar_path = self.dist_path / f"{archive_base}{ext}"
|
||||
logger.info("Creating %s source archive (%s)...", ext, tar_path)
|
||||
if self.dry:
|
||||
tar_path.touch()
|
||||
else:
|
||||
with tarfile.open(tar_path, f"w:{comp}") as tar_object:
|
||||
for git_file in git_files:
|
||||
tar_info = tarfile.TarInfo(f"{archive_base}/{git_file.path}")
|
||||
tar_info.mode = git_file.mode
|
||||
tar_info.size = len(git_file.data)
|
||||
tar_info.mtime = git_file.time.timestamp()
|
||||
tar_object.addfile(tar_info, fileobj=io.BytesIO(git_file.data))
|
||||
|
||||
if tar_path.suffix == ".gz":
|
||||
# Zero the embedded timestamp in the gzip'ed tarball
|
||||
with open(tar_path, "r+b") as f:
|
||||
f.seek(4, 0)
|
||||
f.write(b"\x00\x00\x00\x00")
|
||||
|
||||
self.artifacts[f"src-tar-{comp}"] = tar_path
|
||||
|
||||
def create_framework(self, configuration: str="Release") -> None:
|
||||
dmg_in = self.root / f"Xcode/SDL/build/{self.project}.dmg"
|
||||
dmg_in.unlink(missing_ok=True)
|
||||
self.executer.run(["xcodebuild", "-project", str(self.root / "Xcode/SDL/SDL.xcodeproj"), "-target", "Standard DMG", "-configuration", configuration])
|
||||
if self.dry:
|
||||
dmg_in.parent.mkdir(parents=True, exist_ok=True)
|
||||
dmg_in.touch()
|
||||
|
||||
assert dmg_in.is_file(), f"{self.project}.dmg was not created by xcodebuild"
|
||||
|
||||
dmg_out = self.dist_path / f"{self.project}-{self.version}.dmg"
|
||||
shutil.copy(dmg_in, dmg_out)
|
||||
self.artifacts["dmg"] = dmg_out
|
||||
|
||||
@property
|
||||
def git_hash_data(self) -> bytes:
|
||||
return f"{self.commit}\n".encode()
|
||||
|
||||
def _tar_add_git_hash(self, tar_object: tarfile.TarFile, root: typing.Optional[str]=None, time: typing.Optional[datetime.datetime]=None):
|
||||
if not time:
|
||||
time = datetime.datetime(year=2024, month=4, day=1)
|
||||
path = GIT_HASH_FILENAME
|
||||
if root:
|
||||
path = f"{root}/{path}"
|
||||
|
||||
tar_info = tarfile.TarInfo(path)
|
||||
tar_info.mode = 0o100644
|
||||
tar_info.size = len(self.git_hash_data)
|
||||
tar_info.mtime = int(time.timestamp())
|
||||
tar_object.addfile(tar_info, fileobj=io.BytesIO(self.git_hash_data))
|
||||
|
||||
def _zip_add_git_hash(self, zip_file: zipfile.ZipFile, root: typing.Optional[str]=None, time: typing.Optional[datetime.datetime]=None):
|
||||
if not time:
|
||||
time = datetime.datetime(year=2024, month=4, day=1)
|
||||
path = GIT_HASH_FILENAME
|
||||
if root:
|
||||
path = f"{root}/{path}"
|
||||
|
||||
file_data_time = (time.year, time.month, time.day, time.hour, time.minute, time.second)
|
||||
zip_info = zipfile.ZipInfo(filename=path, date_time=file_data_time)
|
||||
zip_info.external_attr = 0o100644 << 16
|
||||
zip_info.compress_type = zipfile.ZIP_DEFLATED
|
||||
zip_file.writestr(zip_info, data=self.git_hash_data)
|
||||
|
||||
def create_mingw_archives(self) -> None:
|
||||
build_type = "Release"
|
||||
mingw_archs = ("i686", "x86_64")
|
||||
build_parent_dir = self.root / "build-mingw"
|
||||
|
||||
zip_path = self.dist_path / f"{self.project}-devel-{self.version}-mingw.zip"
|
||||
tar_exts = ("gz", "xz")
|
||||
tar_paths = { ext: self.dist_path / f"{self.project}-devel-{self.version}-mingw.tar.{ext}" for ext in tar_exts}
|
||||
|
||||
arch_install_paths = {}
|
||||
arch_files = {}
|
||||
|
||||
for arch in mingw_archs:
|
||||
build_path = build_parent_dir / f"build-{arch}"
|
||||
install_path = build_parent_dir / f"install-{arch}"
|
||||
arch_install_paths[arch] = install_path
|
||||
shutil.rmtree(install_path, ignore_errors=True)
|
||||
build_path.mkdir(parents=True, exist_ok=True)
|
||||
with self.section_printer.group(f"Configuring MinGW {arch}"):
|
||||
self.executer.run([
|
||||
"cmake", "-S", str(self.root), "-B", str(build_path),
|
||||
"--fresh",
|
||||
f'''-DCMAKE_C_FLAGS="-ffile-prefix-map={self.root}=/src/{self.project}"''',
|
||||
f'''-DCMAKE_CXX_FLAGS="-ffile-prefix-map={self.root}=/src/{self.project}"''',
|
||||
"-DSDL_SHARED=ON",
|
||||
"-DSDL_STATIC=ON",
|
||||
"-DSDL_DISABLE_INSTALL_DOCS=ON",
|
||||
"-DSDL_TEST_LIBRARY=ON",
|
||||
"-DSDL_TESTS=OFF",
|
||||
"-DCMAKE_INSTALL_BINDIR=bin",
|
||||
"-DCMAKE_INSTALL_DATAROOTDIR=share",
|
||||
"-DCMAKE_INSTALL_INCLUDEDIR=include",
|
||||
"-DCMAKE_INSTALL_LIBDIR=lib",
|
||||
f"-DCMAKE_BUILD_TYPE={build_type}",
|
||||
f"-DCMAKE_TOOLCHAIN_FILE={self.root}/build-scripts/cmake-toolchain-mingw64-{arch}.cmake",
|
||||
f"-G{self.cmake_generator}",
|
||||
f"-DCMAKE_INSTALL_PREFIX={install_path}",
|
||||
])
|
||||
with self.section_printer.group(f"Build MinGW {arch}"):
|
||||
self.executer.run(["cmake", "--build", str(build_path), "--verbose", "--config", build_type])
|
||||
with self.section_printer.group(f"Install MinGW {arch}"):
|
||||
self.executer.run(["cmake", "--install", str(build_path), "--strip", "--config", build_type])
|
||||
arch_files[arch] = list(Path(r) / f for r, _, files in os.walk(install_path) for f in files)
|
||||
|
||||
extra_files = (
|
||||
("mingw/pkg-support/INSTALL.txt", ""),
|
||||
("mingw/pkg-support/Makefile", ""),
|
||||
("mingw/pkg-support/cmake/sdl2-config.cmake", "cmake/"),
|
||||
("mingw/pkg-support/cmake/sdl2-config-version.cmake", "cmake/"),
|
||||
("BUGS.txt", ""),
|
||||
("CREDITS.txt", ""),
|
||||
("README-SDL.txt", ""),
|
||||
("WhatsNew.txt", ""),
|
||||
("LICENSE.txt", ""),
|
||||
("README.md", ""),
|
||||
("docs/*.md", "docs/"),
|
||||
)
|
||||
test_files = list(Path(r) / f for r, _, files in os.walk(self.root / "test") for f in files)
|
||||
|
||||
# FIXME: split SDL2.dll debug information into debug library
|
||||
# objcopy --only-keep-debug SDL2.dll SDL2.debug.dll
|
||||
# objcopy --add-gnu-debuglink=SDL2.debug.dll SDL2.dll
|
||||
# objcopy --strip-debug SDL2.dll
|
||||
|
||||
for comp in tar_exts:
|
||||
logger.info("Creating %s...", tar_paths[comp])
|
||||
with tarfile.open(tar_paths[comp], f"w:{comp}") as tar_object:
|
||||
arc_root = f"{self.project}-{self.version}"
|
||||
for file_path_glob, arcdirname in extra_files:
|
||||
assert not arcdirname or arcdirname[-1] == "/"
|
||||
for file_path in glob.glob(file_path_glob, root_dir=self.root):
|
||||
arcname = f"{arc_root}/{arcdirname}{Path(file_path).name}"
|
||||
tar_object.add(self.root / file_path, arcname=arcname)
|
||||
for arch in mingw_archs:
|
||||
install_path = arch_install_paths[arch]
|
||||
arcname_parent = f"{arc_root}/{arch}-w64-mingw32"
|
||||
for file in arch_files[arch]:
|
||||
arcname = os.path.join(arcname_parent, file.relative_to(install_path))
|
||||
tar_object.add(file, arcname=arcname)
|
||||
for test_file in test_files:
|
||||
arcname = f"{arc_root}/test/{test_file.relative_to(self.root/'test')}"
|
||||
tar_object.add(test_file, arcname=arcname)
|
||||
self._tar_add_git_hash(tar_object=tar_object, root=arc_root)
|
||||
|
||||
self.artifacts[f"mingw-devel-tar-{comp}"] = tar_paths[comp]
|
||||
|
||||
def build_vs(self, arch: str, platform: str, vs: VisualStudio, configuration: str="Release") -> VcArchDevel:
|
||||
dll_path = self.root / f"VisualC/SDL/{platform}/{configuration}/{self.project}.dll"
|
||||
pdb_path = self.root / f"VisualC/SDL/{platform}/{configuration}/{self.project}.pdb"
|
||||
imp_path = self.root / f"VisualC/SDL/{platform}/{configuration}/{self.project}.lib"
|
||||
test_path = self.root / f"VisualC/SDLtest/{platform}/{configuration}/{self.project}test.lib"
|
||||
main_path = self.root / f"VisualC/SDLmain/{platform}/{configuration}/{self.project}main.lib"
|
||||
|
||||
dll_path.unlink(missing_ok=True)
|
||||
pdb_path.unlink(missing_ok=True)
|
||||
imp_path.unlink(missing_ok=True)
|
||||
test_path.unlink(missing_ok=True)
|
||||
main_path.unlink(missing_ok=True)
|
||||
|
||||
projects = [
|
||||
self.root / "VisualC/SDL/SDL.vcxproj",
|
||||
self.root / "VisualC/SDLmain/SDLmain.vcxproj",
|
||||
self.root / "VisualC/SDLtest/SDLtest.vcxproj",
|
||||
]
|
||||
|
||||
with self.section_printer.group(f"Build {arch} VS binary"):
|
||||
vs.build(arch=arch, platform=platform, configuration=configuration, projects=projects)
|
||||
|
||||
if self.dry:
|
||||
dll_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
dll_path.touch()
|
||||
pdb_path.touch()
|
||||
imp_path.touch()
|
||||
main_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
main_path.touch()
|
||||
test_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
test_path.touch()
|
||||
|
||||
assert dll_path.is_file(), f"{self.project}.dll has not been created"
|
||||
assert pdb_path.is_file(), f"{self.project}.pdb has not been created"
|
||||
assert imp_path.is_file(), f"{self.project}.lib has not been created"
|
||||
assert main_path.is_file(), f"{self.project}main.lib has not been created"
|
||||
assert test_path.is_file(), f"{self.project}est.lib has not been created"
|
||||
|
||||
zip_path = self.dist_path / f"{self.project}-{self.version}-win32-{arch}.zip"
|
||||
zip_path.unlink(missing_ok=True)
|
||||
logger.info("Creating %s", zip_path)
|
||||
with zipfile.ZipFile(zip_path, mode="w", compression=zipfile.ZIP_DEFLATED) as zf:
|
||||
logger.debug("Adding %s", dll_path.name)
|
||||
zf.write(dll_path, arcname=dll_path.name)
|
||||
logger.debug("Adding %s", "README-SDL.txt")
|
||||
zf.write(self.root / "README-SDL.txt", arcname="README-SDL.txt")
|
||||
self._zip_add_git_hash(zip_file=zf)
|
||||
self.artifacts[f"VC-{arch}"] = zip_path
|
||||
|
||||
return VcArchDevel(dll=dll_path, pdb=pdb_path, imp=imp_path, main=main_path, test=test_path)
|
||||
|
||||
|
||||
def build_vs_devel(self, arch_vc: dict[str, VcArchDevel]) -> None:
|
||||
zip_path = self.dist_path / f"{self.project}-devel-{self.version}-VC.zip"
|
||||
archive_prefix = f"{self.project}-{self.version}"
|
||||
|
||||
def zip_file(zf: zipfile.ZipFile, path: Path, arcrelpath: str):
|
||||
arcname = f"{archive_prefix}/{arcrelpath}"
|
||||
logger.debug("Adding %s to %s", path, arcname)
|
||||
zf.write(path, arcname=arcname)
|
||||
|
||||
def zip_directory(zf: zipfile.ZipFile, directory: Path, arcrelpath: str):
|
||||
for f in directory.iterdir():
|
||||
if f.is_file():
|
||||
arcname = f"{archive_prefix}/{arcrelpath}/{f.name}"
|
||||
logger.debug("Adding %s to %s", f, arcname)
|
||||
zf.write(f, arcname=arcname)
|
||||
|
||||
with zipfile.ZipFile(zip_path, mode="w", compression=zipfile.ZIP_DEFLATED) as zf:
|
||||
for arch, binaries in arch_vc.items():
|
||||
zip_file(zf, path=binaries.dll, arcrelpath=f"lib/{arch}/{binaries.dll.name}")
|
||||
zip_file(zf, path=binaries.imp, arcrelpath=f"lib/{arch}/{binaries.imp.name}")
|
||||
zip_file(zf, path=binaries.pdb, arcrelpath=f"lib/{arch}/{binaries.pdb.name}")
|
||||
zip_file(zf, path=binaries.main, arcrelpath=f"lib/{arch}/{binaries.main.name}")
|
||||
zip_file(zf, path=binaries.test, arcrelpath=f"lib/{arch}/{binaries.test.name}")
|
||||
|
||||
zip_directory(zf, directory=self.root / "include", arcrelpath="include")
|
||||
zip_directory(zf, directory=self.root / "docs", arcrelpath="docs")
|
||||
zip_directory(zf, directory=self.root / "VisualC/pkg-support/cmake", arcrelpath="cmake")
|
||||
|
||||
for txt in ("BUGS.txt", "README-SDL.txt", "WhatsNew.txt"):
|
||||
zip_file(zf, path=self.root / txt, arcrelpath=txt)
|
||||
zip_file(zf, path=self.root / "LICENSE.txt", arcrelpath="COPYING.txt")
|
||||
zip_file(zf, path=self.root / "README.md", arcrelpath="README.txt")
|
||||
|
||||
self._zip_add_git_hash(zip_file=zf, root=archive_prefix)
|
||||
self.artifacts["VC-devel"] = zip_path
|
||||
|
||||
@classmethod
|
||||
def extract_sdl_version(cls, root: Path, project: str) -> str:
|
||||
with open(root / f"include/SDL_version.h", "r") as f:
|
||||
text = f.read()
|
||||
major = next(re.finditer(r"^#define SDL_MAJOR_VERSION\s+([0-9]+)$", text, flags=re.M)).group(1)
|
||||
minor = next(re.finditer(r"^#define SDL_MINOR_VERSION\s+([0-9]+)$", text, flags=re.M)).group(1)
|
||||
micro = next(re.finditer(r"^#define SDL_PATCHLEVEL\s+([0-9]+)$", text, flags=re.M)).group(1)
|
||||
return f"{major}.{minor}.{micro}"
|
||||
|
||||
|
||||
def main(argv=None) -> int:
|
||||
parser = argparse.ArgumentParser(allow_abbrev=False, description="Create SDL release artifacts")
|
||||
parser.add_argument("--root", metavar="DIR", type=Path, default=Path(__file__).absolute().parents[1], help="Root of SDL")
|
||||
parser.add_argument("--out", "-o", metavar="DIR", dest="dist_path", type=Path, default="dist", help="Output directory")
|
||||
parser.add_argument("--github", action="store_true", help="Script is running on a GitHub runner")
|
||||
parser.add_argument("--commit", default="HEAD", help="Git commit/tag of which a release should be created")
|
||||
parser.add_argument("--project", required=True, help="Name of the project (e.g. SDL2")
|
||||
parser.add_argument("--create", choices=["source", "mingw", "win32", "framework", "android"], required=True, action="append", dest="actions", help="What to do")
|
||||
parser.set_defaults(loglevel=logging.INFO)
|
||||
parser.add_argument('--vs-year', dest="vs_year", help="Visual Studio year")
|
||||
parser.add_argument('--android-api', type=int, dest="android_api", help="Android API version")
|
||||
parser.add_argument('--android-home', dest="android_home", default=os.environ.get("ANDROID_HOME"), help="Android Home folder")
|
||||
parser.add_argument('--android-ndk-home', dest="android_ndk_home", default=os.environ.get("ANDROID_NDK_HOME"), help="Android NDK Home folder")
|
||||
parser.add_argument('--android-abis', dest="android_abis", nargs="*", choices=ANDROID_AVAILABLE_ABIS, default=list(ANDROID_AVAILABLE_ABIS), help="Android NDK Home folder")
|
||||
parser.add_argument('--cmake-generator', dest="cmake_generator", default="Ninja", help="CMake Generator")
|
||||
parser.add_argument('--debug', action='store_const', const=logging.DEBUG, dest="loglevel", help="Print script debug information")
|
||||
parser.add_argument('--dry-run', action='store_true', dest="dry", help="Don't execute anything")
|
||||
parser.add_argument('--force', action='store_true', dest="force", help="Ignore a non-clean git tree")
|
||||
|
||||
args = parser.parse_args(argv)
|
||||
logging.basicConfig(level=args.loglevel, format='[%(levelname)s] %(message)s')
|
||||
args.actions = set(args.actions)
|
||||
args.dist_path = args.dist_path.absolute()
|
||||
args.root = args.root.absolute()
|
||||
args.dist_path = args.dist_path.absolute()
|
||||
if args.dry:
|
||||
args.dist_path = args.dist_path / "dry"
|
||||
|
||||
if args.github:
|
||||
section_printer: SectionPrinter = GitHubSectionPrinter()
|
||||
else:
|
||||
section_printer = SectionPrinter()
|
||||
|
||||
executer = Executer(root=args.root, dry=args.dry)
|
||||
|
||||
root_git_hash_path = args.root / GIT_HASH_FILENAME
|
||||
root_is_maybe_archive = root_git_hash_path.is_file()
|
||||
if root_is_maybe_archive:
|
||||
logger.warning("%s detected: Building from archive", GIT_HASH_FILENAME)
|
||||
archive_commit = root_git_hash_path.read_text().strip()
|
||||
if args.commit != archive_commit:
|
||||
logger.warning("Commit argument is %s, but archive commit is %s. Using %s.", args.commit, archive_commit, archive_commit)
|
||||
args.commit = archive_commit
|
||||
else:
|
||||
args.commit = executer.run(["git", "rev-parse", args.commit], stdout=True, dry_out="e5812a9fd2cda317b503325a702ba3c1c37861d9").stdout.strip()
|
||||
logger.info("Using commit %s", args.commit)
|
||||
|
||||
releaser = Releaser(
|
||||
project=args.project,
|
||||
commit=args.commit,
|
||||
root=args.root,
|
||||
dist_path=args.dist_path,
|
||||
executer=executer,
|
||||
section_printer=section_printer,
|
||||
cmake_generator=args.cmake_generator,
|
||||
)
|
||||
|
||||
if root_is_maybe_archive:
|
||||
logger.warning("Building from archive. Skipping clean git tree check.")
|
||||
else:
|
||||
porcelain_status = executer.run(["git", "status", "--ignored", "--porcelain"], stdout=True, dry_out="\n").stdout.strip()
|
||||
if porcelain_status:
|
||||
print(porcelain_status)
|
||||
logger.warning("The tree is dirty! Do not publish any generated artifacts!")
|
||||
if not args.force:
|
||||
raise Exception("The git repo contains modified and/or non-committed files. Run with --force to ignore.")
|
||||
|
||||
with section_printer.group("Arguments"):
|
||||
print(f"project = {args.project}")
|
||||
print(f"version = {releaser.version}")
|
||||
print(f"commit = {args.commit}")
|
||||
print(f"out = {args.dist_path}")
|
||||
print(f"actions = {args.actions}")
|
||||
print(f"dry = {args.dry}")
|
||||
print(f"force = {args.force}")
|
||||
print(f"cmake_generator = {args.cmake_generator}")
|
||||
|
||||
releaser.prepare()
|
||||
|
||||
if "source" in args.actions:
|
||||
if root_is_maybe_archive:
|
||||
raise Exception("Cannot build source archive from source archive")
|
||||
with section_printer.group("Create source archives"):
|
||||
releaser.create_source_archives()
|
||||
|
||||
if "framework" in args.actions:
|
||||
if platform.system() != "Darwin" and not args.dry:
|
||||
parser.error("framework artifact(s) can only be built on Darwin")
|
||||
|
||||
releaser.create_framework()
|
||||
|
||||
if "win32" in args.actions:
|
||||
if platform.system() != "Windows" and not args.dry:
|
||||
parser.error("win32 artifact(s) can only be built on Windows")
|
||||
with section_printer.group("Find Visual Studio"):
|
||||
vs = VisualStudio(executer=executer)
|
||||
x86 = releaser.build_vs(arch="x86", platform="Win32", vs=vs)
|
||||
x64 = releaser.build_vs(arch="x64", platform="x64", vs=vs)
|
||||
with section_printer.group("Create SDL VC development zip"):
|
||||
arch_vc = {
|
||||
"x86": x86,
|
||||
"x64": x64,
|
||||
}
|
||||
releaser.build_vs_devel(arch_vc)
|
||||
|
||||
if "mingw" in args.actions:
|
||||
releaser.create_mingw_archives()
|
||||
|
||||
if "android" in args.actions:
|
||||
if args.android_home is None or not Path(args.android_home).is_dir():
|
||||
parser.error("Invalid $ANDROID_HOME or --android-home: must be a directory containing the Android SDK")
|
||||
if args.android_ndk_home is None or not Path(args.android_ndk_home).is_dir():
|
||||
parser.error("Invalid $ANDROID_NDK_HOME or --android_ndk_home: must be a directory containing the Android NDK")
|
||||
if args.android_api is None:
|
||||
with section_printer.group("Detect Android APIS"):
|
||||
args.android_api = releaser.detect_android_api(android_home=args.android_home)
|
||||
if args.android_api is None or not (Path(args.android_home) / f"platforms/android-{args.android_api}").is_dir():
|
||||
parser.error("Invalid --android-api, and/or could not be detected")
|
||||
if not args.android_abis:
|
||||
parser.error("Need at least one Android ABI")
|
||||
with section_printer.group("Android arguments"):
|
||||
print(f"android_home = {args.android_home}")
|
||||
print(f"android_ndk_home = {args.android_ndk_home}")
|
||||
print(f"android_api = {args.android_api}")
|
||||
print(f"android_abis = {args.android_abis}")
|
||||
releaser.create_android_archives(
|
||||
android_api=args.android_api,
|
||||
android_home=args.android_home,
|
||||
android_ndk_home=args.android_ndk_home,
|
||||
android_abis=args.android_abis,
|
||||
)
|
||||
|
||||
|
||||
with section_printer.group("Summary"):
|
||||
print(f"artifacts = {releaser.artifacts}")
|
||||
|
||||
if args.github:
|
||||
if args.dry:
|
||||
os.environ["GITHUB_OUTPUT"] = "/tmp/github_output.txt"
|
||||
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
|
||||
f.write(f"project={releaser.project}\n")
|
||||
f.write(f"version={releaser.version}\n")
|
||||
for k, v in releaser.artifacts.items():
|
||||
f.write(f"{k}={v.name}\n")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
18
build-scripts/cmake-toolchain-mingw64-i686.cmake
Normal file
18
build-scripts/cmake-toolchain-mingw64-i686.cmake
Normal file
@@ -0,0 +1,18 @@
|
||||
set(CMAKE_SYSTEM_NAME Windows)
|
||||
set(CMAKE_SYSTEM_PROCESSOR x86)
|
||||
|
||||
find_program(CMAKE_C_COMPILER NAMES i686-w64-mingw32-gcc)
|
||||
find_program(CMAKE_CXX_COMPILER NAMES i686-w64-mingw32-g++)
|
||||
find_program(CMAKE_RC_COMPILER NAMES i686-w64-mingw32-windres windres)
|
||||
|
||||
if(NOT CMAKE_C_COMPILER)
|
||||
message(FATAL_ERROR "Failed to find CMAKE_C_COMPILER.")
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_CXX_COMPILER)
|
||||
message(FATAL_ERROR "Failed to find CMAKE_CXX_COMPILER.")
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_RC_COMPILER)
|
||||
message(FATAL_ERROR "Failed to find CMAKE_RC_COMPILER.")
|
||||
endif()
|
||||
18
build-scripts/cmake-toolchain-mingw64-x86_64.cmake
Normal file
18
build-scripts/cmake-toolchain-mingw64-x86_64.cmake
Normal file
@@ -0,0 +1,18 @@
|
||||
set(CMAKE_SYSTEM_NAME Windows)
|
||||
set(CMAKE_SYSTEM_PROCESSOR x86_64)
|
||||
|
||||
find_program(CMAKE_C_COMPILER NAMES x86_64-w64-mingw32-gcc)
|
||||
find_program(CMAKE_CXX_COMPILER NAMES x86_64-w64-mingw32-g++)
|
||||
find_program(CMAKE_RC_COMPILER NAMES x86_64-w64-mingw32-windres windres)
|
||||
|
||||
if(NOT CMAKE_C_COMPILER)
|
||||
message(FATAL_ERROR "Failed to find CMAKE_C_COMPILER.")
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_CXX_COMPILER)
|
||||
message(FATAL_ERROR "Failed to find CMAKE_CXX_COMPILER.")
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_RC_COMPILER)
|
||||
message(FATAL_ERROR "Failed to find CMAKE_RC_COMPILER.")
|
||||
endif()
|
||||
41
build-scripts/create-release.py
Executable file
41
build-scripts/create-release.py
Executable file
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
import logging
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
def determine_project() -> str:
|
||||
text = (ROOT / "CMakeLists.txt").read_text()
|
||||
match = next(re.finditer(r"project\((?P<project>[a-zA-Z0-9_]+)\s+", text, flags=re.M))
|
||||
project_with_version = match["project"]
|
||||
project, _ = re.subn("([^a-zA-Z_])", "", project_with_version)
|
||||
return project
|
||||
|
||||
|
||||
def main():
|
||||
project = determine_project()
|
||||
default_remote = f"libsdl-org/{project}"
|
||||
|
||||
current_commit = subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=ROOT, text=True).strip()
|
||||
|
||||
parser = argparse.ArgumentParser(allow_abbrev=False)
|
||||
parser.add_argument("--ref", required=True, help=f"Name of branch or tag containing release.yml")
|
||||
parser.add_argument("--remote", "-R", default=default_remote, help=f"Remote repo (default={default_remote})")
|
||||
parser.add_argument("--commit", default=current_commit, help=f"Commit (default={current_commit})")
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
print(f"Running release.yml workflow:")
|
||||
print(f" commit = {args.commit}")
|
||||
print(f" remote = {args.remote}")
|
||||
|
||||
subprocess.check_call(["gh", "-R", args.remote, "workflow", "run", "release.yml", "--ref", args.ref, "-f", f"commit={args.commit}"], cwd=ROOT)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
@@ -27,6 +27,12 @@ add_feature_info("TEST_SHARED" TEST_SHARED "Test linking with shared library")
|
||||
option(TEST_STATIC "Test linking to static SDL2 library" ON)
|
||||
add_feature_info("TEST_STATIC" TEST_STATIC "Test linking with static library")
|
||||
|
||||
option(TEST_TEST "Test linking to SDL3_test library" ON)
|
||||
add_feature_info("TEST_TEST" TEST_STATIC "Test linking to SDL test library")
|
||||
|
||||
option(TEST_FULL "Run complete SDL test suite" OFF)
|
||||
add_feature_info("TEST_FULL" TEST_FULL "Build full SDL testsuite")
|
||||
|
||||
if(TEST_SHARED)
|
||||
find_package(SDL2 REQUIRED CONFIG COMPONENTS SDL2)
|
||||
if(EMSCRIPTEN OR (WIN32 AND NOT WINDOWS_STORE))
|
||||
@@ -75,6 +81,11 @@ if(TEST_SHARED)
|
||||
generate_export_header(sharedlib-shared-vars EXPORT_MACRO_NAME MYLIBRARY_EXPORT)
|
||||
target_compile_definitions(sharedlib-shared-vars PRIVATE "EXPORT_HEADER=\"${CMAKE_CURRENT_BINARY_DIR}/sharedlib-shared-vars_export.h\"")
|
||||
set_target_properties(sharedlib-shared-vars PROPERTIES C_VISIBILITY_PRESET "hidden")
|
||||
|
||||
if(TEST_TEST)
|
||||
add_executable(sdltest-shared sdltest.c)
|
||||
target_link_libraries(sdltest-shared PRIVATE SDL2::SDL2main SDL2::SDL2test SDL2::SDL2)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(TEST_STATIC)
|
||||
@@ -111,6 +122,21 @@ if(TEST_STATIC)
|
||||
target_link_libraries(cli-static-vars PRIVATE ${SDL2_STATIC_LIBRARIES})
|
||||
target_include_directories(cli-static-vars PRIVATE ${SDL2_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
if(CMAKE_Swift_COMPILER)
|
||||
add_executable(swift-static main.swift)
|
||||
target_include_directories(swift-static PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/swift")
|
||||
target_link_libraries(swift-static PRIVATE SDL2::SDL2-static)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(TEST_FULL)
|
||||
enable_testing()
|
||||
set(SDL_TESTS_TIMEOUT_MULTIPLIER "1" CACHE STRING "Test timeout multiplier")
|
||||
set(SDL_TESTS_LINK_SHARED ${TEST_SHARED})
|
||||
|
||||
add_definitions(-DNO_BUILD_CONFIG)
|
||||
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/../../test" SDL_test)
|
||||
endif()
|
||||
|
||||
message(STATUS "SDL2_PREFIX: ${SDL2_PREFIX}")
|
||||
|
||||
9
cmake/test/sdltest.c
Normal file
9
cmake/test/sdltest.c
Normal file
@@ -0,0 +1,9 @@
|
||||
#include "SDL.h"
|
||||
#include "SDL_test.h"
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
SDLTest_CommonState state;
|
||||
SDLTest_CommonDefaultArgs(&state, argc, argv);
|
||||
return 0;
|
||||
}
|
||||
2
configure
vendored
2
configure
vendored
@@ -3508,7 +3508,7 @@ orig_CFLAGS="$CFLAGS"
|
||||
# See docs/release_checklist.md
|
||||
SDL_MAJOR_VERSION=2
|
||||
SDL_MINOR_VERSION=30
|
||||
SDL_MICRO_VERSION=6
|
||||
SDL_MICRO_VERSION=8
|
||||
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
|
||||
|
||||
SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION`
|
||||
|
||||
@@ -13,7 +13,7 @@ dnl Set various version strings - taken gratefully from the GTk sources
|
||||
# See docs/release_checklist.md
|
||||
SDL_MAJOR_VERSION=2
|
||||
SDL_MINOR_VERSION=30
|
||||
SDL_MICRO_VERSION=6
|
||||
SDL_MICRO_VERSION=8
|
||||
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
|
||||
|
||||
SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION`
|
||||
|
||||
@@ -1912,6 +1912,7 @@ extern "C" {
|
||||
* Since it's driver-specific, it's only supported where possible and
|
||||
* implemented. Currently supported the following drivers:
|
||||
*
|
||||
* - Wayland (wayland)
|
||||
* - KMSDRM (kmsdrm)
|
||||
* - Raspberry Pi (raspberrypi)
|
||||
*/
|
||||
|
||||
@@ -59,7 +59,7 @@ typedef struct SDL_version
|
||||
*/
|
||||
#define SDL_MAJOR_VERSION 2
|
||||
#define SDL_MINOR_VERSION 30
|
||||
#define SDL_PATCHLEVEL 6
|
||||
#define SDL_PATCHLEVEL 8
|
||||
|
||||
/**
|
||||
* Macro to determine SDL version program was compiled against.
|
||||
|
||||
18
mingw/pkg-support/INSTALL.txt
Normal file
18
mingw/pkg-support/INSTALL.txt
Normal file
@@ -0,0 +1,18 @@
|
||||
|
||||
The 32-bit files are in i686-w64-mingw32
|
||||
The 64-bit files are in x86_64-w64-mingw32
|
||||
|
||||
To install SDL for native development:
|
||||
make native
|
||||
|
||||
To install SDL for cross-compiling development:
|
||||
make cross
|
||||
|
||||
Look at the example programs in ./test, and check out online documentation:
|
||||
http://wiki.libsdl.org/
|
||||
|
||||
Join the SDL developer mailing list if you want to join the community:
|
||||
http://www.libsdl.org/mailing-list.php
|
||||
|
||||
That's it!
|
||||
Sam Lantinga <slouken@libsdl.org>
|
||||
28
mingw/pkg-support/Makefile
Normal file
28
mingw/pkg-support/Makefile
Normal file
@@ -0,0 +1,28 @@
|
||||
#
|
||||
# Makefile for installing the mingw32 version of the SDL library
|
||||
|
||||
CROSS_PATH := /usr/local
|
||||
ARCHITECTURES := i686-w64-mingw32 x86_64-w64-mingw32
|
||||
|
||||
all install:
|
||||
@echo "Type \"make native\" to install 32-bit to /usr"
|
||||
@echo "Type \"make cross\" to install 32-bit and 64-bit to $(CROSS_PATH)"
|
||||
|
||||
native:
|
||||
make install-package arch=i686-w64-mingw32 prefix=/usr
|
||||
|
||||
cross:
|
||||
for arch in $(ARCHITECTURES); do \
|
||||
make install-package arch=$$arch prefix=$(CROSS_PATH)/$$arch; \
|
||||
done
|
||||
|
||||
install-package:
|
||||
@if test -d $(arch) && test -d $(prefix); then \
|
||||
(cd $(arch) && cp -rv bin include lib share $(prefix)/); \
|
||||
sed "s|^prefix=.*|prefix=$(prefix)|" <$(arch)/bin/sdl2-config >$(prefix)/bin/sdl2-config; \
|
||||
chmod 755 $(prefix)/bin/sdl2-config; \
|
||||
sed "s|^prefix=.*|prefix=$(prefix)|" <$(arch)/lib/pkgconfig/sdl2.pc >$(prefix)/lib/pkgconfig/sdl2.pc; \
|
||||
else \
|
||||
echo "*** ERROR: $(arch) or $(prefix) does not exist!"; \
|
||||
exit 1; \
|
||||
fi
|
||||
@@ -2,9 +2,9 @@
|
||||
# This file is meant to be placed in a cmake subfolder of SDL2-devel-2.x.y-mingw
|
||||
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
set(sdl2_config_path "${CMAKE_CURRENT_LIST_DIR}/../i686-w64-mingw32/lib/cmake/SDL2/sdl2-config-version.cmake")
|
||||
set(sdl2_config_path "${CMAKE_CURRENT_LIST_DIR}/../i686-w64-mingw32/lib/cmake/SDL2/SDL2ConfigVersion.cmake")
|
||||
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(sdl2_config_path "${CMAKE_CURRENT_LIST_DIR}/../x86_64-w64-mingw32/lib/cmake/SDL2/sdl2-config-version.cmake")
|
||||
set(sdl2_config_path "${CMAKE_CURRENT_LIST_DIR}/../x86_64-w64-mingw32/lib/cmake/SDL2/SDL2ConfigVersion.cmake")
|
||||
else()
|
||||
set(PACKAGE_VERSION_UNSUITABLE TRUE)
|
||||
return()
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
# This file is meant to be placed in a cmake subfolder of SDL2-devel-2.x.y-mingw
|
||||
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
set(sdl2_config_path "${CMAKE_CURRENT_LIST_DIR}/../i686-w64-mingw32/lib/cmake/SDL2/sdl2-config.cmake")
|
||||
set(sdl2_config_path "${CMAKE_CURRENT_LIST_DIR}/../i686-w64-mingw32/lib/cmake/SDL2/SDL2Config.cmake")
|
||||
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(sdl2_config_path "${CMAKE_CURRENT_LIST_DIR}/../x86_64-w64-mingw32/lib/cmake/SDL2/sdl2-config.cmake")
|
||||
set(sdl2_config_path "${CMAKE_CURRENT_LIST_DIR}/../x86_64-w64-mingw32/lib/cmake/SDL2/SDL2Config.cmake")
|
||||
else()
|
||||
set(SDL2_FOUND FALSE)
|
||||
return()
|
||||
|
||||
@@ -897,8 +897,12 @@ static void PULSEAUDIO_DetectDevices(void)
|
||||
|
||||
/* ok, we have a sane list, let's set up hotplug notifications now... */
|
||||
SDL_AtomicSet(&pulseaudio_hotplug_thread_active, 1);
|
||||
pulseaudio_hotplug_thread = SDL_CreateThreadInternal(HotplugThread, "PulseHotplug", 256 * 1024, ready_sem); /* !!! FIXME: this can probably survive in significantly less stack space. */
|
||||
SDL_SemWait(ready_sem);
|
||||
pulseaudio_hotplug_thread = SDL_CreateThreadInternal(HotplugThread, "PulseHotplug", 0, ready_sem);
|
||||
if (pulseaudio_hotplug_thread) {
|
||||
SDL_SemWait(ready_sem);
|
||||
} else {
|
||||
SDL_AtomicSet(&pulseaudio_hotplug_thread_active, 0); // thread failed to start, we'll go on without hotplug.
|
||||
}
|
||||
SDL_DestroySemaphore(ready_sem);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
|
||||
#ifdef HAVE_STDIO_H
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
#ifdef HAVE_LIMITS_H
|
||||
@@ -632,7 +633,7 @@ SDL_RWops *SDL_RWFromFile(const char *file, const char *mode)
|
||||
FILE *fp = fopen(file, mode);
|
||||
#endif
|
||||
if (!fp) {
|
||||
SDL_SetError("Couldn't open %s", file);
|
||||
SDL_SetError("Couldn't open %s: %s", file, strerror(errno));
|
||||
} else if (!IsRegularFileOrPipe(fp)) {
|
||||
fclose(fp);
|
||||
fp = NULL;
|
||||
|
||||
@@ -370,6 +370,7 @@ static Uint32 initial_wheel_devices[] = {
|
||||
MAKE_VIDPID(0x044f, 0xb65e), /* Thrustmaster T500RS */
|
||||
MAKE_VIDPID(0x044f, 0xb664), /* Thrustmaster TX (initial mode) */
|
||||
MAKE_VIDPID(0x044f, 0xb669), /* Thrustmaster TX (active mode) */
|
||||
MAKE_VIDPID(0x044f, 0xb67f), /* Thrustmaster TMX */
|
||||
MAKE_VIDPID(0x044f, 0xb691), /* Thrustmaster TS-XW (initial mode) */
|
||||
MAKE_VIDPID(0x044f, 0xb692), /* Thrustmaster TS-XW (active mode) */
|
||||
MAKE_VIDPID(0x0483, 0x0522), /* Simagic Wheelbase (including M10, Alpha Mini, Alpha, Alpha U) */
|
||||
@@ -395,6 +396,7 @@ static Uint32 initial_wheel_devices[] = {
|
||||
MAKE_VIDPID(0x2433, 0xf303), /* Asetek SimSports La Prima Wheelbase */
|
||||
MAKE_VIDPID(0x2433, 0xf306), /* Asetek SimSports Tony Kannan Wheelbase */
|
||||
MAKE_VIDPID(0x3416, 0x0301), /* Cammus C5 Wheelbase */
|
||||
MAKE_VIDPID(0x3416, 0x0302), /* Cammus C12 Wheelbase */
|
||||
MAKE_VIDPID(0x346e, 0x0000), /* Moza R16/R21 Wheelbase */
|
||||
MAKE_VIDPID(0x346e, 0x0002), /* Moza R9 Wheelbase */
|
||||
MAKE_VIDPID(0x346e, 0x0004), /* Moza R5 Wheelbase */
|
||||
|
||||
@@ -69,7 +69,7 @@ static const ControllerDescription_t arrControllers[] = {
|
||||
{ MAKE_CONTROLLER_ID( 0x20d6, 0x576d ), k_eControllerType_PS3Controller, NULL }, // Power A PS3
|
||||
{ MAKE_CONTROLLER_ID( 0x20d6, 0xca6d ), k_eControllerType_PS3Controller, NULL }, // From SDL
|
||||
{ MAKE_CONTROLLER_ID( 0x2563, 0x0523 ), k_eControllerType_PS3Controller, NULL }, // Digiflip GP006
|
||||
{ MAKE_CONTROLLER_ID( 0x2563, 0x0575 ), k_eControllerType_PS3Controller, NULL }, // From SDL
|
||||
{ MAKE_CONTROLLER_ID( 0x2563, 0x0575 ), k_eControllerType_PS3Controller, "Retro-bit Controller" }, // SWITCH CO., LTD. Retro-bit Controller
|
||||
{ MAKE_CONTROLLER_ID( 0x25f0, 0x83c3 ), k_eControllerType_PS3Controller, NULL }, // gioteck vx2
|
||||
{ MAKE_CONTROLLER_ID( 0x25f0, 0xc121 ), k_eControllerType_PS3Controller, NULL }, //
|
||||
{ MAKE_CONTROLLER_ID( 0x2c22, 0x2003 ), k_eControllerType_PS3Controller, NULL }, // Qanba Drone
|
||||
|
||||
@@ -50,6 +50,7 @@ typedef struct
|
||||
SDL_HIDAPI_Device *device;
|
||||
SDL_Joystick *joystick;
|
||||
SDL_bool is_shanwan;
|
||||
SDL_bool has_analog_buttons;
|
||||
SDL_bool report_sensors;
|
||||
SDL_bool effects_updated;
|
||||
int player_index;
|
||||
@@ -145,6 +146,7 @@ static SDL_bool HIDAPI_DriverPS3_InitDevice(SDL_HIDAPI_Device *device)
|
||||
}
|
||||
ctx->device = device;
|
||||
ctx->is_shanwan = is_shanwan;
|
||||
ctx->has_analog_buttons = SDL_TRUE;
|
||||
|
||||
device->context = ctx;
|
||||
|
||||
@@ -247,7 +249,10 @@ static SDL_bool HIDAPI_DriverPS3_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joy
|
||||
|
||||
/* Initialize the joystick capabilities */
|
||||
joystick->nbuttons = 15;
|
||||
joystick->naxes = 16;
|
||||
joystick->naxes = 6;
|
||||
if (ctx->has_analog_buttons) {
|
||||
joystick->naxes += 10;
|
||||
}
|
||||
joystick->epowerlevel = SDL_JOYSTICK_POWER_WIRED;
|
||||
|
||||
SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_ACCEL, 100.0f);
|
||||
@@ -432,7 +437,7 @@ static void HIDAPI_DriverPS3_HandleStatePacket(SDL_Joystick *joystick, SDL_Drive
|
||||
SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTY, axis);
|
||||
|
||||
/* Buttons are mapped as axes in the order they appear in the button enumeration */
|
||||
{
|
||||
if (ctx->has_analog_buttons) {
|
||||
static int button_axis_offsets[] = {
|
||||
24, /* SDL_CONTROLLER_BUTTON_A */
|
||||
23, /* SDL_CONTROLLER_BUTTON_B */
|
||||
@@ -617,6 +622,11 @@ static SDL_bool HIDAPI_DriverPS3ThirdParty_InitDevice(SDL_HIDAPI_Device *device)
|
||||
return SDL_FALSE;
|
||||
}
|
||||
ctx->device = device;
|
||||
if (device->vendor_id == USB_VENDOR_SWITCH && device->product_id == USB_PRODUCT_SWITCH_RETROBIT_CONTROLLER) {
|
||||
ctx->has_analog_buttons = SDL_FALSE;
|
||||
} else {
|
||||
ctx->has_analog_buttons = SDL_TRUE;
|
||||
}
|
||||
|
||||
device->context = ctx;
|
||||
|
||||
@@ -650,8 +660,17 @@ static SDL_bool HIDAPI_DriverPS3ThirdParty_OpenJoystick(SDL_HIDAPI_Device *devic
|
||||
|
||||
/* Initialize the joystick capabilities */
|
||||
joystick->nbuttons = 15;
|
||||
joystick->naxes = 16;
|
||||
joystick->epowerlevel = SDL_JOYSTICK_POWER_WIRED;
|
||||
joystick->naxes = 6;
|
||||
if (ctx->has_analog_buttons) {
|
||||
joystick->naxes += 10;
|
||||
}
|
||||
|
||||
if (device->vendor_id == USB_VENDOR_SWITCH && device->product_id == USB_PRODUCT_SWITCH_RETROBIT_CONTROLLER) {
|
||||
// This is a wireless controller using a USB dongle
|
||||
joystick->epowerlevel = SDL_JOYSTICK_POWER_UNKNOWN;
|
||||
} else {
|
||||
joystick->epowerlevel = SDL_JOYSTICK_POWER_WIRED;
|
||||
}
|
||||
|
||||
return SDL_TRUE;
|
||||
}
|
||||
@@ -762,7 +781,7 @@ static void HIDAPI_DriverPS3ThirdParty_HandleStatePacket18(SDL_Joystick *joystic
|
||||
SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTY, axis);
|
||||
|
||||
/* Buttons are mapped as axes in the order they appear in the button enumeration */
|
||||
{
|
||||
if (ctx->has_analog_buttons) {
|
||||
static int button_axis_offsets[] = {
|
||||
12, /* SDL_GAMEPAD_BUTTON_A */
|
||||
11, /* SDL_GAMEPAD_BUTTON_B */
|
||||
@@ -871,9 +890,17 @@ static void HIDAPI_DriverPS3ThirdParty_HandleStatePacket19(SDL_Joystick *joystic
|
||||
}
|
||||
}
|
||||
|
||||
axis = ((int)data[17] * 257) - 32768;
|
||||
if (data[0] & 0x40) {
|
||||
axis = 32767;
|
||||
} else {
|
||||
axis = ((int)data[17] * 257) - 32768;
|
||||
}
|
||||
SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERLEFT, axis);
|
||||
axis = ((int)data[18] * 257) - 32768;
|
||||
if (data[0] & 0x80) {
|
||||
axis = 32767;
|
||||
} else {
|
||||
axis = ((int)data[18] * 257) - 32768;
|
||||
}
|
||||
SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERRIGHT, axis);
|
||||
axis = ((int)data[3] * 257) - 32768;
|
||||
SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTX, axis);
|
||||
@@ -885,7 +912,7 @@ static void HIDAPI_DriverPS3ThirdParty_HandleStatePacket19(SDL_Joystick *joystic
|
||||
SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTY, axis);
|
||||
|
||||
/* Buttons are mapped as axes in the order they appear in the button enumeration */
|
||||
{
|
||||
if (ctx->has_analog_buttons) {
|
||||
static int button_axis_offsets[] = {
|
||||
13, /* SDL_CONTROLLER_BUTTON_A */
|
||||
12, /* SDL_CONTROLLER_BUTTON_B */
|
||||
|
||||
@@ -1208,6 +1208,7 @@ static SDL_bool HIDAPI_DriverPS4_UpdateDevice(SDL_HIDAPI_Device *device)
|
||||
if (SDL_TICKS_PASSED(now, ctx->last_packet + BLUETOOTH_DISCONNECT_TIMEOUT_MS)) {
|
||||
/* Send an empty output report to tickle the Bluetooth stack */
|
||||
HIDAPI_DriverPS4_TickleBluetooth(device);
|
||||
ctx->last_packet = now;
|
||||
}
|
||||
} else {
|
||||
/* Reconnect the Bluetooth device once the USB device is gone */
|
||||
|
||||
@@ -1500,6 +1500,7 @@ static SDL_bool HIDAPI_DriverPS5_UpdateDevice(SDL_HIDAPI_Device *device)
|
||||
if (SDL_TICKS_PASSED(now, ctx->last_packet + BLUETOOTH_DISCONNECT_TIMEOUT_MS)) {
|
||||
/* Send an empty output report to tickle the Bluetooth stack */
|
||||
HIDAPI_DriverPS5_TickleBluetooth(device);
|
||||
ctx->last_packet = now;
|
||||
}
|
||||
} else {
|
||||
/* Reconnect the Bluetooth device once the USB device is gone */
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
#define USB_VENDOR_SONY 0x054c
|
||||
#define USB_VENDOR_THRUSTMASTER 0x044f
|
||||
#define USB_VENDOR_TURTLE_BEACH 0x10f5
|
||||
#define USB_VENDOR_SWITCH 0x2563
|
||||
#define USB_VENDOR_VALVE 0x28de
|
||||
#define USB_VENDOR_ZEROPLUS 0x0c12
|
||||
|
||||
@@ -116,6 +117,7 @@
|
||||
#define USB_PRODUCT_SONY_DS4_STRIKEPAD 0x05c5
|
||||
#define USB_PRODUCT_SONY_DS5 0x0ce6
|
||||
#define USB_PRODUCT_SONY_DS5_EDGE 0x0df2
|
||||
#define USB_PRODUCT_SWITCH_RETROBIT_CONTROLLER 0x0575
|
||||
#define USB_PRODUCT_THRUSTMASTER_ESWAPX_PRO 0xd012
|
||||
#define USB_PRODUCT_TURTLE_BEACH_SERIES_X_REACT_R 0x7013
|
||||
#define USB_PRODUCT_TURTLE_BEACH_SERIES_X_RECON 0x7009
|
||||
|
||||
@@ -1290,6 +1290,7 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
|
||||
value_caps = SDL_stack_alloc(HIDP_VALUE_CAPS, caps.NumberInputValueCaps);
|
||||
if (SDL_HidP_GetValueCaps(HidP_Input, value_caps, &caps.NumberInputValueCaps, ctx->preparsed_data) != HIDP_STATUS_SUCCESS) {
|
||||
RAWINPUT_JoystickClose(joystick);
|
||||
SDL_stack_free(button_caps);
|
||||
return SDL_SetError("Couldn't get device value capabilities");
|
||||
}
|
||||
|
||||
@@ -1318,6 +1319,8 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
|
||||
ctx->button_indices = (USHORT *)SDL_malloc(joystick->nbuttons * sizeof(*ctx->button_indices));
|
||||
if (!ctx->button_indices) {
|
||||
RAWINPUT_JoystickClose(joystick);
|
||||
SDL_stack_free(value_caps);
|
||||
SDL_stack_free(button_caps);
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
@@ -1342,6 +1345,8 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
|
||||
joystick->nbuttons += 1;
|
||||
}
|
||||
|
||||
SDL_stack_free(button_caps);
|
||||
|
||||
for (i = 0; i < caps.NumberInputValueCaps; ++i) {
|
||||
HIDP_VALUE_CAPS *cap = &value_caps[i];
|
||||
|
||||
@@ -1371,6 +1376,7 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
|
||||
ctx->axis_indices = (USHORT *)SDL_malloc(joystick->naxes * sizeof(*ctx->axis_indices));
|
||||
if (!ctx->axis_indices) {
|
||||
RAWINPUT_JoystickClose(joystick);
|
||||
SDL_stack_free(value_caps);
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
@@ -1404,6 +1410,7 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
|
||||
ctx->hat_indices = (USHORT *)SDL_malloc(joystick->nhats * sizeof(*ctx->hat_indices));
|
||||
if (!ctx->hat_indices) {
|
||||
RAWINPUT_JoystickClose(joystick);
|
||||
SDL_stack_free(value_caps);
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
@@ -1422,6 +1429,8 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
|
||||
}
|
||||
}
|
||||
|
||||
SDL_stack_free(value_caps);
|
||||
|
||||
joystick->epowerlevel = SDL_JOYSTICK_POWER_UNKNOWN;
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -377,7 +377,7 @@ static int SDLCALL SDL_JoystickThread(void *_data)
|
||||
#ifdef SDL_JOYSTICK_XINPUT
|
||||
/* WM_DEVICECHANGE not working, poll for new XINPUT controllers */
|
||||
SDL_CondWaitTimeout(s_condJoystickThread, s_mutexJoyStickEnum, 1000);
|
||||
if (SDL_XINPUT_Enabled() && XINPUTGETCAPABILITIES) {
|
||||
if (SDL_XINPUT_Enabled()) {
|
||||
/* scan for any change in XInput devices */
|
||||
Uint8 userId;
|
||||
for (userId = 0; userId < XUSER_MAX_COUNT; userId++) {
|
||||
@@ -473,12 +473,12 @@ void WINDOWS_JoystickQuit(void);
|
||||
*/
|
||||
static int WINDOWS_JoystickInit(void)
|
||||
{
|
||||
if (SDL_DINPUT_JoystickInit() < 0) {
|
||||
if (SDL_XINPUT_JoystickInit() < 0) {
|
||||
WINDOWS_JoystickQuit();
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (SDL_XINPUT_JoystickInit() < 0) {
|
||||
if (SDL_DINPUT_JoystickInit() < 0) {
|
||||
WINDOWS_JoystickQuit();
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ extern "C" {
|
||||
/*
|
||||
* Internal stuff.
|
||||
*/
|
||||
static SDL_bool s_bXInputEnabled = SDL_TRUE;
|
||||
static SDL_bool s_bXInputEnabled = SDL_FALSE;
|
||||
|
||||
static SDL_bool SDL_XInputUseOldJoystickMapping(void)
|
||||
{
|
||||
@@ -65,11 +65,13 @@ SDL_bool SDL_XINPUT_Enabled(void)
|
||||
|
||||
int SDL_XINPUT_JoystickInit(void)
|
||||
{
|
||||
s_bXInputEnabled = SDL_GetHintBoolean(SDL_HINT_XINPUT_ENABLED, SDL_TRUE);
|
||||
SDL_bool enabled = SDL_GetHintBoolean(SDL_HINT_XINPUT_ENABLED, SDL_TRUE);
|
||||
|
||||
if (s_bXInputEnabled && WIN_LoadXInputDLL() < 0) {
|
||||
s_bXInputEnabled = SDL_FALSE; /* oh well. */
|
||||
if (enabled && WIN_LoadXInputDLL() < 0) {
|
||||
enabled = SDL_FALSE; /* oh well. */
|
||||
}
|
||||
s_bXInputEnabled = enabled;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 2,30,6,0
|
||||
PRODUCTVERSION 2,30,6,0
|
||||
FILEVERSION 2,30,8,0
|
||||
PRODUCTVERSION 2,30,8,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
FILEFLAGS 0x0L
|
||||
FILEOS 0x40004L
|
||||
@@ -23,12 +23,12 @@ BEGIN
|
||||
BEGIN
|
||||
VALUE "CompanyName", "\0"
|
||||
VALUE "FileDescription", "SDL\0"
|
||||
VALUE "FileVersion", "2, 30, 6, 0\0"
|
||||
VALUE "FileVersion", "2, 30, 8, 0\0"
|
||||
VALUE "InternalName", "SDL\0"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2024 Sam Lantinga\0"
|
||||
VALUE "OriginalFilename", "SDL2.dll\0"
|
||||
VALUE "ProductName", "Simple DirectMedia Layer\0"
|
||||
VALUE "ProductVersion", "2, 30, 6, 0\0"
|
||||
VALUE "ProductVersion", "2, 30, 8, 0\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
||||
@@ -161,7 +161,7 @@ static void SDL_ANDROID_SensorUpdate(SDL_Sensor *sensor)
|
||||
ASensorEvent event;
|
||||
struct android_poll_source *source;
|
||||
|
||||
if (ALooper_pollAll(0, NULL, &events, (void **)&source) == LOOPER_ID_USER) {
|
||||
if (ALooper_pollOnce(0, NULL, &events, (void **)&source) == LOOPER_ID_USER) {
|
||||
SDL_zero(event);
|
||||
while (ASensorEventQueue_getEvents(sensor->hwdata->eventqueue, &event, 1) > 0) {
|
||||
SDL_PrivateSensorUpdate(sensor, 0, event.data, SDL_arraysize(event.data));
|
||||
|
||||
@@ -1529,7 +1529,7 @@ typedef enum
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SDL_bool left_justify; /* for now: ignored. */
|
||||
SDL_bool left_justify;
|
||||
SDL_bool force_sign;
|
||||
SDL_bool force_type; /* for now: used only by float printer, ignored otherwise. */
|
||||
SDL_bool pad_zeroes;
|
||||
@@ -1541,6 +1541,9 @@ typedef struct
|
||||
|
||||
static size_t SDL_PrintString(char *text, size_t maxlen, SDL_FormatInfo *info, const char *string)
|
||||
{
|
||||
const char fill = (info && info->pad_zeroes) ? '0' : ' ';
|
||||
size_t width = 0;
|
||||
size_t filllen = 0;
|
||||
size_t length = 0;
|
||||
size_t slen, sz;
|
||||
|
||||
@@ -1550,24 +1553,29 @@ static size_t SDL_PrintString(char *text, size_t maxlen, SDL_FormatInfo *info, c
|
||||
|
||||
sz = SDL_strlen(string);
|
||||
if (info && info->width > 0 && (size_t)info->width > sz) {
|
||||
const char fill = info->pad_zeroes ? '0' : ' ';
|
||||
size_t width = info->width - sz;
|
||||
size_t filllen;
|
||||
|
||||
width = info->width - sz;
|
||||
if (info->precision >= 0 && (size_t)info->precision < sz) {
|
||||
width += sz - (size_t)info->precision;
|
||||
}
|
||||
|
||||
filllen = SDL_min(width, maxlen);
|
||||
SDL_memset(text, fill, filllen);
|
||||
text += filllen;
|
||||
maxlen -= filllen;
|
||||
length += width;
|
||||
if (!info->left_justify) {
|
||||
SDL_memset(text, fill, filllen);
|
||||
text += filllen;
|
||||
maxlen -= filllen;
|
||||
length += width;
|
||||
filllen = 0;
|
||||
}
|
||||
}
|
||||
|
||||
SDL_strlcpy(text, string, maxlen);
|
||||
length += sz;
|
||||
|
||||
if (filllen > 0) {
|
||||
SDL_memset(text + sz, fill, filllen);
|
||||
length += width;
|
||||
}
|
||||
|
||||
if (info) {
|
||||
if (info->precision >= 0 && (size_t)info->precision < sz) {
|
||||
slen = (size_t)info->precision;
|
||||
|
||||
@@ -1222,10 +1222,9 @@ static void BlitARGBto565PixelAlpha(SDL_BlitInfo *info)
|
||||
DUFFS_LOOP4({
|
||||
Uint32 s = *srcp;
|
||||
unsigned alpha = s >> 27; /* downscale alpha to 5 bits */
|
||||
/* FIXME: Here we special-case opaque alpha since the
|
||||
/* Here we special-case opaque alpha since the
|
||||
compositioning used (>>8 instead of /255) doesn't handle
|
||||
it correctly. Also special-case alpha=0 for speed?
|
||||
Benchmark this! */
|
||||
it correctly. */
|
||||
if (alpha) {
|
||||
if (alpha == (SDL_ALPHA_OPAQUE >> 3)) {
|
||||
*dstp = (Uint16)((s >> 8 & 0xf800) + (s >> 5 & 0x7e0) + (s >> 3 & 0x1f));
|
||||
@@ -1235,8 +1234,7 @@ static void BlitARGBto565PixelAlpha(SDL_BlitInfo *info)
|
||||
* convert source and destination to G0RAB65565
|
||||
* and blend all components at the same time
|
||||
*/
|
||||
s = ((s & 0xfc00) << 11) + (s >> 8 & 0xf800)
|
||||
+ (s >> 3 & 0x1f);
|
||||
s = ((s & 0xfc00) << 11) + (s >> 8 & 0xf800) + (s >> 3 & 0x1f);
|
||||
d = (d | d << 16) & 0x07e0f81f;
|
||||
d += (s - d) * alpha >> 5;
|
||||
d &= 0x07e0f81f;
|
||||
@@ -1268,21 +1266,19 @@ static void BlitARGBto555PixelAlpha(SDL_BlitInfo *info)
|
||||
unsigned alpha;
|
||||
Uint32 s = *srcp;
|
||||
alpha = s >> 27; /* downscale alpha to 5 bits */
|
||||
/* FIXME: Here we special-case opaque alpha since the
|
||||
/* Here we special-case opaque alpha since the
|
||||
compositioning used (>>8 instead of /255) doesn't handle
|
||||
it correctly. Also special-case alpha=0 for speed?
|
||||
Benchmark this! */
|
||||
it correctly. */
|
||||
if (alpha) {
|
||||
if (alpha == (SDL_ALPHA_OPAQUE >> 3)) {
|
||||
*dstp = (Uint16)((s >> 9 & 0x7c00) + (s >> 6 & 0x3e0) + (s >> 3 & 0x1f));
|
||||
} else {
|
||||
Uint32 d = *dstp;
|
||||
/*
|
||||
* convert source and destination to G0RAB65565
|
||||
* convert source and destination to G0RAB55555
|
||||
* and blend all components at the same time
|
||||
*/
|
||||
s = ((s & 0xf800) << 10) + (s >> 9 & 0x7c00)
|
||||
+ (s >> 3 & 0x1f);
|
||||
s = ((s & 0xf800) << 10) + (s >> 9 & 0x7c00) + (s >> 3 & 0x1f);
|
||||
d = (d | d << 16) & 0x03e07c1f;
|
||||
d += (s - d) * alpha >> 5;
|
||||
d &= 0x03e07c1f;
|
||||
@@ -1452,7 +1448,7 @@ SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface)
|
||||
if (sf->BytesPerPixel == 4 && sf->Amask == 0xff000000 && sf->Gmask == 0xff00 && ((sf->Rmask == 0xff && df->Rmask == 0x1f) || (sf->Bmask == 0xff && df->Bmask == 0x1f))) {
|
||||
if (df->Gmask == 0x7e0) {
|
||||
return BlitARGBto565PixelAlpha;
|
||||
} else if (df->Gmask == 0x3e0) {
|
||||
} else if (df->Gmask == 0x3e0 && !df->Amask) {
|
||||
return BlitARGBto555PixelAlpha;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3303,6 +3303,9 @@ void SDL_DestroyWindow(SDL_Window *window)
|
||||
if (SDL_GetKeyboardFocus() == window) {
|
||||
SDL_SetKeyboardFocus(NULL);
|
||||
}
|
||||
if ((window->flags & SDL_WINDOW_MOUSE_CAPTURE)) {
|
||||
SDL_UpdateMouseCapture(SDL_TRUE);
|
||||
}
|
||||
if (SDL_GetMouseFocus() == window) {
|
||||
SDL_SetMouseFocus(NULL);
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ static kmsdrmdynlib kmsdrmlibs[] = {
|
||||
{ NULL, SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC }
|
||||
};
|
||||
|
||||
static void *KMSDRM_GetSym(const char *fnname, int *pHasModule)
|
||||
static void *KMSDRM_GetSym(const char *fnname, int *pHasModule, SDL_bool required)
|
||||
{
|
||||
int i;
|
||||
void *fn = NULL;
|
||||
@@ -67,7 +67,7 @@ static void *KMSDRM_GetSym(const char *fnname, int *pHasModule)
|
||||
SDL_Log("KMSDRM: Symbol '%s' NOT FOUND!\n", fnname);
|
||||
#endif
|
||||
|
||||
if (!fn) {
|
||||
if (!fn && required) {
|
||||
*pHasModule = 0; /* kill this module. */
|
||||
}
|
||||
|
||||
@@ -80,6 +80,7 @@ static void *KMSDRM_GetSym(const char *fnname, int *pHasModule)
|
||||
#define SDL_KMSDRM_MODULE(modname) int SDL_KMSDRM_HAVE_##modname = 0;
|
||||
#define SDL_KMSDRM_SYM(rc, fn, params) SDL_DYNKMSDRMFN_##fn KMSDRM_##fn = NULL;
|
||||
#define SDL_KMSDRM_SYM_CONST(type, name) SDL_DYNKMSDRMCONST_##name KMSDRM_##name = NULL;
|
||||
#define SDL_KMSDRM_SYM_OPT(rc, fn, params) SDL_DYNKMSDRMFN_##fn KMSDRM_##fn = NULL;
|
||||
#include "SDL_kmsdrmsym.h"
|
||||
|
||||
static int kmsdrm_load_refcount = 0;
|
||||
@@ -97,6 +98,7 @@ void SDL_KMSDRM_UnloadSymbols(void)
|
||||
#define SDL_KMSDRM_MODULE(modname) SDL_KMSDRM_HAVE_##modname = 0;
|
||||
#define SDL_KMSDRM_SYM(rc, fn, params) KMSDRM_##fn = NULL;
|
||||
#define SDL_KMSDRM_SYM_CONST(type, name) KMSDRM_##name = NULL;
|
||||
#define SDL_KMSDRM_SYM_OPT(rc, fn, params) KMSDRM_##fn = NULL;
|
||||
#include "SDL_kmsdrmsym.h"
|
||||
|
||||
#ifdef SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC
|
||||
@@ -130,9 +132,10 @@ int SDL_KMSDRM_LoadSymbols(void)
|
||||
#define SDL_KMSDRM_MODULE(modname) SDL_KMSDRM_HAVE_##modname = 1; /* default yes */
|
||||
#include "SDL_kmsdrmsym.h"
|
||||
|
||||
#define SDL_KMSDRM_MODULE(modname) thismod = &SDL_KMSDRM_HAVE_##modname;
|
||||
#define SDL_KMSDRM_SYM(rc, fn, params) KMSDRM_##fn = (SDL_DYNKMSDRMFN_##fn)KMSDRM_GetSym(#fn, thismod);
|
||||
#define SDL_KMSDRM_SYM_CONST(type, name) KMSDRM_##name = *(SDL_DYNKMSDRMCONST_##name *)KMSDRM_GetSym(#name, thismod);
|
||||
#define SDL_KMSDRM_MODULE(modname) thismod = &SDL_KMSDRM_HAVE_##modname;
|
||||
#define SDL_KMSDRM_SYM(rc, fn, params) KMSDRM_##fn = (SDL_DYNKMSDRMFN_##fn)KMSDRM_GetSym(#fn, thismod, SDL_TRUE);
|
||||
#define SDL_KMSDRM_SYM_CONST(type, name) KMSDRM_##name = *(SDL_DYNKMSDRMCONST_##name *)KMSDRM_GetSym(#name, thismod, SDL_TRUE);
|
||||
#define SDL_KMSDRM_SYM_OPT(rc, fn, params) KMSDRM_##fn = (SDL_DYNKMSDRMFN_##fn)KMSDRM_GetSym(#fn, thismod, SDL_FALSE);
|
||||
#include "SDL_kmsdrmsym.h"
|
||||
|
||||
if ((SDL_KMSDRM_HAVE_LIBDRM) && (SDL_KMSDRM_HAVE_GBM)) {
|
||||
@@ -149,6 +152,7 @@ int SDL_KMSDRM_LoadSymbols(void)
|
||||
#define SDL_KMSDRM_MODULE(modname) SDL_KMSDRM_HAVE_##modname = 1; /* default yes */
|
||||
#define SDL_KMSDRM_SYM(rc, fn, params) KMSDRM_##fn = fn;
|
||||
#define SDL_KMSDRM_SYM_CONST(type, name) KMSDRM_##name = name;
|
||||
#define SDL_KMSDRM_SYM_OPT(rc, fn, params) KMSDRM_##fn = fn;
|
||||
#include "SDL_kmsdrmsym.h"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -42,6 +42,9 @@ void SDL_KMSDRM_UnloadSymbols(void);
|
||||
#define SDL_KMSDRM_SYM_CONST(type, name) \
|
||||
typedef type SDL_DYNKMSDRMCONST_##name; \
|
||||
extern SDL_DYNKMSDRMCONST_##name KMSDRM_##name;
|
||||
#define SDL_KMSDRM_SYM_OPT(rc, fn, params) \
|
||||
typedef rc(*SDL_DYNKMSDRMFN_##fn) params; \
|
||||
extern SDL_DYNKMSDRMFN_##fn KMSDRM_##fn;
|
||||
#include "SDL_kmsdrmsym.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -194,7 +194,7 @@ int KMSDRM_GLES_SwapWindow(_THIS, SDL_Window *window)
|
||||
we have waited here, there won't be a pending pageflip so the
|
||||
WaitPageflip at the beginning of this function will be a no-op.
|
||||
Just leave it here and don't worry.
|
||||
Run your SDL2 program with "SDL_KMSDRM_DOUBLE_BUFFER=1 <program_name>"
|
||||
Run your SDL2 program with "SDL_VIDEO_DOUBLE_BUFFER=1 <program_name>"
|
||||
to enable this. */
|
||||
if (windata->double_buffer) {
|
||||
if (!KMSDRM_WaitPageflip(_this, windata)) {
|
||||
|
||||
@@ -33,6 +33,10 @@
|
||||
#define SDL_KMSDRM_SYM_CONST(type, name)
|
||||
#endif
|
||||
|
||||
#ifndef SDL_KMSDRM_SYM_OPT
|
||||
#define SDL_KMSDRM_SYM_OPT(rc,fn,params)
|
||||
#endif
|
||||
|
||||
|
||||
SDL_KMSDRM_MODULE(LIBDRM)
|
||||
SDL_KMSDRM_SYM(void,drmModeFreeResources,(drmModeResPtr ptr))
|
||||
@@ -49,12 +53,12 @@ SDL_KMSDRM_SYM(int,drmModeAddFB,(int fd, uint32_t width, uint32_t height, uint8_
|
||||
uint8_t bpp, uint32_t pitch, uint32_t bo_handle,
|
||||
uint32_t *buf_id))
|
||||
|
||||
SDL_KMSDRM_SYM(int,drmModeAddFB2,(int fd, uint32_t width, uint32_t height,
|
||||
SDL_KMSDRM_SYM_OPT(int,drmModeAddFB2,(int fd, uint32_t width, uint32_t height,
|
||||
uint32_t pixel_format, const uint32_t bo_handles[4],
|
||||
const uint32_t pitches[4], const uint32_t offsets[4],
|
||||
uint32_t *buf_id, uint32_t flags))
|
||||
|
||||
SDL_KMSDRM_SYM(int,drmModeAddFB2WithModifiers,(int fd, uint32_t width,
|
||||
SDL_KMSDRM_SYM_OPT(int,drmModeAddFB2WithModifiers,(int fd, uint32_t width,
|
||||
uint32_t height, uint32_t pixel_format, const uint32_t bo_handles[4],
|
||||
const uint32_t pitches[4], const uint32_t offsets[4],
|
||||
const uint64_t modifier[4], uint32_t *buf_id, uint32_t flags))
|
||||
@@ -129,15 +133,16 @@ SDL_KMSDRM_SYM(void,gbm_surface_destroy,(struct gbm_surface *surf))
|
||||
SDL_KMSDRM_SYM(struct gbm_bo *,gbm_surface_lock_front_buffer,(struct gbm_surface *surf))
|
||||
SDL_KMSDRM_SYM(void,gbm_surface_release_buffer,(struct gbm_surface *surf, struct gbm_bo *bo))
|
||||
|
||||
SDL_KMSDRM_SYM(uint64_t,gbm_bo_get_modifier,(struct gbm_bo *bo))
|
||||
SDL_KMSDRM_SYM(int,gbm_bo_get_plane_count,(struct gbm_bo *bo))
|
||||
SDL_KMSDRM_SYM(uint32_t,gbm_bo_get_offset,(struct gbm_bo *bo, int plane))
|
||||
SDL_KMSDRM_SYM(uint32_t,gbm_bo_get_stride_for_plane,(struct gbm_bo *bo, int plane))
|
||||
SDL_KMSDRM_SYM(union gbm_bo_handle,gbm_bo_get_handle_for_plane,(struct gbm_bo *bo, int plane);)
|
||||
SDL_KMSDRM_SYM_OPT(uint64_t,gbm_bo_get_modifier,(struct gbm_bo *bo))
|
||||
SDL_KMSDRM_SYM_OPT(int,gbm_bo_get_plane_count,(struct gbm_bo *bo))
|
||||
SDL_KMSDRM_SYM_OPT(uint32_t,gbm_bo_get_offset,(struct gbm_bo *bo, int plane))
|
||||
SDL_KMSDRM_SYM_OPT(uint32_t,gbm_bo_get_stride_for_plane,(struct gbm_bo *bo, int plane))
|
||||
SDL_KMSDRM_SYM_OPT(union gbm_bo_handle,gbm_bo_get_handle_for_plane,(struct gbm_bo *bo, int plane))
|
||||
|
||||
#undef SDL_KMSDRM_MODULE
|
||||
#undef SDL_KMSDRM_SYM
|
||||
#undef SDL_KMSDRM_SYM_CONST
|
||||
#undef SDL_KMSDRM_SYM_OPT
|
||||
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ static int get_driindex(void)
|
||||
|
||||
SDL_strlcpy(device + kmsdrm_dri_pathsize, kmsdrm_dri_devname,
|
||||
sizeof(device) - kmsdrm_dri_devnamesize);
|
||||
while((res = readdir(folder)) != NULL) {
|
||||
while((res = readdir(folder)) != NULL && available < 0) {
|
||||
if (SDL_memcmp(res->d_name, kmsdrm_dri_devname,
|
||||
kmsdrm_dri_devnamesize) == 0) {
|
||||
SDL_strlcpy(device + kmsdrm_dri_pathsize + kmsdrm_dri_devnamesize,
|
||||
@@ -123,7 +123,7 @@ static int get_driindex(void)
|
||||
resources->count_encoders > 0 &&
|
||||
resources->count_crtcs > 0) {
|
||||
available = -ENOENT;
|
||||
for (i = 0; i < resources->count_connectors; i++) {
|
||||
for (i = 0; i < resources->count_connectors && available < 0; i++) {
|
||||
drmModeConnector *conn =
|
||||
KMSDRM_drmModeGetConnector(
|
||||
drm_fd, resources->connectors[i]);
|
||||
@@ -134,20 +134,21 @@ static int get_driindex(void)
|
||||
|
||||
if (conn->connection == DRM_MODE_CONNECTED &&
|
||||
conn->count_modes) {
|
||||
SDL_bool access_denied = SDL_FALSE;
|
||||
if (SDL_GetHintBoolean(
|
||||
SDL_HINT_KMSDRM_REQUIRE_DRM_MASTER,
|
||||
SDL_TRUE)) {
|
||||
/* Skip this device if we can't obtain
|
||||
* DRM master */
|
||||
KMSDRM_drmSetMaster(drm_fd);
|
||||
if (KMSDRM_drmAuthMagic(drm_fd, 0) ==
|
||||
-EACCES) {
|
||||
continue;
|
||||
if (KMSDRM_drmAuthMagic(drm_fd, 0) == -EACCES) {
|
||||
access_denied = SDL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
available = devindex;
|
||||
break;
|
||||
if (!access_denied) {
|
||||
available = devindex;
|
||||
}
|
||||
}
|
||||
|
||||
KMSDRM_drmModeFreeConnector(conn);
|
||||
@@ -158,11 +159,10 @@ static int get_driindex(void)
|
||||
SDL_KMSDRM_UnloadSymbols();
|
||||
}
|
||||
close(drm_fd);
|
||||
} else {
|
||||
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO,
|
||||
"Failed to open KMSDRM device %s, errno: %d\n", device, errno);
|
||||
}
|
||||
|
||||
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO,
|
||||
"Failed to open KMSDRM device %s, errno: %d\n", device,
|
||||
errno);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -336,8 +336,9 @@ KMSDRM_FBInfo *KMSDRM_FBFromBO(_THIS, struct gbm_bo *bo)
|
||||
{
|
||||
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
|
||||
unsigned w, h;
|
||||
int ret, num_planes = 0;
|
||||
Uint32 format, strides[4] = { 0 }, handles[4] = { 0 }, offsets[4] = { 0 }, flags = 0;
|
||||
int rc = -1;
|
||||
int num_planes = 0;
|
||||
uint32_t format, strides[4] = { 0 }, handles[4] = { 0 }, offsets[4] = { 0 }, flags = 0;
|
||||
uint64_t modifiers[4] = { 0 };
|
||||
|
||||
/* Check for an existing framebuffer */
|
||||
@@ -364,34 +365,36 @@ KMSDRM_FBInfo *KMSDRM_FBFromBO(_THIS, struct gbm_bo *bo)
|
||||
h = KMSDRM_gbm_bo_get_height(bo);
|
||||
format = KMSDRM_gbm_bo_get_format(bo);
|
||||
|
||||
modifiers[0] = KMSDRM_gbm_bo_get_modifier(bo);
|
||||
num_planes = KMSDRM_gbm_bo_get_plane_count(bo);
|
||||
for (int i = 0; i < num_planes; i++) {
|
||||
strides[i] = KMSDRM_gbm_bo_get_stride_for_plane(bo, i);
|
||||
handles[i] = KMSDRM_gbm_bo_get_handle_for_plane(bo, i).u32;
|
||||
offsets[i] = KMSDRM_gbm_bo_get_offset(bo, i);
|
||||
modifiers[i] = modifiers[0];
|
||||
}
|
||||
if (KMSDRM_drmModeAddFB2WithModifiers &&
|
||||
KMSDRM_gbm_bo_get_modifier &&
|
||||
KMSDRM_gbm_bo_get_plane_count &&
|
||||
KMSDRM_gbm_bo_get_offset &&
|
||||
KMSDRM_gbm_bo_get_stride_for_plane &&
|
||||
KMSDRM_gbm_bo_get_handle_for_plane) {
|
||||
|
||||
if (modifiers[0] && modifiers[0] != DRM_FORMAT_MOD_INVALID) {
|
||||
flags = DRM_MODE_FB_MODIFIERS;
|
||||
}
|
||||
|
||||
ret = KMSDRM_drmModeAddFB2WithModifiers(viddata->drm_fd, w, h, format, handles, strides, offsets, modifiers, &fb_info->fb_id, flags);
|
||||
|
||||
if (ret) {
|
||||
handles[0] = KMSDRM_gbm_bo_get_handle(bo).u32;
|
||||
strides[0] = KMSDRM_gbm_bo_get_stride(bo);
|
||||
offsets[0] = 0;
|
||||
for (int i = 1; i<4; i++) {
|
||||
handles[i] = 0;
|
||||
strides[i] = 0;
|
||||
offsets[i] = 0;
|
||||
modifiers[0] = KMSDRM_gbm_bo_get_modifier(bo);
|
||||
num_planes = KMSDRM_gbm_bo_get_plane_count(bo);
|
||||
for (int i = 0; i < num_planes; i++) {
|
||||
strides[i] = KMSDRM_gbm_bo_get_stride_for_plane(bo, i);
|
||||
handles[i] = KMSDRM_gbm_bo_get_handle_for_plane(bo, i).u32;
|
||||
offsets[i] = KMSDRM_gbm_bo_get_offset(bo, i);
|
||||
modifiers[i] = modifiers[0];
|
||||
}
|
||||
ret = KMSDRM_drmModeAddFB2(viddata->drm_fd, w, h, format, handles, strides, offsets, &fb_info->fb_id, 0);
|
||||
|
||||
if (modifiers[0] && modifiers[0] != DRM_FORMAT_MOD_INVALID) {
|
||||
flags = DRM_MODE_FB_MODIFIERS;
|
||||
}
|
||||
|
||||
rc = KMSDRM_drmModeAddFB2WithModifiers(viddata->drm_fd, w, h, format, handles, strides, offsets, modifiers, &fb_info->fb_id, flags);
|
||||
}
|
||||
|
||||
if (ret) {
|
||||
if (rc < 0) {
|
||||
strides[0] = KMSDRM_gbm_bo_get_stride(bo);
|
||||
handles[0] = KMSDRM_gbm_bo_get_handle(bo).u32;
|
||||
rc = KMSDRM_drmModeAddFB(viddata->drm_fd, w, h, 24, 32, strides[0], handles[0], &fb_info->fb_id);
|
||||
}
|
||||
|
||||
if (rc < 0) {
|
||||
SDL_free(fb_info);
|
||||
return NULL;
|
||||
}
|
||||
@@ -527,10 +530,23 @@ static drmModeModeInfo *KMSDRM_GetClosestDisplayMode(SDL_VideoDisplay *display,
|
||||
/* _this is a SDL_VideoDevice * */
|
||||
/*****************************************************************************/
|
||||
|
||||
static SDL_bool KMSDRM_DropMaster(_THIS)
|
||||
{
|
||||
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
|
||||
|
||||
/* Check if we have DRM master to begin with */
|
||||
if (KMSDRM_drmAuthMagic(viddata->drm_fd, 0) == -EACCES) {
|
||||
/* Nope, nothing to do then */
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
return KMSDRM_drmDropMaster(viddata->drm_fd) < 0 ? SDL_FALSE : SDL_TRUE;
|
||||
}
|
||||
|
||||
/* Deinitializes the driverdata of the SDL Displays in the SDL display list. */
|
||||
static void KMSDRM_DeinitDisplays(_THIS)
|
||||
{
|
||||
|
||||
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
|
||||
SDL_DisplayData *dispdata;
|
||||
int num_displays, i;
|
||||
|
||||
@@ -554,6 +570,11 @@ static void KMSDRM_DeinitDisplays(_THIS)
|
||||
dispdata->crtc = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (viddata->drm_fd >= 0) {
|
||||
close(viddata->drm_fd);
|
||||
viddata->drm_fd = -1;
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t KMSDRM_CrtcGetPropId(uint32_t drm_fd,
|
||||
@@ -909,8 +930,6 @@ cleanup:
|
||||
|
||||
/* Initializes the list of SDL displays: we build a new display for each
|
||||
connecter connector we find.
|
||||
Inoffeensive for VK compatibility, except we must leave the drm_fd
|
||||
closed when we get to the end of this function.
|
||||
This is to be called early, in VideoInit(), because it gets us
|
||||
the videomode information, which SDL needs immediately after VideoInit(). */
|
||||
static int KMSDRM_InitDisplays(_THIS)
|
||||
@@ -983,10 +1002,13 @@ static int KMSDRM_InitDisplays(_THIS)
|
||||
/* Block for Vulkan compatibility. */
|
||||
/***********************************/
|
||||
|
||||
/* THIS IS FOR VULKAN! Leave the FD closed, so VK can work.
|
||||
Will reopen this in CreateWindow, but only if requested a non-VK window. */
|
||||
close(viddata->drm_fd);
|
||||
viddata->drm_fd = -1;
|
||||
/* Vulkan requires DRM master on its own FD to work, so try to drop master
|
||||
on our FD. This will only work without root on kernels v5.8 and later.
|
||||
If it doesn't work, just close the FD and we'll reopen it later. */
|
||||
if (!KMSDRM_DropMaster(_this)) {
|
||||
close(viddata->drm_fd);
|
||||
viddata->drm_fd = -1;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
if (resources) {
|
||||
@@ -1014,10 +1036,15 @@ static int KMSDRM_GBMInit(_THIS, SDL_DisplayData *dispdata)
|
||||
SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata;
|
||||
int ret = 0;
|
||||
|
||||
/* Reopen the FD! */
|
||||
viddata->drm_fd = open(viddata->devpath, O_RDWR | O_CLOEXEC);
|
||||
/* Reopen the FD if we weren't able to drop master on the original one */
|
||||
if (viddata->drm_fd < 0) {
|
||||
viddata->drm_fd = open(viddata->devpath, O_RDWR | O_CLOEXEC);
|
||||
if (viddata->drm_fd < 0) {
|
||||
return SDL_SetError("Could not reopen %s", viddata->devpath);
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the FD we just opened as current DRM master. */
|
||||
/* Set the FD as current DRM master. */
|
||||
KMSDRM_drmSetMaster(viddata->drm_fd);
|
||||
|
||||
/* Create the GBM device. */
|
||||
@@ -1043,8 +1070,9 @@ static void KMSDRM_GBMDeinit(_THIS, SDL_DisplayData *dispdata)
|
||||
viddata->gbm_dev = NULL;
|
||||
}
|
||||
|
||||
/* Finally close DRM FD. May be reopen on next non-vulkan window creation. */
|
||||
if (viddata->drm_fd >= 0) {
|
||||
/* Finally drop DRM master if possible, otherwise close DRM FD.
|
||||
May be reopened on next non-vulkan window creation. */
|
||||
if (viddata->drm_fd >= 0 && !KMSDRM_DropMaster(_this)) {
|
||||
close(viddata->drm_fd);
|
||||
viddata->drm_fd = -1;
|
||||
}
|
||||
@@ -1478,6 +1506,12 @@ int KMSDRM_CreateWindow(_THIS, SDL_Window *window)
|
||||
windata->viddata = viddata;
|
||||
window->driverdata = windata;
|
||||
|
||||
/* Do we want a double buffering scheme to get low video lag? */
|
||||
windata->double_buffer = SDL_FALSE;
|
||||
if (SDL_GetHintBoolean(SDL_HINT_VIDEO_DOUBLE_BUFFER, SDL_FALSE)) {
|
||||
windata->double_buffer = SDL_TRUE;
|
||||
}
|
||||
|
||||
if (!is_vulkan && !vulkan_mode) { /* NON-Vulkan block. */
|
||||
|
||||
/* Maybe you didn't ask for an OPENGL window, but that's what you will get.
|
||||
@@ -1583,7 +1617,12 @@ int KMSDRM_CreateWindow(_THIS, SDL_Window *window)
|
||||
SDL_SetKeyboardFocus(window);
|
||||
|
||||
/* Tell the app that the window has moved to top-left. */
|
||||
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MOVED, 0, 0);
|
||||
{
|
||||
SDL_Rect display_bounds;
|
||||
SDL_zero(display_bounds);
|
||||
SDL_GetDisplayBounds(SDL_GetWindowDisplayIndex(window), &display_bounds);
|
||||
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MOVED, display_bounds.x, display_bounds.y);
|
||||
}
|
||||
|
||||
/* Allocated windata will be freed in KMSDRM_DestroyWindow,
|
||||
and KMSDRM_DestroyWindow() will be called by SDL_CreateWindow()
|
||||
|
||||
@@ -70,8 +70,8 @@ void VITA_InitTouch(void)
|
||||
}
|
||||
|
||||
// Support passing both front and back touch devices in events
|
||||
SDL_AddTouch((SDL_TouchID)0, SDL_TOUCH_DEVICE_DIRECT, "Front");
|
||||
SDL_AddTouch((SDL_TouchID)1, SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE, "Back");
|
||||
SDL_AddTouch((SDL_TouchID)1, SDL_TOUCH_DEVICE_DIRECT, "Front");
|
||||
SDL_AddTouch((SDL_TouchID)2, SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE, "Back");
|
||||
}
|
||||
|
||||
void VITA_QuitTouch(void)
|
||||
|
||||
@@ -248,12 +248,25 @@ static SDL_bool keyboard_repeat_key_is_set(SDL_WaylandKeyboardRepeat *repeat_inf
|
||||
return repeat_info->is_initialized && repeat_info->is_key_down && key == repeat_info->key;
|
||||
}
|
||||
|
||||
static void sync_done_handler(void *data, struct wl_callback *callback, uint32_t callback_data)
|
||||
{
|
||||
/* Nothing to do, just destroy the callback */
|
||||
wl_callback_destroy(callback);
|
||||
}
|
||||
|
||||
static struct wl_callback_listener sync_listener = {
|
||||
sync_done_handler
|
||||
};
|
||||
|
||||
void Wayland_SendWakeupEvent(_THIS, SDL_Window *window)
|
||||
{
|
||||
SDL_VideoData *d = _this->driverdata;
|
||||
|
||||
/* TODO: Maybe use a pipe to avoid the compositor roundtrip? */
|
||||
wl_display_sync(d->display);
|
||||
/* Queue a sync event to unblock the event queue fd if it's empty and being waited on.
|
||||
* TODO: Maybe use a pipe to avoid the compositor roundtrip?
|
||||
*/
|
||||
struct wl_callback *cb = wl_display_sync(d->display);
|
||||
wl_callback_add_listener(cb, &sync_listener, NULL);
|
||||
WAYLAND_wl_display_flush(d->display);
|
||||
}
|
||||
|
||||
@@ -2522,6 +2535,9 @@ void Wayland_display_destroy_input(SDL_VideoData *d)
|
||||
if (input->primary_selection_device->selection_offer) {
|
||||
Wayland_primary_selection_offer_destroy(input->primary_selection_device->selection_offer);
|
||||
}
|
||||
if (input->primary_selection_device->primary_selection_device) {
|
||||
zwp_primary_selection_device_v1_destroy(input->primary_selection_device->primary_selection_device);
|
||||
}
|
||||
SDL_free(input->primary_selection_device);
|
||||
}
|
||||
|
||||
|
||||
@@ -595,6 +595,7 @@ static void Wayland_WarpMouse(SDL_Window *window, int x, int y)
|
||||
Wayland_input_lock_pointer(input);
|
||||
input->relative_mode_override = SDL_TRUE;
|
||||
}
|
||||
SDL_SendMouseMotion(window, 0, 0, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -120,6 +120,20 @@ int Wayland_GLES_SwapWindow(_THIS, SDL_Window *window)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* By default, we wait for Wayland frame callback and then issue pageflip (eglSwapBuffers),
|
||||
* but if we want low latency (double buffer scheme), we issue the pageflip
|
||||
* and then wait immediately for Wayland frame callback.
|
||||
*/
|
||||
|
||||
if (data->double_buffer) {
|
||||
/* Feed the frame to Wayland. This will set it so the wl_surface_frame callback can fire again. */
|
||||
if (!_this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, data->egl_surface)) {
|
||||
return SDL_EGL_SetError("unable to show color buffer in an OS-native window", "eglSwapBuffers");
|
||||
}
|
||||
|
||||
WAYLAND_wl_display_flush(data->waylandData->display);
|
||||
}
|
||||
|
||||
/* Control swap interval ourselves. See comments on Wayland_GLES_SetSwapInterval */
|
||||
if (swap_interval != 0) {
|
||||
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
|
||||
@@ -162,12 +176,14 @@ int Wayland_GLES_SwapWindow(_THIS, SDL_Window *window)
|
||||
SDL_AtomicSet(&data->swap_interval_ready, 0);
|
||||
}
|
||||
|
||||
/* Feed the frame to Wayland. This will set it so the wl_surface_frame callback can fire again. */
|
||||
if (!_this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, data->egl_surface)) {
|
||||
return SDL_EGL_SetError("unable to show color buffer in an OS-native window", "eglSwapBuffers");
|
||||
}
|
||||
if (!data->double_buffer) {
|
||||
/* Feed the frame to Wayland. This will set it so the wl_surface_frame callback can fire again. */
|
||||
if (!_this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, data->egl_surface)) {
|
||||
return SDL_EGL_SetError("unable to show color buffer in an OS-native window", "eglSwapBuffers");
|
||||
}
|
||||
|
||||
WAYLAND_wl_display_flush(data->waylandData->display);
|
||||
WAYLAND_wl_display_flush(data->waylandData->display);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1481,6 +1481,9 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window)
|
||||
* HideWindow was called immediately before ShowWindow.
|
||||
*/
|
||||
WAYLAND_wl_display_roundtrip(c->display);
|
||||
|
||||
/* Send an exposure event to signal that the client should draw. */
|
||||
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_EXPOSED, 0, 0);
|
||||
}
|
||||
|
||||
static void Wayland_ReleasePopup(_THIS, SDL_Window *popup)
|
||||
@@ -2023,6 +2026,11 @@ int Wayland_CreateWindow(_THIS, SDL_Window *window)
|
||||
}
|
||||
}
|
||||
|
||||
data->double_buffer = SDL_FALSE;
|
||||
if (SDL_GetHintBoolean(SDL_HINT_VIDEO_DOUBLE_BUFFER, SDL_FALSE)) {
|
||||
data->double_buffer = SDL_TRUE;
|
||||
}
|
||||
|
||||
data->outputs = NULL;
|
||||
data->num_outputs = 0;
|
||||
|
||||
@@ -2142,6 +2150,7 @@ static void Wayland_HandleResize(SDL_Window *window, int width, int height, floa
|
||||
window->w = 0;
|
||||
window->h = 0;
|
||||
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, width, height);
|
||||
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_EXPOSED, 0, 0);
|
||||
window->w = width;
|
||||
window->h = height;
|
||||
data->needs_resize_event = SDL_FALSE;
|
||||
|
||||
@@ -116,6 +116,7 @@ typedef struct
|
||||
SDL_bool is_fullscreen;
|
||||
SDL_bool in_fullscreen_transition;
|
||||
Uint32 fullscreen_flags;
|
||||
SDL_bool double_buffer;
|
||||
} SDL_WindowData;
|
||||
|
||||
extern void Wayland_ShowWindow(_THIS, SDL_Window *window);
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
|
||||
/* FIXME: Find a better place to put this... */
|
||||
static Cursor x11_empty_cursor = None;
|
||||
static SDL_bool x11_cursor_visible = SDL_TRUE;
|
||||
|
||||
static Display *GetDisplay(void)
|
||||
{
|
||||
@@ -298,6 +299,8 @@ static int X11_ShowCursor(SDL_Cursor *cursor)
|
||||
Display *display = GetDisplay();
|
||||
SDL_Window *window;
|
||||
|
||||
x11_cursor_visible = !!cursor;
|
||||
|
||||
for (window = video->windows; window; window = window->next) {
|
||||
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
|
||||
if (data) {
|
||||
@@ -317,12 +320,13 @@ static void WarpMouseInternal(Window xwindow, const int x, const int y)
|
||||
{
|
||||
SDL_VideoData *videodata = (SDL_VideoData *)SDL_GetVideoDevice()->driverdata;
|
||||
Display *display = videodata->display;
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2
|
||||
int deviceid = 0;
|
||||
#endif
|
||||
SDL_bool warp_hack = SDL_FALSE;
|
||||
|
||||
/* XWayland will only warp the cursor if it is hidden, so this workaround is required. */
|
||||
if (videodata->is_xwayland && mouse && mouse->cursor_shown) {
|
||||
if (videodata->is_xwayland && x11_cursor_visible) {
|
||||
warp_hack = SDL_TRUE;
|
||||
}
|
||||
|
||||
@@ -490,5 +494,3 @@ void X11_QuitMouse(_THIS)
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_X11 */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
@@ -32,8 +32,10 @@
|
||||
|
||||
#if defined(__OpenBSD__)
|
||||
#define DEFAULT_VULKAN "libvulkan.so"
|
||||
#define DEFAULT_X11_XCB "libX11-xcb.so"
|
||||
#else
|
||||
#define DEFAULT_VULKAN "libvulkan.so.1"
|
||||
#define DEFAULT_X11_XCB "libX11-xcb.so.1"
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -108,7 +110,7 @@ int X11_Vulkan_LoadLibrary(_THIS, const char *path)
|
||||
} else {
|
||||
const char *libX11XCBLibraryName = SDL_getenv("SDL_X11_XCB_LIBRARY");
|
||||
if (!libX11XCBLibraryName) {
|
||||
libX11XCBLibraryName = "libX11-xcb.so";
|
||||
libX11XCBLibraryName = DEFAULT_X11_XCB;
|
||||
}
|
||||
videoData->vulkan_xlib_xcb_library = SDL_LoadObject(libX11XCBLibraryName);
|
||||
if (!videoData->vulkan_xlib_xcb_library) {
|
||||
|
||||
@@ -62,6 +62,18 @@ int stdlib_snprintf(void *arg)
|
||||
SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: %s, got: %s", expected, text);
|
||||
SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", (int)SDL_strlen(text), result);
|
||||
|
||||
result = SDL_snprintf(text, sizeof(text), "%10sA", "foo");
|
||||
expected = " fooA";
|
||||
SDLTest_AssertPass("Call to SDL_snprintf(\"%%10sA\", \"foo\")");
|
||||
SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: %s, got: %s", expected, text);
|
||||
SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", (int)SDL_strlen(text), result);
|
||||
|
||||
result = SDL_snprintf(text, sizeof(text), "%-10sA", "foo");
|
||||
expected = "foo A";
|
||||
SDLTest_AssertPass("Call to SDL_snprintf(\"%%-10sA\", \"foo\")");
|
||||
SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: %s, got: %s", expected, text);
|
||||
SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", (int)SDL_strlen(text), result);
|
||||
|
||||
result = SDL_snprintf(text, sizeof(text), "%S", L"foo");
|
||||
expected = "foo";
|
||||
SDLTest_AssertPass("Call to SDL_snprintf(\"%%S\", \"foo\")");
|
||||
|
||||
@@ -19,7 +19,8 @@
|
||||
#include "SDL.h"
|
||||
|
||||
static SDL_TLSID tls;
|
||||
static int alive = 0;
|
||||
static SDL_Thread *thread = NULL;
|
||||
static SDL_atomic_t alive;
|
||||
static int testprio = 0;
|
||||
|
||||
/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
|
||||
@@ -55,7 +56,7 @@ ThreadFunc(void *data)
|
||||
SDL_TLSSet(tls, "baby thread", NULL);
|
||||
SDL_Log("Started thread %s: My thread id is %lu, thread data = %s\n",
|
||||
(char *)data, SDL_ThreadID(), (const char *)SDL_TLSGet(tls));
|
||||
while (alive) {
|
||||
while (SDL_AtomicGet(&alive)) {
|
||||
SDL_Log("Thread '%s' is alive!\n", (char *)data);
|
||||
|
||||
if (testprio) {
|
||||
@@ -76,14 +77,14 @@ killed(int sig)
|
||||
{
|
||||
SDL_Log("Killed with SIGTERM, waiting 5 seconds to exit\n");
|
||||
SDL_Delay(5 * 1000);
|
||||
alive = 0;
|
||||
SDL_AtomicSet(&alive, 0);
|
||||
SDL_WaitThread(thread, NULL);
|
||||
quit(0);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int arg = 1;
|
||||
SDL_Thread *thread;
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
@@ -112,7 +113,7 @@ int main(int argc, char *argv[])
|
||||
SDL_TLSSet(tls, "main thread", NULL);
|
||||
SDL_Log("Main thread data initially: %s\n", (const char *)SDL_TLSGet(tls));
|
||||
|
||||
alive = 1;
|
||||
SDL_AtomicSet(&alive, 1);
|
||||
thread = SDL_CreateThread(ThreadFunc, "One", "#1");
|
||||
if (!thread) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError());
|
||||
@@ -120,12 +121,12 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
SDL_Delay(5 * 1000);
|
||||
SDL_Log("Waiting for thread #1\n");
|
||||
alive = 0;
|
||||
SDL_AtomicSet(&alive, 0);
|
||||
SDL_WaitThread(thread, NULL);
|
||||
|
||||
SDL_Log("Main thread data finally: %s\n", (const char *)SDL_TLSGet(tls));
|
||||
|
||||
alive = 1;
|
||||
SDL_AtomicSet(&alive, 1);
|
||||
(void)signal(SIGTERM, killed);
|
||||
thread = SDL_CreateThread(ThreadFunc, "Two", "#2");
|
||||
if (!thread) {
|
||||
|
||||
@@ -34,8 +34,9 @@ quit(int rc)
|
||||
int SDLCALL
|
||||
SubThreadFunc(void *data)
|
||||
{
|
||||
while (!*(int volatile *)data) {
|
||||
; /* SDL_Delay(10); */ /* do nothing */
|
||||
SDL_atomic_t *flag = (SDL_atomic_t *)data;
|
||||
while (!SDL_AtomicGet(flag)) {
|
||||
SDL_Delay(10);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -44,7 +45,7 @@ int SDLCALL
|
||||
ThreadFunc(void *data)
|
||||
{
|
||||
SDL_Thread *sub_threads[NUMTHREADS];
|
||||
int flags[NUMTHREADS];
|
||||
SDL_atomic_t flags[NUMTHREADS];
|
||||
int i;
|
||||
int tid = (int)(uintptr_t)data;
|
||||
|
||||
@@ -53,7 +54,7 @@ ThreadFunc(void *data)
|
||||
for (i = 0; i < NUMTHREADS; i++) {
|
||||
char name[64];
|
||||
(void)SDL_snprintf(name, sizeof(name), "Child%d_%d", tid, i);
|
||||
flags[i] = 0;
|
||||
SDL_AtomicSet(&flags[i], 0);
|
||||
sub_threads[i] = SDL_CreateThread(SubThreadFunc, name, &flags[i]);
|
||||
}
|
||||
|
||||
@@ -64,7 +65,7 @@ ThreadFunc(void *data)
|
||||
|
||||
SDL_Log("Thread '%d' sending signals to subthreads\n", tid);
|
||||
for (i = 0; i < NUMTHREADS; i++) {
|
||||
flags[i] = 1;
|
||||
SDL_AtomicSet(&flags[i], 1);
|
||||
SDL_WaitThread(sub_threads[i], NULL);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user