Module: wine Branch: master Commit: 0a66eaea689e97ebf2277afaecfb844cd73ec1bd URL: https://source.winehq.org/git/wine.git/?a=commit;h=0a66eaea689e97ebf2277afae...
Author: Alexandre Julliard julliard@winehq.org Date: Fri Feb 7 10:38:06 2020 +0100
wrc: Set the output format from the output file name.
Signed-off-by: Alexandre Julliard julliard@winehq.org
---
tools/makedep.c | 43 +++++++++++++++---------------------------- tools/wrc/utils.c | 7 +++++++ tools/wrc/utils.h | 1 + tools/wrc/wrc.c | 8 +++++++- 4 files changed, 30 insertions(+), 29 deletions(-)
diff --git a/tools/makedep.c b/tools/makedep.c index 12095436dd..f7261795fc 100644 --- a/tools/makedep.c +++ b/tools/makedep.c @@ -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 ) { struct strarray defines = get_source_defines( make, source, obj ); + char *po_dir = NULL; unsigned int i;
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 )); - 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" ) ); if (make->is_win16) output_filename( "-m16" ); else output_filenames( target_flags ); output_filename( "--nostdinc" ); + if (po_dir) output_filename( strmake( "--po-dir=%s", po_dir )); output_filenames( defines ); - if (linguas.count && (source->file->flags & FLAG_RC_PO)) + output_filename( source->filename ); + output( "\n" ); + if (po_dir) { - char *po_dir = top_obj_dir_path( make, "po" ); - output_filename( strmake( "--po-dir=%s", po_dir )); - output_filename( source->filename ); - output( "\n" ); output( "%s.res:", obj_dir_path( make, obj )); for (i = 0; i < linguas.count; i++) output_filename( strmake( "%s/%s.mo", po_dir, linguas.str[i] )); 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" ); }
diff --git a/tools/wrc/utils.c b/tools/wrc/utils.c index 9780beb613..8c8a36faf5 100644 --- a/tools/wrc/utils.c +++ b/tools/wrc/utils.c @@ -219,6 +219,13 @@ char *xstrdup(const char *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 ) { for (;;) diff --git a/tools/wrc/utils.h b/tools/wrc/utils.h index aed10b5dea..8b48be38e1 100644 --- a/tools/wrc/utils.h +++ b/tools/wrc/utils.h @@ -36,6 +36,7 @@ char *xstrdup(const char *str); int compare_striA( const char *str1, const char *str2 ); int compare_striW( const WCHAR *str1, const WCHAR *str2 ); 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_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)); diff --git a/tools/wrc/wrc.c b/tools/wrc/wrc.c index b4cb013f8e..f81fe7baa6 100644 --- a/tools/wrc/wrc.c +++ b/tools/wrc/wrc.c @@ -589,8 +589,14 @@ int main(int argc,char *argv[]) verify_translations(resource_top); 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 (!win32) error( "PO files are not supported in 16-bit mode\n" ); if (po_mode == 2) /* pot file */ { if (!output_name) @@ -604,7 +610,7 @@ int main(int argc,char *argv[]) output_name = NULL; exit(0); } - add_translations( po_dir ); + if (win32) add_translations( po_dir );
/* Convert the internal lists to binary data */ resources2res(resource_top);