Skip to content

Commit

Permalink
If compiling against libc++ without filesystem, don't reference fstream
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
stevew817 committed Feb 25, 2025
1 parent ff7398a commit d3f3ecc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/setup_payload/SetupPayloadHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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)
Expand Down

0 comments on commit d3f3ecc

Please sign in to comment.