diff options
author | Geoff Viola <geoffrey.viola@asirobots.com> | 2016-04-24 19:47:48 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-04-25 14:46:09 (GMT) |
commit | 1703a6d2c46cc7981dd80bd18d7c2e82ec5d9f82 (patch) | |
tree | 5b839beb4d5ca5aeaccccd4c42ea623a629e9470 /Source | |
parent | 657a446175c1b61999a77958c5b7480f8be041a5 (diff) | |
download | CMake-1703a6d2c46cc7981dd80bd18d7c2e82ec5d9f82.zip CMake-1703a6d2c46cc7981dd80bd18d7c2e82ec5d9f82.tar.gz CMake-1703a6d2c46cc7981dd80bd18d7c2e82ec5d9f82.tar.bz2 |
GHS: Fix handling of duplicate source filenames (#16046)
Green Hills MULTI project files must specify explicitly distinct object
file names for source files with the same name.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGhsMultiTargetGenerator.cxx | 42 | ||||
-rw-r--r-- | Source/cmGhsMultiTargetGenerator.h | 2 |
2 files changed, 44 insertions, 0 deletions
diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index 1f17f8f..12e2eee 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -481,9 +481,46 @@ void cmGhsMultiTargetGenerator::WriteCustomCommandsHelper( } } +std::map<const cmSourceFile *, std::string> +cmGhsMultiTargetGenerator::GetObjectNames( + const std::vector<cmSourceFile *> &objectSources) +{ + bool found_duplicate = false; + std::set<std::string> filenames; + for(std::vector<cmSourceFile *>::const_iterator + sf = objectSources.begin(); sf != objectSources.end(); ++sf) + { + const std::string filename = + cmSystemTools::GetFilenameName((*sf)->GetFullPath()); + const std::string lower_filename = cmSystemTools::LowerCase(filename); + if (filenames.end() != filenames.find(lower_filename)) + { + found_duplicate = true; + } + filenames.insert(lower_filename); + } + + std::map<const cmSourceFile *, std::string> objectNames; + if (found_duplicate) + { + for(std::vector<cmSourceFile *>::const_iterator + sf = objectSources.begin(); sf != objectSources.end(); ++sf) + { + std::string full_filename = (*sf)->GetFullPath(); + cmsys::SystemTools::ReplaceString(full_filename, ":/", "_"); + cmsys::SystemTools::ReplaceString(full_filename, "/", "_"); + objectNames[*sf] = full_filename; + } + } + + return objectNames; +} + void cmGhsMultiTargetGenerator::WriteSources( std::vector<cmSourceFile *> const &objectSources) { + std::map<const cmSourceFile *, std::string> objectNames = + cmGhsMultiTargetGenerator::GetObjectNames(objectSources); for (std::vector<cmSourceFile *>::const_iterator si = objectSources.begin(); si != objectSources.end(); ++si) { @@ -515,6 +552,11 @@ void cmGhsMultiTargetGenerator::WriteSources( "bsp" != (*si)->GetExtension()) { this->WriteObjectLangOverride(this->FolderBuildStreams[sgPath], (*si)); + if (objectNames.end() != objectNames.find(*si)) + { + *this->FolderBuildStreams[sgPath] << " -o \"" << + objectNames.find(*si)->second << ".o\"" << std::endl; + } this->WriteObjectDir(this->FolderBuildStreams[sgPath], this->AbsBuildFilePath + sgPath); diff --git a/Source/cmGhsMultiTargetGenerator.h b/Source/cmGhsMultiTargetGenerator.h index e85e412..3a13600 100644 --- a/Source/cmGhsMultiTargetGenerator.h +++ b/Source/cmGhsMultiTargetGenerator.h @@ -88,6 +88,8 @@ private: WriteCustomCommandsHelper(std::vector<cmCustomCommand> const &commandsSet, cmTarget::CustomCommandType commandType); void WriteSources(std::vector<cmSourceFile *> const &objectSources); + static std::map<const cmSourceFile *, std::string> + GetObjectNames(const std::vector<cmSourceFile *> &objectSources); static void WriteObjectLangOverride(cmGeneratedFileStream *fileStream, cmSourceFile *sourceFile); static void WriteObjectDir(cmGeneratedFileStream *fileStream, |