Skip to content

Commit 31bffbf

Browse files
committed
ENH: Add support to find Headers in Apple Frameworks
The header locations in apple frameworks require manipulation of the directory name in a '<pkg/myhdr.h>' include defintion. The header file is located at <pkg.framework/Headers/myhdr.h> in a framework.
1 parent a6d3586 commit 31bffbf

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

simplecpp.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3212,13 +3212,40 @@ static std::string getIncludePathFileName(const std::string &includePath, const
32123212
return isAbsolutePath(includePath) ? absoluteSimplifiedHeaderPath : extractRelativePathFromAbsolute(absoluteSimplifiedHeaderPath);
32133213
}
32143214

3215+
#ifdef __APPLE__
3216+
static std::string get_apple_framework_relative_path(const std::string& header)
3217+
{
3218+
std::string appleFrameworkHeader = {header};
3219+
// try the Framework path on Mac, if there is a path in front
3220+
// ### what about escaped slashes?
3221+
size_t slashPos = appleFrameworkHeader.find('/');
3222+
if (slashPos != std::string::npos)
3223+
{
3224+
constexpr auto framework_separator{ ".framework/Headers" };
3225+
appleFrameworkHeader.insert(slashPos, framework_separator);
3226+
}
3227+
return appleFrameworkHeader;
3228+
}
3229+
#endif // __APPLE__
3230+
32153231
static std::string openHeaderIncludePath(std::ifstream &f, const simplecpp::DUI &dui, const std::string &header)
32163232
{
32173233
for (std::list<std::string>::const_iterator it = dui.includePaths.begin(); it != dui.includePaths.end(); ++it) {
32183234
std::string path = openHeader(f, getIncludePathFileName(*it, header));
32193235
if (!path.empty())
32203236
return path;
32213237
}
3238+
#ifdef __APPLE__
3239+
std::string appleFrameworkHeader = get_apple_framework_relative_path(header);
3240+
if (appleFrameworkHeader != header)
3241+
{
3242+
for (std::list<std::string>::const_iterator it = dui.includePaths.begin(); it != dui.includePaths.end(); ++it) {
3243+
std::string simplePath = openHeader(f, getIncludePathFileName(*it, appleFrameworkHeader));
3244+
if (!simplePath.empty())
3245+
return simplePath;
3246+
}
3247+
}
3248+
#endif // __APPLE__
32223249
return "";
32233250
}
32243251

0 commit comments

Comments
 (0)