Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: add gn-check to precommit linting (#19850)
- Loading branch information
1 parent
0f5ff1f
commit bfe2568
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const cp = require('child_process') | ||
const path = require('path') | ||
|
||
const { getOutDir } = require('./lib/utils') | ||
|
||
const SOURCE_ROOT = path.normalize(path.dirname(__dirname)) | ||
const DEPOT_TOOLS = path.resolve(SOURCE_ROOT, '..', 'third_party', 'depot_tools') | ||
const OUT_DIR = getOutDir() | ||
|
||
if (!OUT_DIR) { | ||
throw new Error(`No viable out dir: one of Debug, Testing, or Release must exist.`) | ||
} | ||
|
||
const env = Object.assign({ | ||
CHROMIUM_BUILDTOOLS_PATH: path.resolve(SOURCE_ROOT, '..', 'buildtools'), | ||
DEPOT_TOOLS_WIN_TOOLCHAIN: '0' | ||
}, process.env) | ||
// Users may not have depot_tools in PATH. | ||
env.PATH = `${env.PATH}${path.delimiter}${DEPOT_TOOLS}` | ||
|
||
const gnCheckDirs = [ | ||
'//electron:electron_lib', | ||
'//electron:electron_app', | ||
'//electron:manifests', | ||
'//electron/shell/common/api:mojo' | ||
] | ||
|
||
for (const dir of gnCheckDirs) { | ||
const args = ['check', `../out/${OUT_DIR}`, dir] | ||
const result = cp.spawnSync('gn', args, { env, stdio: 'inherit' }) | ||
if (result.status !== 0) process.exit(result.status) | ||
} | ||
|
||
process.exit(0) |