[CMake] Use target oriented design for bmalloc
[WebKit-https.git] / WebKitLibraries / win / tools / scripts / version-stamp.pl
index a6f1cd4753262c0ffb3c2eac34072ff474919cfe..b0627f0043b664fd56493497f212da5a8471fad3 100644 (file)
@@ -1,7 +1,10 @@
 #!/usr/bin/perl -w
 
 use strict;
+use Cwd 'abs_path';
+use File::Basename;
 use File::Spec;
+use POSIX;
 
 # Copyright (C) 2007, 2009, 2014 Apple Inc.  All rights reserved.
 #
@@ -28,9 +31,11 @@ use File::Spec;
 
 sub exitStatus($);
 
-my $WEBKIT_LIBRARIES = $ENV{'WEBKIT_LIBRARIES'};
+my $rawPath = $0;
 
-my $VERSION_STAMPER = File::Spec->catfile($WEBKIT_LIBRARIES, 'tools', 'VersionStamper', 'VersionStamper.exe');
+my $thisDirectory = dirname(abs_path($rawPath));
+
+my $VERSION_STAMPER = File::Spec->catfile($thisDirectory, '..', 'VersionStamper', 'VersionStamper.exe');
 
 unless (-e $VERSION_STAMPER) {
     print "No $VERSION_STAMPER executable. Exiting.\n";
@@ -62,6 +67,7 @@ my %components =
     '__VERSION_MINOR__' => undef,
     '__VERSION_TINY__' => undef,
     '__VERSION_BUILD__' => undef,
+    '__FULL_BUILD_MAJOR_VERSION__' => undef,
 );
 
 my $VERSION_FILE = File::Spec->catfile(File::Spec->canonpath($intdir), 'include', 'autoversion.h');
@@ -87,20 +93,23 @@ print "Processing version $components{'__VERSION_TEXT__'} for $target\n";
 
 my $TARGET_PATH = File::Spec->canonpath($target);
 
+# Replace forward slashes with backslashes in case we are running Cygwin Perl.
+$TARGET_PATH =~ s/\//\\/g;
+
 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_PROJECT_VERSION = "$components{'__FULL_BUILD_MAJOR_VERSION__'}.$components{'__VERSION_MINOR__'}.$components{'__VERSION_TINY__'}";
+my $SAFE_BUILD_VERSION = $ENV{RC_ProjectBuildVersion} || $ENV{RC_PROJECTBUILDVERSION} || $components{'__VERSION_BUILD__'};
 
-print "Using RC_PROJECTSOURCEVERSION=$SAFE_PROJECT_VERSION and RC_PROJECTBUILDVERSION=$components{'__VERSION_BUILD__'}\n";
+print "Using RC_PROJECTSOURCEVERSION=$SAFE_PROJECT_VERSION and RC_PROJECTBUILDVERSION=$SAFE_BUILD_VERSION\n";
 
 # Note: These environment settings only affect this script and its child processes:
 $ENV{RC_PROJECTSOURCEVERSION} = $SAFE_PROJECT_VERSION;
 $ENV{RC_ProjectSourceVersion} = $SAFE_PROJECT_VERSION;
-$ENV{RC_PROJECTBUILDVERSION} = $components{'__VERSION_BUILD__'};
 
-my $rc = system($VERSION_STAMPER, '--verbose', $TARGET_PATH, '--fileMajor', $components{'__VERSION_MAJOR__'},
+my $rc = system($VERSION_STAMPER, '--verbose', $TARGET_PATH, '--fileMajor', $components{'__FULL_BUILD_MAJOR_VERSION__'},
     '--fileMinor', $components{'__VERSION_MINOR__'}, '--fileRevision', $components{'__VERSION_TINY__'},
-    '--fileBuild', $components{'__VERSION_BUILD__'}, '--productMajor', $components{'__VERSION_MAJOR__'},
+    '--fileBuild', $SAFE_BUILD_VERSION, '--productMajor', $components{'__FULL_BUILD_MAJOR_VERSION__'},
     '--productMinor', $components{'__VERSION_MINOR__'}, '--productRevision', $components{'__VERSION_TINY__'},
     '--productBuild', $components{'__VERSION_BUILD__'});