Small patch to fix build on Windows

Started by Dmitry Igrishinover 6 years ago17 messages
#1Dmitry Igrishin
dmitigr@gmail.com
1 attachment(s)

Hi,

The attached self-documented patch fixes build on Windows in case when
path to Python has embedded spaces.

Attachments:

fix-mkvcbuild.patchtext/x-patch; charset=US-ASCII; name=fix-mkvcbuild.patchDownload
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index d1d0aed07e..76834f5188 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -495,7 +495,7 @@ sub mkvcbuild
 		my $pythonprog = "import sys;print(sys.prefix);"
 		  . "print(str(sys.version_info[0])+str(sys.version_info[1]))";
 		my $prefixcmd =
-		  $solution->{options}->{python} . "\\python -c \"$pythonprog\"";
+		  "\"$solution->{options}->{python}\\python\" -c \"$pythonprog\"";
 		my $pyout = `$prefixcmd`;
 		die "Could not query for python version!\n" if $?;
 		my ($pyprefix, $pyver) = split(/\r?\n/, $pyout);
diff --git a/src/tools/msvc/Project.pm b/src/tools/msvc/Project.pm
index b5d1dc6e89..28893f072d 100644
--- a/src/tools/msvc/Project.pm
+++ b/src/tools/msvc/Project.pm
@@ -132,10 +132,9 @@ sub AddLibrary
 {
 	my ($self, $lib, $dbgsuffix) = @_;
 
-	if ($lib =~ m/\s/)
-	{
-		$lib = '"' . $lib . """;
-	}
+	# Since VC automatically quotes paths specified as the data of
+	# <AdditionalDependencies> in VC project file, it's mistakably
+	# to quote them here. Thus, it's okay if $lib contains spaces.
 
 	push @{ $self->{libraries} }, $lib;
 	if ($dbgsuffix)
#2Kyotaro Horiguchi
horikyota.ntt@gmail.com
In reply to: Dmitry Igrishin (#1)
Re: Small patch to fix build on Windows

Hi,

At Tue, 6 Aug 2019 22:50:14 +0300, Dmitry Igrishin <dmitigr@gmail.com> wrote in <CAAfz9KO4Nt-kDUKAcEKFND+1LeZ6nH_hjPGamonfTeZLRKz0bg@mail.gmail.com>

The attached self-documented patch fixes build on Windows in case when
path to Python has embedded spaces.

-          $solution->{options}->{python} . "\\python -c \"$pythonprog\"";
+          "\"$solution->{options}->{python}\\python\" -c \"$pythonprog\"";

Solution.pm has the following line:

my $opensslcmd =
$self->{options}->{openssl} . "\\bin\\openssl.exe version 2>&1";

AFAICS that's all.

-    if ($lib =~ m/\s/)
-    {
-        $lib = '&quot;' . $lib . "&quot;";
-    }
+    # Since VC automatically quotes paths specified as the data of
+    # <AdditionalDependencies> in VC project file, it's mistakably
+    # to quote them here. Thus, it's okay if $lib contains spaces.

I'm not sure, but it's not likely that someone adds it without
actually stumbling on space-containing paths with the ealier
version. Anyway if we shouldn't touch this unless the existing
code makes actual problem.

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

#3Dmitry Igrishin
dmitigr@gmail.com
In reply to: Kyotaro Horiguchi (#2)
1 attachment(s)
Re: Small patch to fix build on Windows

ср, 7 авг. 2019 г. в 11:29, Kyotaro Horiguchi <horikyota.ntt@gmail.com>:

Hi,

At Tue, 6 Aug 2019 22:50:14 +0300, Dmitry Igrishin <dmitigr@gmail.com> wrote in <CAAfz9KO4Nt-kDUKAcEKFND+1LeZ6nH_hjPGamonfTeZLRKz0bg@mail.gmail.com>

The attached self-documented patch fixes build on Windows in case when
path to Python has embedded spaces.

-          $solution->{options}->{python} . "\\python -c \"$pythonprog\"";
+          "\"$solution->{options}->{python}\\python\" -c \"$pythonprog\"";

Solution.pm has the following line:

my $opensslcmd =
$self->{options}->{openssl} . "\\bin\\openssl.exe version 2>&1";

AFAICS that's all.

Thank you! The attached 2nd version of the patch fixes this too.

-    if ($lib =~ m/\s/)
-    {
-        $lib = '&quot;' . $lib . "&quot;";
-    }
+    # Since VC automatically quotes paths specified as the data of
+    # <AdditionalDependencies> in VC project file, it's mistakably
+    # to quote them here. Thus, it's okay if $lib contains spaces.

I'm not sure, but it's not likely that someone adds it without
actually stumbling on space-containing paths with the ealier
version. Anyway if we shouldn't touch this unless the existing
code makes actual problem.

So, do you think a comment is not needed here?

Attachments:

fix-mkvcbuild-2.patchtext/x-patch; charset=US-ASCII; name=fix-mkvcbuild-2.patchDownload
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index d1d0aed07e..76834f5188 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -495,7 +495,7 @@ sub mkvcbuild
 		my $pythonprog = "import sys;print(sys.prefix);"
 		  . "print(str(sys.version_info[0])+str(sys.version_info[1]))";
 		my $prefixcmd =
-		  $solution->{options}->{python} . "\\python -c \"$pythonprog\"";
+		  "\"$solution->{options}->{python}\\python\" -c \"$pythonprog\"";
 		my $pyout = `$prefixcmd`;
 		die "Could not query for python version!\n" if $?;
 		my ($pyprefix, $pyver) = split(/\r?\n/, $pyout);
diff --git a/src/tools/msvc/Project.pm b/src/tools/msvc/Project.pm
index b5d1dc6e89..28893f072d 100644
--- a/src/tools/msvc/Project.pm
+++ b/src/tools/msvc/Project.pm
@@ -132,10 +132,9 @@ sub AddLibrary
 {
 	my ($self, $lib, $dbgsuffix) = @_;
 
-	if ($lib =~ m/\s/)
-	{
-		$lib = '&quot;' . $lib . "&quot;";
-	}
+	# Since VC automatically quotes paths specified as the data of
+	# <AdditionalDependencies> in VC project file, it's mistakably
+	# to quote them here. Thus, it's okay if $lib contains spaces.
 
 	push @{ $self->{libraries} }, $lib;
 	if ($dbgsuffix)
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 318594db5d..327e556c53 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -126,7 +126,7 @@ sub GetOpenSSLVersion
 	# Attempt to get OpenSSL version and location.  This assumes that
 	# openssl.exe is in the specified directory.
 	my $opensslcmd =
-	  $self->{options}->{openssl} . "\\bin\\openssl.exe version 2>&1";
+	  "\"$self->{options}->{openssl}\\bin\\openssl.exe\" version 2>&1";
 	my $sslout = `$opensslcmd`;
 
 	$? >> 8 == 0
#4Juan José Santamaría Flecha
juanjo.santamaria@gmail.com
In reply to: Dmitry Igrishin (#3)
Re: Small patch to fix build on Windows

On Wed, Aug 7, 2019 at 11:11 AM Dmitry Igrishin <dmitigr@gmail.com> wrote:

ср, 7 авг. 2019 г. в 11:29, Kyotaro Horiguchi <horikyota.ntt@gmail.com>:

Solution.pm has the following line:

my $opensslcmd =
$self->{options}->{openssl} . "\\bin\\openssl.exe version 2>&1";

AFAICS that's all.

Thank you! The attached 2nd version of the patch fixes this too.

At some point the propossed patch for opensslcmd was like:

+ my $opensslprog = '\bin\openssl.exe version 2>&1';
+ my $opensslcmd = '"' . $self->{options}->{openssl} . '"' . $opensslprog;

It can be a question of taste, but I think the dot is easier to read.

Regards,

Juan José Santamaría Flecha

#5Dmitry Igrishin
dmitigr@gmail.com
In reply to: Juan José Santamaría Flecha (#4)
Re: Small patch to fix build on Windows

ср, 7 авг. 2019 г. в 15:33, Juan José Santamaría Flecha
<juanjo.santamaria@gmail.com>:

On Wed, Aug 7, 2019 at 11:11 AM Dmitry Igrishin <dmitigr@gmail.com> wrote:

ср, 7 авг. 2019 г. в 11:29, Kyotaro Horiguchi <horikyota.ntt@gmail.com>:

Solution.pm has the following line:

my $opensslcmd =
$self->{options}->{openssl} . "\\bin\\openssl.exe version 2>&1";

AFAICS that's all.

Thank you! The attached 2nd version of the patch fixes this too.

At some point the propossed patch for opensslcmd was like:

+ my $opensslprog = '\bin\openssl.exe version 2>&1';
+ my $opensslcmd = '"' . $self->{options}->{openssl} . '"' . $opensslprog;

It can be a question of taste, but I think the dot is easier to read.

Well, the style inconsistent anyway, for example, in file Project.pm

$self->{def} = "./__CFGNAME__/$self->{name}/$self->{name}.def";
$self->{implib} = "__CFGNAME__/$self->{name}/$libname";

So, I don't know what style is preferable. Personally, I don't care.

#6Kyotaro Horiguchi
horikyota.ntt@gmail.com
In reply to: Dmitry Igrishin (#3)
Re: Small patch to fix build on Windows

Hello.

At Wed, 7 Aug 2019 12:14:48 +0300, Dmitry Igrishin <dmitigr@gmail.com> wrote in <CAAfz9KPVff92Np51DvvCDvqvxVchiuuvJCzz56qtM=N0SUnG8A@mail.gmail.com>

-    if ($lib =~ m/\s/)
-    {
-        $lib = '&quot;' . $lib . "&quot;";
-    }
+    # Since VC automatically quotes paths specified as the data of
+    # <AdditionalDependencies> in VC project file, it's mistakably
+    # to quote them here. Thus, it's okay if $lib contains spaces.

I'm not sure, but it's not likely that someone adds it without
actually stumbling on space-containing paths with the ealier
version. Anyway if we shouldn't touch this unless the existing
code makes actual problem.

So, do you think a comment is not needed here?

# Sorry the last phrase above is broken.

I meant "if it ain't broke don't fix it".

I doubt that some older versions of VC might need it. I confirmed
that the extra &quot; actually harms at least VC2019 and the code
removal in the patch works. As for the replace comment, I'm not
sure it is needed since I think quoting is not the task for
AddLibrary/AddIncludeDir in the first place (and AddIncludeDir
doesn't have the same comment).

Now I'm trying to install VS2015 into my alomost-filled-up disk..

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

#7Dmitry Igrishin
dmitigr@gmail.com
In reply to: Kyotaro Horiguchi (#6)
Re: Small patch to fix build on Windows

чт, 8 авг. 2019 г. в 06:18, Kyotaro Horiguchi <horikyota.ntt@gmail.com>:

Hello.

At Wed, 7 Aug 2019 12:14:48 +0300, Dmitry Igrishin <dmitigr@gmail.com> wrote in <CAAfz9KPVff92Np51DvvCDvqvxVchiuuvJCzz56qtM=N0SUnG8A@mail.gmail.com>

-    if ($lib =~ m/\s/)
-    {
-        $lib = '&quot;' . $lib . "&quot;";
-    }
+    # Since VC automatically quotes paths specified as the data of
+    # <AdditionalDependencies> in VC project file, it's mistakably
+    # to quote them here. Thus, it's okay if $lib contains spaces.

I'm not sure, but it's not likely that someone adds it without
actually stumbling on space-containing paths with the ealier
version. Anyway if we shouldn't touch this unless the existing
code makes actual problem.

So, do you think a comment is not needed here?

# Sorry the last phrase above is broken.

I meant "if it ain't broke don't fix it".

I doubt that some older versions of VC might need it. I confirmed
that the extra &quot; actually harms at least VC2019 and the code
removal in the patch works.

The code removal is required also to build on VC2017.

As for the replace comment, I'm not
sure it is needed since I think quoting is not the task for
AddLibrary/AddIncludeDir in the first place (and AddIncludeDir
doesn't have the same comment).

The attached 3rd version of the patch contains no comment in AddLibrary().

Now I'm trying to install VS2015 into my alomost-filled-up disk..

Thank you!

#8Dmitry Igrishin
dmitigr@gmail.com
In reply to: Dmitry Igrishin (#7)
1 attachment(s)
Re: Small patch to fix build on Windows

As for the replace comment, I'm not
sure it is needed since I think quoting is not the task for
AddLibrary/AddIncludeDir in the first place (and AddIncludeDir
doesn't have the same comment).

The attached 3rd version of the patch contains no comment in AddLibrary().

Sorry, forgot to attach the patch to the previous mail.

Attachments:

fix-mkvcbuild-3.patchtext/x-patch; charset=US-ASCII; name=fix-mkvcbuild-3.patchDownload
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index d1d0aed07e..76834f5188 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -495,7 +495,7 @@ sub mkvcbuild
 		my $pythonprog = "import sys;print(sys.prefix);"
 		  . "print(str(sys.version_info[0])+str(sys.version_info[1]))";
 		my $prefixcmd =
-		  $solution->{options}->{python} . "\\python -c \"$pythonprog\"";
+		  "\"$solution->{options}->{python}\\python\" -c \"$pythonprog\"";
 		my $pyout = `$prefixcmd`;
 		die "Could not query for python version!\n" if $?;
 		my ($pyprefix, $pyver) = split(/\r?\n/, $pyout);
diff --git a/src/tools/msvc/Project.pm b/src/tools/msvc/Project.pm
index b5d1dc6e89..88e9e3187d 100644
--- a/src/tools/msvc/Project.pm
+++ b/src/tools/msvc/Project.pm
@@ -132,11 +132,6 @@ sub AddLibrary
 {
 	my ($self, $lib, $dbgsuffix) = @_;
 
-	if ($lib =~ m/\s/)
-	{
-		$lib = '&quot;' . $lib . "&quot;";
-	}
-
 	push @{ $self->{libraries} }, $lib;
 	if ($dbgsuffix)
 	{
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 318594db5d..327e556c53 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -126,7 +126,7 @@ sub GetOpenSSLVersion
 	# Attempt to get OpenSSL version and location.  This assumes that
 	# openssl.exe is in the specified directory.
 	my $opensslcmd =
-	  $self->{options}->{openssl} . "\\bin\\openssl.exe version 2>&1";
+	  "\"$self->{options}->{openssl}\\bin\\openssl.exe\" version 2>&1";
 	my $sslout = `$opensslcmd`;
 
 	$? >> 8 == 0
#9Kyotaro Horiguchi
horikyota.ntt@gmail.com
In reply to: Kyotaro Horiguchi (#6)
Re: Small patch to fix build on Windows

Hello.

At Thu, 08 Aug 2019 12:15:38 +0900 (Tokyo Standard Time), Kyotaro Horiguchi <horikyota.ntt@gmail.com> wrote in <20190808.121538.87367461.horikyota.ntt@gmail.com>

At Wed, 7 Aug 2019 12:14:48 +0300, Dmitry Igrishin <dmitigr@gmail.com> wrote in <CAAfz9KPVff92Np51DvvCDvqvxVchiuuvJCzz56qtM=N0SUnG8A@mail.gmail.com>

-    if ($lib =~ m/\s/)
-    {
-        $lib = '&quot;' . $lib . "&quot;";
-    }
+    # Since VC automatically quotes paths specified as the data of
+    # <AdditionalDependencies> in VC project file, it's mistakably
+    # to quote them here. Thus, it's okay if $lib contains spaces.

..

I doubt that some older versions of VC might need it. I confirmed
that the extra &quot; actually harms at least VC2019 and the code
removal in the patch works. As for the replace comment, I'm not
sure it is needed since I think quoting is not the task for
AddLibrary/AddIncludeDir in the first place (and AddIncludeDir
doesn't have the same comment).

Now I'm trying to install VS2015 into my alomost-filled-up disk..

I confirmed that VC2015 works with the above diff. So the patch
is overall fine with me.

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

#10Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Dmitry Igrishin (#8)
Re: Small patch to fix build on Windows

On 2019-Aug-08, Dmitry Igrishin wrote:

my $prefixcmd =
-		  $solution->{options}->{python} . "\\python -c \"$pythonprog\"";
+		  "\"$solution->{options}->{python}\\python\" -c \"$pythonprog\"";

I think you can make this prettier like this:

my $prefixcmd = qq{"$solution->{options}->{python}\\python" -c "$pythonprog"};

--
�lvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

#11Dmitry Igrishin
dmitigr@gmail.com
In reply to: Alvaro Herrera (#10)
Re: Small patch to fix build on Windows

чт, 8 авг. 2019 г. в 20:07, Alvaro Herrera <alvherre@2ndquadrant.com>:

On 2019-Aug-08, Dmitry Igrishin wrote:

my $prefixcmd =
-               $solution->{options}->{python} . "\\python -c \"$pythonprog\"";
+               "\"$solution->{options}->{python}\\python\" -c \"$pythonprog\"";

I think you can make this prettier like this:

my $prefixcmd = qq{"$solution->{options}->{python}\\python" -c "$pythonprog"};

This looks nice for a Perl hacker :-). As for me, it looks unusual and
a bit confusing. I never
programmed in Perl, but I was able to quickly understand where the
problem lies due to the
style adopted in other languages, when the contents are enclosed in
quotation marks, and
the quotation marks are escaped if they are part of the contents.
So, should I fix it? Any thoughts?

#12Michael Paquier
michael@paquier.xyz
In reply to: Dmitry Igrishin (#11)
Re: Small patch to fix build on Windows

On Thu, Aug 08, 2019 at 10:46:07PM +0300, Dmitry Igrishin wrote:

This looks nice for a Perl hacker :-). As for me, it looks unusual and
a bit confusing. I never
programmed in Perl, but I was able to quickly understand where the
problem lies due to the
style adopted in other languages, when the contents are enclosed in
quotation marks, and
the quotation marks are escaped if they are part of the contents.
So, should I fix it? Any thoughts?

FWIW, I like Alvaro's suggestion about qq{} in this case, as it makes
sure that double-quotes are correctly applied where they should.
--
Michael

#13Dmitry Igrishin
dmitigr@gmail.com
In reply to: Michael Paquier (#12)
1 attachment(s)
Re: Small patch to fix build on Windows

пт, 9 авг. 2019 г. в 05:45, Michael Paquier <michael@paquier.xyz>:

On Thu, Aug 08, 2019 at 10:46:07PM +0300, Dmitry Igrishin wrote:

This looks nice for a Perl hacker :-). As for me, it looks unusual and
a bit confusing. I never
programmed in Perl, but I was able to quickly understand where the
problem lies due to the
style adopted in other languages, when the contents are enclosed in
quotation marks, and
the quotation marks are escaped if they are part of the contents.
So, should I fix it? Any thoughts?

FWIW, I like Alvaro's suggestion about qq{} in this case, as it makes
sure that double-quotes are correctly applied where they should.

The attached 4rd version of the patch uses qq||. I used qq|| instead
of qq{} for consistency because qq|| is already used in Solution.pm:

return qq|VisualStudioVersion = $self->{VisualStudioVersion}
MinimumVisualStudioVersion = $self->{MinimumVisualStudioVersion}
|;

Attachments:

fix-mkvcbuild-4.patchtext/x-patch; charset=US-ASCII; name=fix-mkvcbuild-4.patchDownload
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index d1d0aed07e..042879238e 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -495,7 +495,7 @@ sub mkvcbuild
 		my $pythonprog = "import sys;print(sys.prefix);"
 		  . "print(str(sys.version_info[0])+str(sys.version_info[1]))";
 		my $prefixcmd =
-		  $solution->{options}->{python} . "\\python -c \"$pythonprog\"";
+		  qq|"$solution->{options}->{python}\\python" -c "$pythonprog"|;
 		my $pyout = `$prefixcmd`;
 		die "Could not query for python version!\n" if $?;
 		my ($pyprefix, $pyver) = split(/\r?\n/, $pyout);
diff --git a/src/tools/msvc/Project.pm b/src/tools/msvc/Project.pm
index b5d1dc6e89..88e9e3187d 100644
--- a/src/tools/msvc/Project.pm
+++ b/src/tools/msvc/Project.pm
@@ -132,11 +132,6 @@ sub AddLibrary
 {
 	my ($self, $lib, $dbgsuffix) = @_;
 
-	if ($lib =~ m/\s/)
-	{
-		$lib = '&quot;' . $lib . "&quot;";
-	}
-
 	push @{ $self->{libraries} }, $lib;
 	if ($dbgsuffix)
 	{
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 318594db5d..6406df6769 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -126,7 +126,7 @@ sub GetOpenSSLVersion
 	# Attempt to get OpenSSL version and location.  This assumes that
 	# openssl.exe is in the specified directory.
 	my $opensslcmd =
-	  $self->{options}->{openssl} . "\\bin\\openssl.exe version 2>&1";
+	  qq|"$self->{options}->{openssl}\\bin\\openssl.exe" version 2>&1|;
 	my $sslout = `$opensslcmd`;
 
 	$? >> 8 == 0
#14Kyotaro Horiguchi
horikyota.ntt@gmail.com
In reply to: Dmitry Igrishin (#13)
Re: Small patch to fix build on Windows

At Fri, 9 Aug 2019 09:56:27 +0300, Dmitry Igrishin <dmitigr@gmail.com> wrote in <CAAfz9KPZbPjoWTqOb5moi_YWvdbSjAMZsrVBW0cBw33Q560CLw@mail.gmail.com>

пт, 9 авг. 2019 г. в 05:45, Michael Paquier <michael@paquier.xyz>:

On Thu, Aug 08, 2019 at 10:46:07PM +0300, Dmitry Igrishin wrote:

This looks nice for a Perl hacker :-). As for me, it looks unusual and
a bit confusing. I never
programmed in Perl, but I was able to quickly understand where the
problem lies due to the
style adopted in other languages, when the contents are enclosed in
quotation marks, and
the quotation marks are escaped if they are part of the contents.
So, should I fix it? Any thoughts?

FWIW, I like Alvaro's suggestion about qq{} in this case, as it makes
sure that double-quotes are correctly applied where they should.

The attached 4rd version of the patch uses qq||. I used qq|| instead
of qq{} for consistency because qq|| is already used in Solution.pm:

return qq|VisualStudioVersion = $self->{VisualStudioVersion}
MinimumVisualStudioVersion = $self->{MinimumVisualStudioVersion}
|;

Hmm. qq is nice but '|' make my eyes twitch (a bit). Couldn't we
use other delimites like (), ##, or // ? (I like {} for use in
this patch.)

Any opinions?

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

#15Dmitry Igrishin
dmitigr@gmail.com
In reply to: Kyotaro Horiguchi (#14)
Re: Small patch to fix build on Windows

пт, 9 авг. 2019 г. в 10:23, Kyotaro Horiguchi <horikyota.ntt@gmail.com>:

At Fri, 9 Aug 2019 09:56:27 +0300, Dmitry Igrishin <dmitigr@gmail.com> wrote in <CAAfz9KPZbPjoWTqOb5moi_YWvdbSjAMZsrVBW0cBw33Q560CLw@mail.gmail.com>

пт, 9 авг. 2019 г. в 05:45, Michael Paquier <michael@paquier.xyz>:

On Thu, Aug 08, 2019 at 10:46:07PM +0300, Dmitry Igrishin wrote:

This looks nice for a Perl hacker :-). As for me, it looks unusual and
a bit confusing. I never
programmed in Perl, but I was able to quickly understand where the
problem lies due to the
style adopted in other languages, when the contents are enclosed in
quotation marks, and
the quotation marks are escaped if they are part of the contents.
So, should I fix it? Any thoughts?

FWIW, I like Alvaro's suggestion about qq{} in this case, as it makes
sure that double-quotes are correctly applied where they should.

The attached 4rd version of the patch uses qq||. I used qq|| instead
of qq{} for consistency because qq|| is already used in Solution.pm:

return qq|VisualStudioVersion = $self->{VisualStudioVersion}
MinimumVisualStudioVersion = $self->{MinimumVisualStudioVersion}
|;

Hmm. qq is nice but '|' make my eyes twitch (a bit). Couldn't we
use other delimites like (), ##, or // ? (I like {} for use in
this patch.)

Any opinions?

Personally I don't care. I used || notation only in order to be
consistent, since this notation is already used in Solution.pm. If
this consistency is not required let me provide a patch with {}
notation. What do you think?

#16Michael Paquier
michael@paquier.xyz
In reply to: Dmitry Igrishin (#15)
Re: Small patch to fix build on Windows

On Fri, Aug 09, 2019 at 11:21:52AM +0300, Dmitry Igrishin wrote:

Personally I don't care. I used || notation only in order to be
consistent, since this notation is already used in Solution.pm. If
this consistency is not required let me provide a patch with {}
notation. What do you think?

We are talking about one place in src/tools/msvc/ using qq on HEAD.
So one or the other is fine by me as long as we remain in the
acceptable ASCII ranks.
--
Michael

#17Dmitry Igrishin
dmitigr@gmail.com
In reply to: Michael Paquier (#16)
1 attachment(s)
Re: Small patch to fix build on Windows

вт, 13 авг. 2019 г. в 06:19, Michael Paquier <michael@paquier.xyz>:

On Fri, Aug 09, 2019 at 11:21:52AM +0300, Dmitry Igrishin wrote:

Personally I don't care. I used || notation only in order to be
consistent, since this notation is already used in Solution.pm. If
this consistency is not required let me provide a patch with {}
notation. What do you think?

We are talking about one place in src/tools/msvc/ using qq on HEAD.
So one or the other is fine by me as long as we remain in the
acceptable ASCII ranks.

Okay. 5th version of patch is attached.

Attachments:

fix-mkvcbuild-5.patchtext/x-patch; charset=US-ASCII; name=fix-mkvcbuild-5.patchDownload
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index d1d0aed07e..67e9eede49 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -495,7 +495,7 @@ sub mkvcbuild
 		my $pythonprog = "import sys;print(sys.prefix);"
 		  . "print(str(sys.version_info[0])+str(sys.version_info[1]))";
 		my $prefixcmd =
-		  $solution->{options}->{python} . "\\python -c \"$pythonprog\"";
+		  qq{"$solution->{options}->{python}\\python" -c "$pythonprog"};
 		my $pyout = `$prefixcmd`;
 		die "Could not query for python version!\n" if $?;
 		my ($pyprefix, $pyver) = split(/\r?\n/, $pyout);
diff --git a/src/tools/msvc/Project.pm b/src/tools/msvc/Project.pm
index b5d1dc6e89..88e9e3187d 100644
--- a/src/tools/msvc/Project.pm
+++ b/src/tools/msvc/Project.pm
@@ -132,11 +132,6 @@ sub AddLibrary
 {
 	my ($self, $lib, $dbgsuffix) = @_;
 
-	if ($lib =~ m/\s/)
-	{
-		$lib = '&quot;' . $lib . "&quot;";
-	}
-
 	push @{ $self->{libraries} }, $lib;
 	if ($dbgsuffix)
 	{
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 318594db5d..400c6706fb 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -126,7 +126,7 @@ sub GetOpenSSLVersion
 	# Attempt to get OpenSSL version and location.  This assumes that
 	# openssl.exe is in the specified directory.
 	my $opensslcmd =
-	  $self->{options}->{openssl} . "\\bin\\openssl.exe version 2>&1";
+	  qq{"$self->{options}->{openssl}\\bin\\openssl.exe" version 2>&1};
 	my $sslout = `$opensslcmd`;
 
 	$? >> 8 == 0