Tue, 10 Apr 2012 08:18:28 -0700
7074397: Build infrastructure changes (makefile re-write)
Summary: New makefiles transition, old and new living side by side for now.
Reviewed-by: ohair, jjg, dholmes, ohrstrom, erikj, ihse, tgranat, ykantser
Contributed-by: ohrstrom <fredrik.ohrstrom@oracle.com>, erikj <erik.joelsson@oracle.com>, ihse <magnus.ihse.bursie@oracle.com>, tgranat <torbjorn.granat@oracle.com>, ykantser <yekaterina.kantserova@oracle.com>
ohair@425 | 1 | #!/bin/bash |
ohair@425 | 2 | # |
ohair@425 | 3 | # Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
ohair@425 | 4 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ohair@425 | 5 | # |
ohair@425 | 6 | # This code is free software; you can redistribute it and/or modify it |
ohair@425 | 7 | # under the terms of the GNU General Public License version 2 only, as |
ohair@425 | 8 | # published by the Free Software Foundation. |
ohair@425 | 9 | # |
ohair@425 | 10 | # This code is distributed in the hope that it will be useful, but WITHOUT |
ohair@425 | 11 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ohair@425 | 12 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ohair@425 | 13 | # version 2 for more details (a copy is included in the LICENSE file that |
ohair@425 | 14 | # accompanied this code). |
ohair@425 | 15 | # |
ohair@425 | 16 | # You should have received a copy of the GNU General Public License version |
ohair@425 | 17 | # 2 along with this work; if not, write to the Free Software Foundation, |
ohair@425 | 18 | # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ohair@425 | 19 | # |
ohair@425 | 20 | # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@425 | 21 | # or visit www.oracle.com if you need additional information or have any |
ohair@425 | 22 | # questions. |
ohair@425 | 23 | # |
ohair@425 | 24 | |
ohair@425 | 25 | # MANUAL |
ohair@425 | 26 | # |
ohair@425 | 27 | # ./common/bin/compareimages.sh old_jdk_image new_jdk_image |
ohair@425 | 28 | # |
ohair@425 | 29 | # Compare the directory structure. |
ohair@425 | 30 | # Compare the filenames in the directories. |
ohair@425 | 31 | # Compare the contents of the zip archives |
ohair@425 | 32 | # Compare the contents of the jar archives |
ohair@425 | 33 | # Compare the native libraries |
ohair@425 | 34 | # Compare the native executables |
ohair@425 | 35 | # Compare the remaining files |
ohair@425 | 36 | # |
ohair@425 | 37 | # ./common/bin/compareimages.sh old_jdk_image new_jdk_image [zips jars libs execs other] |
ohair@425 | 38 | # |
ohair@425 | 39 | # Compare only the selected subset of the images. |
ohair@425 | 40 | # |
ohair@425 | 41 | # ./common/bin/compareimages.sh old_jdk_image new_jdk_image CodePointIM.jar |
ohair@425 | 42 | # |
ohair@425 | 43 | # Compare only the CodePointIM.jar file |
ohair@425 | 44 | # Can be used to compare zips, libraries and executables. |
ohair@425 | 45 | # |
ohair@425 | 46 | |
ohair@425 | 47 | if [ "x$1" = "x-h" ] || [ "x$1" = "x--help" ] || [ "x$1" == "x" ]; then |
ohair@425 | 48 | echo "./common/bin/compareimages.sh old_jdk_image new_jdk_image" |
ohair@425 | 49 | echo "" |
ohair@425 | 50 | echo "Compare the directory structure." |
ohair@425 | 51 | echo "Compare the filenames in the directories." |
ohair@425 | 52 | echo "Compare the contents of the zip archives" |
ohair@425 | 53 | echo "Compare the contents of the jar archives" |
ohair@425 | 54 | echo "Compare the native libraries" |
ohair@425 | 55 | echo "Compare the native executables" |
ohair@425 | 56 | echo "Compare the remaining files" |
ohair@425 | 57 | echo "" |
ohair@425 | 58 | echo "./common/bin/compareimages.sh old_jdk_image new_jdk_image [zips jars libs execs other]" |
ohair@425 | 59 | echo "" |
ohair@425 | 60 | echo "Compare only the selected subset of the images." |
ohair@425 | 61 | echo "" |
ohair@425 | 62 | echo "./common/bin/compareimages.sh old_jdk_image new_jdk_image CodePointIM.jar" |
ohair@425 | 63 | echo "" |
ohair@425 | 64 | echo "Compare only the CodePointIM.jar file" |
ohair@425 | 65 | echo "Can be used to compare zips, libraries and executables." |
ohair@425 | 66 | exit 10 |
ohair@425 | 67 | fi |
ohair@425 | 68 | |
ohair@425 | 69 | OLD="$1" |
ohair@425 | 70 | NEW="$2" |
ohair@425 | 71 | CMD="$3" |
ohair@425 | 72 | |
ohair@425 | 73 | DIFF_RESULT=0 |
ohair@425 | 74 | |
ohair@425 | 75 | CMP_ZIPS=false |
ohair@425 | 76 | CMP_JARS=false |
ohair@425 | 77 | CMP_LIBS=false |
ohair@425 | 78 | CMP_EXECS=false |
ohair@425 | 79 | CMP_OTHER=false |
ohair@425 | 80 | |
ohair@425 | 81 | FILTER="cat" |
ohair@425 | 82 | |
ohair@425 | 83 | if [ -n "$CMD" ]; then |
ohair@425 | 84 | case "$CMD" in |
ohair@425 | 85 | zips) |
ohair@425 | 86 | CMP_ZIPS=true |
ohair@425 | 87 | ;; |
ohair@425 | 88 | jars) |
ohair@425 | 89 | CMP_JARS=true |
ohair@425 | 90 | ;; |
ohair@425 | 91 | libs) |
ohair@425 | 92 | CMP_LIBS=true |
ohair@425 | 93 | ;; |
ohair@425 | 94 | execs) |
ohair@425 | 95 | CMP_EXECS=true |
ohair@425 | 96 | ;; |
ohair@425 | 97 | other) |
ohair@425 | 98 | CMP_OTHER=true |
ohair@425 | 99 | ;; |
ohair@425 | 100 | *) |
ohair@425 | 101 | CMP_ZIPS=true |
ohair@425 | 102 | CMP_JARS=true |
ohair@425 | 103 | CMP_LIBS=true |
ohair@425 | 104 | CMP_EXECS=true |
ohair@425 | 105 | CMP_OTHER=true |
ohair@425 | 106 | FILTER="grep $3" |
ohair@425 | 107 | ;; |
ohair@425 | 108 | esac |
ohair@425 | 109 | else |
ohair@425 | 110 | CMP_ZIPS=true |
ohair@425 | 111 | CMP_JARS=true |
ohair@425 | 112 | CMP_LIBS=true |
ohair@425 | 113 | CMP_EXECS=true |
ohair@425 | 114 | CMP_OTHER=true |
ohair@425 | 115 | fi |
ohair@425 | 116 | |
ohair@425 | 117 | DIFFJARZIP=`dirname $0`/diffjarzip.sh |
ohair@425 | 118 | DIFFLIB=`dirname $0`/difflib.sh |
ohair@425 | 119 | DIFFEXEC=`dirname $0`/diffexec.sh |
ohair@425 | 120 | export COMPARE_ROOT=/tmp/cimages |
ohair@425 | 121 | mkdir -p $COMPARE_ROOT |
ohair@425 | 122 | |
ohair@425 | 123 | # Load the correct exception list. |
ohair@425 | 124 | case "`uname -s`" in |
ohair@425 | 125 | Linux) |
ohair@425 | 126 | . `dirname $0`/exception_list_linux |
ohair@425 | 127 | ;; |
ohair@425 | 128 | esac |
ohair@425 | 129 | |
ohair@425 | 130 | echo |
ohair@425 | 131 | echo Comparing $OLD to $NEW |
ohair@425 | 132 | echo |
ohair@425 | 133 | |
ohair@425 | 134 | (cd $OLD && find . -type d | sort > $COMPARE_ROOT/from_dirs) |
ohair@425 | 135 | (cd $NEW && find . -type d | sort > $COMPARE_ROOT/to_dirs) |
ohair@425 | 136 | |
ohair@425 | 137 | echo -n Directory structure... |
ohair@425 | 138 | if diff $COMPARE_ROOT/from_dirs $COMPARE_ROOT/to_dirs > /dev/null; then |
ohair@425 | 139 | echo Identical! |
ohair@425 | 140 | else |
ohair@425 | 141 | echo Differences found. |
ohair@425 | 142 | DIFF_RESULT=1 |
ohair@425 | 143 | # Differences in directories found. |
ohair@425 | 144 | ONLY_OLD=$(diff $COMPARE_ROOT/from_dirs $COMPARE_ROOT/to_dirs | grep '<') |
ohair@425 | 145 | if [ "$ONLY_OLD" ]; then |
ohair@425 | 146 | echo Only in $OLD |
ohair@425 | 147 | echo $ONLY_OLD | sed 's|< ./|\t|g' | sed 's/ /\n/g' |
ohair@425 | 148 | fi |
ohair@425 | 149 | # Differences in directories found. |
ohair@425 | 150 | ONLY_NEW=$(diff $COMPARE_ROOT/from_dirs $COMPARE_ROOT/to_dirs | grep '>') |
ohair@425 | 151 | if [ "$ONLY_NEW" ]; then |
ohair@425 | 152 | echo Only in $NEW |
ohair@425 | 153 | echo $ONLY_NEW | sed 's|> ./|\t|g' | sed 's/ /\n/g' |
ohair@425 | 154 | fi |
ohair@425 | 155 | fi |
ohair@425 | 156 | |
ohair@425 | 157 | (cd $OLD && find . -type f | sort > $COMPARE_ROOT/from_files) |
ohair@425 | 158 | (cd $NEW && find . -type f | sort > $COMPARE_ROOT/to_files) |
ohair@425 | 159 | |
ohair@425 | 160 | echo -n File names... |
ohair@425 | 161 | if diff $COMPARE_ROOT/from_files $COMPARE_ROOT/to_files > /dev/null; then |
ohair@425 | 162 | echo Identical! |
ohair@425 | 163 | else |
ohair@425 | 164 | echo Differences found. |
ohair@425 | 165 | DIFF_RESULT=1 |
ohair@425 | 166 | # Differences in directories found. |
ohair@425 | 167 | ONLY_OLD=$(diff $COMPARE_ROOT/from_files $COMPARE_ROOT/to_files | grep '<') |
ohair@425 | 168 | if [ "$ONLY_OLD" ]; then |
ohair@425 | 169 | echo Only in $OLD |
ohair@425 | 170 | echo $ONLY_OLD | sed 's|< ./|\t|g' | sed 's/ /\n/g' |
ohair@425 | 171 | fi |
ohair@425 | 172 | # Differences in directories found. |
ohair@425 | 173 | ONLY_NEW=$(diff $COMPARE_ROOT/from_files $COMPARE_ROOT/to_files | grep '>') |
ohair@425 | 174 | if [ "$ONLY_NEW" ]; then |
ohair@425 | 175 | echo Only in $NEW |
ohair@425 | 176 | echo $ONLY_NEW | sed 's|> ./|\t|g' | sed 's/ /\n/g' |
ohair@425 | 177 | fi |
ohair@425 | 178 | fi |
ohair@425 | 179 | |
ohair@425 | 180 | if [ "x$CMP_ZIPS" == "xtrue" ]; then |
ohair@425 | 181 | ZIPS=$(cd $OLD && find . -type f -name "*.zip" | sort | $FILTER) |
ohair@425 | 182 | |
ohair@425 | 183 | if [ -n "$ZIPS" ]; then |
ohair@425 | 184 | echo Zip files... |
ohair@425 | 185 | |
ohair@425 | 186 | for f in $ZIPS |
ohair@425 | 187 | do |
ohair@425 | 188 | $DIFFJARZIP $OLD/$f $NEW/$f $OLD $NEW |
ohair@425 | 189 | if [ "$?" != "0" ]; then |
ohair@425 | 190 | DIFF_RESULT=1 |
ohair@425 | 191 | fi |
ohair@425 | 192 | done |
ohair@425 | 193 | fi |
ohair@425 | 194 | fi |
ohair@425 | 195 | |
ohair@425 | 196 | if [ "x$CMP_JARS" == "xtrue" ]; then |
ohair@425 | 197 | JARS=$(cd $OLD && find . -type f -name "*.jar" | sort | $FILTER) |
ohair@425 | 198 | |
ohair@425 | 199 | if [ -n "$JARS" ]; then |
ohair@425 | 200 | echo Jar files... |
ohair@425 | 201 | |
ohair@425 | 202 | for f in $JARS |
ohair@425 | 203 | do |
ohair@425 | 204 | DIFFJAR_OUTPUT=`$DIFFJARZIP $OLD/$f $NEW/$f $OLD $NEW` |
ohair@425 | 205 | DIFFJAR_RESULT=$? |
ohair@425 | 206 | if [ "$DIFFJAR_RESULT" != "0" ]; then |
ohair@425 | 207 | for diff in $LIST_DIFF_JAR; do |
ohair@425 | 208 | DIFFJAR_OUTPUT=`echo "$DIFFJAR_OUTPUT" | grep -v "$diff"` |
ohair@425 | 209 | done |
ohair@425 | 210 | if [ "`echo "$DIFFJAR_OUTPUT" | grep -v "Differing files in"`" != "" ]; then |
ohair@425 | 211 | DIFF_RESULT=1 |
ohair@425 | 212 | echo "$DIFFJAR_OUTPUT" |
ohair@425 | 213 | fi |
ohair@425 | 214 | fi |
ohair@425 | 215 | done |
ohair@425 | 216 | fi |
ohair@425 | 217 | fi |
ohair@425 | 218 | |
ohair@425 | 219 | if [ "x$FILTER" != "xcat" ]; then |
ohair@425 | 220 | VIEW=view |
ohair@425 | 221 | else |
ohair@425 | 222 | VIEW= |
ohair@425 | 223 | fi |
ohair@425 | 224 | |
ohair@425 | 225 | if [ "x$CMP_LIBS" == "xtrue" ]; then |
ohair@425 | 226 | LIBS=$(cd $OLD && find . -name 'lib*.so' -o -name '*.dylib' -o -name '*.dll' | sort | $FILTER) |
ohair@425 | 227 | |
ohair@425 | 228 | if [ -n "$LIBS" ]; then |
ohair@425 | 229 | echo Libraries... |
ohair@425 | 230 | for f in $LIBS |
ohair@425 | 231 | do |
ohair@425 | 232 | DIFFLIB_OUTPUT=`$DIFFLIB $OLD/$f $NEW/$f $OLD $NEW $VIEW` |
ohair@425 | 233 | DIFFLIB_RESULT=$? |
ohair@425 | 234 | if [ "$DIFFLIB_RESULT" = "0" ]; then |
ohair@425 | 235 | : |
ohair@425 | 236 | #echo "OK: $DIFFLIB_OUTPUT" |
ohair@425 | 237 | elif [ "$DIFFLIB_RESULT" = "2" ] && [[ "$LIST_DIFF_SIZE $LIST_DIFF_BYTE" == *"${f:2}"* ]]; then |
ohair@425 | 238 | : |
ohair@425 | 239 | #echo "OK: $DIFFLIB_OUTPUT" |
ohair@425 | 240 | elif [ "$DIFFLIB_RESULT" = "1" ] && [[ "$LIST_DIFF_BYTE" == *"${f:2}"* ]]; then |
ohair@425 | 241 | : |
ohair@425 | 242 | #echo "OK: $DIFFLIB_OUTPUT" |
ohair@425 | 243 | else |
ohair@425 | 244 | echo "$DIFFLIB_OUTPUT" |
ohair@425 | 245 | DIFF_RESULT=1 |
ohair@425 | 246 | fi |
ohair@425 | 247 | done |
ohair@425 | 248 | fi |
ohair@425 | 249 | fi |
ohair@425 | 250 | |
ohair@425 | 251 | if [ "x$CMP_EXECS" == "xtrue" ]; then |
ohair@425 | 252 | if [ $OSTYPE == "cygwin" ]; then |
ohair@425 | 253 | EXECS=$(cd $OLD && find . -type f -name '*.exe' | sort | $FILTER) |
ohair@425 | 254 | else |
ohair@425 | 255 | EXECS=$(cd $OLD && find . -type f -perm -100 \! \( -name '*.so' -o -name '*.dylib' -o -name '*.dll' \) | sort | $FILTER) |
ohair@425 | 256 | fi |
ohair@425 | 257 | |
ohair@425 | 258 | |
ohair@425 | 259 | if [ -n "$EXECS" ]; then |
ohair@425 | 260 | echo Executables... |
ohair@425 | 261 | |
ohair@425 | 262 | for f in $EXECS |
ohair@425 | 263 | do |
ohair@425 | 264 | DIFFEXEC_OUTPUT=`$DIFFEXEC $OLD/$f $NEW/$f $OLD $NEW $VIEW` |
ohair@425 | 265 | DIFFEXEC_RESULT=$? |
ohair@425 | 266 | if [ "$DIFFEXEC_RESULT" = "0" ]; then |
ohair@425 | 267 | : |
ohair@425 | 268 | #echo "OK: $DIFFEXEC_OUTPUT" |
ohair@425 | 269 | elif [ "$DIFFEXEC_RESULT" = "2" ] && [[ "$LIST_DIFF_SIZE $LIST_DIFF_BYTE" == *"${f:2}"* ]]; then |
ohair@425 | 270 | : |
ohair@425 | 271 | #echo "OK: $DIFFEXEC_OUTPUT" |
ohair@425 | 272 | elif [ "$DIFFEXEC_RESULT" = "1" ] && [[ "$LIST_DIFF_BYTE" == *"${f:2}"* ]]; then |
ohair@425 | 273 | : |
ohair@425 | 274 | #echo "OK: $DIFFEXEC_OUTPUT" |
ohair@425 | 275 | else |
ohair@425 | 276 | echo "$DIFFEXEC_OUTPUT" |
ohair@425 | 277 | DIFF_RESULT=1 |
ohair@425 | 278 | fi |
ohair@425 | 279 | done |
ohair@425 | 280 | fi |
ohair@425 | 281 | fi |
ohair@425 | 282 | |
ohair@425 | 283 | exit $DIFF_RESULT |