Makefile 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. # Andreas, 2015-08-11, clone of ../interaction/Makefile
  2. TOP = ../..
  3. include $(TOP)/mk/paths.mk
  4. uname:=$(shell uname)
  5. ifeq (NT-5,$(findstring NT-5,$(uname)))
  6. pwd=$(shell (cmd /c 'echo %CD%') | $(SED) -e 's/\\/\\\\\\\\/g')
  7. pwdPlusDelimiter=$(pwd)\\\\
  8. else
  9. pwd=$(shell pwd)
  10. pwdPlusDelimiter=$(pwd)/
  11. endif
  12. clean=/usr/bin/env bash $(shell pwd)/clean.sh $(SED)
  13. # Andreas, 2017-04-24 ls -t: sort by newest first
  14. AgdaFiles=$(shell ls -t *agda)
  15. OutFiles=$(patsubst %.lagda,%.out,$(patsubst %.agda,%.out,$(AgdaFiles)))
  16. Tests=$(patsubst %.lagda,%.cmp,$(patsubst %.agda,%.cmp,$(AgdaFiles)))
  17. default : $(Tests)
  18. export TMPDIR=highlighting-tmp
  19. # Filter out absolute pathes
  20. filter=$(SED) -e 's"$(pwdPlusDelimiter)""g' \
  21. -e 's"$(pwd)""g' \
  22. -e 's" \"$(TMPDIR).*\"""' \
  23. -e 's"[^ (\"]*lib.prim"agda-default-include-path"g' \
  24. -e 's/\(\\n\| \)\+/ /g' \
  25. | $(clean)
  26. # Turn off "eager failure" flags (e, E, pipefail) while running the test.
  27. run_test=\
  28. set +eE +o pipefail; \
  29. if test -f $*.in; \
  30. then cat $*.in \
  31. | $(SED) "s/ioTCM/IOTCM/g" \
  32. | $(SED) "s/cmd_/Cmd_/g" \
  33. | $(SED) "s/showImplicitArgs/ShowImplicitArgs/g" \
  34. | $(SED) "s/toggleImplicitArgs/ToggleImplicitArgs/g" \
  35. | $(SED) "s/top_command/IOTCM currentFile None Indirect/g" \
  36. | $(SED) "s/goal_command \\([0-9]\+\\) (\\([^)]\+\\)) \\(\"[^\"]*\"\\)/IOTCM currentFile None Indirect (\\2 \\1 noRange \\3)/g" \
  37. | $(SED) "s/goal_command \\([0-9]\+\\) \\([^ ]\+\\) \\(\"[^\"]*\"\\)/IOTCM currentFile None Indirect (\\2 \\1 noRange \\3)/g" \
  38. | $(SED) "s/currentFile/\"$(wildcard $*.agda $*.lagda)\"/g" \
  39. | $(AGDA_BIN) -v 0 -i . -i .. --interaction --no-default-libraries $(RTS_$*) \
  40. 2>&1 | $(filter) ; \
  41. else /usr/bin/env bash ./$*.sh $(AGDA_BIN) > $(TMPDIR)/$*.tmp_out ; \
  42. cat $(TMPDIR)/$*.tmp_out | $(filter) ; \
  43. fi
  44. # Note that RTS_... variables are ignored when .sh files are used.
  45. # For RTS_... and setup_... variable examples, see ../interaction/Makefile.
  46. # No recorded output
  47. $(OutFiles) : %.out : $(wildcard %.agda %.lagda) $(wildcard %.in %.in_ghci)
  48. @-mkdir -p $(TMPDIR)
  49. @$(setup_$*)
  50. @rm -f "$(@:.out=.agdai)"
  51. @echo "=== Output for $* ==="
  52. @$(run_test) > $@
  53. @cat $@
  54. @echo "=== End of output ==="
  55. @rm -rf $(TMPDIR)
  56. # Comparing output
  57. $(Tests) : %.cmp : %.out
  58. @-mkdir -p $(TMPDIR)
  59. @$(setup_$*)
  60. @rm -f "$(@:.cmp=.agdai)"
  61. @echo $*
  62. @$(run_test) > $*.tmp
  63. @if diff -q -b $*.out $*.tmp; \
  64. then rm -f $*.tmp; true; \
  65. else \
  66. echo "=== Old output ==="; \
  67. cat $*.out; \
  68. echo "=== New output ==="; \
  69. cat $*.tmp; \
  70. echo "=== Diff ==="; \
  71. ( git diff --no-index --no-ext-diff -w $*.out $*.tmp || true ) ; \
  72. /bin/echo -n "Accept new error [y/N/q]? "; \
  73. read -n 1; \
  74. echo ""; \
  75. if [ "fckShPrg$$REPLY" != "fckShPrgy" ]; \
  76. then echo "Keeping old output"; \
  77. rm -f $*.tmp; \
  78. rm -rf $(TMPDIR); \
  79. if [ "$(cleanup_$*)" != "" ]; then $(cleanup_$*)"" ; fi ; \
  80. [ "X$$REPLY" != "Xq" ]; \
  81. else echo "Replacing output, continuing..."; \
  82. mv $*.tmp $*.out; \
  83. true; \
  84. fi; \
  85. fi
  86. @$(cleanup_$*)
  87. @rm -rf $(TMPDIR)
  88. # EOF