OLD | NEW |
| (Empty) |
1 # Copyright (c) 2012 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 shutil | |
6 import os | |
7 import re | |
8 | |
9 prefixes = ["../../third_party/WebKit/Source/WebCore/platform/chromium/support", | |
10 "../../third_party/WebKit/Source/WebKit/chromium/src", | |
11 "../../third_party/WebKit/Source/WebKit/chromium/tests", | |
12 "../../third_party/WebKit/Source/WebCore/platform"] | |
13 | |
14 def Copy(name): | |
15 src = name | |
16 dst = name | |
17 fullsrc = "" | |
18 if name.startswith("test/"): | |
19 src = src[5:] | |
20 for prefix in prefixes: | |
21 candidate = "%s/%s" % (prefix, src) | |
22 if os.path.exists(candidate): | |
23 fullsrc = candidate | |
24 break | |
25 assert fullsrc != "" | |
26 shutil.copyfile(fullsrc, dst) | |
27 print "copying from %s to %s" % (fullsrc, dst) | |
28 return dst | |
29 | |
30 def Readfile(gypfile): | |
31 cc_gyp = open(gypfile, "r") | |
32 obj = eval(cc_gyp.read()) | |
33 cc_gyp.close() | |
34 return obj | |
35 | |
36 def FixCopyrightHeaderText(text, year): | |
37 header_template = """// Copyright %s The Chromium Authors. All rights reserved
. | |
38 // Use of this source code is governed by a BSD-style license that can be | |
39 // found in the LICENSE file. | |
40 """ | |
41 | |
42 while text[0].find(" */") == -1: | |
43 text = text[1:] | |
44 text = text[1:] | |
45 | |
46 return (header_template % year) + "".join(text) | |
47 | |
48 def FixCopyrightHeader(filepath): | |
49 with open(filepath, "r") as f: | |
50 text = f.readlines() | |
51 | |
52 pattern = ".*Copyright \(C\) (20[01][0-9])" | |
53 m = re.match(pattern, text[0]) | |
54 if m == None: | |
55 m = re.match(pattern, text[1]) | |
56 assert m | |
57 year = m.group(1) | |
58 | |
59 fixed_text = FixCopyrightHeaderText(text, year) | |
60 with open(filepath, "w") as f: | |
61 f.write(fixed_text) | |
62 | |
63 def Main(): | |
64 files = Readfile("compositor.gyp")['variables']['webkit_compositor_sources'] | |
65 for f in files: | |
66 dst = Copy(f) | |
67 FixCopyrightHeader(dst) | |
68 | |
69 variables = Readfile("compositor_tests.gyp")['variables'] | |
70 files = variables['webkit_compositor_tests_sources'] | |
71 for f in files: | |
72 dst = Copy(f) | |
73 FixCopyrightHeader(dst) | |
74 | |
75 if __name__ == '__main__': | |
76 import sys | |
77 os.chdir(os.path.dirname(__file__)) | |
78 sys.exit(Main()) | |
OLD | NEW |