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