From 19fa7f20af304229d9ec70f3ca2d5a0f9505d04d Mon Sep 17 00:00:00 2001 From: Casper Hornstrup Date: Mon, 4 Apr 2005 20:50:55 +0000 Subject: [PATCH] Support installation of generated files svn path=/branches/xmlbuildsystem/; revision=14488 --- reactos/tools/rbuild/backend/mingw/mingw.cpp | 135 ++++++++++-------- reactos/tools/rbuild/backend/mingw/mingw.h | 9 +- .../rbuild/backend/mingw/modulehandler.cpp | 2 +- reactos/tools/rbuild/module.cpp | 16 ++- reactos/tools/rbuild/rbuild.h | 2 + reactos/tools/rbuild/rbuild.txt | 4 +- reactos/tools/rbuild/tests/data/module.xml | 2 +- reactos/tools/rbuild/tests/moduletest.cpp | 4 + 8 files changed, 107 insertions(+), 67 deletions(-) diff --git a/reactos/tools/rbuild/backend/mingw/mingw.cpp b/reactos/tools/rbuild/backend/mingw/mingw.cpp index b8d43cee7fe..bd50e0238d4 100644 --- a/reactos/tools/rbuild/backend/mingw/mingw.cpp +++ b/reactos/tools/rbuild/backend/mingw/mingw.cpp @@ -614,47 +614,6 @@ MingwBackend::DetectPCHSupport () // allow that to override use_pch if true } -string -MingwBackend::GetNonModuleInstallDirectories ( const string& installDirectory ) -{ - string directories; - for ( size_t i = 0; i < ProjectNode.installfiles.size (); i++ ) - { - const InstallFile& installfile = *ProjectNode.installfiles[i]; - string targetDirectory ( installDirectory + SSEP + installfile.base ); - if ( directories.size () > 0 ) - directories += " "; - directories += MingwModuleHandler::PassThruCacheDirectory ( - FixupTargetFilename ( targetDirectory ), - true ); - } - return directories; -} - -string -MingwBackend::GetInstallDirectories ( const string& installDirectory ) -{ - return GetNonModuleInstallDirectories ( installDirectory ); -} - -void -MingwBackend::GetNonModuleInstallFiles ( - vector& out ) const -{ - for ( size_t i = 0; i < ProjectNode.installfiles.size (); i++ ) - { - const InstallFile& installfile = *ProjectNode.installfiles[i]; - out.push_back ( NormalizeFilename ( installfile.GetPath () ) ); - } -} - -void -MingwBackend::GetInstallFiles ( - vector& out ) const -{ - GetNonModuleInstallFiles ( out ); -} - void MingwBackend::GetNonModuleInstallTargetFiles ( string installDirectory, @@ -665,12 +624,31 @@ MingwBackend::GetNonModuleInstallTargetFiles ( const InstallFile& installfile = *ProjectNode.installfiles[i]; string targetFilenameNoFixup = installDirectory + SSEP + installfile.base + SSEP + installfile.newname; string targetFilename = MingwModuleHandler::PassThruCacheDirectory ( - FixupTargetFilename ( targetFilenameNoFixup ), + NormalizeFilename ( targetFilenameNoFixup ), true ); out.push_back ( targetFilename ); } } +void +MingwBackend::GetModuleInstallTargetFiles ( + string installDirectory, + vector& out ) const +{ + for ( size_t i = 0; i < ProjectNode.modules.size (); i++ ) + { + const Module& module = *ProjectNode.modules[i]; + if ( module.installName.length () > 0 ) + { + string targetFilenameNoFixup = installDirectory + SSEP + module.installBase + SSEP + module.installName; + string targetFilename = MingwModuleHandler::PassThruCacheDirectory ( + NormalizeFilename ( targetFilenameNoFixup ), + true ); + out.push_back ( targetFilename ); + } + } +} + void MingwBackend::GetInstallTargetFiles ( string installDirectory, @@ -678,32 +656,64 @@ MingwBackend::GetInstallTargetFiles ( { GetNonModuleInstallTargetFiles ( installDirectory, out ); + GetModuleInstallTargetFiles ( installDirectory, + out ); } void -MingwBackend::OutputInstallfileTargets ( const string& installDirectory ) +MingwBackend::OutputInstallTarget ( const string& installDirectory, + const string& sourceFilename, + const string& targetFilename, + const string& targetDirectory ) +{ + string normalizedTargetFilename = MingwModuleHandler::PassThruCacheDirectory ( + NormalizeFilename ( installDirectory + SSEP + targetDirectory + SSEP + targetFilename ), + true ); + string normalizedTargetDirectory = MingwModuleHandler::PassThruCacheDirectory ( + NormalizeFilename ( installDirectory + SSEP + targetDirectory ), + true ); + fprintf ( fMakefile, + "%s: %s %s\n", + normalizedTargetFilename.c_str (), + sourceFilename.c_str (), + normalizedTargetDirectory.c_str () ); + fprintf ( fMakefile, + "\t$(ECHO_CP)\n" ); + fprintf ( fMakefile, + "\t${cp} %s %s\n", + sourceFilename.c_str (), + normalizedTargetFilename.c_str () ); +} + +void +MingwBackend::OutputNonModuleInstallTargets ( const string& installDirectory ) { for ( size_t i = 0; i < ProjectNode.installfiles.size (); i++ ) { const InstallFile& installfile = *ProjectNode.installfiles[i]; - string targetFilenameNoFixup = installDirectory + SSEP + installfile.base + SSEP + installfile.newname; - string targetFilename = MingwModuleHandler::PassThruCacheDirectory ( - FixupTargetFilename ( targetFilenameNoFixup ), - true ); - string targetDirectory = MingwModuleHandler::PassThruCacheDirectory ( - FixupTargetFilename ( installDirectory + SSEP + installfile.base ), - true ); - fprintf ( fMakefile, - "%s: %s %s\n", - targetFilename.c_str (), - installfile.GetPath ().c_str (), - targetDirectory.c_str () ); - fprintf ( fMakefile, - "\t$(ECHO_CP)\n" ); - fprintf ( fMakefile, - "\t${cp} %s %s\n", - installfile.GetPath ().c_str (), - targetFilename.c_str () ); + OutputInstallTarget ( installDirectory, + installfile.GetPath (), + installfile.newname, + installfile.base ); + } +} + +void +MingwBackend::OutputModuleInstallTargets ( const string& installDirectory ) +{ + for ( size_t i = 0; i < ProjectNode.modules.size (); i++ ) + { + const Module& module = *ProjectNode.modules[i]; + if ( module.installName.length () > 0 ) + { + string sourceFilename = MingwModuleHandler::PassThruCacheDirectory ( + NormalizeFilename ( module.GetPath () ), + true ); + OutputInstallTarget ( installDirectory, + sourceFilename, + module.installName, + module.installBase ); + } } } @@ -723,7 +733,8 @@ MingwBackend::GenerateInstallTarget () "install: %s %s\n", installDirectory.c_str (), installTargetFiles.c_str () ); - OutputInstallfileTargets ( installDirectoryNoFixup ); + OutputNonModuleInstallTargets ( installDirectoryNoFixup ); + OutputModuleInstallTargets ( installDirectoryNoFixup ); fprintf ( fMakefile, "\n" ); } diff --git a/reactos/tools/rbuild/backend/mingw/mingw.h b/reactos/tools/rbuild/backend/mingw/mingw.h index 48b0ab857fc..d8581b4f5a4 100644 --- a/reactos/tools/rbuild/backend/mingw/mingw.h +++ b/reactos/tools/rbuild/backend/mingw/mingw.h @@ -50,9 +50,16 @@ private: void GetInstallFiles ( std::vector& out ) const; void GetNonModuleInstallTargetFiles ( std::string installDirectory, std::vector& out ) const; + void GetModuleInstallTargetFiles ( std::string installDirectory, + std::vector& out ) const; void GetInstallTargetFiles ( std::string installDirectory, std::vector& out ) const; - void OutputInstallfileTargets ( const std::string& installDirectory ); + void OutputInstallTarget ( const std::string& installDirectory, + const std::string& sourceFilename, + const std::string& targetFilename, + const std::string& targetDirectory ); + void OutputNonModuleInstallTargets ( const std::string& installDirectory ); + void OutputModuleInstallTargets ( const std::string& installDirectory ); void GenerateInstallTarget (); FILE* fMakefile; bool use_pch; diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp index 3024d10b24a..86eeaf536d2 100644 --- a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp +++ b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp @@ -97,7 +97,7 @@ MingwModuleHandler::RemoveVariables ( string path) } return path; } - + /*static*/ string MingwModuleHandler::PassThruCacheDirectory ( const string &file, bool out ) diff --git a/reactos/tools/rbuild/module.cpp b/reactos/tools/rbuild/module.cpp index 702dc23dcb6..0efd4d57527 100644 --- a/reactos/tools/rbuild/module.cpp +++ b/reactos/tools/rbuild/module.cpp @@ -133,7 +133,9 @@ Module::Module ( const Project& project, host (HostDefault) { if ( node.name != "module" ) - throw Exception ( "internal tool error: Module created with non- node" ); + throw InvalidOperationException ( __FILE__, + __LINE__, + "Module created with non- node" ); path = FixSeparator ( modulePath ); @@ -202,6 +204,18 @@ Module::Module ( const Project& project, att = moduleNode.GetAttribute ( "prefix", false ); if ( att != NULL ) prefix = att->value; + + att = moduleNode.GetAttribute ( "installbase", false ); + if ( att != NULL ) + installBase = att->value; + else + installBase = ""; + + att = moduleNode.GetAttribute ( "installname", false ); + if ( att != NULL ) + installName = att->value; + else + installName = ""; } Module::~Module () diff --git a/reactos/tools/rbuild/rbuild.h b/reactos/tools/rbuild/rbuild.h index 0a1949eed64..aa3f185e175 100644 --- a/reactos/tools/rbuild/rbuild.h +++ b/reactos/tools/rbuild/rbuild.h @@ -171,6 +171,8 @@ public: bool cplusplus; std::string prefix; HostType host; + std::string installBase; + std::string installName; Module ( const Project& project, const XMLElement& moduleNode, diff --git a/reactos/tools/rbuild/rbuild.txt b/reactos/tools/rbuild/rbuild.txt index 9e90c9aec79..9bd140c5b7c 100644 --- a/reactos/tools/rbuild/rbuild.txt +++ b/reactos/tools/rbuild/rbuild.txt @@ -107,7 +107,7 @@ Module element There can be zero or more modules per xml build file. Syntax: - + ... @@ -118,6 +118,8 @@ Attributes: entrypoint - Entrypoint symbol of the generated file if such file is generated for the particular module type. baseaddress - Base address of the generated file if such file is generated for the particular module type. mangledsymbols - Controls wether or not to pass --kill-at to dlltool. If this attribute has the value false then --kill-at is passed to dlltool. If the value is true, then --kill-at is not passed to dlltool. If the generated file exports C++ classes then this need to be true. + installbase - Base directory of the generated file in the installation directory. This attribute is optional. + installname - Name of generated file in the installation directory. This attribute is optional, but if not specified, the generated file is not copied to the installation directory. Value: None. diff --git a/reactos/tools/rbuild/tests/data/module.xml b/reactos/tools/rbuild/tests/data/module.xml index bea8d7d2431..6e72aad37be 100644 --- a/reactos/tools/rbuild/tests/data/module.xml +++ b/reactos/tools/rbuild/tests/data/module.xml @@ -7,7 +7,7 @@ - + module1 module1 file3.c diff --git a/reactos/tools/rbuild/tests/moduletest.cpp b/reactos/tools/rbuild/tests/moduletest.cpp index 3b8d77d4966..01313e9364a 100644 --- a/reactos/tools/rbuild/tests/moduletest.cpp +++ b/reactos/tools/rbuild/tests/moduletest.cpp @@ -10,6 +10,7 @@ void ModuleTest::Run() Module& module1 = *project.modules[0]; IS_TRUE(module1.type == BuildTool); + ARE_EQUAL(2, module1.non_if_data.files.size()); 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); @@ -18,6 +19,9 @@ void ModuleTest::Run() Module& module2 = *project.modules[1]; IS_TRUE(module2.type == KernelModeDLL); + ARE_EQUAL("reactos", module2.installBase); + ARE_EQUAL("module2.ext", module2.installName); + ARE_EQUAL(2, module2.non_if_data.files.size()); 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);