Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Don't duplicate references and libraries in MSVC scripts
authorDavid Rowley <drowley@postgresql.org>
Wed, 28 Jul 2021 22:41:31 +0000 (10:41 +1200)
committerDavid Rowley <drowley@postgresql.org>
Wed, 28 Jul 2021 22:41:31 +0000 (10:41 +1200)
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.

Reviewed-by: Álvaro Herrera, Andrew Dunstan, Dagfinn Ilmari Mannsåker
Discussion: https://postgr.es/m/CAApHDvpo6g5csCTjc_0C7DMvgFPomVb0Rh-AcW5afd=Ya=LRuw@mail.gmail.com

src/tools/msvc/Project.pm

index a6c3aa0d6871d1991e5f36f8bcb201257300ed46..f1c93a3fa3224018066c67df3cd0109a4721f43c 100644 (file)
@@ -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;