Skip to content

Commit d3f3ecc

Browse files
committed
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.
1 parent ff7398a commit d3f3ecc

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/setup_payload/SetupPayloadHelper.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ static CHIP_ERROR addParameter(SetupPayload & setupPayload, const SetupPayloadPa
143143

144144
CHIP_ERROR loadPayloadFromFile(SetupPayload & setupPayload, const std::string & filePath)
145145
{
146+
#if defined(_LIBCPP_VERSION) && _LIBCPP_HAS_FILESYSTEM == 0
147+
(void) setupPayload;
148+
(void) filePath;
149+
return CHIP_ERROR_NOT_IMPLEMENTED;
150+
#else
146151
std::ifstream fileStream(filePath);
147152
VerifyOrReturnError(!fileStream.fail(), CHIP_ERROR_INVALID_ARGUMENT);
148153

@@ -165,6 +170,7 @@ CHIP_ERROR loadPayloadFromFile(SetupPayload & setupPayload, const std::string &
165170
ReturnErrorOnFailure(addParameter(setupPayload, parameter));
166171
}
167172
return CHIP_NO_ERROR;
173+
#endif
168174
}
169175

170176
CHIP_ERROR generateQRCodeFromFilePath(std::string filePath, std::string & outCode)

0 commit comments

Comments
 (0)