gn-check.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. Usage:
  3. $ node ./script/gn-check.js [--outDir=dirName]
  4. */
  5. const cp = require('node:child_process');
  6. const path = require('node:path');
  7. const args = require('minimist')(process.argv.slice(2), { string: ['outDir'] });
  8. const { getOutDir } = require('./lib/utils');
  9. const SOURCE_ROOT = path.normalize(path.dirname(__dirname));
  10. const DEPOT_TOOLS = path.resolve(SOURCE_ROOT, '..', 'third_party', 'depot_tools');
  11. const OUT_DIR = getOutDir({ outDir: args.outDir });
  12. if (!OUT_DIR) {
  13. throw new Error('No viable out dir: one of Debug, Testing, or Release must exist.');
  14. }
  15. const env = {
  16. CHROMIUM_BUILDTOOLS_PATH: path.resolve(SOURCE_ROOT, '..', 'buildtools'),
  17. DEPOT_TOOLS_WIN_TOOLCHAIN: '0',
  18. ...process.env
  19. };
  20. // Users may not have depot_tools in PATH.
  21. env.PATH = `${env.PATH}${path.delimiter}${DEPOT_TOOLS}`;
  22. const gnCheckDirs = [
  23. '//electron:electron_lib',
  24. '//electron:electron_app',
  25. '//electron/shell/common/api:mojo'
  26. ];
  27. for (const dir of gnCheckDirs) {
  28. const args = ['check', `../out/${OUT_DIR}`, dir];
  29. const result = cp.spawnSync('gn', args, { env, stdio: 'inherit' });
  30. if (result.status !== 0) process.exit(result.status);
  31. }
  32. process.exit(0);