name: RISCV64

on: [ push, pull_request ]

env:
  BUILD_TYPE: Release

jobs:
  build_linux:
    strategy:
      matrix:
        platform: [ linux ]
      fail-fast: false

    runs-on: ubuntu-latest

    steps:

      - name: Install build dependencies
        run: >
          sudo apt-get update &&
          sudo apt-get install
          gcc-10-riscv64-linux-gnu
          g++-10-riscv64-linux-gnu
          ninja-build
          qemu-user

      - name: Checkout dynarmic repo
        uses: actions/checkout@v2

      - name: Ccache
        if: matrix.platform == 'linux'
        uses: hendrikmuhs/ccache-action@v1.2

      - name: Checkout ext-boost repo
        uses: actions/checkout@v2
        with:
          repository: MerryMage/ext-boost
          path: externals/ext-boost

      - name: Configure CMake for RISCV64 (Linux)
        if: matrix.platform == 'linux'
        env:
          CC: riscv64-linux-gnu-gcc-10
          CXX: riscv64-linux-gnu-g++-10
        run: >
          cmake
          -B ${{github.workspace}}/build-riscv64
          -DBOOST_INCLUDEDIR=${{github.workspace}}/externals/ext-boost
          -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
          -DDYNARMIC_TESTS_USE_UNICORN=0
          -DDYNARMIC_USE_LLVM=0
          -DDYNARMIC_FRONTENDS=A32
          -G Ninja

      - name: Build RISCV64
        working-directory: ${{github.workspace}}/build-riscv64
        run: cmake --build . --config Release

      # - name: Basic tests
      #   if: matrix.platform == 'linux'
      #   working-directory: ${{github.workspace}}
      #   run: qemu-riscv64 -L /usr/riscv64-linux-gnu ./build-riscv64/tests/dynarmic_tests -d yes
