OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """ | 6 """ |
7 Runs Coverity Prevent on a build of Chromium. | 7 Runs Coverity Prevent on a build of Chromium. |
8 | 8 |
9 This script should be run in a Visual Studio Command Prompt, so that the | 9 This script should be run in a Visual Studio Command Prompt, so that the |
10 INCLUDE, LIB, and PATH environment variables are set properly for Visual | 10 INCLUDE, LIB, and PATH environment variables are set properly for Visual |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 cmd = 'gclient sync' | 128 cmd = 'gclient sync' |
129 gclient_exit = _RunCommand(cmd, options.dry_run, shell=True) | 129 gclient_exit = _RunCommand(cmd, options.dry_run, shell=True) |
130 if gclient_exit != 0: | 130 if gclient_exit != 0: |
131 print 'gclient aborted with status %s' % gclient_exit | 131 print 'gclient aborted with status %s' % gclient_exit |
132 _ReleaseLock(lock_file, lock_filename) | 132 _ReleaseLock(lock_file, lock_filename) |
133 sys.exit(1) | 133 sys.exit(1) |
134 | 134 |
135 print 'Elapsed time: %ds' % (time.time() - start_time) | 135 print 'Elapsed time: %ds' % (time.time() - start_time) |
136 | 136 |
137 # Do a clean build. Remove the build output directory first. | 137 # Do a clean build. Remove the build output directory first. |
138 if sys.platform == 'linux2': | 138 if sys.platform.startswith('linux'): |
139 rm_path = os.path.join(options.source_dir,'src','out',options.target) | 139 rm_path = os.path.join(options.source_dir,'src','out',options.target) |
140 elif sys.platform == 'win32': | 140 elif sys.platform == 'win32': |
141 rm_path = os.path.join(options.source_dir,options.solution_dir, | 141 rm_path = os.path.join(options.source_dir,options.solution_dir, |
142 options.target) | 142 options.target) |
143 elif sys.platform == 'darwin': | 143 elif sys.platform == 'darwin': |
144 rm_path = os.path.join(options.source_dir,'src','xcodebuild') | 144 rm_path = os.path.join(options.source_dir,'src','xcodebuild') |
145 else: | 145 else: |
146 print 'Platform "%s" unrecognized, aborting' % sys.platform | 146 print 'Platform "%s" unrecognized, aborting' % sys.platform |
147 _ReleaseLock(lock_file, lock_filename) | 147 _ReleaseLock(lock_file, lock_filename) |
148 sys.exit(1) | 148 sys.exit(1) |
149 | 149 |
150 if options.dry_run: | 150 if options.dry_run: |
151 print 'shutil.rmtree(%s)' % repr(rm_path) | 151 print 'shutil.rmtree(%s)' % repr(rm_path) |
152 else: | 152 else: |
153 shutil.rmtree(rm_path,True) | 153 shutil.rmtree(rm_path,True) |
154 | 154 |
155 if options.preserve_intermediate_dir: | 155 if options.preserve_intermediate_dir: |
156 print 'Preserving intermediate directory.' | 156 print 'Preserving intermediate directory.' |
157 else: | 157 else: |
158 if options.dry_run: | 158 if options.dry_run: |
159 print 'shutil.rmtree(%s)' % repr(options.coverity_intermediate_dir) | 159 print 'shutil.rmtree(%s)' % repr(options.coverity_intermediate_dir) |
160 print 'os.mkdir(%s)' % repr(options.coverity_intermediate_dir) | 160 print 'os.mkdir(%s)' % repr(options.coverity_intermediate_dir) |
161 else: | 161 else: |
162 shutil.rmtree(options.coverity_intermediate_dir,True) | 162 shutil.rmtree(options.coverity_intermediate_dir,True) |
163 os.mkdir(options.coverity_intermediate_dir) | 163 os.mkdir(options.coverity_intermediate_dir) |
164 | 164 |
165 print 'Elapsed time: %ds' % (time.time() - start_time) | 165 print 'Elapsed time: %ds' % (time.time() - start_time) |
166 | 166 |
167 use_shell_during_make = False | 167 use_shell_during_make = False |
168 if sys.platform == 'linux2': | 168 if sys.platform.startswith('linux'): |
169 use_shell_during_make = True | 169 use_shell_during_make = True |
170 os.chdir('src') | 170 os.chdir('src') |
171 _RunCommand('pwd', options.dry_run, shell=True) | 171 _RunCommand('pwd', options.dry_run, shell=True) |
172 cmd = '%s/cov-build --dir %s make BUILDTYPE=%s chrome' % ( | 172 cmd = '%s/cov-build --dir %s make BUILDTYPE=%s chrome' % ( |
173 options.coverity_bin_dir, options.coverity_intermediate_dir, | 173 options.coverity_bin_dir, options.coverity_intermediate_dir, |
174 options.target) | 174 options.target) |
175 elif sys.platform == 'win32': | 175 elif sys.platform == 'win32': |
176 cmd = ('%s\\cov-build.exe --dir %s devenv.com %s\\%s /build %s ' | 176 cmd = ('%s\\cov-build.exe --dir %s devenv.com %s\\%s /build %s ' |
177 '/project chrome.vcproj') % ( | 177 '/project chrome.vcproj') % ( |
178 options.coverity_bin_dir, options.coverity_intermediate_dir, | 178 options.coverity_bin_dir, options.coverity_intermediate_dir, |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 helpmsg = ('By default, the intermediate dir is emptied before analysis. ' | 292 helpmsg = ('By default, the intermediate dir is emptied before analysis. ' |
293 'This switch disables that behavior.') | 293 'This switch disables that behavior.') |
294 option_parser.add_option('', '--preserve-intermediate-dir', | 294 option_parser.add_option('', '--preserve-intermediate-dir', |
295 action='store_true', help=helpmsg, | 295 action='store_true', help=helpmsg, |
296 default=False) | 296 default=False) |
297 | 297 |
298 options, args = option_parser.parse_args() | 298 options, args = option_parser.parse_args() |
299 | 299 |
300 result = main(options, args) | 300 result = main(options, args) |
301 sys.exit(result) | 301 sys.exit(result) |
OLD | NEW |