java-rebuild.sh 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #! /bin/sh
  2. # Copyright (C) 2011-2017 Free Software Foundation, Inc.
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2, or (at your option)
  7. # any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. # Test rebuild rules for Java class files.
  17. required='javac'
  18. . test-init.sh
  19. cat >> configure.ac <<'END'
  20. AC_OUTPUT
  21. END
  22. cat > Makefile.am <<'END'
  23. AM_JAVACFLAGS = -verbose
  24. foodir = $(datadir)/java
  25. foo_JAVA = a.java
  26. dist_foo_JAVA = d.java
  27. nodist_foo_JAVA = n.java
  28. nobase_foo_JAVA = Nobase.java
  29. nobase_dist_foo_JAVA = NobaseDist.java
  30. nobase_nodist_foo_JAVA = NobaseNoDist.java
  31. END
  32. echo 'class _x {}' > a.java
  33. echo 'class x_ {}' > d.java
  34. echo 'class a {} class d {}' > n.java
  35. echo 'class Nobase_Foo {} class Nobase_Bar {}' > Nobase.java
  36. echo 'class NobaseDist {}' > NobaseDist.java
  37. echo 'class NobaseNoDist {}' > NobaseNoDist.java
  38. $ACLOCAL
  39. $AUTOCONF
  40. $AUTOMAKE
  41. all_classes='_x x_ a d Nobase_Foo Nobase_Bar NobaseDist NobaseNoDist'
  42. for vpath in : false; do
  43. if $vpath; then
  44. srcdir=..
  45. mkdir build
  46. cd build
  47. else
  48. srcdir=.
  49. fi
  50. $srcdir/configure
  51. $MAKE
  52. ls -l # For debugging.
  53. # Sanity check.
  54. test -f classfoo.stamp
  55. for cls in $all_classes; do
  56. test -f $cls.class
  57. done
  58. # When the stampfile is removed, all the *.class files should
  59. # be considered out-of-date.
  60. echo timestamp > older
  61. $sleep
  62. rm -f classfoo.stamp
  63. $MAKE
  64. for cls in $all_classes; do
  65. is_newest $cls.class older
  66. done
  67. # When only a java file is modified, only the *.class files derived from
  68. # it should be updated.
  69. # The strings we loop on here have the following format:
  70. # "JAVA-FILES-TO-BE-TOUCHED -- CLASSES-THAT-SHOULD-BE-UPDATED"
  71. for args in \
  72. 'a -- _x' \
  73. 'd -- x_' \
  74. 'n -- a d' \
  75. 'a d Nobase -- _x x_ Nobase_Foo Nobase_Bar' \
  76. 'n NobaseDist -- a d NobaseDist' \
  77. 'd NobaseNoDist -- x_ NobaseNoDist' \
  78. "a d n Nobase NobaseDist NobaseNoDist -- $all_classes" \
  79. ; do
  80. set $args
  81. touched_javas=
  82. while test $# -gt 0; do
  83. if test x"$1" = x"--"; then
  84. shift
  85. break
  86. else
  87. touched_javas="$touched_javas $1"
  88. shift
  89. fi
  90. done
  91. updated_classes=$*
  92. echo timestamp > older
  93. $sleep
  94. for j in $touched_javas; do
  95. touch $srcdir/$j.java
  96. done
  97. $MAKE
  98. is_newest classfoo.stamp older
  99. for cls in $all_classes; do
  100. case " $updated_classes " in
  101. *" $cls "*) is_newest $cls.class older;;
  102. *) is_newest older $cls.class;;
  103. esac
  104. done
  105. done # $args ...
  106. cd $srcdir
  107. done # $vpath ...
  108. :