winebuild: Add an option to convert a .def file to a .spec file
André Hentschel
nerv at dawncrow.de
Thu Aug 16 15:41:11 CDT 2012
This is usefull when viewing/importing def files from other projects (e.g. mingw-w64)
---
tools/winebuild/build.h | 1 +
tools/winebuild/main.c | 13 +++++++++++++
tools/winebuild/spec32.c | 27 +++++++++++++++++++++++++++
3 files changed, 41 insertions(+), 0 deletions(-)
diff --git a/tools/winebuild/build.h b/tools/winebuild/build.h
index 05adf31..7aa8230 100644
--- a/tools/winebuild/build.h
+++ b/tools/winebuild/build.h
@@ -296,6 +296,7 @@ extern void output_resources( DLLSPEC *spec );
extern void output_bin_resources( DLLSPEC *spec, unsigned int start_rva );
extern void output_fake_module( DLLSPEC *spec );
extern void output_def_file( DLLSPEC *spec, int include_private );
+extern void output_spec_file( DLLSPEC *spec );
extern void load_res16_file( const char *name, DLLSPEC *spec );
extern void output_res16_data( DLLSPEC *spec );
extern void output_bin_res16_data( DLLSPEC *spec );
diff --git a/tools/winebuild/main.c b/tools/winebuild/main.c
index 28ecec8..2004726 100644
--- a/tools/winebuild/main.c
+++ b/tools/winebuild/main.c
@@ -100,6 +100,7 @@ enum exec_mode_values
MODE_DLL,
MODE_EXE,
MODE_DEF,
+ MODE_SPEC,
MODE_IMPLIB,
MODE_RESOURCES
};
@@ -275,6 +276,7 @@ static const char usage_str[] =
"\nMode options:\n"
" --dll Build a .c file from a .spec or .def file\n"
" --def Build a .def file from a .spec file\n"
+" --spec Build a .spec file from a .def file\n"
" --exe Build a .c file for an executable\n"
" --implib Build an import library\n"
" --resources Build a .o file for the resource files\n\n"
@@ -284,6 +286,7 @@ enum long_options_values
{
LONG_OPT_DLL = 1,
LONG_OPT_DEF,
+ LONG_OPT_SPEC,
LONG_OPT_EXE,
LONG_OPT_IMPLIB,
LONG_OPT_ASCMD,
@@ -305,6 +308,7 @@ static const struct option long_options[] =
{
{ "dll", 0, 0, LONG_OPT_DLL },
{ "def", 0, 0, LONG_OPT_DEF },
+ { "spec", 0, 0, LONG_OPT_SPEC },
{ "exe", 0, 0, LONG_OPT_EXE },
{ "implib", 0, 0, LONG_OPT_IMPLIB },
{ "as-cmd", 1, 0, LONG_OPT_ASCMD },
@@ -466,6 +470,9 @@ static char **parse_options( int argc, char **argv, DLLSPEC *spec )
case LONG_OPT_DEF:
set_exec_mode( MODE_DEF );
break;
+ case LONG_OPT_SPEC:
+ set_exec_mode( MODE_SPEC );
+ break;
case LONG_OPT_EXE:
set_exec_mode( MODE_EXE );
if (!spec->subsystem) spec->subsystem = IMAGE_SUBSYSTEM_WINDOWS_GUI;
@@ -646,6 +653,12 @@ int main(int argc, char **argv)
if (!parse_input_file( spec )) break;
output_def_file( spec, 1 );
break;
+ case MODE_SPEC:
+ if (!argv[0]) fatal_error( "missing .def file\n" );
+ spec_file_name = xstrdup( argv[0] );
+ if (!parse_input_file( spec )) break;
+ output_spec_file( spec );
+ break;
case MODE_IMPLIB:
if (!spec_file_name) fatal_error( "missing .spec file\n" );
if (!parse_input_file( spec )) break;
diff --git a/tools/winebuild/spec32.c b/tools/winebuild/spec32.c
index 20fcbc0..5b539fb 100644
--- a/tools/winebuild/spec32.c
+++ b/tools/winebuild/spec32.c
@@ -924,3 +924,30 @@ void output_def_file( DLLSPEC *spec, int include_private )
if (!total) warning( "%s: Import library doesn't export anything\n", spec->file_name );
if (spec32) free_dll_spec( spec32 );
}
+
+/*******************************************************************
+ * output_spec_file
+ *
+ * Build a spec file from a def file.
+ */
+void output_spec_file( DLLSPEC *spec )
+{
+ const char *name;
+ int i;
+
+ for (i = 0; i < spec->nb_entry_points; i++)
+ {
+ const ORDDEF *odp = &spec->entry_points[i];
+
+ if (!odp) continue;
+
+ if (odp->name) name = odp->name;
+ else if (odp->export_name) name = odp->export_name;
+ else continue;
+
+ output( "%d stub", odp->ordinal );
+ if (!odp->name || (odp->flags & (FLAG_NONAME|FLAG_ORDINAL))) output( " -noname" );
+ if (odp->flags & FLAG_PRIVATE) output( " -private" );
+ output( " %s\n", name );
+ }
+}
--
1.7.4.1
--
Best Regards, André Hentschel
More information about the wine-patches
mailing list