gen_ccls_file.sh 978 B

12345678910111213141516171819202122232425262728293031
  1. #!/bin/sh
  2. ##############################################################################
  3. # THIS MUST BE CALLED FROM THE ROOT DIRECTORY. IT IS USED BY THE MAKEFILE SO #
  4. # IN THEORY, YOU SHOULD NEVER CALL THIS. #
  5. ##############################################################################
  6. set -e
  7. CCLS_FILE=".ccls"
  8. # Get all #define *_PRIVATE from our source. We need to list them in our .ccls
  9. # file and enable them otherwise ccls will not find their definition thinking
  10. # that they are dead code.
  11. PRIVATE_DEFS=$(grep -r --include \*.h "_PRIVATE" | grep "#ifdef" | cut -d' ' -f2 | sort | uniq)
  12. echo "clang" > "$CCLS_FILE"
  13. # Add these include so the ccls server can properly check new files that are
  14. # not in the compile_commands.json yet
  15. {
  16. echo "-I."
  17. echo "-I./src"
  18. echo "-I./src/ext"
  19. echo "-I./src/ext/trunnel"
  20. } >> "$CCLS_FILE"
  21. # Add all defines (-D).
  22. for p in $PRIVATE_DEFS; do
  23. echo "-D$p" >> "$CCLS_FILE"
  24. done