name: Get dependencies

inputs:
  arg:
    description: 'Arguments to get_deps.py'
    required: true

runs:
  using: "composite"
  steps:
    - name: Checkout pico-sdk for rp2040
      if: contains(inputs.arg, 'rp2040') || contains(inputs.arg, 'raspberry_pi_pico')
      uses: actions/checkout@v4
      with:
        repository: raspberrypi/pico-sdk
        ref: master
        path: pico-sdk

    - name: Linux dependencies
      if: runner.os == 'Linux'
      run: |
        NINJA_URL=https://github.com/ninja-build/ninja/releases/download/v1.13.1/ninja-linux.zip
        wget $NINJA_URL -O ninja-linux.zip
        unzip ninja-linux.zip -d ninja-bin
        echo >> $GITHUB_PATH "${{ github.workspace }}/ninja-bin"
      shell: bash

    - name: Get Dependencies
      env:
        ARG: ${{ inputs.arg }}
      run: |
        python3 tools/get_deps.py ${ARG}
        echo "PICO_SDK_PATH=${{ github.workspace }}/pico-sdk" >> $GITHUB_ENV
      shell: bash
