Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: third_party/instrumented_libraries/download_build_install.py

Issue 113443003: Disable library dependencies check by default (instrumented libs). (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/instrumented_libraries/instrumented_libraries.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 shutil 10 import shutil
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 def get_library_build_dependencies(library): 46 def get_library_build_dependencies(library):
47 command = 'apt-get -s build-dep %s | grep Inst | cut -d " " -f 2' % library 47 command = 'apt-get -s build-dep %s | grep Inst | cut -d " " -f 2' % library
48 command_result = subprocess.Popen(command, stdout=subprocess.PIPE, 48 command_result = subprocess.Popen(command, stdout=subprocess.PIPE,
49 shell=True) 49 shell=True)
50 if command_result.wait(): 50 if command_result.wait():
51 raise Exception("Failed to determine build dependencies for %s" % library) 51 raise Exception("Failed to determine build dependencies for %s" % library)
52 build_dependencies = [l.strip() for l in command_result.stdout] 52 build_dependencies = [l.strip() for l in command_result.stdout]
53 return build_dependencies 53 return build_dependencies
54 54
55 def check_library_build_dependencies(library):
56 build_dependencies = get_library_build_dependencies(library)
57 if len(build_dependencies):
58 print >> sys.stderr, 'Please, install build-dependencies for %s' % library
59 print >> sys.stderr, 'One-liner for APT:'
60 print >> sys.stderr, 'sudo apt-get -y --no-remove build-dep %s' % library
61 sys.exit(1)
55 62
56 def shell_call(command, verbose=False, environment=None): 63 def shell_call(command, verbose=False, environment=None):
57 """ Wrapper on subprocess.Popen 64 """ Wrapper on subprocess.Popen
58 65
59 Calls command with specific environment and verbosity using 66 Calls command with specific environment and verbosity using
60 subprocess.Popen 67 subprocess.Popen
61 68
62 Args: 69 Args:
63 command: Command to run in shell. 70 command: Command to run in shell.
64 verbose: If False, hides all stdout and stderr in case of successful build. 71 verbose: If False, hides all stdout and stderr in case of successful build.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 111
105 if not os.path.exists(library_directory): 112 if not os.path.exists(library_directory):
106 os.makedirs(library_directory) 113 os.makedirs(library_directory)
107 114
108 with ScopedChangeDirectory(library_directory): 115 with ScopedChangeDirectory(library_directory):
109 shell_call('apt-get source %s' % parsed_arguments.library, 116 shell_call('apt-get source %s' % parsed_arguments.library,
110 parsed_arguments.verbose) 117 parsed_arguments.verbose)
111 # There should be exactly one subdirectory after downloading a package. 118 # There should be exactly one subdirectory after downloading a package.
112 subdirectories = [d for d in os.listdir('.') if os.path.isdir(d)] 119 subdirectories = [d for d in os.listdir('.') if os.path.isdir(d)]
113 if len(subdirectories) != 1: 120 if len(subdirectories) != 1:
114 raise Exception('There was not one directory after downloading ' \ 121 raise (Exception('There was not one directory after downloading '
115 'a package %s' % parsed_arguments.library) 122 'a package %s' % parsed_arguments.library))
116 with ScopedChangeDirectory(subdirectories[0]): 123 with ScopedChangeDirectory(subdirectories[0]):
117 # Now we are in the package directory. 124 # Now we are in the package directory.
118 configure_command = './configure %s --prefix=%s' % ( 125 configure_command = './configure %s --prefix=%s' % (
119 parsed_arguments.custom_configure_flags, install_prefix) 126 parsed_arguments.custom_configure_flags, install_prefix)
120 shell_call(configure_command, parsed_arguments.verbose, environment) 127 try:
121 shell_call('make -j%s' % parsed_arguments.jobs, parsed_arguments.verbose) 128 shell_call(configure_command, parsed_arguments.verbose, environment)
122 shell_call('make -j%s install' % parsed_arguments.jobs, 129 shell_call('make -j%s' % parsed_arguments.jobs,
123 parsed_arguments.verbose) 130 parsed_arguments.verbose, environment)
124 131 shell_call('make -j%s install' % parsed_arguments.jobs,
132 parsed_arguments.verbose, environment)
133 except Exception as exception:
134 print exception
135 print "Failed to build library %s." % parsed_arguments.library
136 print ("Probably, some of its dependencies are not installed: %s" %
137 ' '.join(get_library_build_dependencies(parsed_arguments.library)))
138 sys.exit(1)
139
125 # Touch a txt file to indicate library is installed. 140 # Touch a txt file to indicate library is installed.
126 open('%s/%s.txt' % (install_prefix, parsed_arguments.library), 'w').close() 141 open('%s/%s.txt' % (install_prefix, parsed_arguments.library), 'w').close()
127 142
128 # Remove downloaded package and generated temporary build files. 143 # Remove downloaded package and generated temporary build files.
129 shutil.rmtree(library_directory) 144 shutil.rmtree(library_directory)
130 145
131 146
132 def main(): 147 def main():
133 argument_parser = argparse.ArgumentParser( 148 argument_parser = argparse.ArgumentParser(
134 description = 'Download, build and install instrumented library') 149 description = 'Download, build and install instrumented library')
135 150
136 argument_parser.add_argument('-j', '--jobs', type=int, default=1) 151 argument_parser.add_argument('-j', '--jobs', type=int, default=1)
137 argument_parser.add_argument('-l', '--library', required=True) 152 argument_parser.add_argument('-l', '--library', required=True)
138 argument_parser.add_argument('-i', '--product-directory', default='.', 153 argument_parser.add_argument('-i', '--product-directory', default='.',
139 help='Relative path to the directory with chrome binaries') 154 help='Relative path to the directory with chrome binaries')
140 argument_parser.add_argument('-m', '--intermediate-directory', default='.', 155 argument_parser.add_argument('-m', '--intermediate-directory', default='.',
141 help='Relative path to the directory for temporary build files') 156 help='Relative path to the directory for temporary build files')
142 argument_parser.add_argument('-c', '--custom-configure-flags', default='') 157 argument_parser.add_argument('-c', '--custom-configure-flags', default='')
143 argument_parser.add_argument('-s', '--sanitizer-type', required=True, 158 argument_parser.add_argument('-s', '--sanitizer-type', required=True,
144 choices=SUPPORTED_SANITIZERS.keys()) 159 choices=SUPPORTED_SANITIZERS.keys())
145 argument_parser.add_argument('-v', '--verbose', action='store_true') 160 argument_parser.add_argument('-v', '--verbose', action='store_true')
146 161 argument_parser.add_argument('--check-build-deps', action='store_true')
162
147 # Ignore all empty arguments because in several cases gyp passes them to the 163 # Ignore all empty arguments because in several cases gyp passes them to the
148 # script, but ArgumentParser treats them as positional arguments instead of 164 # script, but ArgumentParser treats them as positional arguments instead of
149 # ignoring (and doesn't have such options). 165 # ignoring (and doesn't have such options).
150 parsed_arguments = argument_parser.parse_args( 166 parsed_arguments = argument_parser.parse_args(
151 [arg for arg in sys.argv[1:] if len(arg) != 0]) 167 [arg for arg in sys.argv[1:] if len(arg) != 0])
152 # Ensure current working directory is this script directory. 168 # Ensure current working directory is this script directory.
153 os.chdir(get_script_absolute_path()) 169 os.chdir(get_script_absolute_path())
154 # Ensure all build dependencies are installed. 170 # Ensure all build dependencies are installed.
155 build_dependencies = get_library_build_dependencies(parsed_arguments.library) 171 if parsed_arguments.check_build_deps:
156 if len(build_dependencies): 172 check_library_build_dependencies(parsed_arguments.library)
157 print >> sys.stderr, 'Please, install build-dependencies for %s' % \ 173
158 parsed_arguments.library
159 print >> sys.stderr, 'One-liner for APT:'
160 print >> sys.stderr, 'sudo apt-get -y --no-remove build-dep %s' % \
161 parsed_arguments.library
162 sys.exit(1)
163
164 download_build_install(parsed_arguments) 174 download_build_install(parsed_arguments)
165 175
166 176
167 if __name__ == '__main__': 177 if __name__ == '__main__':
168 main() 178 main()
OLDNEW
« no previous file with comments | « no previous file | third_party/instrumented_libraries/instrumented_libraries.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698