cmSourceFile: Rename non-const GetLanguage
GetOrDetermineLanguage: - Read the property if available - Determine the Language using the file extension Fix all usage of the non-const member in the repository.
This commit is contained in:
parent
65fe80794d
commit
8cb3cffa42
@ -365,7 +365,7 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
|
||||
|
||||
// check whether it is a C/C++/CUDA implementation file
|
||||
bool isCFile = false;
|
||||
std::string lang = s->GetLanguage();
|
||||
std::string lang = s->GetOrDetermineLanguage();
|
||||
if (lang == "C" || lang == "CXX" || lang == "CUDA") {
|
||||
std::string const& srcext = s->GetExtension();
|
||||
isCFile = cm->IsSourceExtension(srcext);
|
||||
|
@ -342,7 +342,7 @@ std::string cmExtraSublimeTextGenerator::ComputeFlagsForObject(
|
||||
cmSourceFile* source, cmLocalGenerator* lg, cmGeneratorTarget* gtgt)
|
||||
{
|
||||
std::string flags;
|
||||
std::string language = source->GetLanguage();
|
||||
std::string language = source->GetOrDetermineLanguage();
|
||||
if (language.empty()) {
|
||||
language = "C";
|
||||
}
|
||||
@ -377,7 +377,7 @@ std::string cmExtraSublimeTextGenerator::ComputeDefines(
|
||||
{
|
||||
std::set<std::string> defines;
|
||||
cmMakefile* makefile = lg->GetMakefile();
|
||||
const std::string& language = source->GetLanguage();
|
||||
const std::string& language = source->GetOrDetermineLanguage();
|
||||
const std::string& config = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
|
||||
cmGeneratorExpressionInterpreter genexInterpreter(lg, config, target,
|
||||
language);
|
||||
@ -410,7 +410,7 @@ std::string cmExtraSublimeTextGenerator::ComputeIncludes(
|
||||
{
|
||||
std::vector<std::string> includes;
|
||||
cmMakefile* makefile = lg->GetMakefile();
|
||||
const std::string& language = source->GetLanguage();
|
||||
const std::string& language = source->GetOrDetermineLanguage();
|
||||
const std::string& config = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
|
||||
cmGeneratorExpressionInterpreter genexInterpreter(lg, config, target,
|
||||
language);
|
||||
|
@ -837,7 +837,7 @@ CompileData Target::BuildCompileData(cmSourceFile* sf)
|
||||
{
|
||||
CompileData fd;
|
||||
|
||||
fd.Language = sf->GetLanguage();
|
||||
fd.Language = sf->GetOrDetermineLanguage();
|
||||
if (fd.Language.empty()) {
|
||||
return fd;
|
||||
}
|
||||
|
@ -1593,7 +1593,7 @@ void cmGeneratorTarget::ComputeKindedSources(KindedSources& files,
|
||||
kind = SourceKindHeader;
|
||||
} else if (sf->GetPropertyAsBool("EXTERNAL_OBJECT")) {
|
||||
kind = SourceKindExternalObject;
|
||||
} else if (!sf->GetLanguage().empty()) {
|
||||
} else if (!sf->GetOrDetermineLanguage().empty()) {
|
||||
kind = SourceKindObjectSource;
|
||||
} else if (ext == "def") {
|
||||
kind = SourceKindModuleDefinition;
|
||||
@ -6055,7 +6055,7 @@ void cmGeneratorTarget::GetLanguages(std::set<std::string>& languages,
|
||||
std::vector<cmSourceFile*> sourceFiles;
|
||||
this->GetSourceFiles(sourceFiles, config);
|
||||
for (cmSourceFile* src : sourceFiles) {
|
||||
const std::string& lang = src->GetLanguage();
|
||||
const std::string& lang = src->GetOrDetermineLanguage();
|
||||
if (!lang.empty()) {
|
||||
languages.insert(lang);
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ bool cmGetSourceFilePropertyCommand::InitialPass(
|
||||
}
|
||||
if (sf) {
|
||||
if (args[2] == "LANGUAGE") {
|
||||
this->Makefile->AddDefinition(var, sf->GetLanguage());
|
||||
this->Makefile->AddDefinition(var, sf->GetOrDetermineLanguage());
|
||||
return true;
|
||||
}
|
||||
const char* prop = nullptr;
|
||||
|
@ -264,7 +264,7 @@ static Json::Value DumpSourceFilesList(
|
||||
std::unordered_map<LanguageData, std::vector<std::string>> fileGroups;
|
||||
for (cmSourceFile* file : files) {
|
||||
LanguageData fileData;
|
||||
fileData.Language = file->GetLanguage();
|
||||
fileData.Language = file->GetOrDetermineLanguage();
|
||||
if (!fileData.Language.empty()) {
|
||||
const LanguageData& ld = languageDataMap.at(fileData.Language);
|
||||
cmLocalGenerator* lg = target->GetLocalGenerator();
|
||||
|
@ -45,11 +45,13 @@ std::string cmSourceFile::GetObjectLibrary() const
|
||||
return this->ObjectLibrary;
|
||||
}
|
||||
|
||||
std::string cmSourceFile::GetLanguage()
|
||||
std::string const& cmSourceFile::GetOrDetermineLanguage()
|
||||
{
|
||||
// If the language was set explicitly by the user then use it.
|
||||
if (const char* lang = this->GetProperty(propLANGUAGE)) {
|
||||
return lang;
|
||||
// Assign to member in order to return a reference.
|
||||
this->Language = lang;
|
||||
return this->Language;
|
||||
}
|
||||
|
||||
// Perform computation needed to get the language if necessary.
|
||||
@ -72,8 +74,8 @@ std::string cmSourceFile::GetLanguage()
|
||||
}
|
||||
}
|
||||
|
||||
// Now try to determine the language.
|
||||
return static_cast<cmSourceFile const*>(this)->GetLanguage();
|
||||
// Use the language determined from the file extension.
|
||||
return this->Language;
|
||||
}
|
||||
|
||||
std::string cmSourceFile::GetLanguage() const
|
||||
@ -83,13 +85,8 @@ std::string cmSourceFile::GetLanguage() const
|
||||
return lang;
|
||||
}
|
||||
|
||||
// If the language was determined from the source file extension use it.
|
||||
if (!this->Language.empty()) {
|
||||
return this->Language;
|
||||
}
|
||||
|
||||
// The language is not known.
|
||||
return "";
|
||||
// Use the language determined from the file extension.
|
||||
return this->Language;
|
||||
}
|
||||
|
||||
cmSourceFileLocation const& cmSourceFile::GetLocation() const
|
||||
|
@ -88,7 +88,7 @@ public:
|
||||
/**
|
||||
* Get the language of the compiler to use for this source file.
|
||||
*/
|
||||
std::string GetLanguage();
|
||||
std::string const& GetOrDetermineLanguage();
|
||||
std::string GetLanguage() const;
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user