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