Add bootstrap tag to specify that files are to be copied to the CD
authorCasper Hornstrup <chorns@users.sourceforge.net>
Wed, 2 Mar 2005 21:24:02 +0000 (21:24 +0000)
committerCasper Hornstrup <chorns@users.sourceforge.net>
Wed, 2 Mar 2005 21:24:02 +0000 (21:24 +0000)
svn path=/branches/xmlbuildsystem/; revision=13797

reactos/tools/rbuild/backend/mingw/modulehandler.cpp
reactos/tools/rbuild/backend/mingw/modulehandler.h
reactos/tools/rbuild/bootstrap.cpp [new file with mode: 0644]
reactos/tools/rbuild/linkerflag.cpp
reactos/tools/rbuild/makefile
reactos/tools/rbuild/module.cpp
reactos/tools/rbuild/rbuild.h
reactos/tools/rbuild/rbuild.txt

index 54f25a6..5d9ab57 100644 (file)
@@ -1873,7 +1873,7 @@ MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ( const Module& mod
 {\r
        static string ros_junk ( "$(ROS_TEMPORARY)" );\r
        string targetName ( module.GetTargetName () );\r
-       string target ( FixupTargetFilename (module.GetPath ()) );\r
+       string target ( FixupTargetFilename ( module.GetPath () ) );\r
        string workingDirectory = GetWorkingDirectory ();\r
        string junk_tmp = ros_junk + module.name + ".junk.tmp";\r
        string objectsMacro = GetObjectsMacro ( module );\r
@@ -1951,6 +1951,44 @@ MingwIsoModuleHandler::Process ( const Module& module )
        GenerateInvocations ( module );\r
 }\r
 \r
+void\r
+MingwIsoModuleHandler::OutputBootstrapfileCopyCommands ( const string bootcdDirectory,\r
+                                                            const Module& module ) const\r
+{\r
+       for ( size_t i = 0; i < module.project.modules.size (); i++ )\r
+       {\r
+               const Module& m = *module.project.modules[i];\r
+               if ( m.bootstrap != NULL )\r
+               {\r
+                       string targetFilenameNoFixup = bootcdDirectory + SSEP + m.bootstrap->base + SSEP + m.bootstrap->nameoncd;\r
+                       string targetFilename = PassThruCacheDirectory ( FixupTargetFilename ( targetFilenameNoFixup ) );\r
+                       fprintf ( fMakefile,\r
+                                 "\t${cp} %s %s\n",\r
+                                 m.GetPath ().c_str (),\r
+                                 targetFilename.c_str () );\r
+               }\r
+       }\r
+}\r
+\r
+string\r
+MingwIsoModuleHandler::GetCdDirectories ( const string bootcdDirectory,\r
+                                             const Module& module ) const\r
+{\r
+       string directories;\r
+       for ( size_t i = 0; i < module.project.modules.size (); i++ )\r
+       {\r
+               const Module& m = *module.project.modules[i];\r
+               if ( m.bootstrap != NULL )\r
+               {\r
+                       string targetDirecctory = bootcdDirectory + SSEP + m.bootstrap->base;\r
+                       if ( directories.size () > 0 )\r
+                               directories += " ";\r
+                       directories += FixupTargetFilename ( targetDirecctory );\r
+               }\r
+       }\r
+       return directories;\r
+}\r
+\r
 void\r
 MingwIsoModuleHandler::GenerateIsoModuleTarget ( const Module& module )\r
 {\r
@@ -1961,6 +1999,8 @@ MingwIsoModuleHandler::GenerateIsoModuleTarget ( const Module& module )
        PassThruCacheDirectory ( bootcdReactos + SSEP );\r
        string reactosInf = FixupTargetFilename ( bootcdReactosNoFixup + "/reactos.inf" );\r
        string reactosDff = NormalizeFilename ( "bootdata/packages/reactos.dff" );\r
+       string cdDirectories = bootcdReactos + " " + GetCdDirectories ( bootcdDirectory,\r
+                                                                       module );\r
 \r
        fprintf ( fMakefile, ".PHONY: %s\n\n",\r
                      module.name.c_str ());\r
@@ -1968,7 +2008,7 @@ MingwIsoModuleHandler::GenerateIsoModuleTarget ( const Module& module )
                  "%s: all %s %s\n",\r
                  module.name.c_str (),\r
                  isoboot.c_str (),\r
-                 bootcdReactos.c_str () );\r
+                 cdDirectories.c_str () );\r
        fprintf ( fMakefile,\r
                  "\t${cabman} /C %s /L %s /I\n",\r
                  reactosDff.c_str (),\r
@@ -1981,6 +2021,8 @@ MingwIsoModuleHandler::GenerateIsoModuleTarget ( const Module& module )
        fprintf ( fMakefile,\r
                  "\t- ${rm} %s\n",\r
                  reactosInf.c_str () );\r
+       OutputBootstrapfileCopyCommands ( bootcdDirectory,\r
+                                         module );\r
        fprintf ( fMakefile,\r
                  "\t${cdmake} -v -m -b %s %s REACTOS ReactOS.iso\n",\r
                  isoboot.c_str (),\r
index 717921b..5a4feca 100644 (file)
@@ -291,6 +291,10 @@ public:
        virtual void Process ( const Module& module );\r
 private:\r
        void GenerateIsoModuleTarget ( const Module& module );\r
+       std::string GetCdDirectories ( const std::string bootcdDirectory,\r
+                                      const Module& module ) const;\r
+       void OutputBootstrapfileCopyCommands ( const std::string bootcdDirectory,\r
+                                              const Module& module ) const;\r
 };\r
 \r
 #endif /* MINGW_MODULEHANDLER_H */\r
diff --git a/reactos/tools/rbuild/bootstrap.cpp b/reactos/tools/rbuild/bootstrap.cpp
new file mode 100644 (file)
index 0000000..b96a1f7
--- /dev/null
@@ -0,0 +1,74 @@
+#include "pch.h"\r
+#include <assert.h>\r
+\r
+#include "rbuild.h"\r
+\r
+using std::string;\r
+\r
+Bootstrap::Bootstrap ( const Project& project_,\r
+                          const Module* module_,\r
+                          const XMLElement& bootstrapNode )\r
+       : project(project_),\r
+         module(module_),\r
+         node(bootstrapNode)\r
+{\r
+       Initialize();\r
+}\r
+\r
+Bootstrap::~Bootstrap ()\r
+{\r
+}\r
+\r
+bool\r
+Bootstrap::IsSupportedModuleType ( ModuleType type )\r
+{\r
+       switch ( type )\r
+       {\r
+               case Kernel:\r
+               case KernelModeDLL:\r
+               case NativeDLL:\r
+               case NativeCUI:\r
+               case Win32DLL:\r
+               case Win32CUI:\r
+               case Win32GUI:\r
+               case KernelModeDriver:\r
+                       return true;\r
+               case BuildTool:\r
+               case StaticLibrary:\r
+               case ObjectLibrary:\r
+               case BootLoader:\r
+               case BootSector:\r
+               case Iso:\r
+                       return false;\r
+       }\r
+       throw InvalidOperationException ( __FILE__,\r
+                                         __LINE__ );\r
+}\r
+\r
+void\r
+Bootstrap::Initialize ()\r
+{\r
+       if ( !IsSupportedModuleType ( module->type ) )\r
+       {\r
+               throw InvalidBuildFileException (\r
+                       node.location,\r
+                       "<bootstrap> is not applicable for this module type." );\r
+       }\r
+\r
+       const XMLAttribute* att = node.GetAttribute ( "base", false );\r
+       if ( att != NULL )\r
+               base = att->value;\r
+       else\r
+               base = "";\r
+\r
+       att = node.GetAttribute ( "nameoncd", false );\r
+       if ( att != NULL )\r
+               nameoncd = att->value;\r
+       else\r
+               nameoncd = module->GetTargetName ();\r
+}\r
+\r
+void\r
+Bootstrap::ProcessXML()\r
+{\r
+}\r
index 6ef22c9..f2abab3 100644 (file)
@@ -30,14 +30,14 @@ LinkerFlag::~LinkerFlag ()
 }\r
 \r
 void\r
-LinkerFlag::Initialize()\r
+LinkerFlag::Initialize ()\r
 {\r
 }\r
 \r
 void\r
-LinkerFlag::ProcessXML()\r
+LinkerFlag::ProcessXML ()\r
 {\r
-       if (node.value.size () == 0)\r
+       if ( node.value.size () == 0 )\r
        {\r
                throw InvalidBuildFileException (\r
                        node.location,\r
index 3dedb3c..5a0fb31 100644 (file)
@@ -21,6 +21,7 @@ RBUILD_BACKEND_BASE_SOURCES = \
 RBUILD_BASE_SOURCES = \\r
        $(RBUILD_BACKEND_BASE_SOURCES) \\r
        automaticdependency.cpp \\r
+       bootstrap.cpp \\r
        compilerflag.cpp \\r
        define.cpp \\r
        exception.cpp \\r
index 47157e4..1ee50a5 100644 (file)
@@ -55,7 +55,8 @@ Module::Module ( const Project& project,
                  const string& modulePath )\r
        : project (project),\r
          node (moduleNode),\r
-         importLibrary (NULL)\r
+         importLibrary (NULL),\r
+         bootstrap (NULL)\r
 {\r
        if ( node.name != "module" )\r
                throw Exception ( "internal tool error: Module created with non-<module> node" );\r
@@ -261,6 +262,11 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
                        e.location,\r
                        "<property> is not a valid sub-element of <module>" );\r
        }\r
+       else if ( e.name == "bootstrap" )\r
+       {\r
+               bootstrap = new Bootstrap ( project, this, e );\r
+               subs_invalid = true;\r
+       }\r
        if ( subs_invalid && e.subElements.size() > 0 )\r
                throw InvalidBuildFileException (\r
                        e.location,\r
index 99d624f..4d8572a 100644 (file)
@@ -51,6 +51,7 @@ class CompilerFlag;
 class LinkerFlag;\r
 class Property;\r
 class AutomaticDependency;\r
+class Bootstrap;\r
 \r
 class SourceFileTest;\r
 \r
@@ -127,6 +128,7 @@ public:
        ModuleType type;\r
        ImportLibrary* importLibrary;\r
        bool mangledSymbols;\r
+       Bootstrap* bootstrap;\r
        std::vector<File*> files;\r
        std::vector<Library*> libraries;\r
        std::vector<Include*> includes;\r
@@ -450,6 +452,26 @@ private:
 };\r
 \r
 \r
+class Bootstrap\r
+{\r
+public:\r
+       const Project& project;\r
+       const Module* module;\r
+       const XMLElement& node;\r
+       std::string base;\r
+       std::string nameoncd;\r
+\r
+       Bootstrap ( const Project& project,\r
+                   const Module* module,\r
+                   const XMLElement& bootstrapNode );\r
+       ~Bootstrap ();\r
+       void ProcessXML();\r
+private:\r
+       bool IsSupportedModuleType ( ModuleType type );\r
+       void Initialize();\r
+};\r
+\r
+\r
 extern std::string\r
 FixSeparator ( const std::string& s );\r
 \r
index 121622c..a5dcc76 100644 (file)
@@ -123,7 +123,7 @@ Value:
        None.\r
 \r
 Elements:\r
-       define, dependency, directory, file, if, importlibrary, include, invoke, library, property.\r
+       bootstrap, define, dependency, directory, file, if, importlibrary, include, invoke, library, property.\r
 \r
 \r
 Module types\r
@@ -143,6 +143,24 @@ The module type determines the actions that is to be carried out to process the
        iso - Builds a bootable CD. The entrypoint, baseaddress, and mangledsymbols module attributes are not applicable for this module type.\r
 \r
 \r
+Bootstrap element\r
+-----------------\r
+A bootstrap element specifies that the generated file should be put on the bootable CD as a bootstrap file.\r
+\r
+Syntax:\r
+       <bootstrap base="reactos" nameoncd="halmp.dll" />\r
+\r
+Attributes:\r
+       base - Put file in this directory on the bootable CD. This attribute is optional.\r
+       nameoncd - Name of file on the bootable CD. This attribute is optional.\r
+\r
+Value:\r
+       None.\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