├── .github ├── actions │ └── setup-ninja │ │ └── action.yml └── workflows │ ├── main.yml │ └── release.yml ├── .gitignore ├── .wikiheaders-options ├── CMakeLists.txt ├── LICENSE.txt ├── README.md ├── VisualC ├── SDL_net.sln ├── SDL_net.vcxproj ├── SDL_net.vcxproj.filters ├── clean.sh └── examples │ ├── get-local-addrs.vcxproj │ ├── resolve-hostnames.vcxproj │ ├── simple-http-get.vcxproj │ └── voipchat.vcxproj ├── build-scripts ├── build-release.py ├── cmake-toolchain-mingw64-i686.cmake ├── cmake-toolchain-mingw64-x86_64.cmake ├── create-release.py ├── pkg-support │ ├── android │ │ ├── README.md.in │ │ └── aar │ │ │ ├── __main__.py.in │ │ │ ├── cmake │ │ │ ├── SDL3_netConfig.cmake │ │ │ └── SDL3_netConfigVersion.cmake.in │ │ │ └── description.json.in │ ├── mingw │ │ ├── Makefile │ │ └── cmake │ │ │ ├── SDL3_netConfig.cmake │ │ │ └── SDL3_netConfigVersion.cmake │ └── msvc │ │ └── cmake │ │ ├── SDL3_netConfig.cmake.in │ │ └── SDL3_netConfigVersion.cmake.in ├── release-info.json ├── test-versioning.sh └── wikiheaders.pl ├── cmake ├── GetGitRevisionDescription.cmake ├── GetGitRevisionDescription.cmake.in ├── PrivateSdlFunctions.cmake ├── SDL3_netConfig.cmake.in ├── sdl3-net.pc.in ├── sdlcpu.cmake ├── sdlmanpages.cmake └── test │ ├── CMakeLists.txt │ └── main.c ├── examples ├── get-local-addrs.c ├── resolve-hostnames.c ├── simple-http-get.c └── voipchat.c ├── include └── SDL3_net │ └── SDL_net.h └── src ├── SDL_net.c ├── SDL_net.sym └── version.rc /.github/actions/setup-ninja/action.yml: -------------------------------------------------------------------------------- 1 | name: 'Setup ninja' 2 | description: 'Download ninja and add it to the PATH environment variable' 3 | inputs: 4 | version: 5 | description: 'Ninja version' 6 | default: '1.12.1' 7 | runs: 8 | using: 'composite' 9 | steps: 10 | - name: 'Calculate variables' 11 | id: calc 12 | shell: sh 13 | run: | 14 | case "${{ runner.os }}-${{ runner.arch }}" in 15 | "Linux-X86" | "Linux-X64") 16 | archive="ninja-linux.zip" 17 | ;; 18 | "Linux-ARM64") 19 | archive="ninja-linux-aarch64.zip" 20 | ;; 21 | "macOS-X86" | "macOS-X64" | "macOS-ARM64") 22 | archive="ninja-mac.zip" 23 | ;; 24 | "Windows-X86" | "Windows-X64") 25 | archive="ninja-win.zip" 26 | ;; 27 | "Windows-ARM64") 28 | archive="ninja-winarm64.zip" 29 | ;; 30 | *) 31 | echo "Unsupported ${{ runner.os }}-${{ runner.arch }}" 32 | exit 1; 33 | ;; 34 | esac 35 | echo "archive=${archive}" >> ${GITHUB_OUTPUT} 36 | echo "cache-key=${archive}-${{ inputs.version }}-${{ runner.os }}-${{ runner.arch }}" >> ${GITHUB_OUTPUT} 37 | - name: 'Restore cached ${{ steps.calc.outputs.archive }}' 38 | id: cache-restore 39 | uses: actions/cache/restore@v4 40 | with: 41 | path: '${{ runner.temp }}/${{ steps.calc.outputs.archive }}' 42 | key: ${{ steps.calc.outputs.cache-key }} 43 | - name: 'Download ninja ${{ inputs.version }} for ${{ runner.os }} (${{ runner.arch }})' 44 | if: ${{ !steps.cache-restore.outputs.cache-hit || steps.cache-restore.outputs.cache-hit == 'false' }} 45 | shell: pwsh 46 | run: | 47 | Invoke-WebRequest "https://github.com/ninja-build/ninja/releases/download/v${{ inputs.version }}/${{ steps.calc.outputs.archive }}" -OutFile "${{ runner.temp }}/${{ steps.calc.outputs.archive }}" 48 | - name: 'Cache ${{ steps.calc.outputs.archive }}' 49 | if: ${{ !steps.cache-restore.outputs.cache-hit || steps.cache-restore.outputs.cache-hit == 'false' }} 50 | uses: actions/cache/save@v4 51 | with: 52 | path: '${{ runner.temp }}/${{ steps.calc.outputs.archive }}' 53 | key: ${{ steps.calc.outputs.cache-key }} 54 | - name: 'Extract ninja' 55 | shell: pwsh 56 | run: | 57 | 7z "-o${{ runner.temp }}/ninja-${{ inputs.version }}-${{ runner.arch }}" x "${{ runner.temp }}/${{ steps.calc.outputs.archive }}" 58 | - name: 'Set output variables' 59 | id: final 60 | shell: pwsh 61 | run: | 62 | echo "${{ runner.temp }}/ninja-${{ inputs.version }}-${{ runner.arch }}" >> $env:GITHUB_PATH 63 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | pull_request: 5 | push: 6 | 7 | jobs: 8 | Build: 9 | name: '${{ matrix.platform.name }}' 10 | runs-on: '${{ matrix.platform.os }}' 11 | strategy: 12 | fail-fast: false 13 | matrix: 14 | platform: 15 | - { name: 'Linux', os: ubuntu-latest, shell: sh } 16 | - { name: 'MacOS', os: macos-latest, shell: sh } 17 | # - { name: 'Windows msys2 (mingw32)', os: windows-latest, shell: 'msys2 {0}', msystem: mingw32, msys-env: mingw-w64-i686 } 18 | - { name: 'Windows msys2 (mingw64)', os: windows-latest, shell: 'msys2 {0}', msystem: mingw64, msys-env: mingw-w64-x86_64 } 19 | # - { name: 'Windows msys2 (clang32)', os: windows-latest, shell: 'msys2 {0}', msystem: clang32, msys-env: mingw-w64-clang-i686 } 20 | - { name: 'Windows msys2 (clang64)', os: windows-latest, shell: 'msys2 {0}', msystem: clang64, msys-env: mingw-w64-clang-x86_64 } 21 | # - { name: 'Windows MSVC (x86)', os: windows-latest, shell: sh, msvc: true, msvc-arch: x86, cmake: '-DPerl_ROOT=C:/Strawberry/perl/bin/' } 22 | - { name: 'Windows MSVC (x64)', os: windows-latest, shell: sh, msvc: true, msvc-arch: x64, cmake: '-DPerl_ROOT=C:/Strawberry/perl/bin/' } 23 | # - { name: 'Windows MSVC (arm32)', os: windows-latest, shell: sh, msvc: true, msvc-arch: amd64_arm, cross: true } 24 | # - { name: 'Windows MSVC (arm64)', os: windows-latest, shell: sh, msvc: true, msvc-arch: amd64_arm64, cross: true } 25 | defaults: 26 | run: 27 | shell: ${{ matrix.platform.shell }} 28 | steps: 29 | - uses: ilammy/msvc-dev-cmd@v1 30 | if: ${{ matrix.platform.msvc }} 31 | with: 32 | arch: ${{ matrix.platform.msvc-arch }} 33 | - name: Set up MSYS2 34 | if: ${{ contains(matrix.platform.shell, 'msys2') }} 35 | uses: msys2/setup-msys2@v2 36 | with: 37 | msystem: ${{ matrix.platform.msystem }} 38 | install: >- 39 | ${{ matrix.platform.msys-env }}-cc 40 | ${{ matrix.platform.msys-env }}-cmake 41 | ${{ matrix.platform.msys-env }}-crt 42 | ${{ matrix.platform.msys-env }}-ninja 43 | ${{ matrix.platform.msys-env }}-perl 44 | - name: Get SDL3_net sources 45 | uses: actions/checkout@v4 46 | - name: Install Ninja 47 | if: ${{ !contains(matrix.platform.shell, 'msys2') }} 48 | uses: aseprite/get-ninja@main 49 | - name: Set up SDL3 50 | uses: libsdl-org/setup-sdl@main 51 | id: sdl 52 | with: 53 | cmake-generator: Ninja 54 | version: 3-head 55 | sdl-test: true 56 | shell: ${{ matrix.platform.shell }} 57 | add-to-environment: true 58 | - name: Configure (CMake) 59 | run: | 60 | cmake -B build -GNinja \ 61 | -DCMAKE_BUILD_TYPE=Release \ 62 | -DCMAKE_INSTALL_PREFIX=prefix \ 63 | -DSDLNET_WERROR=ON \ 64 | -DSDLNET_INSTALL_MAN=ON \ 65 | -DCMAKE_INSTALL_PREFIX=prefix \ 66 | ${{ matrix.platform.cmake }} 67 | 68 | - name: Build (CMake) 69 | run: | 70 | cmake --build build/ --verbose 71 | - name: Install (CMake) 72 | if: ${{ matrix.platform.shell == 'sh' || contains(matrix.platform.shell, 'msys2') }} 73 | run: | 74 | set -eu 75 | rm -fr DESTDIR-cmake 76 | cmake --install build/ --config Release 77 | echo "SDL3_net_ROOT=$(pwd)/prefix" >> $GITHUB_ENV 78 | ( cd prefix; find . ) | LC_ALL=C sort -u 79 | - name: Verify CMake configuration files 80 | run: | 81 | cmake -S cmake/test -B cmake_config_build \ 82 | -DCMAKE_BUILD_TYPE=Release \ 83 | -DTEST_SHARED=TRUE \ 84 | -DTEST_STATIC=FALSE 85 | cmake --build cmake_config_build --verbose 86 | 87 | - name: Check that versioning is consistent 88 | # We only need to run this once: arbitrarily use the Linux build 89 | if: ${{ runner.os == 'Linux' }} 90 | run: ./build-scripts/test-versioning.sh 91 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: 'release' 2 | run-name: 'Create SDL_net release artifacts for ${{ inputs.commit }}' 3 | 4 | on: 5 | workflow_dispatch: 6 | inputs: 7 | commit: 8 | description: 'Commit of SDL_net' 9 | required: true 10 | 11 | jobs: 12 | 13 | src: 14 | runs-on: ubuntu-latest 15 | outputs: 16 | project: ${{ steps.releaser.outputs.project }} 17 | version: ${{ steps.releaser.outputs.version }} 18 | src-tar-gz: ${{ steps.releaser.outputs.src-tar-gz }} 19 | src-tar-xz: ${{ steps.releaser.outputs.src-tar-xz }} 20 | src-zip: ${{ steps.releaser.outputs.src-zip }} 21 | steps: 22 | - name: 'Set up Python' 23 | uses: actions/setup-python@v5 24 | with: 25 | python-version: '3.11' 26 | - name: 'Fetch build-release.py' 27 | uses: actions/checkout@v4 28 | with: 29 | ref: ${{ inputs.commit }} 30 | sparse-checkout: 'build-scripts/build-release.py' 31 | - name: 'Set up SDL sources' 32 | uses: actions/checkout@v4 33 | with: 34 | ref: ${{ inputs.commit }} 35 | path: 'SDL' 36 | fetch-depth: 0 37 | - name: 'Build Source archive' 38 | id: releaser 39 | shell: bash 40 | env: 41 | GH_TOKEN: ${{ github.token }} 42 | run: | 43 | python build-scripts/build-release.py \ 44 | --actions source \ 45 | --commit ${{ inputs.commit }} \ 46 | --root "${{ github.workspace }}/SDL" \ 47 | --github \ 48 | --debug 49 | - name: 'Store source archives' 50 | uses: actions/upload-artifact@v4 51 | with: 52 | name: sources 53 | path: '${{ github.workspace}}/dist' 54 | - name: 'Generate summary' 55 | run: | 56 | echo "Run the following commands to download all artifacts:" >> $GITHUB_STEP_SUMMARY 57 | echo '```' >> $GITHUB_STEP_SUMMARY 58 | echo "mkdir -p /tmp/${{ steps.releaser.outputs.project }}-${{ steps.releaser.outputs.version }}" >> $GITHUB_STEP_SUMMARY 59 | echo "cd /tmp/${{ steps.releaser.outputs.project }}-${{ steps.releaser.outputs.version }}" >> $GITHUB_STEP_SUMMARY 60 | echo "gh run -R ${{ github.repository }} download ${{ github.run_id }}" >> $GITHUB_STEP_SUMMARY 61 | echo '```' >> $GITHUB_STEP_SUMMARY 62 | 63 | linux-verify: 64 | needs: [src] 65 | runs-on: ubuntu-latest 66 | steps: 67 | - name: 'Set up Python' 68 | uses: actions/setup-python@v5 69 | with: 70 | python-version: '3.11' 71 | - name: 'Download source archives' 72 | uses: actions/download-artifact@v4 73 | with: 74 | name: sources 75 | path: '/tmp' 76 | - name: 'Unzip ${{ needs.src.outputs.src-zip }}' 77 | id: zip 78 | run: | 79 | set -e 80 | mkdir /tmp/zipdir 81 | cd /tmp/zipdir 82 | unzip "/tmp/${{ needs.src.outputs.src-zip }}" 83 | echo "path=/tmp/zipdir/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$GITHUB_OUTPUT 84 | - name: 'Untar ${{ needs.src.outputs.src-tar-gz }}' 85 | id: tar 86 | run: | 87 | set -e 88 | mkdir -p /tmp/tardir 89 | tar -C /tmp/tardir -v -x -f "/tmp/${{ needs.src.outputs.src-tar-gz }}" 90 | echo "path=/tmp/tardir/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$GITHUB_OUTPUT 91 | - name: 'Compare contents of ${{ needs.src.outputs.src-zip }} and ${{ needs.src.outputs.src-tar-gz }}' 92 | run: | 93 | set -e 94 | diff "${{ steps.zip.outputs.path }}" "${{ steps.tar.outputs.path }}" 95 | - name: 'Test versioning' 96 | shell: bash 97 | run: | 98 | ${{ steps.tar.outputs.path }}/build-scripts/test-versioning.sh 99 | - name: 'Fetch build-release.py' 100 | uses: actions/checkout@v4 101 | with: 102 | ref: ${{ inputs.commit }} 103 | sparse-checkout: 'build-scripts/build-release.py' 104 | - name: 'Download dependencies' 105 | id: deps 106 | env: 107 | GH_TOKEN: ${{ github.token }} 108 | run: | 109 | python build-scripts/build-release.py \ 110 | --actions download \ 111 | --commit ${{ inputs.commit }} \ 112 | --root "${{ steps.tar.outputs.path }}" \ 113 | --github \ 114 | --debug 115 | - name: 'Install Linux dependencies' 116 | run: | 117 | sudo apt-get update -y 118 | sudo apt-get install -y \ 119 | gnome-desktop-testing libasound2-dev libpulse-dev libaudio-dev libjack-dev libsndio-dev \ 120 | libusb-1.0-0-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev \ 121 | libxss-dev libwayland-dev libxkbcommon-dev libdrm-dev libgbm-dev libgl1-mesa-dev libgles2-mesa-dev \ 122 | libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev fcitx-libs-dev 123 | - name: 'Extract dependencies, build and install them' 124 | id: deps-build 125 | run: | 126 | tar -C /tmp -v -x -f "${{ steps.deps.outputs.dep-path }}/SDL3-${{ steps.deps.outputs.dep-sdl-version }}.tar.gz" 127 | cmake -S /tmp/SDL3-${{ steps.deps.outputs.dep-sdl-version }} -B /tmp/SDL-build -DCMAKE_INSTALL_PREFIX=/tmp/deps-prefix 128 | cmake --build /tmp/SDL-build 129 | cmake --install /tmp/SDL-build 130 | echo "path=/tmp/deps-prefix" >>$GITHUB_OUTPUT 131 | - name: 'CMake (configure + build)' 132 | run: | 133 | cmake \ 134 | -S ${{ steps.tar.outputs.path }} \ 135 | -B /tmp/build \ 136 | -DSDL3net_SAMPLES=ON \ 137 | -DSDL3net_TESTS=ON \ 138 | -DCMAKE_PREFIX_PATH="${{ steps.deps-build.outputs.path }}" 139 | cmake --build /tmp/build --verbose 140 | # ctest --test-dir /tmp/build --no-tests=error --output-on-failure 141 | 142 | # dmg: 143 | # needs: [src] 144 | # runs-on: macos-latest 145 | # outputs: 146 | # dmg: ${{ steps.releaser.outputs.dmg }} 147 | # steps: 148 | # - name: 'Set up Python' 149 | # uses: actions/setup-python@v5 150 | # with: 151 | # python-version: '3.11' 152 | # - name: 'Fetch build-release.py' 153 | # uses: actions/checkout@v4 154 | # with: 155 | # ref: ${{ inputs.commit }} 156 | # sparse-checkout: 'build-scripts/build-release.py' 157 | # - name: 'Download source archives' 158 | # uses: actions/download-artifact@v4 159 | # with: 160 | # name: sources 161 | # path: '${{ github.workspace }}' 162 | # - name: 'Untar ${{ needs.src.outputs.src-tar-gz }}' 163 | # id: tar 164 | # run: | 165 | # mkdir -p "${{ github.workspace }}/tardir" 166 | # tar -C "${{ github.workspace }}/tardir" -v -x -f "${{ github.workspace }}/${{ needs.src.outputs.src-tar-gz }}" 167 | # echo "path=${{ github.workspace }}/tardir/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$GITHUB_OUTPUT 168 | ## - name: 'Download external dependencies' 169 | ## run: | 170 | ## sh "${{ steps.tar.outputs.path }}/external/download.sh" --depth 1 171 | # - name: 'Build SDL3_net.dmg' 172 | # id: releaser 173 | # shell: bash 174 | # env: 175 | # GH_TOKEN: ${{ github.token }} 176 | # run: | 177 | # python build-scripts/build-release.py \ 178 | # --actions dmg \ 179 | # --commit ${{ inputs.commit }} \ 180 | # --root "${{ steps.tar.outputs.path }}" \ 181 | # --github \ 182 | # --debug 183 | # - name: 'Store DMG image file' 184 | # uses: actions/upload-artifact@v4 185 | # with: 186 | # name: dmg 187 | # path: '${{ github.workspace }}/dist' 188 | # 189 | # dmg-verify: 190 | # needs: [dmg, src] 191 | # runs-on: macos-latest 192 | # steps: 193 | # - name: 'Set up Python' 194 | # uses: actions/setup-python@v5 195 | # with: 196 | # python-version: '3.11' 197 | # - name: 'Fetch build-release.py' 198 | # uses: actions/checkout@v4 199 | # with: 200 | # ref: ${{ inputs.commit }} 201 | # sparse-checkout: 'build-scripts/build-release.py' 202 | # - name: 'Download source archives' 203 | # uses: actions/download-artifact@v4 204 | # with: 205 | # name: sources 206 | # path: '${{ github.workspace }}' 207 | # - name: 'Untar ${{ needs.src.outputs.src-tar-gz }}' 208 | # id: src 209 | # run: | 210 | # mkdir -p /tmp/tardir 211 | # tar -C /tmp/tardir -v -x -f "${{ github.workspace }}/${{ needs.src.outputs.src-tar-gz }}" 212 | # echo "path=/tmp/tardir/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$GITHUB_OUTPUT 213 | # - name: 'Download dependencies' 214 | # id: deps 215 | # env: 216 | # GH_TOKEN: ${{ github.token }} 217 | # run: | 218 | # python build-scripts/build-release.py \ 219 | # --actions download \ 220 | # --commit ${{ inputs.commit }} \ 221 | # --root "${{ steps.src.outputs.path }}" \ 222 | # --github \ 223 | # --debug 224 | # - name: 'Mount dependencies' 225 | # id: deps-mount 226 | # run: | 227 | # hdiutil attach "${{ steps.deps.outputs.dep-path }}/SDL3-${{ steps.deps.outputs.dep-sdl-version }}.dmg" 228 | # sdl_mount_pount="/Volumes/SDL3" 229 | # if [ ! -d "$sdl_mount_pount/SDL3.xcframework" ]; then 230 | # echo "Cannot find SDL3.xcframework!" 231 | # exit 1 232 | # fi 233 | # echo "path=${sdl_mount_pount}" >>$GITHUB_OUTPUT 234 | # - name: 'Download ${{ needs.dmg.outputs.dmg }}' 235 | # uses: actions/download-artifact@v4 236 | # with: 237 | # name: dmg 238 | # path: '${{ github.workspace }}' 239 | # - name: 'Mount ${{ needs.dmg.outputs.dmg }}' 240 | # id: mount 241 | # run: | 242 | # hdiutil attach '${{ github.workspace }}/${{ needs.dmg.outputs.dmg }}' 243 | # mount_point="/Volumes/${{ needs.src.outputs.project }}" 244 | # if [ ! -d "$mount_point/${{ needs.src.outputs.project }}.xcframework" ]; then 245 | # echo "Cannot find ${{ needs.src.outputs.project }}.xcframework!" 246 | # exit 1 247 | # fi 248 | # echo "mount-point=${mount_point}">>$GITHUB_OUTPUT 249 | # - name: 'CMake (configure + build) Darwin' 250 | # run: | 251 | # set -e 252 | # cmake -S "${{ steps.src.outputs.path }}/cmake/test" \ 253 | # -DTEST_SHARED=TRUE \ 254 | # -DTEST_SHARED=TRUE \ 255 | # -DTEST_STATIC=FALSE \ 256 | # -DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount-point }};${{ steps.deps-mount.outputs.path }}" \ 257 | # -DCMAKE_SYSTEM_NAME=Darwin \ 258 | # -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \ 259 | # -Werror=dev \ 260 | # -B build_darwin 261 | # cmake --build build_darwin --config Release --verbose 262 | # 263 | # - name: 'CMake (configure + build) iOS' 264 | # run: | 265 | # cmake -S "${{ steps.src.outputs.path }}/cmake/test" \ 266 | # -DTEST_SHARED=TRUE \ 267 | # -DTEST_STATIC=FALSE \ 268 | # -DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount-point }};${{ steps.deps-mount.outputs.path }}" \ 269 | # -DCMAKE_SYSTEM_NAME=iOS \ 270 | # -DCMAKE_OSX_ARCHITECTURES="arm64" \ 271 | # -Werror=dev \ 272 | # -B build_ios 273 | # cmake --build build_ios --config Release --verbose 274 | # - name: 'CMake (configure + build) tvOS' 275 | # run: | 276 | # cmake -S "${{ steps.src.outputs.path }}/cmake/test" \ 277 | # -DTEST_SHARED=TRUE \ 278 | # -DTEST_STATIC=FALSE \ 279 | # -DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount-point }};${{ steps.deps-mount.outputs.path }}" \ 280 | # -DCMAKE_SYSTEM_NAME=tvOS \ 281 | # -DCMAKE_OSX_ARCHITECTURES="arm64" \ 282 | # -Werror=dev \ 283 | # -B build_tvos 284 | # cmake --build build_tvos --config Release --verbose 285 | # - name: 'CMake (configure + build) iOS simulator' 286 | # run: | 287 | # sysroot=$(xcodebuild -version -sdk iphonesimulator Path) 288 | # echo "sysroot=$sysroot" 289 | # cmake -S "${{ steps.src.outputs.path }}/cmake/test" \ 290 | # -DTEST_SHARED=TRUE \ 291 | # -DTEST_STATIC=FALSE \ 292 | # -DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount-point }};${{ steps.deps-mount.outputs.path }}" \ 293 | # -DCMAKE_SYSTEM_NAME=iOS \ 294 | # -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \ 295 | # -DCMAKE_OSX_SYSROOT="${sysroot}" \ 296 | # -Werror=dev \ 297 | # -B build_ios_simulator 298 | # cmake --build build_ios_simulator --config Release --verbose 299 | # - name: 'CMake (configure + build) tvOS simulator' 300 | # run: | 301 | # sysroot=$(xcodebuild -version -sdk appletvsimulator Path) 302 | # echo "sysroot=$sysroot" 303 | # cmake -S "${{ steps.src.outputs.path }}/cmake/test" \ 304 | # -DTEST_SHARED=TRUE \ 305 | # -DTEST_STATIC=FALSE \ 306 | # -DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount-point }};${{ steps.deps-mount.outputs.path }}" \ 307 | # -DCMAKE_SYSTEM_NAME=tvOS \ 308 | # -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \ 309 | # -DCMAKE_OSX_SYSROOT="${sysroot}" \ 310 | # -Werror=dev \ 311 | # -B build_tvos_simulator 312 | # cmake --build build_tvos_simulator --config Release --verbose 313 | msvc: 314 | needs: [src] 315 | runs-on: windows-2019 316 | outputs: 317 | VC-x86: ${{ steps.releaser.outputs.VC-x86 }} 318 | VC-x64: ${{ steps.releaser.outputs.VC-x64 }} 319 | VC-devel: ${{ steps.releaser.outputs.VC-devel }} 320 | steps: 321 | - name: 'Set up Python' 322 | uses: actions/setup-python@v5 323 | with: 324 | python-version: '3.11' 325 | - name: 'Fetch build-release.py' 326 | uses: actions/checkout@v4 327 | with: 328 | ref: ${{ inputs.commit }} 329 | sparse-checkout: 'build-scripts/build-release.py' 330 | - name: 'Download source archives' 331 | uses: actions/download-artifact@v4 332 | with: 333 | name: sources 334 | path: '${{ github.workspace }}' 335 | - name: 'Unzip ${{ needs.src.outputs.src-zip }}' 336 | id: zip 337 | run: | 338 | New-Item C:\temp -ItemType Directory -ErrorAction SilentlyContinue 339 | cd C:\temp 340 | unzip "${{ github.workspace }}/${{ needs.src.outputs.src-zip }}" 341 | echo "path=C:\temp\${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$Env:GITHUB_OUTPUT 342 | # - name: 'Download external dependencies' 343 | # run: | 344 | # ${{ steps.zip.outputs.path }}/external/Get-GitModules.ps1 345 | - name: 'Build MSVC binary archives' 346 | id: releaser 347 | env: 348 | GH_TOKEN: ${{ github.token }} 349 | run: | 350 | python build-scripts/build-release.py ` 351 | --actions download msvc ` 352 | --commit ${{ inputs.commit }} ` 353 | --root "${{ steps.zip.outputs.path }}" ` 354 | --github ` 355 | --debug 356 | - name: 'Store MSVC archives' 357 | uses: actions/upload-artifact@v4 358 | with: 359 | name: msvc 360 | path: '${{ github.workspace }}/dist' 361 | 362 | msvc-verify: 363 | needs: [msvc, src] 364 | runs-on: windows-latest 365 | steps: 366 | - name: 'Fetch .github/actions/setup-ninja/action.yml' 367 | uses: actions/checkout@v4 368 | with: 369 | ref: ${{ inputs.commit }} 370 | sparse-checkout: | 371 | .github/actions/setup-ninja/action.yml 372 | build-scripts/build-release.py 373 | - name: 'Set up Python' 374 | uses: actions/setup-python@v5 375 | with: 376 | python-version: '3.11' 377 | - name: Set up ninja 378 | uses: ./.github/actions/setup-ninja 379 | - name: 'Download source archives' 380 | uses: actions/download-artifact@v4 381 | with: 382 | name: sources 383 | path: '${{ github.workspace }}' 384 | - name: 'Unzip ${{ needs.src.outputs.src-zip }}' 385 | id: src 386 | run: | 387 | mkdir '${{ github.workspace }}/sources' 388 | cd '${{ github.workspace }}/sources' 389 | unzip "${{ github.workspace }}/${{ needs.src.outputs.src-zip }}" 390 | echo "path=${{ github.workspace }}/sources/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$env:GITHUB_OUTPUT 391 | - name: 'Download dependencies' 392 | id: deps 393 | env: 394 | GH_TOKEN: ${{ github.token }} 395 | run: | 396 | python build-scripts/build-release.py ` 397 | --actions download ` 398 | --commit ${{ inputs.commit }} ` 399 | --root "${{ steps.src.outputs.path }}" ` 400 | --github ` 401 | --debug 402 | - name: 'Extract dependencies' 403 | id: deps-extract 404 | run: | 405 | mkdir '${{ github.workspace }}/deps-vc' 406 | cd '${{ github.workspace }}/deps-vc' 407 | unzip "${{ steps.deps.outputs.dep-path }}/SDL3-devel-${{ steps.deps.outputs.dep-sdl-version }}-VC.zip" 408 | echo "path=${{ github.workspace }}/deps-vc" >>$env:GITHUB_OUTPUT 409 | - name: 'Download MSVC binaries' 410 | uses: actions/download-artifact@v4 411 | with: 412 | name: msvc 413 | path: '${{ github.workspace }}' 414 | - name: 'Unzip ${{ needs.msvc.outputs.VC-devel }}' 415 | id: bin 416 | run: | 417 | mkdir '${{ github.workspace }}/vc' 418 | cd '${{ github.workspace }}/vc' 419 | unzip "${{ github.workspace }}/${{ needs.msvc.outputs.VC-devel }}" 420 | echo "path=${{ github.workspace }}/vc/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$env:GITHUB_OUTPUT 421 | - name: 'Configure vcvars x86' 422 | uses: ilammy/msvc-dev-cmd@v1 423 | with: 424 | arch: x64_x86 425 | - name: 'CMake (configure + build + tests) x86' 426 | run: | 427 | cmake -S "${{ steps.src.outputs.path }}/cmake/test" ` 428 | -B build_x86 ` 429 | -GNinja ` 430 | -DCMAKE_BUILD_TYPE=Debug ` 431 | -Werror=dev ` 432 | -DTEST_SHARED=TRUE ` 433 | -DTEST_STATIC=FALSE ` 434 | -DCMAKE_SUPPRESS_REGENERATION=TRUE ` 435 | -DCMAKE_PREFIX_PATH="${{ steps.bin.outputs.path }};${{ steps.deps-extract.outputs.path }}" 436 | Start-Sleep -Seconds 2 437 | cmake --build build_x86 --config Release --verbose 438 | - name: 'Configure vcvars x64' 439 | uses: ilammy/msvc-dev-cmd@v1 440 | with: 441 | arch: x64 442 | - name: 'CMake (configure + build + tests) x64' 443 | run: | 444 | cmake -S "${{ steps.src.outputs.path }}/cmake/test" ` 445 | -B build_x64 ` 446 | -GNinja ` 447 | -DCMAKE_BUILD_TYPE=Debug ` 448 | -Werror=dev ` 449 | -DTEST_SHARED=TRUE ` 450 | -DTEST_STATIC=FALSE ` 451 | -DCMAKE_SUPPRESS_REGENERATION=TRUE ` 452 | -DCMAKE_PREFIX_PATH="${{ steps.bin.outputs.path }};${{ steps.deps-extract.outputs.path }}" 453 | Start-Sleep -Seconds 2 454 | cmake --build build_x64 --config Release --verbose 455 | - name: 'Configure vcvars arm64' 456 | uses: ilammy/msvc-dev-cmd@v1 457 | with: 458 | arch: x64_arm64 459 | - name: 'CMake (configure + build + tests) arm64' 460 | run: | 461 | cmake -S "${{ steps.src.outputs.path }}/cmake/test" ` 462 | -B build_arm64 ` 463 | -GNinja ` 464 | -DCMAKE_BUILD_TYPE=Debug ` 465 | -Werror=dev ` 466 | -DTEST_SHARED=TRUE ` 467 | -DTEST_STATIC=FALSE ` 468 | -DCMAKE_SUPPRESS_REGENERATION=TRUE ` 469 | -DCMAKE_PREFIX_PATH="${{ steps.bin.outputs.path }};${{ steps.deps-extract.outputs.path }}" 470 | Start-Sleep -Seconds 2 471 | cmake --build build_arm64 --config Release --verbose 472 | 473 | mingw: 474 | needs: [src] 475 | runs-on: ubuntu-24.04 # FIXME: current ubuntu-latest ships an outdated mingw, replace with ubuntu-latest once 24.04 becomes the new default 476 | outputs: 477 | mingw-devel-tar-gz: ${{ steps.releaser.outputs.mingw-devel-tar-gz }} 478 | mingw-devel-tar-xz: ${{ steps.releaser.outputs.mingw-devel-tar-xz }} 479 | steps: 480 | - name: 'Set up Python' 481 | uses: actions/setup-python@v5 482 | with: 483 | python-version: '3.11' 484 | - name: 'Fetch build-release.py' 485 | uses: actions/checkout@v4 486 | with: 487 | ref: ${{ inputs.commit }} 488 | sparse-checkout: 'build-scripts/build-release.py' 489 | - name: 'Install Mingw toolchain' 490 | run: | 491 | sudo apt-get update -y 492 | sudo apt-get install -y gcc-mingw-w64 g++-mingw-w64 ninja-build 493 | - name: 'Download source archives' 494 | uses: actions/download-artifact@v4 495 | with: 496 | name: sources 497 | path: '${{ github.workspace }}' 498 | - name: 'Untar ${{ needs.src.outputs.src-tar-gz }}' 499 | id: tar 500 | run: | 501 | mkdir -p /tmp/tardir 502 | tar -C /tmp/tardir -v -x -f "${{ github.workspace }}/${{ needs.src.outputs.src-tar-gz }}" 503 | echo "path=/tmp/tardir/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$GITHUB_OUTPUT 504 | - name: 'Build MinGW binary archives' 505 | id: releaser 506 | env: 507 | GH_TOKEN: ${{ github.token }} 508 | run: | 509 | python build-scripts/build-release.py \ 510 | --actions download mingw \ 511 | --commit ${{ inputs.commit }} \ 512 | --root "${{ steps.tar.outputs.path }}" \ 513 | --github \ 514 | --debug 515 | - name: 'Store MinGW archives' 516 | uses: actions/upload-artifact@v4 517 | with: 518 | name: mingw 519 | path: '${{ github.workspace }}/dist' 520 | 521 | mingw-verify: 522 | needs: [mingw, src] 523 | runs-on: ubuntu-latest 524 | steps: 525 | - name: 'Set up Python' 526 | uses: actions/setup-python@v5 527 | with: 528 | python-version: '3.11' 529 | - name: 'Fetch build-release.py' 530 | uses: actions/checkout@v4 531 | with: 532 | ref: ${{ inputs.commit }} 533 | sparse-checkout: 'build-scripts/build-release.py' 534 | - name: 'Install Mingw toolchain' 535 | run: | 536 | sudo apt-get update -y 537 | sudo apt-get install -y gcc-mingw-w64 g++-mingw-w64 ninja-build 538 | - name: 'Download source archives' 539 | uses: actions/download-artifact@v4 540 | with: 541 | name: sources 542 | path: '${{ github.workspace }}' 543 | - name: 'Untar ${{ needs.src.outputs.src-tar-gz }}' 544 | id: src 545 | run: | 546 | mkdir -p /tmp/tardir 547 | tar -C /tmp/tardir -v -x -f "${{ github.workspace }}/${{ needs.src.outputs.src-tar-gz }}" 548 | echo "path=/tmp/tardir/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$GITHUB_OUTPUT 549 | - name: 'Download dependencies' 550 | id: deps 551 | env: 552 | GH_TOKEN: ${{ github.token }} 553 | run: | 554 | python build-scripts/build-release.py \ 555 | --actions download \ 556 | --commit ${{ inputs.commit }} \ 557 | --root "${{ steps.src.outputs.path }}" \ 558 | --github \ 559 | --debug 560 | - name: 'Untar and install dependencies' 561 | id: deps-extract 562 | run: | 563 | mkdir -p /tmp/deps-mingw/cmake 564 | mkdir -p /tmp/deps-mingw/i686-w64-mingw32 565 | mkdir -p /tmp/deps-mingw/x86_64-w64-mingw32 566 | 567 | mkdir -p /tmp/deps-mingw-extract/sdl3 568 | tar -C /tmp/deps-mingw-extract/sdl3 -v -x -f "${{ steps.deps.outputs.dep-path }}/SDL3-devel-${{ steps.deps.outputs.dep-sdl-version }}-mingw.tar.gz" 569 | make -C /tmp/deps-mingw-extract/sdl3/SDL3-${{ steps.deps.outputs.dep-sdl-version }} install-all DESTDIR=/tmp/deps-mingw 570 | 571 | # FIXME: this should be fixed in SDL3 releases after 3.1.3 572 | mkdir -p /tmp/deps-mingw/cmake 573 | cp -rv /tmp/deps-mingw-extract/sdl3/SDL3-${{ steps.deps.outputs.dep-sdl-version }}/cmake/* /tmp/deps-mingw/cmake 574 | - name: 'Download MinGW binaries' 575 | uses: actions/download-artifact@v4 576 | with: 577 | name: mingw 578 | path: '${{ github.workspace }}' 579 | - name: 'Untar and install ${{ needs.mingw.outputs.mingw-devel-tar-gz }}' 580 | id: bin 581 | run: | 582 | mkdir -p /tmp/mingw-tardir 583 | tar -C /tmp/mingw-tardir -v -x -f "${{ github.workspace }}/${{ needs.mingw.outputs.mingw-devel-tar-gz }}" 584 | make -C /tmp/mingw-tardir/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }} install-all DESTDIR=/tmp/deps-mingw 585 | - name: 'CMake (configure + build) i686' 586 | run: | 587 | set -e 588 | cmake -S "${{ steps.src.outputs.path }}/cmake/test" \ 589 | -DCMAKE_BUILD_TYPE="Release" \ 590 | -DTEST_SHARED=TRUE \ 591 | -DTEST_STATIC=FALSE \ 592 | -DCMAKE_PREFIX_PATH="/tmp/deps-mingw" \ 593 | -DCMAKE_TOOLCHAIN_FILE="${{ steps.src.outputs.path }}/build-scripts/cmake-toolchain-mingw64-i686.cmake" \ 594 | -Werror=dev \ 595 | -B build_x86 596 | cmake --build build_x86 --config Release --verbose 597 | - name: 'CMake (configure + build) x86_64' 598 | run: | 599 | set -e 600 | cmake -S "${{ steps.src.outputs.path }}/cmake/test" \ 601 | -DCMAKE_BUILD_TYPE="Release" \ 602 | -DTEST_SHARED=TRUE \ 603 | -DTEST_STATIC=FALSE \ 604 | -DCMAKE_PREFIX_PATH="/tmp/deps-mingw" \ 605 | -DCMAKE_TOOLCHAIN_FILE="${{ steps.src.outputs.path }}/build-scripts/cmake-toolchain-mingw64-x86_64.cmake" \ 606 | -Werror=dev \ 607 | -B build_x64 608 | cmake --build build_x64 --config Release --verbose 609 | 610 | android: 611 | needs: [src] 612 | runs-on: ubuntu-latest 613 | outputs: 614 | android-aar: ${{ steps.releaser.outputs.android-aar }} 615 | steps: 616 | - name: 'Set up Python' 617 | uses: actions/setup-python@v5 618 | with: 619 | python-version: '3.11' 620 | - name: 'Fetch build-release.py' 621 | uses: actions/checkout@v4 622 | with: 623 | sparse-checkout: 'build-scripts/build-release.py' 624 | - name: 'Setup Android NDK' 625 | uses: nttld/setup-ndk@v1 626 | with: 627 | local-cache: true 628 | ndk-version: r21e 629 | - name: 'Setup Java JDK' 630 | uses: actions/setup-java@v4 631 | with: 632 | distribution: 'temurin' 633 | java-version: '11' 634 | - name: 'Install ninja' 635 | run: | 636 | sudo apt-get update -y 637 | sudo apt-get install -y ninja-build 638 | - name: 'Download source archives' 639 | uses: actions/download-artifact@v4 640 | with: 641 | name: sources 642 | path: '${{ github.workspace }}' 643 | - name: 'Untar ${{ needs.src.outputs.src-tar-gz }}' 644 | id: tar 645 | run: | 646 | mkdir -p /tmp/tardir 647 | tar -C /tmp/tardir -v -x -f "${{ github.workspace }}/${{ needs.src.outputs.src-tar-gz }}" 648 | echo "path=/tmp/tardir/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$GITHUB_OUTPUT 649 | - name: 'Build Android prefab binary archive(s)' 650 | id: releaser 651 | env: 652 | GH_TOKEN: ${{ github.token }} 653 | run: | 654 | python build-scripts/build-release.py \ 655 | --actions download android \ 656 | --commit ${{ inputs.commit }} \ 657 | --root "${{ steps.tar.outputs.path }}" \ 658 | --github \ 659 | --debug 660 | - name: 'Store Android archive(s)' 661 | uses: actions/upload-artifact@v4 662 | with: 663 | name: android 664 | path: '${{ github.workspace }}/dist' 665 | 666 | android-verify: 667 | needs: [android, src] 668 | runs-on: ubuntu-latest 669 | steps: 670 | - name: 'Set up Python' 671 | uses: actions/setup-python@v5 672 | with: 673 | python-version: '3.11' 674 | - uses: actions/setup-java@v4 675 | with: 676 | distribution: 'temurin' 677 | java-version: '17' 678 | - name: 'Download source archives' 679 | uses: actions/download-artifact@v4 680 | with: 681 | name: sources 682 | path: '${{ github.workspace }}' 683 | - name: 'Download Android .aar archive' 684 | uses: actions/download-artifact@v4 685 | with: 686 | name: android 687 | path: '${{ github.workspace }}' 688 | - name: 'Untar ${{ needs.src.outputs.src-tar-gz }}' 689 | id: src 690 | run: | 691 | mkdir -p /tmp/tardir 692 | tar -C /tmp/tardir -v -x -f "${{ github.workspace }}/${{ needs.src.outputs.src-tar-gz }}" 693 | echo "path=/tmp/tardir/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$GITHUB_OUTPUT 694 | - name: 'Extract Android SDK from AAR' 695 | id: sdk 696 | run: | 697 | unzip -o "${{ github.workspace }}/${{ needs.android.outputs.android-aar }}" 698 | python "${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}.aar" -o /tmp/SDL3_net-android 699 | echo "prefix=/tmp/SDL3_net-android" >>$GITHUB_OUTPUT 700 | - name: 'Download dependencies' 701 | id: deps 702 | env: 703 | GH_TOKEN: ${{ github.token }} 704 | run: | 705 | python "${{ steps.src.outputs.path }}/build-scripts/build-release.py" \ 706 | --actions download \ 707 | --commit ${{ inputs.commit }} \ 708 | --root "${{ steps.src.outputs.path }}" \ 709 | --github \ 710 | --debug 711 | - name: 'Extract dependencies' 712 | id: deps-extract 713 | run: | 714 | unzip -o "${{ steps.deps.outputs.dep-path }}/SDL3-devel-${{ steps.deps.outputs.dep-sdl-version }}-android.zip" 715 | python "SDL3-${{ steps.deps.outputs.dep-sdl-version }}.aar" -o /tmp/SDL3-android 716 | echo "sdl3-prefix=/tmp/SDL3-android" >>$GITHUB_OUTPUT 717 | - name: 'Install ninja' 718 | run: | 719 | sudo apt-get update -y 720 | sudo apt-get install -y ninja-build 721 | - name: 'CMake (configure + build) x86, x64, arm32, arm64' 722 | run: | 723 | android_abis="x86 x86_64 armeabi-v7a arm64-v8a" 724 | for android_abi in ${android_abis}; do 725 | echo "Configuring ${android_abi}..." 726 | cmake -S "${{ steps.src.outputs.path }}/cmake/test" \ 727 | -GNinja \ 728 | -DTEST_FULL=TRUE \ 729 | -DTEST_STATIC=FALSE \ 730 | -DCMAKE_PREFIX_PATH="${{ steps.sdk.outputs.prefix }};${{ steps.deps-extract.outputs.sdl3-prefix }}" \ 731 | -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake \ 732 | -DANDROID_ABI=${android_abi} \ 733 | -DCMAKE_BUILD_TYPE=Release \ 734 | -B "${android_abi}" 735 | echo "Building ${android_abi}..." 736 | cmake --build "${android_abi}" --config Release --verbose 737 | done 738 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | buildbot/ 3 | /VERSION.txt 4 | 5 | *.so 6 | *.so.* 7 | *.dylib 8 | *.dll 9 | *.exe 10 | *.o 11 | *.obj 12 | *.res 13 | *.lib 14 | *.a 15 | *.la 16 | *.dSYM 17 | *,e1f 18 | *,ff8 19 | *.lnk 20 | *.err 21 | *.exp 22 | *.map 23 | *.orig 24 | *~ 25 | *.swp 26 | *.tmp 27 | *.rej 28 | 29 | sdl3-net.pc 30 | get-local-addrs 31 | resolve-hostnames 32 | simple-http-get 33 | voipchat 34 | 35 | # for CMake 36 | CMakeFiles/ 37 | CMakeScripts/ 38 | CMakeCache.txt 39 | cmake_install.cmake 40 | cmake_uninstall.cmake 41 | SDL3_netConfig.cmake 42 | SDL3_netConfigVersion.cmake 43 | compile_commands.json 44 | Makefile 45 | .ninja_* 46 | *.ninja 47 | SDL3_net.xcodeproj 48 | Debug/ 49 | Release/ 50 | RelWithDebInfo/ 51 | MinSizeRel/ 52 | dummy.sym 53 | 54 | # for CLion 55 | .idea 56 | cmake-build-* 57 | 58 | # for Visual C++ 59 | .vs 60 | CMakeSettings.json 61 | out/ 62 | /*.sln 63 | /*.vcxproj* 64 | *.dir 65 | *.user 66 | *.ncb 67 | *.suo 68 | *.sdf 69 | -------------------------------------------------------------------------------- /.wikiheaders-options: -------------------------------------------------------------------------------- 1 | projectfullname = SDL_net 2 | projectshortname = SDL_net 3 | incsubdir = include/SDL3_net 4 | wikisubdir = SDL3_net 5 | apiprefixregex = NET_ 6 | mainincludefname = SDL3_net/SDL_net.h 7 | versionfname = include/SDL3_net/SDL_net.h 8 | versionmajorregex = \A\#define\s+SDL_NET_MAJOR_VERSION\s+(\d+)\Z 9 | versionminorregex = \A\#define\s+SDL_NET_MINOR_VERSION\s+(\d+)\Z 10 | versionmicroregex = \A\#define\s+SDL_NET_MICRO_VERSION\s+(\d+)\Z 11 | selectheaderregex = \ASDL_net\.h\Z 12 | projecturl = https://libsdl.org/projects/SDL_net 13 | wikiurl = https://wiki.libsdl.org/SDL_net 14 | bugreporturl = https://github.com/libsdl-org/sdlwiki/issues/new 15 | warn_about_missing = 0 16 | wikipreamble = (This function is part of SDL_net, a separate library from SDL.) 17 | wikiheaderfiletext = Defined in [](https://github.com/libsdl-org/SDL_net/blob/main/include/SDL3_net/%fname%) 18 | manpageheaderfiletext = Defined in SDL3_net/%fname% 19 | quickrefenabled = 1 20 | quickreftitle = SDL3_net API Quick Reference 21 | quickrefurl = https://libsdl.org/ 22 | quickrefdesc = The latest version of this document can be found at https://wiki.libsdl.org/SDL3_net/QuickReference 23 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16...4.0) 2 | 3 | if(NOT DEFINED CMAKE_BUILD_TYPE) 4 | set(cmake_build_type_undefined 1) 5 | endif() 6 | 7 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") 8 | 9 | # See docs/release_checklist.md 10 | set(MAJOR_VERSION 3) 11 | set(MINOR_VERSION 0) 12 | set(MICRO_VERSION 0) 13 | set(SDL_REQUIRED_VERSION 3.0.0) 14 | 15 | project(SDL3_net 16 | LANGUAGES C 17 | VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}" 18 | ) 19 | 20 | include("${SDL3_net_SOURCE_DIR}/cmake/GetGitRevisionDescription.cmake") 21 | include("${SDL3_net_SOURCE_DIR}/cmake/PrivateSdlFunctions.cmake") 22 | include("${SDL3_net_SOURCE_DIR}/cmake/sdlmanpages.cmake") 23 | sdl_calculate_derived_version_variables(${MAJOR_VERSION} ${MINOR_VERSION} ${MICRO_VERSION}) 24 | 25 | message(STATUS "Configuring ${PROJECT_NAME} ${PROJECT_VERSION}") 26 | 27 | if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) 28 | set(SDLNET_ROOTPROJECT ON) 29 | else() 30 | set(SDLNET_ROOTPROJECT OFF) 31 | endif() 32 | 33 | # By default, configure in RelWithDebInfo configuration 34 | if(SDLNET_ROOTPROJECT) 35 | get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) 36 | if(is_multi_config) 37 | # The first item in CMAKE_CONFIGURATION_TYPES is the default configuration 38 | if(DEFINED CMAKE_CONFIGURATION_TYPES AND "RelWithDebInfo" IN_LIST CMAKE_CONFIGURATION_TYPES) 39 | list(REMOVE_ITEM CMAKE_CONFIGURATION_TYPES "RelWithDebInfo") 40 | list(INSERT CMAKE_CONFIGURATION_TYPES 0 "RelWithDebInfo") 41 | set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "CMake configuration types" FORCE) 42 | endif() 43 | else() 44 | if(cmake_build_type_undefined) 45 | set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "CMake build type" FORCE) 46 | endif() 47 | endif() 48 | endif() 49 | 50 | set(SDLNET_SAMPLES_DEFAULT ${SDLNET_ROOTPROJECT}) 51 | if(ANDROID) 52 | set(SDLNET_SAMPLES_DEFAULT OFF) 53 | endif() 54 | 55 | set(sdl3net_install_enableable ON) 56 | if((TARGET SDL3-shared OR TARGET SDL3-static) AND SDL_DISABLE_INSTALL) 57 | # Cannot install SDL3_net when SDL3 is built in same built, and is not installed. 58 | set(sdl3net_install_enableable OFF) 59 | endif() 60 | 61 | if(NOT DEFINED CMAKE_FIND_PACKAGE_PREFER_CONFIG) 62 | set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON) 63 | endif() 64 | 65 | include(CMakeDependentOption) 66 | include(CMakePackageConfigHelpers) 67 | include(GNUInstallDirs) 68 | 69 | set(PLATFORM_SUPPORTS_SHARED ON) 70 | if(EMSCRIPTEN OR VITA OR PSP OR PS2 OR N3DS OR RISCOS) 71 | set(PLATFORM_SUPPORTS_SHARED OFF) 72 | endif() 73 | 74 | option(CMAKE_POSITION_INDEPENDENT_CODE "Build static libraries with -fPIC" ${PLATFORM_SUPPORTS_SHARED}) 75 | cmake_dependent_option(BUILD_SHARED_LIBS "Build the library as a shared library" ON PLATFORM_SUPPORTS_SHARED OFF) 76 | 77 | cmake_dependent_option(SDLNET_INSTALL "Enable SDL3_net install target" ${SDLNET_ROOTPROJECT} "${sdl3net_install_enableable}" OFF) 78 | cmake_dependent_option(SDLNET_INSTALL_MAN "Install man pages for SDL3_net" OFF "SDLNET_INSTALL" OFF) 79 | cmake_dependent_option(SDLNET_RELOCATABLE "Create relocatable SDL_net package" "${MSVC}" SDLNET_INSTALL OFF) 80 | option(SDLNET_WERROR "Treat warnings as errors" OFF) 81 | 82 | option(SDLNET_SAMPLES "Build the SDL3_net sample program(s)" ${SDLNET_SAMPLES_DEFAULT}) 83 | cmake_dependent_option(SDLNET_SAMPLES_INSTALL "Install the SDL3_net sample program(s)" OFF "SDLNET_SAMPLES;SDLNET_INSTALL" OFF) 84 | 85 | # Save BUILD_SHARED_LIBS variable 86 | set(SDLNET_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}) 87 | 88 | set(sdl_required_components Headers) 89 | 90 | if(SDLNET_BUILD_SHARED_LIBS) 91 | set(sdl3_net_target_name SDL3_net-shared) 92 | set(sdl3_target_name SDL3::SDL3-shared) 93 | 94 | list(APPEND sdl_required_components SDL3-shared) 95 | else() 96 | set(sdl3_net_target_name SDL3_net-static) 97 | set(sdl3_target_name SDL3::SDL3) 98 | endif() 99 | 100 | if(NOT TARGET SDL3::Headers OR NOT TARGET ${sdl3_target_name}) 101 | find_package(SDL3 ${SDL_REQUIRED_VERSION} REQUIRED COMPONENTS ${sdl_required_components}) 102 | endif() 103 | 104 | set(PC_LIBS) 105 | set(PC_REQUIRES) 106 | 107 | add_library(${sdl3_net_target_name} src/SDL_net.c) 108 | add_library(SDL3_net::${sdl3_net_target_name} ALIAS ${sdl3_net_target_name}) 109 | set_property(TARGET ${sdl3_net_target_name} PROPERTY C_STANDARD 99) 110 | if(NOT TARGET SDL3_net::SDL3_net) 111 | add_library(SDL3_net::SDL3_net ALIAS ${sdl3_net_target_name}) 112 | endif() 113 | target_include_directories(${sdl3_net_target_name} 114 | PUBLIC 115 | "$" 116 | "$" 117 | ) 118 | target_compile_definitions(${sdl3_net_target_name} PRIVATE 119 | BUILD_SDL 120 | SDL_BUILD_MAJOR_VERSION=${MAJOR_VERSION} 121 | SDL_BUILD_MINOR_VERSION=${MINOR_VERSION} 122 | SDL_BUILD_MICRO_VERSION=${MICRO_VERSION} 123 | ) 124 | target_link_libraries(${sdl3_net_target_name} PUBLIC SDL3::Headers) 125 | if(SDLNET_BUILD_SHARED_LIBS) 126 | target_link_libraries(${sdl3_net_target_name} PRIVATE SDL3::SDL3-shared) 127 | endif() 128 | sdl_add_warning_options(${sdl3_net_target_name} WARNING_AS_ERROR ${SDLNET_WERROR}) 129 | if(WIN32) 130 | if(SDLNET_BUILD_SHARED_LIBS) 131 | target_sources(${sdl3_net_target_name} PRIVATE 132 | src/version.rc 133 | ) 134 | if(MINGW) 135 | target_link_options(${sdl3_net_target_name} PRIVATE -static-libgcc) 136 | endif() 137 | endif() 138 | target_link_libraries(${sdl3_net_target_name} PRIVATE iphlpapi ws2_32) 139 | list(APPEND PC_LIBS -liphlpapi -lws2_32) 140 | endif() 141 | if(CMAKE_SYSTEM_NAME MATCHES "Haiku.*") 142 | target_link_libraries(${sdl3_net_target_name} PRIVATE network) 143 | endif() 144 | set_target_properties(${sdl3_net_target_name} PROPERTIES 145 | OUTPUT_NAME "SDL3_net" 146 | DEFINE_SYMBOL DLL_EXPORT 147 | EXPORT_NAME ${sdl3_net_target_name} 148 | C_VISIBILITY_PRESET "hidden" 149 | ) 150 | 151 | sdl_target_link_option_version_file(${sdl3_net_target_name} "${CMAKE_CURRENT_SOURCE_DIR}/src/SDL_net.sym") 152 | 153 | if(NOT ANDROID) 154 | set_target_properties(${sdl3_net_target_name} PROPERTIES 155 | SOVERSION "${SO_VERSION_MAJOR}" 156 | VERSION "${SO_VERSION}" 157 | ) 158 | if(APPLE) 159 | cmake_minimum_required(VERSION 3.17...3.28) 160 | set_target_properties(${sdl3_net_target_name} PROPERTIES 161 | MACHO_COMPATIBILITY_VERSION "${DYLIB_COMPAT_VERSION}" 162 | MACHO_CURRENT_VERSION "${DYLIB_CURRENT_VERSION}" 163 | ) 164 | sdl_no_deprecated_errors(${sdl3_net_target_name}) 165 | endif() 166 | endif() 167 | if(SDLNET_BUILD_SHARED_LIBS) 168 | if(WIN32) 169 | set_target_properties(${sdl3_net_target_name} PROPERTIES 170 | PREFIX "" 171 | ) 172 | endif() 173 | else() 174 | if(MSVC) 175 | set_target_properties(${sdl3_net_target_name} PROPERTIES 176 | OUTPUT_NAME "SDL3_net-static" 177 | ) 178 | endif() 179 | endif() 180 | 181 | # Use `Compatible Interface Properties` to ensure a shared SDL3_net is built with a shared SDL3 182 | if(SDLNET_BUILD_SHARED_LIBS) 183 | set_property(TARGET ${sdl3_net_target_name} PROPERTY INTERFACE_SDL3_SHARED TRUE) 184 | set_property(TARGET ${sdl3_net_target_name} APPEND PROPERTY COMPATIBLE_INTERFACE_BOOL SDL3_SHARED) 185 | endif() 186 | 187 | if(SDLNET_BUILD_SHARED_LIBS) 188 | sdl_target_link_options_no_undefined(${sdl3_net_target_name}) 189 | endif() 190 | 191 | if(SDLNET_INSTALL) 192 | install( 193 | TARGETS ${sdl3_net_target_name} 194 | EXPORT SDL3NetExports 195 | ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT devel 196 | LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT library 197 | RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT library 198 | ) 199 | install( 200 | FILES "${CMAKE_CURRENT_SOURCE_DIR}/include/SDL3_net/SDL_net.h" 201 | DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/SDL3_net" COMPONENT devel 202 | ) 203 | 204 | if(WIN32 AND NOT MINGW) 205 | set(SDLNET_INSTALL_CMAKEDIR_ROOT_DEFAULT "cmake") 206 | else() 207 | set(SDLNET_INSTALL_CMAKEDIR_ROOT_DEFAULT "${CMAKE_INSTALL_LIBDIR}/cmake") 208 | endif() 209 | set(SDLNET_INSTALL_CMAKEDIR_ROOT "${SDLNET_INSTALL_CMAKEDIR_ROOT_DEFAULT}" CACHE STRING "Root folder where to install SDL3_netConfig.cmake related files (SDL3_net subfolder for MSVC projects)") 210 | set(SDLNET_PKGCONFIG_INSTALLDIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig") 211 | 212 | if(WIN32 AND NOT MINGW) 213 | set(SDLNET_INSTALL_CMAKEDIR "${SDLNET_INSTALL_CMAKEDIR_ROOT}") 214 | set(LICENSES_PREFIX "licenses/SDL3_net") 215 | else() 216 | set(SDLNET_INSTALL_CMAKEDIR "${SDLNET_INSTALL_CMAKEDIR_ROOT}/SDL3_net") 217 | set(LICENSES_PREFIX "${CMAKE_INSTALL_DATAROOTDIR}/licenses/SDL3_net") 218 | endif() 219 | 220 | configure_package_config_file(cmake/SDL3_netConfig.cmake.in SDL3_netConfig.cmake 221 | INSTALL_DESTINATION "${SDLNET_INSTALL_CMAKEDIR}" 222 | ) 223 | write_basic_package_version_file("${PROJECT_BINARY_DIR}/SDL3_netConfigVersion.cmake" 224 | COMPATIBILITY AnyNewerVersion 225 | ) 226 | install( 227 | FILES 228 | "${CMAKE_CURRENT_BINARY_DIR}/SDL3_netConfig.cmake" 229 | "${CMAKE_CURRENT_BINARY_DIR}/SDL3_netConfigVersion.cmake" 230 | DESTINATION "${SDLNET_INSTALL_CMAKEDIR}" 231 | COMPONENT devel 232 | ) 233 | install(EXPORT SDL3NetExports 234 | FILE ${sdl3_net_target_name}-targets.cmake 235 | NAMESPACE SDL3_net:: 236 | DESTINATION "${SDLNET_INSTALL_CMAKEDIR}" 237 | COMPONENT devel 238 | ) 239 | 240 | if(SDLNET_RELOCATABLE) 241 | file(RELATIVE_PATH SDL_PATH_PREFIX_RELATIVE_TO_PKGCONFIG "${CMAKE_INSTALL_PREFIX}/${SDLNET_PKGCONFIG_INSTALLDIR}" "${CMAKE_INSTALL_PREFIX}") 242 | string(REGEX REPLACE "[/]+$" "" SDL_PATH_PREFIX_RELATIVE_TO_PKGCONFIG "${SDL_PATH_PREFIX_RELATIVE_TO_PKGCONFIG}") 243 | set(SDL_PKGCONFIG_PREFIX "\${pcfiledir}/${SDL_PATH_PREFIX_RELATIVE_TO_PKGCONFIG}") 244 | else() 245 | set(SDL_PKGCONFIG_PREFIX "${CMAKE_PREFIX_PATH}") 246 | endif() 247 | 248 | if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}") 249 | set(INCLUDEDIR_FOR_PKG_CONFIG "${CMAKE_INSTALL_INCLUDEDIR}") 250 | else() 251 | set(INCLUDEDIR_FOR_PKG_CONFIG "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}") 252 | endif() 253 | if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}") 254 | set(LIBDIR_FOR_PKG_CONFIG "${CMAKE_INSTALL_LIBDIR}") 255 | else() 256 | set(LIBDIR_FOR_PKG_CONFIG "\${prefix}/${CMAKE_INSTALL_LIBDIR}") 257 | endif() 258 | 259 | string(JOIN " " PC_REQUIRES ${PC_REQUIRES}) 260 | string(JOIN " " PC_LIBS ${PC_LIBS}) 261 | configure_file(cmake/sdl3-net.pc.in sdl3-net.pc @ONLY) 262 | 263 | # Always install sdl3-net.pc file: libraries might be different between config modes 264 | install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sdl3-net.pc" 265 | DESTINATION "${SDLNET_PKGCONFIG_INSTALLDIR}" COMPONENT devel) 266 | if(BUILD_SHARED_LIBS) 267 | set(pdbdir "${CMAKE_INSTALL_BINDIR}") 268 | else() 269 | set(pdbdir "${CMAKE_INSTALL_LIBDIR}") 270 | endif() 271 | if(MSVC) 272 | SDL_install_pdb("${sdl3_net_target_name}" "${pdbdir}") 273 | endif() 274 | 275 | install(FILES "LICENSE.txt" 276 | DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/licenses/${PROJECT_NAME}" 277 | COMPONENT library 278 | ) 279 | 280 | if(SDLNET_INSTALL_MAN) 281 | sdl_get_git_revision_hash(SDLNET_REVISION) 282 | SDL_generate_manpages( 283 | HEADERS_DIR "${PROJECT_SOURCE_DIR}/include/SDL3_net" 284 | SYMBOL "NET_Init" 285 | WIKIHEADERS_PL_PATH "${CMAKE_CURRENT_SOURCE_DIR}/build-scripts/wikiheaders.pl" 286 | REVISION "${SDLNET_REVISION}" 287 | ) 288 | endif() 289 | endif() 290 | 291 | if(SDLNET_SAMPLES) 292 | function(add_sdl_net_example_executable TARGET) 293 | if(ANDROID) 294 | add_library(${TARGET} SHARED ${ARGN}) 295 | else() 296 | add_executable(${TARGET} ${ARGN}) 297 | endif() 298 | sdl_add_warning_options(${TARGET} WARNING_AS_ERROR ${SDLTTF_WERROR}) 299 | sdl_target_link_options_no_undefined(${TARGET}) 300 | target_link_libraries(${TARGET} PRIVATE SDL3_net::${sdl3_net_target_name}) 301 | target_link_libraries(${TARGET} PRIVATE ${sdl3_target_name}) 302 | set_property(TARGET ${TARGET} PROPERTY C_STANDARD 99) 303 | set_property(TARGET ${TARGET} PROPERTY C_EXTENSIONS FALSE) 304 | 305 | if(SDLNET_SAMPLES_INSTALL) 306 | install(TARGETS ${TARGET} 307 | RUNTIME DESTINATION "${CMAKE_INSTALL_LIBEXECDIR}/installed-tests/SDL3_net" 308 | ) 309 | endif() 310 | endfunction() 311 | add_sdl_net_example_executable(voipchat examples/voipchat.c) 312 | add_sdl_net_example_executable(simple-http-get examples/simple-http-get.c) 313 | add_sdl_net_example_executable(resolve-hostnames examples/resolve-hostnames.c) 314 | add_sdl_net_example_executable(get-local-addrs examples/get-local-addrs.c) 315 | 316 | # Build at least one example in C90 317 | set_property(TARGET get-local-addrs PROPERTY C_STANDARD 90) 318 | endif() 319 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (C) 1997-2025 Sam Lantinga 2 | 3 | This software is provided 'as-is', without any express or implied 4 | warranty. In no event will the authors be held liable for any damages 5 | arising from the use of this software. 6 | 7 | Permission is granted to anyone to use this software for any purpose, 8 | including commercial applications, and to alter it and redistribute it 9 | freely, subject to the following restrictions: 10 | 11 | 1. The origin of this software must not be misrepresented; you must not 12 | claim that you wrote the original software. If you use this software 13 | in a product, an acknowledgment in the product documentation would be 14 | appreciated but is not required. 15 | 2. Altered source versions must be plainly marked as such, and must not be 16 | misrepresented as being the original software. 17 | 3. This notice may not be removed or altered from any source distribution. 18 | 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SDL_net 3.0 2 | 3 | The latest version of this library is available from GitHub: 4 | 5 | https://github.com/libsdl-org/SDL_net/releases 6 | 7 | This is a portable network library for use with SDL. It's goal is to 8 | simplify the use of the usual socket interfaces and use SDL infrastructure 9 | to handle some portability things (such as threading and reporting 10 | errors). 11 | 12 | It is available under the zlib license, found in the file LICENSE.txt. 13 | The API can be found in the file SDL_net.h and online at https://wiki.libsdl.org/SDL3_net 14 | This library supports most platforms that offer both SDL3 and networking. 15 | 16 | This is a work in progress! 17 | 18 | Enjoy! 19 | 20 | -------------------------------------------------------------------------------- /VisualC/SDL_net.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL3_net", "SDL_net.vcxproj", "{8AB3504F-5E58-4910-AFE8-7A1E595AC3F4}" 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "get-local-addrs", "examples\get-local-addrs.vcxproj", "{7B1F60CD-2A09-4514-937C-D9DD044428FB}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "resolve-hostnames", "examples\resolve-hostnames.vcxproj", "{8DAC2820-128D-4FAF-9416-A8AD4C6D7A9A}" 9 | EndProject 10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "simple-http-get", "examples\simple-http-get.vcxproj", "{35F14669-ED09-4105-A035-7984B94FDFBC}" 11 | EndProject 12 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "voipchat", "examples\voipchat.vcxproj", "{A01E2216-139A-480E-8458-03CB4E90FE61}" 13 | EndProject 14 | Global 15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 16 | Debug|Win32 = Debug|Win32 17 | Debug|x64 = Debug|x64 18 | Release|Win32 = Release|Win32 19 | Release|x64 = Release|x64 20 | EndGlobalSection 21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 22 | {8AB3504F-5E58-4910-AFE8-7A1E595AC3F4}.Debug|Win32.ActiveCfg = Debug|Win32 23 | {8AB3504F-5E58-4910-AFE8-7A1E595AC3F4}.Debug|Win32.Build.0 = Debug|Win32 24 | {8AB3504F-5E58-4910-AFE8-7A1E595AC3F4}.Debug|x64.ActiveCfg = Debug|x64 25 | {8AB3504F-5E58-4910-AFE8-7A1E595AC3F4}.Debug|x64.Build.0 = Debug|x64 26 | {8AB3504F-5E58-4910-AFE8-7A1E595AC3F4}.Release|Win32.ActiveCfg = Release|Win32 27 | {8AB3504F-5E58-4910-AFE8-7A1E595AC3F4}.Release|Win32.Build.0 = Release|Win32 28 | {8AB3504F-5E58-4910-AFE8-7A1E595AC3F4}.Release|x64.ActiveCfg = Release|x64 29 | {8AB3504F-5E58-4910-AFE8-7A1E595AC3F4}.Release|x64.Build.0 = Release|x64 30 | {7B1F60CD-2A09-4514-937C-D9DD044428FB}.Debug|Win32.ActiveCfg = Debug|Win32 31 | {7B1F60CD-2A09-4514-937C-D9DD044428FB}.Debug|Win32.Build.0 = Debug|Win32 32 | {7B1F60CD-2A09-4514-937C-D9DD044428FB}.Debug|x64.ActiveCfg = Debug|x64 33 | {7B1F60CD-2A09-4514-937C-D9DD044428FB}.Debug|x64.Build.0 = Debug|x64 34 | {7B1F60CD-2A09-4514-937C-D9DD044428FB}.Release|Win32.ActiveCfg = Release|Win32 35 | {7B1F60CD-2A09-4514-937C-D9DD044428FB}.Release|Win32.Build.0 = Release|Win32 36 | {7B1F60CD-2A09-4514-937C-D9DD044428FB}.Release|x64.ActiveCfg = Release|x64 37 | {7B1F60CD-2A09-4514-937C-D9DD044428FB}.Release|x64.Build.0 = Release|x64 38 | {8DAC2820-128D-4FAF-9416-A8AD4C6D7A9A}.Debug|Win32.ActiveCfg = Debug|Win32 39 | {8DAC2820-128D-4FAF-9416-A8AD4C6D7A9A}.Debug|Win32.Build.0 = Debug|Win32 40 | {8DAC2820-128D-4FAF-9416-A8AD4C6D7A9A}.Debug|x64.ActiveCfg = Debug|x64 41 | {8DAC2820-128D-4FAF-9416-A8AD4C6D7A9A}.Debug|x64.Build.0 = Debug|x64 42 | {8DAC2820-128D-4FAF-9416-A8AD4C6D7A9A}.Release|Win32.ActiveCfg = Release|Win32 43 | {8DAC2820-128D-4FAF-9416-A8AD4C6D7A9A}.Release|Win32.Build.0 = Release|Win32 44 | {8DAC2820-128D-4FAF-9416-A8AD4C6D7A9A}.Release|x64.ActiveCfg = Release|x64 45 | {8DAC2820-128D-4FAF-9416-A8AD4C6D7A9A}.Release|x64.Build.0 = Release|x64 46 | {35F14669-ED09-4105-A035-7984B94FDFBC}.Debug|Win32.ActiveCfg = Debug|Win32 47 | {35F14669-ED09-4105-A035-7984B94FDFBC}.Debug|Win32.Build.0 = Debug|Win32 48 | {35F14669-ED09-4105-A035-7984B94FDFBC}.Debug|x64.ActiveCfg = Debug|x64 49 | {35F14669-ED09-4105-A035-7984B94FDFBC}.Debug|x64.Build.0 = Debug|x64 50 | {35F14669-ED09-4105-A035-7984B94FDFBC}.Release|Win32.ActiveCfg = Release|Win32 51 | {35F14669-ED09-4105-A035-7984B94FDFBC}.Release|Win32.Build.0 = Release|Win32 52 | {35F14669-ED09-4105-A035-7984B94FDFBC}.Release|x64.ActiveCfg = Release|x64 53 | {35F14669-ED09-4105-A035-7984B94FDFBC}.Release|x64.Build.0 = Release|x64 54 | {A01E2216-139A-480E-8458-03CB4E90FE61}.Debug|Win32.ActiveCfg = Debug|Win32 55 | {A01E2216-139A-480E-8458-03CB4E90FE61}.Debug|Win32.Build.0 = Debug|Win32 56 | {A01E2216-139A-480E-8458-03CB4E90FE61}.Debug|x64.ActiveCfg = Debug|x64 57 | {A01E2216-139A-480E-8458-03CB4E90FE61}.Debug|x64.Build.0 = Debug|x64 58 | {A01E2216-139A-480E-8458-03CB4E90FE61}.Release|Win32.ActiveCfg = Release|Win32 59 | {A01E2216-139A-480E-8458-03CB4E90FE61}.Release|Win32.Build.0 = Release|Win32 60 | {A01E2216-139A-480E-8458-03CB4E90FE61}.Release|x64.ActiveCfg = Release|x64 61 | {A01E2216-139A-480E-8458-03CB4E90FE61}.Release|x64.Build.0 = Release|x64 62 | EndGlobalSection 63 | GlobalSection(SolutionProperties) = preSolution 64 | HideSolutionNode = FALSE 65 | EndGlobalSection 66 | EndGlobal 67 | -------------------------------------------------------------------------------- /VisualC/SDL_net.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | SDL3_net 23 | {8AB3504F-5E58-4910-AFE8-7A1E595AC3F4} 24 | SDL_net 25 | 26 | 27 | 28 | DynamicLibrary 29 | $(DefaultPlatformToolset) 30 | 31 | 32 | DynamicLibrary 33 | $(DefaultPlatformToolset) 34 | 35 | 36 | DynamicLibrary 37 | $(DefaultPlatformToolset) 38 | 39 | 40 | DynamicLibrary 41 | $(DefaultPlatformToolset) 42 | 43 | 44 | 45 | 46 | 47 | 48 | <_ProjectFileVersion>10.0.40219.1 49 | $(SolutionDir)\$(Platform)\$(Configuration)\ 50 | $(Platform)\$(Configuration)\ 51 | $(SolutionDir)\$(Platform)\$(Configuration)\ 52 | $(Platform)\$(Configuration)\ 53 | $(SolutionDir)\$(Platform)\$(Configuration)\ 54 | $(Platform)\$(Configuration)\ 55 | $(SolutionDir)\$(Platform)\$(Configuration)\ 56 | $(Platform)\$(Configuration)\ 57 | AllRules.ruleset 58 | 59 | 60 | AllRules.ruleset 61 | 62 | 63 | AllRules.ruleset 64 | 65 | 66 | AllRules.ruleset 67 | 68 | 69 | 70 | 71 | $(ProjectDir)..\..\SDL\include;$(ProjectDir)..\include;$(IncludePath) 72 | $(ProjectDir)..\..\SDL\VisualC\$(PlatformName)\$(Configuration);$(LibraryPath) 73 | 74 | 75 | $(ProjectDir)..\..\SDL\include;$(ProjectDir)..\include;$(IncludePath) 76 | $(ProjectDir)..\..\SDL\VisualC\$(PlatformName)\$(Configuration);$(LibraryPath) 77 | 78 | 79 | $(ProjectDir)..\..\SDL\include;$(ProjectDir)..\include;$(IncludePath) 80 | $(ProjectDir)..\..\SDL\VisualC\$(PlatformName)\$(Configuration);$(LibraryPath) 81 | 82 | 83 | $(ProjectDir)..\..\SDL\include;$(ProjectDir)..\include;$(IncludePath) 84 | $(ProjectDir)..\..\SDL\VisualC\$(PlatformName)\$(Configuration);$(LibraryPath) 85 | 86 | 87 | 88 | _DEBUG;%(PreprocessorDefinitions) 89 | true 90 | true 91 | Win32 92 | .\Debug/SDL3_net.tlb 93 | 94 | 95 | 96 | 97 | Disabled 98 | DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) 99 | MultiThreadedDebug 100 | Level3 101 | OldStyle 102 | StreamingSIMDExtensions 103 | 104 | 105 | _DEBUG;%(PreprocessorDefinitions) 106 | 107 | 108 | Windows 109 | ws2_32.lib;iphlpapi.lib;SDL3.lib;%(AdditionalDependencies) 110 | true 111 | 112 | 113 | 114 | 115 | _DEBUG;%(PreprocessorDefinitions) 116 | true 117 | true 118 | X64 119 | .\Debug/SDL3_net.tlb 120 | 121 | 122 | 123 | 124 | Disabled 125 | DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) 126 | MultiThreadedDebug 127 | Level3 128 | OldStyle 129 | StreamingSIMDExtensions 130 | 131 | 132 | _DEBUG;%(PreprocessorDefinitions) 133 | 134 | 135 | Windows 136 | ws2_32.lib;iphlpapi.lib;SDL3.lib;%(AdditionalDependencies) 137 | true 138 | 139 | 140 | 141 | 142 | NDEBUG;%(PreprocessorDefinitions) 143 | true 144 | true 145 | Win32 146 | .\Release/SDL3_net.tlb 147 | 148 | 149 | 150 | 151 | DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) 152 | MultiThreaded 153 | Level3 154 | StreamingSIMDExtensions 155 | 156 | 157 | NDEBUG;%(PreprocessorDefinitions) 158 | 159 | 160 | Windows 161 | ws2_32.lib;iphlpapi.lib;SDL3.lib;%(AdditionalDependencies) 162 | true 163 | true 164 | 165 | 166 | 167 | 168 | 169 | NDEBUG;%(PreprocessorDefinitions) 170 | true 171 | true 172 | X64 173 | .\Release/SDL3_net.tlb 174 | 175 | 176 | 177 | 178 | DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) 179 | MultiThreaded 180 | Level3 181 | StreamingSIMDExtensions 182 | 183 | 184 | NDEBUG;%(PreprocessorDefinitions) 185 | 186 | 187 | Windows 188 | ws2_32.lib;iphlpapi.lib;SDL3.lib;%(AdditionalDependencies) 189 | true 190 | true 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | %(PreprocessorDefinitions) 202 | %(PreprocessorDefinitions) 203 | %(PreprocessorDefinitions) 204 | %(PreprocessorDefinitions) 205 | 206 | 207 | 208 | 209 | 210 | 211 | -------------------------------------------------------------------------------- /VisualC/SDL_net.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {2cc01156-0219-4532-b5cc-4deb572c8d16} 6 | 7 | 8 | {64a63be2-c42b-4b99-a06a-61d4cc4efa21} 9 | 10 | 11 | 12 | 13 | Sources 14 | 15 | 16 | 17 | 18 | Public Headers 19 | 20 | 21 | 22 | 23 | Sources 24 | 25 | 26 | -------------------------------------------------------------------------------- /VisualC/clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | find . -type f \( -name '*.user' -o -name '*.sdf' -o -name '*.ncb' -o -name '*.suo' \) -print -delete 3 | rm -rvf Win32 */Win32 x64 */x64 4 | -------------------------------------------------------------------------------- /VisualC/examples/get-local-addrs.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {7B1F60CD-2A09-4514-937C-D9DD044428FB} 23 | get-local-addrs 24 | 25 | 26 | 27 | Application 28 | $(DefaultPlatformToolset) 29 | 30 | 31 | Application 32 | $(DefaultPlatformToolset) 33 | 34 | 35 | Application 36 | $(DefaultPlatformToolset) 37 | 38 | 39 | Application 40 | $(DefaultPlatformToolset) 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | <_ProjectFileVersion>10.0.40219.1 64 | $(SolutionDir)\$(Platform)\$(Configuration)\ 65 | $(Platform)\$(Configuration)\ 66 | $(SolutionDir)\$(Platform)\$(Configuration)\ 67 | $(Platform)\$(Configuration)\ 68 | $(SolutionDir)\$(Platform)\$(Configuration)\ 69 | $(Platform)\$(Configuration)\ 70 | $(SolutionDir)\$(Platform)\$(Configuration)\ 71 | $(Platform)\$(Configuration)\ 72 | AllRules.ruleset 73 | 74 | 75 | AllRules.ruleset 76 | 77 | 78 | AllRules.ruleset 79 | 80 | 81 | AllRules.ruleset 82 | 83 | 84 | 85 | 86 | $(SolutionDir)..\..\SDL\include;$(SolutionDir)..\include;$(IncludePath) 87 | $(SolutionDir)..\..\SDL\VisualC\$(PlatformName)\$(Configuration);$(LibraryPath) 88 | 89 | 90 | $(SolutionDir)..\..\SDL\include;$(SolutionDir)..\include;$(IncludePath) 91 | $(SolutionDir)..\..\SDL\VisualC\$(PlatformName)\$(Configuration);$(LibraryPath) 92 | 93 | 94 | $(SolutionDir)..\..\SDL\include;$(SolutionDir)..\include;$(IncludePath) 95 | $(SolutionDir)..\..\SDL\VisualC\$(PlatformName)\$(Configuration);$(LibraryPath) 96 | 97 | 98 | $(SolutionDir)..\..\SDL\include;$(SolutionDir)..\include;$(IncludePath) 99 | $(SolutionDir)..\..\SDL\VisualC\$(PlatformName)\$(Configuration);$(LibraryPath) 100 | 101 | 102 | 103 | NDEBUG;%(PreprocessorDefinitions) 104 | true 105 | true 106 | Win32 107 | .\Release/showinterfaces.tlb 108 | 109 | 110 | 111 | 112 | WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) 113 | MultiThreadedDLL 114 | Level3 115 | 116 | 117 | NDEBUG;%(PreprocessorDefinitions) 118 | 0x0409 119 | 120 | 121 | SDL3.lib;%(AdditionalDependencies) 122 | Console 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | NDEBUG;%(PreprocessorDefinitions) 134 | true 135 | true 136 | X64 137 | .\Release/showinterfaces.tlb 138 | 139 | 140 | 141 | 142 | WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) 143 | MultiThreadedDLL 144 | Level3 145 | 146 | 147 | NDEBUG;%(PreprocessorDefinitions) 148 | 0x0409 149 | 150 | 151 | SDL3.lib;%(AdditionalDependencies) 152 | Console 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | _DEBUG;%(PreprocessorDefinitions) 164 | true 165 | true 166 | Win32 167 | .\Debug/showinterfaces.tlb 168 | 169 | 170 | 171 | 172 | Disabled 173 | WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) 174 | MultiThreadedDebugDLL 175 | Level3 176 | OldStyle 177 | 178 | 179 | _DEBUG;%(PreprocessorDefinitions) 180 | 0x0409 181 | 182 | 183 | SDL3.lib;%(AdditionalDependencies) 184 | true 185 | Console 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | _DEBUG;%(PreprocessorDefinitions) 197 | true 198 | true 199 | X64 200 | .\Debug/showinterfaces.tlb 201 | 202 | 203 | 204 | 205 | Disabled 206 | WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) 207 | MultiThreadedDebugDLL 208 | Level3 209 | OldStyle 210 | 211 | 212 | _DEBUG;%(PreprocessorDefinitions) 213 | 0x0409 214 | 215 | 216 | SDL3.lib;%(AdditionalDependencies) 217 | true 218 | Console 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | {8ab3504f-5e58-4910-afe8-7a1e595ac3f4} 233 | 234 | 235 | 236 | 237 | 238 | -------------------------------------------------------------------------------- /VisualC/examples/resolve-hostnames.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {8DAC2820-128D-4FAF-9416-A8AD4C6D7A9A} 23 | resolve-hostnames 24 | 25 | 26 | 27 | Application 28 | $(DefaultPlatformToolset) 29 | 30 | 31 | Application 32 | $(DefaultPlatformToolset) 33 | 34 | 35 | Application 36 | $(DefaultPlatformToolset) 37 | 38 | 39 | Application 40 | $(DefaultPlatformToolset) 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | <_ProjectFileVersion>10.0.40219.1 64 | $(SolutionDir)\$(Platform)\$(Configuration)\ 65 | $(Platform)\$(Configuration)\ 66 | $(SolutionDir)\$(Platform)\$(Configuration)\ 67 | $(Platform)\$(Configuration)\ 68 | $(SolutionDir)\$(Platform)\$(Configuration)\ 69 | $(Platform)\$(Configuration)\ 70 | $(SolutionDir)\$(Platform)\$(Configuration)\ 71 | $(Platform)\$(Configuration)\ 72 | AllRules.ruleset 73 | 74 | 75 | AllRules.ruleset 76 | 77 | 78 | AllRules.ruleset 79 | 80 | 81 | AllRules.ruleset 82 | 83 | 84 | 85 | 86 | $(SolutionDir)..\..\SDL\include;$(SolutionDir)..\include;$(IncludePath) 87 | $(SolutionDir)..\..\SDL\VisualC\$(PlatformName)\$(Configuration);$(LibraryPath) 88 | 89 | 90 | $(SolutionDir)..\..\SDL\include;$(SolutionDir)..\include;$(IncludePath) 91 | $(SolutionDir)..\..\SDL\VisualC\$(PlatformName)\$(Configuration);$(LibraryPath) 92 | 93 | 94 | $(SolutionDir)..\..\SDL\include;$(SolutionDir)..\include;$(IncludePath) 95 | $(SolutionDir)..\..\SDL\VisualC\$(PlatformName)\$(Configuration);$(LibraryPath) 96 | 97 | 98 | $(SolutionDir)..\..\SDL\include;$(SolutionDir)..\include;$(IncludePath) 99 | $(SolutionDir)..\..\SDL\VisualC\$(PlatformName)\$(Configuration);$(LibraryPath) 100 | 101 | 102 | 103 | NDEBUG;%(PreprocessorDefinitions) 104 | true 105 | true 106 | Win32 107 | .\Release/showinterfaces.tlb 108 | 109 | 110 | 111 | 112 | WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) 113 | MultiThreadedDLL 114 | Level3 115 | 116 | 117 | NDEBUG;%(PreprocessorDefinitions) 118 | 0x0409 119 | 120 | 121 | SDL3.lib;%(AdditionalDependencies) 122 | Console 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | NDEBUG;%(PreprocessorDefinitions) 134 | true 135 | true 136 | X64 137 | .\Release/showinterfaces.tlb 138 | 139 | 140 | 141 | 142 | WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) 143 | MultiThreadedDLL 144 | Level3 145 | 146 | 147 | NDEBUG;%(PreprocessorDefinitions) 148 | 0x0409 149 | 150 | 151 | SDL3.lib;%(AdditionalDependencies) 152 | Console 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | _DEBUG;%(PreprocessorDefinitions) 164 | true 165 | true 166 | Win32 167 | .\Debug/showinterfaces.tlb 168 | 169 | 170 | 171 | 172 | Disabled 173 | WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) 174 | MultiThreadedDebugDLL 175 | Level3 176 | OldStyle 177 | 178 | 179 | _DEBUG;%(PreprocessorDefinitions) 180 | 0x0409 181 | 182 | 183 | SDL3.lib;%(AdditionalDependencies) 184 | true 185 | Console 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | _DEBUG;%(PreprocessorDefinitions) 197 | true 198 | true 199 | X64 200 | .\Debug/showinterfaces.tlb 201 | 202 | 203 | 204 | 205 | Disabled 206 | WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) 207 | MultiThreadedDebugDLL 208 | Level3 209 | OldStyle 210 | 211 | 212 | _DEBUG;%(PreprocessorDefinitions) 213 | 0x0409 214 | 215 | 216 | SDL3.lib;%(AdditionalDependencies) 217 | true 218 | Console 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | {8ab3504f-5e58-4910-afe8-7a1e595ac3f4} 233 | 234 | 235 | 236 | 237 | 238 | -------------------------------------------------------------------------------- /VisualC/examples/simple-http-get.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {35F14669-ED09-4105-A035-7984B94FDFBC} 23 | simple-http-get 24 | 25 | 26 | 27 | Application 28 | $(DefaultPlatformToolset) 29 | 30 | 31 | Application 32 | $(DefaultPlatformToolset) 33 | 34 | 35 | Application 36 | $(DefaultPlatformToolset) 37 | 38 | 39 | Application 40 | $(DefaultPlatformToolset) 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | <_ProjectFileVersion>10.0.40219.1 64 | $(SolutionDir)\$(Platform)\$(Configuration)\ 65 | $(Platform)\$(Configuration)\ 66 | $(SolutionDir)\$(Platform)\$(Configuration)\ 67 | $(Platform)\$(Configuration)\ 68 | $(SolutionDir)\$(Platform)\$(Configuration)\ 69 | $(Platform)\$(Configuration)\ 70 | $(SolutionDir)\$(Platform)\$(Configuration)\ 71 | $(Platform)\$(Configuration)\ 72 | AllRules.ruleset 73 | 74 | 75 | AllRules.ruleset 76 | 77 | 78 | AllRules.ruleset 79 | 80 | 81 | AllRules.ruleset 82 | 83 | 84 | 85 | 86 | $(SolutionDir)..\..\SDL\include;$(SolutionDir)..\include;$(IncludePath) 87 | $(SolutionDir)..\..\SDL\VisualC\$(PlatformName)\$(Configuration);$(LibraryPath) 88 | 89 | 90 | $(SolutionDir)..\..\SDL\include;$(SolutionDir)..\include;$(IncludePath) 91 | $(SolutionDir)..\..\SDL\VisualC\$(PlatformName)\$(Configuration);$(LibraryPath) 92 | 93 | 94 | $(SolutionDir)..\..\SDL\include;$(SolutionDir)..\include;$(IncludePath) 95 | $(SolutionDir)..\..\SDL\VisualC\$(PlatformName)\$(Configuration);$(LibraryPath) 96 | 97 | 98 | $(SolutionDir)..\..\SDL\include;$(SolutionDir)..\include;$(IncludePath) 99 | $(SolutionDir)..\..\SDL\VisualC\$(PlatformName)\$(Configuration);$(LibraryPath) 100 | 101 | 102 | 103 | NDEBUG;%(PreprocessorDefinitions) 104 | true 105 | true 106 | Win32 107 | .\Release/showinterfaces.tlb 108 | 109 | 110 | 111 | 112 | WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) 113 | MultiThreadedDLL 114 | Level3 115 | 116 | 117 | NDEBUG;%(PreprocessorDefinitions) 118 | 0x0409 119 | 120 | 121 | SDL3.lib;%(AdditionalDependencies) 122 | Console 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | NDEBUG;%(PreprocessorDefinitions) 134 | true 135 | true 136 | X64 137 | .\Release/showinterfaces.tlb 138 | 139 | 140 | 141 | 142 | WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) 143 | MultiThreadedDLL 144 | Level3 145 | 146 | 147 | NDEBUG;%(PreprocessorDefinitions) 148 | 0x0409 149 | 150 | 151 | SDL3.lib;%(AdditionalDependencies) 152 | Console 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | _DEBUG;%(PreprocessorDefinitions) 164 | true 165 | true 166 | Win32 167 | .\Debug/showinterfaces.tlb 168 | 169 | 170 | 171 | 172 | Disabled 173 | WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) 174 | MultiThreadedDebugDLL 175 | Level3 176 | OldStyle 177 | 178 | 179 | _DEBUG;%(PreprocessorDefinitions) 180 | 0x0409 181 | 182 | 183 | SDL3.lib;%(AdditionalDependencies) 184 | true 185 | Console 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | _DEBUG;%(PreprocessorDefinitions) 197 | true 198 | true 199 | X64 200 | .\Debug/showinterfaces.tlb 201 | 202 | 203 | 204 | 205 | Disabled 206 | WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) 207 | MultiThreadedDebugDLL 208 | Level3 209 | OldStyle 210 | 211 | 212 | _DEBUG;%(PreprocessorDefinitions) 213 | 0x0409 214 | 215 | 216 | SDL3.lib;%(AdditionalDependencies) 217 | true 218 | Console 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | {8ab3504f-5e58-4910-afe8-7a1e595ac3f4} 233 | 234 | 235 | 236 | 237 | 238 | -------------------------------------------------------------------------------- /VisualC/examples/voipchat.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {A01E2216-139A-480E-8458-03CB4E90FE61} 23 | voipchat 24 | 25 | 26 | 27 | Application 28 | $(DefaultPlatformToolset) 29 | 30 | 31 | Application 32 | $(DefaultPlatformToolset) 33 | 34 | 35 | Application 36 | $(DefaultPlatformToolset) 37 | 38 | 39 | Application 40 | $(DefaultPlatformToolset) 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | <_ProjectFileVersion>10.0.40219.1 64 | $(SolutionDir)\$(Platform)\$(Configuration)\ 65 | $(Platform)\$(Configuration)\ 66 | $(SolutionDir)\$(Platform)\$(Configuration)\ 67 | $(Platform)\$(Configuration)\ 68 | $(SolutionDir)\$(Platform)\$(Configuration)\ 69 | $(Platform)\$(Configuration)\ 70 | $(SolutionDir)\$(Platform)\$(Configuration)\ 71 | $(Platform)\$(Configuration)\ 72 | AllRules.ruleset 73 | 74 | 75 | AllRules.ruleset 76 | 77 | 78 | AllRules.ruleset 79 | 80 | 81 | AllRules.ruleset 82 | 83 | 84 | 85 | 86 | $(SolutionDir)..\..\SDL\include;$(SolutionDir)..\include;$(IncludePath) 87 | $(SolutionDir)..\..\SDL\VisualC\$(PlatformName)\$(Configuration);$(LibraryPath) 88 | 89 | 90 | $(SolutionDir)..\..\SDL\include;$(SolutionDir)..\include;$(IncludePath) 91 | $(SolutionDir)..\..\SDL\VisualC\$(PlatformName)\$(Configuration);$(LibraryPath) 92 | 93 | 94 | $(SolutionDir)..\..\SDL\include;$(SolutionDir)..\include;$(IncludePath) 95 | $(SolutionDir)..\..\SDL\VisualC\$(PlatformName)\$(Configuration);$(LibraryPath) 96 | 97 | 98 | $(SolutionDir)..\..\SDL\include;$(SolutionDir)..\include;$(IncludePath) 99 | $(SolutionDir)..\..\SDL\VisualC\$(PlatformName)\$(Configuration);$(LibraryPath) 100 | 101 | 102 | 103 | NDEBUG;%(PreprocessorDefinitions) 104 | true 105 | true 106 | Win32 107 | .\Release/showinterfaces.tlb 108 | 109 | 110 | 111 | 112 | WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) 113 | MultiThreadedDLL 114 | Level3 115 | 116 | 117 | NDEBUG;%(PreprocessorDefinitions) 118 | 0x0409 119 | 120 | 121 | SDL3.lib;%(AdditionalDependencies) 122 | Console 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | NDEBUG;%(PreprocessorDefinitions) 134 | true 135 | true 136 | X64 137 | .\Release/showinterfaces.tlb 138 | 139 | 140 | 141 | 142 | WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) 143 | MultiThreadedDLL 144 | Level3 145 | 146 | 147 | NDEBUG;%(PreprocessorDefinitions) 148 | 0x0409 149 | 150 | 151 | SDL3.lib;%(AdditionalDependencies) 152 | Console 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | _DEBUG;%(PreprocessorDefinitions) 164 | true 165 | true 166 | Win32 167 | .\Debug/showinterfaces.tlb 168 | 169 | 170 | 171 | 172 | Disabled 173 | WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) 174 | MultiThreadedDebugDLL 175 | Level3 176 | OldStyle 177 | 178 | 179 | _DEBUG;%(PreprocessorDefinitions) 180 | 0x0409 181 | 182 | 183 | SDL3.lib;%(AdditionalDependencies) 184 | true 185 | Console 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | _DEBUG;%(PreprocessorDefinitions) 197 | true 198 | true 199 | X64 200 | .\Debug/showinterfaces.tlb 201 | 202 | 203 | 204 | 205 | Disabled 206 | WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) 207 | MultiThreadedDebugDLL 208 | Level3 209 | OldStyle 210 | 211 | 212 | _DEBUG;%(PreprocessorDefinitions) 213 | 0x0409 214 | 215 | 216 | SDL3.lib;%(AdditionalDependencies) 217 | true 218 | Console 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | {8ab3504f-5e58-4910-afe8-7a1e595ac3f4} 233 | 234 | 235 | 236 | 237 | 238 | -------------------------------------------------------------------------------- /build-scripts/cmake-toolchain-mingw64-i686.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_SYSTEM_NAME Windows) 2 | set(CMAKE_SYSTEM_PROCESSOR x86) 3 | 4 | find_program(CMAKE_C_COMPILER NAMES i686-w64-mingw32-gcc) 5 | find_program(CMAKE_CXX_COMPILER NAMES i686-w64-mingw32-g++) 6 | find_program(CMAKE_RC_COMPILER NAMES i686-w64-mingw32-windres windres) 7 | 8 | if(NOT CMAKE_C_COMPILER) 9 | message(FATAL_ERROR "Failed to find CMAKE_C_COMPILER.") 10 | endif() 11 | 12 | if(NOT CMAKE_CXX_COMPILER) 13 | message(FATAL_ERROR "Failed to find CMAKE_CXX_COMPILER.") 14 | endif() 15 | 16 | if(NOT CMAKE_RC_COMPILER) 17 | message(FATAL_ERROR "Failed to find CMAKE_RC_COMPILER.") 18 | endif() 19 | -------------------------------------------------------------------------------- /build-scripts/cmake-toolchain-mingw64-x86_64.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_SYSTEM_NAME Windows) 2 | set(CMAKE_SYSTEM_PROCESSOR x86_64) 3 | 4 | find_program(CMAKE_C_COMPILER NAMES x86_64-w64-mingw32-gcc) 5 | find_program(CMAKE_CXX_COMPILER NAMES x86_64-w64-mingw32-g++) 6 | find_program(CMAKE_RC_COMPILER NAMES x86_64-w64-mingw32-windres windres) 7 | 8 | if(NOT CMAKE_C_COMPILER) 9 | message(FATAL_ERROR "Failed to find CMAKE_C_COMPILER.") 10 | endif() 11 | 12 | if(NOT CMAKE_CXX_COMPILER) 13 | message(FATAL_ERROR "Failed to find CMAKE_CXX_COMPILER.") 14 | endif() 15 | 16 | if(NOT CMAKE_RC_COMPILER) 17 | message(FATAL_ERROR "Failed to find CMAKE_RC_COMPILER.") 18 | endif() 19 | -------------------------------------------------------------------------------- /build-scripts/create-release.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import argparse 4 | from pathlib import Path 5 | import json 6 | import logging 7 | import re 8 | import subprocess 9 | 10 | ROOT = Path(__file__).resolve().parents[1] 11 | 12 | 13 | def determine_remote() -> str: 14 | text = (ROOT / "build-scripts/release-info.json").read_text() 15 | release_info = json.loads(text) 16 | if "remote" in release_info: 17 | return release_info["remote"] 18 | project_with_version = release_info["name"] 19 | project, _ = re.subn("([^a-zA-Z_])", "", project_with_version) 20 | return f"libsdl-org/{project}" 21 | 22 | 23 | def main(): 24 | default_remote = determine_remote() 25 | 26 | parser = argparse.ArgumentParser(allow_abbrev=False) 27 | parser.add_argument("--ref", required=True, help=f"Name of branch or tag containing release.yml") 28 | parser.add_argument("--remote", "-R", default=default_remote, help=f"Remote repo (default={default_remote})") 29 | parser.add_argument("--commit", help=f"Input 'commit' of release.yml (default is the hash of the ref)") 30 | args = parser.parse_args() 31 | 32 | if args.commit is None: 33 | args.commit = subprocess.check_output(["git", "rev-parse", args.ref], cwd=ROOT, text=True).strip() 34 | 35 | 36 | print(f"Running release.yml workflow:") 37 | print(f" remote = {args.remote}") 38 | print(f" ref = {args.ref}") 39 | print(f" commit = {args.commit}") 40 | 41 | subprocess.check_call(["gh", "-R", args.remote, "workflow", "run", "release.yml", "--ref", args.ref, "-f", f"commit={args.commit}"], cwd=ROOT) 42 | 43 | 44 | if __name__ == "__main__": 45 | raise SystemExit(main()) 46 | -------------------------------------------------------------------------------- /build-scripts/pkg-support/android/README.md.in: -------------------------------------------------------------------------------- 1 | 2 | The Simple DirectMedia Layer (SDL for short) is a cross-platform library 3 | designed to make it easy to write multi-media software, such as games 4 | and emulators. 5 | 6 | The Simple DirectMedia Layer library source code is available from: 7 | https://www.libsdl.org/ 8 | 9 | This library is distributed under the terms of the zlib license: 10 | http://www.zlib.net/zlib_license.html 11 | 12 | # @<@PROJECT_NAME@>@-@<@PROJECT_VERSION@>@.aar 13 | 14 | This Android archive allows use of @<@PROJECT_NAME@>@ in your Android project, without needing to copy any SDL source. 15 | 16 | ## Gradle integration 17 | 18 | For integration with CMake/ndk-build, it uses [prefab](https://google.github.io/prefab/). 19 | 20 | Copy the aar archive (@<@PROJECT_NAME@>@-@<@PROJECT_VERSION@>@.aar) to a `app/libs` directory of your project. 21 | 22 | In `app/build.gradle` of your Android project, add: 23 | ``` 24 | android { 25 | /* ... */ 26 | buildFeatures { 27 | prefab true 28 | } 29 | } 30 | dependencies { 31 | implementation files('libs/@<@PROJECT_NAME@>@-@<@PROJECT_VERSION@>@.aar') 32 | /* ... */ 33 | } 34 | ``` 35 | 36 | If you're using CMake, add the following to your CMakeLists.txt: 37 | ``` 38 | find_package(@<@PROJECT_NAME@>@ REQUIRED CONFIG) 39 | target_link_libraries(yourgame PRIVATE @<@PROJECT_NAME@>@::@<@PROJECT_NAME@>@) 40 | ``` 41 | 42 | If you use ndk-build, add the following before `include $(BUILD_SHARED_LIBRARY)` to your `Android.mk`: 43 | ``` 44 | LOCAL_SHARED_LIBARARIES := @<@PROJECT_NAME@>@ 45 | ``` 46 | And add the following at the bottom: 47 | ``` 48 | # https://google.github.io/prefab/build-systems.html 49 | 50 | # Add the prefab modules to the import path. 51 | $(call import-add-path,/out) 52 | 53 | # Import @<@PROJECT_NAME@>@ so we can depend on it. 54 | $(call import-module,prefab/@<@PROJECT_NAME@>@) 55 | ``` 56 | 57 | --- 58 | 59 | ## Other build systems (advanced) 60 | 61 | If you want to build a project without Gradle, 62 | running the following command will extract the Android archive into a more common directory structure. 63 | ``` 64 | python @<@PROJECT_NAME@>@-@<@PROJECT_VERSION@>@.aar -o android_prefix 65 | ``` 66 | Add `--help` for a list of all available options. 67 | 68 | 69 | Look at the example programs in ./examples (of the source archive), and check out online documentation: 70 | https://wiki.libsdl.org/SDL3/FrontPage 71 | 72 | Join the SDL discourse server if you want to join the community: 73 | https://discourse.libsdl.org/ 74 | 75 | 76 | That's it! 77 | Sam Lantinga 78 | -------------------------------------------------------------------------------- /build-scripts/pkg-support/android/aar/__main__.py.in: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """ 4 | Create a @<@PROJECT_NAME@>@ SDK prefix from an Android archive 5 | This file is meant to be placed in a the root of an android .aar archive 6 | 7 | Example usage: 8 | ```sh 9 | python @<@PROJECT_NAME@>@-@<@PROJECT_VERSION@>@.aar -o /usr/opt/android-sdks 10 | cmake -S my-project \ 11 | -DCMAKE_PREFIX_PATH=/usr/opt/android-sdks \ 12 | -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake \ 13 | -B build-arm64 -DANDROID_ABI=arm64-v8a \ 14 | -DCMAKE_BUILD_TYPE=Releaase 15 | cmake --build build-arm64 16 | ``` 17 | """ 18 | import argparse 19 | import io 20 | import json 21 | import os 22 | import pathlib 23 | import re 24 | import stat 25 | import zipfile 26 | 27 | 28 | AAR_PATH = pathlib.Path(__file__).resolve().parent 29 | ANDROID_ARCHS = { "armeabi-v7a", "arm64-v8a", "x86", "x86_64" } 30 | 31 | 32 | def main(): 33 | parser = argparse.ArgumentParser( 34 | description="Convert a @<@PROJECT_NAME@>@ Android .aar archive into a SDK", 35 | allow_abbrev=False, 36 | ) 37 | parser.add_argument("--version", action="version", version="@<@PROJECT_NAME@>@ @<@PROJECT_VERSION@>@") 38 | parser.add_argument("-o", dest="output", type=pathlib.Path, required=True, help="Folder where to store the SDK") 39 | args = parser.parse_args() 40 | 41 | print(f"Creating a @<@PROJECT_NAME@>@ SDK at {args.output}...") 42 | 43 | prefix = args.output 44 | incdir = prefix / "include" 45 | libdir = prefix / "lib" 46 | 47 | RE_LIB_MODULE_ARCH = re.compile(r"prefab/modules/(?P[A-Za-z0-9_-]+)/libs/android\.(?P[a-zA-Z0-9_-]+)/(?Plib[A-Za-z0-9_]+\.(?:so|a))") 48 | RE_INC_MODULE_ARCH = re.compile(r"prefab/modules/(?P[A-Za-z0-9_-]+)/include/(?P
[a-zA-Z0-9_./-]+)") 49 | RE_LICENSE = re.compile(r"(?:.*/)?(?P(?:license|copying)(?:\.md|\.txt)?)", flags=re.I) 50 | RE_PROGUARD = re.compile(r"(?:.*/)?(?Pproguard.*\.(?:pro|txt))", flags=re.I) 51 | RE_CMAKE = re.compile(r"(?:.*/)?(?P.*\.cmake)", flags=re.I) 52 | 53 | with zipfile.ZipFile(AAR_PATH) as zf: 54 | project_description = json.loads(zf.read("description.json")) 55 | project_name = project_description["name"] 56 | project_version = project_description["version"] 57 | licensedir = prefix / "share/licenses" / project_name 58 | cmakedir = libdir / "cmake" / project_name 59 | javadir = prefix / "share/java" / project_name 60 | javadocdir = prefix / "share/javadoc" / project_name 61 | 62 | def read_zipfile_and_write(path: pathlib.Path, zippath: str): 63 | data = zf.read(zippath) 64 | path.parent.mkdir(parents=True, exist_ok=True) 65 | path.write_bytes(data) 66 | 67 | for zip_info in zf.infolist(): 68 | zippath = zip_info.filename 69 | if m := RE_LIB_MODULE_ARCH.match(zippath): 70 | lib_path = libdir / m["arch"] / m["filename"] 71 | read_zipfile_and_write(lib_path, zippath) 72 | if m["filename"].endswith(".so"): 73 | os.chmod(lib_path, stat.S_IRWXU | stat.S_IRGRP | stat.S_IXGRP | stat.S_IROTH | stat.S_IXOTH) 74 | 75 | elif m := RE_INC_MODULE_ARCH.match(zippath): 76 | header_path = incdir / m["header"] 77 | read_zipfile_and_write(header_path, zippath) 78 | elif m:= RE_LICENSE.match(zippath): 79 | license_path = licensedir / m["filename"] 80 | read_zipfile_and_write(license_path, zippath) 81 | elif m:= RE_PROGUARD.match(zippath): 82 | proguard_path = javadir / m["filename"] 83 | read_zipfile_and_write(proguard_path, zippath) 84 | elif m:= RE_CMAKE.match(zippath): 85 | cmake_path = cmakedir / m["filename"] 86 | read_zipfile_and_write(cmake_path, zippath) 87 | elif zippath == "classes.jar": 88 | versioned_jar_path = javadir / f"{project_name}-{project_version}.jar" 89 | unversioned_jar_path = javadir / f"{project_name}.jar" 90 | read_zipfile_and_write(versioned_jar_path, zippath) 91 | os.symlink(src=versioned_jar_path.name, dst=unversioned_jar_path) 92 | elif zippath == "classes-sources.jar": 93 | jarpath = javadir / f"{project_name}-{project_version}-sources.jar" 94 | read_zipfile_and_write(jarpath, zippath) 95 | elif zippath == "classes-doc.jar": 96 | jarpath = javadocdir / f"{project_name}-{project_version}-javadoc.jar" 97 | read_zipfile_and_write(jarpath, zippath) 98 | 99 | print("... done") 100 | return 0 101 | 102 | 103 | if __name__ == "__main__": 104 | raise SystemExit(main()) 105 | -------------------------------------------------------------------------------- /build-scripts/pkg-support/android/aar/cmake/SDL3_netConfig.cmake: -------------------------------------------------------------------------------- 1 | # SDL CMake configuration file: 2 | # This file is meant to be placed in lib/cmake/SDL3_net subfolder of a reconstructed Android SDL3_net SDK 3 | 4 | cmake_minimum_required(VERSION 3.0...3.28) 5 | 6 | include(FeatureSummary) 7 | set_package_properties(SDL3_net PROPERTIES 8 | URL "https://www.libsdl.org/projects/SDL_net/" 9 | DESCRIPTION "SDL_net is a simple, cross-platform wrapper over sockets" 10 | ) 11 | 12 | # Copied from `configure_package_config_file` 13 | macro(set_and_check _var _file) 14 | set(${_var} "${_file}") 15 | if(NOT EXISTS "${_file}") 16 | message(FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist !") 17 | endif() 18 | endmacro() 19 | 20 | # Copied from `configure_package_config_file` 21 | macro(check_required_components _NAME) 22 | foreach(comp ${${_NAME}_FIND_COMPONENTS}) 23 | if(NOT ${_NAME}_${comp}_FOUND) 24 | if(${_NAME}_FIND_REQUIRED_${comp}) 25 | set(${_NAME}_FOUND FALSE) 26 | endif() 27 | endif() 28 | endforeach() 29 | endmacro() 30 | 31 | set(SDL3_net_FOUND TRUE) 32 | 33 | if(SDL_CPU_X86) 34 | set(_sdl_arch_subdir "x86") 35 | elseif(SDL_CPU_X64) 36 | set(_sdl_arch_subdir "x86_64") 37 | elseif(SDL_CPU_ARM32) 38 | set(_sdl_arch_subdir "armeabi-v7a") 39 | elseif(SDL_CPU_ARM64) 40 | set(_sdl_arch_subdir "arm64-v8a") 41 | else() 42 | set(SDL3_net_FOUND FALSE) 43 | return() 44 | endif() 45 | 46 | get_filename_component(_sdl3net_prefix "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE) 47 | get_filename_component(_sdl3net_prefix "${_sdl3net_prefix}/.." ABSOLUTE) 48 | get_filename_component(_sdl3net_prefix "${_sdl3net_prefix}/.." ABSOLUTE) 49 | set_and_check(_sdl3net_prefix "${_sdl3net_prefix}") 50 | set_and_check(_sdl3net_include_dirs "${_sdl3net_prefix}/include") 51 | 52 | set_and_check(_sdl3net_lib "${_sdl3net_prefix}/lib/${_sdl_arch_subdir}/libSDL3_net.so") 53 | 54 | unset(_sdl_arch_subdir) 55 | unset(_sdl3net_prefix) 56 | 57 | # All targets are created, even when some might not be requested though COMPONENTS. 58 | # This is done for compatibility with CMake generated SDL3_net-target.cmake files. 59 | 60 | set(SDL3_net_SDL3_net-shared_FOUND FALSE) 61 | if(EXISTS "${_sdl3net_lib}") 62 | if(NOT TARGET SDL3_net::SDL3_net-shared) 63 | add_library(SDL3_net::SDL3_net-shared SHARED IMPORTED) 64 | set_target_properties(SDL3_net::SDL3_net-shared 65 | PROPERTIES 66 | IMPORTED_LOCATION "${_sdl3net_lib}" 67 | INTERFACE_INCLUDE_DIRECTORIES "${_sdl3net_include_dirs}" 68 | COMPATIBLE_INTERFACE_BOOL "SDL3_SHARED" 69 | INTERFACE_SDL3_SHARED "ON" 70 | COMPATIBLE_INTERFACE_STRING "SDL_VERSION" 71 | INTERFACE_SDL_VERSION "SDL3" 72 | ) 73 | endif() 74 | set(SDL3_net_SDL3_net-shared_FOUND TRUE) 75 | endif() 76 | unset(_sdl3net_include_dirs) 77 | unset(_sdl3net_lib) 78 | 79 | set(SDL3_net_SDL3_net-static_FOUND FALSE) 80 | 81 | if(SDL3_net_SDL3_net-shared_FOUND) 82 | set(SDL3_net_SDL3_net_FOUND TRUE) 83 | endif() 84 | 85 | function(_sdl_create_target_alias_compat NEW_TARGET TARGET) 86 | if(CMAKE_VERSION VERSION_LESS "3.18") 87 | # Aliasing local targets is not supported on CMake < 3.18, so make it global. 88 | add_library(${NEW_TARGET} INTERFACE IMPORTED) 89 | set_target_properties(${NEW_TARGET} PROPERTIES INTERFACE_LINK_LIBRARIES "${TARGET}") 90 | else() 91 | add_library(${NEW_TARGET} ALIAS ${TARGET}) 92 | endif() 93 | endfunction() 94 | 95 | # Make sure SDL3_net::SDL3_net always exists 96 | if(NOT TARGET SDL3_net::SDL3_net) 97 | if(TARGET SDL3_net::SDL3_net-shared) 98 | _sdl_create_target_alias_compat(SDL3_net::SDL3_net SDL3_net::SDL3_net-shared) 99 | endif() 100 | endif() 101 | 102 | check_required_components(SDL3_net) 103 | -------------------------------------------------------------------------------- /build-scripts/pkg-support/android/aar/cmake/SDL3_netConfigVersion.cmake.in: -------------------------------------------------------------------------------- 1 | # SDL_net CMake version configuration file: 2 | # This file is meant to be placed in a lib/cmake/SDL3_net subfolder of a reconstructed Android SDL3_net SDK 3 | 4 | set(PACKAGE_VERSION "@<@PROJECT_VERSION@>@") 5 | 6 | if(PACKAGE_FIND_VERSION_RANGE) 7 | # Package version must be in the requested version range 8 | if ((PACKAGE_FIND_VERSION_RANGE_MIN STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION_MIN) 9 | OR ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_GREATER PACKAGE_FIND_VERSION_MAX) 10 | OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND PACKAGE_VERSION VERSION_GREATER_EQUAL PACKAGE_FIND_VERSION_MAX))) 11 | set(PACKAGE_VERSION_COMPATIBLE FALSE) 12 | else() 13 | set(PACKAGE_VERSION_COMPATIBLE TRUE) 14 | endif() 15 | else() 16 | if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) 17 | set(PACKAGE_VERSION_COMPATIBLE FALSE) 18 | else() 19 | set(PACKAGE_VERSION_COMPATIBLE TRUE) 20 | if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) 21 | set(PACKAGE_VERSION_EXACT TRUE) 22 | endif() 23 | endif() 24 | endif() 25 | 26 | # if the using project doesn't have CMAKE_SIZEOF_VOID_P set, fail. 27 | if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "") 28 | set(PACKAGE_VERSION_UNSUITABLE TRUE) 29 | endif() 30 | 31 | include("${CMAKE_CURRENT_LIST_DIR}/sdlcpu.cmake") 32 | SDL_DetectTargetCPUArchitectures(_detected_archs) 33 | 34 | # check that the installed version has a compatible architecture as the one which is currently searching: 35 | if(NOT(SDL_CPU_X86 OR SDL_CPU_X64 OR SDL_CPU_ARM32 OR SDL_CPU_ARM64)) 36 | set(PACKAGE_VERSION "${PACKAGE_VERSION} (X86,X64,ARM32,ARM64)") 37 | set(PACKAGE_VERSION_UNSUITABLE TRUE) 38 | endif() 39 | -------------------------------------------------------------------------------- /build-scripts/pkg-support/android/aar/description.json.in: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@<@PROJECT_NAME@>@", 3 | "version": "@<@PROJECT_VERSION@>@", 4 | "git-hash": "@<@PROJECT_COMMIT@>@" 5 | } 6 | -------------------------------------------------------------------------------- /build-scripts/pkg-support/mingw/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for installing the mingw32 version of the SDL_net library 3 | 4 | DESTDIR = /usr/local 5 | ARCHITECTURES := i686-w64-mingw32 x86_64-w64-mingw32 6 | 7 | default: 8 | @echo "Run \"make install-i686\" to install 32-bit" 9 | @echo "Run \"make install-x86_64\" to install 64-bit" 10 | @echo "Run \"make install-all\" to install both" 11 | @echo "Add DESTDIR=/custom/path to change the destination folder" 12 | 13 | install: 14 | @if test -d $(ARCH) && test -d $(DESTDIR); then \ 15 | (cd $(ARCH) && cp -rv bin include lib share $(DESTDIR)/); \ 16 | else \ 17 | echo "*** ERROR: $(ARCH) or $(DESTDIR) does not exist!"; \ 18 | exit 1; \ 19 | fi 20 | 21 | install-i686: 22 | $(MAKE) install ARCH=i686-w64-mingw32 23 | 24 | install-x86_64: 25 | $(MAKE) install ARCH=x86_64-w64-mingw32 26 | 27 | install-all: 28 | @if test -d $(DESTDIR); then \ 29 | mkdir -p $(DESTDIR)/cmake; \ 30 | cp -rv cmake/* $(DESTDIR)/cmake; \ 31 | for arch in $(ARCHITECTURES); do \ 32 | $(MAKE) install ARCH=$$arch DESTDIR=$(DESTDIR)/$$arch; \ 33 | done \ 34 | else \ 35 | echo "*** ERROR: $(DESTDIR) does not exist!"; \ 36 | exit 1; \ 37 | fi 38 | 39 | .PHONY: default install install-i686 install-x86_64 install-all 40 | -------------------------------------------------------------------------------- /build-scripts/pkg-support/mingw/cmake/SDL3_netConfig.cmake: -------------------------------------------------------------------------------- 1 | # SDL3_net CMake configuration file: 2 | # This file is meant to be placed in a cmake subfolder of SDL3_net-devel-3.x.y-mingw 3 | 4 | if(CMAKE_SIZEOF_VOID_P EQUAL 4) 5 | set(sdl3_net_config_path "${CMAKE_CURRENT_LIST_DIR}/../i686-w64-mingw32/lib/cmake/SDL3_net/SDL3_netConfig.cmake") 6 | elseif(CMAKE_SIZEOF_VOID_P EQUAL 8) 7 | set(sdl3_net_config_path "${CMAKE_CURRENT_LIST_DIR}/../x86_64-w64-mingw32/lib/cmake/SDL3_net/SDL3_netConfig.cmake") 8 | else("${CMAKE_SIZEOF_VOID_P}" STREQUAL "") 9 | set(SDL3_net_FOUND FALSE) 10 | return() 11 | endif() 12 | 13 | if(NOT EXISTS "${sdl3_net_config_path}") 14 | message(WARNING "${sdl3_net_config_path} does not exist: MinGW development package is corrupted") 15 | set(SDL3_net_FOUND FALSE) 16 | return() 17 | endif() 18 | 19 | include("${sdl3_net_config_path}") 20 | -------------------------------------------------------------------------------- /build-scripts/pkg-support/mingw/cmake/SDL3_netConfigVersion.cmake: -------------------------------------------------------------------------------- 1 | # SDL3_net CMake version configuration file: 2 | # This file is meant to be placed in a cmake subfolder of SDL3_net-devel-3.x.y-mingw 3 | 4 | if(CMAKE_SIZEOF_VOID_P EQUAL 4) 5 | set(sdl3_net_config_path "${CMAKE_CURRENT_LIST_DIR}/../i686-w64-mingw32/lib/cmake/SDL3_net/SDL3_netConfigVersion.cmake") 6 | elseif(CMAKE_SIZEOF_VOID_P EQUAL 8) 7 | set(sdl3_net_config_path "${CMAKE_CURRENT_LIST_DIR}/../x86_64-w64-mingw32/lib/cmake/SDL3_net/SDL3_netConfigVersion.cmake") 8 | else("${CMAKE_SIZEOF_VOID_P}" STREQUAL "") 9 | set(PACKAGE_VERSION_UNSUITABLE TRUE) 10 | return() 11 | endif() 12 | 13 | if(NOT EXISTS "${sdl3_net_config_path}") 14 | message(WARNING "${sdl3_net_config_path} does not exist: MinGW development package is corrupted") 15 | set(PACKAGE_VERSION_UNSUITABLE TRUE) 16 | return() 17 | endif() 18 | 19 | include("${sdl3_net_config_path}") 20 | -------------------------------------------------------------------------------- /build-scripts/pkg-support/msvc/cmake/SDL3_netConfig.cmake.in: -------------------------------------------------------------------------------- 1 | # @<@PROJECT_NAME@>@ CMake configuration file: 2 | # This file is meant to be placed in a cmake subfolder of @<@PROJECT_NAME@>@-devel-@<@PROJECT_VERSION@>@-VC.zip 3 | 4 | include(FeatureSummary) 5 | set_package_properties(SDL3_net PROPERTIES 6 | URL "https://www.libsdl.org/projects/SDL_net/" 7 | DESCRIPTION "SDL_net is a simple, cross-platform wrapper over sockets" 8 | ) 9 | 10 | cmake_minimum_required(VERSION 3.0...3.28) 11 | 12 | # Copied from `configure_package_config_file` 13 | macro(check_required_components _NAME) 14 | foreach(comp ${${_NAME}_FIND_COMPONENTS}) 15 | if(NOT ${_NAME}_${comp}_FOUND) 16 | if(${_NAME}_FIND_REQUIRED_${comp}) 17 | set(${_NAME}_FOUND FALSE) 18 | endif() 19 | endif() 20 | endforeach() 21 | endmacro() 22 | 23 | set(SDL3_net_FOUND TRUE) 24 | 25 | 26 | if(SDL_CPU_X86) 27 | set(_sdl3_net_arch_subdir "x86") 28 | elseif(SDL_CPU_X64 OR SDL_CPU_ARM64EC) 29 | set(_sdl3_net_arch_subdir "x64") 30 | elseif(SDL_CPU_ARM64) 31 | set(_sdl3_net_arch_subdir "arm64") 32 | else() 33 | set(SDL3_net_FOUND FALSE) 34 | return() 35 | endif() 36 | 37 | set(_sdl3_net_incdir "${CMAKE_CURRENT_LIST_DIR}/../include") 38 | set(_sdl3_net_library "${CMAKE_CURRENT_LIST_DIR}/../lib/${_sdl3_net_arch_subdir}/SDL3_net.lib") 39 | set(_sdl3_net_dll "${CMAKE_CURRENT_LIST_DIR}/../lib/${_sdl3_net_arch_subdir}/SDL3_net.dll") 40 | 41 | # All targets are created, even when some might not be requested though COMPONENTS. 42 | # This is done for compatibility with CMake generated SDL3_net-target.cmake files. 43 | 44 | set(SDL3_net_SDL3_net-shared_FOUND TRUE) 45 | if(NOT TARGET SDL3_net::SDL3_net-shared) 46 | add_library(SDL3_net::SDL3_net-shared SHARED IMPORTED) 47 | set_target_properties(SDL3_net::SDL3_net-shared 48 | PROPERTIES 49 | INTERFACE_INCLUDE_DIRECTORIES "${_sdl3_net_incdir}" 50 | IMPORTED_IMPLIB "${_sdl3_net_library}" 51 | IMPORTED_LOCATION "${_sdl3_net_dll}" 52 | COMPATIBLE_INTERFACE_BOOL "SDL3_SHARED" 53 | INTERFACE_SDL3_SHARED "ON" 54 | ) 55 | endif() 56 | 57 | set(SDL3_net_SDL3_net-static_FOUND FALSE) 58 | 59 | if(SDL3_net_SDL3_net-shared_FOUND OR SDL3_net_SDL3_net-static_FOUND) 60 | set(SDL3_net_SDL3_net_FOUND TRUE) 61 | endif() 62 | 63 | function(_sdl_create_target_alias_compat NEW_TARGET TARGET) 64 | if(CMAKE_VERSION VERSION_LESS "3.18") 65 | # Aliasing local targets is not supported on CMake < 3.18, so make it global. 66 | add_library(${NEW_TARGET} INTERFACE IMPORTED) 67 | set_target_properties(${NEW_TARGET} PROPERTIES INTERFACE_LINK_LIBRARIES "${TARGET}") 68 | else() 69 | add_library(${NEW_TARGET} ALIAS ${TARGET}) 70 | endif() 71 | endfunction() 72 | 73 | # Make sure SDL3_net::SDL3_net always exists 74 | if(NOT TARGET SDL3_net::SDL3_net) 75 | if(TARGET SDL3_net::SDL3_net-shared) 76 | _sdl_create_target_alias_compat(SDL3_net::SDL3_net SDL3_net::SDL3_net-shared) 77 | endif() 78 | endif() 79 | 80 | unset(_sdl3_net_arch_subdir) 81 | unset(_sdl3_net_incdir) 82 | unset(_sdl3_net_library) 83 | unset(_sdl3_net_dll) 84 | 85 | check_required_components(SDL3_net) 86 | -------------------------------------------------------------------------------- /build-scripts/pkg-support/msvc/cmake/SDL3_netConfigVersion.cmake.in: -------------------------------------------------------------------------------- 1 | # @<@PROJECT_NAME@>@ CMake version configuration file: 2 | # This file is meant to be placed in a cmake subfolder of @<@PROJECT_NAME@>@-devel-@<@PROJECT_VERSION@>@-VC.zip 3 | 4 | set(PACKAGE_VERSION "@<@PROJECT_VERSION@>@") 5 | 6 | include("${CMAKE_CURRENT_LIST_DIR}/sdlcpu.cmake") 7 | SDL_DetectTargetCPUArchitectures(_detected_archs) 8 | 9 | if(PACKAGE_FIND_VERSION_RANGE) 10 | # Package version must be in the requested version range 11 | if ((PACKAGE_FIND_VERSION_RANGE_MIN STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION_MIN) 12 | OR ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_GREATER PACKAGE_FIND_VERSION_MAX) 13 | OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND PACKAGE_VERSION VERSION_GREATER_EQUAL PACKAGE_FIND_VERSION_MAX))) 14 | set(PACKAGE_VERSION_COMPATIBLE FALSE) 15 | else() 16 | set(PACKAGE_VERSION_COMPATIBLE TRUE) 17 | endif() 18 | else() 19 | if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) 20 | set(PACKAGE_VERSION_COMPATIBLE FALSE) 21 | else() 22 | set(PACKAGE_VERSION_COMPATIBLE TRUE) 23 | if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) 24 | set(PACKAGE_VERSION_EXACT TRUE) 25 | endif() 26 | endif() 27 | endif() 28 | 29 | include("${CMAKE_CURRENT_LIST_DIR}/sdlcpu.cmake") 30 | SDL_DetectTargetCPUArchitectures(_detected_archs) 31 | 32 | # check that the installed version has a compatible architecture as the one which is currently searching: 33 | if(NOT(SDL_CPU_X86 OR SDL_CPU_X64 OR SDL_CPU_ARM64 OR SDL_CPU_ARM64EC)) 34 | set(PACKAGE_VERSION "${PACKAGE_VERSION} (X86,X64,ARM64)") 35 | set(PACKAGE_VERSION_UNSUITABLE TRUE) 36 | endif() 37 | -------------------------------------------------------------------------------- /build-scripts/release-info.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "SDL3_net", 3 | "remote": "libsdl-org/SDL_net", 4 | "dependencies": { 5 | "SDL": { 6 | "startswith": "3.", 7 | "repo": "libsdl-org/SDL" 8 | } 9 | }, 10 | "version": { 11 | "file": "include/SDL3_net/SDL_net.h", 12 | "re_major": "^#define SDL_NET_MAJOR_VERSION\\s+([0-9]+)$", 13 | "re_minor": "^#define SDL_NET_MINOR_VERSION\\s+([0-9]+)$", 14 | "re_micro": "^#define SDL_NET_MICRO_VERSION\\s+([0-9]+)$" 15 | }, 16 | "source": { 17 | "checks": [ 18 | "src/SDL_net.c", 19 | "include/SDL3_net/SDL_net.h", 20 | "examples/voipchat.c" 21 | ] 22 | }, 23 | "dmg": { 24 | "project": "Xcode/SDL_net.xcodeproj", 25 | "path": "Xcode/build/SDL3_net.dmg", 26 | "scheme": "SDL3_net.dmg", 27 | "dependencies": { 28 | "SDL": { 29 | "artifact": "SDL3-*.dmg" 30 | } 31 | } 32 | }, 33 | "mingw": { 34 | "cmake": { 35 | "archs": ["x86", "x64"], 36 | "args": [ 37 | "-DBUILD_SHARED_LIBS=ON", 38 | "-DSDLNET_RELOCATABLE=ON", 39 | "-DSDLNET_SAMPLES=OFF", 40 | "-DSDLNET_INSTALL=ON", 41 | "-DSDLNET_INSTALL_MAN=OFF" 42 | ], 43 | "shared-static": "args" 44 | }, 45 | "files": { 46 | "": [ 47 | "LICENSE.txt", 48 | "README.md", 49 | "build-scripts/pkg-support/mingw/Makefile" 50 | ], 51 | "cmake": [ 52 | "build-scripts/pkg-support/mingw/cmake/SDL3_netConfig.cmake", 53 | "build-scripts/pkg-support/mingw/cmake/SDL3_netConfigVersion.cmake" 54 | ] 55 | }, 56 | "dependencies": { 57 | "SDL": { 58 | "artifact": "SDL3-devel-*-mingw.tar.gz", 59 | "install-command": "make install-@<@ARCH@>@ DESTDIR=@<@PREFIX@>@" 60 | } 61 | } 62 | }, 63 | "msvc": { 64 | "msbuild": { 65 | "archs": [ 66 | "x86", 67 | "x64" 68 | ], 69 | "projects": [ 70 | "VisualC/SDL_net.vcxproj" 71 | ], 72 | "files-lib": { 73 | "": [ 74 | "VisualC/@<@PLATFORM@>@/@<@CONFIGURATION@>@/SDL3_net.dll" 75 | ] 76 | }, 77 | "files-devel": { 78 | "lib/@<@ARCH@>@": [ 79 | "VisualC/@<@PLATFORM@>@/@<@CONFIGURATION@>@/SDL3_net.dll", 80 | "VisualC/@<@PLATFORM@>@/@<@CONFIGURATION@>@/SDL3_net.lib", 81 | "VisualC/@<@PLATFORM@>@/@<@CONFIGURATION@>@/SDL3_net.pdb" 82 | ] 83 | } 84 | }, 85 | "cmake": { 86 | "archs": [ 87 | "arm64" 88 | ], 89 | "args": [ 90 | "-DBUILD_SHARED_LIBS=ON", 91 | "-DSDLNET_RELOCATABLE=ON", 92 | "-DSDLNET_SAMPLES=OFF", 93 | "-DSDLNET_INSTALL=ON", 94 | "-DSDLNET_INSTALL_MAN=OFF" 95 | ], 96 | "files-lib": { 97 | "": [ 98 | "bin/SDL3_net.dll" 99 | ] 100 | }, 101 | "files-devel": { 102 | "lib/@<@ARCH@>@": [ 103 | "bin/SDL3_net.dll", 104 | "bin/SDL3_net.pdb", 105 | "lib/SDL3_net.lib" 106 | ] 107 | } 108 | }, 109 | "files-lib": { 110 | "": [ 111 | "README.md" 112 | ] 113 | }, 114 | "files-devel": { 115 | "": [ 116 | "LICENSE.txt", 117 | "README.md" 118 | ], 119 | "cmake": [ 120 | "build-scripts/pkg-support/msvc/cmake/SDL3_netConfig.cmake.in:SDL3_netConfig.cmake", 121 | "build-scripts/pkg-support/msvc/cmake/SDL3_netConfigVersion.cmake.in:SDL3_netConvigVersion.cmake", 122 | "cmake/sdlcpu.cmake" 123 | ], 124 | "include/SDL3_net": [ 125 | "include/SDL3_net/SDL_net.h" 126 | ] 127 | }, 128 | "dependencies": { 129 | "SDL": { 130 | "artifact": "SDL3-devel-*-VC.zip", 131 | "copy": [ 132 | { 133 | "src": "lib/@<@ARCH@>@/SDL3.*", 134 | "dst": "../SDL/VisualC/@<@PLATFORM@>@/@<@CONFIGURATION@>@" 135 | }, 136 | { 137 | "src": "include/SDL3/*", 138 | "dst": "../SDL/include/SDL3" 139 | } 140 | ] 141 | } 142 | } 143 | }, 144 | "android": { 145 | "cmake": { 146 | "args": [ 147 | "-DBUILD_SHARED_LIBS=ON", 148 | "-DSDLNET_SAMPLES=OFF", 149 | "-DSDLNET_INSTALL=ON", 150 | "-DSDLNET_INSTALL_MAN=OFF" 151 | ] 152 | }, 153 | "modules": { 154 | "SDL3_net-shared": { 155 | "type": "library", 156 | "library": "lib/libSDL3_net.so", 157 | "includes": { 158 | "SDL3_net": ["include/SDL3_net/*.h"] 159 | } 160 | }, 161 | "SDL3_net": { 162 | "type": "interface", 163 | "export-libraries": [":SDL3_net-shared"] 164 | } 165 | }, 166 | "abis": [ 167 | "armeabi-v7a", 168 | "arm64-v8a", 169 | "x86", 170 | "x86_64" 171 | ], 172 | "api-minimum": 19, 173 | "api-target": 29, 174 | "ndk-minimum": 21, 175 | "aar-files": { 176 | "": [ 177 | "build-scripts/pkg-support/android/aar/__main__.py.in:__main__.py", 178 | "build-scripts/pkg-support/android/aar/description.json.in:description.json" 179 | ], 180 | "META-INF": [ 181 | "LICENSE.txt" 182 | ], 183 | "cmake": [ 184 | "cmake/sdlcpu.cmake", 185 | "build-scripts/pkg-support/android/aar/cmake/SDL3_netConfig.cmake", 186 | "build-scripts/pkg-support/android/aar/cmake/SDL3_netConfigVersion.cmake.in:SDL3_netConfigVersion.cmake" 187 | ] 188 | }, 189 | "files": { 190 | "": [ 191 | "build-scripts/pkg-support/android/README.md.in:README.md" 192 | ] 193 | }, 194 | "dependencies": { 195 | "SDL": { 196 | "artifact": "SDL3-devel-*-android.zip" 197 | } 198 | } 199 | } 200 | } 201 | -------------------------------------------------------------------------------- /build-scripts/test-versioning.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright 2022 Collabora Ltd. 3 | # SPDX-License-Identifier: Zlib 4 | 5 | set -eu 6 | 7 | cd `dirname $0`/.. 8 | 9 | # Needed so sed doesn't report illegal byte sequences on macOS 10 | export LC_CTYPE=C 11 | 12 | header=include/SDL3_net/SDL_net.h 13 | ref_major=$(sed -ne 's/^#define SDL_NET_MAJOR_VERSION *//p' $header) 14 | ref_minor=$(sed -ne 's/^#define SDL_NET_MINOR_VERSION *//p' $header) 15 | ref_micro=$(sed -ne 's/^#define SDL_NET_MICRO_VERSION *//p' $header) 16 | ref_version="${ref_major}.${ref_minor}.${ref_micro}" 17 | 18 | tests=0 19 | failed=0 20 | 21 | ok () { 22 | tests=$(( tests + 1 )) 23 | echo "ok - $*" 24 | } 25 | 26 | not_ok () { 27 | tests=$(( tests + 1 )) 28 | echo "not ok - $*" 29 | failed=1 30 | } 31 | 32 | major=$(sed -ne 's/^set(MAJOR_VERSION \([0-9]*\))$/\1/p' CMakeLists.txt) 33 | minor=$(sed -ne 's/^set(MINOR_VERSION \([0-9]*\))$/\1/p' CMakeLists.txt) 34 | micro=$(sed -ne 's/^set(MICRO_VERSION \([0-9]*\))$/\1/p' CMakeLists.txt) 35 | version="${major}.${minor}.${micro}" 36 | 37 | if [ "$ref_version" = "$version" ]; then 38 | ok "CMakeLists.txt $version" 39 | else 40 | not_ok "CMakeLists.txt $version disagrees with SDL_net.h $ref_version" 41 | fi 42 | 43 | for rcfile in src/version.rc; do 44 | tuple=$(sed -ne 's/^ *FILEVERSION *//p' "$rcfile" | tr -d '\r') 45 | ref_tuple="${ref_major},${ref_minor},${ref_micro},0" 46 | 47 | if [ "$ref_tuple" = "$tuple" ]; then 48 | ok "$rcfile FILEVERSION $tuple" 49 | else 50 | not_ok "$rcfile FILEVERSION $tuple disagrees with SDL_net.h $ref_tuple" 51 | fi 52 | 53 | tuple=$(sed -ne 's/^ *PRODUCTVERSION *//p' "$rcfile" | tr -d '\r') 54 | 55 | if [ "$ref_tuple" = "$tuple" ]; then 56 | ok "$rcfile PRODUCTVERSION $tuple" 57 | else 58 | not_ok "$rcfile PRODUCTVERSION $tuple disagrees with SDL_net.h $ref_tuple" 59 | fi 60 | 61 | tuple=$(sed -Ene 's/^ *VALUE "FileVersion", "([0-9, ]*)\\0"\r?$/\1/p' "$rcfile" | tr -d '\r') 62 | ref_tuple="${ref_major}, ${ref_minor}, ${ref_micro}, 0" 63 | 64 | if [ "$ref_tuple" = "$tuple" ]; then 65 | ok "$rcfile FileVersion $tuple" 66 | else 67 | not_ok "$rcfile FileVersion $tuple disagrees with SDL_net.h $ref_tuple" 68 | fi 69 | 70 | tuple=$(sed -Ene 's/^ *VALUE "ProductVersion", "([0-9, ]*)\\0"\r?$/\1/p' "$rcfile" | tr -d '\r') 71 | 72 | if [ "$ref_tuple" = "$tuple" ]; then 73 | ok "$rcfile ProductVersion $tuple" 74 | else 75 | not_ok "$rcfile ProductVersion $tuple disagrees with SDL_net.h $ref_tuple" 76 | fi 77 | done 78 | 79 | #version=$(sed -Ene '/CFBundleShortVersionString/,+1 s/.*(.*)<\/string>.*/\1/p' Xcode/Info-Framework.plist) 80 | # 81 | #if [ "$ref_version" = "$version" ]; then 82 | # ok "Info-Framework.plist CFBundleShortVersionString $version" 83 | #else 84 | # not_ok "Info-Framework.plist CFBundleShortVersionString $version disagrees with SDL_net.h $ref_version" 85 | #fi 86 | # 87 | #version=$(sed -Ene '/CFBundleVersion/,+1 s/.*(.*)<\/string>.*/\1/p' Xcode/Info-Framework.plist) 88 | # 89 | #if [ "$ref_version" = "$version" ]; then 90 | # ok "Info-Framework.plist CFBundleVersion $version" 91 | #else 92 | # not_ok "Info-Framework.plist CFBundleVersion $version disagrees with SDL_net.h $ref_version" 93 | #fi 94 | # 95 | ## For simplicity this assumes we'll never break ABI before SDL 3. 96 | #dylib_compat=$(sed -Ene 's/.*DYLIB_COMPATIBILITY_VERSION = (.*);$/\1/p' Xcode/SDL_net.xcodeproj/project.pbxproj) 97 | # 98 | #case "$ref_minor" in 99 | # (*[02468]) 100 | # major="$(( ref_minor * 100 + 1 ))" 101 | # minor="0" 102 | # ;; 103 | # (*) 104 | # major="$(( ref_minor * 100 + ref_micro + 1 ))" 105 | # minor="0" 106 | # ;; 107 | #esac 108 | # 109 | #ref="${major}.${minor}.0 110 | #${major}.${minor}.0" 111 | # 112 | #if [ "$ref" = "$dylib_compat" ]; then 113 | # ok "project.pbxproj DYLIB_COMPATIBILITY_VERSION is consistent" 114 | #else 115 | # not_ok "project.pbxproj DYLIB_COMPATIBILITY_VERSION is inconsistent, expected $ref, got $dylib_compat" 116 | #fi 117 | # 118 | #dylib_cur=$(sed -Ene 's/.*DYLIB_CURRENT_VERSION = (.*);$/\1/p' Xcode/SDL_net.xcodeproj/project.pbxproj) 119 | # 120 | #case "$ref_minor" in 121 | # (*[02468]) 122 | # major="$(( ref_minor * 100 + 1 ))" 123 | # minor="$ref_micro" 124 | # ;; 125 | # (*) 126 | # major="$(( ref_minor * 100 + ref_micro + 1 ))" 127 | # minor="0" 128 | # ;; 129 | #esac 130 | # 131 | #ref="${major}.${minor}.0 132 | #${major}.${minor}.0" 133 | # 134 | #if [ "$ref" = "$dylib_cur" ]; then 135 | # ok "project.pbxproj DYLIB_CURRENT_VERSION is consistent" 136 | #else 137 | # not_ok "project.pbxproj DYLIB_CURRENT_VERSION is inconsistent, expected $ref, got $dylib_cur" 138 | #fi 139 | 140 | echo "1..$tests" 141 | exit "$failed" 142 | -------------------------------------------------------------------------------- /cmake/GetGitRevisionDescription.cmake: -------------------------------------------------------------------------------- 1 | # - Returns a version string from Git 2 | # 3 | # These functions force a re-configure on each git commit so that you can 4 | # trust the values of the variables in your build system. 5 | # 6 | # get_git_head_revision( [ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR]) 7 | # 8 | # Returns the refspec and sha hash of the current head revision 9 | # 10 | # git_describe( [ ...]) 11 | # 12 | # Returns the results of git describe on the source tree, and adjusting 13 | # the output so that it tests false if an error occurs. 14 | # 15 | # git_describe_working_tree( [ ...]) 16 | # 17 | # Returns the results of git describe on the working tree (--dirty option), 18 | # and adjusting the output so that it tests false if an error occurs. 19 | # 20 | # git_get_exact_tag( [ ...]) 21 | # 22 | # Returns the results of git describe --exact-match on the source tree, 23 | # and adjusting the output so that it tests false if there was no exact 24 | # matching tag. 25 | # 26 | # git_local_changes() 27 | # 28 | # Returns either "CLEAN" or "DIRTY" with respect to uncommitted changes. 29 | # Uses the return code of "git diff-index --quiet HEAD --". 30 | # Does not regard untracked files. 31 | # 32 | # Requires CMake 2.6 or newer (uses the 'function' command) 33 | # 34 | # Original Author: 35 | # 2009-2020 Ryan Pavlik 36 | # http://academic.cleardefinition.com 37 | # 38 | # Copyright 2009-2013, Iowa State University. 39 | # Copyright 2013-2020, Ryan Pavlik 40 | # Copyright 2013-2020, Contributors 41 | # SPDX-License-Identifier: BSL-1.0 42 | # Distributed under the Boost Software License, Version 1.0. 43 | # (See accompanying file LICENSE_1_0.txt or copy at 44 | # http://www.boost.org/LICENSE_1_0.txt) 45 | 46 | if(__get_git_revision_description) 47 | return() 48 | endif() 49 | set(__get_git_revision_description YES) 50 | 51 | # We must run the following at "include" time, not at function call time, 52 | # to find the path to this module rather than the path to a calling list file 53 | get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH) 54 | 55 | # Function _git_find_closest_git_dir finds the next closest .git directory 56 | # that is part of any directory in the path defined by _start_dir. 57 | # The result is returned in the parent scope variable whose name is passed 58 | # as variable _git_dir_var. If no .git directory can be found, the 59 | # function returns an empty string via _git_dir_var. 60 | # 61 | # Example: Given a path C:/bla/foo/bar and assuming C:/bla/.git exists and 62 | # neither foo nor bar contain a file/directory .git. This will return 63 | # C:/bla/.git 64 | # 65 | function(_git_find_closest_git_dir _start_dir _git_dir_var) 66 | set(cur_dir "${_start_dir}") 67 | set(git_dir "${_start_dir}/.git") 68 | while(NOT EXISTS "${git_dir}") 69 | # .git dir not found, search parent directories 70 | set(git_previous_parent "${cur_dir}") 71 | get_filename_component(cur_dir "${cur_dir}" DIRECTORY) 72 | if(cur_dir STREQUAL git_previous_parent) 73 | # We have reached the root directory, we are not in git 74 | set(${_git_dir_var} 75 | "" 76 | PARENT_SCOPE) 77 | return() 78 | endif() 79 | set(git_dir "${cur_dir}/.git") 80 | endwhile() 81 | set(${_git_dir_var} 82 | "${git_dir}" 83 | PARENT_SCOPE) 84 | endfunction() 85 | 86 | function(get_git_head_revision _refspecvar _hashvar) 87 | _git_find_closest_git_dir("${CMAKE_CURRENT_SOURCE_DIR}" GIT_DIR) 88 | 89 | if("${ARGN}" STREQUAL "ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR") 90 | set(ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR TRUE) 91 | else() 92 | set(ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR FALSE) 93 | endif() 94 | if(NOT "${GIT_DIR}" STREQUAL "") 95 | file(RELATIVE_PATH _relative_to_source_dir "${CMAKE_SOURCE_DIR}" 96 | "${GIT_DIR}") 97 | if("${_relative_to_source_dir}" MATCHES "[.][.]" AND NOT ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR) 98 | # We've gone above the CMake root dir. 99 | set(GIT_DIR "") 100 | endif() 101 | endif() 102 | if("${GIT_DIR}" STREQUAL "") 103 | set(${_refspecvar} 104 | "GITDIR-NOTFOUND" 105 | PARENT_SCOPE) 106 | set(${_hashvar} 107 | "GITDIR-NOTFOUND" 108 | PARENT_SCOPE) 109 | return() 110 | endif() 111 | 112 | # Check if the current source dir is a git submodule or a worktree. 113 | # In both cases .git is a file instead of a directory. 114 | # 115 | if(NOT IS_DIRECTORY ${GIT_DIR}) 116 | # The following git command will return a non empty string that 117 | # points to the super project working tree if the current 118 | # source dir is inside a git submodule. 119 | # Otherwise the command will return an empty string. 120 | # 121 | execute_process( 122 | COMMAND "${GIT_EXECUTABLE}" rev-parse 123 | --show-superproject-working-tree 124 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" 125 | OUTPUT_VARIABLE out 126 | ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) 127 | if(NOT "${out}" STREQUAL "") 128 | # If out is empty, GIT_DIR/CMAKE_CURRENT_SOURCE_DIR is in a submodule 129 | file(READ ${GIT_DIR} submodule) 130 | string(REGEX REPLACE "gitdir: (.*)$" "\\1" GIT_DIR_RELATIVE 131 | ${submodule}) 132 | string(STRIP ${GIT_DIR_RELATIVE} GIT_DIR_RELATIVE) 133 | get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH) 134 | get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} 135 | ABSOLUTE) 136 | set(HEAD_SOURCE_FILE "${GIT_DIR}/HEAD") 137 | else() 138 | # GIT_DIR/CMAKE_CURRENT_SOURCE_DIR is in a worktree 139 | file(READ ${GIT_DIR} worktree_ref) 140 | # The .git directory contains a path to the worktree information directory 141 | # inside the parent git repo of the worktree. 142 | # 143 | string(REGEX REPLACE "gitdir: (.*)$" "\\1" git_worktree_dir 144 | ${worktree_ref}) 145 | string(STRIP ${git_worktree_dir} git_worktree_dir) 146 | _git_find_closest_git_dir("${git_worktree_dir}" GIT_DIR) 147 | set(HEAD_SOURCE_FILE "${git_worktree_dir}/HEAD") 148 | endif() 149 | else() 150 | set(HEAD_SOURCE_FILE "${GIT_DIR}/HEAD") 151 | endif() 152 | set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data") 153 | if(NOT EXISTS "${GIT_DATA}") 154 | file(MAKE_DIRECTORY "${GIT_DATA}") 155 | endif() 156 | 157 | if(NOT EXISTS "${HEAD_SOURCE_FILE}") 158 | return() 159 | endif() 160 | set(HEAD_FILE "${GIT_DATA}/HEAD") 161 | configure_file("${HEAD_SOURCE_FILE}" "${HEAD_FILE}" COPYONLY) 162 | 163 | configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in" 164 | "${GIT_DATA}/grabRef.cmake" @ONLY) 165 | include("${GIT_DATA}/grabRef.cmake") 166 | 167 | set(${_refspecvar} 168 | "${HEAD_REF}" 169 | PARENT_SCOPE) 170 | set(${_hashvar} 171 | "${HEAD_HASH}" 172 | PARENT_SCOPE) 173 | endfunction() 174 | 175 | function(git_describe _var) 176 | if(NOT GIT_FOUND) 177 | find_package(Git QUIET) 178 | endif() 179 | get_git_head_revision(refspec hash) 180 | if(NOT GIT_FOUND) 181 | set(${_var} 182 | "GIT-NOTFOUND" 183 | PARENT_SCOPE) 184 | return() 185 | endif() 186 | if(NOT hash) 187 | set(${_var} 188 | "HEAD-HASH-NOTFOUND" 189 | PARENT_SCOPE) 190 | return() 191 | endif() 192 | 193 | # TODO sanitize 194 | #if((${ARGN}" MATCHES "&&") OR 195 | # (ARGN MATCHES "||") OR 196 | # (ARGN MATCHES "\\;")) 197 | # message("Please report the following error to the project!") 198 | # message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}") 199 | #endif() 200 | 201 | #message(STATUS "Arguments to execute_process: ${ARGN}") 202 | 203 | execute_process( 204 | COMMAND "${GIT_EXECUTABLE}" describe --tags --always ${hash} ${ARGN} 205 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" 206 | RESULT_VARIABLE res 207 | OUTPUT_VARIABLE out 208 | ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) 209 | if(NOT res EQUAL 0) 210 | set(out "${out}-${res}-NOTFOUND") 211 | endif() 212 | 213 | set(${_var} 214 | "${out}" 215 | PARENT_SCOPE) 216 | endfunction() 217 | 218 | function(git_describe_working_tree _var) 219 | if(NOT GIT_FOUND) 220 | find_package(Git QUIET) 221 | endif() 222 | if(NOT GIT_FOUND) 223 | set(${_var} 224 | "GIT-NOTFOUND" 225 | PARENT_SCOPE) 226 | return() 227 | endif() 228 | 229 | execute_process( 230 | COMMAND "${GIT_EXECUTABLE}" describe --dirty ${ARGN} 231 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" 232 | RESULT_VARIABLE res 233 | OUTPUT_VARIABLE out 234 | ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) 235 | if(NOT res EQUAL 0) 236 | set(out "${out}-${res}-NOTFOUND") 237 | endif() 238 | 239 | set(${_var} 240 | "${out}" 241 | PARENT_SCOPE) 242 | endfunction() 243 | 244 | function(git_get_exact_tag _var) 245 | git_describe(out --exact-match ${ARGN}) 246 | set(${_var} 247 | "${out}" 248 | PARENT_SCOPE) 249 | endfunction() 250 | 251 | function(git_local_changes _var) 252 | if(NOT GIT_FOUND) 253 | find_package(Git QUIET) 254 | endif() 255 | get_git_head_revision(refspec hash) 256 | if(NOT GIT_FOUND) 257 | set(${_var} 258 | "GIT-NOTFOUND" 259 | PARENT_SCOPE) 260 | return() 261 | endif() 262 | if(NOT hash) 263 | set(${_var} 264 | "HEAD-HASH-NOTFOUND" 265 | PARENT_SCOPE) 266 | return() 267 | endif() 268 | 269 | execute_process( 270 | COMMAND "${GIT_EXECUTABLE}" diff-index --quiet HEAD -- 271 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" 272 | RESULT_VARIABLE res 273 | OUTPUT_VARIABLE out 274 | ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) 275 | if(res EQUAL 0) 276 | set(${_var} 277 | "CLEAN" 278 | PARENT_SCOPE) 279 | else() 280 | set(${_var} 281 | "DIRTY" 282 | PARENT_SCOPE) 283 | endif() 284 | endfunction() 285 | -------------------------------------------------------------------------------- /cmake/GetGitRevisionDescription.cmake.in: -------------------------------------------------------------------------------- 1 | # 2 | # Internal file for GetGitRevisionDescription.cmake 3 | # 4 | # Requires CMake 2.6 or newer (uses the 'function' command) 5 | # 6 | # Original Author: 7 | # 2009-2010 Ryan Pavlik 8 | # http://academic.cleardefinition.com 9 | # Iowa State University HCI Graduate Program/VRAC 10 | # 11 | # Copyright 2009-2012, Iowa State University 12 | # Copyright 2011-2015, Contributors 13 | # Distributed under the Boost Software License, Version 1.0. 14 | # (See accompanying file LICENSE_1_0.txt or copy at 15 | # http://www.boost.org/LICENSE_1_0.txt) 16 | # SPDX-License-Identifier: BSL-1.0 17 | 18 | set(HEAD_HASH) 19 | 20 | file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024) 21 | 22 | string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) 23 | if(HEAD_CONTENTS MATCHES "ref") 24 | # named branch 25 | string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}") 26 | if(EXISTS "@GIT_DIR@/${HEAD_REF}") 27 | configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) 28 | else() 29 | configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY) 30 | file(READ "@GIT_DATA@/packed-refs" PACKED_REFS) 31 | if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}") 32 | set(HEAD_HASH "${CMAKE_MATCH_1}") 33 | endif() 34 | endif() 35 | else() 36 | # detached HEAD 37 | configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY) 38 | endif() 39 | 40 | if(NOT HEAD_HASH) 41 | file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024) 42 | string(STRIP "${HEAD_HASH}" HEAD_HASH) 43 | endif() 44 | -------------------------------------------------------------------------------- /cmake/PrivateSdlFunctions.cmake: -------------------------------------------------------------------------------- 1 | # This file is shared amongst SDL_image/SDL_mixer/SDL_ttf 2 | 3 | include(CheckCCompilerFlag) 4 | include(CheckCSourceCompiles) 5 | include(CMakePushCheckState) 6 | 7 | macro(sdl_calculate_derived_version_variables MAJOR MINOR MICRO) 8 | set(SO_VERSION_MAJOR "0") 9 | set(SO_VERSION_MINOR "${MINOR_VERSION}") 10 | set(SO_VERSION_MICRO "${MICRO_VERSION}") 11 | set(SO_VERSION "${SO_VERSION_MAJOR}.${SO_VERSION_MINOR}.${SO_VERSION_MICRO}") 12 | 13 | if(MINOR MATCHES "[02468]$") 14 | math(EXPR DYLIB_COMPAT_VERSION_MAJOR "100 * ${MINOR} + 1") 15 | set(DYLIB_COMPAT_VERSION_MINOR "0") 16 | math(EXPR DYLIB_CURRENT_VERSION_MAJOR "${DYLIB_COMPAT_VERSION_MAJOR}") 17 | set(DYLIB_CURRENT_VERSION_MINOR "${MICRO}") 18 | else() 19 | math(EXPR DYLIB_COMPAT_VERSION_MAJOR "100 * ${MINOR} + ${MICRO} + 1") 20 | set(DYLIB_COMPAT_VERSION_MINOR "0") 21 | math(EXPR DYLIB_CURRENT_VERSION_MAJOR "${DYLIB_COMPAT_VERSION_MAJOR}") 22 | set(DYLIB_CURRENT_VERSION_MINOR "0") 23 | endif() 24 | set(DYLIB_COMPAT_VERSION_MICRO "0") 25 | set(DYLIB_CURRENT_VERSION_MICRO "0") 26 | 27 | set(DYLIB_CURRENT_VERSION "${DYLIB_CURRENT_VERSION_MAJOR}.${DYLIB_CURRENT_VERSION_MINOR}.${DYLIB_CURRENT_VERSION_MICRO}") 28 | set(DYLIB_COMPAT_VERSION "${DYLIB_COMPAT_VERSION_MAJOR}.${DYLIB_COMPAT_VERSION_MINOR}.${DYLIB_COMPAT_VERSION_MICRO}") 29 | endmacro() 30 | 31 | function(read_absolute_symlink DEST PATH) 32 | file(READ_SYMLINK "${PATH}" p) 33 | if(NOT IS_ABSOLUTE "${p}") 34 | get_filename_component(pdir "${PATH}" DIRECTORY) 35 | set(p "${pdir}/${p}") 36 | endif() 37 | get_filename_component(p "${p}" ABSOLUTE) 38 | set("${DEST}" "${p}" PARENT_SCOPE) 39 | endfunction() 40 | 41 | function(win32_implib_identify_dll DEST IMPLIB) 42 | cmake_parse_arguments(ARGS "NOTFATAL" "" "" ${ARGN}) 43 | if(CMAKE_DLLTOOL) 44 | execute_process( 45 | COMMAND "${CMAKE_DLLTOOL}" --identify "${IMPLIB}" 46 | RESULT_VARIABLE retcode 47 | OUTPUT_VARIABLE stdout 48 | ERROR_VARIABLE stderr) 49 | if(NOT retcode EQUAL 0) 50 | if(NOT ARGS_NOTFATAL) 51 | message(FATAL_ERROR "${CMAKE_DLLTOOL} failed.") 52 | else() 53 | set("${DEST}" "${DEST}-NOTFOUND" PARENT_SCOPE) 54 | return() 55 | endif() 56 | endif() 57 | string(STRIP "${stdout}" result) 58 | set(${DEST} "${result}" PARENT_SCOPE) 59 | elseif(MSVC) 60 | get_filename_component(CMAKE_C_COMPILER_DIRECTORY "${CMAKE_C_COMPILER}" DIRECTORY CACHE) 61 | find_program(CMAKE_DUMPBIN NAMES dumpbin PATHS "${CMAKE_C_COMPILER_DIRECTORY}") 62 | if(CMAKE_DUMPBIN) 63 | execute_process( 64 | COMMAND "${CMAKE_DUMPBIN}" "-headers" "${IMPLIB}" 65 | RESULT_VARIABLE retcode 66 | OUTPUT_VARIABLE stdout 67 | ERROR_VARIABLE stderr) 68 | if(NOT retcode EQUAL 0) 69 | if(NOT ARGS_NOTFATAL) 70 | message(FATAL_ERROR "dumpbin failed.") 71 | else() 72 | set(${DEST} "${DEST}-NOTFOUND" PARENT_SCOPE) 73 | return() 74 | endif() 75 | endif() 76 | string(REGEX MATCH "DLL name[ ]+:[ ]+([^\n]+)\n" match "${stdout}") 77 | if(NOT match) 78 | if(NOT ARGS_NOTFATAL) 79 | message(FATAL_ERROR "dumpbin did not find any associated dll for ${IMPLIB}.") 80 | else() 81 | set(${DEST} "${DEST}-NOTFOUND" PARENT_SCOPE) 82 | return() 83 | endif() 84 | endif() 85 | set(result "${CMAKE_MATCH_1}") 86 | set(${DEST} "${result}" PARENT_SCOPE) 87 | else() 88 | message(FATAL_ERROR "Cannot find dumpbin, please set CMAKE_DUMPBIN cmake variable") 89 | endif() 90 | else() 91 | if(NOT ARGS_NOTFATAL) 92 | message(FATAL_ERROR "Don't know how to identify dll from import library. Set CMAKE_DLLTOOL (for mingw) or CMAKE_DUMPBIN (for MSVC)") 93 | else() 94 | set(${DEST} "${DEST}-NOTFOUND") 95 | endif() 96 | endif() 97 | endfunction() 98 | 99 | function(get_actual_target) 100 | set(dst "${ARGV0}") 101 | set(target "${${dst}}") 102 | set(input "${target}") 103 | get_target_property(alias "${target}" ALIASED_TARGET) 104 | while(alias) 105 | set(target "${alias}") 106 | get_target_property(alias "${target}" ALIASED_TARGET) 107 | endwhile() 108 | message(DEBUG "get_actual_target(\"${input}\") -> \"${target}\"") 109 | set("${dst}" "${target}" PARENT_SCOPE) 110 | endfunction() 111 | 112 | function(target_get_dynamic_library DEST TARGET) 113 | set(result) 114 | get_actual_target(TARGET) 115 | if(WIN32) 116 | # Use the target dll of the import library 117 | set(props_to_check IMPORTED_IMPLIB) 118 | if(CMAKE_BUILD_TYPE) 119 | list(APPEND props_to_check IMPORTED_IMPLIB_${CMAKE_BUILD_TYPE}) 120 | endif() 121 | list(APPEND props_to_check IMPORTED_LOCATION) 122 | if(CMAKE_BUILD_TYPE) 123 | list(APPEND props_to_check IMPORTED_LOCATION_${CMAKE_BUILD_TYPE}) 124 | endif() 125 | foreach (config_type ${CMAKE_CONFIGURATION_TYPES} RELEASE DEBUG RELWITHDEBINFO MINSIZEREL) 126 | list(APPEND props_to_check IMPORTED_IMPLIB_${config_type}) 127 | list(APPEND props_to_check IMPORTED_LOCATION_${config_type}) 128 | endforeach() 129 | 130 | foreach(prop_to_check ${props_to_check}) 131 | if(NOT result) 132 | get_target_property(propvalue "${TARGET}" ${prop_to_check}) 133 | if(propvalue AND EXISTS "${propvalue}") 134 | win32_implib_identify_dll(result "${propvalue}" NOTFATAL) 135 | endif() 136 | endif() 137 | endforeach() 138 | else() 139 | # 1. find the target library a file might be symbolic linking to 140 | # 2. find all other files in the same folder that symolic link to it 141 | # 3. sort all these files, and select the 1st item on Linux, and last on Macos 142 | set(location_properties IMPORTED_LOCATION) 143 | if(CMAKE_BUILD_TYPE) 144 | list(APPEND location_properties IMPORTED_LOCATION_${CMAKE_BUILD_TYPE}) 145 | endif() 146 | foreach (config_type ${CMAKE_CONFIGURATION_TYPES} RELEASE DEBUG RELWITHDEBINFO MINSIZEREL) 147 | list(APPEND location_properties IMPORTED_LOCATION_${config_type}) 148 | endforeach() 149 | if(APPLE) 150 | set(valid_shared_library_regex "\\.[0-9]+\\.dylib$") 151 | else() 152 | set(valid_shared_library_regex "\\.so\\.([0-9.]+)?[0-9]") 153 | endif() 154 | foreach(location_property ${location_properties}) 155 | if(NOT result) 156 | get_target_property(library_path "${TARGET}" ${location_property}) 157 | message(DEBUG "get_target_property(${TARGET} ${location_propert}) -> ${library_path}") 158 | if(EXISTS "${library_path}") 159 | get_filename_component(library_path "${library_path}" ABSOLUTE) 160 | while (IS_SYMLINK "${library_path}") 161 | read_absolute_symlink(library_path "${library_path}") 162 | endwhile() 163 | message(DEBUG "${TARGET} -> ${library_path}") 164 | get_filename_component(libdir "${library_path}" DIRECTORY) 165 | file(GLOB subfiles "${libdir}/*") 166 | set(similar_files "${library_path}") 167 | foreach(subfile ${subfiles}) 168 | if(IS_SYMLINK "${subfile}") 169 | read_absolute_symlink(subfile_target "${subfile}") 170 | while(IS_SYMLINK "${subfile_target}") 171 | read_absolute_symlink(subfile_target "${subfile_target}") 172 | endwhile() 173 | get_filename_component(subfile_target "${subfile_target}" ABSOLUTE) 174 | if(subfile_target STREQUAL library_path AND subfile MATCHES "${valid_shared_library_regex}") 175 | list(APPEND similar_files "${subfile}") 176 | endif() 177 | endif() 178 | endforeach() 179 | list(SORT similar_files) 180 | message(DEBUG "files that are similar to \"${library_path}\"=${similar_files}") 181 | if(APPLE) 182 | list(REVERSE similar_files) 183 | endif() 184 | list(GET similar_files 0 item) 185 | get_filename_component(result "${item}" NAME) 186 | endif() 187 | endif() 188 | endforeach() 189 | endif() 190 | if(result) 191 | string(TOLOWER "${result}" result_lower) 192 | if(WIN32 OR OS2) 193 | if(NOT result_lower MATCHES ".*dll") 194 | message(FATAL_ERROR "\"${result}\" is not a .dll library") 195 | endif() 196 | elseif(APPLE) 197 | if(NOT result_lower MATCHES ".*dylib.*") 198 | message(FATAL_ERROR "\"${result}\" is not a .dylib shared library") 199 | endif() 200 | else() 201 | if(NOT result_lower MATCHES ".*so.*") 202 | message(FATAL_ERROR "\"${result}\" is not a .so shared library") 203 | endif() 204 | endif() 205 | else() 206 | get_target_property(target_type ${TARGET} TYPE) 207 | if(target_type MATCHES "SHARED_LIBRARY|MODULE_LIBRARY") 208 | # OK 209 | elseif(target_type MATCHES "STATIC_LIBRARY|OBJECT_LIBRARY|INTERFACE_LIBRARY|EXECUTABLE") 210 | message(SEND_ERROR "${TARGET} is not a shared library, but has type=${target_type}") 211 | else() 212 | message(WARNING "Unable to extract dynamic library from target=${TARGET}, type=${target_type}.") 213 | endif() 214 | # TARGET_SONAME_FILE is not allowed for DLL target platforms. 215 | if(WIN32) 216 | set(result "$") 217 | else() 218 | set(result "$") 219 | endif() 220 | endif() 221 | set(${DEST} ${result} PARENT_SCOPE) 222 | endfunction() 223 | 224 | function(sdl_check_project_in_subfolder relative_subfolder name vendored_option) 225 | cmake_parse_arguments(ARG "" "FILE" "" ${ARGN}) 226 | if(NOT ARG_FILE) 227 | set(ARG_FILE "CMakeLists.txt") 228 | endif() 229 | if(NOT EXISTS "${PROJECT_SOURCE_DIR}/${relative_subfolder}/${ARG_FILE}") 230 | message(FATAL_ERROR "Could not find ${ARG_FILE} for ${name} in ${relative_subfolder}.\n" 231 | "Run the download script in the external folder, or re-configure with -D${vendored_option}=OFF to use system packages.") 232 | endif() 233 | endfunction() 234 | 235 | macro(sdl_check_linker_flag flag var) 236 | # FIXME: Use CheckLinkerFlag module once cmake minimum version >= 3.18 237 | cmake_push_check_state(RESET) 238 | set(CMAKE_REQUIRED_LINK_OPTIONS "${flag}") 239 | check_c_source_compiles("int main() { return 0; }" ${var} FAIL_REGEX "(unsupported|syntax error|unrecognized option)") 240 | cmake_pop_check_state() 241 | endmacro() 242 | 243 | function(SDL_detect_linker) 244 | if(CMAKE_VERSION VERSION_LESS 3.29) 245 | if(NOT DEFINED SDL_CMAKE_C_COMPILER_LINKER_ID) 246 | execute_process(COMMAND ${CMAKE_LINKER} -v OUTPUT_VARIABLE LINKER_OUTPUT ERROR_VARIABLE LINKER_OUTPUT) 247 | string(REGEX REPLACE "[\r\n]" " " LINKER_OUTPUT "${LINKER_OUTPUT}") 248 | if(LINKER_OUTPUT MATCHES ".*Microsoft.*") 249 | set(linker MSVC) 250 | else() 251 | set(linker GNUlike) 252 | endif() 253 | message(STATUS "Linker identification: ${linker}") 254 | set(SDL_CMAKE_C_COMPILER_LINKER_ID "${linker}" CACHE STRING "Linker identification") 255 | mark_as_advanced(SDL_CMAKE_C_COMPILER_LINKER_ID) 256 | endif() 257 | set(CMAKE_C_COMPILER_LINKER_ID "${SDL_CMAKE_C_COMPILER_LINKER_ID}" PARENT_SCOPE) 258 | endif() 259 | endfunction() 260 | 261 | function(check_linker_support_version_script VAR) 262 | SDL_detect_linker() 263 | if(CMAKE_C_COMPILER_LINKER_ID MATCHES "^(MSVC)$") 264 | set(LINKER_SUPPORTS_VERSION_SCRIPT FALSE) 265 | else() 266 | cmake_push_check_state(RESET) 267 | file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/dummy.sym" "n_0 {\n global:\n func;\n local: *;\n};\n") 268 | list(APPEND CMAKE_REQUIRED_LINK_OPTIONS "-Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/dummy.sym") 269 | check_c_source_compiles("int func(void) {return 0;} int main(int argc,char*argv[]){(void)argc;(void)argv;return func();}" LINKER_SUPPORTS_VERSION_SCRIPT FAIL_REGEX "(unsupported|syntax error|unrecognized option)") 270 | cmake_pop_check_state() 271 | endif() 272 | set(${VAR} "${LINKER_SUPPORTS_VERSION_SCRIPT}" PARENT_SCOPE) 273 | endfunction() 274 | 275 | function(sdl_target_link_options_no_undefined TARGET) 276 | if(NOT MSVC AND NOT CMAKE_SYSTEM_NAME MATCHES ".*OpenBSD.*") 277 | if(CMAKE_C_COMPILER_ID MATCHES "AppleClang") 278 | target_link_options(${TARGET} PRIVATE "-Wl,-undefined,error") 279 | else() 280 | sdl_check_linker_flag("-Wl,--no-undefined" HAVE_WL_NO_UNDEFINED) 281 | if(HAVE_WL_NO_UNDEFINED AND NOT ((CMAKE_C_COMPILER_ID MATCHES "Clang") AND WIN32)) 282 | target_link_options(${TARGET} PRIVATE "-Wl,--no-undefined") 283 | endif() 284 | endif() 285 | endif() 286 | endfunction() 287 | 288 | function(sdl_target_link_option_version_file TARGET VERSION_SCRIPT) 289 | check_linker_support_version_script(HAVE_WL_VERSION_SCRIPT) 290 | if(HAVE_WL_VERSION_SCRIPT) 291 | target_link_options(${TARGET} PRIVATE "-Wl,--version-script=${VERSION_SCRIPT}") 292 | set_property(TARGET ${TARGET} APPEND PROPERTY LINK_DEPENDS "${VERSION_SCRIPT}") 293 | else() 294 | if(LINUX OR ANDROID) 295 | message(FATAL_ERROR "Linker does not support '-Wl,--version-script=xxx.sym'. This is required on the current host platform.") 296 | endif() 297 | endif() 298 | endfunction() 299 | 300 | function(sdl_add_warning_options TARGET) 301 | cmake_parse_arguments(ARGS "" "WARNING_AS_ERROR" "" ${ARGN}) 302 | if(MSVC) 303 | target_compile_options(${TARGET} PRIVATE /W2) 304 | else() 305 | target_compile_options(${TARGET} PRIVATE -Wall -Wextra) 306 | endif() 307 | if(ARGS_WARNING_AS_ERROR) 308 | if(MSVC) 309 | target_compile_options(${TARGET} PRIVATE /WX) 310 | else() 311 | target_compile_options(${TARGET} PRIVATE -Werror) 312 | endif() 313 | endif() 314 | endfunction() 315 | 316 | function(sdl_no_deprecated_errors TARGET) 317 | check_c_compiler_flag(-Wno-error=deprecated-declarations HAVE_WNO_ERROR_DEPRECATED_DECLARATIONS) 318 | if(HAVE_WNO_ERROR_DEPRECATED_DECLARATIONS) 319 | target_compile_options(${TARGET} PRIVATE "-Wno-error=deprecated-declarations") 320 | endif() 321 | endfunction() 322 | 323 | function(sdl_get_git_revision_hash VARNAME) 324 | set("${VARNAME}" "" CACHE STRING "${PROJECT_NAME} revision") 325 | set(revision "${${VARNAME}}") 326 | if(NOT revision) 327 | if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/VERSION.txt") 328 | # If VERSION.txt exists, it contains the SDL version 329 | file(READ "${CMAKE_CURRENT_SOURCE_DIR}/VERSION.txt" revision_version) 330 | string(STRIP "${revision_version}" revision_version) 331 | else() 332 | # If VERSION.txt does not exist, use git to calculate a version 333 | git_describe(revision_version) 334 | if(NOT revision_version) 335 | set(revision_version "${PROJECT_VERSION}-no-vcs") 336 | endif() 337 | endif() 338 | set(revision "${revision_version}") 339 | endif() 340 | set("${VARNAME}" "${revision}" PARENT_SCOPE) 341 | endfunction() 342 | 343 | function(SDL_install_pdb TARGET DIRECTORY) 344 | get_property(type TARGET ${TARGET} PROPERTY TYPE) 345 | if(type MATCHES "^(SHARED_LIBRARY|EXECUTABLE)$") 346 | install(FILES $ DESTINATION "${DIRECTORY}" OPTIONAL) 347 | elseif(type STREQUAL "STATIC_LIBRARY") 348 | # FIXME: Use $= @SDL_REQUIRED_VERSION@ 10 | Libs: -L${libdir} -lSDL3_net 11 | Requires.private: @PC_REQUIRES@ 12 | Libs.private: @PC_LIBS@ 13 | Cflags: -I${includedir} 14 | -------------------------------------------------------------------------------- /cmake/sdlcpu.cmake: -------------------------------------------------------------------------------- 1 | function(SDL_DetectTargetCPUArchitectures DETECTED_ARCHS) 2 | 3 | set(known_archs EMSCRIPTEN ARM32 ARM64 ARM64EC LOONGARCH64 POWERPC32 POWERPC64 X86 X64) 4 | 5 | if(APPLE AND CMAKE_OSX_ARCHITECTURES) 6 | foreach(known_arch IN LISTS known_archs) 7 | set(SDL_CPU_${known_arch} "0") 8 | endforeach() 9 | set(detected_archs) 10 | foreach(osx_arch IN LISTS CMAKE_OSX_ARCHITECTURES) 11 | if(osx_arch STREQUAL "x86_64") 12 | set(SDL_CPU_X64 "1") 13 | list(APPEND detected_archs "X64") 14 | elseif(osx_arch STREQUAL "arm64") 15 | set(SDL_CPU_ARM64 "1") 16 | list(APPEND detected_archs "ARM64") 17 | endif() 18 | endforeach() 19 | set("${DETECTED_ARCHS}" "${detected_archs}" PARENT_SCOPE) 20 | return() 21 | endif() 22 | 23 | set(detected_archs) 24 | foreach(known_arch IN LISTS known_archs) 25 | if(SDL_CPU_${known_arch}) 26 | list(APPEND detected_archs "${known_arch}") 27 | endif() 28 | endforeach() 29 | 30 | if(detected_archs) 31 | set("${DETECTED_ARCHS}" "${detected_archs}" PARENT_SCOPE) 32 | return() 33 | endif() 34 | 35 | set(arch_check_ARM32 "defined(__arm__) || defined(_M_ARM)") 36 | set(arch_check_ARM64 "defined(__aarch64__) || defined(_M_ARM64)") 37 | set(arch_check_ARM64EC "defined(_M_ARM64EC)") 38 | set(arch_check_EMSCRIPTEN "defined(__EMSCRIPTEN__)") 39 | set(arch_check_LOONGARCH64 "defined(__loongarch64)") 40 | set(arch_check_POWERPC32 "(defined(__PPC__) || defined(__powerpc__)) && !defined(__powerpc64__)") 41 | set(arch_check_POWERPC64 "defined(__PPC64__) || defined(__powerpc64__)") 42 | set(arch_check_X86 "defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) ||defined( __i386) || defined(_M_IX86)") 43 | set(arch_check_X64 "(defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64)) && !defined(_M_ARM64EC)") 44 | 45 | set(src_vars "") 46 | set(src_main "") 47 | foreach(known_arch IN LISTS known_archs) 48 | set(detected_${known_arch} "0") 49 | 50 | string(APPEND src_vars " 51 | #if ${arch_check_${known_arch}} 52 | #define ARCH_${known_arch} \"1\" 53 | #else 54 | #define ARCH_${known_arch} \"0\" 55 | #endif 56 | const char *arch_${known_arch} = \"INFO<${known_arch}=\" ARCH_${known_arch} \">\"; 57 | ") 58 | string(APPEND src_main " 59 | result += arch_${known_arch}[argc];") 60 | endforeach() 61 | 62 | set(src_arch_detect "${src_vars} 63 | int main(int argc, char *argv[]) { 64 | int result = 0; 65 | (void)argv; 66 | ${src_main} 67 | return result; 68 | }") 69 | 70 | if(CMAKE_C_COMPILER) 71 | set(ext ".c") 72 | elseif(CMAKE_CXX_COMPILER) 73 | set(ext ".cpp") 74 | else() 75 | enable_language(C) 76 | set(ext ".c") 77 | endif() 78 | set(path_src_arch_detect "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CMakeTmp/SDL_detect_arch${ext}") 79 | file(WRITE "${path_src_arch_detect}" "${src_arch_detect}") 80 | set(path_dir_arch_detect "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CMakeTmp/SDL_detect_arch") 81 | set(path_bin_arch_detect "${path_dir_arch_detect}/bin") 82 | 83 | set(detected_archs) 84 | 85 | set(msg "Detecting Target CPU Architecture") 86 | message(STATUS "${msg}") 87 | 88 | include(CMakePushCheckState) 89 | 90 | set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY") 91 | 92 | cmake_push_check_state(RESET) 93 | try_compile(SDL_CPU_CHECK_ALL 94 | "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CMakeTmp/SDL_detect_arch" 95 | SOURCES "${path_src_arch_detect}" 96 | COPY_FILE "${path_bin_arch_detect}" 97 | ) 98 | cmake_pop_check_state() 99 | if(NOT SDL_CPU_CHECK_ALL) 100 | message(STATUS "${msg} - ") 101 | message(WARNING "Failed to compile source detecting the target CPU architecture") 102 | else() 103 | set(re "INFO<([A-Z0-9]+)=([01])>") 104 | file(STRINGS "${path_bin_arch_detect}" infos REGEX "${re}") 105 | 106 | foreach(info_arch_01 IN LISTS infos) 107 | string(REGEX MATCH "${re}" A "${info_arch_01}") 108 | if(NOT "${CMAKE_MATCH_1}" IN_LIST known_archs) 109 | message(WARNING "Unknown architecture: \"${CMAKE_MATCH_1}\"") 110 | continue() 111 | endif() 112 | set(arch "${CMAKE_MATCH_1}") 113 | set(arch_01 "${CMAKE_MATCH_2}") 114 | set(detected_${arch} "${arch_01}") 115 | endforeach() 116 | 117 | foreach(known_arch IN LISTS known_archs) 118 | if(detected_${known_arch}) 119 | list(APPEND detected_archs ${known_arch}) 120 | endif() 121 | endforeach() 122 | endif() 123 | 124 | if(detected_archs) 125 | foreach(known_arch IN LISTS known_archs) 126 | set("SDL_CPU_${known_arch}" "${detected_${known_arch}}" CACHE BOOL "Detected architecture ${known_arch}") 127 | endforeach() 128 | message(STATUS "${msg} - ${detected_archs}") 129 | else() 130 | include(CheckCSourceCompiles) 131 | cmake_push_check_state(RESET) 132 | foreach(known_arch IN LISTS known_archs) 133 | if(NOT detected_archs) 134 | set(cache_variable "SDL_CPU_${known_arch}") 135 | set(test_src " 136 | int main(int argc, char *argv[]) { 137 | #if ${arch_check_${known_arch}} 138 | return 0; 139 | #else 140 | choke 141 | #endif 142 | } 143 | ") 144 | check_c_source_compiles("${test_src}" "${cache_variable}") 145 | if(${cache_variable}) 146 | set(SDL_CPU_${known_arch} "1" CACHE BOOL "Detected architecture ${known_arch}") 147 | set(detected_archs ${known_arch}) 148 | else() 149 | set(SDL_CPU_${known_arch} "0" CACHE BOOL "Detected architecture ${known_arch}") 150 | endif() 151 | endif() 152 | endforeach() 153 | cmake_pop_check_state() 154 | endif() 155 | set("${DETECTED_ARCHS}" "${detected_archs}" PARENT_SCOPE) 156 | endfunction() 157 | -------------------------------------------------------------------------------- /cmake/sdlmanpages.cmake: -------------------------------------------------------------------------------- 1 | include(CMakeParseArguments) 2 | include(GNUInstallDirs) 3 | 4 | function(SDL_generate_manpages) 5 | cmake_parse_arguments(ARG "" "RESULT_VARIABLE;NAME;BUILD_DOCDIR;HEADERS_DIR;SOURCE_DIR;SYMBOL;OPTION_FILE;WIKIHEADERS_PL_PATH;REVISION" "" ${ARGN}) 6 | 7 | set(wikiheaders_extra_args) 8 | 9 | if(NOT ARG_NAME) 10 | set(ARG_NAME "${PROJECT_NAME}") 11 | endif() 12 | 13 | if(NOT ARG_SOURCE_DIR) 14 | set(ARG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") 15 | endif() 16 | 17 | if(NOT ARG_OPTION_FILE) 18 | set(ARG_OPTION_FILE "${PROJECT_SOURCE_DIR}/.wikiheaders-options") 19 | endif() 20 | 21 | if(NOT ARG_HEADERS_DIR) 22 | message(FATAL_ERROR "Missing required HEADERS_DIR argument") 23 | endif() 24 | 25 | # FIXME: get rid of SYMBOL and let the perl script figure out the dependencies 26 | if(NOT ARG_SYMBOL) 27 | message(FATAL_ERROR "Missing required SYMBOL argument") 28 | endif() 29 | 30 | if(ARG_REVISION) 31 | list(APPEND wikiheaders_extra_args "--rev=${ARG_REVISION}") 32 | endif() 33 | 34 | if(NOT ARG_BUILD_DOCDIR) 35 | set(ARG_BUILD_DOCDIR "${CMAKE_CURRENT_BINARY_DIR}/docs") 36 | endif() 37 | set(BUILD_WIKIDIR "${ARG_BUILD_DOCDIR}/wiki") 38 | set(BUILD_MANDIR "${ARG_BUILD_DOCDIR}/man") 39 | 40 | find_package(Perl) 41 | file(GLOB HEADER_FILES "${ARG_HEADERS_DIR}/*.h") 42 | 43 | set(result FALSE) 44 | 45 | if(PERL_FOUND AND EXISTS "${ARG_WIKIHEADERS_PL_PATH}") 46 | add_custom_command( 47 | OUTPUT "${BUILD_WIKIDIR}/${ARG_SYMBOL}.md" 48 | COMMAND "${CMAKE_COMMAND}" -E make_directory "${BUILD_WIKIDIR}" 49 | COMMAND "${PERL_EXECUTABLE}" "${ARG_WIKIHEADERS_PL_PATH}" "${ARG_SOURCE_DIR}" "${BUILD_WIKIDIR}" "--options=${ARG_OPTION_FILE}" --copy-to-wiki ${wikiheaders_extra_args} 50 | DEPENDS ${HEADER_FILES} "${ARG_WIKIHEADERS_PL_PATH}" "${ARG_OPTION_FILE}" 51 | COMMENT "Generating ${ARG_NAME} wiki markdown files" 52 | ) 53 | add_custom_command( 54 | OUTPUT "${BUILD_MANDIR}/man3/${ARG_SYMBOL}.3" 55 | COMMAND "${PERL_EXECUTABLE}" "${ARG_WIKIHEADERS_PL_PATH}" "${ARG_SOURCE_DIR}" "${BUILD_WIKIDIR}" "--options=${ARG_OPTION_FILE}" "--manpath=${BUILD_MANDIR}" --copy-to-manpages ${wikiheaders_extra_args} 56 | DEPENDS "${BUILD_WIKIDIR}/${ARG_SYMBOL}.md" "${ARG_WIKIHEADERS_PL_PATH}" "${ARG_OPTION_FILE}" 57 | COMMENT "Generating ${ARG_NAME} man pages" 58 | ) 59 | add_custom_target(${ARG_NAME}-docs ALL DEPENDS "${BUILD_MANDIR}/man3/${ARG_SYMBOL}.3") 60 | 61 | install(DIRECTORY "${BUILD_MANDIR}/" DESTINATION "${CMAKE_INSTALL_MANDIR}") 62 | set(result TRUE) 63 | endif() 64 | 65 | if(ARG_RESULT_VARIABLE) 66 | set(${ARG_RESULT_VARIABLE} ${result} PARENT_SCOPE) 67 | endif() 68 | endfunction() 69 | -------------------------------------------------------------------------------- /cmake/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This cmake build script is meant for verifying the various CMake configuration script. 2 | 3 | cmake_minimum_required(VERSION 3.12...3.28) 4 | project(sdl_test LANGUAGES C) 5 | 6 | cmake_policy(SET CMP0074 NEW) 7 | 8 | # Override CMAKE_FIND_ROOT_PATH_MODE to allow search for SDL3 outside of sysroot 9 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE NEVER) 10 | 11 | include(FeatureSummary) 12 | 13 | option(TEST_SHARED "Test linking to shared SDL3_net library" ON) 14 | add_feature_info("TEST_SHARED" TEST_SHARED "Test linking with shared library") 15 | 16 | option(TEST_STATIC "Test linking to static SDL3_net library" ON) 17 | add_feature_info("TEST_STATIC" TEST_STATIC "Test linking with static library") 18 | 19 | if(ANDROID) 20 | macro(add_executable NAME) 21 | set(args ${ARGN}) 22 | list(REMOVE_ITEM args WIN32) 23 | add_library(${NAME} SHARED ${args}) 24 | unset(args) 25 | endmacro() 26 | endif() 27 | 28 | if(TEST_SHARED) 29 | find_package(SDL3 REQUIRED CONFIG COMPONENTS SDL3) 30 | find_package(SDL3_net REQUIRED CONFIG) 31 | add_executable(main_shared main.c) 32 | target_link_libraries(main_shared PRIVATE SDL3_net::SDL3_net-shared SDL3::SDL3) 33 | endif() 34 | 35 | if(TEST_STATIC) 36 | find_package(SDL3 REQUIRED CONFIG COMPONENTS SDL3) 37 | # some static vendored libraries use c++ (enable CXX after `find_package` might show a warning) 38 | enable_language(CXX) 39 | find_package(SDL3_net REQUIRED CONFIG) 40 | add_executable(main_static main.c) 41 | target_link_libraries(main_static PRIVATE SDL3_net::SDL3_net-static SDL3::SDL3) 42 | endif() 43 | 44 | feature_summary(WHAT ALL) 45 | -------------------------------------------------------------------------------- /cmake/test/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | if (!SDL_Init(0)) { 8 | SDL_Log("SDL_Init(0) failed: %s", SDL_GetError()); 9 | return 1; 10 | } 11 | 12 | if (!NET_Init()) { 13 | SDL_Log("NET_Init() failed: %s", SDL_GetError()); 14 | } 15 | 16 | NET_Quit(); 17 | SDL_Quit(); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /examples/get-local-addrs.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This is just for demonstration purposes! This doesn't 3 | * do anything as complicated as, say, the `ifconfig` utility. 4 | * 5 | * All this to say: don't use this for anything serious! 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | int main(int argc, char **argv) 14 | { 15 | NET_Address **addrs = NULL; 16 | int num_addrs = 0; 17 | int i; 18 | 19 | (void)argc; 20 | (void)argv; 21 | 22 | if (!NET_Init()) { 23 | SDL_Log("NET_Init() failed: %s", SDL_GetError()); 24 | return 1; 25 | } 26 | 27 | addrs = NET_GetLocalAddresses(&num_addrs); 28 | if (addrs == NULL) { 29 | SDL_Log("Failed to determine local addresses: %s", SDL_GetError()); 30 | NET_Quit(); 31 | return 1; 32 | } 33 | 34 | SDL_Log("We saw %d local addresses:", num_addrs); 35 | for (i = 0; i < num_addrs; i++) { 36 | SDL_Log(" - %s", NET_GetAddressString(addrs[i])); 37 | } 38 | 39 | NET_FreeLocalAddresses(addrs); 40 | NET_Quit(); 41 | 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /examples/resolve-hostnames.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This is just for demonstration purposes! This doesn't 3 | * do anything as complicated as, say, the `dig` utility. 4 | * 5 | * All this to say: don't use this for anything serious! 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | int main(int argc, char **argv) 14 | { 15 | if (!NET_Init()) { 16 | SDL_Log("NET_Init() failed: %s", SDL_GetError()); 17 | return 1; 18 | } 19 | 20 | //NET_SimulateAddressResolutionLoss(3000, 30); 21 | 22 | NET_Address **addrs = (NET_Address **) SDL_calloc(argc, sizeof (NET_Address *)); 23 | for (int i = 1; i < argc; i++) { 24 | addrs[i] = NET_ResolveHostname(argv[i]); 25 | } 26 | 27 | for (int i = 1; i < argc; i++) { 28 | NET_WaitUntilResolved(addrs[i], -1); 29 | 30 | if (NET_GetAddressStatus(addrs[i]) == -1) { 31 | SDL_Log("%s: [FAILED TO RESOLVE: %s]", argv[i], SDL_GetError()); 32 | } else { 33 | SDL_Log("%s: %s", argv[i], NET_GetAddressString(addrs[i])); 34 | } 35 | 36 | NET_UnrefAddress(addrs[i]); 37 | } 38 | 39 | NET_Quit(); 40 | 41 | return 0; 42 | } 43 | -------------------------------------------------------------------------------- /examples/simple-http-get.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This is just for demonstration purposes! A real HTTP solution would 3 | * be WAY more complicated, support HTTPS, cookies, etc. Use curl or 4 | * wget for real stuff, not this. 5 | * 6 | * All this to say: don't use this for anything serious! 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | int main(int argc, char **argv) 15 | { 16 | if (!NET_Init()) { 17 | SDL_Log("NET_Init() failed: %s", SDL_GetError()); 18 | return 1; 19 | } 20 | 21 | for (int i = 1; i < argc; i++) { 22 | SDL_Log("Looking up %s ...", argv[i]); 23 | NET_Address *addr = NET_ResolveHostname(argv[i]); 24 | if (NET_WaitUntilResolved(addr, -1) == -1) { 25 | SDL_Log("Failed to lookup %s: %s", argv[i], SDL_GetError()); 26 | } else { 27 | SDL_Log("%s is %s", argv[i], NET_GetAddressString(addr)); 28 | char *req = NULL; 29 | SDL_asprintf(&req, "GET / HTTP/1.0\r\nHost: %s\r\n\r\n", argv[i]); 30 | NET_StreamSocket *sock = req ? NET_CreateClient(addr, 80) : NULL; 31 | if (!req) { 32 | SDL_Log("Out of memory!"); 33 | } else if (!sock) { 34 | SDL_Log("Failed to create stream socket to %s: %s\n", argv[i], SDL_GetError()); 35 | } else if (NET_WaitUntilConnected(sock, -1) < 0) { 36 | SDL_Log("Failed to connect to %s: %s", argv[i], SDL_GetError()); 37 | } else if (!NET_WriteToStreamSocket(sock, req, SDL_strlen(req))) { 38 | SDL_Log("Failed to write to %s: %s", argv[i], SDL_GetError()); 39 | } else if (NET_WaitUntilStreamSocketDrained(sock, -1) < 0) { 40 | SDL_Log("Failed to finish write to %s: %s", argv[i], SDL_GetError()); 41 | } else { 42 | char buf[512]; 43 | int br; 44 | while ((br = NET_ReadFromStreamSocket(sock, buf, sizeof (buf))) >= 0) { 45 | fwrite(buf, 1, br, stdout); 46 | } 47 | 48 | printf("\n\n\n%s\n\n\n", SDL_GetError()); 49 | fflush(stdout); 50 | } 51 | 52 | if (sock) { 53 | NET_DestroyStreamSocket(sock); 54 | } 55 | 56 | SDL_free(req); 57 | } 58 | } 59 | 60 | 61 | NET_Quit(); 62 | 63 | return 0; 64 | } 65 | 66 | -------------------------------------------------------------------------------- /examples/voipchat.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | /* 6 | * This is just for demonstration purposes! A real VoIP solution would 7 | * definitely compress audio with a speech codec of some sort, it would 8 | * deal with packet loss better, it would have encryption, NAT punching, 9 | * and it wouldn't just allow _anyone_ to talk to you without some sort 10 | * of authorization step. 11 | * 12 | * All this to say: don't use this for anything serious! 13 | */ 14 | 15 | typedef struct Voice 16 | { 17 | SDL_AudioStream *stream; 18 | NET_Address *addr; 19 | Uint16 port; 20 | Uint64 idnum; 21 | Uint64 last_seen; 22 | Uint64 last_packetnum; 23 | struct Voice *prev; 24 | struct Voice *next; 25 | } Voice; 26 | 27 | static NET_DatagramSocket *sock = NULL; /* you talk over this, client or server. */ 28 | static NET_Address *server_addr = NULL; /* address of the server you're talking to, NULL if you _are_ the server. */ 29 | static Uint16 server_port = 3025; 30 | static int max_datagram = 0; 31 | static Voice *voices = NULL; 32 | static Uint64 next_idnum = 0; 33 | 34 | static SDL_Window *window = NULL; 35 | static SDL_Renderer *renderer = NULL; 36 | static SDL_AudioDeviceID audio_device = 0; 37 | static SDL_AudioDeviceID capture_device = 0; 38 | static SDL_AudioStream *capture_stream = NULL; 39 | static const SDL_AudioSpec audio_spec = { SDL_AUDIO_S16LE, 1, 8000 }; 40 | static Uint64 scratch_area[512]; 41 | 42 | static Voice *FindVoiceByAddr(const NET_Address *addr, const Uint16 port) 43 | { 44 | Voice *i; 45 | for (i = voices; i != NULL; i = i->next) { 46 | if ((i->port == port) && (NET_CompareAddresses(i->addr, addr) == 0)) { 47 | return i; 48 | } 49 | } 50 | return NULL; 51 | } 52 | 53 | static Voice *FindVoiceByIdNum(const Uint64 idnum) 54 | { 55 | Voice *i; 56 | for (i = voices; i != NULL; i = i->next) { 57 | if (i->idnum == idnum) { 58 | return i; 59 | } 60 | } 61 | return NULL; 62 | } 63 | 64 | static void ClearOldVoices(const Uint64 now) 65 | { 66 | Voice *i; 67 | Voice *next; 68 | for (i = voices; i != NULL; i = next) { 69 | next = i->next; 70 | if (!now || ((now - i->last_seen) > 60000)) { /* nothing new in 60+ seconds? (or shutting down?) */ 71 | if (!i->stream || (SDL_GetAudioStreamAvailable(i->stream) == 0)) { /* they'll get a reprieve if data is still playing out */ 72 | SDL_Log("Destroying voice #%" SDL_PRIu64, i->idnum); 73 | SDL_DestroyAudioStream(i->stream); 74 | NET_UnrefAddress(i->addr); 75 | if (i->prev) { 76 | i->prev->next = next; 77 | } else { 78 | voices = next; 79 | } 80 | if (next) { 81 | next->prev = i->prev; 82 | } 83 | SDL_free(i); 84 | } 85 | } 86 | } 87 | } 88 | 89 | static const int extra = (int) (sizeof (Uint64) * 2); 90 | static void SendClientAudioToServer(void) 91 | { 92 | const int br = SDL_GetAudioStreamData(capture_stream, scratch_area + (extra / sizeof(Uint64)), max_datagram - extra); 93 | if (br > 0) { 94 | next_idnum++; 95 | scratch_area[0] = SDL_Swap64LE(0); /* just being nice and leaving space in the buffer for the server to replace. */ 96 | scratch_area[1] = SDL_Swap64LE(next_idnum); 97 | SDL_Log("CLIENT: Sending %d new bytes to server at %s:%d...", br + extra, NET_GetAddressString(server_addr), (int) server_port); 98 | NET_SendDatagram(sock, server_addr, server_port, scratch_area, br + extra); 99 | } 100 | } 101 | 102 | static void mainloop(void) 103 | { 104 | const bool is_client = (server_addr != NULL) ? true : false; 105 | bool done = false; 106 | Uint64 last_send_ticks = 0; 107 | 108 | if (is_client) { 109 | SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255); /* red by default (green when recording) */ 110 | } 111 | 112 | while (!done) { 113 | bool activity = false; 114 | const Uint64 now = SDL_GetTicks(); 115 | SDL_Event event; 116 | NET_Datagram *dgram = NULL; 117 | int rc; 118 | 119 | while (((rc = NET_ReceiveDatagram(sock, &dgram)) == true) && (dgram != NULL)) { 120 | SDL_Log("%s: got %d-byte datagram from %s:%d", is_client ? "CLIENT" : "SERVER", (int) dgram->buflen, NET_GetAddressString(dgram->addr), (int) dgram->port); 121 | activity = true; 122 | if (!is_client) { /* we're the server? */ 123 | Voice *voice = FindVoiceByAddr(dgram->addr, dgram->port); 124 | Voice *i; 125 | 126 | if (!voice) { 127 | SDL_Log("SERVER: Creating voice idnum=%" SDL_PRIu64 " from %s:%d", next_idnum + 1, NET_GetAddressString(dgram->addr), (int) dgram->port); 128 | voice = (Voice *) SDL_calloc(1, sizeof (Voice)); 129 | voice->addr = NET_RefAddress(dgram->addr); 130 | voice->port = dgram->port; 131 | voice->idnum = ++next_idnum; 132 | if (voices) { 133 | voice->next = voices; 134 | voices->prev = voice; 135 | } 136 | voices = voice; 137 | } 138 | 139 | voice->last_seen = now; 140 | 141 | /* send this new voice data to all recent speakers. */ 142 | if (dgram->buflen > extra) { /* ignore it if too small, might just be a keepalive packet. */ 143 | *((Uint64 *) dgram->buf) = SDL_Swap64LE(voice->idnum); /* the client leaves space to fill this in for convenience. */ 144 | for (i = voices; i != NULL; i = i->next) { 145 | if ((voice->port != i->port) || (NET_CompareAddresses(voice->addr, i->addr) != 0)) { /* don't send client's own voice back to them. */ 146 | SDL_Log("SERVER: sending %d-byte datagram to %s:%d", (int) dgram->buflen, NET_GetAddressString(i->addr), (int) i->port); 147 | NET_SendDatagram(sock, i->addr, i->port, dgram->buf, dgram->buflen); 148 | } 149 | } 150 | } 151 | } else { /* we're the client. */ 152 | if ((dgram->port != server_port) || (NET_CompareAddresses(dgram->addr, server_addr) != 0)) { 153 | SDL_Log("CLIENT: Got packet from non-server address %s:%d. Ignoring.", NET_GetAddressString(dgram->addr), (int) dgram->port); 154 | } else if (dgram->buflen < extra) { 155 | SDL_Log("CLIENT: Got bogus packet from the server. Ignoring."); 156 | } else { 157 | const Uint64 idnum = SDL_Swap64LE(((const Uint64 *) dgram->buf)[0]); 158 | const Uint64 packetnum = SDL_Swap64LE(((const Uint64 *) dgram->buf)[1]); 159 | Voice *voice = FindVoiceByIdNum(idnum); 160 | if (!voice) { 161 | SDL_Log("CLIENT: Creating voice idnum=#%" SDL_PRIu64, idnum); 162 | voice = (Voice *) SDL_calloc(1, sizeof (Voice)); 163 | if (audio_device) { 164 | voice->stream = SDL_CreateAudioStream(&audio_spec, &audio_spec); 165 | if (voice->stream) { 166 | SDL_BindAudioStream(audio_device, voice->stream); 167 | } 168 | } 169 | voice->idnum = idnum; 170 | if (voices) { 171 | voice->next = voices; 172 | voices->prev = voice; 173 | } 174 | voices = voice; 175 | } 176 | 177 | voice->last_seen = now; 178 | 179 | if (packetnum > voice->last_packetnum) { /* if packet arrived out of order, don't queue it for playing. */ 180 | voice->last_packetnum = packetnum; 181 | SDL_PutAudioStreamData(voice->stream, dgram->buf + extra, dgram->buflen - extra); 182 | SDL_FlushAudioStream(voice->stream); /* flush right away so we have all data if the stream dries up. We can still safely add more data later. */ 183 | } 184 | } 185 | } 186 | 187 | NET_DestroyDatagram(dgram); 188 | } 189 | 190 | while (SDL_PollEvent(&event)) { 191 | activity = true; 192 | switch (event.type) { 193 | case SDL_EVENT_QUIT: 194 | done = 1; 195 | break; 196 | 197 | case SDL_EVENT_MOUSE_BUTTON_DOWN: 198 | if (is_client && capture_stream && (event.button.button == SDL_BUTTON_LEFT)) { 199 | if (SDL_BindAudioStream(capture_device, capture_stream)) { 200 | SDL_SetRenderDrawColor(renderer, 0, 255, 0, 255); /* green when recording */ 201 | } 202 | } 203 | break; 204 | 205 | case SDL_EVENT_MOUSE_BUTTON_UP: 206 | if (is_client && capture_stream && (event.button.button == SDL_BUTTON_LEFT)) { 207 | SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255); /* red when not recording */ 208 | SDL_UnbindAudioStream(capture_stream); 209 | SDL_FlushAudioStream(capture_stream); 210 | while (SDL_GetAudioStreamAvailable(capture_stream) > 0) { 211 | SendClientAudioToServer(); 212 | last_send_ticks = now; 213 | } 214 | } 215 | break; 216 | } 217 | } 218 | 219 | if (is_client) { 220 | if (capture_stream) { 221 | while (SDL_GetAudioStreamAvailable(capture_stream) > max_datagram) { 222 | SendClientAudioToServer(); 223 | last_send_ticks = now; 224 | activity = true; 225 | } 226 | } 227 | 228 | if (!last_send_ticks || ((now - last_send_ticks) > 5000)) { /* send a keepalive packet if we haven't transmitted for a bit. */ 229 | next_idnum++; 230 | scratch_area[0] = SDL_Swap64LE(0); 231 | scratch_area[1] = SDL_Swap64LE(next_idnum); 232 | SDL_Log("CLIENT: Sending %d keepalive bytes to server at %s:%d...", extra, NET_GetAddressString(server_addr), (int) server_port); 233 | NET_SendDatagram(sock, server_addr, server_port, scratch_area, extra); 234 | last_send_ticks = now; 235 | } 236 | } 237 | 238 | ClearOldVoices(now); 239 | 240 | if (!activity) { 241 | SDL_Delay(10); 242 | } 243 | 244 | SDL_RenderClear(renderer); 245 | SDL_RenderPresent(renderer); 246 | } 247 | } 248 | 249 | static void run_voipchat(int argc, char **argv) 250 | { 251 | const char *hostname = NULL; 252 | bool is_server = false; 253 | int simulate_failure = 0; 254 | int i; 255 | 256 | for (i = 1; i < argc; i++) { 257 | const char *arg = argv[i]; 258 | if (SDL_strcmp(arg, "--server") == 0) { 259 | is_server = true; 260 | } else if ((SDL_strcmp(arg, "--port") == 0) && (i < (argc-1))) { 261 | server_port = (Uint16) SDL_atoi(argv[++i]); 262 | } else if ((SDL_strcmp(arg, "--simulate-failure") == 0) && (i < (argc-1))) { 263 | simulate_failure = (int) SDL_atoi(argv[++i]); 264 | } else { 265 | hostname = arg; 266 | } 267 | } 268 | 269 | simulate_failure = SDL_min(SDL_max(simulate_failure, 0), 100); 270 | 271 | if (simulate_failure) { 272 | SDL_Log("Simulating failure at %d percent", simulate_failure); 273 | } 274 | 275 | if (is_server && hostname) { 276 | SDL_Log("WARNING: Specified --server and a hostname, ignoring the hostname"); 277 | } else if (!is_server && !hostname) { 278 | SDL_Log("USAGE: %s <--server|hostname> [--port X] [--simulate-failure Y]", argv[0]); 279 | return; 280 | } 281 | 282 | if (is_server) { 283 | SDL_Log("SERVER: Listening on port %d", server_port); 284 | } else { 285 | SDL_Log("CLIENT: Resolving server hostname '%s' ...", hostname); 286 | server_addr = NET_ResolveHostname(hostname); 287 | if (server_addr) { 288 | if (NET_WaitUntilResolved(server_addr, -1) < 0) { 289 | NET_UnrefAddress(server_addr); 290 | server_addr = NULL; 291 | } 292 | } 293 | 294 | if (!server_addr) { 295 | SDL_Log("CLIENT: Failed! %s", SDL_GetError()); 296 | SDL_Log("CLIENT: Giving up."); 297 | return; 298 | } 299 | 300 | SDL_Log("CLIENT: Server is at %s:%d.", NET_GetAddressString(server_addr), (int) server_port); 301 | 302 | audio_device = SDL_OpenAudioDevice(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &audio_spec); 303 | if (!audio_device) { 304 | SDL_Log("CLIENT: Failed to open output audio device (%s), going on without sound playback!", SDL_GetError()); 305 | } 306 | 307 | capture_device = SDL_OpenAudioDevice(SDL_AUDIO_DEVICE_DEFAULT_RECORDING, &audio_spec); 308 | if (!capture_device) { 309 | SDL_Log("CLIENT: Failed to open capture audio device (%s), going on without sound recording!", SDL_GetError()); 310 | } else { 311 | capture_stream = SDL_CreateAudioStream(&audio_spec, &audio_spec); 312 | if (!capture_stream) { 313 | SDL_Log("CLIENT: Failed to create capture audio stream (%s), going on without sound recording!", SDL_GetError()); 314 | SDL_CloseAudioDevice(capture_device); 315 | capture_device = 0; 316 | } 317 | } 318 | } 319 | 320 | /* server _must_ be on the requested port. Clients can take anything available, server will respond to where it sees it come from. */ 321 | sock = NET_CreateDatagramSocket(NULL, is_server ? server_port : 0); 322 | if (!sock) { 323 | SDL_Log("Failed to create datagram socket: %s", SDL_GetError()); 324 | } else { 325 | if (simulate_failure) { 326 | NET_SimulateDatagramPacketLoss(sock, simulate_failure); 327 | } 328 | mainloop(); 329 | } 330 | 331 | SDL_Log("Shutting down..."); 332 | 333 | ClearOldVoices(0); 334 | 335 | SDL_DestroyAudioStream(capture_stream); 336 | SDL_CloseAudioDevice(audio_device); 337 | SDL_CloseAudioDevice(capture_device); 338 | audio_device = capture_device = 0; 339 | 340 | NET_UnrefAddress(server_addr); 341 | server_addr = NULL; 342 | NET_DestroyDatagramSocket(sock); 343 | sock = NULL; 344 | } 345 | 346 | 347 | int main(int argc, char **argv) 348 | { 349 | if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO)) { 350 | SDL_Log("SDL_Init failed: %s\n", SDL_GetError()); 351 | return 1; 352 | } 353 | 354 | if (!NET_Init()) { 355 | SDL_Log("NET_Init failed: %s\n", SDL_GetError()); 356 | SDL_Quit(); 357 | return 1; 358 | } 359 | 360 | window = SDL_CreateWindow("SDL3_net voipchat example", 640, 480, 0); 361 | renderer = SDL_CreateRenderer(window, NULL); 362 | SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); 363 | 364 | max_datagram = SDL_min(1200, (int) sizeof (scratch_area)); 365 | 366 | run_voipchat(argc, argv); 367 | 368 | SDL_DestroyRenderer(renderer); 369 | SDL_DestroyWindow(window); 370 | 371 | NET_Quit(); 372 | SDL_Quit(); 373 | return 0; 374 | } 375 | -------------------------------------------------------------------------------- /src/SDL_net.sym: -------------------------------------------------------------------------------- 1 | SDL3_net_0.0.0 { 2 | global: 3 | NET_AcceptClient; 4 | NET_CompareAddresses; 5 | NET_CreateClient; 6 | NET_CreateDatagramSocket; 7 | NET_CreateServer; 8 | NET_DestroyDatagram; 9 | NET_DestroyDatagramSocket; 10 | NET_DestroyServer; 11 | NET_DestroyStreamSocket; 12 | NET_FreeLocalAddresses; 13 | NET_GetAddressStatus; 14 | NET_GetAddressString; 15 | NET_GetConnectionStatus; 16 | NET_GetLocalAddresses; 17 | NET_GetStreamSocketAddress; 18 | NET_GetStreamSocketPendingWrites; 19 | NET_GetVersion; 20 | NET_Init; 21 | NET_Quit; 22 | NET_ReadFromStreamSocket; 23 | NET_ReceiveDatagram; 24 | NET_RefAddress; 25 | NET_ResolveHostname; 26 | NET_SendDatagram; 27 | NET_SimulateAddressResolutionLoss; 28 | NET_SimulateDatagramPacketLoss; 29 | NET_SimulateStreamPacketLoss; 30 | NET_UnrefAddress; 31 | NET_WaitUntilConnected; 32 | NET_WaitUntilInputAvailable; 33 | NET_WaitUntilResolved; 34 | NET_WaitUntilStreamSocketDrained; 35 | NET_WriteToStreamSocket; 36 | local: *; 37 | }; 38 | -------------------------------------------------------------------------------- /src/version.rc: -------------------------------------------------------------------------------- 1 | 2 | #include "winresrc.h" 3 | 4 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 5 | 6 | ///////////////////////////////////////////////////////////////////////////// 7 | // 8 | // Version 9 | // 10 | 11 | VS_VERSION_INFO VERSIONINFO 12 | FILEVERSION 3,0,0,0 13 | PRODUCTVERSION 3,0,0,0 14 | FILEFLAGSMASK 0x3fL 15 | FILEFLAGS 0x0L 16 | FILEOS 0x40004L 17 | FILETYPE 0x2L 18 | FILESUBTYPE 0x0L 19 | BEGIN 20 | BLOCK "StringFileInfo" 21 | BEGIN 22 | BLOCK "040904b0" 23 | BEGIN 24 | VALUE "CompanyName", "\0" 25 | VALUE "FileDescription", "SDL_net\0" 26 | VALUE "FileVersion", "3, 0, 0, 0\0" 27 | VALUE "InternalName", "SDL_net\0" 28 | VALUE "LegalCopyright", "Copyright (C) 2025 Sam Lantinga\0" 29 | VALUE "OriginalFilename", "SDL3_net.dll\0" 30 | VALUE "ProductName", "Simple DirectMedia Layer\0" 31 | VALUE "ProductVersion", "3, 0, 0, 0\0" 32 | END 33 | END 34 | BLOCK "VarFileInfo" 35 | BEGIN 36 | VALUE "Translation", 0x409, 1200 37 | END 38 | END 39 | --------------------------------------------------------------------------------