Update README.md with new GPU examples and latest binding status #53
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Deploy Readme with Binding Status | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - cleanup-github-workflow | |
| permissions: | |
| contents: write # Needed to push to gh-pages branch | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| - name: Cache GHCup | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.ghcup | |
| key: ${{ runner.os }}-ghcup-9.8.4 | |
| restore-keys: | | |
| ${{ runner.os }}-ghcup- | |
| - name: Set up Haskell | |
| uses: haskell-actions/setup@v2 | |
| with: | |
| ghc-version: "9.8.4" | |
| cabal-version: "latest" | |
| - name: Set up SDL3 headers from submodule | |
| run: | | |
| echo "Setting up SDL3 headers from submodule..." | |
| # Source config to get the expected commit | |
| source .github/config.sh | |
| # Verify submodule is at expected commit | |
| cd SDL3 | |
| current_commit=$(git rev-parse HEAD) | |
| echo "SDL3 submodule at commit: $current_commit" | |
| if [ "$current_commit" != "$SDL_HEADER_COMMIT" ]; then | |
| echo "⚠️ Warning: Submodule commit ($current_commit) differs from config ($SDL_HEADER_COMMIT)" | |
| fi | |
| cd .. | |
| # Create symlink to system include path for compatibility | |
| sudo mkdir -p /usr/local/include | |
| sudo ln -sf "$(pwd)/SDL3/include/SDL3" /usr/local/include/SDL3 | |
| # Verify headers are available | |
| echo "Verifying SDL3 headers..." | |
| header_count=$(find SDL3/include/SDL3 -name "SDL_*.h" | wc -l) | |
| echo "✅ Found $header_count SDL3 headers in SDL3/include/SDL3" | |
| # List first few headers for verification | |
| ls SDL3/include/SDL3/SDL_*.h | head -5 | |
| - name: Cache Cabal packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cabal/packages | |
| ~/.cabal/store | |
| dist-newstyle | |
| key: ${{ runner.os }}-cabal-v3-${{ hashFiles('**/*.cabal', 'cabal.project') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cabal-v3- | |
| - name: Update Cabal package index | |
| run: cabal update | |
| - name: Clean build artifacts | |
| run: | | |
| echo "Cleaning build artifacts to ensure fresh build..." | |
| rm -rf dist-newstyle | |
| cabal clean | |
| - name: Install dependencies | |
| run: cabal build --dependencies-only exe:binding-checker -f-pkgconfig | |
| - name: Verify binding checker with SDL3 headers | |
| run: | | |
| echo "Testing binding checker with SDL3 headers..." | |
| # Build binding checker (only the executable, not the full library) | |
| cabal build exe:binding-checker -f-pkgconfig | |
| # Verify headers are accessible | |
| if [ -d "/usr/local/include/SDL3" ]; then | |
| header_count=$(find /usr/local/include/SDL3 -name "SDL_*.h" | wc -l) | |
| echo "✅ Found $header_count SDL3 headers" | |
| else | |
| echo "❌ SDL3 headers not found" | |
| exit 1 | |
| fi | |
| # Debug: Show SDL3 version and commit info | |
| echo "SDL3 commit used: cf6c42e6e6cca075b196a8ee69e96a0d8ba0652b" | |
| if [ -f "/usr/local/include/SDL3/SDL_version.h" ]; then | |
| echo "SDL3 version header content:" | |
| grep -E "SDL_MAJOR_VERSION|SDL_MINOR_VERSION|SDL_MICRO_VERSION" /usr/local/include/SDL3/SDL_version.h || true | |
| fi | |
| # Debug: Show some key headers we expect to have bindings for | |
| echo "Checking key headers:" | |
| for header in SDL_asyncio SDL_blendmode SDL_cpuinfo SDL_gpu SDL_guid SDL_iostream SDL_loadso SDL_messagebox; do | |
| if [ -f "/usr/local/include/SDL3/${header}.h" ]; then | |
| echo "✅ Found ${header}.h" | |
| # Quick function count | |
| func_count=$(grep -c "SDL_DECLSPEC.*SDLCALL" "/usr/local/include/SDL3/${header}.h" || echo "0") | |
| echo " - Contains $func_count SDL functions" | |
| else | |
| echo "❌ Missing ${header}.h" | |
| fi | |
| done | |
| # Test binding checker with a known header | |
| if [ -f "/usr/local/include/SDL3/SDL_init.h" ]; then | |
| echo "Testing binding checker with SDL_init.h..." | |
| if ! echo "/usr/local/include/SDL3/SDL_init.h" | cabal exec -f-pkgconfig binding-checker; then | |
| echo "❌ Binding checker test failed" | |
| exit 1 | |
| fi | |
| echo "✅ Binding checker test passed" | |
| else | |
| echo "❌ SDL_init.h not found" | |
| exit 1 | |
| fi | |
| # Test binding checker with SDL_asyncio.h (should show as complete) | |
| if [ -f "/usr/local/include/SDL3/SDL_asyncio.h" ]; then | |
| echo "Testing binding checker with SDL_asyncio.h..." | |
| echo "/usr/local/include/SDL3/SDL_asyncio.h" | cabal exec -f-pkgconfig binding-checker | |
| fi | |
| echo "✅ Binding checker verification complete" | |
| - name: Configure git user | |
| run: | | |
| git config --global user.name "${{ github.event.head_commit.author.name }}" | |
| git config --global user.email "${{ github.event.head_commit.author.email }}" | |
| - name: Generate binding status | |
| run: | | |
| echo "Generating SDL3 binding status..." | |
| chmod +x .github/config.sh | |
| chmod +x .github/generate-binding-status.sh | |
| chmod +x .github/update-readme.sh | |
| # Source config (for logging) | |
| source .github/config.sh | |
| echo "Using binding source directory: $BINDING_SRC_DIR" | |
| echo "SDL3 commit: $SDL_HEADER_COMMIT" | |
| # Verify binding source exists | |
| if [ ! -d "$BINDING_SRC_DIR" ]; then | |
| echo "Error: Binding source directory not found: $BINDING_SRC_DIR" | |
| ls -la src/ | |
| exit 1 | |
| fi | |
| echo "Found $(ls $BINDING_SRC_DIR/*.hs $BINDING_SRC_DIR/*.hsc 2>/dev/null | wc -l) binding files" | |
| # Generate binding status | |
| if ! ./.github/update-readme.sh; then | |
| echo "Failed to update binding status" | |
| exit 1 | |
| fi | |
| echo "Binding status updated successfully" | |
| - name: Set up Pandoc | |
| uses: r-lib/actions/setup-pandoc@v2 # A reliable action to install Pandoc | |
| - name: Convert README to HTML | |
| run: | | |
| pandoc --standalone \ | |
| -f gfm+fenced_divs \ | |
| -t html5 \ | |
| --template=.github/template.html \ | |
| --metadata title="SDL3 Haskell Bindings" \ | |
| -o index.html \ | |
| README.md | |
| echo "HTML generation complete. index.html created." | |
| - name: Check README status | |
| run: | | |
| echo "README.md status:" | |
| if ! git diff --quiet README.md; then | |
| echo "⚠️ README.md has changes but will not be committed automatically" | |
| echo "💡 Use pre-commit hook locally to update README before committing" | |
| else | |
| echo "✅ README.md is up to date" | |
| fi | |
| - name: Deploy to GitHub Pages | |
| uses: peaceiris/actions-gh-pages@v4 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: . # Directory containing index.html | |
| publish_branch: gh-pages # Branch to deploy to | |
| user_name: ${{ github.event.head_commit.author.name }} | |
| user_email: ${{ github.event.head_commit.author.email }} | |
| commit_message: "Deploy docs with binding status: ${{ github.event.head_commit.message }}" |