Merge topic 'UseMakefileHeaderExtensions'
27e14a8
automoc: use the header extensions from cmMakefile10511aa
automoc: use a std::vector<> instead a std::list
This commit is contained in:
commit
c6c9838c63
|
@ -44,14 +44,14 @@ static bool containsQ_OBJECT(const std::string& text)
|
||||||
static std::string findMatchingHeader(const std::string& absPath,
|
static std::string findMatchingHeader(const std::string& absPath,
|
||||||
const std::string& mocSubDir,
|
const std::string& mocSubDir,
|
||||||
const std::string& basename,
|
const std::string& basename,
|
||||||
const std::list<std::string>& headerExtensions)
|
const std::vector<std::string>& headerExtensions)
|
||||||
{
|
{
|
||||||
std::string header;
|
std::string header;
|
||||||
for(std::list<std::string>::const_iterator ext = headerExtensions.begin();
|
for(std::vector<std::string>::const_iterator ext = headerExtensions.begin();
|
||||||
ext != headerExtensions.end();
|
ext != headerExtensions.end();
|
||||||
++ext)
|
++ext)
|
||||||
{
|
{
|
||||||
std::string sourceFilePath = absPath + basename + (*ext);
|
std::string sourceFilePath = absPath + basename + "." + (*ext);
|
||||||
if (cmsys::SystemTools::FileExists(sourceFilePath.c_str()))
|
if (cmsys::SystemTools::FileExists(sourceFilePath.c_str()))
|
||||||
{
|
{
|
||||||
header = sourceFilePath;
|
header = sourceFilePath;
|
||||||
|
@ -59,7 +59,7 @@ static std::string findMatchingHeader(const std::string& absPath,
|
||||||
}
|
}
|
||||||
if (!mocSubDir.empty())
|
if (!mocSubDir.empty())
|
||||||
{
|
{
|
||||||
sourceFilePath = mocSubDir + basename + (*ext);
|
sourceFilePath = mocSubDir + basename + "." + (*ext);
|
||||||
if (cmsys::SystemTools::FileExists(sourceFilePath.c_str()))
|
if (cmsys::SystemTools::FileExists(sourceFilePath.c_str()))
|
||||||
{
|
{
|
||||||
header = sourceFilePath;
|
header = sourceFilePath;
|
||||||
|
@ -296,7 +296,7 @@ bool cmQtAutomoc::Run(const char* targetDirectory)
|
||||||
|
|
||||||
if (this->QtMajorVersion == "4" || this->QtMajorVersion == "5")
|
if (this->QtMajorVersion == "4" || this->QtMajorVersion == "5")
|
||||||
{
|
{
|
||||||
success = this->RunAutomoc();
|
success = this->RunAutomoc(makefile);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->WriteOldMocDefinitionsFile(targetDirectory);
|
this->WriteOldMocDefinitionsFile(targetDirectory);
|
||||||
|
@ -504,7 +504,7 @@ void cmQtAutomoc::Init()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool cmQtAutomoc::RunAutomoc()
|
bool cmQtAutomoc::RunAutomoc(cmMakefile* makefile)
|
||||||
{
|
{
|
||||||
if (!cmsys::SystemTools::FileExists(this->OutMocCppFilename.c_str())
|
if (!cmsys::SystemTools::FileExists(this->OutMocCppFilename.c_str())
|
||||||
|| (this->OldCompileSettingsStr != this->CurrentCompileSettingsStr))
|
|| (this->OldCompileSettingsStr != this->CurrentCompileSettingsStr))
|
||||||
|
@ -528,22 +528,8 @@ bool cmQtAutomoc::RunAutomoc()
|
||||||
std::vector<std::string> sourceFiles;
|
std::vector<std::string> sourceFiles;
|
||||||
cmSystemTools::ExpandListArgument(this->Sources, sourceFiles);
|
cmSystemTools::ExpandListArgument(this->Sources, sourceFiles);
|
||||||
|
|
||||||
std::list<std::string> headerExtensions;
|
const std::vector<std::string>& headerExtensions =
|
||||||
headerExtensions.push_back(".h");
|
makefile->GetHeaderExtensions();
|
||||||
headerExtensions.push_back(".hpp");
|
|
||||||
headerExtensions.push_back(".hxx");
|
|
||||||
#if defined(_WIN32)
|
|
||||||
// not case sensitive, don't add ".H"
|
|
||||||
#elif defined(__APPLE__)
|
|
||||||
// detect case-sensitive filesystem
|
|
||||||
long caseSensitive = pathconf(this->Srcdir.c_str(), _PC_CASE_SENSITIVE);
|
|
||||||
if (caseSensitive == 1)
|
|
||||||
{
|
|
||||||
headerExtensions.push_back(".H");
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
headerExtensions.push_back(".H");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (std::vector<std::string>::const_iterator it = sourceFiles.begin();
|
for (std::vector<std::string>::const_iterator it = sourceFiles.begin();
|
||||||
it != sourceFiles.end();
|
it != sourceFiles.end();
|
||||||
|
@ -643,7 +629,7 @@ bool cmQtAutomoc::RunAutomoc()
|
||||||
|
|
||||||
|
|
||||||
void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
|
void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
|
||||||
const std::list<std::string>& headerExtensions,
|
const std::vector<std::string>& headerExtensions,
|
||||||
std::map<std::string, std::string>& includedMocs)
|
std::map<std::string, std::string>& includedMocs)
|
||||||
{
|
{
|
||||||
cmsys::RegularExpression mocIncludeRegExp(
|
cmsys::RegularExpression mocIncludeRegExp(
|
||||||
|
@ -821,7 +807,7 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
|
||||||
|
|
||||||
|
|
||||||
void cmQtAutomoc::StrictParseCppFile(const std::string& absFilename,
|
void cmQtAutomoc::StrictParseCppFile(const std::string& absFilename,
|
||||||
const std::list<std::string>& headerExtensions,
|
const std::vector<std::string>& headerExtensions,
|
||||||
std::map<std::string, std::string>& includedMocs)
|
std::map<std::string, std::string>& includedMocs)
|
||||||
{
|
{
|
||||||
cmsys::RegularExpression mocIncludeRegExp(
|
cmsys::RegularExpression mocIncludeRegExp(
|
||||||
|
@ -932,8 +918,8 @@ void cmQtAutomoc::StrictParseCppFile(const std::string& absFilename,
|
||||||
|
|
||||||
|
|
||||||
void cmQtAutomoc::SearchHeadersForCppFile(const std::string& absFilename,
|
void cmQtAutomoc::SearchHeadersForCppFile(const std::string& absFilename,
|
||||||
const std::list<std::string>& headerExtensions,
|
const std::vector<std::string>& headerExtensions,
|
||||||
std::set<std::string>& absHeaders)
|
std::set<std::string>& absHeaders)
|
||||||
{
|
{
|
||||||
// search for header files and private header files we may need to moc:
|
// search for header files and private header files we may need to moc:
|
||||||
const std::string basename =
|
const std::string basename =
|
||||||
|
@ -941,22 +927,22 @@ void cmQtAutomoc::SearchHeadersForCppFile(const std::string& absFilename,
|
||||||
const std::string absPath = cmsys::SystemTools::GetFilenamePath(
|
const std::string absPath = cmsys::SystemTools::GetFilenamePath(
|
||||||
cmsys::SystemTools::GetRealPath(absFilename.c_str())) + '/';
|
cmsys::SystemTools::GetRealPath(absFilename.c_str())) + '/';
|
||||||
|
|
||||||
for(std::list<std::string>::const_iterator ext = headerExtensions.begin();
|
for(std::vector<std::string>::const_iterator ext = headerExtensions.begin();
|
||||||
ext != headerExtensions.end();
|
ext != headerExtensions.end();
|
||||||
++ext)
|
++ext)
|
||||||
{
|
{
|
||||||
const std::string headerName = absPath + basename + (*ext);
|
const std::string headerName = absPath + basename + "." + (*ext);
|
||||||
if (cmsys::SystemTools::FileExists(headerName.c_str()))
|
if (cmsys::SystemTools::FileExists(headerName.c_str()))
|
||||||
{
|
{
|
||||||
absHeaders.insert(headerName);
|
absHeaders.insert(headerName);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(std::list<std::string>::const_iterator ext = headerExtensions.begin();
|
for(std::vector<std::string>::const_iterator ext = headerExtensions.begin();
|
||||||
ext != headerExtensions.end();
|
ext != headerExtensions.end();
|
||||||
++ext)
|
++ext)
|
||||||
{
|
{
|
||||||
const std::string privateHeaderName = absPath+basename+"_p"+(*ext);
|
const std::string privateHeaderName = absPath+basename+"_p."+(*ext);
|
||||||
if (cmsys::SystemTools::FileExists(privateHeaderName.c_str()))
|
if (cmsys::SystemTools::FileExists(privateHeaderName.c_str()))
|
||||||
{
|
{
|
||||||
absHeaders.insert(privateHeaderName);
|
absHeaders.insert(privateHeaderName);
|
||||||
|
@ -1077,7 +1063,8 @@ bool cmQtAutomoc::GenerateMoc(const std::string& sourceFile,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string cmQtAutomoc::Join(const std::list<std::string>& lst,char separator)
|
std::string cmQtAutomoc::Join(const std::vector<std::string>& lst,
|
||||||
|
char separator)
|
||||||
{
|
{
|
||||||
if (lst.empty())
|
if (lst.empty())
|
||||||
{
|
{
|
||||||
|
@ -1085,11 +1072,11 @@ std::string cmQtAutomoc::Join(const std::list<std::string>& lst,char separator)
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string result;
|
std::string result;
|
||||||
for (std::list<std::string>::const_iterator it = lst.begin();
|
for (std::vector<std::string>::const_iterator it = lst.begin();
|
||||||
it != lst.end();
|
it != lst.end();
|
||||||
++it)
|
++it)
|
||||||
{
|
{
|
||||||
result += (*it) + separator;
|
result += "." + (*it) + separator;
|
||||||
}
|
}
|
||||||
result.erase(result.end() - 1);
|
result.erase(result.end() - 1);
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -37,18 +37,18 @@ private:
|
||||||
|
|
||||||
std::string MakeCompileSettingsString(cmMakefile* makefile);
|
std::string MakeCompileSettingsString(cmMakefile* makefile);
|
||||||
|
|
||||||
bool RunAutomoc();
|
bool RunAutomoc(cmMakefile* makefile);
|
||||||
bool GenerateMoc(const std::string& sourceFile,
|
bool GenerateMoc(const std::string& sourceFile,
|
||||||
const std::string& mocFileName);
|
const std::string& mocFileName);
|
||||||
void ParseCppFile(const std::string& absFilename,
|
void ParseCppFile(const std::string& absFilename,
|
||||||
const std::list<std::string>& headerExtensions,
|
const std::vector<std::string>& headerExtensions,
|
||||||
std::map<std::string, std::string>& includedMocs);
|
std::map<std::string, std::string>& includedMocs);
|
||||||
void StrictParseCppFile(const std::string& absFilename,
|
void StrictParseCppFile(const std::string& absFilename,
|
||||||
const std::list<std::string>& headerExtensions,
|
const std::vector<std::string>& headerExtensions,
|
||||||
std::map<std::string, std::string>& includedMocs);
|
std::map<std::string, std::string>& includedMocs);
|
||||||
void SearchHeadersForCppFile(const std::string& absFilename,
|
void SearchHeadersForCppFile(const std::string& absFilename,
|
||||||
const std::list<std::string>& headerExtensions,
|
const std::vector<std::string>& headerExtensions,
|
||||||
std::set<std::string>& absHeaders);
|
std::set<std::string>& absHeaders);
|
||||||
|
|
||||||
void ParseHeaders(const std::set<std::string>& absHeaders,
|
void ParseHeaders(const std::set<std::string>& absHeaders,
|
||||||
const std::map<std::string, std::string>& includedMocs,
|
const std::map<std::string, std::string>& includedMocs,
|
||||||
|
@ -56,7 +56,7 @@ private:
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
std::string Join(const std::list<std::string>& lst, char separator);
|
std::string Join(const std::vector<std::string>& lst, char separator);
|
||||||
bool EndsWith(const std::string& str, const std::string& with);
|
bool EndsWith(const std::string& str, const std::string& with);
|
||||||
bool StartsWith(const std::string& str, const std::string& with);
|
bool StartsWith(const std::string& str, const std::string& with);
|
||||||
std::string ReadAll(const std::string& filename);
|
std::string ReadAll(const std::string& filename);
|
||||||
|
|
Loading…
Reference in New Issue