prepare_single_header.sh 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/zsh -e
  2. setopt extendedglob
  3. IFS="\n\0"
  4. seen=()
  5. parse_file() {
  6. dir=${1%/*}
  7. file=${1##*/}
  8. case "$file" in
  9. memory.h) return;;
  10. memorybase.h) return;;
  11. *deprecated*) return;;
  12. *debug.h) return;;
  13. esac
  14. [[ "$1" =~ "/" ]] && pushd "$dir"
  15. #echo "${seen[@]}"
  16. if [[ "$PWD/$file" = ${(~j.|.)seen} ]]; then
  17. [[ "$1" =~ "/" ]] && popd || true
  18. return
  19. fi
  20. case "$file" in
  21. *generalinterface.h);;
  22. *loadinterface.h);;
  23. *storeinterface.h);;
  24. *gatherinterface.h);;
  25. *scatterinterface.h);;
  26. *)
  27. seen=(${seen[@]} "$PWD/$file")
  28. ;;
  29. esac
  30. do_skip=false
  31. while read -r line; do
  32. #match='*include*'
  33. case "$line" in
  34. \ #\#\ #include\ #\"*\"*)
  35. echo $line|cut -d\" -f2|read include
  36. parse_file "$include"
  37. ;;
  38. *"@BEGIN SKIP GODBOLT@"*) do_skip=true ;;
  39. *"@END SKIP GODBOLT@"*) do_skip=false ;;
  40. *)
  41. $do_skip || printf "%s\n" "$line"
  42. ;;
  43. esac
  44. done < "$file"
  45. [[ "$1" =~ "/" ]] && popd || true
  46. }
  47. cd `dirname $0`
  48. parse_file "Vc/vector.h" > >(cpp -dD -E -fpreprocessed -w -P | sed 's/^ *//' > godbolt/Vc)
  49. parse_file "Vc/algorithm" > >(cpp -dD -E -fpreprocessed -w -P | sed 's/^ *//' > godbolt/algorithm)
  50. parse_file "Vc/Vc" > >(cpp -dD -E -fpreprocessed -w -P | sed 's/^ *//' > godbolt/containers)