name: build
on: push
jobs:
  build-linux:
    runs-on: ubuntu-22.04
    steps:
      - uses: actions/checkout@v3
        with:
          submodules: recursive
      - name: Install dependencies
        run: |
          sudo apt-get update -qq
          sudo apt-get install -y build-essential libgtk-3-dev libsdl2-dev libfmt-dev git ninja-build nlohmann-json3-dev
          sudo apt-get install -y vulkan-tools libvulkan1 libvulkan-dev vulkan-validationlayers-dev spirv-tools
      - name: Build natsukashii
        run: |
          cmake \
            -G Ninja \
            -B build \
            -DCAPSTONE_ARCHITECTURE_DEFAULT=OFF \
            -DCAPSTONE_BUILD_TESTS=OFF \
            -DCAPSTONE_MIPS_SUPPORT=ON \
            -DCMAKE_BUILD_TYPE=Release \
            -S src
          ninja -j$(nproc) -C build
      - name: Collect artifacts
        run: |
          mkdir upload
          cp -r resources upload
          cp build/natsukashii upload
      - name: Upload artifacts
        uses: actions/upload-artifact@v2
        with:
          name: natsukashii-linux
          path: upload
          if-no-files-found: error
  build-windows:
    runs-on: windows-latest
    defaults:
      run:
        shell: msys2 {0}
    steps:
      - uses: actions/checkout@v3
        with:
          submodules: recursive
      - uses: msys2/setup-msys2@v2
        with:
          install:
            make git mingw-w64-x86_64-gcc mingw-w64-x86_64-cmake mingw-w64-x86_64-SDL2
            mingw-w64-x86_64-vulkan-devel mingw-w64-x86_64-fmt mingw-w64-x86_64-ninja
            mingw-w64-x86_64-nlohmann-json
      - name: Build natsukashii
        run: |
          cmake \
            -G Ninja \
            -B build \
            -DCAPSTONE_ARCHITECTURE_DEFAULT=OFF \
            -DCAPSTONE_BUILD_TESTS=OFF \
            -DCAPSTONE_MIPS_SUPPORT=ON \
            -DCMAKE_BUILD_TYPE=Release \
            -S src
          ninja -j$(nproc) -C build
      - name: Collect artifacts
        run: |
          mkdir upload
          cp -r resources upload
          cp build/natsukashii.exe upload
      - name: Upload artifacts
        uses: actions/upload-artifact@v2
        with:
          name: natsukashii-windows
          path: upload
          if-no-files-found: error