mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Reported by @loic-sharma. The tl;dr is it should be OK to have `\r\n` (CRLF) endings if the header guard is otherwise correct. This minor refactor (and test) discounts the existence of `\r` when determining the name of a header guard, i.e.: ```h #ifndef FLUTTER_MATAN_WHY_H_ ``` ... is now (correctly) considered a value of `FLUTTER_MATAN_WHY_H_` not `FLUTTER_MATAN_WHY_H_\r`.
header_guard_check
A tool to check that C++ header guards are used consistently in the engine.
# Assuming you are in the `flutter` root of the engine repo.
dart ./tools/header_guard_check/bin/main.dart
The tool checks all header files for the following pattern:
// path/to/file.h
#ifndef PATH_TO_FILE_H_
#define PATH_TO_FILE_H_
...
#endif // PATH_TO_FILE_H_
If the header file does not follow this pattern, the tool will print an error message and exit with a non-zero exit code. For more information about why we use this pattern, see the Google C++ style guide.
Automatic fixes
The tool can automatically fix header files that do not follow the pattern:
dart ./tools/header_guard_check/bin/main.dart --fix
Advanced usage
Restricting the files to check
By default, the tool checks all header files in the engine. You can restrict the
files to check by passing a relative (to the engine/src/flutter root) paths to
include:
dart ./tools/header_guard_check/bin/main.dart --include impeller