Skip to content

ENH: Add support to find Headers in Apple Frameworks #448

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions simplecpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3212,13 +3212,40 @@ static std::string getIncludePathFileName(const std::string &includePath, const
return isAbsolutePath(includePath) ? absoluteSimplifiedHeaderPath : extractRelativePathFromAbsolute(absoluteSimplifiedHeaderPath);
}

#ifdef __APPLE__
static std::string get_apple_framework_relative_path(const std::string& header)
{
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 path = openHeader(f, getIncludePathFileName(*it, header));
if (!path.empty())
return path;
}
#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
Loading