OLD | NEW |
1 # Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | 1 # Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file |
2 # for details. All rights reserved. Use of this source code is governed by a | 2 # for details. All rights reserved. Use of this source code is governed by a |
3 # BSD-style license that can be found in the LICENSE.md file. | 3 # BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 import cpplint | 5 import cpplint |
6 | 6 |
7 """Top-level presubmit script for Fletch. | 7 """Top-level presubmit script for Dartino. |
8 | 8 |
9 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts | 9 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts |
10 for more details about the presubmit API built into gcl. | 10 for more details about the presubmit API built into gcl. |
11 """ | 11 """ |
12 # We have auto generated code that we do not want to lint. | 12 # We have auto generated code that we do not want to lint. |
13 NO_LINTING = ( | 13 NO_LINTING = ( |
14 r"^pkg[\\\/]immi_samples[\\\/]lib[\\\/]ios[\\\/].*", | 14 r"^pkg[\\\/]immi_samples[\\\/]lib[\\\/]ios[\\\/].*", |
15 r"^package[\\\/]immi[\\\/]objc[\\\/].*", | 15 r"^package[\\\/]immi[\\\/]objc[\\\/].*", |
16 r"^package[\\\/]service[\\\/]cc[\\\/].*" | 16 r"^package[\\\/]service[\\\/]cc[\\\/].*" |
17 r"^package[\\\/]service[\\\/]java[\\\/]jni[\\\/].*", | 17 r"^package[\\\/]service[\\\/]java[\\\/]jni[\\\/].*", |
18 r"^platforms[\\\/]stm[\\\/]disco_fletch[\\\/]generated[\\\/].*", | 18 r"^platforms[\\\/]stm[\\\/]disco_dartino[\\\/]generated[\\\/].*", |
19 r"^samples[\\\/]github[\\\/]ios[\\\/].*", | 19 r"^samples[\\\/]github[\\\/]ios[\\\/].*", |
20 r"^samples[\\\/]buildbot[\\\/]cc[\\\/].*", | 20 r"^samples[\\\/]buildbot[\\\/]cc[\\\/].*", |
21 r"^samples[\\\/]buildbot[\\\/]ios[\\\/].*", | 21 r"^samples[\\\/]buildbot[\\\/]ios[\\\/].*", |
22 r"^samples[\\\/]buildbot[\\\/]java[\\\/]jni[\\\/].*", | 22 r"^samples[\\\/]buildbot[\\\/]java[\\\/]jni[\\\/].*", |
23 r"^samples[\\\/]buildbot[\\\/]objc[\\\/].*", | 23 r"^samples[\\\/]buildbot[\\\/]objc[\\\/].*", |
24 r"^samples[\\\/]myapi[\\\/]generated[\\\/]java[\\\/]jni[\\\/].*", | 24 r"^samples[\\\/]myapi[\\\/]generated[\\\/]java[\\\/]jni[\\\/].*", |
25 r"^samples[\\\/]todomvc[\\\/]cc[\\\/].*", | 25 r"^samples[\\\/]todomvc[\\\/]cc[\\\/].*", |
26 r"^samples[\\\/]todomvc[\\\/]ios[\\\/].*", | 26 r"^samples[\\\/]todomvc[\\\/]ios[\\\/].*", |
27 r"^samples[\\\/]todomvc[\\\/]java[\\\/]jni[\\\/].*", | 27 r"^samples[\\\/]todomvc[\\\/]java[\\\/]jni[\\\/].*", |
28 r"^tests[\\\/]service_tests[\\\/]conformance[\\\/]cc[\\\/].*", | 28 r"^tests[\\\/]service_tests[\\\/]conformance[\\\/]cc[\\\/].*", |
29 r"^tests[\\\/]service_tests[\\\/]conformance[\\\/]java[\\\/]jni[\\\/].*", | 29 r"^tests[\\\/]service_tests[\\\/]conformance[\\\/]java[\\\/]jni[\\\/].*", |
30 r"^tests[\\\/]service_tests[\\\/]performance[\\\/]cc[\\\/].*", | 30 r"^tests[\\\/]service_tests[\\\/]performance[\\\/]cc[\\\/].*", |
31 r"^tests[\\\/]service_tests[\\\/]performance[\\\/]java[\\\/]jni[\\\/].*", | 31 r"^tests[\\\/]service_tests[\\\/]performance[\\\/]java[\\\/]jni[\\\/].*", |
32 r"^tests[\\\/]service_tests[\\\/]multiple_services[\\\/]cc[\\\/].*", | 32 r"^tests[\\\/]service_tests[\\\/]multiple_services[\\\/]cc[\\\/].*", |
33 r"^tests[\\\/]service_tests[\\\/]multiple_services[\\\/]java[\\\/]jni[\\\/].
*", | 33 r"^tests[\\\/]service_tests[\\\/]multiple_services[\\\/]java[\\\/]jni[\\\/].
*", |
34 r"^third_party[\\\/]yasm[\\\/]source[\\\/]config[\\\/]win[\\\/].*", | 34 r"^third_party[\\\/]yasm[\\\/]source[\\\/]config[\\\/]win[\\\/].*", |
35 r"^third_party[\\\/]double-conversion[\\\/]src[\\\/].*", | 35 r"^third_party[\\\/]double-conversion[\\\/]src[\\\/].*", |
36 r"^tools[\\\/]immic[\\\/]lib[\\\/]src[\\\/]resources[\\\/]objc[\\\/].*", | 36 r"^tools[\\\/]immic[\\\/]lib[\\\/]src[\\\/]resources[\\\/]objc[\\\/].*", |
37 r"^tools[\\\/]servicec[\\\/]lib[\\\/]src[\\\/]resources[\\\/]cc[\\\/].*", | 37 r"^tools[\\\/]servicec[\\\/]lib[\\\/]src[\\\/]resources[\\\/]cc[\\\/].*", |
38 ) | 38 ) |
39 | 39 |
40 def CheckChangeOnCommit(input_api, output_api): | 40 def CheckChangeOnCommit(input_api, output_api): |
41 results = [] | 41 results = [] |
42 status_check = input_api.canned_checks.CheckTreeIsOpen( | 42 status_check = input_api.canned_checks.CheckTreeIsOpen( |
43 input_api, | 43 input_api, |
44 output_api, | 44 output_api, |
45 json_url='http://fletch-status.appspot.com/current?format=json') | 45 json_url='http://dartino-status.appspot.com/current?format=json') |
46 results.extend(status_check) | 46 results.extend(status_check) |
47 results.extend(RunLint(input_api, output_api)) | 47 results.extend(RunLint(input_api, output_api)) |
48 return results | 48 return results |
49 | 49 |
50 def CheckChangeOnUpload(input_api, output_api): | 50 def CheckChangeOnUpload(input_api, output_api): |
51 return RunLint(input_api, output_api) | 51 return RunLint(input_api, output_api) |
52 | 52 |
53 | 53 |
54 def RunLint(input_api, output_api): | 54 def RunLint(input_api, output_api): |
55 def FilterFile(file): | 55 def FilterFile(file): |
56 return input_api.FilterSourceFile(file, | 56 return input_api.FilterSourceFile(file, |
57 black_list=NO_LINTING) | 57 black_list=NO_LINTING) |
58 result = [] | 58 result = [] |
59 cpplint._cpplint_state.ResetErrorCounts() | 59 cpplint._cpplint_state.ResetErrorCounts() |
60 # Find all .cc and .h files in the change list. | 60 # Find all .cc and .h files in the change list. |
61 for f in input_api.AffectedSourceFiles(FilterFile): | 61 for f in input_api.AffectedSourceFiles(FilterFile): |
62 filename = f.AbsoluteLocalPath() | 62 filename = f.AbsoluteLocalPath() |
63 if filename.endswith('.cc') or filename.endswith('.h'): | 63 if filename.endswith('.cc') or filename.endswith('.h'): |
64 # Run cpplint on the file. | 64 # Run cpplint on the file. |
65 cpplint.ProcessFile(filename, 1) | 65 cpplint.ProcessFile(filename, 1) |
66 | 66 |
67 # Report a presubmit error if any of the files had an error. | 67 # Report a presubmit error if any of the files had an error. |
68 if cpplint._cpplint_state.error_count > 0: | 68 if cpplint._cpplint_state.error_count > 0: |
69 result = [output_api.PresubmitError('Failed cpplint check.')] | 69 result = [output_api.PresubmitError('Failed cpplint check.')] |
70 return result | 70 return result |
OLD | NEW |