From 3bb250690a63d6c745baec50d7b7e2d8d2f197e7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Jun 2023 08:58:48 +0000 Subject: [PATCH 01/13] Bump third_party/pigweed/repo from `d6b036c` to `7c87569` Bumps [third_party/pigweed/repo](https://github.com/google/pigweed) from `d6b036c` to `7c87569`. - [Commits](https://github.com/google/pigweed/compare/d6b036c2c385b8934e83d6d4d258870ccfcc1e08...7c875693d478ac0da2f358a1542a4fc1cad1b60d) --- updated-dependencies: - dependency-name: third_party/pigweed/repo dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- third_party/pigweed/repo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/pigweed/repo b/third_party/pigweed/repo index d6b036c2c385b8..7c875693d478ac 160000 --- a/third_party/pigweed/repo +++ b/third_party/pigweed/repo @@ -1 +1 @@ -Subproject commit d6b036c2c385b8934e83d6d4d258870ccfcc1e08 +Subproject commit 7c875693d478ac0da2f358a1542a4fc1cad1b60d From 725303e1423a8a1d0c6b77c7c8c8a0930500c029 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Mon, 5 Jun 2023 11:37:48 -0400 Subject: [PATCH 02/13] Update clang version --- scripts/setup/clang.json | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/scripts/setup/clang.json b/scripts/setup/clang.json index 5c09ee6798672f..294cf3141ad4cf 100644 --- a/scripts/setup/clang.json +++ b/scripts/setup/clang.json @@ -1,13 +1,13 @@ { - "packages": [ - { - "path": "fuchsia/third_party/clang/mac-arm64", - "platforms": [ - "mac-arm64" - ], - "tags": [ - "git_revision:6d667d4b261e81f325756fdfd5bb43b3b3d2451d" - ] - } - ] + "packages": [ + { + "path": "fuchsia/third_party/clang/mac-arm64", + "platforms": [ + "mac-arm64" + ], + "tags": [ + "git_revision:6d667d4b261e81f325756fdfd5bb43b3b3d2451d" + ] + } + ] } From aaf7ba2df6c44ecf4c9888022867083cccae7c7d Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Mon, 5 Jun 2023 11:38:25 -0400 Subject: [PATCH 03/13] Restyle --- scripts/setup/clang.json | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/scripts/setup/clang.json b/scripts/setup/clang.json index 294cf3141ad4cf..f367045368b791 100644 --- a/scripts/setup/clang.json +++ b/scripts/setup/clang.json @@ -1,13 +1,9 @@ { - "packages": [ - { - "path": "fuchsia/third_party/clang/mac-arm64", - "platforms": [ - "mac-arm64" - ], - "tags": [ - "git_revision:6d667d4b261e81f325756fdfd5bb43b3b3d2451d" - ] - } - ] + "packages": [ + { + "path": "fuchsia/third_party/clang/mac-arm64", + "platforms": ["mac-arm64"], + "tags": ["git_revision:6d667d4b261e81f325756fdfd5bb43b3b3d2451d"] + } + ] } From cd53be2358e63ddc009a9a98298bead74e7acc63 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Mon, 5 Jun 2023 12:02:55 -0400 Subject: [PATCH 04/13] fix revision - file permissions messed up before --- scripts/setup/clang.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/setup/clang.json b/scripts/setup/clang.json index f367045368b791..febab50ea82f34 100644 --- a/scripts/setup/clang.json +++ b/scripts/setup/clang.json @@ -3,7 +3,7 @@ { "path": "fuchsia/third_party/clang/mac-arm64", "platforms": ["mac-arm64"], - "tags": ["git_revision:6d667d4b261e81f325756fdfd5bb43b3b3d2451d"] + "tags": ["git_revision:895b55537870cdaf6e4c304a09f4bf01954ccbd6"] } ] } From de0cc2eadd948a34950e12d4447646efaf9ede37 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Mon, 5 Jun 2023 12:39:33 -0400 Subject: [PATCH 05/13] Zap regen --- .../zap-generated/MTRCommandPayloadsObjc.mm | 287 +++++++++--------- .../app-common/zap-generated/cluster-enums.h | 20 +- 2 files changed, 154 insertions(+), 153 deletions(-) diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm index 0f7cc9d3233ebd..ed3b2ee198f3b1 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm @@ -12319,179 +12319,180 @@ @implementation MTRUnitTestingClusterTestStructArrayArgumentResponseParams (Inte - (CHIP_ERROR)_setFieldsFromDecodableStruct: (const chip::app::Clusters::UnitTesting::Commands::TestStructArrayArgumentResponse::DecodableType &)decodableStruct { - { { // Scope for our temporary variables - auto * array_0 = [NSMutableArray new]; - auto iter_0 = decodableStruct.arg1.begin(); - while (iter_0.Next()) { - auto & entry_0 = iter_0.GetValue(); - MTRUnitTestingClusterNestedStructList * newElement_0; - newElement_0 = [MTRUnitTestingClusterNestedStructList new]; - newElement_0.a = [NSNumber numberWithUnsignedChar:entry_0.a]; - newElement_0.b = [NSNumber numberWithBool:entry_0.b]; - newElement_0.c = [MTRUnitTestingClusterSimpleStruct new]; - newElement_0.c.a = [NSNumber numberWithUnsignedChar:entry_0.c.a]; - newElement_0.c.b = [NSNumber numberWithBool:entry_0.c.b]; - newElement_0.c.c = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_0.c.c)]; - newElement_0.c.d = AsData(entry_0.c.d); - newElement_0.c.e = AsString(entry_0.c.e); - if (newElement_0.c.e == nil) { - CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT; - return err; - } - newElement_0.c.f = [NSNumber numberWithUnsignedChar:entry_0.c.f.Raw()]; - newElement_0.c.g = [NSNumber numberWithFloat:entry_0.c.g]; - newElement_0.c.h = [NSNumber numberWithDouble:entry_0.c.h]; + { { // Scope for our temporary variables - auto * array_2 = [NSMutableArray new]; - auto iter_2 = entry_0.d.begin(); - while (iter_2.Next()) { - auto & entry_2 = iter_2.GetValue(); - MTRUnitTestingClusterSimpleStruct * newElement_2; - newElement_2 = [MTRUnitTestingClusterSimpleStruct new]; - newElement_2.a = [NSNumber numberWithUnsignedChar:entry_2.a]; - newElement_2.b = [NSNumber numberWithBool:entry_2.b]; - newElement_2.c = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_2.c)]; - newElement_2.d = AsData(entry_2.d); - newElement_2.e = AsString(entry_2.e); - if (newElement_2.e == nil) { + auto * array_0 = [NSMutableArray new]; + auto iter_0 = decodableStruct.arg1.begin(); + while (iter_0.Next()) { + auto & entry_0 = iter_0.GetValue(); + MTRUnitTestingClusterNestedStructList * newElement_0; + newElement_0 = [MTRUnitTestingClusterNestedStructList new]; + newElement_0.a = [NSNumber numberWithUnsignedChar:entry_0.a]; + newElement_0.b = [NSNumber numberWithBool:entry_0.b]; + newElement_0.c = [MTRUnitTestingClusterSimpleStruct new]; + newElement_0.c.a = [NSNumber numberWithUnsignedChar:entry_0.c.a]; + newElement_0.c.b = [NSNumber numberWithBool:entry_0.c.b]; + newElement_0.c.c = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_0.c.c)]; + newElement_0.c.d = AsData(entry_0.c.d); + newElement_0.c.e = AsString(entry_0.c.e); + if (newElement_0.c.e == nil) { CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT; return err; } - newElement_2.f = [NSNumber numberWithUnsignedChar:entry_2.f.Raw()]; - newElement_2.g = [NSNumber numberWithFloat:entry_2.g]; - newElement_2.h = [NSNumber numberWithDouble:entry_2.h]; - [array_2 addObject:newElement_2]; + newElement_0.c.f = [NSNumber numberWithUnsignedChar:entry_0.c.f.Raw()]; + newElement_0.c.g = [NSNumber numberWithFloat:entry_0.c.g]; + newElement_0.c.h = [NSNumber numberWithDouble:entry_0.c.h]; + { // Scope for our temporary variables + auto * array_2 = [NSMutableArray new]; + auto iter_2 = entry_0.d.begin(); + while (iter_2.Next()) { + auto & entry_2 = iter_2.GetValue(); + MTRUnitTestingClusterSimpleStruct * newElement_2; + newElement_2 = [MTRUnitTestingClusterSimpleStruct new]; + newElement_2.a = [NSNumber numberWithUnsignedChar:entry_2.a]; + newElement_2.b = [NSNumber numberWithBool:entry_2.b]; + newElement_2.c = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_2.c)]; + newElement_2.d = AsData(entry_2.d); + newElement_2.e = AsString(entry_2.e); + if (newElement_2.e == nil) { + CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT; + return err; + } + newElement_2.f = [NSNumber numberWithUnsignedChar:entry_2.f.Raw()]; + newElement_2.g = [NSNumber numberWithFloat:entry_2.g]; + newElement_2.h = [NSNumber numberWithDouble:entry_2.h]; + [array_2 addObject:newElement_2]; + } + CHIP_ERROR err = iter_2.GetStatus(); + if (err != CHIP_NO_ERROR) { + return err; + } + newElement_0.d = array_2; + } + { // Scope for our temporary variables + auto * array_2 = [NSMutableArray new]; + auto iter_2 = entry_0.e.begin(); + while (iter_2.Next()) { + auto & entry_2 = iter_2.GetValue(); + NSNumber * newElement_2; + newElement_2 = [NSNumber numberWithUnsignedInt:entry_2]; + [array_2 addObject:newElement_2]; + } + CHIP_ERROR err = iter_2.GetStatus(); + if (err != CHIP_NO_ERROR) { + return err; + } + newElement_0.e = array_2; + } + { // Scope for our temporary variables + auto * array_2 = [NSMutableArray new]; + auto iter_2 = entry_0.f.begin(); + while (iter_2.Next()) { + auto & entry_2 = iter_2.GetValue(); + NSData * newElement_2; + newElement_2 = AsData(entry_2); + [array_2 addObject:newElement_2]; + } + CHIP_ERROR err = iter_2.GetStatus(); + if (err != CHIP_NO_ERROR) { + return err; + } + newElement_0.f = array_2; + } + { // Scope for our temporary variables + auto * array_2 = [NSMutableArray new]; + auto iter_2 = entry_0.g.begin(); + while (iter_2.Next()) { + auto & entry_2 = iter_2.GetValue(); + NSNumber * newElement_2; + newElement_2 = [NSNumber numberWithUnsignedChar:entry_2]; + [array_2 addObject:newElement_2]; + } + CHIP_ERROR err = iter_2.GetStatus(); + if (err != CHIP_NO_ERROR) { + return err; + } + newElement_0.g = array_2; + } + [array_0 addObject:newElement_0]; } - CHIP_ERROR err = iter_2.GetStatus(); + CHIP_ERROR err = iter_0.GetStatus(); if (err != CHIP_NO_ERROR) { return err; } - newElement_0.d = array_2; + self.arg1 = array_0; } + } + { { // Scope for our temporary variables - auto * array_2 = [NSMutableArray new]; - auto iter_2 = entry_0.e.begin(); - while (iter_2.Next()) { - auto & entry_2 = iter_2.GetValue(); - NSNumber * newElement_2; - newElement_2 = [NSNumber numberWithUnsignedInt:entry_2]; - [array_2 addObject:newElement_2]; + auto * array_0 = [NSMutableArray new]; + auto iter_0 = decodableStruct.arg2.begin(); + while (iter_0.Next()) { + auto & entry_0 = iter_0.GetValue(); + MTRUnitTestingClusterSimpleStruct * newElement_0; + newElement_0 = [MTRUnitTestingClusterSimpleStruct new]; + newElement_0.a = [NSNumber numberWithUnsignedChar:entry_0.a]; + newElement_0.b = [NSNumber numberWithBool:entry_0.b]; + newElement_0.c = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_0.c)]; + newElement_0.d = AsData(entry_0.d); + newElement_0.e = AsString(entry_0.e); + if (newElement_0.e == nil) { + CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT; + return err; + } + newElement_0.f = [NSNumber numberWithUnsignedChar:entry_0.f.Raw()]; + newElement_0.g = [NSNumber numberWithFloat:entry_0.g]; + newElement_0.h = [NSNumber numberWithDouble:entry_0.h]; + [array_0 addObject:newElement_0]; } - CHIP_ERROR err = iter_2.GetStatus(); + CHIP_ERROR err = iter_0.GetStatus(); if (err != CHIP_NO_ERROR) { return err; } - newElement_0.e = array_2; + self.arg2 = array_0; } + } + { { // Scope for our temporary variables - auto * array_2 = [NSMutableArray new]; - auto iter_2 = entry_0.f.begin(); - while (iter_2.Next()) { - auto & entry_2 = iter_2.GetValue(); - NSData * newElement_2; - newElement_2 = AsData(entry_2); - [array_2 addObject:newElement_2]; + auto * array_0 = [NSMutableArray new]; + auto iter_0 = decodableStruct.arg3.begin(); + while (iter_0.Next()) { + auto & entry_0 = iter_0.GetValue(); + NSNumber * newElement_0; + newElement_0 = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_0)]; + [array_0 addObject:newElement_0]; } - CHIP_ERROR err = iter_2.GetStatus(); + CHIP_ERROR err = iter_0.GetStatus(); if (err != CHIP_NO_ERROR) { return err; } - newElement_0.f = array_2; + self.arg3 = array_0; } + } + { { // Scope for our temporary variables - auto * array_2 = [NSMutableArray new]; - auto iter_2 = entry_0.g.begin(); - while (iter_2.Next()) { - auto & entry_2 = iter_2.GetValue(); - NSNumber * newElement_2; - newElement_2 = [NSNumber numberWithUnsignedChar:entry_2]; - [array_2 addObject:newElement_2]; + auto * array_0 = [NSMutableArray new]; + auto iter_0 = decodableStruct.arg4.begin(); + while (iter_0.Next()) { + auto & entry_0 = iter_0.GetValue(); + NSNumber * newElement_0; + newElement_0 = [NSNumber numberWithBool:entry_0]; + [array_0 addObject:newElement_0]; } - CHIP_ERROR err = iter_2.GetStatus(); + CHIP_ERROR err = iter_0.GetStatus(); if (err != CHIP_NO_ERROR) { return err; } - newElement_0.g = array_2; - } - [array_0 addObject:newElement_0]; - } - CHIP_ERROR err = iter_0.GetStatus(); - if (err != CHIP_NO_ERROR) { - return err; - } - self.arg1 = array_0; -} -} -{ - { // Scope for our temporary variables - auto * array_0 = [NSMutableArray new]; - auto iter_0 = decodableStruct.arg2.begin(); - while (iter_0.Next()) { - auto & entry_0 = iter_0.GetValue(); - MTRUnitTestingClusterSimpleStruct * newElement_0; - newElement_0 = [MTRUnitTestingClusterSimpleStruct new]; - newElement_0.a = [NSNumber numberWithUnsignedChar:entry_0.a]; - newElement_0.b = [NSNumber numberWithBool:entry_0.b]; - newElement_0.c = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_0.c)]; - newElement_0.d = AsData(entry_0.d); - newElement_0.e = AsString(entry_0.e); - if (newElement_0.e == nil) { - CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT; - return err; - } - newElement_0.f = [NSNumber numberWithUnsignedChar:entry_0.f.Raw()]; - newElement_0.g = [NSNumber numberWithFloat:entry_0.g]; - newElement_0.h = [NSNumber numberWithDouble:entry_0.h]; - [array_0 addObject:newElement_0]; - } - CHIP_ERROR err = iter_0.GetStatus(); - if (err != CHIP_NO_ERROR) { - return err; + self.arg4 = array_0; } - self.arg2 = array_0; } -} -{ - { // Scope for our temporary variables - auto * array_0 = [NSMutableArray new]; - auto iter_0 = decodableStruct.arg3.begin(); - while (iter_0.Next()) { - auto & entry_0 = iter_0.GetValue(); - NSNumber * newElement_0; - newElement_0 = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_0)]; - [array_0 addObject:newElement_0]; - } - CHIP_ERROR err = iter_0.GetStatus(); - if (err != CHIP_NO_ERROR) { - return err; - } - self.arg3 = array_0; + { + self.arg5 = [NSNumber numberWithUnsignedChar:chip::to_underlying(decodableStruct.arg5)]; } -} -{ - { // Scope for our temporary variables - auto * array_0 = [NSMutableArray new]; - auto iter_0 = decodableStruct.arg4.begin(); - while (iter_0.Next()) { - auto & entry_0 = iter_0.GetValue(); - NSNumber * newElement_0; - newElement_0 = [NSNumber numberWithBool:entry_0]; - [array_0 addObject:newElement_0]; - } - CHIP_ERROR err = iter_0.GetStatus(); - if (err != CHIP_NO_ERROR) { - return err; - } - self.arg4 = array_0; + { + self.arg6 = [NSNumber numberWithBool:decodableStruct.arg6]; } -} -{ - self.arg5 = [NSNumber numberWithUnsignedChar:chip::to_underlying(decodableStruct.arg5)]; -} -{ - self.arg6 = [NSNumber numberWithBool:decodableStruct.arg6]; -} -return CHIP_NO_ERROR; + return CHIP_NO_ERROR; } @end diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h b/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h index 34679c83ac976a..a3101b86a58501 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h @@ -186,8 +186,8 @@ enum class MoveMode : uint8_t kUnknownEnumValue = 2, }; #else // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM -using MoveMode = EmberAfMoveMode; -static MoveMode __attribute__((unused)) kMoveModekUnknownEnumValue = static_cast(2); +using MoveMode = EmberAfMoveMode; +static MoveMode __attribute__((unused)) kMoveModekUnknownEnumValue = static_cast(2); #endif // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM // Need to convert consumers to using the new enum classes, so we @@ -205,8 +205,8 @@ enum class StepMode : uint8_t kUnknownEnumValue = 2, }; #else // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM -using StepMode = EmberAfStepMode; -static StepMode __attribute__((unused)) kStepModekUnknownEnumValue = static_cast(2); +using StepMode = EmberAfStepMode; +static StepMode __attribute__((unused)) kStepModekUnknownEnumValue = static_cast(2); #endif // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM // Bitmap for Feature @@ -1050,8 +1050,8 @@ enum class RadioFaultEnum : uint8_t kUnknownEnumValue = 7, }; #else // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM -using RadioFaultEnum = EmberAfRadioFaultEnum; -static RadioFaultEnum __attribute__((unused)) kRadioFaultEnumkUnknownEnumValue = static_cast(7); +using RadioFaultEnum = EmberAfRadioFaultEnum; +static RadioFaultEnum __attribute__((unused)) kRadioFaultEnumkUnknownEnumValue = static_cast(7); #endif // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM } // namespace GeneralDiagnostics @@ -1213,8 +1213,8 @@ enum class PHYRateEnum : uint8_t kUnknownEnumValue = 10, }; #else // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM -using PHYRateEnum = EmberAfPHYRateEnum; -static PHYRateEnum __attribute__((unused)) kPHYRateEnumkUnknownEnumValue = static_cast(10); +using PHYRateEnum = EmberAfPHYRateEnum; +static PHYRateEnum __attribute__((unused)) kPHYRateEnumkUnknownEnumValue = static_cast(10); #endif // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM // Bitmap for Feature @@ -2985,8 +2985,8 @@ enum class ColorMode : uint8_t kUnknownEnumValue = 3, }; #else // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM -using ColorMode = EmberAfColorMode; -static ColorMode __attribute__((unused)) kColorModekUnknownEnumValue = static_cast(3); +using ColorMode = EmberAfColorMode; +static ColorMode __attribute__((unused)) kColorModekUnknownEnumValue = static_cast(3); #endif // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM // Enum for HueDirection From 671fbbc1626cc8eb515fd2260443296e7fd60039 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Tue, 6 Jun 2023 14:06:32 -0400 Subject: [PATCH 06/13] Remove clang.json ... corresponding version already available in pigweed latest --- .github/workflows/lint.yml | 4 -- scripts/lints/clang-format-version-matches.py | 43 ------------------- scripts/setup/clang.json | 9 ---- scripts/setup/environment.json | 21 ++++++--- 4 files changed, 15 insertions(+), 62 deletions(-) delete mode 100755 scripts/lints/clang-format-version-matches.py delete mode 100644 scripts/setup/clang.json diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 8b6f099ca15c48..8a770ecb46b6f0 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -223,7 +223,3 @@ jobs: run: | git grep -n 'SuccessOrExit([^=)]*(' -- './*' ':(exclude).github/workflows/lint.yml' && exit 1 || exit 0 - - name: Check that our hardcoded SHA for clang-format on ARM mac matches the pigweed SHA. - if: always() - run: | - ./scripts/lints/clang-format-version-matches.py diff --git a/scripts/lints/clang-format-version-matches.py b/scripts/lints/clang-format-version-matches.py deleted file mode 100755 index 09bf7eda7d8e15..00000000000000 --- a/scripts/lints/clang-format-version-matches.py +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright (c) 2021 Project CHIP Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -import json -import os - -CHIP_ROOT_DIR = os.path.realpath( - os.path.join(os.path.dirname(__file__), '../..')) - - -def readClangRevision(jsonFileName): - with open(os.path.join(CHIP_ROOT_DIR, jsonFileName)) as file: - data = json.load(file) - - packages = data['packages'] - for package in packages: - if package['path'].startswith('fuchsia/third_party/clang/'): - return package['tags'] - - raise Exception('Could not find clang package in %s' % jsonFileName) - - -pigweed_revision = readClangRevision('third_party/pigweed/repo/pw_env_setup/py/pw_env_setup/cipd_setup/pigweed.json') - -our_file = 'scripts/setup/clang.json' -our_revision = readClangRevision(our_file) - -if our_revision != pigweed_revision: - raise Exception('In %s, "%s" should be changed to "%s"' % (our_file, our_revision, pigweed_revision)) diff --git a/scripts/setup/clang.json b/scripts/setup/clang.json deleted file mode 100644 index febab50ea82f34..00000000000000 --- a/scripts/setup/clang.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "packages": [ - { - "path": "fuchsia/third_party/clang/mac-arm64", - "platforms": ["mac-arm64"], - "tags": ["git_revision:895b55537870cdaf6e4c304a09f4bf01954ccbd6"] - } - ] -} diff --git a/scripts/setup/environment.json b/scripts/setup/environment.json index 6c32bb62ebe8e4..f2e23adc429992 100644 --- a/scripts/setup/environment.json +++ b/scripts/setup/environment.json @@ -2,18 +2,27 @@ "cipd_package_files": [ "third_party/pigweed/repo/pw_env_setup/py/pw_env_setup/cipd_setup/arm.json", "third_party/pigweed/repo/pw_env_setup/py/pw_env_setup/cipd_setup/pigweed.json", - "scripts/setup/clang.json", "scripts/setup/python.json", "scripts/setup/zap.json" ], "virtualenv": { "gn_root": ".", - "gn_targets": [":python_packages.install"], - "requirements": ["scripts/setup/requirements.txt"], - "constraints": ["scripts/setup/constraints.txt"], - "gn_args": ["chip_crypto=\"boringssl\""] + "gn_targets": [ + ":python_packages.install" + ], + "requirements": [ + "scripts/setup/requirements.txt" + ], + "constraints": [ + "scripts/setup/constraints.txt" + ], + "gn_args": [ + "chip_crypto=\"boringssl\"" + ] }, - "required_submodules": ["third_party/pigweed/repo"], + "required_submodules": [ + "third_party/pigweed/repo" + ], "rosetta": "never", "gni_file": "build_overrides/pigweed_environment.gni" } From 6be67b4a7e1bbef9710e1076d1bac04e3ccd3072 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Tue, 6 Jun 2023 14:34:36 -0400 Subject: [PATCH 07/13] make generate.py try hard to use the pigweed clang-format --- scripts/tools/zap/generate.py | 85 ++++++++++++++++++++++++++--------- 1 file changed, 63 insertions(+), 22 deletions(-) diff --git a/scripts/tools/zap/generate.py b/scripts/tools/zap/generate.py index cb932b0cefc2eb..0c9e842608fe70 100755 --- a/scripts/tools/zap/generate.py +++ b/scripts/tools/zap/generate.py @@ -23,7 +23,9 @@ import subprocess import sys import tempfile +import traceback import urllib.request + from dataclasses import dataclass from pathlib import Path from typing import Optional @@ -215,6 +217,56 @@ def runGeneration(cmdLineArgs): extractGeneratedIdl(output_dir, zap_file) +def getClangFormatBinaryChoices(): + """ + Returns an ordered list of paths that may be suitable clang-format versions + """ + PW_CLANG_FORMAT_PATH = 'cipd/packages/pigweed/bin/clang-format' + + if 'PW_ENVIRONMENT_ROOT' in os.environ: + yield os.path.join(os.environ["PW_ENVIRONMENT_ROOT"], PW_CLANG_FORMAT_PATH) + + dot_name = os.path.join(CHIP_ROOT_DIR, '.environment', PW_CLANG_FORMAT_PATH) + if os.path.exists(dot_name): + yield dot_name + + os_name = shutil.which('clang-format') + if os_name: + yield os_name + +def getClangFormatBinary(): + """Fetches the clang-format binary that is to be used for formatting. + + Tries to figure out where the pigweed-provided binary is (via cipd) + """ + for binary in getClangFormatBinaryChoices(): + # Running the binary with `--version` yields a string of the form: + # "Fuchsia clang-format version 17.0.0 (https://llvm.googlesource.com/llvm-project 6d667d4b261e81f325756fdfd5bb43b3b3d2451d)" + # + # the SHA at the end generall should match pigweed version + + try: + version_string = subprocess.check_output([binary, '--version']).decode('utf8') + + pigweed_config = json.load(open(os.path.join(CHIP_ROOT_DIR, 'third_party/pigweed/repo/pw_env_setup/py/pw_env_setup/cipd_setup/pigweed.json'))) + clang_config = [p for p in pigweed_config['packages'] if p['path'].startswith('fuchsia/third_party/clang/')][0] + + # Tags should be like: + # ['git_revision:895b55537870cdaf6e4c304a09f4bf01954ccbd6'] + prefix, sha = clang_config['tags'][0].split(':') + + if sha not in version_string: + print('WARNING: clang-format may not be the right version:') + print(' PIGWEED TAG: %s' % clang_config['tags'][0]) + print(' ACTUAL VERSION: %s' % version_string) + except: + print("Failed to validate clang version.") + traceback.print_last() + + return binary + + raise Exception('Could not find a suitable clang-format') + def runClangPrettifier(templates_file, output_dir): listOfSupportedFileExtensions = [ @@ -228,28 +280,17 @@ def runClangPrettifier(templates_file, output_dir): filepath)[1] in listOfSupportedFileExtensions, outputs)) if len(clangOutputs) > 0: - # NOTE: clang-format may differ in time. Currently pigweed comes - # with clang-format 15. CI may have clang-format-10 installed - # on linux. - # - # We generally want consistent formatting, so - # at this point attempt to use clang-format 15. - clang_formats = ['clang-format-15', 'clang-format'] - for clang_format in clang_formats: - args = [clang_format, '-i'] - args.extend(clangOutputs) - try: - subprocess.check_call(args) - err = None - print('Formatted using %s (%s)' % (clang_format, subprocess.check_output([clang_format, '--version']))) - for outputName in clangOutputs: - print(' - %s' % outputName) - break - except Exception as thrown: - err = thrown - # Press on to the next binary name - if err is not None: - raise err + # NOTE: clang-format differs output in time. We generally would be + # compatible only with pigweed provided clang-format (which is + # tracking non-released clang). + clang_format = getClangFormatBinary() + args = [clang_format, '-i'] + args.extend(clangOutputs) + subprocess.check_call(args) + err = None + print('Formatted using %s (%s)' % (clang_format, subprocess.check_output([clang_format, '--version']))) + for outputName in clangOutputs: + print(' - %s' % outputName) except Exception as err: print('clang-format error:', err) From 42937d0c23516ee97a40428eebb64bc87a3c8eef Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Tue, 6 Jun 2023 14:41:32 -0400 Subject: [PATCH 08/13] Fix typo --- scripts/tools/zap/generate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/tools/zap/generate.py b/scripts/tools/zap/generate.py index 0c9e842608fe70..bc854cda6c494a 100755 --- a/scripts/tools/zap/generate.py +++ b/scripts/tools/zap/generate.py @@ -243,7 +243,7 @@ def getClangFormatBinary(): # Running the binary with `--version` yields a string of the form: # "Fuchsia clang-format version 17.0.0 (https://llvm.googlesource.com/llvm-project 6d667d4b261e81f325756fdfd5bb43b3b3d2451d)" # - # the SHA at the end generall should match pigweed version + # the SHA at the end generally should match pigweed version try: version_string = subprocess.check_output([binary, '--version']).decode('utf8') From be9d16ea71fc0a35aa9232d6c412ddf23a4a29fe Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 6 Jun 2023 18:39:25 +0000 Subject: [PATCH 09/13] Restyled by prettier-json --- scripts/setup/environment.json | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/scripts/setup/environment.json b/scripts/setup/environment.json index f2e23adc429992..ebe77d9db6dbc8 100644 --- a/scripts/setup/environment.json +++ b/scripts/setup/environment.json @@ -7,22 +7,12 @@ ], "virtualenv": { "gn_root": ".", - "gn_targets": [ - ":python_packages.install" - ], - "requirements": [ - "scripts/setup/requirements.txt" - ], - "constraints": [ - "scripts/setup/constraints.txt" - ], - "gn_args": [ - "chip_crypto=\"boringssl\"" - ] + "gn_targets": [":python_packages.install"], + "requirements": ["scripts/setup/requirements.txt"], + "constraints": ["scripts/setup/constraints.txt"], + "gn_args": ["chip_crypto=\"boringssl\""] }, - "required_submodules": [ - "third_party/pigweed/repo" - ], + "required_submodules": ["third_party/pigweed/repo"], "rosetta": "never", "gni_file": "build_overrides/pigweed_environment.gni" } From c59789aace35b95e395fc54ac795c32595c2e02e Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 6 Jun 2023 18:39:27 +0000 Subject: [PATCH 10/13] Restyled by autopep8 --- scripts/tools/zap/generate.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/tools/zap/generate.py b/scripts/tools/zap/generate.py index bc854cda6c494a..eb967b4d64524c 100755 --- a/scripts/tools/zap/generate.py +++ b/scripts/tools/zap/generate.py @@ -217,6 +217,7 @@ def runGeneration(cmdLineArgs): extractGeneratedIdl(output_dir, zap_file) + def getClangFormatBinaryChoices(): """ Returns an ordered list of paths that may be suitable clang-format versions @@ -234,6 +235,7 @@ def getClangFormatBinaryChoices(): if os_name: yield os_name + def getClangFormatBinary(): """Fetches the clang-format binary that is to be used for formatting. @@ -248,7 +250,8 @@ def getClangFormatBinary(): try: version_string = subprocess.check_output([binary, '--version']).decode('utf8') - pigweed_config = json.load(open(os.path.join(CHIP_ROOT_DIR, 'third_party/pigweed/repo/pw_env_setup/py/pw_env_setup/cipd_setup/pigweed.json'))) + pigweed_config = json.load( + open(os.path.join(CHIP_ROOT_DIR, 'third_party/pigweed/repo/pw_env_setup/py/pw_env_setup/cipd_setup/pigweed.json'))) clang_config = [p for p in pigweed_config['packages'] if p['path'].startswith('fuchsia/third_party/clang/')][0] # Tags should be like: @@ -290,7 +293,7 @@ def runClangPrettifier(templates_file, output_dir): err = None print('Formatted using %s (%s)' % (clang_format, subprocess.check_output([clang_format, '--version']))) for outputName in clangOutputs: - print(' - %s' % outputName) + print(' - %s' % outputName) except Exception as err: print('clang-format error:', err) From c112b01be1c8cbcaed8bd47e2386a7f62db4718b Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 6 Jun 2023 18:39:28 +0000 Subject: [PATCH 11/13] Restyled by isort --- scripts/tools/zap/generate.py | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/tools/zap/generate.py b/scripts/tools/zap/generate.py index eb967b4d64524c..5b1f4f4c629f49 100755 --- a/scripts/tools/zap/generate.py +++ b/scripts/tools/zap/generate.py @@ -25,7 +25,6 @@ import tempfile import traceback import urllib.request - from dataclasses import dataclass from pathlib import Path from typing import Optional From df437c873006f371b1b4a69e64fcd4ca1e9a4727 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Tue, 6 Jun 2023 14:58:00 -0400 Subject: [PATCH 12/13] Gcc errors out with "error: unrecognized command line option -Wno-unknown-warning-option" --- build/config/compiler/BUILD.gn | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index 31f396a4574c3a..c64890681cc3c3 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -195,14 +195,17 @@ config("disabled_warnings") { cflags = [ "-Wno-deprecated-declarations", "-Wno-missing-field-initializers", - "-Wno-unknown-warning-option", "-Wno-unused-parameter", ] if (!is_debug) { # assert() causes unused variable warnings in release. cflags += [ "-Wno-unused" ] } - if (!is_clang) { + if (is_clang) { + cflags += [ + "-Wno-unknown-warning-option", + ] + } else { cflags += [ "-Wno-cast-function-type", "-Wno-psabi", From 8924bea447ed2b59a966a5b833b42e234b07ebd8 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Tue, 6 Jun 2023 16:56:24 -0400 Subject: [PATCH 13/13] Revert "Gcc errors out with "error: unrecognized command line option -Wno-unknown-warning-option"" This reverts commit df437c873006f371b1b4a69e64fcd4ca1e9a4727. --- build/config/compiler/BUILD.gn | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index c64890681cc3c3..31f396a4574c3a 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -195,17 +195,14 @@ config("disabled_warnings") { cflags = [ "-Wno-deprecated-declarations", "-Wno-missing-field-initializers", + "-Wno-unknown-warning-option", "-Wno-unused-parameter", ] if (!is_debug) { # assert() causes unused variable warnings in release. cflags += [ "-Wno-unused" ] } - if (is_clang) { - cflags += [ - "-Wno-unknown-warning-option", - ] - } else { + if (!is_clang) { cflags += [ "-Wno-cast-function-type", "-Wno-psabi",