wrc: 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-07 10:38:06 +01:00
parent fe888bbbb6
commit 0a66eaea68
4 changed files with 30 additions and 29 deletions

View File

@ -2705,49 +2705,36 @@ static void output_source_h( struct makefile *make, struct incl_file *source, co
static void output_source_rc( struct makefile *make, struct incl_file *source, const char *obj ) static void output_source_rc( struct makefile *make, struct incl_file *source, const char *obj )
{ {
struct strarray defines = get_source_defines( make, source, obj ); struct strarray defines = get_source_defines( make, source, obj );
char *po_dir = NULL;
unsigned int i; unsigned int i;
if (source->file->flags & FLAG_GENERATED) strarray_add( &make->clean_files, source->name ); if (source->file->flags & FLAG_GENERATED) strarray_add( &make->clean_files, source->name );
if (linguas.count && (source->file->flags & FLAG_RC_PO)) po_dir = top_obj_dir_path( make, "po" );
strarray_add( &make->res_files, strmake( "%s.res", obj )); strarray_add( &make->res_files, strmake( "%s.res", obj ));
output( "%s.res: %s\n", obj_dir_path( make, obj ), source->filename ); if (source->file->flags & FLAG_RC_PO && !(source->file->flags & FLAG_PARENTDIR))
{
strarray_add( &make->clean_files, strmake( "%s.pot", obj ));
output( "%s.pot ", obj_dir_path( make, obj ) );
}
output( "%s.res: %s", obj_dir_path( make, obj ), source->filename );
output_filename( tools_path( make, "wrc" ));
output_filenames( source->dependencies );
output( "\n" );
output( "\t%s -u -o $@", tools_path( make, "wrc" ) ); output( "\t%s -u -o $@", tools_path( make, "wrc" ) );
if (make->is_win16) output_filename( "-m16" ); if (make->is_win16) output_filename( "-m16" );
else output_filenames( target_flags ); else output_filenames( target_flags );
output_filename( "--nostdinc" ); output_filename( "--nostdinc" );
if (po_dir) output_filename( strmake( "--po-dir=%s", po_dir ));
output_filenames( defines ); output_filenames( defines );
if (linguas.count && (source->file->flags & FLAG_RC_PO))
{
char *po_dir = top_obj_dir_path( make, "po" );
output_filename( strmake( "--po-dir=%s", po_dir ));
output_filename( source->filename ); output_filename( source->filename );
output( "\n" ); output( "\n" );
if (po_dir)
{
output( "%s.res:", obj_dir_path( make, obj )); output( "%s.res:", obj_dir_path( make, obj ));
for (i = 0; i < linguas.count; i++) for (i = 0; i < linguas.count; i++)
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" );
} }
else
{
output_filename( source->filename );
output( "\n" );
}
if (source->file->flags & FLAG_RC_PO && !(source->file->flags & FLAG_PARENTDIR))
{
strarray_add( &make->clean_files, strmake( "%s.pot", obj ));
output( "%s.pot: %s\n", obj_dir_path( make, obj ), source->filename );
output( "\t%s -u -O pot -o $@", tools_path( make, "wrc" ) );
if (make->is_win16) output_filename( "-m16" );
else output_filenames( target_flags );
output_filename( "--nostdinc" );
output_filenames( defines );
output_filename( source->filename );
output( "\n" );
output( "%s.pot ", obj_dir_path( make, obj ));
}
output( "%s.res:", obj_dir_path( make, obj ));
output_filename( tools_path( make, "wrc" ));
output_filenames( source->dependencies );
output( "\n" );
} }

View File

@ -219,6 +219,13 @@ char *xstrdup(const char *str)
return strcpy(s, str); return strcpy(s, str);
} }
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 compare_striA( const char *str1, const char *str2 ) int compare_striA( const char *str1, const char *str2 )
{ {
for (;;) for (;;)

View File

@ -36,6 +36,7 @@ char *xstrdup(const char *str);
int compare_striA( const char *str1, const char *str2 ); int compare_striA( const char *str1, const char *str2 );
int compare_striW( const WCHAR *str1, const WCHAR *str2 ); int compare_striW( const WCHAR *str1, const WCHAR *str2 );
char *strmake(const char* fmt, ...) __attribute__((__format__ (__printf__, 1, 2 ))); char *strmake(const char* fmt, ...) __attribute__((__format__ (__printf__, 1, 2 )));
int strendswith( const char *str, const char *end );
int parser_error(const char *s, ...) __attribute__((format (printf, 1, 2))); int parser_error(const char *s, ...) __attribute__((format (printf, 1, 2)));
int parser_warning(const char *s, ...) __attribute__((format (printf, 1, 2))); int parser_warning(const char *s, ...) __attribute__((format (printf, 1, 2)));
void internal_error(const char *file, int line, const char *s, ...) __attribute__((format (printf, 3, 4), noreturn)); void internal_error(const char *file, int line, const char *s, ...) __attribute__((format (printf, 3, 4), noreturn));

View File

@ -589,8 +589,14 @@ int main(int argc,char *argv[])
verify_translations(resource_top); verify_translations(resource_top);
exit(0); exit(0);
} }
if (!po_mode && output_name)
{
if (strendswith( output_name, ".po" )) po_mode = 1;
else if (strendswith( output_name, ".pot" )) po_mode = 2;
}
if (po_mode) if (po_mode)
{ {
if (!win32) error( "PO files are not supported in 16-bit mode\n" );
if (po_mode == 2) /* pot file */ if (po_mode == 2) /* pot file */
{ {
if (!output_name) if (!output_name)
@ -604,7 +610,7 @@ int main(int argc,char *argv[])
output_name = NULL; output_name = NULL;
exit(0); exit(0);
} }
add_translations( po_dir ); if (win32) add_translations( po_dir );
/* Convert the internal lists to binary data */ /* Convert the internal lists to binary data */
resources2res(resource_top); resources2res(resource_top);