From 3570bfd41f5728ee34ffb6c9ecf7540e3df87d7d Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Mon, 13 Nov 2000 04:46:34 +0000 Subject: [PATCH] Do not warn for unused imported dlls when forwards to the same dlls are present. --- tools/winebuild/build.h | 2 +- tools/winebuild/import.c | 21 ++++++++++++++++++++- tools/winebuild/main.c | 2 +- tools/winebuild/spec32.c | 12 +++++++----- 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/tools/winebuild/build.h b/tools/winebuild/build.h index 2f9fe33e1ee..2b9188dbbc8 100644 --- a/tools/winebuild/build.h +++ b/tools/winebuild/build.h @@ -153,7 +153,7 @@ extern int output_res16_directory( unsigned char *buffer ); extern void BuildGlue( FILE *outfile, FILE *infile ); extern void BuildRelays( FILE *outfile ); extern void BuildSpec16File( FILE *outfile ); -extern void BuildSpec32File( FILE *outfile, int output_main ); +extern void BuildSpec32File( FILE *outfile ); extern SPEC_TYPE ParseTopLevel( FILE *file ); /* global variables */ diff --git a/tools/winebuild/import.c b/tools/winebuild/import.c index 0f5ae4c2fe5..3aee81b3871 100644 --- a/tools/winebuild/import.c +++ b/tools/winebuild/import.c @@ -195,6 +195,25 @@ static void add_extra_undef_symbols(void) } } +/* warn if a given dll is not used, but check forwards first */ +static void warn_unused( const char *dllname ) +{ + int i; + size_t len = strlen(dllname); + const char *p = strchr( dllname, '.' ); + if (p && !strcasecmp( p, ".dll" )) len = p - dllname; + + for (i = Base; i <= Limit; i++) + { + ORDDEF *odp = Ordinals[i]; + if (!odp || odp->type != TYPE_FORWARD) continue; + if (!strncasecmp( odp->u.fwd.link_name, dllname, len ) && + odp->u.fwd.link_name[len] == '.') + return; /* found an import, do not warn */ + } + warning( "%s imported but no symbols used\n", dllname ); +} + /* read in the list of undefined symbols */ void read_undef_symbols( const char *name ) { @@ -249,7 +268,7 @@ int resolve_imports( FILE *outfile ) else undef_symbols[j - off] = undef_symbols[j]; } nb_undef_symbols -= off; - if (!off) warning( "%s imported but no symbols used\n", imp->dll ); + if (!off) warn_unused( imp->dll ); } return 1; } diff --git a/tools/winebuild/main.c b/tools/winebuild/main.c index 941abf6dc75..559c7963abd 100644 --- a/tools/winebuild/main.c +++ b/tools/winebuild/main.c @@ -203,7 +203,7 @@ int main(int argc, char **argv) BuildSpec16File( output_file ); break; case SPEC_WIN32: - BuildSpec32File( output_file, !resolve_imports( output_file ) ); + BuildSpec32File( output_file ); break; default: assert(0); } diff --git a/tools/winebuild/spec32.c b/tools/winebuild/spec32.c index ca87eaf479d..ffa780a35a5 100644 --- a/tools/winebuild/spec32.c +++ b/tools/winebuild/spec32.c @@ -358,12 +358,12 @@ static void output_stub_funcs( FILE *outfile ) * * Build a Win32 C file from a spec file. */ -void BuildSpec32File( FILE *outfile, int output_main ) +void BuildSpec32File( FILE *outfile ) { ORDDEF *odp; int i, fwd_size = 0, have_regs = FALSE; int nr_exports, nr_imports, nr_resources, nr_debug; - int characteristics, subsystem; + int characteristics, subsystem, has_imports; const char *init_func; DWORD page_size; @@ -380,6 +380,8 @@ void BuildSpec32File( FILE *outfile, int output_main ) AssignOrdinals(); nr_exports = Base <= Limit ? Limit - Base + 1 : 0; + has_imports = resolve_imports( outfile ); + fprintf( outfile, "/* File generated automatically from %s; do not edit! */\n\n", input_file_name ); @@ -498,7 +500,7 @@ void BuildSpec32File( FILE *outfile, int output_main ) " _ARGC = __wine_get_main_args( &_ARGV );\n" " ExitProcess( %s( GetModuleHandleA(0), 0, cmdline, info.wShowWindow ) );\n" "}\n\n", init_func, init_func ); - if (output_main) + if (!has_imports) fprintf( outfile, "int main( int argc, char *argv[] )\n" "{\n" @@ -510,7 +512,7 @@ void BuildSpec32File( FILE *outfile, int output_main ) subsystem = IMAGE_SUBSYSTEM_WINDOWS_GUI; break; case SPEC_MODE_CUIEXE: - if (!init_func) init_func = output_main ? "wine_main" : "main"; + if (!init_func) init_func = has_imports ? "main" : "wine_main"; fprintf( outfile, "\n#include \n" "int _ARGC;\n" @@ -522,7 +524,7 @@ void BuildSpec32File( FILE *outfile, int output_main ) " _ARGC = __wine_get_main_args( &_ARGV );\n" " ExitProcess( %s( _ARGC, _ARGV ) );\n" "}\n\n", init_func, init_func ); - if (output_main) + if (!has_imports) fprintf( outfile, "int main( int argc, char *argv[] )\n" "{\n"