On Wed, May 06, 2020 at 12:17:03AM +0200, Juan José Santamaría Flecha wrote:
> Please forgive me if I am being too nitpicky, but I find the comments a
> little too verbose, a usage format might be more visual and easier to
> explain:
> 
> Usage: build [[CONFIGURATION] COMPONENT]
> 
> The options are  case-insensitive.
> CONFIGURATION sets the configuration to build, "debug" or "release" (by
> default).
> COMPONENT defines a component to build. An empty option means all
> components.

Your comment makes sense to me.  What about the attached then?  On top
of documenting the script usage in the code, let's trigger it if it
gets called with more than 3 arguments.  What do you think?

FWIW, I forgot to mention that I don't think those warnings are worth
a backpatch.  No objections with improving things on HEAD of course.
--
Michael
diff --git a/src/tools/msvc/build.pl b/src/tools/msvc/build.pl
index de50554e7e..b66f2c3b12 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')
+
+if (defined($ARGV[0]))
 {
-	$bconf = "Debug";
-}
-elsif (uc($ARGV[0]) ne "RELEASE")
-{
-	$buildwhat = $ARGV[0] || "";
+	if (uc($ARGV[0]) eq 'DEBUG')
+	{
+		$bconf = "Debug";
+	}
+	elsif (uc($ARGV[0]) ne "RELEASE")
+	{
+		$buildwhat = $ARGV[0] || "";
+	}
 }
 
 # ... and do it

Attachment: signature.asc
Description: PGP signature

Reply via email to