Skip to content

Commit

Permalink
Bump third_party/pigweed/repo from d6b036c to 7c87569 (#27068)
Browse files Browse the repository at this point in the history
* Bump third_party/pigweed/repo from `d6b036c` to `7c87569`

Bumps [third_party/pigweed/repo](https://github.com/google/pigweed) from `d6b036c` to `7c87569`.
- [Commits](google/pigweed@d6b036c...7c87569)

---
updated-dependencies:
- dependency-name: third_party/pigweed/repo
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update clang version

* Restyle

* fix revision - file permissions messed up before

* Zap regen

* Remove clang.json ... corresponding version already available in pigweed latest

* make generate.py try hard to use the pigweed clang-format

* Fix typo

* Restyled by prettier-json

* Restyled by autopep8

* Restyled by isort

* Gcc errors out with "error: unrecognized command line option -Wno-unknown-warning-option"

* Revert "Gcc errors out with "error: unrecognized command line option -Wno-unknown-warning-option""

This reverts commit df437c8.

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Andrei Litvin <andy314@gmail.com>
Co-authored-by: Andrei Litvin <andreilitvin@google.com>
Co-authored-by: Restyled.io <commits@restyled.io>
  • Loading branch information
4 people authored and pull[bot] committed Aug 15, 2023
1 parent b8975fa commit 9329864
Show file tree
Hide file tree
Showing 8 changed files with 220 additions and 237 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
43 changes: 0 additions & 43 deletions scripts/lints/clang-format-version-matches.py

This file was deleted.

13 changes: 0 additions & 13 deletions scripts/setup/clang.json

This file was deleted.

1 change: 0 additions & 1 deletion scripts/setup/environment.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"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"
],
Expand Down
87 changes: 65 additions & 22 deletions scripts/tools/zap/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import subprocess
import sys
import tempfile
import traceback
import urllib.request
from dataclasses import dataclass
from pathlib import Path
Expand Down Expand Up @@ -216,6 +217,59 @@ 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 generally 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 = [
'.js', '.h', '.c', '.hpp', '.cpp', '.m', '.mm']
Expand All @@ -228,28 +282,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)

Expand Down
Loading

0 comments on commit 9329864

Please sign in to comment.