mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
cmMakeFile: Remove source groups argument from FindSourceGroup
This commit is contained in:
@@ -518,8 +518,6 @@ void cmExtraEclipseCDT4Generator::CreateLinksForTargets(cmXMLWriter& xml)
|
||||
if (!this->GenerateLinkedResources) {
|
||||
break; // skip generating the linked resources to the source files
|
||||
}
|
||||
std::vector<cmSourceGroup> sourceGroups =
|
||||
makefile->GetSourceGroups();
|
||||
// get the files from the source lists then add them to the groups
|
||||
std::vector<cmSourceFile*> files;
|
||||
target->GetSourceFiles(
|
||||
@@ -527,11 +525,12 @@ void cmExtraEclipseCDT4Generator::CreateLinksForTargets(cmXMLWriter& xml)
|
||||
for (cmSourceFile* sf : files) {
|
||||
// Add the file to the list of sources.
|
||||
std::string const& source = sf->ResolveFullPath();
|
||||
cmSourceGroup* sourceGroup =
|
||||
makefile->FindSourceGroup(source, sourceGroups);
|
||||
cmSourceGroup* sourceGroup = makefile->FindSourceGroup(source);
|
||||
sourceGroup->AssignSource(sf);
|
||||
}
|
||||
|
||||
std::vector<cmSourceGroup> sourceGroups =
|
||||
makefile->GetSourceGroups();
|
||||
this->WriteGroups(sourceGroups, linkName2, xml);
|
||||
} break;
|
||||
// ignore all others:
|
||||
|
||||
@@ -439,7 +439,6 @@ class Target
|
||||
std::string const& Config;
|
||||
std::string TopSource;
|
||||
std::string TopBuild;
|
||||
std::vector<cmSourceGroup> SourceGroupsLocal;
|
||||
BacktraceData Backtraces;
|
||||
|
||||
std::map<std::string, CompileData> CompileDataMap;
|
||||
@@ -1256,7 +1255,6 @@ Target::Target(cmGeneratorTarget* gt, unsigned int versionMajor,
|
||||
, TopSource(gt->GetGlobalGenerator()->GetCMakeInstance()->GetHomeDirectory())
|
||||
, TopBuild(
|
||||
gt->GetGlobalGenerator()->GetCMakeInstance()->GetHomeOutputDirectory())
|
||||
, SourceGroupsLocal(this->GT->Makefile->GetSourceGroups())
|
||||
, Backtraces(this->TopSource)
|
||||
{
|
||||
}
|
||||
@@ -1815,8 +1813,7 @@ Json::Value Target::DumpSource(cmGeneratorTarget::SourceAndKind const& sk,
|
||||
source["fileSetIndex"] = fsit->second;
|
||||
}
|
||||
|
||||
if (cmSourceGroup* sg =
|
||||
this->GT->Makefile->FindSourceGroup(path, this->SourceGroupsLocal)) {
|
||||
if (cmSourceGroup* sg = this->GT->Makefile->FindSourceGroup(path)) {
|
||||
source["sourceGroupIndex"] = this->AddSourceGroup(sg, si);
|
||||
}
|
||||
|
||||
|
||||
@@ -509,17 +509,12 @@ void cmGhsMultiTargetGenerator::WriteSources(std::ostream& fout_proj)
|
||||
std::vector<cmSourceFile*> sources;
|
||||
this->GeneratorTarget->GetSourceFiles(sources, this->ConfigName);
|
||||
|
||||
/* vector of all groups defined for this target
|
||||
* -- but the vector is not expanded with sub groups or in any useful order
|
||||
*/
|
||||
std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups();
|
||||
|
||||
/* for each source file assign it to its group */
|
||||
std::map<std::string, std::vector<cmSourceFile*>> groupFiles;
|
||||
std::set<std::string> groupNames;
|
||||
for (cmSourceFile* sf : sources) {
|
||||
cmSourceGroup* sourceGroup =
|
||||
this->Makefile->FindSourceGroup(sf->ResolveFullPath(), sourceGroups);
|
||||
this->Makefile->FindSourceGroup(sf->ResolveFullPath());
|
||||
std::string gn = sourceGroup->GetFullName();
|
||||
groupFiles[gn].push_back(sf);
|
||||
groupNames.insert(std::move(gn));
|
||||
|
||||
@@ -1051,9 +1051,6 @@ cm::VS::Solution cmGlobalVisualStudioGenerator::CreateSolution(
|
||||
}
|
||||
|
||||
cmMakefile* mf = root->GetMakefile();
|
||||
// Unfortunately we have to copy the source groups because
|
||||
// FindSourceGroup uses a regex which is modifying the group.
|
||||
std::vector<cmSourceGroup> sourceGroups = mf->GetSourceGroups();
|
||||
std::vector<std::string> items =
|
||||
cmList{ root->GetMakefile()->GetProperty("VS_SOLUTION_ITEMS") };
|
||||
for (std::string item : items) {
|
||||
@@ -1061,7 +1058,7 @@ cm::VS::Solution cmGlobalVisualStudioGenerator::CreateSolution(
|
||||
item =
|
||||
cmSystemTools::CollapseFullPath(item, mf->GetCurrentSourceDirectory());
|
||||
}
|
||||
cmSourceGroup* sg = mf->FindSourceGroup(item, sourceGroups);
|
||||
cmSourceGroup* sg = mf->FindSourceGroup(item);
|
||||
std::string folderName = sg->GetFullName();
|
||||
if (folderName.empty()) {
|
||||
folderName = "Solution Items"_s;
|
||||
|
||||
@@ -4500,7 +4500,6 @@ bool cmGlobalXCodeGenerator::CreateGroups(
|
||||
{
|
||||
for (auto& generator : generators) {
|
||||
cmMakefile* mf = generator->GetMakefile();
|
||||
std::vector<cmSourceGroup> sourceGroups = mf->GetSourceGroups();
|
||||
for (auto const& gtgt : generator->GetGeneratorTargets()) {
|
||||
// Same skipping logic here as in CreateXCodeTargets so that we do not
|
||||
// end up with (empty anyhow) ZERO_CHECK, install, or test source
|
||||
@@ -4512,9 +4511,8 @@ bool cmGlobalXCodeGenerator::CreateGroups(
|
||||
continue;
|
||||
}
|
||||
|
||||
auto addSourceToGroup = [this, mf, >gt,
|
||||
&sourceGroups](std::string const& source) {
|
||||
cmSourceGroup* sourceGroup = mf->FindSourceGroup(source, sourceGroups);
|
||||
auto addSourceToGroup = [this, mf, >gt](std::string const& source) {
|
||||
cmSourceGroup* sourceGroup = mf->FindSourceGroup(source);
|
||||
cmXCodeObject* pbxgroup =
|
||||
this->CreateOrGetPBXGroup(gtgt.get(), sourceGroup);
|
||||
std::string key = GetGroupMapKeyFromPath(gtgt.get(), source);
|
||||
|
||||
@@ -1406,9 +1406,6 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
|
||||
std::vector<std::string> configs =
|
||||
this->Makefile->GetGeneratorConfigs(cmMakefile::ExcludeEmptyConfig);
|
||||
|
||||
// We may be modifying the source groups temporarily, so make a copy.
|
||||
std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups();
|
||||
|
||||
AllConfigSources sources;
|
||||
sources.Sources = target->GetAllConfigSources();
|
||||
|
||||
@@ -1450,8 +1447,7 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
|
||||
}
|
||||
// Add the file to the list of sources.
|
||||
std::string const source = sf->GetFullPath();
|
||||
cmSourceGroup* sourceGroup =
|
||||
this->Makefile->FindSourceGroup(source, sourceGroups);
|
||||
cmSourceGroup* sourceGroup = this->Makefile->FindSourceGroup(source);
|
||||
sourceGroup->AssignSource(sf);
|
||||
}
|
||||
|
||||
@@ -1463,6 +1459,7 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
|
||||
fout << "\t<Files>\n";
|
||||
|
||||
// Loop through every source group.
|
||||
std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups();
|
||||
for (auto const& sg : sourceGroups) {
|
||||
this->WriteGroup(&sg, target, fout, libName, configs, sources);
|
||||
}
|
||||
|
||||
@@ -2193,11 +2193,10 @@ cmSourceGroup* cmMakefile::GetOrCreateSourceGroup(std::string const& name)
|
||||
* non-inherited SOURCE_GROUP commands will have precedence over
|
||||
* inherited ones.
|
||||
*/
|
||||
cmSourceGroup* cmMakefile::FindSourceGroup(
|
||||
std::string const& source, std::vector<cmSourceGroup>& groups) const
|
||||
cmSourceGroup* cmMakefile::FindSourceGroup(std::string const& source)
|
||||
{
|
||||
// First search for a group that lists the file explicitly.
|
||||
for (auto sg = groups.rbegin(); sg != groups.rend(); ++sg) {
|
||||
for (auto sg = SourceGroups.rbegin(); sg != SourceGroups.rend(); ++sg) {
|
||||
cmSourceGroup* result = sg->MatchChildrenFiles(source);
|
||||
if (result) {
|
||||
return result;
|
||||
@@ -2205,7 +2204,7 @@ cmSourceGroup* cmMakefile::FindSourceGroup(
|
||||
}
|
||||
|
||||
// Now search for a group whose regex matches the file.
|
||||
for (auto sg = groups.rbegin(); sg != groups.rend(); ++sg) {
|
||||
for (auto sg = SourceGroups.rbegin(); sg != SourceGroups.rend(); ++sg) {
|
||||
cmSourceGroup* result = sg->MatchChildrenRegex(source);
|
||||
if (result) {
|
||||
return result;
|
||||
@@ -2213,7 +2212,7 @@ cmSourceGroup* cmMakefile::FindSourceGroup(
|
||||
}
|
||||
|
||||
// Shouldn't get here, but just in case, return the default group.
|
||||
return groups.data();
|
||||
return SourceGroups.data();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
+1
-2
@@ -658,8 +658,7 @@ public:
|
||||
/**
|
||||
* find what source group this source is in
|
||||
*/
|
||||
cmSourceGroup* FindSourceGroup(std::string const& source,
|
||||
std::vector<cmSourceGroup>& groups) const;
|
||||
cmSourceGroup* FindSourceGroup(std::string const& source);
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
||||
@@ -1993,29 +1993,24 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
|
||||
return;
|
||||
}
|
||||
|
||||
// collect up group information
|
||||
std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups();
|
||||
|
||||
std::vector<cmGeneratorTarget::AllConfigSource> const& sources =
|
||||
this->GeneratorTarget->GetAllConfigSources();
|
||||
|
||||
std::set<cmSourceGroup const*> groupsUsed;
|
||||
for (cmGeneratorTarget::AllConfigSource const& si : sources) {
|
||||
std::string const& source = si.Source->GetFullPath();
|
||||
cmSourceGroup* sourceGroup =
|
||||
this->Makefile->FindSourceGroup(source, sourceGroups);
|
||||
cmSourceGroup* sourceGroup = this->Makefile->FindSourceGroup(source);
|
||||
groupsUsed.insert(sourceGroup);
|
||||
}
|
||||
|
||||
if (cmSourceFile const* srcCMakeLists =
|
||||
this->LocalGenerator->CreateVCProjBuildRule()) {
|
||||
std::string const& source = srcCMakeLists->GetFullPath();
|
||||
cmSourceGroup* sourceGroup =
|
||||
this->Makefile->FindSourceGroup(source, sourceGroups);
|
||||
cmSourceGroup* sourceGroup = this->Makefile->FindSourceGroup(source);
|
||||
groupsUsed.insert(sourceGroup);
|
||||
}
|
||||
|
||||
this->AddMissingSourceGroups(groupsUsed, sourceGroups);
|
||||
this->AddMissingSourceGroups(groupsUsed, this->Makefile->GetSourceGroups());
|
||||
|
||||
// Write out group file
|
||||
std::string path = cmStrCat(
|
||||
@@ -2035,7 +2030,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
|
||||
"http://schemas.microsoft.com/developer/msbuild/2003");
|
||||
|
||||
for (auto const& ti : this->Tools) {
|
||||
this->WriteGroupSources(e0, ti.first, ti.second, sourceGroups);
|
||||
this->WriteGroupSources(e0, ti.first, ti.second);
|
||||
}
|
||||
|
||||
// Added files are images and the manifest.
|
||||
@@ -2163,16 +2158,14 @@ void cmVisualStudio10TargetGenerator::AddMissingSourceGroups(
|
||||
}
|
||||
|
||||
void cmVisualStudio10TargetGenerator::WriteGroupSources(
|
||||
Elem& e0, std::string const& name, ToolSources const& sources,
|
||||
std::vector<cmSourceGroup>& sourceGroups)
|
||||
Elem& e0, std::string const& name, ToolSources const& sources)
|
||||
{
|
||||
Elem e1(e0, "ItemGroup");
|
||||
e1.SetHasElements();
|
||||
for (ToolSource const& s : sources) {
|
||||
cmSourceFile const* sf = s.SourceFile;
|
||||
std::string const& source = sf->GetFullPath();
|
||||
cmSourceGroup* sourceGroup =
|
||||
this->Makefile->FindSourceGroup(source, sourceGroups);
|
||||
cmSourceGroup* sourceGroup = this->Makefile->FindSourceGroup(source);
|
||||
std::string const& filter = sourceGroup->GetFullName();
|
||||
std::string path = this->ConvertPath(source, s.RelativePath);
|
||||
ConvertToWindowsSlash(path);
|
||||
@@ -6043,11 +6036,7 @@ std::string cmVisualStudio10TargetGenerator::GetCSharpSourceLink(
|
||||
std::string const& fullFileName = source->GetFullPath();
|
||||
std::string const& srcDir = this->Makefile->GetCurrentSourceDirectory();
|
||||
std::string const& binDir = this->Makefile->GetCurrentBinaryDirectory();
|
||||
// unfortunately we have to copy the source groups, because
|
||||
// FindSourceGroup uses a regex which is modifying the group
|
||||
std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups();
|
||||
cmSourceGroup* sourceGroup =
|
||||
this->Makefile->FindSourceGroup(fullFileName, sourceGroups);
|
||||
cmSourceGroup* sourceGroup = this->Makefile->FindSourceGroup(fullFileName);
|
||||
if (sourceGroup && !sourceGroup->GetFullName().empty()) {
|
||||
sourceGroupedFile =
|
||||
cmStrCat(sourceGroup->GetFullName(), '/',
|
||||
|
||||
@@ -202,8 +202,7 @@ private:
|
||||
std::vector<cmCustomCommand> const& commands,
|
||||
std::string const& configName);
|
||||
void WriteGroupSources(Elem& e0, std::string const& name,
|
||||
ToolSources const& sources,
|
||||
std::vector<cmSourceGroup>&);
|
||||
ToolSources const& sources);
|
||||
void AddMissingSourceGroups(std::set<cmSourceGroup const*>& groupsUsed,
|
||||
std::vector<cmSourceGroup> const& allGroups);
|
||||
bool IsResxHeader(std::string const& headerFile);
|
||||
|
||||
Reference in New Issue
Block a user