FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

ENH: Improve Qt include path resolution macOS by hjmjohnson · Pull Request #271 · MeVisLab/pythonqt · GitHub

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .cpp  (2) .h  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
15 changes: 14 additions & 1 deletion generator/main.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,20 @@ namespace
QRegularExpression re("#define\\s+QTCORE_VERSION\\s+0x([0-9a-f]+)", QRegularExpression::CaseInsensitiveOption);
for (const QString &includeDir: getIncludeDirectories(commandLineIncludes))
{
QFileInfo fi(QDir(includeDir), "qtcoreversion.h");
std::list<std::string> candiate_paths;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

typo: candidate_paths

candiate_paths.emplace_back("qtcoreversion.h");
candiate_paths.emplace_back("QtCore/qtcoreversion.h");
candiate_paths.emplace_back("QtCore.framework/Headers/qtcoreversion.h");
QFileInfo fi(QDir(includeDir), QString("qtcoreversion.h"));
for (const std::string &candidate : candiate_paths)
{
QFileInfo candidate_fi(QDir(includeDir), candidate.c_str());
if (candidate_fi.exists() && candidate_fi.isFile())
{
fi = candidate_fi;
break;
}
}
if (fi.exists())
{
QString filePath = fi.absoluteFilePath();
Expand Down
27 changes: 27 additions & 0 deletions generator/simplecpp/simplecpp.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -3116,13 +3116,40 @@ static std::string getIncludePathFileName(const std::string &includePath, const
return path + header;
}

#ifdef __APPLE__
static std::string get_apple_framework_relative_path(const std::string& header)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Please try to use the same naming style (e.g. camel case) as the rest of the code.

{
std::string appleFrameworkHeader = {header};
// try the Framework path on Mac, if there is a path in front
// ### what about escaped slashes?
size_t slashPos = appleFrameworkHeader.find('/');
if (slashPos != std::string::npos)
{
constexpr auto framework_separator{ ".framework/Headers" };
appleFrameworkHeader.insert(slashPos, framework_separator);
}
return appleFrameworkHeader;
}
#endif // __APPLE__

static std::string openHeaderIncludePath(std::ifstream &f, const simplecpp::DUI &dui, const std::string &header)
{
for (std::list<std::string>::const_iterator it = dui.includePaths.begin(); it != dui.includePaths.end(); ++it) {
std::string simplePath = openHeader(f, getIncludePathFileName(*it, header));
if (!simplePath.empty())
return simplePath;
}
#ifdef __APPLE__
std::string appleFrameworkHeader = get_apple_framework_relative_path(header);
if (appleFrameworkHeader != header)
{
for (std::list<std::string>::const_iterator it = dui.includePaths.begin(); it != dui.includePaths.end(); ++it) {
std::string simplePath = openHeader(f, getIncludePathFileName(*it, appleFrameworkHeader));
if (!simplePath.empty())
return simplePath;
}
}
#endif // __APPLE__
return "";
}

Expand Down
3 changes: 3 additions & 0 deletions generator/simplecpp/simplecpp.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
#endif

namespace simplecpp {

std::string get_apple_framework_relative_path(const std::string& header);

Comment on lines +43 to +44

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Does this have to be public, or could you just put it into an anonymous namespace in the implementation?

/** C code standard */
enum cstd_t { CUnknown=-1, C89, C99, C11, C17, C23 };

Expand Down
Loading

Back | FazBrowse Home | New Git URL