webengine/osswebengine/WebKit/win/WebKit.vcproj/auto-version.sh
changeset 0 dd21522fd290
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 #!/usr/bin/bash
       
     2 
       
     3 # Copyright (C) 2007 Apple Inc.  All rights reserved.
       
     4 #
       
     5 # Redistribution and use in source and binary forms, with or without
       
     6 # modification, are permitted provided that the following conditions
       
     7 # are met:
       
     8 # 1. Redistributions of source code must retain the above copyright
       
     9 #    notice, this list of conditions and the following disclaimer.
       
    10 # 2. Redistributions in binary form must reproduce the above copyright
       
    11 #    notice, this list of conditions and the following disclaimer in the
       
    12 #    documentation and/or other materials provided with the distribution.
       
    13 #
       
    14 # THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
       
    15 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
       
    16 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
       
    17 # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
       
    18 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
       
    19 # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
       
    20 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
       
    21 # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
       
    22 # OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
       
    23 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
       
    24 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
       
    25 
       
    26 SRCPATH=`cygpath -u "$1"`
       
    27 VERSIONPATH=`cygpath -u "$2"`
       
    28 VERSIONPATH=$VERSIONPATH/include
       
    29 VERSIONFILE=$VERSIONPATH/autoversion.h
       
    30 mkdir -p "$VERSIONPATH"
       
    31 
       
    32 PRODUCTVERSION=`cat "$SRCPATH/PRODUCTVERSION"`
       
    33 MAJORVERSION=`sed 's/\([^\.]*\)\.\([^.]*\)\(\.\([^.]*\)\)\?/\1/' "$SRCPATH/PRODUCTVERSION"`
       
    34 MINORVERSION=`sed 's/\([^\.]*\)\.\([^.]*\)\(\.\([^.]*\)\)\?/\2/' "$SRCPATH/PRODUCTVERSION"`
       
    35 TINYVERSION=`sed 's/\([^\.]*\)\.\([^.]*\)\(\.\([^.]*\)\)\?/\4/' "$SRCPATH/PRODUCTVERSION"`
       
    36 if [ "$TINYVERSION" == "" ]; then
       
    37     TINYVERSION=0
       
    38 fi
       
    39 
       
    40 echo -n `cat "$SRCPATH/VERSION"` > "$VERSIONFILE"
       
    41 
       
    42 if [ `grep -c -E "4\.|4$" "$VERSIONFILE"` -ne 0 ]; then
       
    43     echo "Can't set WebKit's version to something that ends in a 4!"
       
    44     echo "If we do, someone's going to think it's Netscape 4."
       
    45     echo "Radar bug 3787996 has some details."
       
    46     exit 1
       
    47 fi
       
    48 
       
    49 BLDMAJORVERSION=`sed 's/\([^\.]*\)\.\([^.]*\)\(\.\([^.]*\)\)\?/\1/' "$VERSIONFILE"`
       
    50 BLDMINORVERSION=`sed 's/\([^\.]*\)\.\([^.]*\)\(\.\([^.]*\)\)\?/\2/' "$VERSIONFILE"`
       
    51 BLDVARIANTVERSION=`sed 's/\([^\.]*\)\.\([^.]*\)\(\.\([^.]*\)\)\?/\4/' "$VERSIONFILE"`
       
    52 if [ "$BLDVARIANTVERSION" == "" ]; then
       
    53     BLDVARIANTVERSION=0
       
    54 fi
       
    55 SVNOPENSOURCEREVISION=`svn info | grep '^Revision' | sed 's/^Revision: \(.*\)/\1/'`
       
    56 
       
    57 BLDNMBR=`cat "$VERSIONFILE"`
       
    58 BLDNMBRSHORT=`cat "$VERSIONFILE"`
       
    59 BUILDER=""
       
    60 
       
    61 if [ "$BUILDBOT" == "" -o "$ARCHIVE_BUILD" == "1" ]; then
       
    62     echo -n "+" >> "$VERSIONFILE"
       
    63     BLDNMBRSHORT=`cat "$VERSIONFILE"`
       
    64     echo -n " " >> "$VERSIONFILE"
       
    65     echo -n `whoami` >> "$VERSIONFILE"
       
    66     echo -n " - " >> "$VERSIONFILE"
       
    67     echo -n `date` >> "$VERSIONFILE"
       
    68     echo -n " - r$SVNOPENSOURCEREVISION" >> "$VERSIONFILE"
       
    69     BLDNMBR=`cat "$VERSIONFILE"`
       
    70 fi
       
    71 
       
    72 echo -n '#define __VERSION_TEXT__ "' > "$VERSIONFILE"
       
    73 echo -n $PRODUCTVERSION >> "$VERSIONFILE"
       
    74 echo -n " (" >> "$VERSIONFILE"
       
    75 echo -n $BLDNMBR >> "$VERSIONFILE"
       
    76 echo ')"' >> "$VERSIONFILE"
       
    77 echo -n '#define __BUILD_NUMBER_SHORT__ "' >> "$VERSIONFILE"
       
    78 echo -n $BLDNMBRSHORT >> "$VERSIONFILE"
       
    79 echo '"' >> "$VERSIONFILE"
       
    80 
       
    81 echo -n '#define __VERSION_MAJOR__ ' >> "$VERSIONFILE"
       
    82 echo $MAJORVERSION >> "$VERSIONFILE"
       
    83 echo -n '#define __VERSION_MINOR__ ' >> "$VERSIONFILE"
       
    84 echo $MINORVERSION >> "$VERSIONFILE"
       
    85 echo -n '#define __VERSION_TINY__ ' >> "$VERSIONFILE"
       
    86 echo $TINYVERSION >> "$VERSIONFILE"
       
    87 
       
    88 echo -n '#define __BUILD_NUMBER_MAJOR__ ' >> "$VERSIONFILE"
       
    89 echo $BLDMAJORVERSION >> "$VERSIONFILE"
       
    90 echo -n '#define __BUILD_NUMBER_MINOR__ ' >> "$VERSIONFILE"
       
    91 echo $BLDMINORVERSION >> "$VERSIONFILE"
       
    92 echo -n '#define __BUILD_NUMBER_VARIANT__ ' >> "$VERSIONFILE"
       
    93 echo $BLDVARIANTVERSION >> "$VERSIONFILE"
       
    94 
       
    95 echo -n '#define __SVN_REVISION__ ' >> "$VERSIONFILE"
       
    96 echo $SVNREVISION >> "$VERSIONFILE"