Skip to content

Commit

Permalink
Pull latest pigweed version. (#20158)
Browse files Browse the repository at this point in the history
* Pull latest pigweed version.

```
cd third_party/pigweed/repo
git fetch https://github.com/google/pigweed.git main
git checkout FETCH_HEAD
```

* change std::span/std::as_bytes to pw::span/pw::as_bytes to make pigweed polyfill happy

* Switch include: from span to pw_span.h

* More replacing of std::span with pw::span

* Restyle

* Set pw_span_ENABLE_STD_SPAN_POLYFILL to false for anything that sets a sys_io_BACKEND

* fix amebad-pigweed builds

* Ensure import is done for polyfill settings for Amebad

* Fix ESP32 builds with pw_span

* Restyle
  • Loading branch information
andy31415 authored and pull[bot] committed Oct 24, 2023
1 parent 28e80d8 commit 8138897
Show file tree
Hide file tree
Showing 27 changed files with 48 additions and 36 deletions.
4 changes: 4 additions & 0 deletions config/ameba/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
# Options from standalone-chip.mk that differ from configure defaults. These
# options are used from examples/.

import("//build_overrides/pigweed.gni")
import("$dir_pw_span/polyfill.gni")

chip_device_platform = "ameba"

chip_project_config_include = ""
Expand All @@ -35,4 +38,5 @@ custom_toolchain = "//third_party/connectedhomeip/config/ameba/toolchain:ameba"

pw_build_PIP_CONSTRAINTS =
[ "//third_party/connectedhomeip/scripts/constraints.txt" ]
pw_span_ENABLE_STD_SPAN_POLYFILL = false
cpp_standard = "c++17"
1 change: 1 addition & 0 deletions config/bouffalolab/bl602/lib/pw_rpc/pw_rpc.gni
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pw_log_BACKEND = "$dir_pw_log_basic"
pw_assert_BACKEND = "$dir_pw_assert_log:check_backend"
pw_sys_io_BACKEND =
"${chip_root}/examples/platform/bl602/pw_sys_io:pw_sys_io_bl602"
pw_span_ENABLE_STD_SPAN_POLYFILL = false

pw_build_LINK_DEPS = [
"$dir_pw_assert:impl",
Expand Down
1 change: 1 addition & 0 deletions config/efr32/lib/pw_rpc/pw_rpc.gni
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pw_log_BACKEND = "$dir_pw_log_basic"
pw_assert_BACKEND = "$dir_pw_assert_log:check_backend"
pw_sys_io_BACKEND =
"${chip_root}/examples/platform/efr32/pw_sys_io:pw_sys_io_efr32"
pw_span_ENABLE_STD_SPAN_POLYFILL = false

pw_build_LINK_DEPS = [
"$dir_pw_assert:impl",
Expand Down
4 changes: 3 additions & 1 deletion config/esp32/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

# Options from standalone-chip.mk that differ from configure defaults. These
# options are used from examples/.

import("//build_overrides/pigweed.gni")
import("$dir_pw_span/polyfill.gni")
chip_device_platform = "esp32"

chip_project_config_include = ""
Expand All @@ -38,3 +39,4 @@ custom_toolchain = "//third_party/connectedhomeip/config/esp32/toolchain:esp32"
# whatever pigweed ships with
pw_build_PIP_CONSTRAINTS =
[ "//third_party/connectedhomeip/scripts/constraints.txt" ]
pw_span_ENABLE_STD_SPAN_POLYFILL = false
1 change: 1 addition & 0 deletions config/mbed/chip-gn/lib/pw_rpc/pw_rpc.gni
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pw_sys_io_BACKEND =
"${chip_root}/examples/platform/mbed/pw_sys_io:pw_sys_io_mbed"
pw_rpc_system_server_BACKEND =
"${chip_root}/examples/common/pigweed:system_rpc_server"
pw_span_ENABLE_STD_SPAN_POLYFILL = false

pw_build_LINK_DEPS = [
"$dir_pw_assert:impl",
Expand Down
1 change: 1 addition & 0 deletions config/qpg/lib/pw_rpc/pw_rpc.gni
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import("//build_overrides/pigweed.gni")
pw_log_BACKEND = "$dir_pw_log_basic"
pw_assert_BACKEND = "$dir_pw_assert_log:check_backend"
pw_sys_io_BACKEND = "${chip_root}/examples/platform/qpg/pw_sys_io:pw_sys_io_qpg"
pw_span_ENABLE_STD_SPAN_POLYFILL = false

pw_build_LINK_DEPS = [
"$dir_pw_assert:impl",
Expand Down
1 change: 1 addition & 0 deletions examples/chef/linux/with_pw_rpc.gni
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pw_rpc_system_server_BACKEND = "${chip_root}/config/linux/lib/pw_rpc:pw_rpc"
dir_pw_third_party_nanopb = "${chip_root}/third_party/nanopb/repo"
pw_chrono_SYSTEM_CLOCK_BACKEND = "$dir_pw_chrono_stl:system_clock"
pw_sync_MUTEX_BACKEND = "$dir_pw_sync_stl:mutex_backend"
pw_span_ENABLE_STD_SPAN_POLYFILL = false

pw_build_LINK_DEPS = [
"$dir_pw_assert:impl",
Expand Down
6 changes: 3 additions & 3 deletions examples/common/pigweed/RpcService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

#include "RpcService.h"

#include "pw_span/span.h"
#include <array>
#include <span>
#include <string_view>

#include "pw_hdlc/rpc_channel.h"
Expand Down Expand Up @@ -56,7 +56,7 @@ class ChipRpcChannelOutput : public pw::rpc::ChannelOutput
pw::rpc::ChannelOutput(channel_name), mWriter(writer), mAddress(address)
{}

pw::Status Send(std::span<const std::byte> buffer) override
pw::Status Send(pw::span<const std::byte> buffer) override
{
if (buffer.empty())
{
Expand Down Expand Up @@ -102,7 +102,7 @@ void Start(void (*RegisterServices)(pw::rpc::Server &), ::chip::rpc::Mutex * uar
{
uart_mutex->Lock();
}
pw::hdlc::WriteUIFrame(1, std::as_bytes(std::span(log)), sysIoWriter);
pw::hdlc::WriteUIFrame(1, pw::as_bytes(pw::span(log)), sysIoWriter);
if (uart_mutex)
{
uart_mutex->Unlock();
Expand Down
4 changes: 2 additions & 2 deletions examples/common/pigweed/mbed/Rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ Thread * Init()

ChipLogProgress(NotSpecified, "RPC service starting...\r\n");

auto error = rpcThread.start(RunRpcService);
long error = rpcThread.start(RunRpcService);
if (error != osOK)
{
ChipLogError(NotSpecified, "Run RPC service failed[%d]", error);
ChipLogError(NotSpecified, "Run RPC service failed[%ld]", error);
return NULL;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/common/pigweed/system_rpc_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void Init()
{
// Send log messages to HDLC address 1. This prevents logs from interfering
// with pw_rpc communications.
pw::log_basic::SetOutput([](std::string_view log) { pw::hdlc::WriteUIFrame(1, std::as_bytes(std::span(log)), writer); });
pw::log_basic::SetOutput([](std::string_view log) { pw::hdlc::WriteUIFrame(1, pw::as_bytes(pw::span(log)), writer); });
}

rpc::Server & Server()
Expand Down
1 change: 1 addition & 0 deletions examples/lighting-app/linux/with_pw_rpc.gni
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pw_rpc_system_server_BACKEND = "${chip_root}/config/linux/lib/pw_rpc:pw_rpc"
dir_pw_third_party_nanopb = "${chip_root}/third_party/nanopb/repo"
pw_chrono_SYSTEM_CLOCK_BACKEND = "$dir_pw_chrono_stl:system_clock"
pw_sync_MUTEX_BACKEND = "$dir_pw_sync_stl:mutex_backend"
pw_span_ENABLE_STD_SPAN_POLYFILL = false

pw_build_LINK_DEPS = [
"$dir_pw_assert:impl",
Expand Down
4 changes: 2 additions & 2 deletions examples/platform/ameba/PigweedLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
#include <pw_hdlc/encoder.h>
#include <pw_stream/sys_io_stream.h>

#include "pw_span/span.h"
#include <assert.h>
#include <span>

namespace PigweedLogger {
namespace {
Expand All @@ -41,7 +41,7 @@ bool uartInitialised;

void send()
{
pw::hdlc::WriteUIFrame(kLogHdlcAddress, std::as_bytes(std::span(sWriteBuffer, sWriteBufferPos)), sWriter);
pw::hdlc::WriteUIFrame(kLogHdlcAddress, pw::as_bytes(pw::span(sWriteBuffer, sWriteBufferPos)), sWriter);
sWriteBufferPos = 0;
}

Expand Down
4 changes: 2 additions & 2 deletions examples/platform/ameba/pw_sys_io/sys_io_ameba.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ Status WriteByte(std::byte b)
StatusWithSize WriteLine(const std::string_view & s)
{
size_t chars_written = 0;
StatusWithSize result = WriteBytes(std::as_bytes(std::span(s)));
StatusWithSize result = WriteBytes(pw::as_bytes(pw::span(s)));
if (!result.ok())
{
return result;
}
chars_written += result.size();
result = WriteBytes(std::as_bytes(std::span("\r\n", 2)));
result = WriteBytes(pw::as_bytes(pw::span("\r\n", 2)));
chars_written += result.size();

return StatusWithSize(result.status(), chars_written);
Expand Down
4 changes: 2 additions & 2 deletions examples/platform/bouffalolab/bl602/PigweedLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
#include <pw_stream/sys_io_stream.h>
#include <pw_sys_io_efr32/init.h>

#include "pw_span/span.h"
#include <cassert>
#include <cstdint>
#include <span>
#include <string_view>

namespace PigweedLogger {
Expand All @@ -52,7 +52,7 @@ static char sWriteBuffer[kWriteBufferSize];

static void send(void)
{
pw::hdlc::WriteUIFrame(kLogHdlcAddress, std::as_bytes(std::span(sWriteBuffer, sWriteBufferPos)), sWriter);
pw::hdlc::WriteUIFrame(kLogHdlcAddress, pw::as_bytes(pw::span(sWriteBuffer, sWriteBufferPos)), sWriter);
sWriteBufferPos = 0;
}

Expand Down
4 changes: 2 additions & 2 deletions examples/platform/bouffalolab/bl602/pw_sys_io/sys_io_efr32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ Status WriteByte(std::byte b)
StatusWithSize WriteLine(const std::string_view & s)
{
size_t chars_written = 0;
StatusWithSize result = WriteBytes(std::as_bytes(std::span(s)));
StatusWithSize result = WriteBytes(pw::as_bytes(pw::span(s)));
if (!result.ok())
{
return result;
}
chars_written += result.size();
result = WriteBytes(std::as_bytes(std::span("\r\n", 2)));
result = WriteBytes(pw::as_bytes(pw::span("\r\n", 2)));
chars_written += result.size();

return StatusWithSize(result.status(), chars_written);
Expand Down
4 changes: 2 additions & 2 deletions examples/platform/efr32/PigweedLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
#include <pw_stream/sys_io_stream.h>
#include <pw_sys_io_efr32/init.h>

#include "pw_span/span.h"
#include <cassert>
#include <cstdint>
#include <span>
#include <string_view>

namespace PigweedLogger {
Expand All @@ -52,7 +52,7 @@ static char sWriteBuffer[kWriteBufferSize];

static void send(void)
{
pw::hdlc::WriteUIFrame(kLogHdlcAddress, std::as_bytes(std::span(sWriteBuffer, sWriteBufferPos)), sWriter);
pw::hdlc::WriteUIFrame(kLogHdlcAddress, pw::as_bytes(pw::span(sWriteBuffer, sWriteBufferPos)), sWriter);
sWriteBufferPos = 0;
}

Expand Down
4 changes: 2 additions & 2 deletions examples/platform/efr32/pw_sys_io/sys_io_efr32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ Status WriteByte(std::byte b)
StatusWithSize WriteLine(const std::string_view & s)
{
size_t chars_written = 0;
StatusWithSize result = WriteBytes(std::as_bytes(std::span(s)));
StatusWithSize result = WriteBytes(pw::as_bytes(pw::span(s)));
if (!result.ok())
{
return result;
}
chars_written += result.size();
result = WriteBytes(std::as_bytes(std::span("\r\n", 2)));
result = WriteBytes(pw::as_bytes(pw::span("\r\n", 2)));
chars_written += result.size();

return StatusWithSize(result.status(), chars_written);
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/esp32/PigweedLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ bool uartInitialised;

void send()
{
pw::hdlc::WriteUIFrame(kLogHdlcAddress, std::as_bytes(std::span(sWriteBuffer, sWriteBufferPos)), sWriter);
pw::hdlc::WriteUIFrame(kLogHdlcAddress, pw::as_bytes(pw::span(sWriteBuffer, sWriteBufferPos)), sWriter);
sWriteBufferPos = 0;
}

Expand Down
4 changes: 2 additions & 2 deletions examples/platform/esp32/pw_sys_io/sys_io_esp32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ Status WriteByte(std::byte b)
StatusWithSize WriteLine(const std::string_view & s)
{
size_t chars_written = 0;
StatusWithSize result = WriteBytes(std::as_bytes(std::span(s)));
StatusWithSize result = WriteBytes(pw::as_bytes(pw::span(s)));
if (!result.ok())
{
return result;
}
chars_written += result.size();
result = WriteBytes(std::as_bytes(std::span("\r\n", 2)));
result = WriteBytes(pw::as_bytes(pw::span("\r\n", 2)));
chars_written += result.size();

return StatusWithSize(result.status(), chars_written);
Expand Down
4 changes: 2 additions & 2 deletions examples/platform/mbed/pw_sys_io/sys_io_mbed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ Status WriteByte(std::byte b)
StatusWithSize WriteLine(const std::string_view & s)
{
size_t chars_written = 0;
StatusWithSize result = WriteBytes(std::as_bytes(std::span(s)));
StatusWithSize result = WriteBytes(pw::as_bytes(pw::span(s)));
if (!result.ok())
{
return result;
}
chars_written += result.size();

// Write trailing newline.
result = WriteBytes(std::as_bytes(std::span("\r\n", 2)));
result = WriteBytes(pw::as_bytes(pw::span("\r\n", 2)));
chars_written += result.size();

return StatusWithSize(result.status(), chars_written);
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/mbed/util/PigweedLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ char sWriteBuffer[kWriteBufferSize];

void send()
{
pw::hdlc::WriteUIFrame(kLogHdlcAddress, std::as_bytes(std::span(sWriteBuffer, sWriteBufferPos)), sWriter);
pw::hdlc::WriteUIFrame(kLogHdlcAddress, pw::as_bytes(pw::span(sWriteBuffer, sWriteBufferPos)), sWriter);
sWriteBufferPos = 0;
}

Expand Down
4 changes: 2 additions & 2 deletions examples/platform/nrfconnect/pw_sys_io/sys_io_nrfconnect.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ Status WriteByte(std::byte b)
StatusWithSize WriteLine(const std::string_view & s)
{
size_t chars_written = 0;
StatusWithSize result = WriteBytes(std::as_bytes(std::span(s)));
StatusWithSize result = WriteBytes(pw::as_bytes(pw::span(s)));
if (!result.ok())
{
return result;
}
chars_written += result.size();

// Write trailing newline.
result = WriteBytes(std::as_bytes(std::span("\r\n", 2)));
result = WriteBytes(pw::as_bytes(pw::span("\r\n", 2)));
chars_written += result.size();

return StatusWithSize(result.status(), chars_written);
Expand Down
4 changes: 2 additions & 2 deletions examples/platform/nrfconnect/util/PigweedLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
#include <pw_stream/sys_io_stream.h>
#include <pw_sys_io_nrfconnect/init.h>

#include "pw_span/span.h"
#include <cassert>
#include <cstdint>
#include <span>
#include <string_view>

namespace PigweedLogger {
Expand All @@ -61,7 +61,7 @@ bool sIsPanicMode;

void flush()
{
pw::hdlc::WriteUIFrame(kLogHdlcAddress, std::as_bytes(std::span(sWriteBuffer, sWriteBufferPos)), sWriter);
pw::hdlc::WriteUIFrame(kLogHdlcAddress, pw::as_bytes(pw::span(sWriteBuffer, sWriteBufferPos)), sWriter);
sWriteBufferPos = 0;
}

Expand Down
4 changes: 2 additions & 2 deletions examples/platform/qpg/PigweedLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
#include <pw_stream/sys_io_stream.h>
#include <pw_sys_io_qpg/init.h>

#include "pw_span/span.h"
#include <cassert>
#include <cstdint>
#include <span>
#include <string_view>

namespace PigweedLogger {
Expand All @@ -54,7 +54,7 @@ static char sWriteBuffer[kWriteBufferSize];

static void send(void)
{
pw::hdlc::WriteUIFrame(kLogHdlcAddress, std::as_bytes(std::span(sWriteBuffer, sWriteBufferPos)), sWriter);
pw::hdlc::WriteUIFrame(kLogHdlcAddress, pw::as_bytes(pw::span(sWriteBuffer, sWriteBufferPos)), sWriter);
sWriteBufferPos = 0;
}

Expand Down
4 changes: 2 additions & 2 deletions examples/platform/qpg/pw_sys_io/sys_io_qpg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ Status WriteByte(std::byte b)
StatusWithSize WriteLine(const std::string_view & s)
{
size_t chars_written = 0;
StatusWithSize result = WriteBytes(std::as_bytes(std::span(s)));
StatusWithSize result = WriteBytes(pw::as_bytes(pw::span(s)));
if (!result.ok())
{
return result;
}
chars_written += result.size();
result = WriteBytes(std::as_bytes(std::span("\r\n", 2)));
result = WriteBytes(pw::as_bytes(pw::span("\r\n", 2)));
chars_written += result.size();

return StatusWithSize(result.status(), chars_written);
Expand Down
4 changes: 2 additions & 2 deletions src/platform/bouffalolab/BL602/KeyValueStoreManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ CHIP_ERROR KeyValueStoreManagerImpl::_Delete(const char * key)
// size_t offset_bytes) const
// {
// assert(CHIP_KVS_AVAILABLE);
// auto status_and_size = mKvs.Get(key, std::span<std::byte>(reinterpret_cast<std::byte *>(value), value_size), offset_bytes);
// auto status_and_size = mKvs.Get(key, pw::span<std::byte>(reinterpret_cast<std::byte *>(value), value_size), offset_bytes);
// if (read_bytes_size)
// {
// *read_bytes_size = status_and_size.size();
Expand Down Expand Up @@ -139,7 +139,7 @@ CHIP_ERROR KeyValueStoreManagerImpl::_Delete(const char * key)
// CHIP_ERROR KeyValueStoreManagerImpl::_Put(const char * key, const void * value, size_t value_size)
// {
// assert(CHIP_KVS_AVAILABLE);
// auto status = mKvs.Put(key, std::span<const std::byte>(reinterpret_cast<const std::byte *>(value), value_size));
// auto status = mKvs.Put(key, pw::span<const std::byte>(reinterpret_cast<const std::byte *>(value), value_size));
// switch (status.code())
// {
// case pw::OkStatus().code():
Expand Down
2 changes: 1 addition & 1 deletion third_party/pigweed/repo
Submodule repo updated 425 files

0 comments on commit 8138897

Please sign in to comment.