From f9029e5cd8d7e45ea62dbaf3b226d1794fc569bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9=20van=20Geldorp?= Date: Tue, 2 Nov 2004 19:47:18 +0000 Subject: [PATCH] Generate stub functions from .spec file svn path=/trunk/; revision=11528 --- reactos/lib/cabinet/.cvsignore | 1 + reactos/lib/comctl32/.cvsignore | 1 + reactos/lib/comdlg32/.cvsignore | 1 + reactos/lib/iphlpapi/.cvsignore | 1 + reactos/lib/mpr/.cvsignore | 1 + reactos/lib/msacm/.cvsignore | 1 + reactos/lib/msvideo/.cvsignore | 1 + reactos/lib/netapi32/.cvsignore | 1 + reactos/lib/ole32/.cvsignore | 1 + reactos/lib/oleaut32/.cvsignore | 1 + reactos/lib/oledlg/.cvsignore | 1 + reactos/lib/richedit/.cvsignore | 3 +- reactos/lib/rpcrt4/.cvsignore | 1 + reactos/lib/setupapi/.cvsignore | 1 + reactos/lib/shell32/.cvsignore | 1 + reactos/lib/shlwapi/.cvsignore | 1 + reactos/lib/unicode/Makefile.ros-template | 4 ++- reactos/lib/winmm/.cvsignore | 3 +- reactos/tools/helper.mk | 16 +++++++--- reactos/tools/winebuild/build.h | 1 + reactos/tools/winebuild/main.c | 20 ++++++++++-- reactos/tools/winebuild/spec32.c | 39 ++++++++++++++++++++--- 22 files changed, 86 insertions(+), 15 deletions(-) diff --git a/reactos/lib/cabinet/.cvsignore b/reactos/lib/cabinet/.cvsignore index 53ed6840912..8c8c8af8d32 100644 --- a/reactos/lib/cabinet/.cvsignore +++ b/reactos/lib/cabinet/.cvsignore @@ -8,3 +8,4 @@ *.tmp Makefile.ros cabinet.spec.def +cabinet.stubs.c diff --git a/reactos/lib/comctl32/.cvsignore b/reactos/lib/comctl32/.cvsignore index ef777e14fa3..7c5d58f1704 100644 --- a/reactos/lib/comctl32/.cvsignore +++ b/reactos/lib/comctl32/.cvsignore @@ -23,3 +23,4 @@ idi_tt_info_sm.ico idi_tt_warn_sm.ico idt_check.bmp comctl32.spec.def +comctl32.stubs.c diff --git a/reactos/lib/comdlg32/.cvsignore b/reactos/lib/comdlg32/.cvsignore index 697e67d583b..91839394166 100644 --- a/reactos/lib/comdlg32/.cvsignore +++ b/reactos/lib/comdlg32/.cvsignore @@ -10,3 +10,4 @@ Makefile.ros *.bmp *.ico comdlg32.spec.def +comdlg32.stubs.c \ No newline at end of file diff --git a/reactos/lib/iphlpapi/.cvsignore b/reactos/lib/iphlpapi/.cvsignore index e1b2a86dc6b..a7812eb1a68 100644 --- a/reactos/lib/iphlpapi/.cvsignore +++ b/reactos/lib/iphlpapi/.cvsignore @@ -19,3 +19,4 @@ temp.exp *.tmp Makefile.ros iphlpapi.spec.def +iphlpapi.stubs.c diff --git a/reactos/lib/mpr/.cvsignore b/reactos/lib/mpr/.cvsignore index 23d51ec3770..e2c0b7267b7 100644 --- a/reactos/lib/mpr/.cvsignore +++ b/reactos/lib/mpr/.cvsignore @@ -8,3 +8,4 @@ *.tmp Makefile.ros mpr.spec.def +mpr.stubs.c diff --git a/reactos/lib/msacm/.cvsignore b/reactos/lib/msacm/.cvsignore index 5434809788c..13184e19f5b 100644 --- a/reactos/lib/msacm/.cvsignore +++ b/reactos/lib/msacm/.cvsignore @@ -9,3 +9,4 @@ temp.exp msacm32.spec.def Makefile.ros +msacm32.stubs.c diff --git a/reactos/lib/msvideo/.cvsignore b/reactos/lib/msvideo/.cvsignore index ba02949c04d..9e965988427 100644 --- a/reactos/lib/msvideo/.cvsignore +++ b/reactos/lib/msvideo/.cvsignore @@ -7,3 +7,4 @@ *.tmp Makefile.ros msvfw32.spec.def +msvfw32.stubs.c diff --git a/reactos/lib/netapi32/.cvsignore b/reactos/lib/netapi32/.cvsignore index 0c1b0752c54..780ed5ab6ec 100644 --- a/reactos/lib/netapi32/.cvsignore +++ b/reactos/lib/netapi32/.cvsignore @@ -8,3 +8,4 @@ *.tmp Makefile.ros netapi32.spec.def +netapi32.stubs.c diff --git a/reactos/lib/ole32/.cvsignore b/reactos/lib/ole32/.cvsignore index 024c5c373ce..8bfd83e6ec1 100644 --- a/reactos/lib/ole32/.cvsignore +++ b/reactos/lib/ole32/.cvsignore @@ -12,3 +12,4 @@ drag_link.cur drag_move.cur nodrop.cur ole32.spec.def +ole32.stubs.c diff --git a/reactos/lib/oleaut32/.cvsignore b/reactos/lib/oleaut32/.cvsignore index 8f3b3e45db8..54e5f606adb 100644 --- a/reactos/lib/oleaut32/.cvsignore +++ b/reactos/lib/oleaut32/.cvsignore @@ -7,3 +7,4 @@ *.tmp Makefile.ros oleaut32.spec.def +oleaut32.stubs.c diff --git a/reactos/lib/oledlg/.cvsignore b/reactos/lib/oledlg/.cvsignore index 07623ce9916..2e01462a2cd 100644 --- a/reactos/lib/oledlg/.cvsignore +++ b/reactos/lib/oledlg/.cvsignore @@ -8,3 +8,4 @@ *.tmp Makefile.ros oledlg.spec.def +oledlg.stubs.c diff --git a/reactos/lib/richedit/.cvsignore b/reactos/lib/richedit/.cvsignore index f6c8adbb35d..0813f89345a 100644 --- a/reactos/lib/richedit/.cvsignore +++ b/reactos/lib/richedit/.cvsignore @@ -7,4 +7,5 @@ *.map *.tmp Makefile.ros -riched32.spec.def \ No newline at end of file +riched32.spec.def +riched32.stubs.c diff --git a/reactos/lib/rpcrt4/.cvsignore b/reactos/lib/rpcrt4/.cvsignore index e5b0d54498f..b6b6916e483 100644 --- a/reactos/lib/rpcrt4/.cvsignore +++ b/reactos/lib/rpcrt4/.cvsignore @@ -8,3 +8,4 @@ *.tmp Makefile.ros rpcrt4.spec.def +rpcrt4.stubs.c diff --git a/reactos/lib/setupapi/.cvsignore b/reactos/lib/setupapi/.cvsignore index d89c37dd791..93d2bf1329a 100644 --- a/reactos/lib/setupapi/.cvsignore +++ b/reactos/lib/setupapi/.cvsignore @@ -8,3 +8,4 @@ *.tmp Makefile.ros setupapi.spec.def +setupapi.stubs.c diff --git a/reactos/lib/shell32/.cvsignore b/reactos/lib/shell32/.cvsignore index fc512c5449f..86760760926 100644 --- a/reactos/lib/shell32/.cvsignore +++ b/reactos/lib/shell32/.cvsignore @@ -10,3 +10,4 @@ Makefile.ros *.ico shell32.spec.def authors.c +shell32.stubs.c diff --git a/reactos/lib/shlwapi/.cvsignore b/reactos/lib/shlwapi/.cvsignore index b28a0895f1c..c3ef3272310 100644 --- a/reactos/lib/shlwapi/.cvsignore +++ b/reactos/lib/shlwapi/.cvsignore @@ -8,3 +8,4 @@ *.tmp Makefile.ros shlwapi.spec.def +shlwapi.stubs.c diff --git a/reactos/lib/unicode/Makefile.ros-template b/reactos/lib/unicode/Makefile.ros-template index dcd8e45abcb..69bead63216 100644 --- a/reactos/lib/unicode/Makefile.ros-template +++ b/reactos/lib/unicode/Makefile.ros-template @@ -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) diff --git a/reactos/lib/winmm/.cvsignore b/reactos/lib/winmm/.cvsignore index 1e1bd93e31e..a74647c0151 100644 --- a/reactos/lib/winmm/.cvsignore +++ b/reactos/lib/winmm/.cvsignore @@ -5,4 +5,5 @@ Makefile.ros *.d *.sym *.map -*.spec.def \ No newline at end of file +*.spec.def +winmm.stubs.c diff --git a/reactos/tools/helper.mk b/reactos/tools/helper.mk index 91edae4bd17..0ba1dfadad4 100644 --- a/reactos/tools/helper.mk +++ b/reactos/tools/helper.mk @@ -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 diff --git a/reactos/tools/winebuild/build.h b/reactos/tools/winebuild/build.h index 281b4fd1864..c58ca840f20 100644 --- a/reactos/tools/winebuild/build.h +++ b/reactos/tools/winebuild/build.h @@ -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 ); diff --git a/reactos/tools/winebuild/main.c b/reactos/tools/winebuild/main.c index 98877bdbb3f..f50856ef98f 100644 --- a/reactos/tools/winebuild/main.c +++ b/reactos/tools/winebuild/main.c @@ -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; diff --git a/reactos/tools/winebuild/spec32.c b/reactos/tools/winebuild/spec32.c index 331ef915468..15d5a163f0d 100644 --- a/reactos/tools/winebuild/spec32.c +++ b/reactos/tools/winebuild/spec32.c @@ -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 ); + } +}