Fix copybara include path substitutions errors (which break the google3 build) arising from clang-format linter automation

This commit is contained in:
austinvhuang 2024-02-27 17:11:15 -05:00
parent f70d2de16f
commit 8f3bd63bf7
4 changed files with 14 additions and 3 deletions

View File

@ -1,6 +1,5 @@
--- ---
Language: Cpp Language: Cpp
# BasedOnStyle: Google
AccessModifierOffset: -1 AccessModifierOffset: -1
AlignAfterOpenBracket: Align AlignAfterOpenBracket: Align
AlignArrayOfStructures: None AlignArrayOfStructures: None
@ -211,7 +210,7 @@ RequiresClausePosition: OwnLine
RequiresExpressionIndentation: OuterScope RequiresExpressionIndentation: OuterScope
SeparateDefinitionBlocks: Leave SeparateDefinitionBlocks: Leave
ShortNamespaceLines: 1 ShortNamespaceLines: 1
SortIncludes: CaseSensitive SortIncludes: Never
SortJavaStaticImport: Before SortJavaStaticImport: Before
SortUsingDeclarations: LexicographicNumeric SortUsingDeclarations: LexicographicNumeric
SpaceAfterCStyleCast: false SpaceAfterCStyleCast: false

View File

@ -83,6 +83,14 @@ A `.clang-format` configuration is provided with our defaults, please run source
files through `clang-format` (or a formatter that produces equivalent behavior) files through `clang-format` (or a formatter that produces equivalent behavior)
before finalizing PR for submission. before finalizing PR for submission.
The `.clang-format` is the google style (as of feb 27 2024), except with
`SortIncludes` set to `false` to avoid breaking copybara path substitutions
which rely on adjacent comments.
For transparency, `.clang-format` can be reproduced using the
`make_clang_format_config.sh` script in `utils/` run with `clang-format` version
17.0.6.
## Compile-Time Flags (Advanced) ## Compile-Time Flags (Advanced)
There are several compile-time flags to be aware of (note these may or may not There are several compile-time flags to be aware of (note these may or may not

View File

@ -29,10 +29,10 @@
// copybara:import_next_line:gemma_cpp // copybara:import_next_line:gemma_cpp
#include "configs.h" // kSeqLen #include "configs.h" // kSeqLen
// copybara:import_next_line:gemma_cpp // copybara:import_next_line:gemma_cpp
#include "util/args.h" // ArgsBase
#include "hwy/aligned_allocator.h" #include "hwy/aligned_allocator.h"
#include "hwy/base.h" // hwy::bfloat16_t #include "hwy/base.h" // hwy::bfloat16_t
#include "hwy/contrib/thread_pool/thread_pool.h" #include "hwy/contrib/thread_pool/thread_pool.h"
#include "util/args.h" // ArgsBase
// copybara:import_next_line:sentencepiece // copybara:import_next_line:sentencepiece
#include "src/sentencepiece_processor.h" #include "src/sentencepiece_processor.h"

View File

@ -0,0 +1,4 @@
#!/bin/bash
# Reproduces .clang-format file.
clang-format -style="{BasedOnStyle: Google, SortIncludes: false}" -dump-config > .clang-format