build: Explicitly pass the project root to cpplint.py (#31156)

In order to validate that header guards match the corresponding file
names, `cpplint.py` determines the root of the project based on the
presence of a `.git` directory.

For space reasons, our Electron.js fork running on CircleCI deletes the
`.git` directories as upstream Electron.js does here:

cd09a54365/.circleci/config.yml (L426)

If the C++ linter is ran *after* deleting git directories, `cpplint.py`
gets the root wrong and throws errors for every single header guard in
the project.

Making sure we run the C++ linter *before* deleting git directories
fixes the issue. In any case, this commit always manually passes
`--project_root` to `cpplint.py` so that the implicit default is
explicitly declared and saves some confusion for the next person hitting
this.

Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
This commit is contained in:
Juan Cruz Viotti 2021-09-29 17:44:41 -04:00 committed by GitHub
parent 2d111a4e25
commit 1193a37d8f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -47,6 +47,7 @@ function spawnAndCheckExitCode (cmd, args, opts) {
}
function cpplint (args) {
args.unshift(`--project_root=${SOURCE_ROOT}`);
const result = childProcess.spawnSync(IS_WINDOWS ? 'cpplint.bat' : 'cpplint.py', args, { encoding: 'utf8', shell: true });
// cpplint.py writes EVERYTHING to stderr, including status messages
if (result.stderr) {