Generate stub functions from .spec file

svn path=/trunk/; revision=11528
This commit is contained in:
Gé van Geldorp
2004-11-02 19:47:18 +00:00
parent 5e46da95f8
commit f9029e5cd8
22 changed files with 86 additions and 15 deletions

View File

@@ -8,3 +8,4 @@
*.tmp
Makefile.ros
cabinet.spec.def
cabinet.stubs.c

View File

@@ -23,3 +23,4 @@ idi_tt_info_sm.ico
idi_tt_warn_sm.ico
idt_check.bmp
comctl32.spec.def
comctl32.stubs.c

View File

@@ -10,3 +10,4 @@ Makefile.ros
*.bmp
*.ico
comdlg32.spec.def
comdlg32.stubs.c

View File

@@ -19,3 +19,4 @@ temp.exp
*.tmp
Makefile.ros
iphlpapi.spec.def
iphlpapi.stubs.c

View File

@@ -8,3 +8,4 @@
*.tmp
Makefile.ros
mpr.spec.def
mpr.stubs.c

View File

@@ -9,3 +9,4 @@
temp.exp
msacm32.spec.def
Makefile.ros
msacm32.stubs.c

View File

@@ -7,3 +7,4 @@
*.tmp
Makefile.ros
msvfw32.spec.def
msvfw32.stubs.c

View File

@@ -8,3 +8,4 @@
*.tmp
Makefile.ros
netapi32.spec.def
netapi32.stubs.c

View File

@@ -12,3 +12,4 @@ drag_link.cur
drag_move.cur
nodrop.cur
ole32.spec.def
ole32.stubs.c

View File

@@ -7,3 +7,4 @@
*.tmp
Makefile.ros
oleaut32.spec.def
oleaut32.stubs.c

View File

@@ -8,3 +8,4 @@
*.tmp
Makefile.ros
oledlg.spec.def
oledlg.stubs.c

View File

@@ -7,4 +7,5 @@
*.map
*.tmp
Makefile.ros
riched32.spec.def
riched32.spec.def
riched32.stubs.c

View File

@@ -8,3 +8,4 @@
*.tmp
Makefile.ros
rpcrt4.spec.def
rpcrt4.stubs.c

View File

@@ -8,3 +8,4 @@
*.tmp
Makefile.ros
setupapi.spec.def
setupapi.stubs.c

View File

@@ -10,3 +10,4 @@ Makefile.ros
*.ico
shell32.spec.def
authors.c
shell32.stubs.c

View File

@@ -8,3 +8,4 @@
*.tmp
Makefile.ros
shlwapi.spec.def
shlwapi.stubs.c

View File

@@ -1,4 +1,4 @@
# $Id: Makefile.ros-template,v 1.2 2004/05/29 21:24:47 hbirr Exp $
# $Id: Makefile.ros-template,v 1.3 2004/11/02 19:47:18 gvg Exp $
TARGET_NAME = libwine_unicode
@@ -27,6 +27,8 @@ TARGET_BASE = $(TARGET_BASE_LIB_UNICODE)
TARGET_DEFNAME = wine_unicode
TARGET_STUBS = no
default: all
DEP_OBJECTS = $(TARGET_OBJECTS)

View File

@@ -5,4 +5,5 @@ Makefile.ros
*.d
*.sym
*.map
*.spec.def
*.spec.def
winmm.stubs.c

View File

@@ -1,4 +1,4 @@
# $Id: helper.mk,v 1.93 2004/10/28 19:01:59 chorns Exp $
# $Id: helper.mk,v 1.94 2004/11/02 19:47:18 gvg Exp $
#
# Helper makefile for ReactOS modules
# Variables this makefile accepts:
@@ -485,6 +485,10 @@ ifeq ($(TARGET_DEFNAME),)
MK_SPECDEF := $(MK_DEFBASENAME).def
else
MK_DEFBASENAME := $(TARGET_DEFNAME)
endif
ifneq ($(TARGET_STUBS),no)
MK_STUBS_SRC := $(TARGET_NAME).stubs.c
MK_STUBS_OBJ := $(TARGET_NAME).stubs.o
endif
MK_RC_BINARIES = $(TARGET_RC_BINARIES)
endif
@@ -667,7 +671,7 @@ MK_EXTRADEP += _stubs.o _hooks.o
endif
# We don't want to link header files
MK_OBJECTS := $(filter-out %.h,$(TARGET_OBJECTS))
MK_OBJECTS := $(filter-out %.h,$(TARGET_OBJECTS)) $(MK_STUBS_OBJ)
# There is problems with C++ applications and ld -r. Ld can cause errors like:
# reloc refers to symbol `.text$_ZN9CCABCodecC2Ev' which is not being output
@@ -724,7 +728,7 @@ endif
$(MK_BASENAME).a: $(MK_OBJECTS)
$(AR) -rc $(MK_BASENAME).a $(MK_OBJECTS)
$(MK_NOSTRIPNAME): $(MK_EXTRADEP) $(MK_FULLRES) $(MK_BASENAME).a $(MK_LIBS)
$(MK_NOSTRIPNAME): $(MK_EXTRADEP) $(MK_FULLRES) $(MK_BASENAME).a $(MK_LIBS) $(MK_STUBS_SRC) $(MK_STUBS_OBJ)
ifeq ($(MK_EXETYPE),dll)
$(LD_CC) -Wl,--base-file,base.tmp \
-Wl,--entry,$(TARGET_ENTRY) \
@@ -946,8 +950,8 @@ MK_CLEANDEPS := $(join $(dir $(MK_CLEANFILTERED)), $(addprefix ., $(notdir $(MK_
clean: $(MK_REGTESTS_CLEAN) $(SUBDIRS:%=%_clean)
- $(RM) *.o $(MK_PCHNAME) $(MK_BASENAME).sym $(MK_BASENAME).a $(MK_RESOURCE) \
$(MK_FULLNAME) $(MK_NOSTRIPNAME) $(MK_CLEANFILES) $(MK_CLEANDEPS) $(MK_BASENAME).map \
junk.tmp base.tmp temp.exp $(MK_RC_BINARIES) $(MK_SPECDEF) $(MK_GENERATED_MAKEFILE) \
$(TARGET_CLEAN)
junk.tmp base.tmp temp.exp $(MK_RC_BINARIES) $(MK_SPECDEF) $(MK_STUBS_SRC) \
$(MK_GENERATED_MAKEFILE) $(TARGET_CLEAN)
ifneq ($(TARGET_HEADERS),)
$(TARGET_OBJECTS): $(TARGET_HEADERS)
@@ -1100,6 +1104,8 @@ endif
$(WINEBUILD) $(DEFS) -o $@ --def $<
%.drv.spec.def: %.spec
$(WINEBUILD) $(DEFS) -o $@ --def $<
%.stubs.c: %.spec
$(WINEBUILD) $(DEFS) -o $@ --pedll $<
%.i: %.c
$(CC) $(TARGET_CFLAGS) -E $< > $@
%.h.gch: %.h

View File

@@ -185,6 +185,7 @@ extern void BuildSpec16File( FILE *outfile, DLLSPEC *spec );
extern void BuildSpec32File( FILE *outfile, DLLSPEC *spec );
extern void BuildDef32File( FILE *outfile, DLLSPEC *spec );
extern void BuildDebugFile( FILE *outfile, const char *srcdir, char **argv );
extern void BuildPedllFile( FILE *outfile, DLLSPEC *spec );
extern int parse_spec_file( FILE *file, DLLSPEC *spec );
extern int parse_def_file( FILE *file, DLLSPEC *spec );

View File

@@ -74,7 +74,8 @@ enum exec_mode_values
MODE_DEF,
MODE_DEBUG,
MODE_RELAY16,
MODE_RELAY32
MODE_RELAY32,
MODE_PEDLL
};
static enum exec_mode_values exec_mode = MODE_NONE;
@@ -159,7 +160,8 @@ static const char usage_str[] =
" --exe=NAME Build a .c file for the named executable\n"
" --debug [FILES] Build a .c file with the debug channels declarations\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"
" --pedll Build a .c file for PE dll\n\n"
"The mode options are mutually exclusive; you must specify one and only one.\n\n";
enum long_options_values
@@ -171,7 +173,8 @@ enum long_options_values
LONG_OPT_RELAY16,
LONG_OPT_RELAY32,
LONG_OPT_SUBSYSTEM,
LONG_OPT_VERSION
LONG_OPT_VERSION,
LONG_OPT_PEDLL
};
static const char short_options[] = "C:D:F:H:I:K:L:M:N:d:e:f:hi:kl:m:o:r:w";
@@ -186,6 +189,7 @@ static const struct option long_options[] =
{ "relay32", 0, 0, LONG_OPT_RELAY32 },
{ "subsystem",1, 0, LONG_OPT_SUBSYSTEM },
{ "version", 0, 0, LONG_OPT_VERSION },
{ "pedll", 1, 0, LONG_OPT_PEDLL },
/* aliases for short options */
{ "source-dir", 1, 0, 'C' },
{ "delay-lib", 1, 0, 'd' },
@@ -341,6 +345,11 @@ static char **parse_options( int argc, char **argv, DLLSPEC *spec )
case LONG_OPT_VERSION:
printf( "winebuild version " PACKAGE_VERSION "\n" );
exit(0);
case LONG_OPT_PEDLL:
set_exec_mode( MODE_PEDLL );
spec_file_name = xstrdup( optarg );
set_dll_file_name( optarg, spec );
break;
case '?':
usage(1);
break;
@@ -442,6 +451,11 @@ int main(int argc, char **argv)
case MODE_RELAY32:
fatal_error( "Win32 relays are not supported in ReactOS version of winebuild\n" );
break;
case MODE_PEDLL:
if (argv[0]) fatal_error( "file argument '%s' not allowed in this mode\n", argv[0] );
if (!parse_input_file( spec )) break;
BuildPedllFile( output_file, spec );
break;
default:
usage(1);
break;

View File

@@ -851,12 +851,10 @@ void BuildDef32File( FILE *outfile, DLLSPEC *spec )
int is_data = 0;
if (!odp) continue;
if (odp->flags & FLAG_REGISTER) continue;
if (odp->type == TYPE_STUB) continue;
if (odp->name) name = odp->name;
else if (odp->type == TYPE_STUB) name = make_internal_name( odp, spec, "stub" );
else if (odp->export_name) name = odp->export_name;
else continue;
else name = make_internal_name( odp, spec, "noname_export" );
fprintf(outfile, " %s", name);
@@ -886,11 +884,23 @@ void BuildDef32File( FILE *outfile, DLLSPEC *spec )
}
break;
}
case TYPE_STUB:
{
if (NULL != odp->name)
{
fprintf(outfile, "=%s", make_internal_name( odp, spec, "stub" ));
}
break;
}
default:
assert(0);
}
fprintf( outfile, " @%d", odp->ordinal );
#if 0 /* MinGW binutils cannot handle this correctly */
if (!odp->name) fprintf( outfile, " NONAME" );
#else
if (!odp->name && (odp->type == TYPE_STUB || odp->export_name)) fprintf( outfile, " NONAME" );
#endif
if (is_data) fprintf( outfile, " DATA" );
#if 0
/* MinGW binutils cannot handle this correctly */
@@ -994,3 +1004,24 @@ void BuildDebugFile( FILE *outfile, const char *srcdir, char **argv )
free( prefix );
}
/*******************************************************************
* BuildPedllFile
*
* Build a PE DLL C file from a spec file.
*/
void BuildPedllFile( FILE *outfile, DLLSPEC *spec )
{
int nr_exports;
nr_exports = spec->base <= spec->limit ? spec->limit - spec->base + 1 : 0;
output_standard_file_header( outfile );
if (nr_exports)
{
/* Output the stub functions */
output_stub_funcs( outfile, spec );
}
}