Modified: branches/xmlbuildsystem/reactos/lib/kernel32/kernel32.xml
Modified: branches/xmlbuildsystem/reactos/lib/kernel32/tests/tests/CreateFile.c
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.h
Added: branches/xmlbuildsystem/reactos/tools/rbuild/filesupportcode.cpp
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/project.cpp
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.mak
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/stubbedcomponent.cpp
Added: branches/xmlbuildsystem/reactos/tools/rbuild/testsupportcode.cpp
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/wineresource.cpp
--- branches/xmlbuildsystem/reactos/lib/kernel32/kernel32.xml 2005-05-15 11:46:20 UTC (rev 15303)
+++ branches/xmlbuildsystem/reactos/lib/kernel32/kernel32.xml 2005-05-15 11:58:48 UTC (rev 15304)
@@ -1,3 +1,19 @@
+<module name="kernel32" type="win32dll" baseaddress="${BASEADDRESS_KERNEL32}" installbase="system32" installname="kernel32.dll">
+ <importlibrary definition="kernel32.def" />
+ <include base="kernel32">.</include>
+ <include base="kernel32">include</include>
+ <define name="_DISABLE_TIDENTS" />
+ <define name="_SEH_NO_NATIVE_NLG" />
+ <define name="WINVER">0x0500</define>
+ <library>kernel32_base</library>
+ <library>pseh</library>
+ <library>rosrtl</library>
+ <library>ntdll</library>
+ <linkerflag>-lgcc</linkerflag>
+ <linkerflag>-nostartfiles</linkerflag>
+ <linkerflag>-nostdlib</linkerflag>
+ <file>kernel32.rc</file>
+</module>
<module name="kernel32_base" type="objectlibrary">
<include base="kernel32_base">.</include>
<include base="kernel32_base">include</include>
@@ -104,24 +120,8 @@
<file>tls.c</file>
</directory>
</module>
-<module name="kernel32" type="win32dll" baseaddress="${BASEADDRESS_KERNEL32}" installbase="system32" installname="kernel32.dll">
- <importlibrary definition="kernel32.def" />
- <include base="kernel32">.</include>
- <include base="kernel32">include</include>
- <define name="_DISABLE_TIDENTS" />
- <define name="_SEH_NO_NATIVE_NLG" />
- <define name="WINVER">0x0500</define>
- <library>kernel32_base</library>
- <library>pseh</library>
- <library>rosrtl</library>
- <library>ntdll</library>
- <linkerflag>-lgcc</linkerflag>
- <linkerflag>-nostartfiles</linkerflag>
- <linkerflag>-nostdlib</linkerflag>
- <file>kernel32.rc</file>
-</module>
<!--
<directory name="tests">
<xi:include href="tests/kernel32.xml" />
</directory>
--->
+-->
\ No newline at end of file
--- branches/xmlbuildsystem/reactos/lib/kernel32/tests/tests/CreateFile.c 2005-05-15 11:46:20 UTC (rev 15303)
+++ branches/xmlbuildsystem/reactos/lib/kernel32/tests/tests/CreateFile.c 2005-05-15 11:58:48 UTC (rev 15304)
@@ -12,11 +12,11 @@
{
LPCWSTR lpFileName;
DWORD dwDesiredAccess;
- DWORD dwShareMode;
- LPSECURITY_ATTRIBUTES lpSecurityAttributes;
- DWORD dwCreationDisposition;
- DWORD dwFlagsAndAttributes;
- HANDLE hTemplateFile;
+ DWORD dwShareMode;
+ LPSECURITY_ATTRIBUTES lpSecurityAttributes;
+ DWORD dwCreationDisposition;
+ DWORD dwFlagsAndAttributes;
+ HANDLE hTemplateFile;
} CreateFile_PARAMETERS;
typedef struct
@@ -93,7 +93,7 @@
static HOOK NtCreateFileHooks[] =
{
{"NtCreateFile", MockNtCreateFile},
- NULL, NULL
+ {NULL, NULL}
};
static void TestFile()
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp 2005-05-15 11:46:20 UTC (rev 15303)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp 2005-05-15 11:58:48 UTC (rev 15304)
@@ -41,18 +41,6 @@
}
-/* static */ string
-Environment::GetVariable ( const string& name )
-{
- char* value = getenv ( name.c_str () );
- if ( value != NULL && strlen ( value ) > 0 )
- return ssprintf ( "%s",
- value );
- else
- return "";
-}
-
-
Directory::Directory ( const string& name_ )
: name(name_)
{
@@ -131,45 +119,13 @@
return path;
}
-/* static */ string
-Directory::GetEnvironmentVariablePathOrDefault ( const string& name,
- const string& defaultValue )
-{
- const string& environmentVariableValue = Environment::GetVariable ( name );
- if ( environmentVariableValue.length () > 0 )
- return NormalizeFilename ( environmentVariableValue );
- else
- return defaultValue;
-}
-
-/* static */ string
-Directory::GetIntermediatePath ()
-{
- return GetEnvironmentVariablePathOrDefault ( "ROS_INTERMEDIATE",
- "obj-i386" );
-}
-
-/* static */ string
-Directory::GetOutputPath ()
-{
- return GetEnvironmentVariablePathOrDefault ( "ROS_OUTPUT",
- "output-i386" );
-}
-
-/* static */ string
-Directory::GetInstallPath ()
-{
- return GetEnvironmentVariablePathOrDefault ( "ROS_INSTALL",
- "reactos" );
-}
-
void
Directory::ResolveVariablesInPath ( char* buf,
string path )
{
- string s = ReplaceVariable ( "$(INTERMEDIATE)", GetIntermediatePath (), path );
- s = ReplaceVariable ( "$(OUTPUT)", GetOutputPath (), s );
- s = ReplaceVariable ( "$(INSTALL)", GetInstallPath (), s );
+ string s = ReplaceVariable ( "$(INTERMEDIATE)", Environment::GetIntermediatePath (), path );
+ s = ReplaceVariable ( "$(OUTPUT)", Environment::GetOutputPath (), s );
+ s = ReplaceVariable ( "$(INSTALL)", Environment::GetInstallPath (), s );
strcpy ( buf, s.c_str () );
}
@@ -217,7 +173,7 @@
void
Directory::CreateRule ( FILE* f,
- const string& parent )
+ const string& parent )
{
string path;
@@ -356,6 +312,7 @@
GenerateDirectoryTargets ();
GenerateDirectories ();
UnpackWineResources ();
+ GenerateTestSupportCode ();
CheckAutomaticDependencies ();
CloseMakefile ();
}
@@ -641,7 +598,7 @@
string
MingwBackend::GetBin2ResExecutable ()
{
- return NormalizeFilename ( Directory::GetOutputPath () + SSEP + "tools/bin2res/bin2res" + EXEPOSTFIX );
+ return NormalizeFilename ( Environment::GetOutputPath () + SSEP + "tools/bin2res/bin2res" + EXEPOSTFIX );
}
void
@@ -655,6 +612,15 @@
}
void
+MingwBackend::GenerateTestSupportCode ()
+{
+ printf ( "Generating test support code..." );
+ TestSupportCode testSupportCode ( ProjectNode );
+ testSupportCode.GenerateTestSupportCode ( verbose );
+ printf ( "done\n" );
+}
+
+void
MingwBackend::CheckAutomaticDependencies ()
{
printf ( "Checking automatic dependencies..." );
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.h 2005-05-15 11:46:20 UTC (rev 15303)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.h 2005-05-15 11:58:48 UTC (rev 15304)
@@ -18,13 +18,6 @@
typedef std::map<std::string,Directory*> directory_map;
-class Environment
-{
-public:
- static std::string GetVariable ( const std::string& name );
-};
-
-
class Directory
{
public:
@@ -37,17 +30,12 @@
std::string EscapeSpaces ( std::string path );
void CreateRule ( FILE* f,
const std::string& parent );
- static std::string GetIntermediatePath ();
- static std::string GetOutputPath ();
- static std::string GetInstallPath ();
private:
bool mkdir_p ( const char* path );
std::string ReplaceVariable ( std::string name,
std::string value,
std::string path );
std::string GetEnvironmentVariable ( const std::string& name );
- static std::string GetEnvironmentVariablePathOrDefault ( const std::string& name,
- const std::string& defaultValue );
void ResolveVariablesInPath ( char* buf,
std::string path );
bool CreateDirectory ( std::string path );
@@ -92,6 +80,7 @@
void GenerateXmlBuildFilesMacro() const;
std::string GetBin2ResExecutable ();
void UnpackWineResources ();
+ void GenerateTestSupportCode ();
void CheckAutomaticDependencies ();
bool IncludeDirectoryTarget ( const std::string& directory ) const;
bool TryToDetectThisCompiler ( const std::string& compiler );
--- branches/xmlbuildsystem/reactos/tools/rbuild/filesupportcode.cpp 2005-05-15 11:46:20 UTC (rev 15303)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/filesupportcode.cpp 2005-05-15 11:58:48 UTC (rev 15304)
@@ -0,0 +1,68 @@
+#include "pch.h"
+#include <assert.h>
+
+#include "rbuild.h"
+
+using std::string;
+
+/* static */ void
+FileSupportCode::WriteIfChanged ( char* outbuf,
+ string filename )
+{
+ FILE* out;
+ unsigned int end;
+ char* cmpbuf;
+ unsigned int stat;
+
+ out = fopen ( filename.c_str (), "rb" );
+ if ( out == NULL )
+ {
+ out = fopen ( filename.c_str (), "wb" );
+ if ( out == NULL )
+ throw AccessDeniedException ( filename );
+ fputs ( outbuf, out );
+ fclose ( out );
+ return;
+ }
+
+ fseek ( out, 0, SEEK_END );
+ end = ftell ( out );
+ cmpbuf = (char*) malloc ( end );
+ if ( cmpbuf == NULL )
+ {
+ fclose ( out );
+ throw OutOfMemoryException ();
+ }
+
+ fseek ( out, 0, SEEK_SET );
+ stat = fread ( cmpbuf, 1, end, out );
+ if ( stat != end )
+ {
+ free ( cmpbuf );
+ fclose ( out );
+ throw AccessDeniedException ( filename );
+ }
+ if ( end == strlen ( outbuf ) && memcmp ( cmpbuf, outbuf, end ) == 0 )
+ {
+ free ( cmpbuf );
+ fclose ( out );
+ return;
+ }
+
+ free ( cmpbuf );
+ fclose ( out );
+ out = fopen ( filename.c_str (), "wb" );
+ if ( out == NULL )
+ {
+ throw AccessDeniedException ( filename );
+ }
+
+ stat = fwrite ( outbuf, 1, strlen ( outbuf ), out);
+ if ( strlen ( outbuf ) != stat )
+ {
+ fclose ( out );
+ throw AccessDeniedException ( filename );
+ }
+
+ fclose ( out );
+}
Property changes on: branches/xmlbuildsystem/reactos/tools/rbuild/filesupportcode.cpp
___________________________________________________________________
Name: svn:eol-style
+ native
--- branches/xmlbuildsystem/reactos/tools/rbuild/project.cpp 2005-05-15 11:46:20 UTC (rev 15303)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/project.cpp 2005-05-15 11:58:48 UTC (rev 15304)
@@ -7,6 +7,50 @@
using std::string;
using std::vector;
+/* static */ string
+Environment::GetVariable ( const string& name )
+{
+ char* value = getenv ( name.c_str () );
+ if ( value != NULL && strlen ( value ) > 0 )
+ return ssprintf ( "%s",
+ value );
+ else
+ return "";
+}
+
+/* static */ string
+Environment::GetEnvironmentVariablePathOrDefault ( const string& name,
+ const string& defaultValue )
+{
+ const string& environmentVariableValue = Environment::GetVariable ( name );
+ if ( environmentVariableValue.length () > 0 )
+ return NormalizeFilename ( environmentVariableValue );
+ else
+ return defaultValue;
+}
+
+/* static */ string
+Environment::GetIntermediatePath ()
+{
+ return GetEnvironmentVariablePathOrDefault ( "ROS_INTERMEDIATE",
+ "obj-i386" );
+}
+
+/* static */ string
+Environment::GetOutputPath ()
+{
+ return GetEnvironmentVariablePathOrDefault ( "ROS_OUTPUT",
+ "output-i386" );
+}
+
+/* static */ string
+Environment::GetInstallPath ()
+{
+ return GetEnvironmentVariablePathOrDefault ( "ROS_INSTALL",
+ "reactos" );
+}
+
+
Project::Project ( const string& filename )
: xmlfile (filename),
node (NULL),
@@ -42,68 +86,6 @@
}
void
-Project::WriteIfChanged ( char* outbuf,
- string filename )
-{
- FILE* out;
- unsigned int end;
- char* cmpbuf;
- unsigned int stat;
-
- out = fopen ( filename.c_str (), "rb" );
- if ( out == NULL )
- {
- out = fopen ( filename.c_str (), "wb" );
- if ( out == NULL )
- throw AccessDeniedException ( filename );
- fputs ( outbuf, out );
- fclose ( out );
- return;
- }
-
- fseek ( out, 0, SEEK_END );
- end = ftell ( out );
- cmpbuf = (char*) malloc ( end );
- if ( cmpbuf == NULL )
- {
- fclose ( out );
- throw OutOfMemoryException ();
- }
-
- fseek ( out, 0, SEEK_SET );
- stat = fread ( cmpbuf, 1, end, out );
- if ( stat != end )
- {
- free ( cmpbuf );
- fclose ( out );
- throw AccessDeniedException ( filename );
- }
- if ( end == strlen ( outbuf ) && memcmp ( cmpbuf, outbuf, end ) == 0 )
- {
- free ( cmpbuf );
- fclose ( out );
- return;
- }
-
- free ( cmpbuf );
- fclose ( out );
- out = fopen ( filename.c_str (), "wb" );
- if ( out == NULL )
- {
- throw AccessDeniedException ( filename );
- }
-
- stat = fwrite ( outbuf, 1, strlen ( outbuf ), out);
- if ( strlen ( outbuf ) != stat )
- {
- fclose ( out );
- throw AccessDeniedException ( filename );
- }
-
- fclose ( out );
-}
-
-void
Project::SetConfigurationOption ( char* s,
string name,
string* alternativeName )
@@ -161,7 +143,7 @@
s = s + sprintf ( s, "#endif /* __INCLUDE_CONFIG_H */\n" );
- WriteIfChanged ( buf, "include" SSEP "roscfg.h" );
+ FileSupportCode::WriteIfChanged ( buf, "include" SSEP "roscfg.h" );
free ( buf );
}
--- branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h 2005-05-15 11:46:20 UTC (rev 15303)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h 2005-05-15 11:58:48 UTC (rev 15304)
@@ -55,6 +55,7 @@
class CompilerFlag;
class LinkerFlag;
class Property;
+class TestSupportCode;
class WineResource;
class AutomaticDependency;
class Bootstrap;
@@ -66,6 +67,25 @@
class SourceFileTest;
+
+class Environment
+{
+public:
+ static std::string GetVariable ( const std::string& name );
+ static std::string GetIntermediatePath ();
+ static std::string GetOutputPath ();
+ static std::string GetInstallPath ();
+ static std::string GetEnvironmentVariablePathOrDefault ( const std::string& name,
+ const std::string& defaultValue );
+};
+
+class FileSupportCode
+{
+public:
+ static void WriteIfChanged ( char* outbuf,
+ std::string filename );
+};
+
class IfableData
{
public:
@@ -110,8 +130,6 @@
std::string* alternativeName );
void SetConfigurationOption ( char* s,
std::string name );
- void WriteIfChanged ( char* outbuf,
- std::string filename );
void ReadXml ();
void ProcessXMLSubElement ( const XMLElement& e,
const std::string& path,
@@ -422,6 +440,37 @@
};
+class TestSupportCode
+{
+public:
+ const Project& project;
+
+ TestSupportCode ( const Project& project );
+ ~TestSupportCode ();
+ void GenerateTestSupportCode ( bool verbose );
+private:
+ bool IsTestModule ( const Module& module );
+ void GenerateTestSupportCodeForModule ( Module& module,
+ bool verbose );
+ std::string GetHooksFilename ( Module& module );
+ char* WriteStubbedSymbolToHooksFile ( char* buffer,
+ const StubbedComponent& component,
+ const StubbedSymbol& symbol );
+ char* WriteStubbedComponentToHooksFile ( char* buffer,
+ const StubbedComponent& component );
+ void WriteHooksFile ( Module& module );
+ std::string GetStubsFilename ( Module& module );
+ char* WriteStubbedSymbolToStubsFile ( char* buffer,
+ const StubbedComponent& component,
+ const StubbedSymbol& symbol,
+ int stubIndex );
+ char* WriteStubbedComponentToStubsFile ( char* buffer,
+ const StubbedComponent& component,
+ int* stubIndex );
+ void WriteStubsFile ( Module& module );
+};
+
+
class WineResource
{
public:
@@ -610,10 +659,13 @@
const XMLElement& node;
std::string symbol;
std::string newname;
+ std::string strippedName;
StubbedSymbol ( const XMLElement& stubbedSymbolNode );
~StubbedSymbol ();
void ProcessXML();
+private:
+ std::string StripSymbol ( std::string symbol );
};
extern std::string
--- branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.mak 2005-05-15 11:46:20 UTC (rev 15303)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.mak 2005-05-15 11:58:48 UTC (rev 15304)
@@ -116,6 +116,7 @@
compilerflag.cpp \
define.cpp \
exception.cpp \
+ filesupportcode.cpp \
include.cpp \
installfile.cpp \
linkerflag.cpp \
@@ -123,6 +124,7 @@
project.cpp \
ssprintf.cpp \
stubbedcomponent.cpp \
+ testsupportcode.cpp \
wineresource.cpp \
XML.cpp \
)
@@ -230,6 +232,10 @@
$(ECHO_CC)
${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
+$(RBUILD_INT_)filesupportcode.o: $(RBUILD_BASE_)filesupportcode.cpp $(RBUILD_HEADERS) | $(RBUILD_INT)
+ $(ECHO_CC)
+ ${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
+
$(RBUILD_INT_)include.o: $(RBUILD_BASE_)include.cpp $(RBUILD_HEADERS) | $(RBUILD_INT)
$(ECHO_CC)
${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
@@ -266,6 +272,10 @@
$(ECHO_CC)
${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
+$(RBUILD_INT_)testsupportcode.o: $(RBUILD_BASE_)testsupportcode.cpp $(RBUILD_HEADERS) | $(RBUILD_INT)
+ $(ECHO_CC)
+ ${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
+
$(RBUILD_INT_)XML.o: $(RBUILD_BASE_)XML.cpp $(RBUILD_HEADERS) | $(RBUILD_INT)
$(ECHO_CC)
${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
--- branches/xmlbuildsystem/reactos/tools/rbuild/stubbedcomponent.cpp 2005-05-15 11:46:20 UTC (rev 15303)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/stubbedcomponent.cpp 2005-05-15 11:58:48 UTC (rev 15304)
@@ -77,4 +77,23 @@
newname = att->value;
else
newname = symbol;
+
+ strippedName = StripSymbol ( symbol );
}
+
+string
+StubbedSymbol::StripSymbol ( string symbol )
+{
+ size_t start = 0;
+ while ( start < symbol.length () && symbol[start] == '@')
+ start++;
+ size_t end = symbol.length () - 1;
+ while ( end > 0 && isdigit ( symbol[end] ) )
+ end--;
+ if ( end > 0 and symbol[end] == '@' )
+ end--;
+ if ( end > 0 )
+ return symbol.substr ( start, end - start + 1 );
+ else
+ return "";
+}
--- branches/xmlbuildsystem/reactos/tools/rbuild/testsupportcode.cpp 2005-05-15 11:46:20 UTC (rev 15303)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/testsupportcode.cpp 2005-05-15 11:58:48 UTC (rev 15304)
@@ -0,0 +1,190 @@
+#include "pch.h"
+#include <assert.h>
+
+#include "rbuild.h"
+
+using std::string;
+using std::vector;
+
+TestSupportCode::TestSupportCode ( const Project& project )
+ : project ( project )
+{
+}
+
+TestSupportCode::~TestSupportCode ()
+{
+}
+
+bool
+TestSupportCode::IsTestModule ( const Module& module )
+{
+ return module.type == Test;
+}
+
+void
+TestSupportCode::GenerateTestSupportCode ( bool verbose )
+{
+ for ( size_t i = 0; i < project.modules.size (); i++ )
+ {
+ if ( IsTestModule ( *project.modules[i] ) )
+ {
+ GenerateTestSupportCodeForModule ( *project.modules[i],
+ verbose );
+ }
+ }
+}
+
+void
+TestSupportCode::GenerateTestSupportCodeForModule ( Module& module,
+ bool verbose )
+{
+ if ( verbose )
+ {
+ printf ( "\nGenerating test support code for %s",
+ module.name.c_str () );
+ }
+
+ WriteHooksFile ( module );
+ WriteStubsFile ( module );
+}
+
+string
+TestSupportCode::GetHooksFilename ( Module& module )
+{
+ return NormalizeFilename ( Environment::GetIntermediatePath () + SSEP + module.GetBasePath () + SSEP + "_hooks.c" );
+}
+
+char*
+TestSupportCode::WriteStubbedSymbolToHooksFile ( char* buffer,
+ const StubbedComponent& component,
+ const StubbedSymbol& symbol )
+{
+ buffer = buffer + sprintf ( buffer,
+ " {\"%s\", \"%s\", NULL, NULL, NULL},\n",
+ component.name.c_str (),
+ symbol.strippedName.c_str () );
+ return buffer;
+}
+
+char*
+TestSupportCode::WriteStubbedComponentToHooksFile ( char* buffer,
+ const StubbedComponent& component )
+{
+ for ( size_t i = 0; i < component.symbols.size () ; i++ )
+ buffer = WriteStubbedSymbolToHooksFile ( buffer,
+ component,
+ *component.symbols[i] );
+ return buffer;
+}
+
+void
+TestSupportCode::WriteHooksFile ( Module& module )
+{
+ char* buf;
+ char* s;
+
+ buf = (char*) malloc ( 50*1024 );
+ if ( buf == NULL )
+ throw OutOfMemoryException ();
+
+ s = buf;
+ s = s + sprintf ( s, "/* This file is automatically generated. */\n" );
+ s = s + sprintf ( s, "#include <windows.h>\n" );
+ s = s + sprintf ( s, "#include \"regtests.h\"\n" );
+ s = s + sprintf ( s, "\n" );
+ s = s + sprintf ( s, "API_DESCRIPTION ExternalDependencies[] =\n" );
+ s = s + sprintf ( s, "{\n" );
+
+ int symbolCount = 0;
+ for ( size_t i = 0; i < module.stubbedComponents.size () ; i++ )
+ {
+ s = WriteStubbedComponentToHooksFile ( s,
+ *module.stubbedComponents[i] );
+ symbolCount += module.stubbedComponents[i]->symbols.size ();
+ }
+
+ s = s + sprintf ( s, "};\n" );
+ s = s + sprintf ( s, "\n" );
+ s = s + sprintf ( s, "#define ExternalDependencyCount %d\n", symbolCount );
+ s = s + sprintf ( s, "ULONG MaxExternalDependency = ExternalDependencyCount - 1;\n" );
+ s = s + sprintf ( s, "\n" );
+
+ FileSupportCode::WriteIfChanged ( buf, GetHooksFilename ( module ) );
+
+ free ( buf );
+}
+
+string
+TestSupportCode::GetStubsFilename ( Module& module )
+{
+ return NormalizeFilename ( Environment::GetIntermediatePath () + SSEP + module.GetBasePath () + SSEP + "_stubs.S" );
+}
+
+char*
+TestSupportCode::WriteStubbedSymbolToStubsFile ( char* buffer,
+ const StubbedComponent& component,
+ const StubbedSymbol& symbol,
+ int stubIndex )
+{
+ buffer = buffer + sprintf ( buffer,
+ ".globl _%s\n",
+ symbol.symbol.c_str () );
+ buffer = buffer + sprintf ( buffer,
+ "_%s:\n",
+ symbol.symbol.c_str () );
+ buffer = buffer + sprintf ( buffer,
+ " pushl $%d\n",
+ stubIndex );
+ buffer = buffer + sprintf ( buffer,
+ " jmp passthrough\n" );
+ buffer = buffer + sprintf ( buffer, "\n" );
+ return buffer;
+}
+
+char*
+TestSupportCode::WriteStubbedComponentToStubsFile ( char* buffer,
+ const StubbedComponent& component,
+ int* stubIndex )
+{
+ for ( size_t i = 0; i < component.symbols.size () ; i++ )
+ buffer = WriteStubbedSymbolToStubsFile ( buffer,
+ component,
+ *component.symbols[i],
+ (*stubIndex)++ );
+ return buffer;
+}
+
+void
+TestSupportCode::WriteStubsFile ( Module& module )
+{
+ char* buf;
+ char* s;
+
+ buf = (char*) malloc ( 50*1024 );
+ if ( buf == NULL )
+ throw OutOfMemoryException ();
+
+ s = buf;
+ s = s + sprintf ( s, "/* This file is automatically generated. */\n" );
+ s = s + sprintf ( s, "passthrough:\n" );
+ s = s + sprintf ( s, " call _FrameworkGetHook@4\n" );
+ s = s + sprintf ( s, " test %%eax, %%eax\n" );
+ s = s + sprintf ( s, " je .return\n" );
+ s = s + sprintf ( s, " jmp *%%eax\n" );
+ s = s + sprintf ( s, ".return:\n" );
+ s = s + sprintf ( s, " /* This will most likely corrupt the stack */\n" );
+ s = s + sprintf ( s, " ret\n" );
+ s = s + sprintf ( s, "\n" );
+
+ int stubIndex = 0;
+ for ( size_t i = 0; i < module.stubbedComponents.size () ; i++ )
+ {
+ s = WriteStubbedComponentToStubsFile ( s,
+ *module.stubbedComponents[i],
+ &stubIndex );
+ }
+
+ FileSupportCode::WriteIfChanged ( buf, GetStubsFilename ( module ) );
+
+ free ( buf );
+}
Property changes on: branches/xmlbuildsystem/reactos/tools/rbuild/testsupportcode.cpp
___________________________________________________________________
Name: svn:eol-style
+ native
--- branches/xmlbuildsystem/reactos/tools/rbuild/wineresource.cpp 2005-05-15 11:46:20 UTC (rev 15303)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/wineresource.cpp 2005-05-15 11:58:48 UTC (rev 15304)
@@ -82,7 +82,7 @@
if ( verbose )
{
- printf ( "Unpacking resources for %s",
+ printf ( "\nUnpacking resources for %s",
module.name.c_str () );
}