[emscripten] build emscripten libs and keep exports #2132
  
    
      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 | |
| on: [push, pull_request] | |
| jobs: | |
| build: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| cc: gcc | |
| cxx: g++ | |
| - os: ubuntu-latest | |
| cc: clang | |
| cxx: clang++ | |
| - os: windows-latest | |
| cc: cl | |
| cxx: cl | |
| env: | |
| CC: ${{ matrix.cc }} | |
| CXX: ${{ matrix.cxx }} | |
| STEAMRT_SNAPSHOT: latest-steam-client-general-availability | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Checkout steam-runtime | |
| if: startsWith(matrix.os, 'ubuntu') | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: ValveSoftware/steam-runtime | |
| path: steam-runtime | |
| - name: Cache steam-runtime | |
| if: startsWith(matrix.os, 'ubuntu') | |
| id: cache-steam-runtime | |
| uses: actions/cache@v4 | |
| with: | |
| path: com.valvesoftware.SteamRuntime.Sdk-i386-scout-sysroot.tar.gz | |
| key: steam-runtime-${{ env.STEAMRT_SNAPSHOT }} | |
| - name: Download steam-runtime | |
| if: startsWith(matrix.os, 'ubuntu') && steps.cache-steam-runtime.outputs.cache-hit != 'true' | |
| run: wget --no-verbose https://repo.steampowered.com/steamrt-images-scout/snapshots/${{ env.STEAMRT_SNAPSHOT }}/com.valvesoftware.SteamRuntime.Sdk-i386-scout-sysroot.tar.gz | |
| - name: Install steam runtime | |
| if: startsWith(matrix.os, 'ubuntu') | |
| run: | | |
| sudo apt update | |
| ./steam-runtime/setup_chroot.sh --i386 --tarball ./com.valvesoftware.SteamRuntime.Sdk-i386-scout-sysroot.tar.gz | |
| sudo sed -i 's/groups=sudo/groups=adm/g' /etc/schroot/chroot.d/steamrt_scout_i386.conf | |
| - name: Build on Linux | |
| if: startsWith(matrix.os, 'ubuntu') | |
| run: | | |
| schroot --chroot steamrt_scout_i386 -- cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DPOLLY=ON -B build -S . -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined" -DCMAKE_INSTALL_PREFIX="$PWD/dist" | |
| schroot --chroot steamrt_scout_i386 -- cmake --build build --target all | |
| schroot --chroot steamrt_scout_i386 -- cmake --build build --target install | |
| - name: Build on Linux with vgui | |
| if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.cc, 'gcc') | |
| run: | | |
| schroot --chroot steamrt_scout_i386 -- cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DPOLLY=ON -B build-vgui -S . -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined" -DUSE_VGUI=ON -DCMAKE_INSTALL_PREFIX="$PWD/dist-vgui" | |
| cp vgui_support/vgui-dev/lib/vgui.so build-vgui/cl_dll | |
| cp vgui_support/vgui-dev/lib/vgui.so build-vgui | |
| schroot --chroot steamrt_scout_i386 -- cmake --build build-vgui --target all | |
| schroot --chroot steamrt_scout_i386 -- cmake --build build-vgui --target install | |
| - name: Set developer command prompt for Windows x86 | |
| if: startsWith(matrix.os, 'windows') | |
| uses: ilammy/msvc-dev-cmd@v1 | |
| with: | |
| arch: x86 | |
| - name: Build on Windows | |
| if: startsWith(matrix.os, 'windows') | |
| run: | | |
| cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -B build -S . -DCMAKE_INSTALL_PREFIX="dist" | |
| cmake --build build --target all | |
| cmake --build build --target install | |
| - name: Build on Windows with vgui | |
| if: startsWith(matrix.os, 'windows') | |
| run: | | |
| cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -B build -S . -DUSE_VGUI=ON -DCMAKE_INSTALL_PREFIX="dist-vgui" | |
| cmake --build build --target all | |
| cmake --build build --target install | |
| - name: Set developer command prompt for Windows x86_64 | |
| if: startsWith(matrix.os, 'windows') | |
| uses: ilammy/msvc-dev-cmd@v1 | |
| with: | |
| arch: x64 | |
| - name: Build on Windows x64 | |
| if: startsWith(matrix.os, 'windows') | |
| run: | | |
| cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -B build64 -S . -DCMAKE_INSTALL_PREFIX="dist64" -D64BIT=ON | |
| cmake --build build64 --target all | |
| cmake --build build64 --target install | |
| - name: Extract branch name | |
| shell: bash | |
| run: echo "branch=$(echo ${GITHUB_REF#refs/heads/} | tr '/' '_')" >> $GITHUB_OUTPUT | |
| id: extract_branch | |
| - name: Extract gamedir | |
| shell: bash | |
| run: echo "gamedir=$(grep build/CMakeCache.txt -Ee 'GAMEDIR:STRING=[a-z]+' | cut -d '=' -f 2)" >> $GITHUB_OUTPUT | |
| id: extract_gamedir | |
| - name: Upload linux artifact | |
| if: startsWith(matrix.os, 'ubuntu') && matrix.cc == 'gcc' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: hlsdk-${{ steps.extract_branch.outputs.branch }}-linux | |
| path: dist/${{ steps.extract_gamedir.outputs.gamedir }} | |
| - name: Upload linux artifact with vgui | |
| if: startsWith(matrix.os, 'ubuntu') && matrix.cc == 'gcc' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: hlsdk-${{ steps.extract_branch.outputs.branch }}-linux-vgui | |
| path: dist-vgui/${{ steps.extract_gamedir.outputs.gamedir }} | |
| - name: Upload windows artifact | |
| if: startsWith(matrix.os, 'windows') | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: hlsdk-${{ steps.extract_branch.outputs.branch }}-windows | |
| path: dist/${{ steps.extract_gamedir.outputs.gamedir }} | |
| - name: Upload windows x64 artifact | |
| if: startsWith(matrix.os, 'windows') | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: hlsdk-${{ steps.extract_branch.outputs.branch }}-windows_x64 | |
| path: dist64/${{ steps.extract_gamedir.outputs.gamedir }} | |
| - name: Upload windows artifact with vgui | |
| if: startsWith(matrix.os, 'windows') | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: hlsdk-${{ steps.extract_branch.outputs.branch }}-windows-vgui | |
| path: dist-vgui/${{ steps.extract_gamedir.outputs.gamedir }} | |