From: Casper Hornstrup Date: Thu, 3 Mar 2005 21:00:30 +0000 (+0000) Subject: Support for copying non-generated files to cd X-Git-Tag: backups/xmlbuildsystem@15601~215 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=6125e670038f9526ce248d18fa9533090493c3ff Support for copying non-generated files to cd svn path=/branches/xmlbuildsystem/; revision=13807 --- diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp index a9e7dde893d..f8f254815c6 100644 --- a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp +++ b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp @@ -1970,9 +1970,25 @@ MingwIsoModuleHandler::OutputBootstrapfileCopyCommands ( const string bootcdDire } } +void +MingwIsoModuleHandler::OutputCdfileCopyCommands ( const string bootcdDirectory, + const Module& module ) const +{ + for ( size_t i = 0; i < module.project.cdfiles.size (); i++ ) + { + const CDFile& cdfile = *module.project.cdfiles[i]; + string targetFilenameNoFixup = bootcdDirectory + SSEP + cdfile.base + SSEP + cdfile.nameoncd; + string targetFilename = PassThruCacheDirectory ( FixupTargetFilename ( targetFilenameNoFixup ) ); + fprintf ( fMakefile, + "\t${cp} %s %s\n", + cdfile.GetPath ().c_str (), + targetFilename.c_str () ); + } +} + string -MingwIsoModuleHandler::GetCdDirectories ( const string bootcdDirectory, - const Module& module ) const +MingwIsoModuleHandler::GetBootstrapCdDirectories ( const string bootcdDirectory, + const Module& module ) const { string directories; for ( size_t i = 0; i < module.project.modules.size (); i++ ) @@ -1990,21 +2006,74 @@ MingwIsoModuleHandler::GetCdDirectories ( const string bootcdDirectory, } string -MingwIsoModuleHandler::GetCdFiles ( const string bootcdDirectory, - const Module& module ) const +MingwIsoModuleHandler::GetNonModuleCdDirectories ( const string bootcdDirectory, + const Module& module ) const +{ + string directories; + for ( size_t i = 0; i < module.project.cdfiles.size (); i++ ) + { + const CDFile& cdfile = *module.project.cdfiles[i]; + string targetDirecctory = bootcdDirectory + SSEP + cdfile.base; + if ( directories.size () > 0 ) + directories += " "; + directories += FixupTargetFilename ( targetDirecctory ); + } + return directories; +} + +string +MingwIsoModuleHandler::GetCdDirectories ( const string bootcdDirectory, + const Module& module ) const +{ + string directories = GetBootstrapCdDirectories ( bootcdDirectory, + module ); + directories += " " + GetNonModuleCdDirectories ( bootcdDirectory, + module ); + return directories; +} + +string +MingwIsoModuleHandler::GetBootstrapCdFiles ( const string bootcdDirectory, + const Module& module ) const { - string files; + string cdfiles; for ( size_t i = 0; i < module.project.modules.size (); i++ ) { const Module& m = *module.project.modules[i]; if ( m.bootstrap != NULL ) { - if ( files.size () > 0 ) - files += " "; - files += FixupTargetFilename ( m.GetPath () ); + if ( cdfiles.size () > 0 ) + cdfiles += " "; + cdfiles += FixupTargetFilename ( m.GetPath () ); } } - return files; + return cdfiles; +} + +string +MingwIsoModuleHandler::GetNonModuleCdFiles ( const string bootcdDirectory, + const Module& module ) const +{ + string cdfiles; + for ( size_t i = 0; i < module.project.cdfiles.size (); i++ ) + { + const CDFile& cdfile = *module.project.cdfiles[i]; + if ( cdfiles.size () > 0 ) + cdfiles += " "; + cdfiles += NormalizeFilename ( cdfile.GetPath () ); + } + return cdfiles; +} + +string +MingwIsoModuleHandler::GetCdFiles ( const string bootcdDirectory, + const Module& module ) const +{ + string cdfiles = GetBootstrapCdFiles ( bootcdDirectory, + module ); + cdfiles += " " + GetNonModuleCdFiles ( bootcdDirectory, + module ); + return cdfiles; } void @@ -2044,6 +2113,8 @@ MingwIsoModuleHandler::GenerateIsoModuleTarget ( const Module& module ) reactosInf.c_str () ); OutputBootstrapfileCopyCommands ( bootcdDirectory, module ); + OutputCdfileCopyCommands ( bootcdDirectory, + module ); fprintf ( fMakefile, "\t${cdmake} -v -m -b %s %s REACTOS ReactOS.iso\n", isoboot.c_str (), diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.h b/reactos/tools/rbuild/backend/mingw/modulehandler.h index 37bb9a1eeeb..c1eb8e51eca 100644 --- a/reactos/tools/rbuild/backend/mingw/modulehandler.h +++ b/reactos/tools/rbuild/backend/mingw/modulehandler.h @@ -291,12 +291,22 @@ public: virtual void Process ( const Module& module ); private: void GenerateIsoModuleTarget ( const Module& module ); + std::string GetBootstrapCdDirectories ( const std::string bootcdDirectory, + const Module& module ) const; + std::string GetNonModuleCdDirectories ( const std::string bootcdDirectory, + const Module& module ) const; std::string GetCdDirectories ( const std::string bootcdDirectory, const Module& module ) const; + std::string GetBootstrapCdFiles ( const std::string bootcdDirectory, + const Module& module ) const; + std::string GetNonModuleCdFiles ( const std::string bootcdDirectory, + const Module& module ) const; std::string GetCdFiles ( const std::string bootcdDirectory, const Module& module ) const; void OutputBootstrapfileCopyCommands ( const std::string bootcdDirectory, const Module& module ) const; + void OutputCdfileCopyCommands ( const std::string bootcdDirectory, + const Module& module ) const; }; #endif /* MINGW_MODULEHANDLER_H */ diff --git a/reactos/tools/rbuild/cdfile.cpp b/reactos/tools/rbuild/cdfile.cpp new file mode 100644 index 00000000000..d11fe75332f --- /dev/null +++ b/reactos/tools/rbuild/cdfile.cpp @@ -0,0 +1,42 @@ +#include "pch.h" +#include + +#include "rbuild.h" + +using std::string; + +CDFile::CDFile ( const Project& project_, + const XMLElement& cdfileNode, + const string& path ) + : project ( project_ ), + node ( cdfileNode ) +{ + const XMLAttribute* att = node.GetAttribute ( "base", false ); + if ( att != NULL ) + base = att->value; + else + base = ""; + + att = node.GetAttribute ( "nameoncd", false ); + if ( att != NULL ) + nameoncd = att->value; + else + nameoncd = node.value; + name = node.value; + this->path = path; +} + +CDFile::~CDFile () +{ +} + +string +CDFile::GetPath () const +{ + return path + SSEP + name; +} + +void +CDFile::ProcessXML() +{ +} diff --git a/reactos/tools/rbuild/makefile b/reactos/tools/rbuild/makefile index 5a0fb31cbf8..dfb1981a1e3 100644 --- a/reactos/tools/rbuild/makefile +++ b/reactos/tools/rbuild/makefile @@ -22,6 +22,7 @@ RBUILD_BASE_SOURCES = \ $(RBUILD_BACKEND_BASE_SOURCES) \ automaticdependency.cpp \ bootstrap.cpp \ + cdfile.cpp \ compilerflag.cpp \ define.cpp \ exception.cpp \ @@ -61,7 +62,8 @@ RBUILD_TESTS = \ tests$(SEP)linkerflagtest.cpp \ tests$(SEP)moduletest.cpp \ tests$(SEP)projecttest.cpp \ - tests$(SEP)sourcefiletest.cpp + tests$(SEP)sourcefiletest.cpp \ + tests$(SEP)cdfiletest.cpp RBUILD_TEST_SPECIAL_SOURCES = \ $(addprefix $(RBUILD_BASE)$(SEP), $(RBUILD_TESTS)) \ diff --git a/reactos/tools/rbuild/project.cpp b/reactos/tools/rbuild/project.cpp index 9800323838e..50b4d2287ef 100644 --- a/reactos/tools/rbuild/project.cpp +++ b/reactos/tools/rbuild/project.cpp @@ -30,6 +30,8 @@ Project::~Project () delete properties[i]; for ( i = 0; i < ifs.size (); i++ ) delete ifs[i]; + for ( i = 0; i < cdfiles.size (); i++ ) + delete cdfiles[i]; delete head; } @@ -216,26 +218,28 @@ Project::ProcessXML ( const string& path ) makefile = att->value; size_t i; - for ( i = 0; i < node->subElements.size(); i++ ) + for ( i = 0; i < node->subElements.size (); i++ ) ProcessXMLSubElement ( *node->subElements[i], path ); - for ( i = 0; i < modules.size(); i++ ) - modules[i]->ProcessXML(); - for ( i = 0; i < includes.size(); i++ ) - includes[i]->ProcessXML(); - for ( i = 0; i < defines.size(); i++ ) - defines[i]->ProcessXML(); - for ( i = 0; i < linkerFlags.size(); i++ ) - linkerFlags[i]->ProcessXML(); + for ( i = 0; i < modules.size (); i++ ) + modules[i]->ProcessXML (); + for ( i = 0; i < includes.size (); i++ ) + includes[i]->ProcessXML (); + for ( i = 0; i < defines.size (); i++ ) + defines[i]->ProcessXML (); + for ( i = 0; i < linkerFlags.size (); i++ ) + linkerFlags[i]->ProcessXML (); for ( i = 0; i < properties.size(); i++ ) - properties[i]->ProcessXML(); - for ( i = 0; i < ifs.size(); i++ ) - ifs[i]->ProcessXML(); + properties[i]->ProcessXML (); + for ( i = 0; i < ifs.size (); i++ ) + ifs[i]->ProcessXML (); + for ( i = 0; i < cdfiles.size (); i++ ) + ifs[i]->ProcessXML (); } void Project::ProcessXMLSubElement ( const XMLElement& e, const string& path, - If* pIf /*= NULL*/ ) + If* pIf ) { bool subs_invalid = false; string subpath(path); @@ -255,6 +259,12 @@ Project::ProcessXMLSubElement ( const XMLElement& e, modules.push_back ( module ); return; // defer processing until later } + else if ( e.name == "cdfile" ) + { + CDFile* cdfile = new CDFile ( *this, e, path ); + cdfiles.push_back ( cdfile ); + subs_invalid = true; + } else if ( e.name == "directory" ) { const XMLAttribute* att = e.GetAttribute ( "name", true ); diff --git a/reactos/tools/rbuild/rbuild.h b/reactos/tools/rbuild/rbuild.h index 4d8572aec46..fd38de8472c 100644 --- a/reactos/tools/rbuild/rbuild.h +++ b/reactos/tools/rbuild/rbuild.h @@ -52,6 +52,7 @@ class LinkerFlag; class Property; class AutomaticDependency; class Bootstrap; +class CDFile; class SourceFileTest; @@ -68,6 +69,7 @@ public: std::vector linkerFlags; std::vector properties; std::vector ifs; + std::vector cdfiles; Project ( const std::string& filename ); ~Project (); @@ -472,6 +474,25 @@ private: }; +class CDFile +{ +public: + const Project& project; + const XMLElement& node; + std::string name; + std::string base; + std::string nameoncd; + std::string path; + + CDFile ( const Project& project, + const XMLElement& bootstrapNode, + const std::string& path ); + ~CDFile (); + void ProcessXML(); + std::string GetPath () const; +}; + + extern std::string FixSeparator ( const std::string& s ); diff --git a/reactos/tools/rbuild/rbuild.txt b/reactos/tools/rbuild/rbuild.txt index a5dcc762e81..74ae80676a9 100644 --- a/reactos/tools/rbuild/rbuild.txt +++ b/reactos/tools/rbuild/rbuild.txt @@ -161,6 +161,24 @@ Elements: None. +CDFile element +-------------- +A cdfile element specifies the name of a file that is to be put on the bootable CD. + +Syntax: + ReadMe.txt + +Attributes: + base - Put file in this directory on the bootable CD. This attribute is optional. + nameoncd - Name of file on the bootable CD. This attribute is optional. + +Value: + Name of file. + +Elements: + None. + + Define element -------------- A define element specifies the name and (optionally) value of a define for the C/C++ compiler and resource compiler. @@ -211,7 +229,7 @@ Value: None. Elements: - directory, file, if, property. + cdfile, directory, file, if, property. File element diff --git a/reactos/tools/rbuild/test.h b/reactos/tools/rbuild/test.h index fe5becc09a8..a18d22338b7 100644 --- a/reactos/tools/rbuild/test.h +++ b/reactos/tools/rbuild/test.h @@ -4,6 +4,8 @@ #include "rbuild.h" #include "backend/mingw/mingw.h" +#define RBUILD_BASE "tools" SSEP "rbuild" SSEP + class BaseTest { public: @@ -117,4 +119,11 @@ private: }; + +class CDFileTest : public BaseTest +{ +public: + void Run (); +}; + #endif /* __TEST_H */ diff --git a/reactos/tools/rbuild/tests/alltests.cpp b/reactos/tools/rbuild/tests/alltests.cpp index 228141aa0f6..48a538f7530 100644 --- a/reactos/tools/rbuild/tests/alltests.cpp +++ b/reactos/tools/rbuild/tests/alltests.cpp @@ -178,6 +178,7 @@ private: tests.push_back(new IfTest()); tests.push_back(new FunctionTest()); tests.push_back(new SourceFileTest()); + tests.push_back(new CDFileTest()); } }; diff --git a/reactos/tools/rbuild/tests/cdfiletest.cpp b/reactos/tools/rbuild/tests/cdfiletest.cpp new file mode 100644 index 00000000000..717209924f6 --- /dev/null +++ b/reactos/tools/rbuild/tests/cdfiletest.cpp @@ -0,0 +1,22 @@ +#include "test.h" + +using std::string; + +void CDFileTest::Run() +{ + string projectFilename ( RBUILD_BASE "tests/data/cdfile.xml" ); + Project project( projectFilename ); + ARE_EQUAL ( 3, project.cdfiles.size () ); + + CDFile& cdfile1 = *project.cdfiles[0]; + ARE_EQUAL("dir1", cdfile1.base); + ARE_EQUAL("ReadMe1.txt", cdfile1.nameoncd); + + CDFile& cdfile2 = *project.cdfiles[1]; + ARE_EQUAL("dir2", cdfile2.base); + ARE_EQUAL("readme2.txt", cdfile2.nameoncd); + + CDFile& cdfile3 = *project.cdfiles[2]; + //ARE_EQUAL("", cdfile3.base); + ARE_EQUAL("readme3.txt", cdfile3.nameoncd); +} diff --git a/reactos/tools/rbuild/tests/data/automaticdependency.xml b/reactos/tools/rbuild/tests/data/automaticdependency.xml index 646dc5225c7..6fa14b1adbf 100644 --- a/reactos/tools/rbuild/tests/data/automaticdependency.xml +++ b/reactos/tools/rbuild/tests/data/automaticdependency.xml @@ -1,11 +1,15 @@ - - - - . - sourcefile1.c - + + + + + + . + sourcefile1.c + + + diff --git a/reactos/tools/rbuild/tests/data/automaticdependency_include.xml b/reactos/tools/rbuild/tests/data/automaticdependency_include.xml index 8dcf7205039..de713cf9d31 100644 --- a/reactos/tools/rbuild/tests/data/automaticdependency_include.xml +++ b/reactos/tools/rbuild/tests/data/automaticdependency_include.xml @@ -1,12 +1,16 @@ - - - - . - sourcefile1 - sourcefile_include.c - + + + + + + . + sourcefile1 + sourcefile_include.c + + + diff --git a/reactos/tools/rbuild/tests/data/cdfile.xml b/reactos/tools/rbuild/tests/data/cdfile.xml new file mode 100644 index 00000000000..ef69d76d3f7 --- /dev/null +++ b/reactos/tools/rbuild/tests/data/cdfile.xml @@ -0,0 +1,8 @@ + + + + readme1.txt + readme2.txt + readme3.txt + + diff --git a/reactos/tools/rbuild/tests/definetest.cpp b/reactos/tools/rbuild/tests/definetest.cpp index ad0594640f1..a3688910867 100644 --- a/reactos/tools/rbuild/tests/definetest.cpp +++ b/reactos/tools/rbuild/tests/definetest.cpp @@ -4,7 +4,7 @@ using std::string; void DefineTest::Run() { - string projectFilename ( "tests/data/define.xml" ); + string projectFilename ( RBUILD_BASE "tests/data/define.xml" ); Project project ( projectFilename ); ARE_EQUAL(1, project.defines.size()); Define& define1 = *project.defines[0]; diff --git a/reactos/tools/rbuild/tests/iftest.cpp b/reactos/tools/rbuild/tests/iftest.cpp index 2f4133d7a06..adc82e326cb 100644 --- a/reactos/tools/rbuild/tests/iftest.cpp +++ b/reactos/tools/rbuild/tests/iftest.cpp @@ -4,7 +4,7 @@ using std::string; void IfTest::Run() { - string projectFilename ( "tests/data/if.xml" ); + string projectFilename ( RBUILD_BASE "tests/data/if.xml" ); Project project ( projectFilename ); ARE_EQUAL ( 1, project.modules.size () ); diff --git a/reactos/tools/rbuild/tests/includetest.cpp b/reactos/tools/rbuild/tests/includetest.cpp index aa6891ffca9..338bf21ad06 100644 --- a/reactos/tools/rbuild/tests/includetest.cpp +++ b/reactos/tools/rbuild/tests/includetest.cpp @@ -4,7 +4,7 @@ using std::string; void IncludeTest::Run() { - string projectFilename ( "tests/data/include.xml" ); + string projectFilename ( RBUILD_BASE "tests/data/include.xml" ); Project project ( projectFilename ); ARE_EQUAL(1, project.includes.size()); Include& include1 = *project.includes[0]; diff --git a/reactos/tools/rbuild/tests/invoketest.cpp b/reactos/tools/rbuild/tests/invoketest.cpp index bfefc6a3462..b129ac10f29 100644 --- a/reactos/tools/rbuild/tests/invoketest.cpp +++ b/reactos/tools/rbuild/tests/invoketest.cpp @@ -4,7 +4,7 @@ using std::string; void InvokeTest::Run() { - string projectFilename ( "tests/data/invoke.xml" ); + string projectFilename ( RBUILD_BASE "tests/data/invoke.xml" ); Project project ( projectFilename ); ARE_EQUAL(1, project.modules.size()); diff --git a/reactos/tools/rbuild/tests/linkerflagtest.cpp b/reactos/tools/rbuild/tests/linkerflagtest.cpp index 1445fa80851..4e804523aed 100644 --- a/reactos/tools/rbuild/tests/linkerflagtest.cpp +++ b/reactos/tools/rbuild/tests/linkerflagtest.cpp @@ -4,7 +4,7 @@ using std::string; void LinkerFlagTest::Run() { - string projectFilename ( "tests/data/linkerflag.xml" ); + string projectFilename ( RBUILD_BASE "tests/data/linkerflag.xml" ); Project project ( projectFilename ); ARE_EQUAL(1, project.linkerFlags.size()); LinkerFlag& linkerFlag1 = *project.linkerFlags[0]; diff --git a/reactos/tools/rbuild/tests/moduletest.cpp b/reactos/tools/rbuild/tests/moduletest.cpp index 42777d2038c..949f9225b42 100644 --- a/reactos/tools/rbuild/tests/moduletest.cpp +++ b/reactos/tools/rbuild/tests/moduletest.cpp @@ -4,7 +4,7 @@ using std::string; void ModuleTest::Run() { - string projectFilename ( "tests/data/module.xml" ); + string projectFilename ( RBUILD_BASE "tests/data/module.xml" ); Project project ( projectFilename ); ARE_EQUAL(2, project.modules.size()); diff --git a/reactos/tools/rbuild/tests/projecttest.cpp b/reactos/tools/rbuild/tests/projecttest.cpp index 6b66b8764d6..71d5b5481a6 100644 --- a/reactos/tools/rbuild/tests/projecttest.cpp +++ b/reactos/tools/rbuild/tests/projecttest.cpp @@ -4,7 +4,7 @@ using std::string; void ProjectTest::Run() { - string projectFilename ( "tests/data/project.xml" ); + string projectFilename ( RBUILD_BASE "tests/data/project.xml" ); Project project( projectFilename ); ARE_EQUAL(2, project.modules.size()); } diff --git a/reactos/tools/rbuild/tests/sourcefiletest.cpp b/reactos/tools/rbuild/tests/sourcefiletest.cpp index b67c961b9f4..2f5c9906ce9 100644 --- a/reactos/tools/rbuild/tests/sourcefiletest.cpp +++ b/reactos/tools/rbuild/tests/sourcefiletest.cpp @@ -34,26 +34,26 @@ SourceFileTest::IsParentOf ( const SourceFile* parent, void SourceFileTest::IncludeTest () { - const Project project ( "tests" SSEP "data" SSEP "automaticdependency_include.xml" ); + const Project project ( RBUILD_BASE "tests" SSEP "data" SSEP "automaticdependency_include.xml" ); AutomaticDependency automaticDependency ( project ); automaticDependency.Process (); ARE_EQUAL( 4, automaticDependency.sourcefile_map.size () ); - const SourceFile* include = automaticDependency.RetrieveFromCache ( "." SSEP "tests" SSEP "data" SSEP "sourcefile_include.h" ); + const SourceFile* include = automaticDependency.RetrieveFromCache ( "." SSEP RBUILD_BASE "tests" SSEP "data" SSEP "sourcefile_include.h" ); IS_NOT_NULL( include ); - const SourceFile* includenext = automaticDependency.RetrieveFromCache ( "." SSEP "tests" SSEP "data" SSEP "sourcefile1" SSEP "sourcefile_includenext.h" ); + const SourceFile* includenext = automaticDependency.RetrieveFromCache ( "." SSEP RBUILD_BASE "tests" SSEP "data" SSEP "sourcefile1" SSEP "sourcefile_includenext.h" ); IS_NOT_NULL( includenext ); } void SourceFileTest::FullParseTest () { - const Project project ( "tests" SSEP "data" SSEP "automaticdependency.xml" ); + const Project project ( RBUILD_BASE "tests" SSEP "data" SSEP "automaticdependency.xml" ); AutomaticDependency automaticDependency ( project ); automaticDependency.Process (); ARE_EQUAL( 5, automaticDependency.sourcefile_map.size () ); - const SourceFile* header1 = automaticDependency.RetrieveFromCache ( "." SSEP "tests" SSEP "data" SSEP "sourcefile1_header1.h" ); + const SourceFile* header1 = automaticDependency.RetrieveFromCache ( "." SSEP RBUILD_BASE "tests" SSEP "data" SSEP "sourcefile1_header1.h" ); IS_NOT_NULL( header1 ); - const SourceFile* recurse = automaticDependency.RetrieveFromCache ( "." SSEP "tests" SSEP "data" SSEP "sourcefile1_recurse.h" ); + const SourceFile* recurse = automaticDependency.RetrieveFromCache ( "." SSEP RBUILD_BASE"tests" SSEP "data" SSEP "sourcefile1_recurse.h" ); IS_NOT_NULL( recurse ); IS_TRUE( IsParentOf ( header1, recurse ) );