# Description: Masquerade directory to use ccache with clang
# URL: https://ccache.dev/
# Maintainer: Tim Biermann, tbier at posteo dot de
# Depends on: ccache clang

name=clang-ccache-bindings
version=18
release=1
source=()

build() {
  install -d $PKG/usr/lib/ccache

  local clang0="$(clang --version | awk -F'[ .]' '/version/ { print $3"."$4 }')"
  local clang1="${clang0:0:2}"

  if [ -z "$clang0" ]; then
    echo 'Failed to find clang version'
    exit 1
  fi

  ln -s ../../bin/ccache $PKG/usr/lib/ccache/clang
  ln -s ../../bin/ccache $PKG/usr/lib/ccache/clang-$clang0
  ln -s ../../bin/ccache $PKG/usr/lib/ccache/clang-$clang1
  ln -s ../../bin/ccache $PKG/usr/lib/ccache/clang++
}
