Check file header to differentiate between object files and resources
so that the -r option is not necessary.
This commit is contained in:
parent
9afea97a0f
commit
310de886e9
|
@ -25,7 +25,7 @@ all: $(MODULE)$(DLLEXT) $(SUBDIRS)
|
|||
# Rules for .so files
|
||||
|
||||
$(MAINSPEC).c: $(MAINSPEC) $(RC_SRCS:.rc=.res) $(SYMBOLFILE) $(WINEBUILD)
|
||||
$(LDPATH) $(WINEBUILD) $(DEFS) -o $@ --spec $(SRCDIR)/$(MAINSPEC) $(RC_SRCS:%.rc=-r %.res) $(SYMBOLFILE) $(DLLMAIN:%=-e %) -L$(DLLDIR) $(DELAYIMPORTS:%=-d%) $(IMPORTS:%=-l%)
|
||||
$(LDPATH) $(WINEBUILD) $(DEFS) -o $@ --spec $(SRCDIR)/$(MAINSPEC) $(RC_SRCS:.rc=.res) $(SYMBOLFILE) $(DLLMAIN:%=-e %) -L$(DLLDIR) $(DELAYIMPORTS:%=-d%) $(IMPORTS:%=-l%)
|
||||
|
||||
$(MODULE).so: $(MAINSPEC).o $(ALL_OBJS) Makefile.in
|
||||
$(LDSHARED) $(LDDLLFLAGS) $(MAINSPEC).o $(ALL_OBJS) -o $@ -L$(DLLDIR) $(LDIMPORTS:%=-l%) $(ALL_LIBS) -lc
|
||||
|
|
|
@ -32,7 +32,7 @@ all: $(TESTPROGRAM)
|
|||
# Rule for main module spec file
|
||||
|
||||
$(MODULE).spec.c: $(RC_SRCS:.rc=.res) $(OBJS) $(WINEBUILD)
|
||||
$(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -exe $(MODULE) -mcui $(RC_SRCS:%.rc=-r %.res) $(OBJS) -L$(DLLDIR) -L.. $(DELAYIMPORTS:%=-d%) $(IMPORTS:%=-l%)
|
||||
$(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -exe $(MODULE) -mcui $(RC_SRCS:.rc=.res) $(OBJS) -L$(DLLDIR) -L.. $(DELAYIMPORTS:%=-d%) $(IMPORTS:%=-l%)
|
||||
|
||||
# Rules for .so main module
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ all: $(MODULE)$(DLLEXT) $(BASEMODULE)$(EXEEXT)
|
|||
# Rule for main module spec file
|
||||
|
||||
$(MODULE).spec.c: $(RC_SRCS:.rc=.res) $(ALL_OBJS) $(WINEBUILD)
|
||||
$(LDPATH) $(WINEBUILD) $(DEFS) -o $@ --exe $(MODULE) $(APPMODE:%=-m%) $(RC_SRCS:%.rc=-r %.res) $(ALL_OBJS) -L$(DLLDIR) $(DELAYIMPORTS:%=-d%) $(IMPORTS:%=-l%)
|
||||
$(LDPATH) $(WINEBUILD) $(DEFS) -o $@ --exe $(MODULE) $(APPMODE:%=-m%) $(RC_SRCS:.rc=.res) $(ALL_OBJS) -L$(DLLDIR) $(DELAYIMPORTS:%=-d%) $(IMPORTS:%=-l%)
|
||||
|
||||
# Rules for .so main module
|
||||
|
||||
|
|
|
@ -151,7 +151,7 @@ extern void add_ignore_symbol( const char *name );
|
|||
extern void read_undef_symbols( char **argv );
|
||||
extern int resolve_imports( void );
|
||||
extern int output_imports( FILE *outfile );
|
||||
extern void load_res32_file( const char *name );
|
||||
extern int load_res32_file( const char *name );
|
||||
extern int output_resources( FILE *outfile );
|
||||
extern void load_res16_file( const char *name );
|
||||
extern int output_res16_data( FILE *outfile );
|
||||
|
|
|
@ -350,7 +350,7 @@ static void parse_options( char *argv[] )
|
|||
char **ptr, **last;
|
||||
const char* arg=NULL;
|
||||
|
||||
for (ptr = last = argv + 1; *ptr; ptr++)
|
||||
for (ptr = last = argv; *ptr; ptr++)
|
||||
{
|
||||
/* first check the exact option name */
|
||||
for (opt = option_table; opt->name; opt++)
|
||||
|
@ -394,17 +394,31 @@ static void parse_options( char *argv[] )
|
|||
|
||||
|
||||
/* load all specified resource files */
|
||||
static void load_resources(void)
|
||||
static void load_resources( char *argv[] )
|
||||
{
|
||||
int i;
|
||||
char **ptr, **last;
|
||||
|
||||
switch (SpecType)
|
||||
{
|
||||
case SPEC_WIN16:
|
||||
for (i = 0; i < nb_res_files; i++) load_res16_file( res_files[i] );
|
||||
break;
|
||||
|
||||
case SPEC_WIN32:
|
||||
for (i = 0; i < nb_res_files; i++) load_res32_file( res_files[i] );
|
||||
for (i = 0; i < nb_res_files; i++)
|
||||
{
|
||||
if (!load_res32_file( res_files[i] ))
|
||||
fatal_error( "%s is not a valid Win32 resource file\n", res_files[i] );
|
||||
}
|
||||
|
||||
/* load any resource file found in the remaining arguments */
|
||||
for (ptr = last = argv; *ptr; ptr++)
|
||||
{
|
||||
if (!load_res32_file( *ptr ))
|
||||
*last++ = *ptr; /* not a resource file, keep it in the list */
|
||||
}
|
||||
*last = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -415,12 +429,12 @@ static void load_resources(void)
|
|||
int main(int argc, char **argv)
|
||||
{
|
||||
output_file = stdout;
|
||||
parse_options( argv );
|
||||
parse_options( argv + 1 );
|
||||
|
||||
switch(exec_mode)
|
||||
{
|
||||
case MODE_SPEC:
|
||||
load_resources();
|
||||
load_resources( argv + 1 );
|
||||
ParseTopLevel( input_file );
|
||||
switch (SpecType)
|
||||
{
|
||||
|
@ -438,14 +452,13 @@ int main(int argc, char **argv)
|
|||
break;
|
||||
case MODE_EXE:
|
||||
if (SpecType == SPEC_WIN16) fatal_error( "Cannot build 16-bit exe files\n" );
|
||||
load_resources();
|
||||
load_resources( argv + 1 );
|
||||
read_undef_symbols( argv + 1 );
|
||||
BuildSpec32File( output_file );
|
||||
break;
|
||||
case MODE_DEF:
|
||||
if (argv[1]) fatal_error( "file argument '%s' not allowed in this mode\n", argv[1] );
|
||||
if (SpecType == SPEC_WIN16) fatal_error( "Cannot yet build .def file for 16-bit dlls\n" );
|
||||
load_resources();
|
||||
ParseTopLevel( input_file );
|
||||
BuildDef32File( output_file );
|
||||
break;
|
||||
|
|
|
@ -155,20 +155,18 @@ static void get_string( struct string_id *str )
|
|||
|
||||
/* check the file header */
|
||||
/* all values must be zero except header size */
|
||||
static void check_header(void)
|
||||
static int check_header(void)
|
||||
{
|
||||
if (get_dword()) goto error; /* data size */
|
||||
if (get_dword() != 32) goto error; /* header size */
|
||||
if (get_word() != 0xffff || get_word()) goto error; /* type, must be id 0 */
|
||||
if (get_word() != 0xffff || get_word()) goto error; /* name, must be id 0 */
|
||||
if (get_dword()) goto error; /* data version */
|
||||
if (get_word()) goto error; /* mem options */
|
||||
if (get_word()) goto error; /* language */
|
||||
if (get_dword()) goto error; /* version */
|
||||
if (get_dword()) goto error; /* characteristics */
|
||||
return;
|
||||
error:
|
||||
fatal_error( "%s is not a valid Win32 resource file\n", file_name );
|
||||
if (get_dword()) return 0; /* data size */
|
||||
if (get_dword() != 32) return 0; /* header size */
|
||||
if (get_word() != 0xffff || get_word()) return 0; /* type, must be id 0 */
|
||||
if (get_word() != 0xffff || get_word()) return 0; /* name, must be id 0 */
|
||||
if (get_dword()) return 0; /* data version */
|
||||
if (get_word()) return 0; /* mem options */
|
||||
if (get_word()) return 0; /* language */
|
||||
if (get_dword()) return 0; /* version */
|
||||
if (get_dword()) return 0; /* characteristics */
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* load the next resource from the current file */
|
||||
|
@ -196,9 +194,9 @@ static void load_next_resource(void)
|
|||
}
|
||||
|
||||
/* load a Win32 .res file */
|
||||
void load_res32_file( const char *name )
|
||||
int load_res32_file( const char *name )
|
||||
{
|
||||
int fd;
|
||||
int fd, ret;
|
||||
void *base;
|
||||
struct stat st;
|
||||
|
||||
|
@ -217,8 +215,12 @@ void load_res32_file( const char *name )
|
|||
file_name = name;
|
||||
file_pos = base;
|
||||
file_end = file_pos + st.st_size;
|
||||
check_header();
|
||||
while (file_pos < file_end) load_next_resource();
|
||||
if ((ret = check_header()))
|
||||
{
|
||||
while (file_pos < file_end) load_next_resource();
|
||||
}
|
||||
close( fd );
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* compare two unicode strings/ids */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
.\" -*- nroff -*-
|
||||
.TH WINEBUILD 1 "July 2002" "@PACKAGE_STRING@" "Wine dll builder"
|
||||
.TH WINEBUILD 1 "December 2002" "@PACKAGE_STRING@" "Wine dll builder"
|
||||
.SH NAME
|
||||
winebuild \- Wine dll builder
|
||||
.SH SYNOPSIS
|
||||
|
@ -159,6 +159,13 @@ Load resources from the specified binary resource file. The
|
|||
\fIrsrc.res\fR can be produced from a source resource file with
|
||||
.BR wrc(1)
|
||||
(or with a Windows resource compiler).
|
||||
.br
|
||||
This option is only necessary for Win16 resource files, the Win32 ones
|
||||
can simply listed as
|
||||
.I input files
|
||||
and will automatically be handled correctly (though the
|
||||
.B \-r
|
||||
option will also work for Win32 files).
|
||||
.TP
|
||||
.B \-w
|
||||
Turn on warnings.
|
||||
|
|
Loading…
Reference in New Issue