Skip to content

Commit

Permalink
Generate pigweed CIPD json file during bootstrap (project-chip#29968)
Browse files Browse the repository at this point in the history
* Generate pigweed CIPD json file during bootstrap

* Restyle

* Address PR comments

* Fix CI

* Change how to exclude packages

* The name of the json needs to be pigweed since file name is used as a package path later

* Remove pigweed.json file that was in matter SDK

* clang-format was updated between pigweed.json snapshot and what is in pigweed repo now
  • Loading branch information
tehampson authored Oct 27, 2023
1 parent ddf911e commit cb4949d
Show file tree
Hide file tree
Showing 9 changed files with 4,787 additions and 6,493 deletions.
9 changes: 7 additions & 2 deletions scripts/setup/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,12 @@ _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"
mkdir -p "$_PW_ACTUAL_ENVIRONMENT_ROOT"
local _GENERATED_PIGWEED_CIPD_JSON="$_PW_ACTUAL_ENVIRONMENT_ROOT/pigweed.json"
scripts/setup/gen_pigweed_cipd_json.py -i $_PIGWEED_CIPD_JSON -o $_GENERATED_PIGWEED_CIPD_JSON

if test -n "$GITHUB_ACTION"; then
mkdir -p "$_PW_ACTUAL_ENVIRONMENT_ROOT"
tee <<EOF >"${_PW_ACTUAL_ENVIRONMENT_ROOT}/pip.conf"
[global]
cache-dir = ${_PW_ACTUAL_ENVIRONMENT_ROOT}/pip-cache
Expand All @@ -131,7 +135,8 @@ EOF
pw_bootstrap --shell-file "$_SETUP_SH" \
--install-dir "$_PW_ACTUAL_ENVIRONMENT_ROOT" \
--config-file "$_CHIP_ROOT/$_CONFIG_FILE" \
--virtualenv-gn-out-dir "$_PW_ACTUAL_ENVIRONMENT_ROOT/gn_out"
--virtualenv-gn-out-dir "$_PW_ACTUAL_ENVIRONMENT_ROOT/gn_out" \
--additional-cipd-file "$_GENERATED_PIGWEED_CIPD_JSON"
pw_finalize bootstrap "$_SETUP_SH"
_ACTION_TAKEN="bootstrap"
else
Expand Down
1 change: 0 additions & 1 deletion scripts/setup/environment.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"cipd_package_files": [
"third_party/pigweed/repo/pw_env_setup/py/pw_env_setup/cipd_setup/arm.json",
"scripts/setup/pigweed.json",
"scripts/setup/python.json",
"scripts/setup/zap.json"
],
Expand Down
61 changes: 61 additions & 0 deletions scripts/setup/gen_pigweed_cipd_json.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env python3

# Copyright (c) 2023 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 argparse
import json

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


def include_package(package: dict) -> bool:
if 'path' in package:
path = package['path']
exclusion_match = any(
path.startswith(package_to_exclude)
for package_to_exclude in _LIST_OF_PACKAGES_TO_EXCLUDE
)
if exclusion_match:
return False
return True


def generate_new_cipd_package_json(input, output):
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)]

new_packages = {'packages': new_file_packages}
with open(output, 'w') as f:
json.dump(new_packages, f, indent=2)


def main():
parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
parser.add_argument(
'--input', '-i', required=True
)
parser.add_argument(
'--output', '-o', required=True
)
generate_new_cipd_package_json(**vars(parser.parse_args()))


if __name__ == '__main__':
main()
122 changes: 0 additions & 122 deletions scripts/setup/pigweed.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ class DLL_EXPORT OtaSoftwareUpdateProviderCluster : public ClusterBase
{
public:
OtaSoftwareUpdateProviderCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session,
EndpointId endpoint) :
ClusterBase(exchangeManager, session, endpoint)
EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint)
{}
~OtaSoftwareUpdateProviderCluster() {}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ class DLL_EXPORT OtaSoftwareUpdateProviderCluster : public ClusterBase
{
public:
OtaSoftwareUpdateProviderCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session,
EndpointId endpoint) :
ClusterBase(exchangeManager, session, endpoint)
EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint)
{}
~OtaSoftwareUpdateProviderCluster() {}
};
Expand Down
Loading

0 comments on commit cb4949d

Please sign in to comment.