Skip to content

Commit

Permalink
Update pigweed to the latest version (project-chip#35644)
Browse files Browse the repository at this point in the history
* Pull latest pigweed

* Make pigweed pull python 3.11 on macs, to have a consistent build environment

* Restyle

* Remove unused import

* Update signature of WriteLine - this was updated in pigwed to use std::string_view pass by value

* Workaround for slc errors for efr32

* Disable openssl warning of invalid function cast. This is already covered in connect.c via OPENSSL_MSVC_PRAGMA and is intentional

* ZAP regen because we change clang-format version

* SystemConfig includes ICDServerBuildConfig.h. Add the dependency as a formal dependency

* Fix typo in WriteLine parameter

* Restyle

* Fix the typo .. again, I had deleted the wrong thing

* Look to fix openiot sdk build

* Restyle

* Fix clang-tidy: it became stricter on unused arguments

* Fix tidy run for real this time ... at least one file passes locally

* Different fix for clang-tidy, seems more targeted

* More updates: -S is also a flag that clang tidy would not like according to https://github.com/llvm/llvm-project/pull/101103/files

* Fix typo

* Disable two more diagnostics that seem to show up in clang-tidy

* Need comma for - updated config

* Fix some clang-tidy findings

* More clang-tidy fixes

* Generate script update: make sure metadata is generated

* more tidy and dependency fixes

* more clang tidy make happy updates

* Restyle

* Fix too many args error

* Clean up an odd dependency

* Signature update for android test functions

* Fix type cast for android callback on type

* Fix the order of checks in TCP endpoint implementations to be what tests expect ... ugly that we verify input args first

* Fix invalid verify

* Fix typo

* Additional socket checks for socket inet implementations

* Self-review update

* Undo merge error

* Undo pigweed repo loss

* One more extra check to make clang-tidy happy

* One more extra check to make clang-tidy happy

* Switch to nolint

* Avoid large code deltas

* Restyle

* Restyled by clang-format

* Undo changes to build of attestation_verifier: it seems not needed

* Fix for clang-tidy requiring updated template keywords

* Fix the template argument ... there is a 2nd invoke type

* Another fix

---------

Co-authored-by: Andrei Litvin <[email protected]>
Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
3 people authored and nivi-apple committed Sep 24, 2024
1 parent 50ecf3d commit 39a9222
Show file tree
Hide file tree
Showing 43 changed files with 18,379 additions and 18,036 deletions.
4 changes: 3 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Checks: >
-bugprone-multi-level-implicit-pointer-conversion,
-bugprone-narrowing-conversions,
-bugprone-not-null-terminated-result,
-bugprone-pointer-arithmetic-on-polymorphic-object,
-bugprone-reserved-identifier,
-bugprone-signed-char-misuse,
-bugprone-suspicious-include,
Expand All @@ -45,6 +46,7 @@ Checks: >
-clang-analyzer-security.insecureAPI.rand,
-clang-analyzer-security.insecureAPI.strcpy,
-clang-analyzer-unix.Malloc,
-clang-diagnostic-implicit-int-conversion
-clang-diagnostic-implicit-int-conversion,
-clang-diagnostic-missing-template-arg-list-after-template-kw
WarningsAsErrors: '*'
HeaderFilterRegex: '(src|examples|zzz_generated|credentials).*(?<!third_party.*repo)'
2 changes: 1 addition & 1 deletion examples/platform/ameba/pw_sys_io/sys_io_ameba.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Status WriteByte(std::byte b)
}

// Writes a string using pw::sys_io, and add newline characters at the end.
StatusWithSize WriteLine(const std::string_view & s)
StatusWithSize WriteLine(std::string_view s)
{
size_t chars_written = 0;
StatusWithSize result = WriteBytes(pw::as_bytes(pw::span(s)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Status WriteByte(std::byte b)
}

// Writes a string using pw::sys_io, and add newline characters at the end.
StatusWithSize WriteLine(const std::string_view & s)
StatusWithSize WriteLine(std::string_view s)
{
size_t chars_written = 0;
StatusWithSize result = WriteBytes(pw::as_bytes(pw::span(s)));
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/esp32/pw_sys_io/sys_io_esp32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Status WriteByte(std::byte b)
}

// Writes a string using pw::sys_io, and add newline characters at the end.
StatusWithSize WriteLine(const std::string_view & s)
StatusWithSize WriteLine(std::string_view s)
{
size_t chars_written = 0;
StatusWithSize result = WriteBytes(pw::as_bytes(pw::span(s)));
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/mbed/pw_sys_io/sys_io_mbed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Status WriteByte(std::byte b)
}

// Writes a string using pw::sys_io, and add newline characters at the end.
StatusWithSize WriteLine(const std::string_view & s)
StatusWithSize WriteLine(std::string_view s)
{
size_t chars_written = 0;
StatusWithSize result = WriteBytes(pw::as_bytes(pw::span(s)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Status WriteByte(std::byte b)
}

// Writes a string using pw::sys_io, and add newline characters at the end.
StatusWithSize WriteLine(const std::string_view & s)
StatusWithSize WriteLine(std::string_view s)
{
size_t chars_written = 0;
StatusWithSize result = WriteBytes(pw::as_bytes(pw::span(s)));
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/nxp/pw_sys_io/sys_io_nxp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Status WriteByte(std::byte b)
}

// Writes a string using pw::sys_io, and add newline characters at the end.
StatusWithSize WriteLine(const std::string_view & s)
StatusWithSize WriteLine(std::string_view s)
{
size_t chars_written = 0;
StatusWithSize result = WriteBytes(pw::as_bytes(pw::span(s)));
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/qpg/pw_sys_io/sys_io_qpg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Status WriteByte(std::byte b)
}

// Writes a string using pw::sys_io, and add newline characters at the end.
StatusWithSize WriteLine(const std::string_view & s)
StatusWithSize WriteLine(std::string_view s)
{
size_t chars_written = 0;
StatusWithSize result = WriteBytes(pw::as_bytes(pw::span(s)));
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/silabs/pw_sys_io/sys_io_silabs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Status WriteByte(std::byte b)
}

// Writes a string using pw::sys_io, and add newline characters at the end.
StatusWithSize WriteLine(const std::string_view & s)
StatusWithSize WriteLine(std::string_view s)
{
size_t chars_written = 0;
StatusWithSize result = WriteBytes(pw::as_bytes(pw::span(s)));
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/telink/pw_sys_io/sys_io_telink.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Status WriteByte(std::byte b)
}

// Writes a string using pw::sys_io, and add newline characters at the end.
StatusWithSize WriteLine(const std::string_view & s)
StatusWithSize WriteLine(std::string_view s)
{
size_t chars_written = 0;
StatusWithSize result = WriteBytes(pw::as_bytes(pw::span(s)));
Expand Down
8 changes: 4 additions & 4 deletions examples/tv-casting-app/tv-casting-common/core/Command.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class Command

// Invoke command
MediaClusterBase cluster(exchangeMgr, sessionHandle, _commandContext->mEndpoint->GetId());
CHIP_ERROR err = cluster.template InvokeCommand(
CHIP_ERROR err = cluster.template InvokeCommand<RequestType>(
_commandContext->mRequest, _commandContext,
// Command success handler
[](void * __context, const typename RequestType::ResponseType & response) {
Expand Down Expand Up @@ -146,6 +146,6 @@ struct CommandContext
chip::Optional<uint16_t> mTimedInvokeTimeoutMs;
};

}; // namespace core
}; // namespace casting
}; // namespace matter
} // namespace core
} // namespace casting
} // namespace matter
9 changes: 9 additions & 0 deletions scripts/run-clang-tidy-on-compile-commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ def __init__(self, json_entry, gcc_sysroot=None):
command_items = shlex.split(command)
compiler = os.path.basename(command_items[0])

# Clang-tidy complains about "unused argument '-c'"
# We could disable that with something like
#
# self.clang_arguments.append("-Wno-unused-command-line-argument")
#
# However that seems to potentially disable a lot, so for now just filter out the
# offending argument
command_items = [arg for arg in command_items if arg not in {'-c', '-S'}]

# Allow gcc/g++ invocations to also be tidied - arguments should be
# compatible and on darwin gcc/g++ is actually a symlink to clang
if compiler in ['clang++', 'clang', 'gcc', 'g++']:
Expand Down
6 changes: 6 additions & 0 deletions scripts/run_codegen_targets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,9 @@ for name in $(ninja -C "$OUT_DIR" -t targets | grep -E 'dbus.*codegen:' | sed 's
echo "Generating $name ..."
ninja -C "$OUT_DIR" "$name"
done

# TLV decoding metadata
for name in $(ninja -C "$OUT_DIR" -t targets | grep -E '_generate' | sed 's/: .*//'); do
echo "Generating $name ..."
ninja -C "$OUT_DIR" "$name"
done
9 changes: 7 additions & 2 deletions scripts/setup/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,15 @@ _bootstrap_or_activate() {
export PW_DOCTOR_SKIP_CIPD_CHECKS=1
export PATH # https://bugs.chromium.org/p/pigweed/issues/detail?id=281

local _PIGWEED_CIPD_JSON="$_CHIP_ROOT/third_party/pigweed/repo/pw_env_setup/py/pw_env_setup/cipd_setup/pigweed.json"
local _PIGWEED_CIPD_JSON_ROOT="$_CHIP_ROOT/third_party/pigweed/repo/pw_env_setup/py/pw_env_setup/cipd_setup"
local _PIGWEED_CIPD_JSON="$_PIGWEED_CIPD_JSON_ROOT/pigweed.json"
local _PYTHON_CIPD_JSON="$_PIGWEED_CIPD_JSON_ROOT/python311.json"
mkdir -p "$_PW_ACTUAL_ENVIRONMENT_ROOT"
local _GENERATED_PIGWEED_CIPD_JSON="$_PW_ACTUAL_ENVIRONMENT_ROOT/pigweed.json"
$_CHIP_ROOT/scripts/setup/gen_pigweed_cipd_json.py -i $_PIGWEED_CIPD_JSON -o $_GENERATED_PIGWEED_CIPD_JSON
$_CHIP_ROOT/scripts/setup/gen_pigweed_cipd_json.py \
-i $_PIGWEED_CIPD_JSON \
-o $_GENERATED_PIGWEED_CIPD_JSON \
-e darwin:$_PYTHON_CIPD_JSON

if test -n "$GITHUB_ACTION"; then
tee <<EOF >"${_PW_ACTUAL_ENVIRONMENT_ROOT}/pip.conf"
Expand Down
22 changes: 21 additions & 1 deletion scripts/setup/gen_pigweed_cipd_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import argparse
import json
import platform

_LIST_OF_PACKAGES_TO_EXCLUDE = ['fuchsia/third_party/rust/']

Expand All @@ -32,12 +33,26 @@ def include_package(package: dict) -> bool:
return True


def generate_new_cipd_package_json(input, output):
def generate_new_cipd_package_json(input, output, extra):
with open(input) as ins:
packages = json.load(ins)

file_packages = packages.get('packages')
new_file_packages = [x for x in file_packages if include_package(x)]

# Extra is a list of platform:json.
# Filter it for the given platform and append any resulting packages
my_platform = platform.system().lower()
for item in extra:
inject_platform, path = item.split(':', 1)

if inject_platform.lower() != my_platform:
continue

with open(path) as ins:
for package in json.load(ins).get('packages'):
new_file_packages.append(package)

new_packages = {'packages': new_file_packages}
with open(output, 'w') as f:
json.dump(new_packages, f, indent=2)
Expand All @@ -54,6 +69,11 @@ def main():
parser.add_argument(
'--output', '-o', required=True
)
parser.add_argument(
'--extra', '-e', nargs='*', default=[],
help="Inject extra packages for specific platforms. Format is <platform>:<path_to_json>"
)

generate_new_cipd_package_json(**vars(parser.parse_args()))


Expand Down
Loading

0 comments on commit 39a9222

Please sign in to comment.