Test module type support

svn path=/branches/xmlbuildsystem/; revision=14241
This commit is contained in:
Casper Hornstrup 2005-03-20 21:58:30 +00:00
parent ecf13d206b
commit 297bfe4644
28 changed files with 546 additions and 73 deletions

View file

@ -45,47 +45,49 @@ else
endif
endif
ifeq ($(HALFVERBOSEECHO),yes)
ECHO_MKDIR =@echo [MKDIR] $@
ECHO_BUILDNO=@echo [BUILDNO] $@
ECHO_INVOKE =@echo [INVOKE] $<
ECHO_PCH =@echo [PCH] $@
ECHO_CC =@echo [CC] $<
ECHO_GAS =@echo [GAS] $<
ECHO_NASM =@echo [NASM] $<
ECHO_AR =@echo [AR] $@
ECHO_WINEBLD=@echo [WINEBLD] $@
ECHO_WRC =@echo [WRC] $@
ECHO_BIN2RES=@echo [BIN2RES] $<
ECHO_DLLTOOL=@echo [DLLTOOL] $@
ECHO_LD =@echo [LD] $@
ECHO_RBUILD =@echo [RBUILD] $@
ECHO_RSYM =@echo [RSYM] $@
ECHO_WMC =@echo [WMC] $@
ECHO_NCI =@echo [NCI] $@
ECHO_CABMAN =@echo [CABMAN] $<
ECHO_CDMAKE =@echo [CDMAKE] $@
ECHO_TEST =@echo [TEST] $@
ECHO_MKDIR =@echo [MKDIR] $@
ECHO_BUILDNO =@echo [BUILDNO] $@
ECHO_INVOKE =@echo [INVOKE] $<
ECHO_PCH =@echo [PCH] $@
ECHO_CC =@echo [CC] $<
ECHO_GAS =@echo [GAS] $<
ECHO_NASM =@echo [NASM] $<
ECHO_AR =@echo [AR] $@
ECHO_WINEBLD =@echo [WINEBLD] $@
ECHO_WRC =@echo [WRC] $@
ECHO_BIN2RES =@echo [BIN2RES] $<
ECHO_DLLTOOL =@echo [DLLTOOL] $@
ECHO_LD =@echo [LD] $@
ECHO_RBUILD =@echo [RBUILD] $@
ECHO_RSYM =@echo [RSYM] $@
ECHO_WMC =@echo [WMC] $@
ECHO_NCI =@echo [NCI] $@
ECHO_CABMAN =@echo [CABMAN] $<
ECHO_CDMAKE =@echo [CDMAKE] $@
ECHO_REGTESTS=@echo [REGTESTS] $@
ECHO_TEST =@echo [TEST] $@
else
ECHO_MKDIR =
ECHO_BUILDNO=
ECHO_INVOKE =
ECHO_PCH =
ECHO_CC =
ECHO_GAS =
ECHO_NASM =
ECHO_AR =
ECHO_WINEBLD=
ECHO_WRC =
ECHO_BIN2RES=
ECHO_DLLTOOL=
ECHO_LD =
ECHO_RBUILD =
ECHO_RSYM =
ECHO_WMC =
ECHO_NCI =
ECHO_CABMAN =
ECHO_CDMAKE =
ECHO_TEST =
ECHO_MKDIR =
ECHO_BUILDNO =
ECHO_INVOKE =
ECHO_PCH =
ECHO_CC =
ECHO_GAS =
ECHO_NASM =
ECHO_AR =
ECHO_WINEBLD =
ECHO_WRC =
ECHO_BIN2RES =
ECHO_DLLTOOL =
ECHO_LD =
ECHO_RBUILD =
ECHO_RSYM =
ECHO_WMC =
ECHO_NCI =
ECHO_CABMAN =
ECHO_CDMAKE =
ECHO_REGTESTS=
ECHO_TEST =
endif

View file

@ -47,6 +47,9 @@
<directory name="ntoskrnl">
<xi:include href="ntoskrnl/ntoskrnl.xml" />
</directory>
<directory name="regtests">
<xi:include href="regtests/directory.xml" />
</directory>
<directory name="services">
<xi:include href="services/directory.xml" />
</directory>

View file

@ -1,3 +1,4 @@
<property name="BASEADDRESS_REGTESTS" value="0x07000000" />
<property name="BASEADDRESS_NOTIFYHOOK" value="0x08000000" />
<property name="BASEADDRESS_DEVENUM" value="0x35680000" />
<property name="BASEADDRESS_DINPUT" value="0x5F580000" />

View file

@ -1,16 +1,9 @@
<module name="kernel32" type="win32dll" baseaddress="${BASEADDRESS_KERNEL32}">
<importlibrary definition="kernel32.def" />
<include base="kernel32">.</include>
<include base="kernel32">include</include>
<module name="kernel32_base" type="objectlibrary">
<include base="kernel32_base">.</include>
<include base="kernel32_base">include</include>
<define name="_DISABLE_TIDENTS" />
<define name="_SEH_NO_NATIVE_NLG" />
<define name="WINVER">0x0500</define>
<library>pseh</library>
<library>rosrtl</library>
<library>ntdll</library>
<linkerflag>-lgcc</linkerflag>
<linkerflag>-nostartfiles</linkerflag>
<linkerflag>-nostdlib</linkerflag>
<pch>k32.h</pch>
<directory name="debug">
<file>break.c</file>
@ -109,6 +102,25 @@
<file>thread.c</file>
<file>tls.c</file>
</directory>
<file>kernel32.rc</file>
</module>
<module name="kernel32" type="win32dll" baseaddress="${BASEADDRESS_KERNEL32}">
<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>
-->

View file

@ -0,0 +1,19 @@
<module name="kernel32_test" type="test">
<include base="rtshared">.</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>
<library>rtshared</library>
<linkerflag>-lgcc</linkerflag>
<linkerflag>-nostartfiles</linkerflag>
<linkerflag>-nostdlib</linkerflag>
<directory name="tests">
<file>CreateFile.c</file>
</directory>
<file>setup.c</file>
<xi:include href="stubs.xml" />
</module>

View file

@ -0,0 +1,136 @@
<component name="ntdll.dll">
<symbol>CsrCaptureParameterBuffer@16</symbol>
<symbol>CsrClientCallServer@16</symbol>
<symbol>CsrClientConnectToServer@0</symbol>
<symbol>CsrReleaseParameterBuffer@4</symbol>
<symbol>DbgUiContinue@8</symbol>
<symbol newname="RtlAllocateHeap">HeapAlloc@12</symbol>
<symbol newname="RtlFreeHeap">HeapFree@12</symbol>
<symbol>LdrAccessResource@16</symbol>
<symbol>LdrDisableThreadCalloutsForDll@4</symbol>
<symbol>LdrDisableThreadCalloutsForDll@4</symbol>
<symbol>LdrFindResource_U@16</symbol>
<symbol>LdrLoadDll@16</symbol>
<symbol>LdrShutdownProcess@0</symbol>
<symbol>LdrShutdownThread@0</symbol>
<symbol>LdrUnloadDll@4</symbol>
<symbol>NtAllocateVirtualMemory@24</symbol>
<symbol>NtClose@4</symbol>
<symbol>NtCreateDirectoryObject@12</symbol>
<symbol>NtCreateEvent@20</symbol>
<symbol>NtCreateFile@44</symbol>
<symbol>NtCreateKey@28</symbol>
<symbol>NtCreateProcess@32</symbol>
<symbol>NtCreateSection@28</symbol>
<symbol>NtDelayExecution@8</symbol>
<symbol>NtDeviceIoControlFile@40</symbol>
<symbol>_imp__NtDuplicateObject@28</symbol>
<symbol>NtFlushBuffersFile@8</symbol>
<symbol>NtFlushInstructionCache@12</symbol>
<symbol>NtFlushVirtualMemory@16</symbol>
<symbol>NtFreeVirtualMemory@16</symbol>
<symbol>NtFsControlFile@40</symbol>
<symbol>NtGetContextThread@8</symbol>
<symbol>NtLockVirtualMemory@16</symbol>
<symbol>NtOpenDirectoryObject@12</symbol>
<symbol>NtOpenEvent@12</symbol>
<symbol>NtOpenFile@24</symbol>
<symbol>NtOpenKey@12</symbol>
<symbol>NtOpenProcess@16</symbol>
<symbol>NtOpenSection@12</symbol>
<symbol>NtOpenThread@16</symbol>
<symbol>NtProtectVirtualMemory@20</symbol>
<symbol>NtPulseEvent@8</symbol>
<symbol>NtQueryDefaultLocale@8</symbol>
<symbol>NtQueryDefaultUILanguage@4</symbol>
<symbol>NtQueryDirectoryFile@44</symbol>
<symbol>NtQueryInformationFile@20</symbol>
<symbol>_imp__NtQueryInformationProcess@20</symbol>
<symbol>NtQueryInformationThread@20</symbol>
<symbol>NtQueryObject@20</symbol>
<symbol>NtQuerySystemInformation@16</symbol>
<symbol>NtQuerySystemTime@4</symbol>
<symbol>NtQueryValueKey@24</symbol>
<symbol>NtQueryVirtualMemory@24</symbol>
<symbol>NtQueryVolumeInformationFile@20</symbol>
<symbol>NtReadFile@36</symbol>
<symbol>NtReadVirtualMemory@20</symbol>
<symbol>NtResetEvent@8</symbol>
<symbol>NtResumeThread@8</symbol>
<symbol>NtSetContextThread@8</symbol>
<symbol>NtSetEvent@8</symbol>
<symbol>NtSetInformationFile@20</symbol>
<symbol>NtSetInformationObject@16</symbol>
<symbol>_imp__NtSetInformationProcess@16</symbol>
<symbol>NtSetInformationThread@16</symbol>
<symbol>NtSetSystemInformation@12</symbol>
<symbol>NtSetSystemTime@8</symbol>
<symbol>NtSignalAndWaitForSingleObject@16</symbol>
<symbol>NtSuspendThread@8</symbol>
<symbol>NtTerminateThread@8</symbol>
<symbol>NtUnlockVirtualMemory@16</symbol>
<symbol>NtUnmapViewOfSection@8</symbol>
<symbol>NtWaitForMultipleObjects@20</symbol>
<symbol>NtWaitForSingleObject@12</symbol>
<symbol>NtWriteFile@36</symbol>
<symbol>NtWriteVirtualMemory@20</symbol>
<symbol>NtYieldExecution@0</symbol>
<symbol>RtlAcquirePebLock@0</symbol>
<symbol>RtlAnsiStringToUnicodeSize@4</symbol>
<symbol>_imp__RtlBaseProcessStartRoutine</symbol>
<symbol>RtlCompactHeap@8</symbol>
<symbol>RtlCopyUnicodeString@8</symbol>
<symbol>RtlCreateHeap@24</symbol>
<symbol>RtlCreateProcessParameters@40</symbol>
<symbol>RtlCreateUnicodeString@8</symbol>
<symbol>RtlCreateUnicodeStringFromAsciiz@8</symbol>
<symbol>RtlDeleteCriticalSection@4</symbol>
<symbol>RtlDestroyHeap@4</symbol>
<symbol>RtlDestroyProcessParameters@4</symbol>
<symbol>RtlDoesFileExists_U@4</symbol>
<symbol>RtlDosPathNameToNtPathName_U@16</symbol>
<symbol>RtlDosSearchPath_U@24</symbol>
<symbol>RtlEnterCriticalSection@4</symbol>
<symbol>RtlExpandEnvironmentStrings_U@16</symbol>
<symbol>RtlFreeHeap@12</symbol>
<symbol>RtlGetCurrentDirectory_U@8</symbol>
<symbol>RtlGetFullPathName_U@16</symbol>
<symbol>RtlGetProcessHeaps@8</symbol>
<symbol>RtlImageNtHeader@4</symbol>
<symbol>RtlInitCodePageTable@8</symbol>
<symbol>RtlInitializeCriticalSection@4</symbol>
<symbol>RtlInitUnicodeString@8</symbol>
<symbol>RtlIntegerToChar@16</symbol>
<symbol>RtlIntegerToUnicodeString@12</symbol>
<symbol>RtlIsNameLegalDOS8Dot3@12</symbol>
<symbol>RtlLeaveCriticalSection@4</symbol>
<symbol>RtlLockHeap@4</symbol>
<symbol>RtlNtStatusToDosError@4</symbol>
<symbol>RtlOemStringToUnicodeSize@4</symbol>
<symbol>RtlOemStringToUnicodeString@12</symbol>
<symbol>RtlOpenCurrentUser@8</symbol>
<symbol>RtlQueryEnvironmentVariable_U@12</symbol>
<symbol>RtlRaiseException@4</symbol>
<symbol>RtlReAllocateHeap@16</symbol>
<symbol>RtlReleasePebLock@0</symbol>
<symbol>RtlRosCreateUserThreadVa</symbol>
<symbol>RtlRosExitUserThread@4</symbol>
<symbol>RtlSetCurrentDirectory_U@4</symbol>
<symbol>RtlSetEnvironmentVariable@12</symbol>
<symbol>RtlSetTimeZoneInformation@4</symbol>
<symbol>RtlTimeFieldsToTime@8</symbol>
<symbol>RtlTimeToTimeFields@8</symbol>
<symbol>RtlUnicodeStringToAnsiSize@4</symbol>
<symbol>RtlUnicodeStringToAnsiString@12</symbol>
<symbol>RtlUnicodeStringToInteger@12</symbol>
<symbol>RtlUnicodeStringToOemString@12</symbol>
<symbol>RtlUnicodeToOemN@20</symbol>
<symbol>RtlUnlockHeap@4</symbol>
<symbol>RtlValidateHeap@12</symbol>
<symbol>ZwMapViewOfSection@40</symbol>
<symbol>ZwOpenSection@12</symbol>
<symbol>ZwQuerySection@20</symbol>
<symbol>ZwQuerySystemInformation@16</symbol>
<symbol>ZwReadFile@36</symbol>
<symbol>ZwTerminateProcess@8</symbol>
</component>

View file

@ -0,0 +1,6 @@
<directory name="regtests">
<xi:include href="regtests/regtests.xml" />
</directory>
<directory name="shared">
<xi:include href="shared/rtshared.xml" />
</directory>

View file

@ -0,0 +1,6 @@
<module name="regtests" type="win32dll" baseaddress="${BASEADDRESS_REGTESTS}">
<importlibrary definition="regtests.def" />
<include base="regtests">.</include>
<library>kernel32</library>
<file>regtests.c</file>
</module>

View file

@ -0,0 +1,4 @@
<module name="rtshared" type="staticlibrary">
<include base="rtshared">.</include>
<file>regtests.c</file>
</module>

View file

@ -176,6 +176,7 @@ MingwBackend::GenerateGlobalVariables () const
fprintf ( fMakefile, "bin2res = " TOOL_PREFIX "bin2res" SSEP "bin2res" EXEPOSTFIX "\n" );
fprintf ( fMakefile, "cabman = " TOOL_PREFIX "cabman" SSEP "cabman" EXEPOSTFIX "\n" );
fprintf ( fMakefile, "cdmake = " TOOL_PREFIX "cdmake" SSEP "cdmake" EXEPOSTFIX "\n" );
fprintf ( fMakefile, "regtests = " TOOL_PREFIX "regtests" EXEPOSTFIX "\n" );
fprintf ( fMakefile, "rsym = " TOOL_PREFIX "rsym" EXEPOSTFIX "\n" );
fprintf ( fMakefile, "wrc = " TOOL_PREFIX "wrc" SSEP "wrc" EXEPOSTFIX "\n" );
fprintf ( fMakefile, "\n" );

View file

@ -152,6 +152,9 @@ MingwModuleHandler::InstanciateHandler ( const string& location,
case Iso:
handler = new MingwIsoModuleHandler ( backend );
break;
case Test:
handler = new MingwTestModuleHandler ( backend );
break;
}
return handler;
}
@ -1226,10 +1229,10 @@ MingwModuleHandler::GenerateMacrosAndTargets (
clean_files );
CLEAN_FILE ( ar_target );
string tgt = FixupTargetFilename(module.GetPath());
if ( tgt != ar_target )
string target = FixupTargetFilename ( module.GetPath () );
if ( target != ar_target )
{
CLEAN_FILE ( tgt );
CLEAN_FILE ( target );
}
}
@ -1882,8 +1885,7 @@ MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ( const Module& module,
{
GenerateMacrosAndTargets ( module, NULL, NULL, clean_files );
string dependencies =
objectsMacro + " " + linkDepsMacro;
string dependencies = objectsMacro + " " + linkDepsMacro;
string linker;
if ( module.cplusplus )
@ -2302,3 +2304,63 @@ MingwIsoModuleHandler::GenerateIsoModuleTarget ( const Module& module, string_li
fprintf ( fMakefile,
"\n" );
}
MingwTestModuleHandler::MingwTestModuleHandler ( MingwBackend* backend )
: MingwModuleHandler ( Test,
backend )
{
}
void
MingwTestModuleHandler::Process ( const Module& module, string_list& clean_files )
{
GeneratePreconditionDependencies ( module );
GenerateTestModuleTarget ( module, clean_files );
GenerateInvocations ( module );
}
void
MingwTestModuleHandler::GenerateTestModuleTarget ( const Module& module, string_list& clean_files )
{
static string ros_junk ( "$(ROS_TEMPORARY)" );
string target ( FixupTargetFilename ( module.GetPath () ) );
string workingDirectory = GetWorkingDirectory ( );
string objectsMacro = GetObjectsMacro ( module );
string linkDepsMacro = GetLinkingDependenciesMacro ( module );
string libsMacro = GetLibsMacro ( module );
GenerateImportLibraryTargetIfNeeded ( module, clean_files );
if ( module.non_if_data.files.size () > 0 )
{
GenerateMacrosAndTargets ( module, NULL, NULL, clean_files );
string dependencies = objectsMacro + " " + linkDepsMacro;
string linker;
if ( module.cplusplus )
linker = "${gpp}";
else
linker = "${gcc}";
string linkerParameters = ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
module.entrypoint.c_str (),
module.baseaddress.c_str () );
GenerateLinkerCommand ( module,
target,
dependencies,
linker,
linkerParameters,
objectsMacro,
libsMacro,
clean_files );
}
else
{
fprintf ( fMakefile, ".PHONY: %s\n\n",
target.c_str ());
fprintf ( fMakefile, "%s:\n\n",
target.c_str ());
}
}

View file

@ -336,4 +336,14 @@ private:
const Module& module );
};
class MingwTestModuleHandler : public MingwModuleHandler
{
public:
MingwTestModuleHandler ( MingwBackend* backend );
virtual HostType DefaultHost() { return HostFalse; }
virtual void Process ( const Module& module, string_list& clean_files );
private:
void GenerateTestModuleTarget ( const Module& module, string_list& clean_files );
};
#endif /* MINGW_MODULEHANDLER_H */

View file

@ -39,6 +39,7 @@ Bootstrap::IsSupportedModuleType ( ModuleType type )
case StaticLibrary:
case ObjectLibrary:
case Iso:
case Test:
return false;
}
throw InvalidOperationException ( __FILE__,

View file

@ -197,6 +197,8 @@ Module::~Module ()
delete compilerFlags[i];
for ( i = 0; i < linkerFlags.size(); i++ )
delete linkerFlags[i];
for ( i = 0; i < stubbedComponents.size(); i++ )
delete stubbedComponents[i];
if ( pch )
delete pch;
}
@ -215,6 +217,8 @@ Module::ProcessXML()
compilerFlags[i]->ProcessXML();
for ( i = 0; i < linkerFlags.size(); i++ )
linkerFlags[i]->ProcessXML();
for ( i = 0; i < stubbedComponents.size(); i++ )
stubbedComponents[i]->ProcessXML();
non_if_data.ProcessXML();
if ( pch )
pch->ProcessXML();
@ -342,6 +346,11 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
linkerFlags.push_back ( new LinkerFlag ( project, this, e ) );
subs_invalid = true;
}
else if ( e.name == "component" )
{
stubbedComponents.push_back ( new StubbedComponent ( this, e ) );
subs_invalid = false;
}
else if ( e.name == "property" )
{
throw InvalidBuildFileException (
@ -407,6 +416,8 @@ Module::GetModuleType ( const string& location, const XMLAttribute& attribute )
return BootSector;
if ( attribute.value == "iso" )
return Iso;
if ( attribute.value == "test" )
return Test;
throw InvalidAttributeValueException ( location,
attribute.name,
attribute.value );
@ -439,6 +450,8 @@ Module::GetDefaultModuleExtension () const
return ".o";
case Iso:
return ".iso";
case Test:
return ".exe";
}
throw InvalidOperationException ( __FILE__,
__LINE__ );
@ -460,6 +473,7 @@ Module::GetDefaultModuleEntrypoint () const
case Win32DLL:
return "_DllMain@12";
case Win32CUI:
case Test:
return "_mainCRTStartup";
case Win32GUI:
return "_WinMainCRTStartup";
@ -493,6 +507,7 @@ Module::GetDefaultModuleBaseaddress () const
case Win32DLL:
return "0x10000";
case Win32CUI:
case Test:
return "0x00400000";
case Win32GUI:
return "0x00400000";

View file

@ -57,6 +57,8 @@ class AutomaticDependency;
class Bootstrap;
class CDFile;
class PchFile;
class StubbedComponent;
class StubbedSymbol;
class SourceFileTest;
@ -130,7 +132,8 @@ enum ModuleType
Win32GUI,
BootLoader,
BootSector,
Iso
Iso,
Test
};
enum HostType
@ -159,6 +162,7 @@ public:
std::vector<Dependency*> dependencies;
std::vector<CompilerFlag*> compilerFlags;
std::vector<LinkerFlag*> linkerFlags;
std::vector<StubbedComponent*> stubbedComponents;
PchFile* pch;
bool cplusplus;
std::string prefix;
@ -526,6 +530,35 @@ public:
void ProcessXML();
};
class StubbedComponent
{
public:
const Module* module;
const XMLElement& node;
std::string name;
std::vector<StubbedSymbol*> symbols;
StubbedComponent ( const Module* module_,
const XMLElement& stubbedComponentNode );
~StubbedComponent ();
void ProcessXML ();
void ProcessXMLSubElement ( const XMLElement& e );
};
class StubbedSymbol
{
public:
const XMLElement& node;
std::string symbol;
std::string newname;
StubbedSymbol ( const XMLElement& stubbedSymbolNode );
~StubbedSymbol ();
void ProcessXML();
};
extern std::string
FixSeparator ( const std::string& s );

View file

@ -39,6 +39,7 @@ RBUILD_BASE_SOURCES = \
module.cpp \
project.cpp \
ssprintf.cpp \
stubbedcomponent.cpp \
XML.cpp
RBUILD_COMMON_SOURCES = \
@ -62,6 +63,7 @@ RBUILD_OBJECTS = \
$(RBUILD_SPECIAL_OBJECTS)
RBUILD_TESTS = \
tests$(SEP)cdfiletest.cpp \
tests$(SEP)definetest.cpp \
tests$(SEP)functiontest.cpp \
tests$(SEP)iftest.cpp \
@ -71,7 +73,7 @@ RBUILD_TESTS = \
tests$(SEP)moduletest.cpp \
tests$(SEP)projecttest.cpp \
tests$(SEP)sourcefiletest.cpp \
tests$(SEP)cdfiletest.cpp
tests$(SEP)symboltest.cpp
RBUILD_TEST_SPECIAL_SOURCES = \
$(addprefix $(RBUILD_BASE)$(SEP), $(RBUILD_TESTS)) \

View file

@ -123,7 +123,7 @@ Value:
None.
Elements:
bootstrap, define, dependency, directory, file, if, importlibrary, include, invoke, library, property.
bootstrap, component, define, dependency, directory, file, if, importlibrary, include, invoke, library, property.
Module types
@ -137,10 +137,12 @@ The module type determines the actions that is to be carried out to process the
kernelmodedriver - Builds a kernel-mode driver. Default extension is .sys. Default entrypoint is _DriverEntry@8.
nativedll - Builds a native DLL. Default extension is .dll. Default entrypoint is _DllMainCRTStartup@12.
win32dll - Builds a Win32 DLL. Default extension is .dll. Default entrypoint is _DllMain@12.
win32cui - Builds a Win32 console executable. Default extension is .exe. Default entrypoint is _mainCRTStartup. The baseaddress module attribute is not applicable for this module type.
win32gui - Builds a Win32 GUI executable. Default extension is .exe. Default entrypoint is _WinMainCRTStartup. The baseaddress module attribute is not applicable for this module type.
bootloader - Builds a bootloader. The entrypoint, baseaddress, and mangledsymbols module attributes are not applicable for this module type.
bootsector - Builds one or more bootsector binaries. The entrypoint, baseaddress, and mangledsymbols module attributes are not applicable for this module type.
iso - Builds a bootable CD. The entrypoint, baseaddress, and mangledsymbols module attributes are not applicable for this module type.
test - Builds a testsuite. Default extension is .exe. Default entrypoint is _mainCRTStartup. The baseaddress module attribute is not applicable for this module type.
Bootstrap element
@ -179,6 +181,42 @@ Elements:
None.
Component element
-----------------
A component element specifies that imports from a library are to be stubbed so tests can be run without actually calling the functions in the library. This element can only be used for modules of type test.
Syntax:
<component name="ntdll.dll">
...
</component>
Attributes:
name - Name of library.
Value:
None.
Elements:
Symbol.
Symbol element
--------------
A symbol element specifies an imported function from a library that is to be stubbed so tests can be run without actually calling the function in the library.
Syntax:
<symbol newname="RtlAllocateHeap">HeapAlloc@12</symbol>
Attributes:
newname - New name of symbol. This attribute is optional.
Value:
Name of symbol.
Elements:
None.
Define element
--------------
A define element specifies the name and (optionally) value of a define for the C/C++ compiler and resource compiler.

View file

@ -0,0 +1,80 @@
#include "pch.h"
#include <assert.h>
#include "rbuild.h"
using std::string;
using std::vector;
StubbedComponent::StubbedComponent ( const Module* module_,
const XMLElement& stubbedComponentNode )
: module(module_),
node(stubbedComponentNode)
{
const XMLAttribute* att = node.GetAttribute ( "name", true );
assert ( att );
name = att->value;
}
StubbedComponent::~StubbedComponent ()
{
for ( size_t i = 0; i < symbols.size(); i++ )
delete symbols[i];
}
void
StubbedComponent::ProcessXML ()
{
size_t i;
for ( i = 0; i < node.subElements.size (); i++ )
ProcessXMLSubElement ( *node.subElements[i] );
for ( i = 0; i < symbols.size (); i++ )
symbols[i]->ProcessXML ();
}
void
StubbedComponent::ProcessXMLSubElement ( const XMLElement& e )
{
bool subs_invalid = false;
if ( e.name == "symbol" )
{
symbols.push_back ( new StubbedSymbol ( e ) );
subs_invalid = false;
}
if ( subs_invalid && e.subElements.size () > 0 )
throw InvalidBuildFileException (
e.location,
"<%s> cannot have sub-elements",
e.name.c_str() );
for ( size_t i = 0; i < e.subElements.size (); i++ )
ProcessXMLSubElement ( *e.subElements[i] );
}
StubbedSymbol::StubbedSymbol ( const XMLElement& stubbedSymbolNode )
: node(stubbedSymbolNode)
{
}
StubbedSymbol::~StubbedSymbol ()
{
}
void
StubbedSymbol::ProcessXML ()
{
if ( node.value.size () == 0 )
{
throw InvalidBuildFileException (
node.location,
"<symbol> is empty." );
}
symbol = node.value;
const XMLAttribute* att = node.GetAttribute ( "newname", false );
if ( att != NULL )
newname = att->value;
else
newname = symbol;
}

View file

@ -126,4 +126,11 @@ public:
void Run ();
};
class SymbolTest : public BaseTest
{
public:
void Run ();
};
#endif /* __TEST_H */

View file

@ -179,6 +179,7 @@ private:
tests.push_back(new FunctionTest());
tests.push_back(new SourceFileTest());
tests.push_back(new CDFileTest());
tests.push_back(new SymbolTest());
}
};

View file

@ -0,0 +1,9 @@
<?xml version="1.0" ?>
<project name="Project" makefile="Makefile">
<module name="module1" type="test">
<component name="ntdll.dll">
<symbol newname="RtlAllocateHeap">HeapAlloc@12</symbol>
<symbol>LdrAccessResource@16</symbol>
</component>
</module>
</project>

View file

@ -5,5 +5,5 @@ using std::string;
void FunctionTest::Run ()
{
string fixedupFilename = FixupTargetFilename ( "." SSEP "dir1" SSEP "dir2" SSEP ".." SSEP "filename.txt" );
ARE_EQUAL ( "$(ROS_INTERMEDIATE)." SSEP "dir1" SSEP "filename.txt", fixedupFilename );
ARE_EQUAL ( "$(INTERMEDIATE)dir1" SSEP "filename.txt", fixedupFilename );
}

View file

@ -17,9 +17,9 @@ void IfTest::Run()
ARE_EQUAL ( 1, if1.data.files.size () );
File& file1 = *if1.data.files[0];
ARE_EQUAL( "." SSEP "file1.c", file1.name );
ARE_EQUAL( SSEP "file1.c", file1.name );
ARE_EQUAL ( 1, module1.non_if_data.files.size () );
File& file2 = *module1.non_if_data.files[0];
ARE_EQUAL( "." SSEP "file2.c", file2.name );
ARE_EQUAL( SSEP "file2.c", file2.name );
}

View file

@ -20,5 +20,5 @@ void IncludeTest::Run()
ARE_EQUAL(1, module2.non_if_data.includes.size());
Include& include3 = *module2.non_if_data.includes[0];
ARE_EQUAL(FixSeparator("./dir1/include3"), include3.directory);
ARE_EQUAL(FixSeparator("dir1/include3"), include3.directory);
}

View file

@ -15,5 +15,5 @@ void InvokeTest::Run()
ARE_EQUAL(1, invoke1.output.size());
InvokeFile& file1 = *invoke1.output[0];
ARE_EQUAL(FixSeparator("./dir1/file1.c"), file1.name);
ARE_EQUAL(FixSeparator("dir1/file1.c"), file1.name);
}

View file

@ -11,16 +11,16 @@ void ModuleTest::Run()
Module& module1 = *project.modules[0];
IS_TRUE(module1.type == BuildTool);
ARE_EQUAL(2, module1.non_if_data.files.size());
ARE_EQUAL("." SSEP "dir1" SSEP "file1.c", module1.non_if_data.files[0]->name);
ARE_EQUAL("." SSEP "dir1" SSEP "file2.c", module1.non_if_data.files[1]->name);
ARE_EQUAL("dir1" SSEP "file1.c", module1.non_if_data.files[0]->name);
ARE_EQUAL("dir1" SSEP "file2.c", module1.non_if_data.files[1]->name);
ARE_EQUAL(0, module1.non_if_data.libraries.size());
Module& module2 = *project.modules[1];
IS_TRUE(module2.type == KernelModeDLL);
ARE_EQUAL(2, module2.non_if_data.files.size());
ARE_EQUAL("." SSEP "dir2" SSEP "file3.c", module2.non_if_data.files[0]->name);
ARE_EQUAL("." SSEP "dir2" SSEP "file4.c", module2.non_if_data.files[1]->name);
ARE_EQUAL("dir2" SSEP "file3.c", module2.non_if_data.files[0]->name);
ARE_EQUAL("dir2" SSEP "file4.c", module2.non_if_data.files[1]->name);
ARE_EQUAL(1, module2.non_if_data.libraries.size());
Library& library1 = *module2.non_if_data.libraries[0];

View file

@ -38,9 +38,9 @@ SourceFileTest::IncludeTest ()
AutomaticDependency automaticDependency ( project );
automaticDependency.Process ();
ARE_EQUAL( 4, automaticDependency.sourcefile_map.size () );
const SourceFile* include = automaticDependency.RetrieveFromCache ( "." SSEP RBUILD_BASE "tests" SSEP "data" SSEP "sourcefile_include.h" );
const SourceFile* include = automaticDependency.RetrieveFromCache ( RBUILD_BASE "tests" SSEP "data" SSEP "sourcefile_include.h" );
IS_NOT_NULL( include );
const SourceFile* includenext = automaticDependency.RetrieveFromCache ( "." SSEP RBUILD_BASE "tests" SSEP "data" SSEP "sourcefile1" SSEP "sourcefile_includenext.h" );
const SourceFile* includenext = automaticDependency.RetrieveFromCache ( RBUILD_BASE "tests" SSEP "data" SSEP "sourcefile1" SSEP "sourcefile_includenext.h" );
IS_NOT_NULL( includenext );
}
@ -51,9 +51,9 @@ SourceFileTest::FullParseTest ()
AutomaticDependency automaticDependency ( project );
automaticDependency.Process ();
ARE_EQUAL( 5, automaticDependency.sourcefile_map.size () );
const SourceFile* header1 = automaticDependency.RetrieveFromCache ( "." SSEP RBUILD_BASE "tests" SSEP "data" SSEP "sourcefile1_header1.h" );
const SourceFile* header1 = automaticDependency.RetrieveFromCache ( RBUILD_BASE "tests" SSEP "data" SSEP "sourcefile1_header1.h" );
IS_NOT_NULL( header1 );
const SourceFile* recurse = automaticDependency.RetrieveFromCache ( "." SSEP RBUILD_BASE"tests" SSEP "data" SSEP "sourcefile1_recurse.h" );
const SourceFile* recurse = automaticDependency.RetrieveFromCache ( RBUILD_BASE "tests" SSEP "data" SSEP "sourcefile1_recurse.h" );
IS_NOT_NULL( recurse );
IS_TRUE( IsParentOf ( header1,
recurse ) );

View file

@ -0,0 +1,25 @@
#include "test.h"
using std::string;
void SymbolTest::Run()
{
string projectFilename ( RBUILD_BASE "tests/data/symbol.xml" );
Project project ( projectFilename );
ARE_EQUAL ( 1, project.modules.size () );
Module& module1 = *project.modules[0];
ARE_EQUAL ( 1, module1.stubbedComponents.size () );
StubbedComponent& component1 = *module1.stubbedComponents[0];
ARE_EQUAL ( "ntdll.dll", component1.name );
ARE_EQUAL ( 2, component1.symbols.size () );
StubbedSymbol& symbol1 = *component1.symbols[0];
ARE_EQUAL ( "HeapAlloc@12", symbol1.symbol );
ARE_EQUAL ( "RtlAllocateHeap", symbol1.newname );
StubbedSymbol& symbol2 = *component1.symbols[1];
ARE_EQUAL ( "LdrAccessResource@16", symbol2.symbol );
ARE_EQUAL ( "LdrAccessResource@16", symbol2.newname );
}