Commit 3cf9265f authored by Brad King's avatar Brad King
Browse files

ENH: Refactor passing of max length object dir

When computing the maximum length full path to the build directory under
which object files will be placed, pass the actual path instead of just
its length.  This will be useful for error message generation.
parent 63e186a8
......@@ -645,10 +645,10 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target)
!sf->GetPropertyAsBool("HEADER_FILE_ONLY") &&
!sf->GetPropertyAsBool("EXTERNAL_OBJECT"))
{
std::string::size_type dir_len = 0;
dir_len += strlen(this->Makefile->GetCurrentOutputDirectory());
dir_len += 1;
std::string obj = this->GetObjectFileNameWithoutTarget(*sf, dir_len);
std::string dir_max;
dir_max += this->Makefile->GetCurrentOutputDirectory();
dir_max += "/";
std::string obj = this->GetObjectFileNameWithoutTarget(*sf, dir_max);
if(!obj.empty())
{
std::string ofname = this->Makefile->GetCurrentOutputDirectory();
......@@ -2475,7 +2475,7 @@ bool cmLocalGeneratorCheckObjectName(std::string& objName,
std::string&
cmLocalGenerator
::CreateSafeUniqueObjectFileName(const char* sin,
std::string::size_type dir_len)
std::string const& dir_max)
{
// Look for an existing mapped name for this object file.
std::map<cmStdString,cmStdString>::iterator it =
......@@ -2536,9 +2536,10 @@ cmLocalGenerator
}
#if defined(CM_LG_ENCODE_OBJECT_NAMES)
cmLocalGeneratorCheckObjectName(ssin, dir_len, this->ObjectPathMax);
cmLocalGeneratorCheckObjectName(ssin, dir_max.size(),
this->ObjectPathMax);
#else
(void)dir_len;
(void)dir_max;
#endif
// Insert the newly mapped object file name.
......@@ -2554,7 +2555,7 @@ cmLocalGenerator
std::string
cmLocalGenerator
::GetObjectFileNameWithoutTarget(const cmSourceFile& source,
std::string::size_type dir_len,
std::string const& dir_max,
bool* hasSourceExtension)
{
// Construct the object file name using the full path to the source
......@@ -2642,7 +2643,7 @@ cmLocalGenerator
}
// Convert to a safe name.
return this->CreateSafeUniqueObjectFileName(objectName.c_str(), dir_len);
return this->CreateSafeUniqueObjectFileName(objectName.c_str(), dir_max);
}
//----------------------------------------------------------------------------
......
......@@ -340,10 +340,10 @@ protected:
// Compute object file names.
std::string GetObjectFileNameWithoutTarget(const cmSourceFile& source,
std::string::size_type dir_len,
std::string const& dir_max,
bool* hasSourceExtension = 0);
std::string& CreateSafeUniqueObjectFileName(const char* sin,
std::string::size_type dir_len);
std::string const& dir_max);
void ConfigureRelativePaths();
std::string FindRelativePathTopSource();
......
......@@ -1928,12 +1928,12 @@ cmLocalUnixMakefileGenerator3
obj += "/";
// Get the object file name without the target directory.
std::string::size_type dir_len = 0;
dir_len += strlen(this->Makefile->GetCurrentOutputDirectory());
dir_len += 1;
dir_len += obj.size();
std::string dir_max;
dir_max += this->Makefile->GetCurrentOutputDirectory();
dir_max += "/";
dir_max += obj;
std::string objectName =
this->GetObjectFileNameWithoutTarget(source, dir_len,
this->GetObjectFileNameWithoutTarget(source, dir_max,
hasSourceExtension);
if(nameWithoutTargetDir)
{
......
......@@ -372,27 +372,27 @@ void cmLocalVisualStudio6Generator
this->WriteDSPBeginGroup(fout, name.c_str(), "");
}
// Compute the maximum length of a configuration name.
std::string::size_type config_len_max = 0;
// Compute the maximum length configuration name.
std::string config_max;
for(std::vector<std::string>::iterator i = this->Configurations.begin();
i != this->Configurations.end(); ++i)
{
// Strip the subdirectory name out of the configuration name.
std::string config = this->GetConfigName(*i);
if(config.size() > config_len_max)
if(config.size() > config_max.size())
{
config_len_max = config.size();
config_max = config;
}
}
// Compute the maximum length of the full path to the intermediate
// Compute the maximum length full path to the intermediate
// files directory for any configuration. This is used to construct
// object file names that do not produce paths that are too long.
std::string::size_type dir_len = 0;
dir_len += strlen(this->Makefile->GetCurrentOutputDirectory());
dir_len += 1;
dir_len += config_len_max;
dir_len += 1;
std::string dir_max;
dir_max += this->Makefile->GetCurrentOutputDirectory();
dir_max += "/";
dir_max += config_max;
dir_max += "/";
// Loop through each source in the source group.
for(std::vector<const cmSourceFile *>::const_iterator sf =
......@@ -408,7 +408,7 @@ void cmLocalVisualStudio6Generator
{
objectNameDir =
cmSystemTools::GetFilenamePath(
this->GetObjectFileNameWithoutTarget(*(*sf), dir_len));
this->GetObjectFileNameWithoutTarget(*(*sf), dir_max));
}
// Add per-source file flags.
......
......@@ -1226,7 +1226,7 @@ public:
cmTarget& target,
cmSourceFile const& sf,
std::vector<std::string>* configs,
std::string::size_type dir_len);
std::string const& dir_max);
std::map<cmStdString, cmLVS7GFileConfig> FileConfigMap;
};
......@@ -1235,12 +1235,12 @@ cmLocalVisualStudio7GeneratorFCInfo
cmTarget& target,
cmSourceFile const& sf,
std::vector<std::string>* configs,
std::string::size_type dir_len)
std::string const& dir_max)
{
std::string objectName;
if(lg->NeedObjectName.find(&sf) != lg->NeedObjectName.end())
{
objectName = lg->GetObjectFileNameWithoutTarget(sf, dir_len);
objectName = lg->GetObjectFileNameWithoutTarget(sf, dir_max);
}
// Compute per-source, per-config information.
......@@ -1358,27 +1358,27 @@ void cmLocalVisualStudio7Generator
this->WriteVCProjBeginGroup(fout, name.c_str(), "");
}
// Compute the maximum length of a configuration name.
std::string::size_type config_len_max = 0;
// Compute the maximum length configuration name.
std::string config_max;
for(std::vector<std::string>::iterator i = configs->begin();
i != configs->end(); ++i)
{
if(i->size() > config_len_max)
if(i->size() > config_max.size())
{
config_len_max = i->size();
config_max = *i;
}
}
// Compute the maximum length of the full path to the intermediate
// Compute the maximum length full path to the intermediate
// files directory for any configuration. This is used to construct
// object file names that do not produce paths that are too long.
std::string::size_type dir_len = 0;
dir_len += strlen(this->Makefile->GetCurrentOutputDirectory());
dir_len += 1;
dir_len += this->GetTargetDirectory(target).size();
dir_len += 1;
dir_len += config_len_max;
dir_len += 1;
std::string dir_max;
dir_max += this->Makefile->GetCurrentOutputDirectory();
dir_max += "/";
dir_max += this->GetTargetDirectory(target);
dir_max += "/";
dir_max += config_max;
dir_max += "/";
// Loop through each source in the source group.
std::string objectName;
......@@ -1386,7 +1386,7 @@ void cmLocalVisualStudio7Generator
sourceFiles.begin(); sf != sourceFiles.end(); ++sf)
{
std::string source = (*sf)->GetFullPath();
FCInfo fcinfo(this, target, *(*sf), configs, dir_len);
FCInfo fcinfo(this, target, *(*sf), configs, dir_max);
if (source != libName || target.GetType() == cmTarget::UTILITY ||
target.GetType() == cmTarget::GLOBAL_TARGET )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment