winebuild: Add possibility to generate a global resource file without running it through windres.

This commit is contained in:
Alexandre Julliard 2009-06-22 11:46:33 +02:00
parent 43f6c4cb70
commit 6cf96bf940
2 changed files with 24 additions and 13 deletions

View File

@ -244,7 +244,7 @@ static const char usage_str[] =
" --def Build a .def file from a .spec file\n" " --def Build a .def file from a .spec file\n"
" --exe Build a .c file for an executable\n" " --exe Build a .c file for an executable\n"
" --relay16 Build the 16-bit relay assembly routines\n" " --relay16 Build the 16-bit relay assembly routines\n"
" --relay32 Build the 32-bit relay assembly routines\n\n" " --relay32 Build the 32-bit relay assembly routines\n"
" --resources Build a .o file for the resource files\n\n" " --resources Build a .o file for the resource files\n\n"
"The mode options are mutually exclusive; you must specify one and only one.\n\n"; "The mode options are mutually exclusive; you must specify one and only one.\n\n";

View File

@ -541,8 +541,7 @@ void output_res_o_file( DLLSPEC *spec )
{ {
unsigned int i, total_size; unsigned int i, total_size;
unsigned char *data; unsigned char *data;
char *res_file, *cmd; char *res_file = NULL;
const char *prog;
int fd, err; int fd, err;
if (!spec->nb_resources) fatal_error( "--resources mode needs at least one resource file as input\n" ); if (!spec->nb_resources) fatal_error( "--resources mode needs at least one resource file as input\n" );
@ -593,20 +592,32 @@ void output_res_o_file( DLLSPEC *spec )
} }
assert( file_out_pos == file_out_end ); assert( file_out_pos == file_out_end );
res_file = get_temp_file_name( output_file_name, ".res" ); /* if the output file name is a .res too, don't run the results through windres */
if ((fd = open( res_file, O_WRONLY|O_CREAT|O_TRUNC, 0600 )) == -1) if (strendswith( output_file_name, ".res"))
fatal_error( "Cannot create %s\n", res_file ); {
if ((fd = open( output_file_name, O_WRONLY|O_CREAT|O_TRUNC, 0666 )) == -1)
fatal_error( "Cannot create %s\n", output_file_name );
}
else
{
res_file = get_temp_file_name( output_file_name, ".res" );
if ((fd = open( res_file, O_WRONLY|O_CREAT|O_TRUNC, 0600 )) == -1)
fatal_error( "Cannot create %s\n", res_file );
}
if (write( fd, data, total_size ) != total_size) if (write( fd, data, total_size ) != total_size)
fatal_error( "Error writing to %s\n", res_file ); fatal_error( "Error writing to %s\n", res_file );
close( fd ); close( fd );
free( data ); free( data );
prog = get_windres_command(); if (res_file)
cmd = xmalloc( strlen(prog) + strlen(res_file) + strlen(output_file_name) + 9 ); {
sprintf( cmd, "%s -i %s -o %s", prog, res_file, output_file_name ); const char *prog = get_windres_command();
if (verbose) fprintf( stderr, "%s\n", cmd ); char *cmd = xmalloc( strlen(prog) + strlen(res_file) + strlen(output_file_name) + 9 );
err = system( cmd ); sprintf( cmd, "%s -i %s -o %s", prog, res_file, output_file_name );
if (err) fatal_error( "%s failed with status %d\n", prog, err ); if (verbose) fprintf( stderr, "%s\n", cmd );
free( cmd ); err = system( cmd );
if (err) fatal_error( "%s failed with status %d\n", prog, err );
free( cmd );
}
output_file_name = NULL; /* so we don't try to assemble it */ output_file_name = NULL; /* so we don't try to assemble it */
} }