Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / trace-viewer / build / check_gyp.py
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 from build import trace_viewer_project
8
9 GYP_FILE = "trace_viewer.gyp"
10 FILE_GROUPS = ["tracing_html_files",
11     "tracing_css_files",
12     "tracing_js_files",
13     "tracing_img_files"]
14
15 def GypCheck():
16   f = open(GYP_FILE, 'r')
17   gyp = f.read()
18   f.close()
19
20   data = eval(gyp)
21   gyp_files = []
22   for group in FILE_GROUPS:
23     gyp_files.extend(map(os.path.normpath, data["variables"][group]))
24
25   project = trace_viewer_project.TraceViewerProject()
26   known_files = []
27   def handle(dirpath, dirnames, filenames):
28     for name in filenames:
29       if not (name.endswith(("_test.js", "_test_data.js", "tests.html")) or
30          name.startswith(("."))):
31         x = os.path.relpath(os.path.normpath(os.path.join(dirpath, name)),
32                             project.trace_viewer_path)
33         known_files.append(x)
34     if '.svn' in dirnames:
35       dirnames.remove('.svn')
36
37   for (dirpath, dirnames, filenames) in os.walk(project.src_path):
38     handle(dirpath, dirnames, filenames)
39
40   for (dirpath, dirnames, filenames) in os.walk(
41       os.path.join(project.tvcm_path, 'src')):
42     handle(dirpath, dirnames, filenames)
43
44   u = set(gyp_files).union(set(known_files))
45   i = set(gyp_files).intersection(set(known_files))
46   diff = list(u - i)
47
48   if len(diff) == 0:
49     return ''
50
51   error = 'Entries in ' + GYP_FILE + ' do not match files on disk:\n'
52   in_gyp_only = list(set(gyp_files) - set(known_files))
53   in_known_only = list(set(known_files) - set(gyp_files))
54
55   if len(in_gyp_only) > 0:
56     error += '  In GYP only:\n    ' + '\n    '.join(sorted(in_gyp_only))
57   if len(in_known_only) > 0:
58     if len(in_gyp_only) > 0:
59       error += '\n\n'
60     error += '  On disk only:\n    ' + '\n    '.join(sorted(in_known_only))
61
62   return error