Home | History | Annotate | Download | only in build
      1 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
      2 # Use of this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 
      5 import os
      6 
      7 GYP_FILE = "trace_viewer.gyp"
      8 FILE_GROUPS = ["tracing_html_files",
      9     "tracing_css_files",
     10     "tracing_js_files",
     11     "tracing_template_files",
     12     "tracing_img_files"]
     13 
     14 def GypCheck():
     15   f = open(GYP_FILE, 'r')
     16   gyp = f.read()
     17   f.close()
     18 
     19   data = eval(gyp)
     20   gyp_files = []
     21   for group in FILE_GROUPS:
     22     gyp_files.extend(data["variables"][group])
     23 
     24   known_files = []
     25   for (dirpath, dirnames, filenames) in os.walk('src'):
     26     for name in filenames:
     27       if not name.endswith(("_test.js", "_test_data.js", "tests.html")):
     28         known_files.append(os.path.join(dirpath, name))
     29 
     30   u = set(gyp_files).union(set(known_files))
     31   i = set(gyp_files).intersection(set(known_files))
     32   diff = list(u - i)
     33 
     34   if len(diff) == 0:
     35     return ''
     36 
     37   error = 'Entries in ' + GYP_FILE + ' do not match files on disk:\n'
     38   in_gyp_only = list(set(gyp_files) - set(known_files))
     39   in_known_only = list(set(known_files) - set(gyp_files))
     40 
     41   if len(in_gyp_only) > 0:
     42     error += '  In GYP only:\n    ' + '\n    '.join(sorted(in_gyp_only))
     43   if len(in_known_only) > 0:
     44     if len(in_gyp_only) > 0:
     45       error += '\n\n'
     46     error += '  On disk only:\n    ' + '\n    '.join(sorted(in_known_only))
     47 
     48   return error
     49