1#!/usr/bin/env python 2# Copyright 2017 The Chromium Authors 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5 6import json 7import os 8import sys 9 10# Add src/testing/ into sys.path for importing common without pylint errors. 11sys.path.append( 12 os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir))) 13from scripts import common 14 15 16def main_run(args): 17 with common.temporary_file() as tempfile_path: 18 rc = common.run_command([ 19 sys.executable, 20 os.path.join(common.SRC_DIR, 'build', 'check_gn_headers.py'), 21 '--out-dir', 22 os.path.join(args.paths['checkout'], 'out', args.build_config_fs), 23 '--whitelist', 24 os.path.join(common.SRC_DIR, 'build', 'check_gn_headers_whitelist.txt'), 25 '--json', tempfile_path, 26 '--verbose', 27 ], cwd=common.SRC_DIR) 28 29 with open(tempfile_path) as f: 30 failures = json.load(f) 31 32 json.dump({ 33 'valid': True, 34 'failures': failures, 35 }, args.output) 36 37 return rc 38 39 40def main_compile_targets(args): 41 json.dump([], args.output) 42 43 44if __name__ == '__main__': 45 funcs = { 46 'run': main_run, 47 'compile_targets': main_compile_targets, 48 } 49 common.run_script(sys.argv[1:], funcs) 50