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