dmake 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/bin/sh -x
  2. # helper script to run make using GNU AWK with colorizing in development.
  3. #
  4. # /*
  5. # * Copyright (C) 2011 T Lefering
  6. # *
  7. # * This program is free software: you can redistribute it and/or modify
  8. # * it under the terms of the GNU General Public License as published by
  9. # * the Free Software Foundation, either version 3 of the License, or
  10. # * (at your option) any later version.
  11. # *
  12. # * This program is distributed in the hope that it will be useful,
  13. # * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # * GNU General Public License for more details.
  16. # *
  17. # * You should have received a copy of the GNU General Public License
  18. # * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. # *
  20. # * The four essential freedoms with GNU GPL software:
  21. # * The freedom to run the program, for any purpose
  22. # * The freedom to study how the program works, and change it to make it do what you wish
  23. # * The freedom to redistribute copies so you can help others
  24. # * The freedom to distribute copies of your modified versions to others
  25. # */
  26. #
  27. # GNU / Linux is user-friendly. It's just particular who its friends are :)
  28. #
  29. # Only for GNU LINUX console:
  30. #
  31. # \033 ascii ESCape
  32. # \033[<NUM>G move to column <NUM> (linux console, xterm, not vt100)
  33. # \033[<NUM>C move <NUM> columns forward but only upto last column
  34. # \033[<NUM>D move <NUM> columns backward but only upto first column
  35. # \033[<NUM>A move <NUM> rows up
  36. # \033[<NUM>B move <NUM> rows down
  37. # \033[1m switch on bold
  38. # \033[31m switch on red
  39. # \033[32m switch on green
  40. # \033[33m switch on yellow
  41. # \033[m switch off color/bold
  42. # \017 exit alternate mode (xterm, vt100, linux console)
  43. # \033[10m exit alternate mode (linux console)
  44. # \015 carriage return (without newline)
  45. # Black 0;30 Dark Gray 1;30
  46. # Blue 0;34 Light Blue 1;34
  47. # Green 0;32 Light Green 1;32
  48. # Cyan 0;36 Light Cyan 1;36
  49. # Red 0;31 Light Red 1;31
  50. # Purple 0;35 Light Purple 1;35
  51. # Brown 0;33 Yellow 1;33
  52. # Light Gray 0;37 White 1;37
  53. #
  54. # normally 4 args to make should be oke. otherwise argv() to do.
  55. # add colors for enter/leave dir
  56. # if errors then run script to mailto or otherwise
  57. # if errors then run script to start emacs on the file
  58. rm -v -f dsmake.output
  59. rm -v -f dsmake.errors
  60. rm -v -f dsmake.warnings
  61. make $1 $2 $3 $4 2>&1 |
  62. gawk '
  63. function toul() { print "\033[4m"; }
  64. function tobold() { print "\033[36m"; }
  65. function isentermakedir(thetext) { n = match(thetext, /[ ]Entering/); return n; }
  66. function isleavemakedir(thetext) { n = match(thetext, /[ ]Leaving/); return n; }
  67. function isgccerr(thetext) { n = match(thetext, /[ ]error:/); return n; }
  68. function isgccwarning(thetext) { n = match(thetext, /[ ]warning:/); return n; }
  69. BEGIN { tobold(); print "\033[34m"; print ":)" > "dsmake.output" }
  70. /^/ { print $0 > "dsmake.output"; print "\033[34m"; if(isgccerr($0)) { print "\033[31m"; print $0 > "dsmake.errors"; } ; if(isgccwarning($0)) { print "\033[35m"; print $0 > "dsmake.warnings" } ; print $0; next; }
  71. END { print "end of make" > "dsmake.output"; print "\033[10m"; }
  72. '
  73. # end.