name: "Linux Build"
on:
  push:
    branches: [ v1.x ]
  pull_request:
    # branches: [ master ]

jobs:
  build_libebml:
    name: libebml for Linux
    runs-on: ubuntu-latest
    steps:
      - name: install utf8cpp
        run: |
          sudo apt-get update
          sudo apt-get install -y --no-install-recommends libutfcpp-dev

      - name: Get pushed code
        uses: actions/checkout@v7

      - name: Configure CMake
        run: cmake -S . -B _build -DCMAKE_INSTALL_PREFIX:STRING=${GITHUB_WORKSPACE}/_built -G Ninja

      - name: Build with CMake
        run: cmake --build _build --parallel

      - name: Test installation
        run: cmake --install _build --prefix ${GITHUB_WORKSPACE}/_built

  s390X:
    name: libebml for Big Endian Linux
    runs-on: ubuntu-latest
    env:
      CMAKE_OPTIONS: -DDEV_MODE=ON -DBUILD_TESTING=ON -DCMAKE_SYSTEM_PROCESSOR=s390x -DCMAKE_CROSSCOMPILING_EMULATOR="qemu-s390x;-L;/usr/s390x-linux-gnu/" -DCMAKE_CXX_COMPILER=s390x-linux-gnu-g++ -G Ninja
    steps:
      - name: install toolchain
        run: |
          sudo apt-get update
          sudo apt-get install -y --no-install-recommends qemu-user crossbuild-essential-s390x qemu-system-s390x

      - name: list compilers
        run: dpkg --list | grep compiler

      - name: Get pushed code
        uses: actions/checkout@v7

      - name: Configure
        run: cmake -S . -B _build ${{ env.CMAKE_OPTIONS }} -DCMAKE_INSTALL_PREFIX:STRING=${GITHUB_WORKSPACE}/_built

      - name: Build
        run: cmake --build _build --parallel

      - name: Test installation
        run: cmake --install _build --prefix ${GITHUB_WORKSPACE}/_built
