Skip to content

Commit

Permalink
build: Explicitly pass the project root to cpplint.py (#31156)
Browse files Browse the repository at this point in the history
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 <jv@jviotti.com>
  • Loading branch information
jviotti committed Sep 29, 2021
1 parent 2d111a4 commit 1193a37
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions script/lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 1193a37

Please sign in to comment.