Cross-Compile TCC for Windows #7
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: Cross-Platform Build and Release | |
| on: | |
| schedule: | |
| - cron: '*/15 * * * *' | |
| workflow_dispatch: | |
| jobs: | |
| git-sync: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Sync repositories | |
| uses: wei/git-sync@v3 | |
| with: | |
| source_repo: "https://repo.or.cz/tinycc.git" | |
| source_branch: "mob" | |
| destination_repo: "git@github.com:Tiny-C-Compiler/mirror-repository" | |
| destination_branch: "mob" | |
| ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }} | |
| build-binaries: | |
| needs: git-sync | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout mirror repository | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: Tiny-C-Compiler/mirror-repository | |
| ref: mob | |
| ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
| fetch-depth: 0 | |
| - name: Install build dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| gcc \ | |
| make \ | |
| gcc-mingw-w64-x86-64 \ | |
| binutils-mingw-w64-x86-64 \ | |
| mingw-w64-x86-64-dev \ | |
| build-essential | |
| - name: Build Linux host compiler | |
| run: | | |
| ./configure | |
| make | |
| mv tcc tcc-host | |
| - name: Build Linux binary | |
| run: | | |
| ./configure | |
| make | |
| mv tcc tcc-linux | |
| - name: Build Windows binary | |
| run: | | |
| # Clean previous build | |
| make distclean || true | |
| # Configure for Windows with static linking | |
| ./configure \ | |
| --cross-prefix=x86_64-w64-mingw32- \ | |
| --enable-cross-prefix \ | |
| --cpu=x86_64 \ | |
| --extra-cflags="-static" \ | |
| --extra-ldflags="-static" | |
| # Use host compiler for libtcc1 generation | |
| sed -i 's/^\(HOST_CC\s*=\s*\).*/\1gcc/' Makefile | |
| sed -i 's/^\(HOST_LD\s*=\s*\).*/\1gcc/' Makefile | |
| # Build only the necessary targets | |
| make tcc.exe | |
| mv tcc.exe tcc-windows.exe | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: binaries | |
| path: | | |
| tcc-linux | |
| tcc-windows.exe | |
| create-release: | |
| needs: build-binaries | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: binaries | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| repository: Tiny-C-Compiler/mirror-repository | |
| token: ${{ secrets.MIRROR_REPO_TOKEN }} | |
| tag_name: latest | |
| overwrite: true | |
| files: | | |
| tcc-linux | |
| tcc-windows.exe | |
| body: | | |
| Automated cross-platform build containing: | |
| - Linux executable (ELF64) | |
| - Windows executable (PE32+) | |
| Built from mob branch at $(date -u +"%Y-%m-%dT%H:%M:%SZ") |