From d3f3ecc5909bac75961d3028b244325dcb280f24 Mon Sep 17 00:00:00 2001 From: Steven Cooreman Date: Tue, 25 Feb 2025 14:00:03 +0100 Subject: [PATCH] If compiling against libc++ without filesystem, don't reference fstream SetupPayloadHelper.cpp is compiled as part of the setup_payload static library, which is built for (almost?) all targets, even if those targets may not have an onboard filesystem. For GCC's libstdc++ this doesn't matter as it still provides a stub for std::ifstream, but LLVM's libc++ doesn't. The alternative to this patch is to split out SetupPayloadHelper.cpp in its own library which is only pulled in by targets with filesystem support. --- src/setup_payload/SetupPayloadHelper.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/setup_payload/SetupPayloadHelper.cpp b/src/setup_payload/SetupPayloadHelper.cpp index 36fed5a425e46a..623937737a45ab 100644 --- a/src/setup_payload/SetupPayloadHelper.cpp +++ b/src/setup_payload/SetupPayloadHelper.cpp @@ -143,6 +143,11 @@ static CHIP_ERROR addParameter(SetupPayload & setupPayload, const SetupPayloadPa CHIP_ERROR loadPayloadFromFile(SetupPayload & setupPayload, const std::string & filePath) { +#if defined(_LIBCPP_VERSION) && _LIBCPP_HAS_FILESYSTEM == 0 + (void) setupPayload; + (void) filePath; + return CHIP_ERROR_NOT_IMPLEMENTED; +#else std::ifstream fileStream(filePath); VerifyOrReturnError(!fileStream.fail(), CHIP_ERROR_INVALID_ARGUMENT); @@ -165,6 +170,7 @@ CHIP_ERROR loadPayloadFromFile(SetupPayload & setupPayload, const std::string & ReturnErrorOnFailure(addParameter(setupPayload, parameter)); } return CHIP_NO_ERROR; +#endif } CHIP_ERROR generateQRCodeFromFilePath(std::string filePath, std::string & outCode)