1#!/usr/bin/env python 2# Copyright 2015 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 10import common 11 12 13def main_run(args): 14 with common.temporary_file() as tempfile_path: 15 rc = common.run_command([ 16 os.path.join(common.SRC_DIR, 'tools', 'checklicenses', 17 'checklicenses.py'), '--json', tempfile_path 18 ]) 19 20 with open(tempfile_path) as f: 21 checklicenses_results = json.load(f) 22 23 result_set = set() 24 for result in checklicenses_results: 25 result_set.add((result['filename'], result['license'])) 26 27 json.dump( 28 { 29 'valid': True, 30 'failures': ['%s: %s' % (r[0], r[1]) for r in result_set], 31 }, args.output) 32 33 return rc 34 35 36def main_compile_targets(args): 37 json.dump([], args.output) 38 39 40if __name__ == '__main__': 41 funcs = { 42 'run': main_run, 43 'compile_targets': main_compile_targets, 44 } 45 sys.exit(common.run_script(sys.argv[1:], funcs)) 46