0

Update docs for updating clang format

* The file extensions for the compressed tarballs are .tar.xz, not .tgz
* Update the clang-format diff script so that xargs spawns one
  clang-format process per file in parallel instead of spawning one
  clang-format process that formats all files. This considerably speeds
  things up.

Note that the fetch and upload script is still broken for the following
reasons that I haven't fixed yet because this is difficult to debug
(upload_to_google_storage.py can only be run once per object for
example.)
* upload_to_google_storage_first_class.py prints a line that goes
  "Uploading {filename} as gs://{path}" before printing out JSON. This
  makes jq unhappy.
* upload_to_google_storage_first_class.py prints the wrong object_name
  in the JSON; the object name printed is the same as the sha256sum.
  There does exist an object with that name and it contains the right
  data, but it doesn't have the executable bit set. We want another
  object that does.

Change-Id: I6cd5faa0432b71098664e4e79bc7c22140d48545
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6226772
Reviewed-by: Hans Wennborg <hans@chromium.org>
Commit-Queue: Alan Zhao <ayzhao@google.com>
Cr-Commit-Position: refs/heads/main@{#1415760}
This commit is contained in:
Alan Zhao
2025-02-04 12:26:16 -08:00
committed by Chromium LUCI CQ
parent 64be86bd7d
commit c98914a0b2

@ -31,15 +31,15 @@ GS_PATH=gs://chromium-browser-clang-staging
CLANG_REV=llvmorg-15-init-234-g567890abc-2
echo Linux
gsutil cp $GS_PATH/Linux_x64/clang-format-$CLANG_REV.tgz /tmp
gsutil cp $GS_PATH/Linux_x64/clang-format-$CLANG_REV.tar.xz /tmp
tar xf /tmp/clang-format-$CLANG_REV.tgz -C buildtools/linux64 --strip-component=1 bin/clang-format
echo Win
gsutil cp $GS_PATH/Win/clang-format-$CLANG_REV.tgz /tmp
gsutil cp $GS_PATH/Win/clang-format-$CLANG_REV.tar.xz /tmp
tar xf /tmp/clang-format-$CLANG_REV.tgz -C buildtools/win --strip-component=1 bin/clang-format.exe
echo 'Mac x64'
gsutil cp $GS_PATH/Mac/clang-format-$CLANG_REV.tgz /tmp
gsutil cp $GS_PATH/Mac/clang-format-$CLANG_REV.tar.xz /tmp
tar xf /tmp/clang-format-$CLANG_REV.tgz -C buildtools/mac --strip-component=1 bin/clang-format
mv buildtools/mac/clang-format buildtools/mac/clang-format.x64
@ -99,13 +99,18 @@ clang-format differences by choosing patchset 1 as the base for the gerrit diff.
```shell
## New gerrit CL with results of old clang-format.
# For mac, use:
# export NPROC=$(sysctl -n hw.logicalcpu)
export NPROC=$(nproc --all)
# use old clang-format
find base -name '*.cc' -o -name '*.c' -o -name '*.h' -o -name '*.mm' | xargs ./buildtools/linux64-format/clang-format -i
find base -name '*.cc' -o -name '*.c' -o -name '*.h' -o -name '*.mm' | xargs -P $NPROC -n1 ./buildtools/linux64-format/clang-format -i
git commit -a
git cl upload --bypass-hooks
## New patchset on gerrit CL with results of new clang-format.
# update to new clang-format
find base -name '*.cc' -o -name '*.c' -o -name '*.h' -o -name '*.mm' | xargs ./buildtools/linux64/clang-format -i
find base -name '*.cc' -o -name '*.c' -o -name '*.h' -o -name '*.mm' | xargs -P $NPROC -n1 ./buildtools/linux64/clang-format -i
git commit -a --amend --no-edit
git cl upload --bypass-hooks
```