v9-0004-Don-t-duplicate-references-and-libraries-in-MSVC-.patch

application/octet-stream

Filename: v9-0004-Don-t-duplicate-references-and-libraries-in-MSVC-.patch
Type: application/octet-stream
Part: 3
Message: Re: Reduce the number of special cases to build contrib modules on windows

Patch

Format: format-patch
Series: patch v9-0004
Subject: Don't duplicate references and libraries in MSVC scripts
File+
src/tools/msvc/Project.pm 9 2
From b9ca373e019296207195a9272cf85d75849dbe59 Mon Sep 17 00:00:00 2001
From: David Rowley <dgrowley@gmail.com>
Date: Tue, 27 Jul 2021 22:26:55 +1200
Subject: [PATCH v9 4/6] Don't duplicate references and libraries in MSVC
 scripts

In order not to duplicate references and libraries in the Visual Studio
project files produced by the MSVC build scripts, have them check if a
particular reference or library already exists before adding the same one
again.
---
 src/tools/msvc/Project.pm | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/tools/msvc/Project.pm b/src/tools/msvc/Project.pm
index e8095dbd0e..137990ca65 100644
--- a/src/tools/msvc/Project.pm
+++ b/src/tools/msvc/Project.pm
@@ -124,7 +124,10 @@ sub AddReference
 
 	while (my $ref = shift)
 	{
-		push @{ $self->{references} }, $ref;
+		if (! grep { $_ eq $ref} @{ $self->{references} })
+		{
+			push @{ $self->{references} }, $ref;
+		}
 		$self->AddLibrary(
 			"__CFGNAME__/" . $ref->{name} . "/" . $ref->{name} . ".lib");
 	}
@@ -141,7 +144,11 @@ sub AddLibrary
 		$lib = '&quot;' . $lib . "&quot;";
 	}
 
-	push @{ $self->{libraries} }, $lib;
+	if (! grep { $_ eq $lib} @{ $self->{libraries} })
+	{
+		push @{ $self->{libraries} }, $lib;
+	}
+
 	if ($dbgsuffix)
 	{
 		push @{ $self->{suffixlib} }, $lib;
-- 
2.21.0.windows.1