Alexandre Julliard : makefiles: Avoid adding the same source multiple times.

Alexandre Julliard julliard at winehq.org
Thu Jul 28 16:01:12 CDT 2022


Module: wine
Branch: master
Commit: 6f4d1766a7781dd8dd68b8784b01aedbf497138e
URL:    https://gitlab.winehq.org/wine/wine/-/commit/6f4d1766a7781dd8dd68b8784b01aedbf497138e

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Jul 28 15:30:31 2022 +0200

makefiles: Avoid adding the same source multiple times.

---

 dlls/setupapi/tests/Makefile.in |  2 --
 tools/make_makefiles            |  6 ++++++
 tools/makedep.c                 | 21 ++++++++++-----------
 3 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/dlls/setupapi/tests/Makefile.in b/dlls/setupapi/tests/Makefile.in
index df7c6687875..85be56de556 100644
--- a/dlls/setupapi/tests/Makefile.in
+++ b/dlls/setupapi/tests/Makefile.in
@@ -18,5 +18,3 @@ SOURCES = \
 	setupapi.rc \
 	setupcab.c \
 	stringtable.c
-
-RC_SRCS = setupapi.rc
diff --git a/tools/make_makefiles b/tools/make_makefiles
index d61e3865e13..c7afd4080ac 100755
--- a/tools/make_makefiles
+++ b/tools/make_makefiles
@@ -128,6 +128,7 @@ sub replace_makefile_variables($)
     my $make = $makefiles{$file};
     my $source_vars_regexp = join "|", @source_vars;
     my %replaced;
+    my %files;
     my $old;
     my $new;
 
@@ -177,6 +178,11 @@ sub replace_makefile_variables($)
                 $new .= $new_str;
             }
             $replaced{$var} = 1;
+            foreach my $val (@values)
+            {
+                die "$file.in: duplicate file $val" if defined $files{$val};
+                $files{$val} = 1;
+            }
             next;
         }
         $new .= $_;
diff --git a/tools/makedep.c b/tools/makedep.c
index 17227120a0e..0e8daf3a960 100644
--- a/tools/makedep.c
+++ b/tools/makedep.c
@@ -817,10 +817,8 @@ found:
 static struct incl_file *add_generated_source( struct makefile *make,
                                                const char *name, const char *filename )
 {
-    struct incl_file *file;
+    struct incl_file *file = xmalloc( sizeof(*file) );
 
-    if ((file = find_src_file( make, name ))) return file;  /* we already have it */
-    file = xmalloc( sizeof(*file) );
     memset( file, 0, sizeof(*file) );
     file->file = add_file( name );
     file->name = xstrdup( name );
@@ -1564,10 +1562,8 @@ static void parse_file( struct makefile *make, struct incl_file *source, int src
  */
 static struct incl_file *add_src_file( struct makefile *make, const char *name )
 {
-    struct incl_file *file;
+    struct incl_file *file = xmalloc( sizeof(*file) );
 
-    if ((file = find_src_file( make, name ))) return file;  /* we already have it */
-    file = xmalloc( sizeof(*file) );
     memset( file, 0, sizeof(*file) );
     file->name = xstrdup(name);
     file->use_msvcrt = make->use_msvcrt;
@@ -1744,7 +1740,7 @@ static struct makefile *parse_makefile( const char *path )
 static void add_generated_sources( struct makefile *make )
 {
     unsigned int i;
-    struct incl_file *source, *next, *file;
+    struct incl_file *source, *next, *file, *dlldata = NULL;
     struct strarray objs = get_expanded_make_var_array( make, "EXTRA_OBJS" );
 
     LIST_FOR_EACH_ENTRY_SAFE( source, next, &make->sources, struct incl_file, entry )
@@ -1772,10 +1768,13 @@ static void add_generated_sources( struct makefile *make )
         }
         if (source->file->flags & FLAG_IDL_PROXY)
         {
-            file = add_generated_source( make, "dlldata.o", "dlldata.c" );
-            add_dependency( file->file, "objbase.h", INCL_NORMAL );
-            add_dependency( file->file, "rpcproxy.h", INCL_NORMAL );
-            add_all_includes( make, file, file->file );
+            if (!dlldata)
+            {
+                dlldata = add_generated_source( make, "dlldata.o", "dlldata.c" );
+                add_dependency( dlldata->file, "objbase.h", INCL_NORMAL );
+                add_dependency( dlldata->file, "rpcproxy.h", INCL_NORMAL );
+                add_all_includes( make, dlldata, dlldata->file );
+            }
             file = add_generated_source( make, replace_extension( source->name, ".idl", "_p.c" ), NULL );
             add_dependency( file->file, "objbase.h", INCL_NORMAL );
             add_dependency( file->file, "rpcproxy.h", INCL_NORMAL );




More information about the wine-cvs mailing list