setup_ccache 1007 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. autoload -Uz log_debug log_warning
  2. if (( ! ${+project_root} )) {
  3. log_error "'project_root' not set. Please set before running ${0}."
  4. return 2
  5. }
  6. if (( ${+commands[ccache]} )) {
  7. log_debug "Found ccache at ${commands[ccache]}"
  8. typeset -gx CCACHE_CONFIGPATH="${project_root}/.ccache.conf"
  9. ccache --set-config=run_second_cpp=true
  10. ccache --set-config=direct_mode=true
  11. ccache --set-config=inode_cache=true
  12. ccache --set-config=compiler_check=content
  13. ccache --set-config=file_clone=true
  14. local -a sloppiness=(
  15. include_file_mtime
  16. include_file_ctime
  17. file_stat_matches
  18. system_headers
  19. )
  20. if [[ ${host_os} == macos ]] {
  21. sloppiness+=(
  22. modules
  23. clang_index_store
  24. )
  25. ccache --set-config=sloppiness=${(j:,:)sloppiness}
  26. }
  27. if (( ${+CI} )) {
  28. ccache --set-config=cache_dir="${GITHUB_WORKSPACE:-${HOME}}/.ccache"
  29. ccache --set-config=max_size="${CCACHE_SIZE:-1G}"
  30. ccache -z > /dev/null
  31. }
  32. } else {
  33. log_warning "No ccache found on the system"
  34. }