wmc: Set the output format from the output file name.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2020-02-06 15:05:48 +01:00
parent b7b44224d1
commit 8247686c10
4 changed files with 26 additions and 9 deletions

View File

@ -2757,11 +2757,15 @@ static void output_source_rc( struct makefile *make, struct incl_file *source, c
static void output_source_mc( struct makefile *make, struct incl_file *source, const char *obj ) static void output_source_mc( struct makefile *make, struct incl_file *source, const char *obj )
{ {
unsigned int i; unsigned int i;
char *obj_path = obj_dir_path( make, obj );
strarray_add( &make->res_files, strmake( "%s.res", obj )); strarray_add( &make->res_files, strmake( "%s.res", obj ));
strarray_add( &make->clean_files, strmake( "%s.pot", obj )); strarray_add( &make->clean_files, strmake( "%s.pot", obj ));
output( "%s.res: %s\n", obj_dir_path( make, obj ), source->filename ); output( "%s.pot %s.res: %s", obj_path, obj_path, source->filename );
output( "\t%s -U -O res -o $@ %s", tools_path( make, "wmc" ), source->filename ); output_filename( tools_path( make, "wmc" ));
output_filenames( source->dependencies );
output( "\n" );
output( "\t%s -u -o $@ %s", tools_path( make, "wmc" ), source->filename );
if (linguas.count) if (linguas.count)
{ {
char *po_dir = top_obj_dir_path( make, "po" ); char *po_dir = top_obj_dir_path( make, "po" );
@ -2772,13 +2776,6 @@ static void output_source_mc( struct makefile *make, struct incl_file *source, c
output_filename( strmake( "%s/%s.mo", po_dir, linguas.str[i] )); output_filename( strmake( "%s/%s.mo", po_dir, linguas.str[i] ));
} }
output( "\n" ); output( "\n" );
output( "%s.pot: %s\n", obj_dir_path( make, obj ), source->filename );
output( "\t%s -O pot -o $@ %s", tools_path( make, "wmc" ), source->filename );
output( "\n" );
output( "%s.pot %s.res:", obj_dir_path( make, obj ), obj_dir_path( make, obj ));
output_filename( tools_path( make, "wmc" ));
output_filenames( source->dependencies );
output( "\n" );
} }

View File

@ -200,6 +200,13 @@ char *strmake( const char* fmt, ... )
} }
} }
int strendswith( const char *str, const char *end )
{
int l = strlen(str);
int m = strlen(end);
return l >= m && !strcmp( str + l - m, end );
}
int unistrlen(const WCHAR *s) int unistrlen(const WCHAR *s)
{ {
int n; int n;

View File

@ -43,6 +43,7 @@ void error(const char *s, ...) __attribute__((format (printf, 1, 2)));
void warning(const char *s, ...) __attribute__((format (printf, 1, 2))); void warning(const char *s, ...) __attribute__((format (printf, 1, 2)));
char *dup_basename(const char *name, const char *ext); char *dup_basename(const char *name, const char *ext);
int strendswith( const char *str, const char *end );
WCHAR *xunistrdup(const WCHAR * str); WCHAR *xunistrdup(const WCHAR * str);
WCHAR *unistrcpy(WCHAR *dst, const WCHAR *src); WCHAR *unistrcpy(WCHAR *dst, const WCHAR *src);

View File

@ -126,6 +126,7 @@ FILE *yyin;
static enum static enum
{ {
FORMAT_UNKNOWN,
FORMAT_RC, FORMAT_RC,
FORMAT_RES, FORMAT_RES,
FORMAT_POT FORMAT_POT
@ -287,6 +288,15 @@ int main(int argc,char *argv[])
input_name = argv[optind]; input_name = argv[optind];
} }
/* Guess output format */
if (output_format == FORMAT_UNKNOWN)
{
if (output_name && strendswith( output_name, ".res" )) output_format = FORMAT_RES;
else if (output_name && strendswith( output_name, ".pot" )) output_format = FORMAT_POT;
else output_format = FORMAT_RC;
}
if (output_format == FORMAT_RES) unicodeout = 1;
/* Generate appropriate outfile names */ /* Generate appropriate outfile names */
if(!output_name) if(!output_name)
{ {
@ -340,6 +350,8 @@ int main(int argc,char *argv[])
case FORMAT_POT: case FORMAT_POT:
write_pot_file( output_name ); write_pot_file( output_name );
break; break;
default:
break;
} }
output_name = NULL; output_name = NULL;
header_name = NULL; header_name = NULL;