gn-check.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. Usage:
  3. $ node ./script/gn-check.js [--outDir=dirName]
  4. */
  5. const cp = require('child_process');
  6. const path = require('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 = Object.assign({
  16. CHROMIUM_BUILDTOOLS_PATH: path.resolve(SOURCE_ROOT, '..', 'buildtools'),
  17. DEPOT_TOOLS_WIN_TOOLCHAIN: '0'
  18. }, process.env);
  19. // Users may not have depot_tools in PATH.
  20. env.PATH = `${env.PATH}${path.delimiter}${DEPOT_TOOLS}`;
  21. const gnCheckDirs = [
  22. '//electron:electron_lib',
  23. '//electron:electron_app',
  24. '//electron/shell/common/api:mojo'
  25. ];
  26. for (const dir of gnCheckDirs) {
  27. const args = ['check', `../out/${OUT_DIR}`, dir];
  28. const result = cp.spawnSync('gn', args, { env, stdio: 'inherit' });
  29. if (result.status !== 0) process.exit(result.status);
  30. }
  31. process.exit(0);