name: Build toolchain

on:
  workflow_call:
    inputs:
      all-platforms:
        required: false
        default: false
        type: boolean
  workflow_dispatch:

jobs:
  build-toolchain:
    strategy:
      matrix:
        platform: ${{ (inputs.all-platforms && fromJSON('["ubuntu-24.04", "macos-latest", "windows-latest"]')) || fromJSON('["ubuntu-24.04"]') }}
    runs-on: ${{ matrix.platform }}
    steps:
      - name: Check out lingua-franca repository
        uses: actions/checkout@v3
        with:
          submodules: recursive
          fetch-depth: 0
      - name: Prepare build environment
        uses: ./.github/actions/prepare-build-env
      - name: Build and package lf cli tools (regular build)
        run: ./gradlew build testCodeCoverageReport
        shell: bash
      - name: Report to CodeCov
        uses: ./.github/actions/report-code-coverage
        with:
          files: core/build/reports/jacoco/testCodeCoverageReport/testCodeCoverageReport.xml,cli/base/build/reports/jacoco/testCodeCoverageReport/testCodeCoverageReport.xml,cli/lfc/build/reports/jacoco/testCodeCoverageReport/testCodeCoverageReport.xml,cli/lfd/build/reports/jacoco/testCodeCoverageReport/testCodeCoverageReport.xml,cli/lff/build/reports/jacoco/testCodeCoverageReport/testCodeCoverageReport.xml
