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