set windows-shell := ["powershell.exe", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command"]

# Show available commands when invoked without a task.
[default]
help:
    @just --list

# Check network-mode dependencies; add --usb for virtual COM dependencies.
check *args:
    @powershell.exe -NoProfile -ExecutionPolicy Bypass -File scripts/bootstrap.ps1 check {{ args }}

# Select the ELF firmware used by subsequent runs.
elf path:
    @powershell.exe -NoProfile -ExecutionPolicy Bypass -File scripts/bootstrap.ps1 elf '{{ replace(path, "'", "''") }}'

# Update machine-dependent paths for the current project directory.
format:
    @powershell.exe -NoProfile -ExecutionPolicy Bypass -File scripts/bootstrap.ps1 format

# Run over TCP; add --usb for virtual COM, --debug to wait for GDB.
[script('powershell.exe', '-NoProfile', '-ExecutionPolicy', 'Bypass', '-File')]
[extension('.ps1')]
[positional-arguments]
run *args:
    & './scripts/bootstrap.ps1' run @args
    exit $LASTEXITCODE

# Stop this checkout's Renode instance and release its virtual COM port.
stop:
    @powershell.exe -NoProfile -ExecutionPolicy Bypass -File scripts/bootstrap.ps1 stop

# Clear flash1 (internal), flash2 (external), or both by default; stop Renode first.
[script('powershell.exe', '-NoProfile', '-ExecutionPolicy', 'Bypass', '-File')]
[extension('.ps1')]
[positional-arguments]
clean *args:
    & './scripts/bootstrap.ps1' clean @args
    exit $LASTEXITCODE
