From b88f4fccba5bd00c4f49bc6bc0d77ebc3d23a2ad Mon Sep 17 00:00:00 2001 From: Yakun Xu Date: Wed, 15 Jul 2020 01:04:12 +0800 Subject: [PATCH] [flash] avoid build when not needed (#5235) --- src/core/utils/flash.cpp | 4 ++++ tests/unit/test_flash.cpp | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/core/utils/flash.cpp b/src/core/utils/flash.cpp index 4487427fe..aa533710d 100644 --- a/src/core/utils/flash.cpp +++ b/src/core/utils/flash.cpp @@ -35,6 +35,8 @@ #include "common/code_utils.hpp" #include "common/instance.hpp" +#if OPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE + namespace ot { const uint32_t ot::Flash::sSwapActive; @@ -306,3 +308,5 @@ void Flash::Wipe(void) } } // namespace ot + +#endif // OPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE diff --git a/tests/unit/test_flash.cpp b/tests/unit/test_flash.cpp index 92f8ccb43..4710a30c8 100644 --- a/tests/unit/test_flash.cpp +++ b/tests/unit/test_flash.cpp @@ -41,6 +41,7 @@ namespace ot { void TestFlash(void) { +#if OPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE uint8_t readBuffer[256]; uint8_t writeBuffer[256]; @@ -182,6 +183,7 @@ void TestFlash(void) VerifyOrQuit(length == key, "Get() did not return expected length"); VerifyOrQuit(memcmp(readBuffer, writeBuffer, length) == 0, "Get() did not return expected value"); } +#endif // OPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE } } // namespace ot