#!/bin/bash

PATCH=puya_v3.patch

for DIR in ~/.platformio/packages/framework-arduinoespressif8266*/; do

  #not applied yet? (in upstream or otherwise)
  if ! grep "0x146085 PUYA" $DIR/cores/esp8266/Esp.cpp >/dev/null; then
    echo "Patching $DIR"
    patch -p1 -d $DIR < $PATCH
  fi
done
