[Win] Extend auto-version and version-stamp for RC_ProjectBuildVersion
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Aug 2014 21:09:15 +0000 (21:09 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Aug 2014 21:09:15 +0000 (21:09 +0000)
https://bugs.webkit.org/show_bug.cgi?id=135948
<rdar://problem/18022221>

Reviewed by David Kilzer.

Tools:

* Scripts/webkitperl/auto-version_unittest/autoVersionTests.pl: Add tests
for RC_ProjectBuildVersion.

WebKitLibraries:

* win/tools/scripts/auto-version.pl:
(splitVersion): Use RC_ProjectBuildVersion (or RC_PROJECTBUILDVERSION) if set
in the environment as the 'Build Version', unless the multi-tuple version
supplied by RC_ProjectSourceVersion already has a fourth component.
* win/tools/scripts/version-stamp.pl: Check for RC_ProjectBuildVersion and
use it in preference to RC_PROJECTBUILDVERSION.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@172604 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/Scripts/webkitperl/auto-version_unittest/autoVersionTests.pl
WebKitLibraries/ChangeLog
WebKitLibraries/win/tools/scripts/auto-version.pl
WebKitLibraries/win/tools/scripts/version-stamp.pl

index 868f616..38fac63 100644 (file)
@@ -1,3 +1,14 @@
+2014-08-14  Brent Fulgham  <bfulgham@apple.com>
+
+        [Win] Extend auto-version and version-stamp for RC_ProjectBuildVersion
+        https://bugs.webkit.org/show_bug.cgi?id=135948
+        <rdar://problem/18022221>
+
+        Reviewed by David Kilzer.
+
+        * Scripts/webkitperl/auto-version_unittest/autoVersionTests.pl: Add tests
+        for RC_ProjectBuildVersion.
+
 2014-08-05  David Farler  <dfarler@apple.com>
 
         [iOS] run-webkit-tests runs webkit-build-directory on every test
index 8e52256..97c9e9f 100644 (file)
@@ -501,6 +501,144 @@ my @testCases =
             '__BUILD_NUMBER_VARIANT__' => '64099',
         },
     },
+
+    # Use RC_PROJECTBUILDVERSION or RC_ProjectBuildVersion if our submission version
+    # does not have 4 or more tuples.
+    {
+        'RC_ProjectSourceVersion' => '7600.1',
+        'RC_ProjectBuildVersion' => '26',
+        expectedResults => {
+            '__VERSION_TEXT__' => '600.1',
+            '__BUILD_NUMBER__' => '600.1',
+            '__BUILD_NUMBER_SHORT__' => '600.1',
+            '__VERSION_MAJOR__' => '600',
+            '__VERSION_MINOR__' => '1000',
+            '__VERSION_TINY__' => '0',
+            '__VERSION_BUILD__' => '26',
+            '__BUILD_NUMBER_MAJOR__' => '600',
+            '__BUILD_NUMBER_MINOR__' => '1000',
+            '__BUILD_NUMBER_VARIANT__' => '0',
+        },
+    },
+
+    {
+        'RC_ProjectSourceVersion' => '27',
+        'RC_ProjectBuildVersion' => '14',
+        expectedResults => {
+            '__VERSION_TEXT__' => '27',
+            '__BUILD_NUMBER__' => '27',
+            '__BUILD_NUMBER_SHORT__' => '27',
+            '__VERSION_MAJOR__' => '27',
+            '__VERSION_MINOR__' => '0',
+            '__VERSION_TINY__' => '0',
+            '__VERSION_BUILD__' => '14',
+            '__BUILD_NUMBER_MAJOR__' => '27',
+            '__BUILD_NUMBER_MINOR__' => '0',
+            '__BUILD_NUMBER_VARIANT__' => '0',
+        },
+    },
+
+    {
+        'RC_ProjectSourceVersion' => '27',
+        'RC_PROJECTBUILDVERSION' => '14',
+        expectedResults => {
+            '__VERSION_TEXT__' => '27',
+            '__BUILD_NUMBER__' => '27',
+            '__BUILD_NUMBER_SHORT__' => '27',
+            '__VERSION_MAJOR__' => '27',
+            '__VERSION_MINOR__' => '0',
+            '__VERSION_TINY__' => '0',
+            '__VERSION_BUILD__' => '14',
+            '__BUILD_NUMBER_MAJOR__' => '27',
+            '__BUILD_NUMBER_MINOR__' => '0',
+            '__BUILD_NUMBER_VARIANT__' => '0',
+        },
+    },
+
+    {
+        'RC_PROJECTSOURCEVERSION' => '27',
+        'RC_ProjectBuildVersion' => '14',
+        expectedResults => {
+            '__VERSION_TEXT__' => '27',
+            '__BUILD_NUMBER__' => '27',
+            '__BUILD_NUMBER_SHORT__' => '27',
+            '__VERSION_MAJOR__' => '27',
+            '__VERSION_MINOR__' => '0',
+            '__VERSION_TINY__' => '0',
+            '__VERSION_BUILD__' => '14',
+            '__BUILD_NUMBER_MAJOR__' => '27',
+            '__BUILD_NUMBER_MINOR__' => '0',
+            '__BUILD_NUMBER_VARIANT__' => '0',
+        },
+    },
+
+    {
+        'RC_ProjectSourceVersion' => '5300.4.3.2.1',
+        'RC_ProjectBuildVersion' => '14',
+        expectedResults => {
+            '__VERSION_TEXT__' => '300.4.3.2.1',
+            '__BUILD_NUMBER__' => '300.4.3.2.1',
+            '__BUILD_NUMBER_SHORT__' => '300.4.3.2.1',
+            '__VERSION_MAJOR__' => '300',
+            '__VERSION_MINOR__' => '4003',
+            '__VERSION_TINY__' => '2001',
+            '__VERSION_BUILD__' => '1',
+            '__BUILD_NUMBER_MAJOR__' => '300',
+            '__BUILD_NUMBER_MINOR__' => '4003',
+            '__BUILD_NUMBER_VARIANT__' => '2001',
+        },
+    },
+
+    {
+        'RC_ProjectSourceVersion' => '5300.4.3.2.1',
+        'RC_PROJECTBUILDVERSION' => '14',
+        expectedResults => {
+            '__VERSION_TEXT__' => '300.4.3.2.1',
+            '__BUILD_NUMBER__' => '300.4.3.2.1',
+            '__BUILD_NUMBER_SHORT__' => '300.4.3.2.1',
+            '__VERSION_MAJOR__' => '300',
+            '__VERSION_MINOR__' => '4003',
+            '__VERSION_TINY__' => '2001',
+            '__VERSION_BUILD__' => '1',
+            '__BUILD_NUMBER_MAJOR__' => '300',
+            '__BUILD_NUMBER_MINOR__' => '4003',
+            '__BUILD_NUMBER_VARIANT__' => '2001',
+        },
+    },
+
+    {
+        'RC_PROJECTSOURCEVERSION' => '5300.4.3.2.1',
+        'RC_ProjectBuildVersion' => '14',
+        expectedResults => {
+            '__VERSION_TEXT__' => '300.4.3.2.1',
+            '__BUILD_NUMBER__' => '300.4.3.2.1',
+            '__BUILD_NUMBER_SHORT__' => '300.4.3.2.1',
+            '__VERSION_MAJOR__' => '300',
+            '__VERSION_MINOR__' => '4003',
+            '__VERSION_TINY__' => '2001',
+            '__VERSION_BUILD__' => '1',
+            '__BUILD_NUMBER_MAJOR__' => '300',
+            '__BUILD_NUMBER_MINOR__' => '4003',
+            '__BUILD_NUMBER_VARIANT__' => '2001',
+        },
+    },
+
+    {
+        'RC_PROJECTSOURCEVERSION' => '5300.4.3.2.1',
+        'RC_PROJECTBUILDVERSION' => '14',
+        expectedResults => {
+            '__VERSION_TEXT__' => '300.4.3.2.1',
+            '__BUILD_NUMBER__' => '300.4.3.2.1',
+            '__BUILD_NUMBER_SHORT__' => '300.4.3.2.1',
+            '__VERSION_MAJOR__' => '300',
+            '__VERSION_MINOR__' => '4003',
+            '__VERSION_TINY__' => '2001',
+            '__VERSION_BUILD__' => '1',
+            '__BUILD_NUMBER_MAJOR__' => '300',
+            '__BUILD_NUMBER_MINOR__' => '4003',
+            '__BUILD_NUMBER_VARIANT__' => '2001',
+        },
+    },
 );
 
 # This test should only be run on Windows
@@ -517,7 +655,22 @@ foreach my $testCase (@testCases) {
     my $toolsPath = $ENV{'WEBKIT_LIBRARIES'};
     my $autoVersionScript = File::Spec->catfile($toolsPath, 'tools', 'scripts', 'auto-version.pl');
     my $testOutputDir = tempdir(CLEANUP => 1);
-    `RC_ProjectSourceVersion="$testCase->{'RC_ProjectSourceVersion'}" perl $autoVersionScript $testOutputDir`;
+    my $testFlags;
+    if ($testCase->{'RC_ProjectSourceVersion'}) {
+        $testFlags = " RC_ProjectSourceVersion=\"$testCase->{'RC_ProjectSourceVersion'}\"";
+    } elsif ($testCase->{'RC_PROJECTSOURCEVERSION'}) {
+        $testFlags = " RC_PROJECTSOURCEVERSION=\"$testCase->{'RC_PROJECTSOURCEVERSION'}\"";
+    } else {
+        die ("Missing the RC_ProjectSourceVersion environment variable.\n");
+    }
+
+    if ($testCase->{'RC_ProjectBuildVersion'}) {
+        $testFlags .= " RC_ProjectBuildVersion=\"$testCase->{'RC_ProjectBuildVersion'}\"";
+    } elsif ($testCase->{'RC_PROJECTBUILDVERSION'}) {
+        $testFlags .= " RC_PROJECTBUILDVERSION=\"$testCase->{'RC_PROJECTBUILDVERSION'}\"";
+    }
+
+    `$testFlags perl $autoVersionScript $testOutputDir`;
 
     my $expectedResults = $testCase->{expectedResults};
 
@@ -536,7 +689,11 @@ foreach my $testCase (@testCases) {
             chomp($line);
 
             my $expectedResultValue = $expectedResults->{$expectedResultKey};
-            is($line, $expectedResultValue, "$testCase->{'RC_ProjectSourceVersion'}: $expectedResultKey");
+            if ($testCase->{'RC_ProjectSourceVersion'}) {
+                is($line, $expectedResultValue, "$testCase->{'RC_ProjectSourceVersion'}: $expectedResultKey");
+            } else {
+                is($line, $expectedResultValue, "$testCase->{'RC_PROJECTSOURCEVERSION'}: $expectedResultKey");
+            }
         }
     }
 
index 1dffc26..f8cf581 100644 (file)
@@ -1,3 +1,18 @@
+2014-08-14  Brent Fulgham  <bfulgham@apple.com>
+
+        [Win] Extend auto-version and version-stamp for RC_ProjectBuildVersion
+        https://bugs.webkit.org/show_bug.cgi?id=135948
+        <rdar://problem/18022221>
+
+        Reviewed by David Kilzer.
+
+        * win/tools/scripts/auto-version.pl:
+        (splitVersion): Use RC_ProjectBuildVersion (or RC_PROJECTBUILDVERSION) if set
+        in the environment as the 'Build Version', unless the multi-tuple version
+        supplied by RC_ProjectSourceVersion already has a fourth component.
+        * win/tools/scripts/version-stamp.pl: Check for RC_ProjectBuildVersion and
+        use it in preference to RC_PROJECTBUILDVERSION.
+
 2014-08-08  Joseph Pecoraro  <pecoraro@apple.com>
 
         make clean does not work in OpenSource, fails in WebKitLibraries
index d085f1d..b38c480 100755 (executable)
@@ -62,12 +62,8 @@ my $OUTPUT_FILE = File::Spec->catfile($OUTPUT_DIR, 'autoversion.h');
 
 # Take the initial version number from RC_ProjectSourceVersion if it
 # exists, otherwise fall back to the version number stored in the source.
-my $ENVIRONMENT_VERSION = $ENV{'RC_ProjectSourceVersion'};
-if (!defined $ENVIRONMENT_VERSION) {
-    $ENVIRONMENT_VERSION = $ENV{'RC_PROJECTSOURCEVERSION'};
-}
-
-my $PROPOSED_VERSION = (defined $ENVIRONMENT_VERSION) ? $ENVIRONMENT_VERSION : $FALLBACK_VERSION;
+my $ENVIRONMENT_VERSION = $ENV{'RC_ProjectSourceVersion'} || $ENV{'RC_PROJECTSOURCEVERSION'};
+my $PROPOSED_VERSION = $ENVIRONMENT_VERSION || $FALLBACK_VERSION;
 chomp($PROPOSED_VERSION);
 
 my ($BUILD_MAJOR_VERSION, $BUILD_MINOR_VERSION, $BUILD_TINY_VERSION, $BUILD_VARIANT_VERSION, $ADJUSTED_PROPOSED_VERSION) = splitVersion($PROPOSED_VERSION);
@@ -153,7 +149,7 @@ sub splitVersion($)
         $BUILD_MICRO_VERSION = $components[3];
     }
 
-    my $RETURN_NANO_VERSION = $BUILD_MICRO_VERSION;
+    my $RETURN_NANO_VERSION = $ENV{'RC_ProjectBuildVersion'} || $ENV{'RC_PROJECTBUILDVERSION'} || $BUILD_MICRO_VERSION;
     if ($componentCount > 4) {
         $BUILD_NANO_VERSION = $components[4];
         $RETURN_NANO_VERSION = $BUILD_NANO_VERSION;
@@ -171,4 +167,3 @@ sub splitVersion($)
 
     return ($BUILD_MAJOR_VERSION, packTwoValues($BUILD_MINOR_VERSION, $BUILD_TINY_VERSION), packTwoValues($BUILD_MICRO_VERSION, $BUILD_NANO_VERSION), $RETURN_NANO_VERSION, $PROPOSED_VERSION);
 }
-
index 0b3aba4..967bb6c 100644 (file)
@@ -91,7 +91,7 @@ my $TARGET_PATH = File::Spec->canonpath($target);
 print "Adjusting RC_PROJECTSOURCEVERSION and RC_ProjectSourceVersion to be safe for VersionStamper.\n";
 
 my $SAFE_PROJECT_VERSION = "$components{'__VERSION_MAJOR__'}.$components{'__VERSION_MINOR__'}.$components{'__VERSION_TINY__'}";
-my $SAFE_BUILD_VERSION = $ENV{RC_PROJECTBUILDVERSION} || $components{'__VERSION_BUILD__'};
+my $SAFE_BUILD_VERSION = $ENV{RC_ProjectBuildVersion} || $ENV{RC_PROJECTBUILDVERSION} || $components{'__VERSION_BUILD__'};
 
 print "Using RC_PROJECTSOURCEVERSION=$SAFE_PROJECT_VERSION and RC_PROJECTBUILDVERSION=$SAFE_BUILD_VERSION\n";