Commit 10700bf6 authored by Alexandre Julliard's avatar Alexandre Julliard

wrc: Add support for generating .po files from existing resources.

parent 0e79c5c1
DEFS = -D__WINESRC__ -DINCLUDEDIR="\"$(includedir)\"" $(EXTRADEFS) DEFS = -D__WINESRC__ -DINCLUDEDIR="\"$(includedir)\"" $(EXTRADEFS)
PROGRAMS = wrc$(EXEEXT) wrc-installed PROGRAMS = wrc$(EXEEXT) wrc-installed
MANPAGE = wrc.man MANPAGE = wrc.man
ALL_LIBS = @LIBGETTEXTPO@ $(LIBWPP) $(LIBWINE) $(LIBPORT)
C_SRCS = \ C_SRCS = \
dumpres.c \ dumpres.c \
genres.c \ genres.c \
newstruc.c \ newstruc.c \
po.c \
readres.c \ readres.c \
translation.c \ translation.c \
utils.c \ utils.c \
...@@ -22,10 +24,10 @@ all: $(PROGRAMS) ...@@ -22,10 +24,10 @@ all: $(PROGRAMS)
@MAKE_RULES@ @MAKE_RULES@
wrc$(EXEEXT): $(OBJS) $(LIBWPP) wrc$(EXEEXT): $(OBJS) $(LIBWPP)
$(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBWPP) $(LIBWINE) $(LIBPORT) $(LDFLAGS) $(LDRPATH_LOCAL) $(CC) $(CFLAGS) -o $@ $(OBJS) $(ALL_LIBS) $(LDFLAGS) $(LDRPATH_LOCAL)
wrc-installed: $(OBJS) $(LIBWPP) wrc-installed: $(OBJS) $(LIBWPP)
$(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBWPP) $(LIBWINE) $(LIBPORT) $(LDFLAGS) $(LDRPATH_INSTALL) $(CC) $(CFLAGS) -o $@ $(OBJS) $(ALL_LIBS) $(LDFLAGS) $(LDRPATH_INSTALL)
install:: wrc-installed $(DESTDIR)$(bindir) install:: wrc-installed $(DESTDIR)$(bindir)
$(INSTALL_PROGRAM) wrc-installed $(DESTDIR)$(bindir)/wrc$(EXEEXT) $(INSTALL_PROGRAM) wrc-installed $(DESTDIR)$(bindir)/wrc$(EXEEXT)
......
This diff is collapsed. Click to expand it.
...@@ -69,7 +69,7 @@ static const char usage[] = ...@@ -69,7 +69,7 @@ static const char usage[] =
" --no-use-temp-file Ignored for compatibility with windres\n" " --no-use-temp-file Ignored for compatibility with windres\n"
" --nostdinc Disables searching the standard include path\n" " --nostdinc Disables searching the standard include path\n"
" -o, --output=FILE Output to file (default is infile.res)\n" " -o, --output=FILE Output to file (default is infile.res)\n"
" -O, --output-format=FORMAT The output format (either `res' or `res16`)\n" " -O, --output-format=FORMAT The output format (`po', `pot', `res', or `res16`)\n"
" --pedantic Enable pedantic warnings\n" " --pedantic Enable pedantic warnings\n"
" --preprocessor Specifies the preprocessor to use, including arguments\n" " --preprocessor Specifies the preprocessor to use, including arguments\n"
" -r Ignored for compatibility with rc\n" " -r Ignored for compatibility with rc\n"
...@@ -148,7 +148,7 @@ static int pointer_size = sizeof(void *); ...@@ -148,7 +148,7 @@ static int pointer_size = sizeof(void *);
static int verify_translations_mode; static int verify_translations_mode;
char *output_name = NULL; /* The name given by the -o option */ static char *output_name; /* The name given by the -o option */
char *input_name = NULL; /* The name given on the command-line */ char *input_name = NULL; /* The name given on the command-line */
static char *temp_name = NULL; /* Temporary file for preprocess pipe */ static char *temp_name = NULL; /* Temporary file for preprocess pipe */
...@@ -333,6 +333,7 @@ int main(int argc,char *argv[]) ...@@ -333,6 +333,7 @@ int main(int argc,char *argv[])
int nb_files = 0; int nb_files = 0;
int i; int i;
int cmdlen; int cmdlen;
int po_mode = 0;
char **files = xmalloc( argc * sizeof(*files) ); char **files = xmalloc( argc * sizeof(*files) );
signal(SIGSEGV, segvhandler); signal(SIGSEGV, segvhandler);
...@@ -462,7 +463,9 @@ int main(int argc,char *argv[]) ...@@ -462,7 +463,9 @@ int main(int argc,char *argv[])
else error("Too many output files.\n"); else error("Too many output files.\n");
break; break;
case 'O': case 'O':
if (strcmp(optarg, "res16") == 0) win32 = 0; if (strcmp(optarg, "po") == 0) po_mode = 1;
else if (strcmp(optarg, "pot") == 0) po_mode = 2;
else if (strcmp(optarg, "res16") == 0) win32 = 0;
else if (strcmp(optarg, "res")) warning("Output format %s not supported.\n", optarg); else if (strcmp(optarg, "res")) warning("Output format %s not supported.\n", optarg);
break; break;
case 'r': case 'r':
...@@ -524,20 +527,10 @@ int main(int argc,char *argv[]) ...@@ -524,20 +527,10 @@ int main(int argc,char *argv[])
for (i = 0; i < nb_files; i++) for (i = 0; i < nb_files; i++)
{ {
input_name = files[i]; input_name = files[i];
if(!output_name && !preprocess_only)
{
output_name = dup_basename(input_name, ".rc");
strcat(output_name, ".res");
}
if (load_file( input_name, output_name )) exit(1); if (load_file( input_name, output_name )) exit(1);
} }
/* stdin special case. NULL means "stdin" for wpp. */ /* stdin special case. NULL means "stdin" for wpp. */
if (nb_files == 0) if (nb_files == 0 && load_file( NULL, output_name )) exit(1);
{
if(!output_name && !preprocess_only)
output_name = strdup("wrc.tab.res");
if (load_file( NULL, output_name )) exit(1);
}
if(debuglevel & DEBUGLEVEL_DUMP) if(debuglevel & DEBUGLEVEL_DUMP)
dump_resources(resource_top); dump_resources(resource_top);
...@@ -547,11 +540,31 @@ int main(int argc,char *argv[]) ...@@ -547,11 +540,31 @@ int main(int argc,char *argv[])
verify_translations(resource_top); verify_translations(resource_top);
exit(0); exit(0);
} }
if (po_mode)
{
if (po_mode == 2) /* pot file */
{
if (!output_name)
{
output_name = dup_basename( nb_files ? files[0] : NULL, ".rc" );
strcat( output_name, ".pot" );
}
write_pot_file( output_name );
}
else write_po_files( output_name );
output_name = NULL;
exit(0);
}
/* Convert the internal lists to binary data */ /* Convert the internal lists to binary data */
resources2res(resource_top); resources2res(resource_top);
chat("Writing .res-file\n"); chat("Writing .res-file\n");
if (!output_name)
{
output_name = dup_basename( nb_files ? files[0] : NULL, ".rc" );
strcat(output_name, ".res");
}
write_resfile(output_name, resource_top); write_resfile(output_name, resource_top);
output_name = NULL; output_name = NULL;
......
...@@ -45,7 +45,6 @@ extern int preprocess_only; ...@@ -45,7 +45,6 @@ extern int preprocess_only;
extern int no_preprocess; extern int no_preprocess;
extern int check_utf8; extern int check_utf8;
extern char *output_name;
extern char *input_name; extern char *input_name;
extern char *cmdline; extern char *cmdline;
extern time_t now; extern time_t now;
...@@ -57,6 +56,8 @@ extern resource_t *resource_top; ...@@ -57,6 +56,8 @@ extern resource_t *resource_top;
extern language_t *currentlanguage; extern language_t *currentlanguage;
void verify_translations(resource_t *top); void verify_translations(resource_t *top);
void write_pot_file( const char *outname );
void write_po_files( const char *outname );
void write_resfile(char *outname, resource_t *top); void write_resfile(char *outname, resource_t *top);
static inline void set_location( location_t *loc ) static inline void set_location( location_t *loc )
......
...@@ -93,8 +93,15 @@ with \fB.rc\fR stripped or \fBwrc.tab.res\fR if input is read ...@@ -93,8 +93,15 @@ with \fB.rc\fR stripped or \fBwrc.tab.res\fR if input is read
from standard input. from standard input.
.TP .TP
.I \fB\-O\fR, \fB\-\-output\-format\fR=\fIformat\fR .I \fB\-O\fR, \fB\-\-output\-format\fR=\fIformat\fR
Sets the output format. The supported formats are 'res' and 'res16'. Sets the output format. The supported formats are \fBpo\fR, \fBpot\fR,
If this option is not specified, format defaults to 'res'. \fBres\fR, and \fBres16\fR. If this option is not specified, the
format defaults to \fBres\fR.
.br
In \fBpo\fR mode, if an output file name is specified it must match a
known language name, like \fBen_US.po\fR; only resources for the
specified language are output. If no output file name is specified, a
separate .po file is created for every language encountered in the
input.
.TP .TP
.I \fB\-\-pedantic\fR .I \fB\-\-pedantic\fR
Enable pedantic warnings. Notably redefinition of #define statements can Enable pedantic warnings. Notably redefinition of #define statements can
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment