blob: b855b95053f08a54c7f12fdc5c176212b3a4161e [file] [log] [blame]
henrike@webrtc.org390fcb72013-07-22 22:32:50 +00001# libjingle
2# Copyright 2013 Google Inc.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are met:
6#
7# 1. Redistributions of source code must retain the above copyright notice,
8# this list of conditions and the following disclaimer.
9# 2. Redistributions in binary form must reproduce the above copyright notice,
10# this list of conditions and the following disclaimer in the documentation
11# and/or other materials provided with the distribution.
12# 3. The name of the author may not be used to endorse or promote products
13# derived from this software without specific prior written permission.
14#
15# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
16# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
17# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
18# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
henrike@webrtc.orgea40bd02013-07-29 18:20:07 +000026# List of files that should not be committed to
27DO_NOT_SUBMIT_FILES = [
28 "talk/app/webrtc/mediaconstraintsinterface.h",
henrike@webrtc.orgea40bd02013-07-29 18:20:07 +000029 "talk/base/linux.cc",
30 "talk/base/linux.h",
31 "talk/base/linux_unittest.cc",
32 "talk/main.scons",
33 "talk/media/base/hybridvideoengine.cc",
34 "talk/media/base/mediaengine.cc",
35 "talk/media/base/mutedvideocapturer.cc",
36 "talk/media/base/streamparams.h",
37 "talk/media/base/videocapturer.cc",
38 "talk/media/base/videocapturer.h",
39 "talk/media/base/videocapturer_unittest.cc",
40 "talk/media/base/videoengine_unittest.h",
41 "talk/media/devices/devicemanager.cc",
42 "talk/media/webrtc/fakewebrtcvideoengine.h",
43 "talk/media/webrtc/fakewebrtcvoiceengine.h",
44 "talk/media/webrtc/webrtcexport.h",
45 "talk/media/webrtc/webrtcmediaengine.h",
46 "talk/media/webrtc/webrtcvideoengine.cc",
47 "talk/media/webrtc/webrtcvideoengine.h",
48 "talk/media/webrtc/webrtcvideoengine_unittest.cc",
49 "talk/media/webrtc/webrtcvoiceengine.cc",
50 "talk/media/webrtc/webrtcvoiceengine.h",
51 "talk/media/webrtc/webrtcvoiceengine_unittest.cc",
52 "talk/p2p/base/session.cc",
53 "talk/session/media/channel.cc",
54 "talk/session/media/mediasession_unittest.cc"]
55
henrike@webrtc.org390fcb72013-07-22 22:32:50 +000056def _LicenseHeader(input_api):
57 """Returns the license header regexp."""
fischman@webrtc.orgc3d93c62013-08-05 15:01:33 +000058 # Accept any year number from start of project to the current year
henrike@webrtc.org390fcb72013-07-22 22:32:50 +000059 current_year = int(input_api.time.strftime('%Y'))
fischman@webrtc.orgc3d93c62013-08-05 15:01:33 +000060 allowed_years = (str(s) for s in reversed(xrange(2004, current_year + 1)))
henrike@webrtc.org390fcb72013-07-22 22:32:50 +000061 years_re = '(' + '|'.join(allowed_years) + ')'
62 license_header = (
63 r'.*? libjingle\n'
fischman@webrtc.org33584f92013-07-25 16:43:30 +000064 r'.*? Copyright %(year)s,? Google Inc\.\n'
henrike@webrtc.org390fcb72013-07-22 22:32:50 +000065 r'.*?\n'
66 r'.*? Redistribution and use in source and binary forms, with or without'
67 r'\n'
68 r'.*? modification, are permitted provided that the following conditions '
69 r'are met:\n'
70 r'.*?\n'
71 r'.*? 1\. Redistributions of source code must retain the above copyright '
72 r'notice,\n'
73 r'.*? this list of conditions and the following disclaimer\.\n'
74 r'.*? 2\. Redistributions in binary form must reproduce the above '
75 r'copyright notice,\n'
76 r'.*? this list of conditions and the following disclaimer in the '
77 r'documentation\n'
78 r'.*? and/or other materials provided with the distribution\.\n'
79 r'.*? 3\. The name of the author may not be used to endorse or promote '
80 r'products\n'
81 r'.*? derived from this software without specific prior written '
82 r'permission\.\n'
83 r'.*?\n'
84 r'.*? THIS SOFTWARE IS PROVIDED BY THE AUTHOR \`\`AS IS\'\' AND ANY '
85 r'EXPRESS OR IMPLIED\n'
86 r'.*? WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES '
87 r'OF\n'
88 r'.*? MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE '
89 r'DISCLAIMED\. IN NO\n'
90 r'.*? EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, '
91 r'INCIDENTAL,\n'
92 r'.*? SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES \(INCLUDING, '
93 r'BUT NOT LIMITED TO,\n'
94 r'.*? PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR '
95 r'PROFITS;\n'
96 r'.*? OR BUSINESS INTERRUPTION\) HOWEVER CAUSED AND ON ANY THEORY OF '
97 r'LIABILITY,\n'
98 r'.*? WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \(INCLUDING '
99 r'NEGLIGENCE OR\n'
100 r'.*? OTHERWISE\) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, '
101 r'EVEN IF\n'
102 r'.*? ADVISED OF THE POSSIBILITY OF SUCH DAMAGE\.\n'
103 ) % {
104 'year': years_re,
105 }
106 return license_header
107
henrike@webrtc.orgea40bd02013-07-29 18:20:07 +0000108def _ProtectedFiles(input_api, output_api):
109 results = []
110 changed_files = []
111 for f in input_api.AffectedFiles():
112 changed_files.append(f.LocalPath())
113 bad_files = list(set(DO_NOT_SUBMIT_FILES) & set(changed_files))
114 if bad_files:
115 error_type = output_api.PresubmitError
116 results.append(error_type(
117 'The following affected files are only allowed to be updated when '
118 'importing libjingle',
119 bad_files))
120 return results
121
henrike@webrtc.org390fcb72013-07-22 22:32:50 +0000122def _CommonChecks(input_api, output_api):
123 """Checks common to both upload and commit."""
124 results = []
125 results.extend(input_api.canned_checks.CheckLicense(
126 input_api, output_api, _LicenseHeader(input_api)))
henrike@webrtc.orgea40bd02013-07-29 18:20:07 +0000127 results.extend(_ProtectedFiles(input_api, output_api))
henrike@webrtc.org390fcb72013-07-22 22:32:50 +0000128 return results
129
130def CheckChangeOnUpload(input_api, output_api):
131 results = []
132 results.extend(_CommonChecks(input_api, output_api))
133 return results
134
135def CheckChangeOnCommit(input_api, output_api):
136 results = []
137 results.extend(_CommonChecks(input_api, output_api))
138 return results