diff --git a/.clang-format b/.clang-format index 523dc01..3465c13 100644 --- a/.clang-format +++ b/.clang-format @@ -1,6 +1,5 @@ --- Language: Cpp -# BasedOnStyle: Google AccessModifierOffset: -1 AlignAfterOpenBracket: Align AlignArrayOfStructures: None @@ -211,7 +210,7 @@ RequiresClausePosition: OwnLine RequiresExpressionIndentation: OuterScope SeparateDefinitionBlocks: Leave ShortNamespaceLines: 1 -SortIncludes: CaseSensitive +SortIncludes: Never SortJavaStaticImport: Before SortUsingDeclarations: LexicographicNumeric SpaceAfterCStyleCast: false diff --git a/DEVELOPERS.md b/DEVELOPERS.md index 557670a..8e09ee8 100644 --- a/DEVELOPERS.md +++ b/DEVELOPERS.md @@ -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) 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) There are several compile-time flags to be aware of (note these may or may not diff --git a/gemma.h b/gemma.h index a218878..2d5e713 100644 --- a/gemma.h +++ b/gemma.h @@ -29,10 +29,10 @@ // copybara:import_next_line:gemma_cpp #include "configs.h" // kSeqLen // copybara:import_next_line:gemma_cpp +#include "util/args.h" // ArgsBase #include "hwy/aligned_allocator.h" #include "hwy/base.h" // hwy::bfloat16_t #include "hwy/contrib/thread_pool/thread_pool.h" -#include "util/args.h" // ArgsBase // copybara:import_next_line:sentencepiece #include "src/sentencepiece_processor.h" diff --git a/util/make_clang_format_config.sh b/util/make_clang_format_config.sh new file mode 100755 index 0000000..5261e2c --- /dev/null +++ b/util/make_clang_format_config.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +# Reproduces .clang-format file. +clang-format -style="{BasedOnStyle: Google, SortIncludes: false}" -dump-config > .clang-format