summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Paquier2020-07-06 00:16:17 +0000
committerMichael Paquier2020-07-06 00:16:17 +0000
commit404b912c5cab05d4a2ddac85696a300e00783c73 (patch)
tree4a7d279fafb1907d1a7958e854c1dfc289c5d73e
parentfe2e206cdb00a2d5dcebc3c8e8119017392d9781 (diff)
Improve perl script in MSVC to build binaries
This commit includes two improvements for build.pl in src/tools/msvc/: - Fix two warnings related to $ARGV[0] being uninitialized, something that happens when calling build.pl (or build.bat) without arguments to compile all the components with a release quality. - If calling the script with more than two arguments, exit immediately and show a new help output. build.pl was not failing in this case before this commit, and the extra arguments were just ignored, but the new behavior helps in understanding how to run the script without looking at the documentation for the Windows builds. Reported-by: Ranier Vilela Author: Michael Paquier Reviewed-by: Juan José Santamaría Flecha, David Zhang Discussion: https://postgr.es/m/CAEudQAo38dfR_0Ugt2OHy4mq-6Hz93XPSBAGEUV67RhKdgp8Zg@mail.gmail.com
-rw-r--r--src/tools/msvc/build.pl35
1 files changed, 26 insertions, 9 deletions
diff --git a/src/tools/msvc/build.pl b/src/tools/msvc/build.pl
index de50554e7e..a75d191b6d 100644
--- a/src/tools/msvc/build.pl
+++ b/src/tools/msvc/build.pl
@@ -1,7 +1,9 @@
# -*-perl-*- hey - emacs - this is a perl file
-
+#
+# Script that provides 'make' functionality for msvc builds.
+#
# src/tools/msvc/build.pl
-
+#
use strict;
use warnings;
@@ -12,10 +14,22 @@ use Cwd;
use Mkvcbuild;
+sub usage
+{
+ die( "Usage: build.pl [ [ <configuration> ] <component> ]\n"
+ . "Options are case-insensitive.\n"
+ . " configuration: Release | Debug. This sets the configuration\n"
+ . " to build. Default is Release.\n"
+ . " component: name of component to build. An empty value means\n"
+ . " to build all components.\n");
+}
+
chdir('../../..') if (-d '../msvc' && -d '../../../src');
die 'Must run from root or msvc directory'
unless (-d 'src/tools/msvc' && -d 'src');
+usage() unless scalar(@ARGV) <= 2;
+
# buildenv.pl is for specifying the build environment settings
# it should contain lines like:
# $ENV{PATH} = "c:/path/to/bison/bin;$ENV{PATH}";
@@ -37,17 +51,20 @@ do "./src/tools/msvc/config.pl" if (-f "src/tools/msvc/config.pl");
my $vcver = Mkvcbuild::mkvcbuild($config);
# check what sort of build we are doing
-
my $bconf = $ENV{CONFIG} || "Release";
my $msbflags = $ENV{MSBFLAGS} || "";
my $buildwhat = $ARGV[1] || "";
-if (uc($ARGV[0]) eq 'DEBUG')
-{
- $bconf = "Debug";
-}
-elsif (uc($ARGV[0]) ne "RELEASE")
+
+if (defined($ARGV[0]))
{
- $buildwhat = $ARGV[0] || "";
+ if (uc($ARGV[0]) eq 'DEBUG')
+ {
+ $bconf = "Debug";
+ }
+ elsif (uc($ARGV[0]) ne "RELEASE")
+ {
+ $buildwhat = $ARGV[0] || "";
+ }
}
# ... and do it