From d0acee6af82752476c3ade9fa759aeaa36783293 Mon Sep 17 00:00:00 2001 From: Casper Hornstrup Date: Sat, 22 Jan 2005 17:38:31 +0000 Subject: [PATCH] * Invoke cabman when building a CD * Entrypoint attribute on to override default entrypoint * Use entrypoint _DrvEnableDriver@12 for display drivers svn path=/branches/xmlbuildsystem/; revision=13216 --- reactos/boot/freeldr/freeldr.xml | 11 +- .../video/displays/framebuf/framebuf.xml | 2 +- reactos/drivers/video/displays/vga/vgaddi.xml | 2 +- reactos/tools/rbuild/backend/mingw/mingw.cpp | 4 + .../rbuild/backend/mingw/modulehandler.cpp | 114 +++++++++++++++--- .../rbuild/backend/mingw/modulehandler.h | 16 ++- reactos/tools/rbuild/module.cpp | 41 ++++++- reactos/tools/rbuild/rbuild.h | 3 + 8 files changed, 162 insertions(+), 31 deletions(-) diff --git a/reactos/boot/freeldr/freeldr.xml b/reactos/boot/freeldr/freeldr.xml index aee76461b4c..a3c3e782e0d 100644 --- a/reactos/boot/freeldr/freeldr.xml +++ b/reactos/boot/freeldr/freeldr.xml @@ -1,11 +1,4 @@ - + diff --git a/reactos/drivers/video/displays/framebuf/framebuf.xml b/reactos/drivers/video/displays/framebuf/framebuf.xml index 4560d24a6fc..3a98464becc 100644 --- a/reactos/drivers/video/displays/framebuf/framebuf.xml +++ b/reactos/drivers/video/displays/framebuf/framebuf.xml @@ -1,4 +1,4 @@ - + . diff --git a/reactos/drivers/video/displays/vga/vgaddi.xml b/reactos/drivers/video/displays/vga/vgaddi.xml index a9186d1393b..19ab0e8ed1c 100644 --- a/reactos/drivers/video/displays/vga/vgaddi.xml +++ b/reactos/drivers/video/displays/vga/vgaddi.xml @@ -1,4 +1,4 @@ - + . diff --git a/reactos/tools/rbuild/backend/mingw/mingw.cpp b/reactos/tools/rbuild/backend/mingw/mingw.cpp index d5c616dc66d..e448f1e93f8 100644 --- a/reactos/tools/rbuild/backend/mingw/mingw.cpp +++ b/reactos/tools/rbuild/backend/mingw/mingw.cpp @@ -193,6 +193,8 @@ MingwBackend::GenerateGlobalVariables () const fprintf ( fMakefile, "NUL=NUL\n" ); fprintf ( fMakefile, "winebuild = tools" SSEP "winebuild" SSEP "winebuild\n" ); fprintf ( fMakefile, "bin2res = tools" SSEP "bin2res" SSEP "bin2res\n" ); + fprintf ( fMakefile, "cabman = tools" SSEP "cabman" SSEP "cabman\n" ); + fprintf ( fMakefile, "cdmake = tools" SSEP "cdmake" SSEP "cdmake\n" ); fprintf ( fMakefile, "\n" ); GenerateGlobalCFlagsAndProperties ( "=", @@ -213,6 +215,8 @@ MingwBackend::IncludeInAllTarget ( const Module& module ) const { if ( module.type == ObjectLibrary ) return false; + if ( module.type == BootSector ) + return false; if ( module.type == Iso ) return false; return true; diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp index 4ccb419f5ff..29d1041b47b 100644 --- a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp +++ b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp @@ -960,7 +960,8 @@ MingwModuleHandler::GenerateMacrosAndTargets ( const string& cc, const string& cppc, const string& ar, - const string* cflags ) const + const string* cflags, + const string* nasmflags ) const { string cflagsMacro = ssprintf ("%s_CFLAGS", module.name.c_str ()); string nasmflagsMacro = ssprintf ("%s_NASMFLAGS", module.name.c_str ()); @@ -982,7 +983,15 @@ MingwModuleHandler::GenerateMacrosAndTargets ( cflagsMacro.c_str (), cflags->c_str () ); } - + + if ( nasmflags != NULL ) + { + fprintf ( fMakefile, + "%s += %s\n\n", + nasmflagsMacro.c_str (), + nasmflags->c_str () ); + } + // generate phony target for module name fprintf ( fMakefile, ".PHONY: %s\n", module.name.c_str () ); @@ -1021,21 +1030,33 @@ MingwModuleHandler::GenerateMacrosAndTargets ( void MingwModuleHandler::GenerateMacrosAndTargetsHost ( const Module& module ) const { - GenerateMacrosAndTargets ( module, "${host_gcc}", "${host_gpp}", "${host_ar}", NULL ); + GenerateMacrosAndTargets ( module, + "${host_gcc}", + "${host_gpp}", + "${host_ar}", + NULL, + NULL ); } void MingwModuleHandler::GenerateMacrosAndTargetsTarget ( const Module& module ) const { GenerateMacrosAndTargetsTarget ( module, + NULL, NULL ); } void MingwModuleHandler::GenerateMacrosAndTargetsTarget ( const Module& module, - const string* clags ) const + const string* cflags, + const string* nasmflags ) const { - GenerateMacrosAndTargets ( module, "${gcc}", "${gpp}", "${ar}", clags ); + GenerateMacrosAndTargets ( module, + "${gcc}", + "${gpp}", + "${ar}", + cflags, + nasmflags ); } string @@ -1306,8 +1327,9 @@ MingwKernelModuleHandler::GenerateKernelModuleTarget ( const Module& module ) string base_tmp = ros_junk + module.name + ".base.tmp"; string junk_tmp = ros_junk + module.name + ".junk.tmp"; string temp_exp = ros_junk + module.name + ".temp.exp"; - string gccOptions = ssprintf ("-Wl,-T,%s" SSEP "ntoskrnl.lnk -Wl,--subsystem,native -Wl,--entry,_NtProcessStartup -Wl,--image-base,0xC0000000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll", - module.GetBasePath ().c_str () ); + string gccOptions = ssprintf ("-Wl,-T,%s" SSEP "ntoskrnl.lnk -Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,0xC0000000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll", + module.GetBasePath ().c_str (), + module.entrypoint.c_str () ); GenerateMacrosAndTargetsTarget ( module ); @@ -1429,7 +1451,8 @@ MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ( const Modul archiveFilename.c_str (), importLibraryDependencies.c_str () ); - string linkerParameters ( "-Wl,--subsystem,native -Wl,--entry,_DriverEntry@8 -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll" ); + string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll", + module.entrypoint.c_str () ); GenerateLinkerCommand ( module, "${gcc}", linkerParameters, @@ -1476,7 +1499,8 @@ MingwKernelModeDriverModuleHandler::GenerateKernelModeDriverModuleTarget ( const { string* cflags = new string ( "-D__NTDRIVER__" ); GenerateMacrosAndTargetsTarget ( module, - cflags ); + cflags, + NULL ); delete cflags; fprintf ( fMakefile, "%s: %s %s\n", @@ -1484,7 +1508,8 @@ MingwKernelModeDriverModuleHandler::GenerateKernelModeDriverModuleTarget ( const archiveFilename.c_str (), importLibraryDependencies.c_str () ); - string linkerParameters ( "-Wl,--subsystem,native -Wl,--entry,_DriverEntry@8 -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll" ); + string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll", + module.entrypoint.c_str () ); GenerateLinkerCommand ( module, "${gcc}", linkerParameters, @@ -1546,7 +1571,8 @@ MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ( const Module& modul archiveFilename.c_str (), importLibraryDependencies.c_str () ); - string linkerParameters ( "-Wl,--subsystem,native -Wl,--entry,_DllMainCRTStartup@12 -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib -mdll" ); + string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib -mdll", + module.entrypoint.c_str () ); GenerateLinkerCommand ( module, "${gcc}", linkerParameters, @@ -1618,7 +1644,8 @@ MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ( const Module& module objectFilenames.c_str (), linkingDependencies.c_str () ); - string linkerParameters ( "-Wl,--subsystem,console -Wl,--entry,_DllMain@12 -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -mdll" ); + string linkerParameters = ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -mdll", + module.entrypoint.c_str () ); GenerateLinkerCommand ( module, "${gcc}", linkerParameters, @@ -1669,7 +1696,8 @@ MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ( const Module& module objectFilenames.c_str (), importLibraryDependencies.c_str () ); - string linkerParameters ( "-Wl,--subsystem,windows -Wl,--entry,_WinMainCRTStartup -Wl,--image-base,0x00400000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000" ); + string linkerParameters = ssprintf ( "-Wl,--subsystem,windows -Wl,--entry,%s -Wl,--image-base,0x00400000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000", + module.entrypoint.c_str () ); GenerateLinkerCommand ( module, "${gcc}", linkerParameters, @@ -1734,6 +1762,40 @@ MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ( const Module& mod } +static MingwBootSectorModuleHandler bootsectormodule_handler; + +MingwBootSectorModuleHandler::MingwBootSectorModuleHandler () + : MingwModuleHandler ( BootSector ) +{ +} + +void +MingwBootSectorModuleHandler::Process ( const Module& module ) +{ + GeneratePreconditionDependencies ( module ); + GenerateBootSectorModuleTarget ( module ); + GenerateInvocations ( module ); +} + +void +MingwBootSectorModuleHandler::GenerateBootSectorModuleTarget ( const Module& module ) +{ + string objectsMacro = GetObjectsMacro ( module ); + + string* nasmflags = new string ( "-f bin" ); + GenerateMacrosAndTargetsTarget ( module, + NULL, + nasmflags); + + fprintf ( fMakefile, ".PHONY: %s\n\n", + module.name.c_str ()); + fprintf ( fMakefile, + "%s: %s\n", + module.name.c_str (), + objectsMacro.c_str () ); +} + + static MingwIsoModuleHandler isomodule_handler; MingwIsoModuleHandler::MingwIsoModuleHandler () @@ -1752,10 +1814,28 @@ MingwIsoModuleHandler::Process ( const Module& module ) void MingwIsoModuleHandler::GenerateIsoModuleTarget ( const Module& module ) { - string target ( FixupTargetFilename ( module.GetPath ()) ); + string isoboot = "$(ROS_INTERMEDIATE)" + FixupTargetFilename ( "boot/freeldr/bootsect/isoboot.o" ); - fprintf ( fMakefile, "%s: all\n", - target.c_str () ); + fprintf ( fMakefile, ".PHONY: %s\n\n", + module.name.c_str ()); fprintf ( fMakefile, - "\t\n" ); + "%s: all %s\n", + module.name.c_str (), + isoboot.c_str () ); + fprintf ( fMakefile, + "\t${cabman} /C %s /L $(ROS_INTERMEDIATE)%s /I\n", + FixupTargetFilename ( "bootdata/packages/reactos.dff" ).c_str (), + FixupTargetFilename ( "bootcd/reactos" ).c_str () ); + fprintf ( fMakefile, + "\t${cabman} /C %s /RC $(ROS_INTERMEDIATE)%s /L $(BOOTCD_DIR)reactos /N\n", + FixupTargetFilename ( "bootdata/packages/reactos.dff" ).c_str (), + FixupTargetFilename ( "bootcd/reactos/reactos.inf" ).c_str () ); + fprintf ( fMakefile, + "\t- ${rm} $(ROS_INTERMEDIATE)%s\n", + FixupTargetFilename ( "bootcd/reactos/reactos.inf" ).c_str () ); + fprintf ( fMakefile, + "\t${cdmake} -v -m -b %s $(ROS_INTERMEDIATE)bootcd REACTOS ReactOS.iso\n", + isoboot.c_str () ); + fprintf ( fMakefile, + "\n" ); } diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.h b/reactos/tools/rbuild/backend/mingw/modulehandler.h index 6cd0cd05686..08d359925e7 100644 --- a/reactos/tools/rbuild/backend/mingw/modulehandler.h +++ b/reactos/tools/rbuild/backend/mingw/modulehandler.h @@ -42,7 +42,8 @@ protected: void GenerateMacrosAndTargetsHost ( const Module& module ) const; void GenerateMacrosAndTargetsTarget ( const Module& module ) const; void GenerateMacrosAndTargetsTarget ( const Module& module, - const std::string* clags ) const; + const std::string* cflags, + const std::string* nasmflags ) const; std::string GetInvocationDependencies ( const Module& module ) const; std::string GetInvocationParameters ( const Invoke& invoke ) const; void GenerateInvocations ( const Module& module ) const; @@ -141,7 +142,8 @@ private: const std::string& cc, const std::string& cppc, const std::string& ar, - const std::string* clags ) const; + const std::string* clags, + const std::string* nasmflags ) const; std::string GetPreconditionDependenciesName ( const Module& module ) const; std::string GetSpecObjectDependencies ( const std::string& filename ) const; }; @@ -248,6 +250,16 @@ private: }; +class MingwBootSectorModuleHandler : public MingwModuleHandler +{ +public: + MingwBootSectorModuleHandler (); + virtual void Process ( const Module& module ); +private: + void GenerateBootSectorModuleTarget ( const Module& module ); +}; + + class MingwIsoModuleHandler : public MingwModuleHandler { public: diff --git a/reactos/tools/rbuild/module.cpp b/reactos/tools/rbuild/module.cpp index 75117582ebf..37a0f4073bf 100644 --- a/reactos/tools/rbuild/module.cpp +++ b/reactos/tools/rbuild/module.cpp @@ -61,10 +61,16 @@ Module::Module ( const Project& project, type = GetModuleType ( node.location, *att ); att = moduleNode.GetAttribute ( "extension", false ); - if (att != NULL) + if ( att != NULL ) extension = att->value; else extension = GetDefaultModuleExtension (); + + att = moduleNode.GetAttribute ( "entrypoint", false ); + if ( att != NULL ) + entrypoint = att->value; + else + entrypoint = GetDefaultModuleEntrypoint (); } Module::~Module () @@ -265,6 +271,8 @@ Module::GetModuleType ( const string& location, const XMLAttribute& attribute ) return Win32GUI; if ( attribute.value == "bootloader" ) return BootLoader; + if ( attribute.value == "bootsector" ) + return BootSector; if ( attribute.value == "iso" ) return Iso; throw InvalidAttributeValueException ( location, @@ -293,6 +301,8 @@ Module::GetDefaultModuleExtension () const case KernelModeDriver: case BootLoader: return ".sys"; + case BootSector: + return ".o"; case Iso: return ".iso"; } @@ -300,6 +310,35 @@ Module::GetDefaultModuleExtension () const __LINE__ ); } +string +Module::GetDefaultModuleEntrypoint () const +{ + switch (type) + { + case Kernel: + return "_NtProcessStartup"; + case Win32GUI: + return "_WinMainCRTStartup"; + case KernelModeDLL: + return "_DriverEntry@8"; + case NativeDLL: + return "_DllMainCRTStartup@12"; + case Win32DLL: + return "_DllMain@12"; + case KernelModeDriver: + return "_DriverEntry@8"; + case BuildTool: + case StaticLibrary: + case ObjectLibrary: + case BootLoader: + case BootSector: + case Iso: + return ""; + } + throw InvalidOperationException ( __FILE__, + __LINE__ ); +} + bool Module::HasImportLibrary () const { diff --git a/reactos/tools/rbuild/rbuild.h b/reactos/tools/rbuild/rbuild.h index 671dd55beb6..88dcae6ab3b 100644 --- a/reactos/tools/rbuild/rbuild.h +++ b/reactos/tools/rbuild/rbuild.h @@ -80,6 +80,7 @@ enum ModuleType Win32DLL, Win32GUI, BootLoader, + BootSector, Iso }; @@ -91,6 +92,7 @@ public: const XMLElement& node; std::string name; std::string extension; + std::string entrypoint; std::string path; ModuleType type; ImportLibrary* importLibrary; @@ -123,6 +125,7 @@ public: void ProcessXML(); private: std::string GetDefaultModuleExtension () const; + std::string GetDefaultModuleEntrypoint () const; void ProcessXMLSubElement ( const XMLElement& e, const std::string& path, If* pIf = NULL );