summaryrefslogtreecommitdiff
path: root/Source/cmGhsMultiTargetGenerator.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmGhsMultiTargetGenerator.cxx')
-rw-r--r--Source/cmGhsMultiTargetGenerator.cxx554
1 files changed, 239 insertions, 315 deletions
diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx
index 4ca59cb61a..325a86edbe 100644
--- a/Source/cmGhsMultiTargetGenerator.cxx
+++ b/Source/cmGhsMultiTargetGenerator.cxx
@@ -22,18 +22,17 @@
std::string const cmGhsMultiTargetGenerator::DDOption("-dynamic");
-cmGhsMultiTargetGenerator::cmGhsMultiTargetGenerator(cmGeneratorTarget *target)
+cmGhsMultiTargetGenerator::cmGhsMultiTargetGenerator(cmGeneratorTarget* target)
: GeneratorTarget(target)
- , LocalGenerator(static_cast<cmLocalGhsMultiGenerator *>(
- target->GetLocalGenerator()))
+ , LocalGenerator(
+ static_cast<cmLocalGhsMultiGenerator*>(target->GetLocalGenerator()))
, Makefile(target->Target->GetMakefile())
, TargetGroup(DetermineIfTargetGroup(target))
, DynamicDownload(false)
{
this->RelBuildFilePath = this->GetRelBuildFilePath(target);
- this->RelOutputFileName =
- this->RelBuildFilePath + target->GetName() + ".a";
+ this->RelOutputFileName = this->RelBuildFilePath + target->GetName() + ".a";
this->RelBuildFileName = this->RelBuildFilePath;
this->RelBuildFileName += this->GetBuildFileName(target);
@@ -50,50 +49,48 @@ cmGhsMultiTargetGenerator::~cmGhsMultiTargetGenerator()
cmDeleteAll(this->FolderBuildStreams);
}
-std::string
-cmGhsMultiTargetGenerator::GetRelBuildFilePath(
- const cmGeneratorTarget *target)
+std::string cmGhsMultiTargetGenerator::GetRelBuildFilePath(
+ const cmGeneratorTarget* target)
{
std::string output;
- char const *folderProp = target->GetProperty("FOLDER");
+ char const* folderProp = target->GetProperty("FOLDER");
output = NULL == folderProp ? "" : folderProp;
cmSystemTools::ConvertToUnixSlashes(output);
- if (!output.empty())
- {
+ if (!output.empty()) {
output += "/";
}
output += target->GetName() + "/";
return output;
}
-std::string
-cmGhsMultiTargetGenerator::GetAbsPathToRoot(const cmGeneratorTarget *target)
+std::string cmGhsMultiTargetGenerator::GetAbsPathToRoot(
+ const cmGeneratorTarget* target)
{
return target->GetLocalGenerator()->GetBinaryDirectory();
}
-std::string
-cmGhsMultiTargetGenerator::GetAbsBuildFilePath(const cmGeneratorTarget *target)
+std::string cmGhsMultiTargetGenerator::GetAbsBuildFilePath(
+ const cmGeneratorTarget* target)
{
std::string output;
output = cmGhsMultiTargetGenerator::GetAbsPathToRoot(target);
output = cmGhsMultiTargetGenerator::AddSlashIfNeededToPath(output);
output += cmGhsMultiTargetGenerator::GetRelBuildFilePath(target);
- return output;
+ return output;
}
-std::string
-cmGhsMultiTargetGenerator::GetRelBuildFileName(const cmGeneratorTarget *target)
+std::string cmGhsMultiTargetGenerator::GetRelBuildFileName(
+ const cmGeneratorTarget* target)
{
std::string output;
output = cmGhsMultiTargetGenerator::GetRelBuildFilePath(target);
output = cmGhsMultiTargetGenerator::AddSlashIfNeededToPath(output);
output += cmGhsMultiTargetGenerator::GetBuildFileName(target);
- return output;
+ return output;
}
-std::string
-cmGhsMultiTargetGenerator::GetBuildFileName(const cmGeneratorTarget *target)
+std::string cmGhsMultiTargetGenerator::GetBuildFileName(
+ const cmGeneratorTarget* target)
{
std::string output;
output = target->GetName();
@@ -101,44 +98,39 @@ cmGhsMultiTargetGenerator::GetBuildFileName(const cmGeneratorTarget *target)
return output;
}
-std::string
-cmGhsMultiTargetGenerator::AddSlashIfNeededToPath(std::string const &input)
+std::string cmGhsMultiTargetGenerator::AddSlashIfNeededToPath(
+ std::string const& input)
{
std::string output(input);
- if (!cmHasLiteralSuffix(output, "/"))
- {
+ if (!cmHasLiteralSuffix(output, "/")) {
output += "/";
- }
+ }
return output;
}
void cmGhsMultiTargetGenerator::Generate()
{
- std::vector<cmSourceFile *> objectSources = this->GetSources();
- if (!objectSources.empty() && this->IncludeThisTarget())
- {
- if (!cmSystemTools::FileExists(this->AbsBuildFilePath.c_str()))
- {
+ std::vector<cmSourceFile*> objectSources = this->GetSources();
+ if (!objectSources.empty() && this->IncludeThisTarget()) {
+ if (!cmSystemTools::FileExists(this->AbsBuildFilePath.c_str())) {
cmSystemTools::MakeDirectory(this->AbsBuildFilePath.c_str());
- }
+ }
cmGlobalGhsMultiGenerator::Open(std::string(""), this->AbsBuildFileName,
&this->FolderBuildStreams);
cmGlobalGhsMultiGenerator::OpenBuildFileStream(
this->GetFolderBuildStreams());
std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
- if (0 == config.length())
- {
+ if (0 == config.length()) {
config = "RELEASE";
- }
+ }
const std::string language(
- this->GeneratorTarget->GetLinkerLanguage(config));
+ this->GeneratorTarget->GetLinkerLanguage(config));
config = cmSystemTools::UpperCase(config);
this->DynamicDownload = this->DetermineIfDynamicDownload(config, language);
- if (this->DynamicDownload)
- {
+ if (this->DynamicDownload) {
*this->GetFolderBuildStreams() << "#component integrity_dynamic_download"
<< std::endl;
- }
+ }
GhsMultiGpj::WriteGpjTag(this->GetGpjTag(), this->GetFolderBuildStreams());
cmGlobalGhsMultiGenerator::WriteDisclaimer(this->GetFolderBuildStreams());
@@ -148,36 +140,34 @@ void cmGhsMultiTargetGenerator::Generate()
this->WriteCompilerFlags(config, language);
this->WriteCompilerDefinitions(config, language);
this->WriteIncludes(config, language);
- if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE)
- {
+ if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE) {
this->WriteTargetLinkLibraries(config, language);
- }
+ }
this->WriteCustomCommands();
- std::map<const cmSourceFile *, std::string> objectNames =
- cmGhsMultiTargetGenerator::GetObjectNames(
- &objectSources, this->LocalGenerator, this->GeneratorTarget);
+ std::map<const cmSourceFile*, std::string> objectNames =
+ cmGhsMultiTargetGenerator::GetObjectNames(
+ &objectSources, this->LocalGenerator, this->GeneratorTarget);
this->WriteSources(objectSources, objectNames);
- }
+ }
}
bool cmGhsMultiTargetGenerator::IncludeThisTarget()
{
bool output = true;
- char const *excludeFromAll =
- this->GeneratorTarget->GetProperty("EXCLUDE_FROM_ALL");
+ char const* excludeFromAll =
+ this->GeneratorTarget->GetProperty("EXCLUDE_FROM_ALL");
if (NULL != excludeFromAll && '1' == excludeFromAll[0] &&
- '\0' == excludeFromAll[1])
- {
+ '\0' == excludeFromAll[1]) {
output = false;
- }
+ }
return output;
}
-std::vector<cmSourceFile *> cmGhsMultiTargetGenerator::GetSources() const
+std::vector<cmSourceFile*> cmGhsMultiTargetGenerator::GetSources() const
{
- std::vector<cmSourceFile *> output;
+ std::vector<cmSourceFile*> output;
std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
this->GeneratorTarget->GetSourceFiles(output, config);
return output;
@@ -189,185 +179,157 @@ GhsMultiGpj::Types cmGhsMultiTargetGenerator::GetGpjTag() const
}
GhsMultiGpj::Types cmGhsMultiTargetGenerator::GetGpjTag(
- const cmGeneratorTarget *target)
+ const cmGeneratorTarget* target)
{
GhsMultiGpj::Types output;
- if (cmGhsMultiTargetGenerator::DetermineIfTargetGroup(target))
- {
+ if (cmGhsMultiTargetGenerator::DetermineIfTargetGroup(target)) {
output = GhsMultiGpj::INTERGRITY_APPLICATION;
- }
- else if (target->GetType() == cmState::STATIC_LIBRARY)
- {
+ } else if (target->GetType() == cmState::STATIC_LIBRARY) {
output = GhsMultiGpj::LIBRARY;
- }
- else
- {
+ } else {
output = GhsMultiGpj::PROGRAM;
- }
+ }
return output;
}
-cmGlobalGhsMultiGenerator*
-cmGhsMultiTargetGenerator::GetGlobalGenerator() const
+cmGlobalGhsMultiGenerator* cmGhsMultiTargetGenerator::GetGlobalGenerator()
+ const
{
- return static_cast<cmGlobalGhsMultiGenerator *>(
+ return static_cast<cmGlobalGhsMultiGenerator*>(
this->LocalGenerator->GetGlobalGenerator());
}
-void cmGhsMultiTargetGenerator::WriteTypeSpecifics(const std::string &config,
+void cmGhsMultiTargetGenerator::WriteTypeSpecifics(const std::string& config,
bool const notKernel)
{
std::string outputDir(this->GetOutputDirectory(config));
std::string outputFilename(this->GetOutputFilename(config));
- if (this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY)
- {
+ if (this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY) {
std::string const static_library_suffix =
this->Makefile->GetSafeDefinition("CMAKE_STATIC_LIBRARY_SUFFIX");
- *this->GetFolderBuildStreams() << " -o \""
- << outputDir << outputFilename
- << static_library_suffix << "\""
- << std::endl;
- }
- else if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE)
- {
- if (notKernel && !this->IsTargetGroup())
- {
+ *this->GetFolderBuildStreams() << " -o \"" << outputDir
+ << outputFilename << static_library_suffix
+ << "\"" << std::endl;
+ } else if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE) {
+ if (notKernel && !this->IsTargetGroup()) {
*this->GetFolderBuildStreams() << " -relprog" << std::endl;
- }
- if (this->IsTargetGroup())
- {
+ }
+ if (this->IsTargetGroup()) {
*this->GetFolderBuildStreams()
- << " -o \"" << outputDir
- << outputFilename << ".elf\"" << std::endl;
+ << " -o \"" << outputDir << outputFilename << ".elf\"" << std::endl;
*this->GetFolderBuildStreams() << " :extraOutputFile=\"" << outputDir
<< outputFilename << ".elf.ael\""
<< std::endl;
- }
- else
- {
+ } else {
std::string const executable_suffix =
this->Makefile->GetSafeDefinition("CMAKE_EXECUTABLE_SUFFIX");
- *this->GetFolderBuildStreams() << " -o \""
- << outputDir << outputFilename
- << executable_suffix << "\""
- << std::endl;
- }
+ *this->GetFolderBuildStreams() << " -o \"" << outputDir
+ << outputFilename << executable_suffix
+ << "\"" << std::endl;
}
+ }
}
-void cmGhsMultiTargetGenerator::SetCompilerFlags(std::string const &config,
- const std::string &language,
+void cmGhsMultiTargetGenerator::SetCompilerFlags(std::string const& config,
+ const std::string& language,
bool const notKernel)
{
std::map<std::string, std::string>::iterator i =
this->FlagsByLanguage.find(language);
- if (i == this->FlagsByLanguage.end())
- {
+ if (i == this->FlagsByLanguage.end()) {
std::string flags;
- const char *lang = language.c_str();
+ const char* lang = language.c_str();
- if (notKernel)
- {
+ if (notKernel) {
this->LocalGenerator->AddLanguageFlags(flags, lang, config);
- }
- else
- {
- this->LocalGenerator->AddLanguageFlags(
- flags, lang + std::string("_GHS_KERNEL"), config);
- }
- this->LocalGenerator->AddCMP0018Flags(flags, this->GeneratorTarget,
- lang, config);
- this->LocalGenerator->AddVisibilityPresetFlags(flags,
- this->GeneratorTarget,
- lang);
+ } else {
+ this->LocalGenerator->AddLanguageFlags(
+ flags, lang + std::string("_GHS_KERNEL"), config);
+ }
+ this->LocalGenerator->AddCMP0018Flags(flags, this->GeneratorTarget, lang,
+ config);
+ this->LocalGenerator->AddVisibilityPresetFlags(
+ flags, this->GeneratorTarget, lang);
// Append old-style preprocessor definition flags.
- if (std::string(" ") != std::string(this->Makefile->GetDefineFlags()))
- {
+ if (std::string(" ") != std::string(this->Makefile->GetDefineFlags())) {
this->LocalGenerator->AppendFlags(flags,
- this->Makefile->GetDefineFlags());
- }
+ this->Makefile->GetDefineFlags());
+ }
// Add target-specific flags.
- this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget,
- lang, config);
+ this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget, lang,
+ config);
std::map<std::string, std::string>::value_type entry(language, flags);
i = this->FlagsByLanguage.insert(entry).first;
- }
+ }
}
-std::string cmGhsMultiTargetGenerator::GetDefines(const std::string &language,
- std::string const &config)
+std::string cmGhsMultiTargetGenerator::GetDefines(const std::string& language,
+ std::string const& config)
{
std::map<std::string, std::string>::iterator i =
this->DefinesByLanguage.find(language);
- if (i == this->DefinesByLanguage.end())
- {
+ if (i == this->DefinesByLanguage.end()) {
std::set<std::string> defines;
- const char *lang = language.c_str();
+ const char* lang = language.c_str();
// Add the export symbol definition for shared library objects.
- if (const char *exportMacro = this->GeneratorTarget->GetExportMacro())
- {
+ if (const char* exportMacro = this->GeneratorTarget->GetExportMacro()) {
this->LocalGenerator->AppendDefines(defines, exportMacro);
- }
+ }
// Add preprocessor definitions for this target and configuration.
- this->LocalGenerator->AddCompileDefinitions(defines,
- this->GeneratorTarget, config,
- language);
+ this->LocalGenerator->AddCompileDefinitions(defines, this->GeneratorTarget,
+ config, language);
std::string definesString;
this->LocalGenerator->JoinDefines(defines, definesString, lang);
std::map<std::string, std::string>::value_type entry(language,
- definesString);
+ definesString);
i = this->DefinesByLanguage.insert(entry).first;
- }
+ }
return i->second;
}
-void cmGhsMultiTargetGenerator::WriteCompilerFlags(std::string const &,
- const std::string &language)
+void cmGhsMultiTargetGenerator::WriteCompilerFlags(std::string const&,
+ const std::string& language)
{
std::map<std::string, std::string>::iterator flagsByLangI =
- this->FlagsByLanguage.find(language);
- if (flagsByLangI != this->FlagsByLanguage.end())
- {
- if (!flagsByLangI->second.empty())
- {
+ this->FlagsByLanguage.find(language);
+ if (flagsByLangI != this->FlagsByLanguage.end()) {
+ if (!flagsByLangI->second.empty()) {
*this->GetFolderBuildStreams() << " " << flagsByLangI->second
- << std::endl;
- }
+ << std::endl;
}
+ }
}
void cmGhsMultiTargetGenerator::WriteCompilerDefinitions(
- const std::string &config, const std::string &language)
+ const std::string& config, const std::string& language)
{
std::vector<std::string> compileDefinitions;
- this->GeneratorTarget->GetCompileDefinitions(compileDefinitions,
- config, language);
+ this->GeneratorTarget->GetCompileDefinitions(compileDefinitions, config,
+ language);
for (std::vector<std::string>::const_iterator cdI =
compileDefinitions.begin();
- cdI != compileDefinitions.end(); ++cdI)
- {
+ cdI != compileDefinitions.end(); ++cdI) {
*this->GetFolderBuildStreams() << " -D" << (*cdI) << std::endl;
- }
+ }
}
-void cmGhsMultiTargetGenerator::WriteIncludes(const std::string &config,
- const std::string &language)
+void cmGhsMultiTargetGenerator::WriteIncludes(const std::string& config,
+ const std::string& language)
{
std::vector<std::string> includes =
this->GeneratorTarget->GetIncludeDirectories(config, language);
for (std::vector<std::string>::const_iterator includes_i = includes.begin();
- includes_i != includes.end(); ++includes_i)
- {
+ includes_i != includes.end(); ++includes_i) {
*this->GetFolderBuildStreams() << " -I\"" << *includes_i << "\""
<< std::endl;
- }
+ }
}
void cmGhsMultiTargetGenerator::WriteTargetLinkLibraries(
@@ -377,83 +339,71 @@ void cmGhsMultiTargetGenerator::WriteTargetLinkLibraries(
cmTargetDependSet tds =
this->GetGlobalGenerator()->GetTargetDirectDepends(this->GeneratorTarget);
for (cmTargetDependSet::iterator tdsI = tds.begin(); tdsI != tds.end();
- ++tdsI)
- {
- const cmGeneratorTarget *tg = *tdsI;
+ ++tdsI) {
+ const cmGeneratorTarget* tg = *tdsI;
*this->GetFolderBuildStreams() << " -L\"" << GetAbsBuildFilePath(tg)
<< "\"" << std::endl;
- }
+ }
// library targets
cmTarget::LinkLibraryVectorType llv =
this->GeneratorTarget->Target->GetOriginalLinkLibraries();
for (cmTarget::LinkLibraryVectorType::const_iterator llvI = llv.begin();
- llvI != llv.end(); ++llvI)
- {
+ llvI != llv.end(); ++llvI) {
std::string libName = llvI->first;
// if it is a user defined target get the full path to the lib
- cmTarget *tg(GetGlobalGenerator()->FindTarget(libName));
- if (NULL != tg)
- {
+ cmTarget* tg(GetGlobalGenerator()->FindTarget(libName));
+ if (NULL != tg) {
libName = tg->GetName() + ".a";
- }
+ }
*this->GetFolderBuildStreams() << " -l\"" << libName << "\""
<< std::endl;
- }
+ }
- if (!this->TargetGroup)
- {
+ if (!this->TargetGroup) {
std::string linkLibraries;
std::string flags;
std::string linkFlags;
std::string frameworkPath;
std::string linkPath;
std::string createRule =
- this->GeneratorTarget->GetCreateRuleVariable(language, config);
+ this->GeneratorTarget->GetCreateRuleVariable(language, config);
bool useWatcomQuote =
- this->Makefile->IsOn(createRule + "_USE_WATCOM_QUOTE");
+ this->Makefile->IsOn(createRule + "_USE_WATCOM_QUOTE");
this->LocalGenerator->GetTargetFlags(
- linkLibraries, flags, linkFlags,
- frameworkPath, linkPath,
+ linkLibraries, flags, linkFlags, frameworkPath, linkPath,
this->GeneratorTarget, useWatcomQuote);
linkFlags = cmSystemTools::TrimWhitespace(linkFlags);
- if (!linkPath.empty())
- {
+ if (!linkPath.empty()) {
linkPath = " " + linkPath.substr(0U, linkPath.size() - 1U);
*this->GetFolderBuildStreams() << linkPath;
- }
+ }
- if (!linkFlags.empty())
- {
+ if (!linkFlags.empty()) {
*this->GetFolderBuildStreams() << " " << linkFlags << std::endl;
- }
}
+ }
}
void cmGhsMultiTargetGenerator::WriteCustomCommands()
{
- WriteCustomCommandsHelper(
- this->GeneratorTarget->GetPreBuildCommands(),
- cmTarget::PRE_BUILD);
- WriteCustomCommandsHelper(
- this->GeneratorTarget->GetPostBuildCommands(),
- cmTarget::POST_BUILD);
+ WriteCustomCommandsHelper(this->GeneratorTarget->GetPreBuildCommands(),
+ cmTarget::PRE_BUILD);
+ WriteCustomCommandsHelper(this->GeneratorTarget->GetPostBuildCommands(),
+ cmTarget::POST_BUILD);
}
void cmGhsMultiTargetGenerator::WriteCustomCommandsHelper(
- std::vector<cmCustomCommand> const &commandsSet,
+ std::vector<cmCustomCommand> const& commandsSet,
cmTarget::CustomCommandType const commandType)
{
for (std::vector<cmCustomCommand>::const_iterator commandsSetI =
commandsSet.begin();
- commandsSetI != commandsSet.end(); ++commandsSetI)
- {
- cmCustomCommandLines const &commands = commandsSetI->GetCommandLines();
+ commandsSetI != commandsSet.end(); ++commandsSetI) {
+ cmCustomCommandLines const& commands = commandsSetI->GetCommandLines();
for (cmCustomCommandLines::const_iterator commandI = commands.begin();
- commandI != commands.end(); ++commandI)
- {
- switch (commandType)
- {
+ commandI != commands.end(); ++commandI) {
+ switch (commandType) {
case cmTarget::PRE_BUILD:
*this->GetFolderBuildStreams() << " :preexecShellSafe=";
break;
@@ -462,97 +412,88 @@ void cmGhsMultiTargetGenerator::WriteCustomCommandsHelper(
break;
default:
assert("Only pre and post are supported");
- }
- cmCustomCommandLine const &command = *commandI;
+ }
+ cmCustomCommandLine const& command = *commandI;
for (cmCustomCommandLine::const_iterator commandLineI = command.begin();
- commandLineI != command.end(); ++commandLineI)
- {
+ commandLineI != command.end(); ++commandLineI) {
std::string subCommandE =
- this->LocalGenerator->EscapeForShell(*commandLineI, true);
- if (!command.empty())
- {
+ this->LocalGenerator->EscapeForShell(*commandLineI, true);
+ if (!command.empty()) {
*this->GetFolderBuildStreams()
<< (command.begin() == commandLineI ? "'" : " ");
- //Need to double escape backslashes
+ // Need to double escape backslashes
cmSystemTools::ReplaceString(subCommandE, "\\", "\\\\");
- }
- *this->GetFolderBuildStreams() << subCommandE;
}
- if (!command.empty())
- {
+ *this->GetFolderBuildStreams() << subCommandE;
+ }
+ if (!command.empty()) {
*this->GetFolderBuildStreams() << "'" << std::endl;
- }
}
}
+ }
}
-std::map<const cmSourceFile *, std::string>
+std::map<const cmSourceFile*, std::string>
cmGhsMultiTargetGenerator::GetObjectNames(
- std::vector<cmSourceFile *> *const objectSources,
- cmLocalGhsMultiGenerator *const localGhsMultiGenerator,
- cmGeneratorTarget *const generatorTarget)
-{
- std::map<std::string, std::vector<cmSourceFile *> > filenameToSource;
- std::map<cmSourceFile *, std::string> sourceToFilename;
- for(std::vector<cmSourceFile *>::const_iterator
- sf = objectSources->begin(); sf != objectSources->end(); ++sf)
- {
+ std::vector<cmSourceFile*>* const objectSources,
+ cmLocalGhsMultiGenerator* const localGhsMultiGenerator,
+ cmGeneratorTarget* const generatorTarget)
+{
+ std::map<std::string, std::vector<cmSourceFile*> > filenameToSource;
+ std::map<cmSourceFile*, std::string> sourceToFilename;
+ for (std::vector<cmSourceFile*>::const_iterator sf = objectSources->begin();
+ sf != objectSources->end(); ++sf) {
const std::string filename =
- cmSystemTools::GetFilenameName((*sf)->GetFullPath());
+ cmSystemTools::GetFilenameName((*sf)->GetFullPath());
const std::string lower_filename = cmSystemTools::LowerCase(filename);
filenameToSource[lower_filename].push_back(*sf);
sourceToFilename[*sf] = lower_filename;
- }
+ }
- std::vector<cmSourceFile *> duplicateSources;
- for (std::map<std::string, std::vector<cmSourceFile *> >::const_iterator
- msvSourceI = filenameToSource.begin();
- msvSourceI != filenameToSource.end(); ++msvSourceI)
- {
- if (msvSourceI->second.size() > 1)
- {
+ std::vector<cmSourceFile*> duplicateSources;
+ for (std::map<std::string, std::vector<cmSourceFile*> >::const_iterator
+ msvSourceI = filenameToSource.begin();
+ msvSourceI != filenameToSource.end(); ++msvSourceI) {
+ if (msvSourceI->second.size() > 1) {
duplicateSources.insert(duplicateSources.end(),
msvSourceI->second.begin(),
msvSourceI->second.end());
- }
}
+ }
- std::map<const cmSourceFile *, std::string> objectNamesCorrected;
+ std::map<const cmSourceFile*, std::string> objectNamesCorrected;
- for (std::vector<cmSourceFile *>::const_iterator sf =
- duplicateSources.begin();
- sf != duplicateSources.end(); ++sf)
- {
+ for (std::vector<cmSourceFile*>::const_iterator sf =
+ duplicateSources.begin();
+ sf != duplicateSources.end(); ++sf) {
static std::string::size_type const MAX_FULL_PATH_LENGTH = 247;
std::string const longestObjectDirectory(
- cmGhsMultiTargetGenerator::ComputeLongestObjectDirectory(
- localGhsMultiGenerator, generatorTarget, *sf));
+ cmGhsMultiTargetGenerator::ComputeLongestObjectDirectory(
+ localGhsMultiGenerator, generatorTarget, *sf));
std::string fullFilename = (*sf)->GetFullPath();
bool const ObjPathFound = cmLocalGeneratorCheckObjectName(
- fullFilename, longestObjectDirectory.size(), MAX_FULL_PATH_LENGTH);
- if (!ObjPathFound)
- {
+ fullFilename, longestObjectDirectory.size(), MAX_FULL_PATH_LENGTH);
+ if (!ObjPathFound) {
cmSystemTools::Error("Object path \"", fullFilename.c_str(),
"\" too long", "");
- }
+ }
cmsys::SystemTools::ReplaceString(fullFilename, ":/", "_");
cmsys::SystemTools::ReplaceString(fullFilename, "/", "_");
objectNamesCorrected[*sf] = fullFilename;
- }
+ }
return objectNamesCorrected;
}
void cmGhsMultiTargetGenerator::WriteSources(
- std::vector<cmSourceFile *> const &objectSources,
- std::map<const cmSourceFile *, std::string> const &objectNames)
+ std::vector<cmSourceFile*> const& objectSources,
+ std::map<const cmSourceFile*, std::string> const& objectNames)
{
- for (std::vector<cmSourceFile *>::const_iterator si = objectSources.begin();
- si != objectSources.end(); ++si)
- {
+ for (std::vector<cmSourceFile*>::const_iterator si = objectSources.begin();
+ si != objectSources.end(); ++si) {
std::vector<cmSourceGroup> sourceGroups(this->Makefile->GetSourceGroups());
- char const *sourceFullPath = (*si)->GetFullPath().c_str();
- cmSourceGroup *sourceGroup =
+ char const* sourceFullPath = (*si)->GetFullPath().c_str();
+ cmSourceGroup* sourceGroup =
this->Makefile->FindSourceGroup(sourceFullPath, sourceGroups);
std::string sgPath(sourceGroup->GetFullName());
cmSystemTools::ConvertToUnixSlashes(sgPath);
@@ -562,131 +503,118 @@ void cmGhsMultiTargetGenerator::WriteSources(
GhsMultiGpj::SUBPROJECT, this->RelBuildFilePath);
std::string fullSourcePath((*si)->GetFullPath());
- if ((*si)->GetExtension() == "int" || (*si)->GetExtension() == "bsp")
- {
+ if ((*si)->GetExtension() == "int" || (*si)->GetExtension() == "bsp") {
*this->FolderBuildStreams[sgPath] << fullSourcePath << std::endl;
- }
- else
- {
- //WORKAROUND: GHS MULTI needs the path to use backslashes without quotes
+ } else {
+ // WORKAROUND: GHS MULTI needs the path to use backslashes without quotes
// to open files in search as of version 6.1.6
cmsys::SystemTools::ReplaceString(fullSourcePath, "/", "\\");
*this->FolderBuildStreams[sgPath] << fullSourcePath << std::endl;
- }
+ }
if ("ld" != (*si)->GetExtension() && "int" != (*si)->GetExtension() &&
- "bsp" != (*si)->GetExtension())
- {
+ "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;
- }
+ 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);
- }
}
+ }
}
void cmGhsMultiTargetGenerator::WriteObjectLangOverride(
- cmGeneratedFileStream *fileStream, cmSourceFile *sourceFile)
+ cmGeneratedFileStream* fileStream, cmSourceFile* sourceFile)
{
- const char *rawLangProp = sourceFile->GetProperty("LANGUAGE");
- if (NULL != rawLangProp)
- {
+ const char* rawLangProp = sourceFile->GetProperty("LANGUAGE");
+ if (NULL != rawLangProp) {
std::string sourceLangProp(rawLangProp);
std::string extension(sourceFile->GetExtension());
- if ("CXX" == sourceLangProp && ("c" == extension || "C" == extension))
- {
+ if ("CXX" == sourceLangProp && ("c" == extension || "C" == extension)) {
*fileStream << " -dotciscxx" << std::endl;
- }
}
+ }
}
void cmGhsMultiTargetGenerator::WriteObjectDir(
- cmGeneratedFileStream *fileStream, std::string const &dir)
+ cmGeneratedFileStream* fileStream, std::string const& dir)
{
std::string workingDir(dir);
cmSystemTools::ConvertToUnixSlashes(workingDir);
- if (!workingDir.empty())
- {
+ if (!workingDir.empty()) {
workingDir += "/";
- }
+ }
workingDir += "Objs";
*fileStream << " -object_dir=\"" << workingDir << "\"" << std::endl;
}
-std::string
-cmGhsMultiTargetGenerator::GetOutputDirectory(const std::string &config) const
+std::string cmGhsMultiTargetGenerator::GetOutputDirectory(
+ const std::string& config) const
{
std::string outputDir(AbsBuildFilePath);
- const char *runtimeOutputProp =
+ const char* runtimeOutputProp =
this->GeneratorTarget->GetProperty("RUNTIME_OUTPUT_DIRECTORY");
- if (NULL != runtimeOutputProp)
- {
+ if (NULL != runtimeOutputProp) {
outputDir = runtimeOutputProp;
- }
+ }
std::string configCapped(cmSystemTools::UpperCase(config));
- const char *runtimeOutputSProp =
- this->GeneratorTarget
- ->GetProperty("RUNTIME_OUTPUT_DIRECTORY_" + configCapped);
- if (NULL != runtimeOutputSProp)
- {
+ const char* runtimeOutputSProp = this->GeneratorTarget->GetProperty(
+ "RUNTIME_OUTPUT_DIRECTORY_" + configCapped);
+ if (NULL != runtimeOutputSProp) {
outputDir = runtimeOutputSProp;
- }
+ }
cmSystemTools::ConvertToUnixSlashes(outputDir);
- if (!outputDir.empty())
- {
+ if (!outputDir.empty()) {
outputDir += "/";
- }
+ }
return outputDir;
}
-std::string
-cmGhsMultiTargetGenerator::GetOutputFilename(const std::string &config) const
+std::string cmGhsMultiTargetGenerator::GetOutputFilename(
+ const std::string& config) const
{
std::string outputFilename(this->GeneratorTarget->GetName());
- const char *outputNameProp =
- this->GeneratorTarget->GetProperty("OUTPUT_NAME");
- if (NULL != outputNameProp)
- {
+ const char* outputNameProp =
+ this->GeneratorTarget->GetProperty("OUTPUT_NAME");
+ if (NULL != outputNameProp) {
outputFilename = outputNameProp;
- }
+ }
std::string configCapped(cmSystemTools::UpperCase(config));
- const char *outputNameSProp =
+ const char* outputNameSProp =
this->GeneratorTarget->GetProperty(configCapped + "_OUTPUT_NAME");
- if (NULL != outputNameSProp)
- {
+ if (NULL != outputNameSProp) {
outputFilename = outputNameSProp;
- }
+ }
return outputFilename;
}
std::string cmGhsMultiTargetGenerator::ComputeLongestObjectDirectory(
- cmLocalGhsMultiGenerator const *localGhsMultiGenerator,
- cmGeneratorTarget *const generatorTarget, cmSourceFile *const sourceFile)
+ cmLocalGhsMultiGenerator const* localGhsMultiGenerator,
+ cmGeneratorTarget* const generatorTarget, cmSourceFile* const sourceFile)
{
std::string dir_max;
dir_max +=
- localGhsMultiGenerator->GetMakefile()->GetCurrentBinaryDirectory();
+ localGhsMultiGenerator->GetMakefile()->GetCurrentBinaryDirectory();
dir_max += "/";
dir_max += generatorTarget->Target->GetName();
dir_max += "/";
std::vector<cmSourceGroup> sourceGroups(
- localGhsMultiGenerator->GetMakefile()->GetSourceGroups());
- char const *const sourceFullPath = sourceFile->GetFullPath().c_str();
- cmSourceGroup *sourceGroup =
- localGhsMultiGenerator->GetMakefile()->FindSourceGroup(sourceFullPath,
- sourceGroups);
+ localGhsMultiGenerator->GetMakefile()->GetSourceGroups());
+ char const* const sourceFullPath = sourceFile->GetFullPath().c_str();
+ cmSourceGroup* sourceGroup =
+ localGhsMultiGenerator->GetMakefile()->FindSourceGroup(sourceFullPath,
+ sourceGroups);
std::string const sgPath(sourceGroup->GetFullName());
dir_max += sgPath;
dir_max += "/Objs/libs/";
@@ -695,8 +623,8 @@ std::string cmGhsMultiTargetGenerator::ComputeLongestObjectDirectory(
return dir_max;
}
-bool cmGhsMultiTargetGenerator::IsNotKernel(std::string const &config,
- const std::string &language)
+bool cmGhsMultiTargetGenerator::IsNotKernel(std::string const& config,
+ const std::string& language)
{
bool output;
std::vector<std::string> options;
@@ -707,38 +635,34 @@ bool cmGhsMultiTargetGenerator::IsNotKernel(std::string const &config,
}
bool cmGhsMultiTargetGenerator::DetermineIfTargetGroup(
- const cmGeneratorTarget *target)
+ const cmGeneratorTarget* target)
{
bool output = false;
- std::vector<cmSourceFile *> sources;
+ std::vector<cmSourceFile*> sources;
std::string config =
- target->Target->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE");
+ target->Target->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE");
target->GetSourceFiles(sources, config);
- for (std::vector<cmSourceFile *>::const_iterator sources_i = sources.begin();
- sources.end() != sources_i; ++sources_i)
- {
- if ("int" == (*sources_i)->GetExtension())
- {
+ for (std::vector<cmSourceFile*>::const_iterator sources_i = sources.begin();
+ sources.end() != sources_i; ++sources_i) {
+ if ("int" == (*sources_i)->GetExtension()) {
output = true;
- }
}
+ }
return output;
}
bool cmGhsMultiTargetGenerator::DetermineIfDynamicDownload(
- std::string const &config, const std::string &language)
+ std::string const& config, const std::string& language)
{
std::vector<std::string> options;
bool output = false;
this->GeneratorTarget->GetCompileOptions(options, config, language);
for (std::vector<std::string>::const_iterator options_i = options.begin();
- options_i != options.end(); ++options_i)
- {
+ options_i != options.end(); ++options_i) {
std::string option = *options_i;
- if (this->DDOption == option)
- {
+ if (this->DDOption == option) {
output = true;
- }
}
+ }
return output;
}