OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 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 """Downloads, builds (with instrumentation) and installs shared libraries.""" | 6 """Downloads, builds (with instrumentation) and installs shared libraries.""" |
7 | 7 |
8 import argparse | 8 import argparse |
9 import os | 9 import os |
10 import platform | 10 import platform |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 with ScopedChangeDirectory(package_directory) as cd_package: | 279 with ScopedChangeDirectory(package_directory) as cd_package: |
280 shell_call('apt-get source %s' % parsed_arguments.package, | 280 shell_call('apt-get source %s' % parsed_arguments.package, |
281 parsed_arguments.verbose) | 281 parsed_arguments.verbose) |
282 # There should be exactly one subdirectory after downloading a package. | 282 # There should be exactly one subdirectory after downloading a package. |
283 subdirectories = [d for d in os.listdir('.') if os.path.isdir(d)] | 283 subdirectories = [d for d in os.listdir('.') if os.path.isdir(d)] |
284 if len(subdirectories) != 1: | 284 if len(subdirectories) != 1: |
285 raise (Exception('There was not one directory after downloading ' | 285 raise (Exception('There was not one directory after downloading ' |
286 'a package %s' % parsed_arguments.package)) | 286 'a package %s' % parsed_arguments.package)) |
287 with ScopedChangeDirectory(subdirectories[0]): | 287 with ScopedChangeDirectory(subdirectories[0]): |
288 # Here we are in the package directory. | 288 # Here we are in the package directory. |
| 289 if parsed_arguments.patch: |
| 290 shell_call( |
| 291 'patch -p1 -i %s/%s' % |
| 292 (os.path.relpath(cd_package.old_path), |
| 293 parsed_arguments.patch), |
| 294 parsed_arguments.verbose) |
289 if parsed_arguments.run_before_build: | 295 if parsed_arguments.run_before_build: |
290 shell_call( | 296 shell_call( |
291 '%s/%s' % | 297 '%s/%s' % |
292 (os.path.relpath(cd_package.old_path), | 298 (os.path.relpath(cd_package.old_path), |
293 parsed_arguments.run_before_build), | 299 parsed_arguments.run_before_build), |
294 parsed_arguments.verbose) | 300 parsed_arguments.verbose) |
295 try: | 301 try: |
296 build_and_install(parsed_arguments, environment, install_prefix) | 302 build_and_install(parsed_arguments, environment, install_prefix) |
297 except Exception as exception: | 303 except Exception as exception: |
298 print exception | 304 print exception |
(...skipping 24 matching lines...) Expand all Loading... |
323 help='Relative path to the directory for temporary build files') | 329 help='Relative path to the directory for temporary build files') |
324 argument_parser.add_argument('--extra-configure-flags', default='') | 330 argument_parser.add_argument('--extra-configure-flags', default='') |
325 argument_parser.add_argument('--cflags', default='') | 331 argument_parser.add_argument('--cflags', default='') |
326 argument_parser.add_argument('--ldflags', default='') | 332 argument_parser.add_argument('--ldflags', default='') |
327 argument_parser.add_argument('-s', '--sanitizer-type', required=True, | 333 argument_parser.add_argument('-s', '--sanitizer-type', required=True, |
328 choices=['asan', 'msan', 'tsan']) | 334 choices=['asan', 'msan', 'tsan']) |
329 argument_parser.add_argument('-v', '--verbose', action='store_true') | 335 argument_parser.add_argument('-v', '--verbose', action='store_true') |
330 argument_parser.add_argument('--check-build-deps', action='store_true') | 336 argument_parser.add_argument('--check-build-deps', action='store_true') |
331 argument_parser.add_argument('--cc') | 337 argument_parser.add_argument('--cc') |
332 argument_parser.add_argument('--cxx') | 338 argument_parser.add_argument('--cxx') |
333 # This should be a shell script to run before building specific libraries | 339 argument_parser.add_argument('--patch', default='') |
334 # e.g. extracting archives with sources, patching makefiles, etc. | 340 # This should be a shell script to run before building specific libraries. |
| 341 # This will be run after applying the patch above. |
335 argument_parser.add_argument('--run-before-build', default='') | 342 argument_parser.add_argument('--run-before-build', default='') |
336 argument_parser.add_argument('--build-method', default='destdir') | 343 argument_parser.add_argument('--build-method', default='destdir') |
337 argument_parser.add_argument('--sanitizer-blacklist', default='') | 344 argument_parser.add_argument('--sanitizer-blacklist', default='') |
338 | 345 |
339 # Ignore all empty arguments because in several cases gyp passes them to the | 346 # Ignore all empty arguments because in several cases gyp passes them to the |
340 # script, but ArgumentParser treats them as positional arguments instead of | 347 # script, but ArgumentParser treats them as positional arguments instead of |
341 # ignoring (and doesn't have such options). | 348 # ignoring (and doesn't have such options). |
342 parsed_arguments = argument_parser.parse_args( | 349 parsed_arguments = argument_parser.parse_args( |
343 [arg for arg in sys.argv[1:] if len(arg) != 0]) | 350 [arg for arg in sys.argv[1:] if len(arg) != 0]) |
344 # Ensure current working directory is this script directory. | 351 # Ensure current working directory is this script directory. |
345 os.chdir(get_script_absolute_path()) | 352 os.chdir(get_script_absolute_path()) |
346 # Ensure all build dependencies are installed. | 353 # Ensure all build dependencies are installed. |
347 if parsed_arguments.check_build_deps: | 354 if parsed_arguments.check_build_deps: |
348 check_package_build_dependencies(parsed_arguments.package) | 355 check_package_build_dependencies(parsed_arguments.package) |
349 | 356 |
350 download_build_install(parsed_arguments) | 357 download_build_install(parsed_arguments) |
351 | 358 |
352 | 359 |
353 if __name__ == '__main__': | 360 if __name__ == '__main__': |
354 main() | 361 main() |
OLD | NEW |