Test module type support
authorCasper Hornstrup <chorns@users.sourceforge.net>
Sun, 20 Mar 2005 21:58:30 +0000 (21:58 +0000)
committerCasper Hornstrup <chorns@users.sourceforge.net>
Sun, 20 Mar 2005 21:58:30 +0000 (21:58 +0000)
svn path=/branches/xmlbuildsystem/; revision=14241

28 files changed:
reactos/Makefile
reactos/ReactOS.xml
reactos/baseaddress.xml
reactos/lib/kernel32/kernel32.xml
reactos/lib/kernel32/tests/kernel32.xml [new file with mode: 0644]
reactos/lib/kernel32/tests/stubs.xml [new file with mode: 0644]
reactos/regtests/directory.xml [new file with mode: 0644]
reactos/regtests/regtests/regtests.xml [new file with mode: 0644]
reactos/regtests/shared/rtshared.xml [new file with mode: 0644]
reactos/tools/rbuild/backend/mingw/mingw.cpp
reactos/tools/rbuild/backend/mingw/modulehandler.cpp
reactos/tools/rbuild/backend/mingw/modulehandler.h
reactos/tools/rbuild/bootstrap.cpp
reactos/tools/rbuild/module.cpp
reactos/tools/rbuild/rbuild.h
reactos/tools/rbuild/rbuild.mak
reactos/tools/rbuild/rbuild.txt
reactos/tools/rbuild/stubbedcomponent.cpp [new file with mode: 0644]
reactos/tools/rbuild/test.h
reactos/tools/rbuild/tests/alltests.cpp
reactos/tools/rbuild/tests/data/symbol.xml [new file with mode: 0644]
reactos/tools/rbuild/tests/functiontest.cpp
reactos/tools/rbuild/tests/iftest.cpp
reactos/tools/rbuild/tests/includetest.cpp
reactos/tools/rbuild/tests/invoketest.cpp
reactos/tools/rbuild/tests/moduletest.cpp
reactos/tools/rbuild/tests/sourcefiletest.cpp
reactos/tools/rbuild/tests/symboltest.cpp [new file with mode: 0644]

index 4990f96..c94b1ad 100644 (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
 
 
index 80ba92a..284e19b 100644 (file)
@@ -47,6 +47,9 @@
        <directory name="ntoskrnl">\r
                <xi:include href="ntoskrnl/ntoskrnl.xml" />\r
        </directory>\r
+       <directory name="regtests">\r
+               <xi:include href="regtests/directory.xml" />\r
+       </directory>\r
        <directory name="services">\r
                <xi:include href="services/directory.xml" />\r
        </directory>\r
index 66ba16a..56dafd3 100644 (file)
@@ -1,3 +1,4 @@
+<property name="BASEADDRESS_REGTESTS" value="0x07000000" />\r
 <property name="BASEADDRESS_NOTIFYHOOK" value="0x08000000" />\r
 <property name="BASEADDRESS_DEVENUM" value="0x35680000" />\r
 <property name="BASEADDRESS_DINPUT" value="0x5F580000" />\r
index 7cb5069..0d7e5e6 100644 (file)
@@ -1,16 +1,9 @@
-<module name="kernel32" type="win32dll" baseaddress="${BASEADDRESS_KERNEL32}">\r
-       <importlibrary definition="kernel32.def" />\r
-       <include base="kernel32">.</include>\r
-       <include base="kernel32">include</include>\r
+<module name="kernel32_base" type="objectlibrary">\r
+       <include base="kernel32_base">.</include>\r
+       <include base="kernel32_base">include</include>\r
        <define name="_DISABLE_TIDENTS" />\r
        <define name="_SEH_NO_NATIVE_NLG" />\r
        <define name="WINVER">0x0500</define>\r
-       <library>pseh</library>\r
-       <library>rosrtl</library>\r
-       <library>ntdll</library>\r
-       <linkerflag>-lgcc</linkerflag>\r
-       <linkerflag>-nostartfiles</linkerflag>\r
-       <linkerflag>-nostdlib</linkerflag>\r
        <pch>k32.h</pch>\r
        <directory name="debug">\r
                <file>break.c</file>\r
                <file>thread.c</file>\r
                <file>tls.c</file>\r
        </directory>\r
+</module>\r
+<module name="kernel32" type="win32dll" baseaddress="${BASEADDRESS_KERNEL32}">\r
+       <importlibrary definition="kernel32.def" />\r
+       <include base="kernel32">.</include>\r
+       <include base="kernel32">include</include>\r
+       <define name="_DISABLE_TIDENTS" />\r
+       <define name="_SEH_NO_NATIVE_NLG" />\r
+       <define name="WINVER">0x0500</define>\r
+       <library>kernel32_base</library>\r
+       <library>pseh</library>\r
+       <library>rosrtl</library>\r
+       <library>ntdll</library>\r
+       <linkerflag>-lgcc</linkerflag>\r
+       <linkerflag>-nostartfiles</linkerflag>\r
+       <linkerflag>-nostdlib</linkerflag>\r
        <file>kernel32.rc</file>\r
-\r
 </module>\r
+<!--\r
+<directory name="tests">\r
+       <xi:include href="tests/kernel32.xml" />\r
+</directory>\r
+-->\r
diff --git a/reactos/lib/kernel32/tests/kernel32.xml b/reactos/lib/kernel32/tests/kernel32.xml
new file mode 100644 (file)
index 0000000..de5e5e6
--- /dev/null
@@ -0,0 +1,19 @@
+<module name="kernel32_test" type="test">\r
+       <include base="rtshared">.</include>\r
+       <define name="_DISABLE_TIDENTS" />\r
+       <define name="_SEH_NO_NATIVE_NLG" />\r
+       <define name="WINVER">0x0500</define>\r
+       <library>kernel32_base</library>\r
+       <library>pseh</library>\r
+       <library>rosrtl</library>\r
+       <library>ntdll</library>\r
+       <library>rtshared</library>\r
+       <linkerflag>-lgcc</linkerflag>\r
+       <linkerflag>-nostartfiles</linkerflag>\r
+       <linkerflag>-nostdlib</linkerflag>\r
+       <directory name="tests">\r
+               <file>CreateFile.c</file>\r
+       </directory>\r
+       <file>setup.c</file>\r
+       <xi:include href="stubs.xml" />\r
+</module>\r
diff --git a/reactos/lib/kernel32/tests/stubs.xml b/reactos/lib/kernel32/tests/stubs.xml
new file mode 100644 (file)
index 0000000..80b5566
--- /dev/null
@@ -0,0 +1,136 @@
+<component name="ntdll.dll">\r
+       <symbol>CsrCaptureParameterBuffer@16</symbol>\r
+       <symbol>CsrClientCallServer@16</symbol>\r
+       <symbol>CsrClientConnectToServer@0</symbol>\r
+       <symbol>CsrReleaseParameterBuffer@4</symbol>\r
+       <symbol>DbgUiContinue@8</symbol>\r
+       <symbol newname="RtlAllocateHeap">HeapAlloc@12</symbol>\r
+       <symbol newname="RtlFreeHeap">HeapFree@12</symbol>\r
+       <symbol>LdrAccessResource@16</symbol>\r
+       <symbol>LdrDisableThreadCalloutsForDll@4</symbol>\r
+       <symbol>LdrDisableThreadCalloutsForDll@4</symbol>\r
+       <symbol>LdrFindResource_U@16</symbol>\r
+       <symbol>LdrLoadDll@16</symbol>\r
+       <symbol>LdrShutdownProcess@0</symbol>\r
+       <symbol>LdrShutdownThread@0</symbol>\r
+       <symbol>LdrUnloadDll@4</symbol>\r
+       <symbol>NtAllocateVirtualMemory@24</symbol>\r
+       <symbol>NtClose@4</symbol>\r
+       <symbol>NtCreateDirectoryObject@12</symbol>\r
+       <symbol>NtCreateEvent@20</symbol>\r
+       <symbol>NtCreateFile@44</symbol>\r
+       <symbol>NtCreateKey@28</symbol>\r
+       <symbol>NtCreateProcess@32</symbol>\r
+       <symbol>NtCreateSection@28</symbol>\r
+       <symbol>NtDelayExecution@8</symbol>\r
+       <symbol>NtDeviceIoControlFile@40</symbol>\r
+       <symbol>_imp__NtDuplicateObject@28</symbol>\r
+       <symbol>NtFlushBuffersFile@8</symbol>\r
+       <symbol>NtFlushInstructionCache@12</symbol>\r
+       <symbol>NtFlushVirtualMemory@16</symbol>\r
+       <symbol>NtFreeVirtualMemory@16</symbol>\r
+       <symbol>NtFsControlFile@40</symbol>\r
+       <symbol>NtGetContextThread@8</symbol>\r
+       <symbol>NtLockVirtualMemory@16</symbol>\r
+       <symbol>NtOpenDirectoryObject@12</symbol>\r
+       <symbol>NtOpenEvent@12</symbol>\r
+       <symbol>NtOpenFile@24</symbol>\r
+       <symbol>NtOpenKey@12</symbol>\r
+       <symbol>NtOpenProcess@16</symbol>\r
+       <symbol>NtOpenSection@12</symbol>\r
+       <symbol>NtOpenThread@16</symbol>\r
+       <symbol>NtProtectVirtualMemory@20</symbol>\r
+       <symbol>NtPulseEvent@8</symbol>\r
+       <symbol>NtQueryDefaultLocale@8</symbol>\r
+       <symbol>NtQueryDefaultUILanguage@4</symbol>\r
+       <symbol>NtQueryDirectoryFile@44</symbol>\r
+       <symbol>NtQueryInformationFile@20</symbol>\r
+       <symbol>_imp__NtQueryInformationProcess@20</symbol>\r
+       <symbol>NtQueryInformationThread@20</symbol>\r
+       <symbol>NtQueryObject@20</symbol>\r
+       <symbol>NtQuerySystemInformation@16</symbol>\r
+       <symbol>NtQuerySystemTime@4</symbol>\r
+       <symbol>NtQueryValueKey@24</symbol>\r
+       <symbol>NtQueryVirtualMemory@24</symbol>\r
+       <symbol>NtQueryVolumeInformationFile@20</symbol>\r
+       <symbol>NtReadFile@36</symbol>\r
+       <symbol>NtReadVirtualMemory@20</symbol>\r
+       <symbol>NtResetEvent@8</symbol>\r
+       <symbol>NtResumeThread@8</symbol>\r
+       <symbol>NtSetContextThread@8</symbol>\r
+       <symbol>NtSetEvent@8</symbol>\r
+       <symbol>NtSetInformationFile@20</symbol>\r
+       <symbol>NtSetInformationObject@16</symbol>\r
+       <symbol>_imp__NtSetInformationProcess@16</symbol>\r
+       <symbol>NtSetInformationThread@16</symbol>\r
+       <symbol>NtSetSystemInformation@12</symbol>\r
+       <symbol>NtSetSystemTime@8</symbol>\r
+       <symbol>NtSignalAndWaitForSingleObject@16</symbol>\r
+       <symbol>NtSuspendThread@8</symbol>\r
+       <symbol>NtTerminateThread@8</symbol>\r
+       <symbol>NtUnlockVirtualMemory@16</symbol>\r
+       <symbol>NtUnmapViewOfSection@8</symbol>\r
+       <symbol>NtWaitForMultipleObjects@20</symbol>\r
+       <symbol>NtWaitForSingleObject@12</symbol>\r
+       <symbol>NtWriteFile@36</symbol>\r
+       <symbol>NtWriteVirtualMemory@20</symbol>\r
+       <symbol>NtYieldExecution@0</symbol>\r
+       <symbol>RtlAcquirePebLock@0</symbol>\r
+       <symbol>RtlAnsiStringToUnicodeSize@4</symbol>\r
+       <symbol>_imp__RtlBaseProcessStartRoutine</symbol>\r
+       <symbol>RtlCompactHeap@8</symbol>\r
+       <symbol>RtlCopyUnicodeString@8</symbol>\r
+       <symbol>RtlCreateHeap@24</symbol>\r
+       <symbol>RtlCreateProcessParameters@40</symbol>\r
+       <symbol>RtlCreateUnicodeString@8</symbol>\r
+       <symbol>RtlCreateUnicodeStringFromAsciiz@8</symbol>\r
+       <symbol>RtlDeleteCriticalSection@4</symbol>\r
+       <symbol>RtlDestroyHeap@4</symbol>\r
+       <symbol>RtlDestroyProcessParameters@4</symbol>\r
+       <symbol>RtlDoesFileExists_U@4</symbol>\r
+       <symbol>RtlDosPathNameToNtPathName_U@16</symbol>\r
+       <symbol>RtlDosSearchPath_U@24</symbol>\r
+       <symbol>RtlEnterCriticalSection@4</symbol>\r
+       <symbol>RtlExpandEnvironmentStrings_U@16</symbol>\r
+       <symbol>RtlFreeHeap@12</symbol>\r
+       <symbol>RtlGetCurrentDirectory_U@8</symbol>\r
+       <symbol>RtlGetFullPathName_U@16</symbol>\r
+       <symbol>RtlGetProcessHeaps@8</symbol>\r
+       <symbol>RtlImageNtHeader@4</symbol>\r
+       <symbol>RtlInitCodePageTable@8</symbol>\r
+       <symbol>RtlInitializeCriticalSection@4</symbol>\r
+       <symbol>RtlInitUnicodeString@8</symbol>\r
+       <symbol>RtlIntegerToChar@16</symbol>\r
+       <symbol>RtlIntegerToUnicodeString@12</symbol>\r
+       <symbol>RtlIsNameLegalDOS8Dot3@12</symbol>\r
+       <symbol>RtlLeaveCriticalSection@4</symbol>\r
+       <symbol>RtlLockHeap@4</symbol>\r
+       <symbol>RtlNtStatusToDosError@4</symbol>\r
+       <symbol>RtlOemStringToUnicodeSize@4</symbol>\r
+       <symbol>RtlOemStringToUnicodeString@12</symbol>\r
+       <symbol>RtlOpenCurrentUser@8</symbol>\r
+       <symbol>RtlQueryEnvironmentVariable_U@12</symbol>\r
+       <symbol>RtlRaiseException@4</symbol>\r
+       <symbol>RtlReAllocateHeap@16</symbol>\r
+       <symbol>RtlReleasePebLock@0</symbol>\r
+       <symbol>RtlRosCreateUserThreadVa</symbol>\r
+       <symbol>RtlRosExitUserThread@4</symbol>\r
+       <symbol>RtlSetCurrentDirectory_U@4</symbol>\r
+       <symbol>RtlSetEnvironmentVariable@12</symbol>\r
+       <symbol>RtlSetTimeZoneInformation@4</symbol>\r
+       <symbol>RtlTimeFieldsToTime@8</symbol>\r
+       <symbol>RtlTimeToTimeFields@8</symbol>\r
+       <symbol>RtlUnicodeStringToAnsiSize@4</symbol>\r
+       <symbol>RtlUnicodeStringToAnsiString@12</symbol>\r
+       <symbol>RtlUnicodeStringToInteger@12</symbol>\r
+       <symbol>RtlUnicodeStringToOemString@12</symbol>\r
+       <symbol>RtlUnicodeToOemN@20</symbol>\r
+       <symbol>RtlUnlockHeap@4</symbol>\r
+       <symbol>RtlValidateHeap@12</symbol>\r
+       <symbol>ZwMapViewOfSection@40</symbol>\r
+       <symbol>ZwOpenSection@12</symbol>\r
+       <symbol>ZwQuerySection@20</symbol>\r
+       <symbol>ZwQuerySystemInformation@16</symbol>\r
+       <symbol>ZwReadFile@36</symbol>\r
+       <symbol>ZwTerminateProcess@8</symbol>\r
+</component>\r
diff --git a/reactos/regtests/directory.xml b/reactos/regtests/directory.xml
new file mode 100644 (file)
index 0000000..40520c6
--- /dev/null
@@ -0,0 +1,6 @@
+<directory name="regtests">\r
+       <xi:include href="regtests/regtests.xml" />\r
+</directory>\r
+<directory name="shared">\r
+       <xi:include href="shared/rtshared.xml" />\r
+</directory>\r
diff --git a/reactos/regtests/regtests/regtests.xml b/reactos/regtests/regtests/regtests.xml
new file mode 100644 (file)
index 0000000..6a0cbc4
--- /dev/null
@@ -0,0 +1,6 @@
+<module name="regtests" type="win32dll" baseaddress="${BASEADDRESS_REGTESTS}">\r
+       <importlibrary definition="regtests.def" />\r
+       <include base="regtests">.</include>\r
+       <library>kernel32</library>\r
+       <file>regtests.c</file>\r
+</module>\r
diff --git a/reactos/regtests/shared/rtshared.xml b/reactos/regtests/shared/rtshared.xml
new file mode 100644 (file)
index 0000000..eb58e65
--- /dev/null
@@ -0,0 +1,4 @@
+<module name="rtshared" type="staticlibrary">\r
+       <include base="rtshared">.</include>\r
+       <file>regtests.c</file>\r
+</module>\r
index bdaf533..2085534 100644 (file)
@@ -176,6 +176,7 @@ MingwBackend::GenerateGlobalVariables () const
        fprintf ( fMakefile, "bin2res = " TOOL_PREFIX "bin2res" SSEP "bin2res" EXEPOSTFIX "\n" );\r
        fprintf ( fMakefile, "cabman = " TOOL_PREFIX "cabman" SSEP "cabman" EXEPOSTFIX "\n" );\r
        fprintf ( fMakefile, "cdmake = " TOOL_PREFIX "cdmake" SSEP "cdmake" EXEPOSTFIX "\n" );\r
+       fprintf ( fMakefile, "regtests = " TOOL_PREFIX "regtests" EXEPOSTFIX "\n" );\r
        fprintf ( fMakefile, "rsym = " TOOL_PREFIX "rsym" EXEPOSTFIX "\n" );\r
        fprintf ( fMakefile, "wrc = " TOOL_PREFIX "wrc" SSEP "wrc" EXEPOSTFIX "\n" );\r
        fprintf ( fMakefile, "\n" );\r
index 11435f7..7a8a300 100644 (file)
@@ -152,6 +152,9 @@ MingwModuleHandler::InstanciateHandler ( const string& location,
                case Iso:\r
                        handler = new MingwIsoModuleHandler ( backend );\r
                        break;\r
+               case Test:\r
+                       handler = new MingwTestModuleHandler ( backend );\r
+                       break;\r
        }\r
        return handler;\r
 }\r
@@ -1226,10 +1229,10 @@ MingwModuleHandler::GenerateMacrosAndTargets (
                                    clean_files );\r
 \r
        CLEAN_FILE ( ar_target );\r
-       string tgt = FixupTargetFilename(module.GetPath());\r
-       if ( tgt != ar_target )\r
+       string target = FixupTargetFilename ( module.GetPath () );\r
+       if ( target != ar_target )\r
        {\r
-               CLEAN_FILE ( tgt );\r
+               CLEAN_FILE ( target );\r
        }\r
 }\r
 \r
@@ -1882,8 +1885,7 @@ MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ( const Module& module,
        {\r
                GenerateMacrosAndTargets ( module, NULL, NULL, clean_files );\r
 \r
-               string dependencies =\r
-                       objectsMacro + " " + linkDepsMacro;\r
+               string dependencies = objectsMacro + " " + linkDepsMacro;\r
 \r
                string linker;\r
                if ( module.cplusplus )\r
@@ -2302,3 +2304,63 @@ MingwIsoModuleHandler::GenerateIsoModuleTarget ( const Module& module, string_li
        fprintf ( fMakefile,\r
                  "\n" );\r
 }\r
+\r
+\r
+MingwTestModuleHandler::MingwTestModuleHandler ( MingwBackend* backend )\r
+       : MingwModuleHandler ( Test,\r
+                              backend )\r
+{\r
+}\r
+\r
+void\r
+MingwTestModuleHandler::Process ( const Module& module, string_list& clean_files )\r
+{\r
+       GeneratePreconditionDependencies ( module );\r
+       GenerateTestModuleTarget ( module, clean_files );\r
+       GenerateInvocations ( module );\r
+}\r
+\r
+void\r
+MingwTestModuleHandler::GenerateTestModuleTarget ( const Module& module, string_list& clean_files )\r
+{\r
+       static string ros_junk ( "$(ROS_TEMPORARY)" );\r
+       string target ( FixupTargetFilename ( module.GetPath () ) );\r
+       string workingDirectory = GetWorkingDirectory ( );\r
+       string objectsMacro = GetObjectsMacro ( module );\r
+       string linkDepsMacro = GetLinkingDependenciesMacro ( module );\r
+       string libsMacro = GetLibsMacro ( module );\r
+\r
+       GenerateImportLibraryTargetIfNeeded ( module, clean_files );\r
+\r
+       if ( module.non_if_data.files.size () > 0 )\r
+       {\r
+               GenerateMacrosAndTargets ( module, NULL, NULL, clean_files );\r
+\r
+               string dependencies = objectsMacro + " " + linkDepsMacro;\r
+\r
+               string linker;\r
+               if ( module.cplusplus )\r
+                       linker = "${gpp}";\r
+               else\r
+                       linker = "${gcc}";\r
+\r
+               string linkerParameters = ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",\r
+                                                    module.entrypoint.c_str (),\r
+                                                    module.baseaddress.c_str () );\r
+               GenerateLinkerCommand ( module,\r
+                                       target,\r
+                                       dependencies,\r
+                                       linker,\r
+                                       linkerParameters,\r
+                                       objectsMacro,\r
+                                       libsMacro,\r
+                                       clean_files );\r
+       }\r
+       else\r
+       {\r
+               fprintf ( fMakefile, ".PHONY: %s\n\n",\r
+                         target.c_str ());\r
+               fprintf ( fMakefile, "%s:\n\n",\r
+                         target.c_str ());\r
+       }\r
+}\r
index b94c3d0..d9602b1 100644 (file)
@@ -336,4 +336,14 @@ private:
                                        const Module& module );\r
 };\r
 \r
+class MingwTestModuleHandler : public MingwModuleHandler\r
+{\r
+public:\r
+       MingwTestModuleHandler ( MingwBackend* backend );\r
+       virtual HostType DefaultHost() { return HostFalse; }\r
+       virtual void Process ( const Module& module, string_list& clean_files );\r
+private:\r
+       void GenerateTestModuleTarget ( const Module& module, string_list& clean_files );\r
+};\r
+\r
 #endif /* MINGW_MODULEHANDLER_H */\r
index f136132..c4d9842 100644 (file)
@@ -39,6 +39,7 @@ Bootstrap::IsSupportedModuleType ( ModuleType type )
                case StaticLibrary:\r
                case ObjectLibrary:\r
                case Iso:\r
+               case Test:\r
                        return false;\r
        }\r
        throw InvalidOperationException ( __FILE__,\r
index 57a070e..5fa77ad 100644 (file)
@@ -197,6 +197,8 @@ Module::~Module ()
                delete compilerFlags[i];\r
        for ( i = 0; i < linkerFlags.size(); i++ )\r
                delete linkerFlags[i];\r
+       for ( i = 0; i < stubbedComponents.size(); i++ )\r
+               delete stubbedComponents[i];\r
        if ( pch )\r
                delete pch;\r
 }\r
@@ -215,6 +217,8 @@ Module::ProcessXML()
                compilerFlags[i]->ProcessXML();\r
        for ( i = 0; i < linkerFlags.size(); i++ )\r
                linkerFlags[i]->ProcessXML();\r
+       for ( i = 0; i < stubbedComponents.size(); i++ )\r
+               stubbedComponents[i]->ProcessXML();\r
        non_if_data.ProcessXML();\r
        if ( pch )\r
                pch->ProcessXML();\r
@@ -342,6 +346,11 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
                linkerFlags.push_back ( new LinkerFlag ( project, this, e ) );\r
                subs_invalid = true;\r
        }\r
+       else if ( e.name == "component" )\r
+       {\r
+               stubbedComponents.push_back ( new StubbedComponent ( this, e ) );\r
+               subs_invalid = false;\r
+       }\r
        else if ( e.name == "property" )\r
        {\r
                throw InvalidBuildFileException (\r
@@ -407,6 +416,8 @@ Module::GetModuleType ( const string& location, const XMLAttribute& attribute )
                return BootSector;\r
        if ( attribute.value == "iso" )\r
                return Iso;\r
+       if ( attribute.value == "test" )\r
+               return Test;\r
        throw InvalidAttributeValueException ( location,\r
                                               attribute.name,\r
                                               attribute.value );\r
@@ -439,6 +450,8 @@ Module::GetDefaultModuleExtension () const
                        return ".o";\r
                case Iso:\r
                        return ".iso";\r
+               case Test:\r
+                       return ".exe";\r
        }\r
        throw InvalidOperationException ( __FILE__,\r
                                          __LINE__ );\r
@@ -460,6 +473,7 @@ Module::GetDefaultModuleEntrypoint () const
                case Win32DLL:\r
                        return "_DllMain@12";\r
                case Win32CUI:\r
+               case Test:\r
                        return "_mainCRTStartup";\r
                case Win32GUI:\r
                        return "_WinMainCRTStartup";\r
@@ -493,6 +507,7 @@ Module::GetDefaultModuleBaseaddress () const
                case Win32DLL:\r
                        return "0x10000";\r
                case Win32CUI:\r
+               case Test:\r
                        return "0x00400000";\r
                case Win32GUI:\r
                        return "0x00400000";\r
index 7c718d2..0e73b1e 100644 (file)
@@ -57,6 +57,8 @@ class AutomaticDependency;
 class Bootstrap;\r
 class CDFile;\r
 class PchFile;\r
+class StubbedComponent;\r
+class StubbedSymbol;\r
 \r
 class SourceFileTest;\r
 \r
@@ -130,7 +132,8 @@ enum ModuleType
        Win32GUI,\r
        BootLoader,\r
        BootSector,\r
-       Iso\r
+       Iso,\r
+       Test\r
 };\r
 \r
 enum HostType\r
@@ -159,6 +162,7 @@ public:
        std::vector<Dependency*> dependencies;\r
        std::vector<CompilerFlag*> compilerFlags;\r
        std::vector<LinkerFlag*> linkerFlags;\r
+       std::vector<StubbedComponent*> stubbedComponents;\r
        PchFile* pch;\r
        bool cplusplus;\r
        std::string prefix;\r
@@ -526,6 +530,35 @@ public:
        void ProcessXML();\r
 };\r
 \r
+\r
+class StubbedComponent\r
+{\r
+public:\r
+       const Module* module;\r
+       const XMLElement& node;\r
+       std::string name;\r
+       std::vector<StubbedSymbol*> symbols;\r
+\r
+       StubbedComponent ( const Module* module_,\r
+                          const XMLElement& stubbedComponentNode );\r
+       ~StubbedComponent ();\r
+       void ProcessXML ();\r
+       void ProcessXMLSubElement ( const XMLElement& e );\r
+};\r
+\r
+\r
+class StubbedSymbol\r
+{\r
+public:\r
+       const XMLElement& node;\r
+       std::string symbol;\r
+       std::string newname;\r
+\r
+       StubbedSymbol ( const XMLElement& stubbedSymbolNode );\r
+       ~StubbedSymbol ();\r
+       void ProcessXML();\r
+};\r
+\r
 extern std::string\r
 FixSeparator ( const std::string& s );\r
 \r
index 565aa06..9c2f371 100644 (file)
@@ -39,6 +39,7 @@ RBUILD_BASE_SOURCES = \
        module.cpp \\r
        project.cpp \\r
        ssprintf.cpp \\r
+       stubbedcomponent.cpp \\r
        XML.cpp\r
 \r
 RBUILD_COMMON_SOURCES = \\r
@@ -62,6 +63,7 @@ RBUILD_OBJECTS = \
        $(RBUILD_SPECIAL_OBJECTS)\r
 \r
 RBUILD_TESTS = \\r
+       tests$(SEP)cdfiletest.cpp \\r
        tests$(SEP)definetest.cpp \\r
        tests$(SEP)functiontest.cpp \\r
        tests$(SEP)iftest.cpp \\r
@@ -71,7 +73,7 @@ RBUILD_TESTS = \
        tests$(SEP)moduletest.cpp \\r
        tests$(SEP)projecttest.cpp \\r
        tests$(SEP)sourcefiletest.cpp \\r
-       tests$(SEP)cdfiletest.cpp\r
+       tests$(SEP)symboltest.cpp\r
 \r
 RBUILD_TEST_SPECIAL_SOURCES = \\r
        $(addprefix $(RBUILD_BASE)$(SEP), $(RBUILD_TESTS)) \\r
index 74ae806..1b21fea 100644 (file)
@@ -123,7 +123,7 @@ Value:
        None.\r
 \r
 Elements:\r
-       bootstrap, define, dependency, directory, file, if, importlibrary, include, invoke, library, property.\r
+       bootstrap, component, define, dependency, directory, file, if, importlibrary, include, invoke, library, property.\r
 \r
 \r
 Module types\r
@@ -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.\r
        nativedll - Builds a native DLL. Default extension is .dll. Default entrypoint is _DllMainCRTStartup@12.\r
        win32dll - Builds a Win32 DLL. Default extension is .dll. Default entrypoint is _DllMain@12.\r
+       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.\r
        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.\r
        bootloader - Builds a bootloader. The entrypoint, baseaddress, and mangledsymbols module attributes are not applicable for this module type.\r
        bootsector - Builds one or more bootsector binaries. The entrypoint, baseaddress, and mangledsymbols module attributes are not applicable for this module type.\r
        iso - Builds a bootable CD. The entrypoint, baseaddress, and mangledsymbols module attributes are not applicable for this module type.\r
+       test - Builds a testsuite. Default extension is .exe. Default entrypoint is _mainCRTStartup. The baseaddress module attribute is not applicable for this module type.\r
 \r
 \r
 Bootstrap element\r
@@ -179,6 +181,42 @@ Elements:
        None.\r
 \r
 \r
+Component element\r
+-----------------\r
+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.\r
+\r
+Syntax:\r
+       <component name="ntdll.dll">\r
+               ...\r
+       </component>\r
+\r
+Attributes:\r
+       name - Name of library.\r
+\r
+Value:\r
+       None.\r
+\r
+Elements:\r
+       Symbol.\r
+\r
+\r
+Symbol element\r
+--------------\r
+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.\r
+\r
+Syntax:\r
+       <symbol newname="RtlAllocateHeap">HeapAlloc@12</symbol>\r
+\r
+Attributes:\r
+       newname - New name of symbol. This attribute is optional.\r
+\r
+Value:\r
+       Name of symbol.\r
+\r
+Elements:\r
+       None.\r
+\r
+\r
 Define element\r
 --------------\r
 A define element specifies the name and (optionally) value of a define for the C/C++ compiler and resource compiler.\r
diff --git a/reactos/tools/rbuild/stubbedcomponent.cpp b/reactos/tools/rbuild/stubbedcomponent.cpp
new file mode 100644 (file)
index 0000000..707b5bb
--- /dev/null
@@ -0,0 +1,80 @@
+#include "pch.h"\r
+#include <assert.h>\r
+\r
+#include "rbuild.h"\r
+\r
+using std::string;\r
+using std::vector;\r
+\r
+StubbedComponent::StubbedComponent ( const Module* module_,\r
+                                     const XMLElement& stubbedComponentNode )\r
+       : module(module_),\r
+         node(stubbedComponentNode)\r
+{\r
+       const XMLAttribute* att = node.GetAttribute ( "name", true );\r
+       assert ( att );\r
+       name = att->value;\r
+}\r
+\r
+StubbedComponent::~StubbedComponent ()\r
+{\r
+       for ( size_t i = 0; i < symbols.size(); i++ )\r
+               delete symbols[i];\r
+}\r
+\r
+void\r
+StubbedComponent::ProcessXML ()\r
+{\r
+       size_t i;\r
+       for ( i = 0; i < node.subElements.size (); i++ )\r
+               ProcessXMLSubElement ( *node.subElements[i] );\r
+       for ( i = 0; i < symbols.size (); i++ )\r
+               symbols[i]->ProcessXML ();\r
+}\r
+\r
+void\r
+StubbedComponent::ProcessXMLSubElement ( const XMLElement& e )\r
+{\r
+       bool subs_invalid = false;\r
+       if ( e.name == "symbol" )\r
+       {\r
+               symbols.push_back ( new StubbedSymbol ( e ) );\r
+               subs_invalid = false;\r
+       }\r
+       if ( subs_invalid && e.subElements.size () > 0 )\r
+               throw InvalidBuildFileException (\r
+                       e.location,\r
+                       "<%s> cannot have sub-elements",\r
+                       e.name.c_str() );\r
+       for ( size_t i = 0; i < e.subElements.size (); i++ )\r
+               ProcessXMLSubElement ( *e.subElements[i] );\r
+}\r
+\r
+\r
+\r
+StubbedSymbol::StubbedSymbol ( const XMLElement& stubbedSymbolNode )\r
+       : node(stubbedSymbolNode)\r
+{\r
+}\r
+\r
+StubbedSymbol::~StubbedSymbol ()\r
+{\r
+}\r
+\r
+void\r
+StubbedSymbol::ProcessXML ()\r
+{\r
+       if ( node.value.size () == 0 )\r
+       {\r
+               throw InvalidBuildFileException (\r
+                       node.location,\r
+                       "<symbol> is empty." );\r
+       }\r
+       symbol = node.value;\r
+\r
+       const XMLAttribute* att = node.GetAttribute ( "newname", false );\r
+       if ( att != NULL )\r
+               newname = att->value;\r
+       else\r
+               newname = symbol;\r
+}\r
index a18d223..ee740fd 100644 (file)
@@ -126,4 +126,11 @@ public:
        void Run ();\r
 };\r
 \r
+\r
+class SymbolTest : public BaseTest\r
+{\r
+public:\r
+       void Run ();\r
+};\r
+\r
 #endif /* __TEST_H */\r
index 48a538f..f25306d 100644 (file)
@@ -179,6 +179,7 @@ private:
                tests.push_back(new FunctionTest());\r
                tests.push_back(new SourceFileTest());\r
                tests.push_back(new CDFileTest());\r
+               tests.push_back(new SymbolTest());\r
        }\r
 };\r
 \r
diff --git a/reactos/tools/rbuild/tests/data/symbol.xml b/reactos/tools/rbuild/tests/data/symbol.xml
new file mode 100644 (file)
index 0000000..0089d64
--- /dev/null
@@ -0,0 +1,9 @@
+<?xml version="1.0" ?>\r
+<project name="Project" makefile="Makefile">\r
+       <module name="module1" type="test">\r
+               <component name="ntdll.dll">\r
+                       <symbol newname="RtlAllocateHeap">HeapAlloc@12</symbol>\r
+                       <symbol>LdrAccessResource@16</symbol>\r
+               </component>\r
+       </module>\r
+</project>\r
index 84dede1..8278653 100644 (file)
@@ -5,5 +5,5 @@ using std::string;
 void FunctionTest::Run ()\r
 {\r
        string fixedupFilename = FixupTargetFilename ( "." SSEP "dir1" SSEP "dir2" SSEP ".." SSEP "filename.txt" );\r
-       ARE_EQUAL ( "$(ROS_INTERMEDIATE)." SSEP "dir1" SSEP "filename.txt", fixedupFilename );\r
+       ARE_EQUAL ( "$(INTERMEDIATE)dir1" SSEP "filename.txt", fixedupFilename );\r
 }\r
index 0bfb540..92a4c84 100644 (file)
@@ -17,9 +17,9 @@ void IfTest::Run()
 \r
        ARE_EQUAL ( 1, if1.data.files.size () );\r
        File& file1 = *if1.data.files[0];\r
-       ARE_EQUAL( "." SSEP "file1.c", file1.name );\r
+       ARE_EQUAL( SSEP "file1.c", file1.name );\r
 \r
        ARE_EQUAL ( 1, module1.non_if_data.files.size () );\r
        File& file2 = *module1.non_if_data.files[0];\r
-       ARE_EQUAL( "." SSEP "file2.c", file2.name );\r
+       ARE_EQUAL( SSEP "file2.c", file2.name );\r
 }\r
index ddea2f9..6fb4ac8 100644 (file)
@@ -20,5 +20,5 @@ void IncludeTest::Run()
 \r
        ARE_EQUAL(1, module2.non_if_data.includes.size());\r
        Include& include3 = *module2.non_if_data.includes[0];\r
-       ARE_EQUAL(FixSeparator("./dir1/include3"), include3.directory);\r
+       ARE_EQUAL(FixSeparator("dir1/include3"), include3.directory);\r
 }\r
index b129ac1..fdd1893 100644 (file)
@@ -15,5 +15,5 @@ void InvokeTest::Run()
        ARE_EQUAL(1, invoke1.output.size());\r
 \r
        InvokeFile& file1 = *invoke1.output[0];\r
-       ARE_EQUAL(FixSeparator("./dir1/file1.c"), file1.name);\r
+       ARE_EQUAL(FixSeparator("dir1/file1.c"), file1.name);\r
 }\r
index bf10cb0..3b8d77d 100644 (file)
@@ -11,16 +11,16 @@ void ModuleTest::Run()
        Module& module1 = *project.modules[0];\r
        IS_TRUE(module1.type == BuildTool);\r
        ARE_EQUAL(2, module1.non_if_data.files.size());\r
-       ARE_EQUAL("." SSEP "dir1" SSEP "file1.c", module1.non_if_data.files[0]->name);\r
-       ARE_EQUAL("." SSEP "dir1" SSEP "file2.c", module1.non_if_data.files[1]->name);\r
+       ARE_EQUAL("dir1" SSEP "file1.c", module1.non_if_data.files[0]->name);\r
+       ARE_EQUAL("dir1" SSEP "file2.c", module1.non_if_data.files[1]->name);\r
 \r
        ARE_EQUAL(0, module1.non_if_data.libraries.size());\r
 \r
        Module& module2 = *project.modules[1];\r
        IS_TRUE(module2.type == KernelModeDLL);\r
        ARE_EQUAL(2, module2.non_if_data.files.size());\r
-       ARE_EQUAL("." SSEP "dir2" SSEP "file3.c", module2.non_if_data.files[0]->name);\r
-       ARE_EQUAL("." SSEP "dir2" SSEP "file4.c", module2.non_if_data.files[1]->name);\r
+       ARE_EQUAL("dir2" SSEP "file3.c", module2.non_if_data.files[0]->name);\r
+       ARE_EQUAL("dir2" SSEP "file4.c", module2.non_if_data.files[1]->name);\r
 \r
        ARE_EQUAL(1, module2.non_if_data.libraries.size());\r
        Library& library1 = *module2.non_if_data.libraries[0];\r
index 2f5c990..5885baa 100644 (file)
@@ -38,9 +38,9 @@ SourceFileTest::IncludeTest ()
        AutomaticDependency automaticDependency ( project );\r
        automaticDependency.Process ();\r
        ARE_EQUAL( 4, automaticDependency.sourcefile_map.size () );\r
-       const SourceFile* include = automaticDependency.RetrieveFromCache ( "." SSEP RBUILD_BASE "tests" SSEP "data" SSEP "sourcefile_include.h" );\r
+       const SourceFile* include = automaticDependency.RetrieveFromCache ( RBUILD_BASE "tests" SSEP "data" SSEP "sourcefile_include.h" );\r
        IS_NOT_NULL( include );\r
-       const SourceFile* includenext = automaticDependency.RetrieveFromCache ( "." SSEP RBUILD_BASE "tests" SSEP "data" SSEP "sourcefile1" SSEP "sourcefile_includenext.h" );\r
+       const SourceFile* includenext = automaticDependency.RetrieveFromCache ( RBUILD_BASE "tests" SSEP "data" SSEP "sourcefile1" SSEP "sourcefile_includenext.h" );\r
        IS_NOT_NULL( includenext );\r
 }\r
 \r
@@ -51,9 +51,9 @@ SourceFileTest::FullParseTest ()
        AutomaticDependency automaticDependency ( project );\r
        automaticDependency.Process ();\r
        ARE_EQUAL( 5, automaticDependency.sourcefile_map.size () );\r
-       const SourceFile* header1 = automaticDependency.RetrieveFromCache ( "." SSEP RBUILD_BASE "tests" SSEP "data" SSEP "sourcefile1_header1.h" );\r
+       const SourceFile* header1 = automaticDependency.RetrieveFromCache ( RBUILD_BASE "tests" SSEP "data" SSEP "sourcefile1_header1.h" );\r
        IS_NOT_NULL( header1 );\r
-       const SourceFile* recurse = automaticDependency.RetrieveFromCache ( "." SSEP RBUILD_BASE"tests" SSEP "data" SSEP "sourcefile1_recurse.h" );\r
+       const SourceFile* recurse = automaticDependency.RetrieveFromCache ( RBUILD_BASE "tests" SSEP "data" SSEP "sourcefile1_recurse.h" );\r
        IS_NOT_NULL( recurse );\r
        IS_TRUE( IsParentOf ( header1,\r
                              recurse ) );\r
diff --git a/reactos/tools/rbuild/tests/symboltest.cpp b/reactos/tools/rbuild/tests/symboltest.cpp
new file mode 100644 (file)
index 0000000..9d6d534
--- /dev/null
@@ -0,0 +1,25 @@
+#include "test.h"\r
+\r
+using std::string;\r
+\r
+void SymbolTest::Run()\r
+{\r
+       string projectFilename ( RBUILD_BASE "tests/data/symbol.xml" );\r
+       Project project ( projectFilename );\r
+       \r
+       ARE_EQUAL ( 1, project.modules.size () );\r
+       Module& module1 = *project.modules[0];\r
+       \r
+       ARE_EQUAL ( 1, module1.stubbedComponents.size () );\r
+       StubbedComponent& component1 = *module1.stubbedComponents[0];\r
+       ARE_EQUAL ( "ntdll.dll", component1.name );\r
+       \r
+       ARE_EQUAL ( 2, component1.symbols.size () );\r
+       StubbedSymbol& symbol1 = *component1.symbols[0];\r
+       ARE_EQUAL ( "HeapAlloc@12", symbol1.symbol );\r
+       ARE_EQUAL ( "RtlAllocateHeap", symbol1.newname );\r
+       \r
+       StubbedSymbol& symbol2 = *component1.symbols[1];\r
+       ARE_EQUAL ( "LdrAccessResource@16", symbol2.symbol );\r
+       ARE_EQUAL ( "LdrAccessResource@16", symbol2.newname );\r
+}\r