@@ -2431,6 +2431,20 @@ static bool isAbsolutePath(const std::string &path)
2431
2431
}
2432
2432
#endif
2433
2433
2434
+ namespace {
2435
+ // "<Pkg/Hdr.h>" -> "<Pkg.framework/Headers/Hdr.h>"
2436
+ static inline std::string
2437
+ toAppleFrameworkRelative (const std::string& header)
2438
+ {
2439
+ const std::size_t slash = header.find (' /' );
2440
+ if (slash == std::string::npos)
2441
+ return header; // no transformation applicable
2442
+ const std::string pkg = header.substr (0 , slash);
2443
+ const std::string tail = header.substr (slash); // includes '/'
2444
+ return pkg + " .framework/Headers" + tail;
2445
+ }
2446
+ }
2447
+
2434
2448
namespace simplecpp {
2435
2449
/* *
2436
2450
* perform path simplifications for . and ..
@@ -3008,20 +3022,10 @@ static std::string openHeader(std::ifstream &f, const simplecpp::DUI &dui, const
3008
3022
return path;
3009
3023
}
3010
3024
3011
- // a named lambda function to insert the ".framework/Headers" part for apple frameworks
3012
- auto get_apple_framework_relative_path= [](const std::string& appleFrameworkHeader) -> std::string {
3013
- // try the Framework path on apple OS, if there is a path in front
3014
- const size_t slashPos = appleFrameworkHeader.find (' /' );
3015
- if (slashPos == std::string::npos) {
3016
- return appleFrameworkHeader;
3017
- }
3018
- constexpr auto frameworkSuffix{ " .framework/Headers" };
3019
- return appleFrameworkHeader.substr (0 , slashPos) + frameworkSuffix + appleFrameworkHeader.substr (slashPos);
3020
- };
3021
3025
// on Apple, try to find the header in the framework path
3022
3026
// Convert <includePath>/PKGNAME/myHeader -> <includePath>/PKGNAME.framework/Headers/myHeader
3023
3027
// Works on any platform, but only relevant when compiling against Apple SDKs.
3024
- const std::string appleFrameworkHeader = get_apple_framework_relative_path (header);
3028
+ const std::string appleFrameworkHeader = toAppleFrameworkRelative (header);
3025
3029
if (appleFrameworkHeader != header) {
3026
3030
for (const auto & includePath: dui.includePaths ) {
3027
3031
const std::string frameworkCandidatePath = includePath + ' /' + appleFrameworkHeader;
0 commit comments