regenerate-lexers.bash 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/usr/bin/env bash
  2. set -e
  3. forced=1
  4. if [[ "${1}" = "make" ]]; then
  5. forced=0
  6. fi
  7. pushd "${BASH_SOURCE%/*}/../../Source/LexerParser" > /dev/null
  8. extra_args_CommandArgument="--never-interactive --batch"
  9. for lexer in \
  10. CTestResourceGroups \
  11. DependsJava \
  12. Expr \
  13. Fortran \
  14. GccDepfile
  15. do
  16. cxx_file=cm${lexer}Lexer.cxx
  17. h_file=cm${lexer}Lexer.h
  18. in_file=cm${lexer}Lexer.in.l
  19. if [[ (${in_file} -nt ${cxx_file}) || (${in_file} -nt ${h_file}) || (${forced} -gt 0) ]]; then
  20. extra_args=`eval echo \\${extra_args_\${lexer}}`
  21. echo "Generating Lexer ${lexer}"
  22. flex --nounistd ${extra_args} -DFLEXINT_H --noline --header-file=${h_file} -o${cxx_file} ${in_file}
  23. sed -i 's/\s*$//' ${h_file} ${cxx_file} # remove trailing whitespaces
  24. sed -i '${/^$/d;}' ${h_file} ${cxx_file} # remove blank line at the end
  25. sed -i '1i#include "cmStandardLexer.h"' ${cxx_file} # add cmStandardLexer.h include
  26. else
  27. echo "Skipped generating Lexer ${lexer}"
  28. fi
  29. done
  30. # these lexers (at the moment only the ListFileLexer) are compiled as C and do not generate a header
  31. for lexer in ListFile
  32. do
  33. c_file=cm${lexer}Lexer.c
  34. in_file=cm${lexer}Lexer.in.l
  35. if [[ (${in_file} -nt ${c_file}) || (${forced} -gt 0) ]]; then
  36. echo "Generating Lexer ${lexer}"
  37. flex --nounistd -DFLEXINT_H --noline -o${c_file} ${in_file}
  38. sed -i 's/\s*$//' ${c_file} # remove trailing whitespaces
  39. sed -i '${/^$/d;}' ${c_file} # remove blank line at the end
  40. sed -i '1i#include "cmStandardLexer.h"' ${c_file} # add cmStandardLexer.h include
  41. else
  42. echo "Skipped generating Lexer ${lexer}"
  43. fi
  44. done
  45. popd > /dev/null