From 1193a37d8f8a2cb67d2122f3fd490690e9588cff Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Wed, 29 Sep 2021 17:44:41 -0400 Subject: [PATCH] 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: https://github.com/electron/electron/blob/cd09a5436544ca0610542bc5b14adf992a9d9df2/.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 --- script/lint.js | 1 + 1 file changed, 1 insertion(+) diff --git a/script/lint.js b/script/lint.js index 3ee6ace0bd..75de62a9a6 100755 --- a/script/lint.js +++ b/script/lint.js @@ -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) {