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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 Exception: if return code after call is not zero. | 91 Exception: if return code after call is not zero. |
92 """ | 92 """ |
93 child = subprocess.Popen(command, stdout=subprocess.PIPE, | 93 child = subprocess.Popen(command, stdout=subprocess.PIPE, |
94 stderr=subprocess.STDOUT, env=environment, shell=True) | 94 stderr=subprocess.STDOUT, env=environment, shell=True) |
95 stdout, stderr = child.communicate() | 95 stdout, stderr = child.communicate() |
96 if verbose or child.returncode: | 96 if verbose or child.returncode: |
97 print stdout | 97 print stdout |
98 if child.returncode: | 98 if child.returncode: |
99 raise Exception("Failed to run: %s" % command) | 99 raise Exception("Failed to run: %s" % command) |
100 | 100 |
101 def configure_make_install(parsed_arguments, environment, install_prefix): | 101 def destdir_configure_make_install(parsed_arguments, environment, |
| 102 install_prefix): |
| 103 configure_command = './configure %s' % parsed_arguments.custom_configure_flags |
| 104 configure_command += ' --libdir=/lib/' |
| 105 shell_call(configure_command, parsed_arguments.verbose, environment) |
| 106 shell_call('make -j%s' % parsed_arguments.jobs, |
| 107 parsed_arguments.verbose, environment) |
| 108 shell_call('make -j%s DESTDIR=%s install' % (parsed_arguments.jobs, |
| 109 install_prefix), |
| 110 parsed_arguments.verbose, environment) |
| 111 # Kill the .la files. They contain absolute paths, and will cause build errors |
| 112 # in dependent libraries. |
| 113 shell_call('rm %s/lib/*.la -f' % install_prefix) |
| 114 |
| 115 def prefix_configure_make_install(parsed_arguments, environment, |
| 116 install_prefix): |
102 configure_command = './configure %s --prefix=%s' % ( | 117 configure_command = './configure %s --prefix=%s' % ( |
103 parsed_arguments.custom_configure_flags, install_prefix) | 118 parsed_arguments.custom_configure_flags, install_prefix) |
104 shell_call(configure_command, parsed_arguments.verbose, environment) | 119 shell_call(configure_command, parsed_arguments.verbose, environment) |
105 shell_call('make -j%s' % parsed_arguments.jobs, | 120 shell_call('make -j%s' % parsed_arguments.jobs, |
106 parsed_arguments.verbose, environment) | 121 parsed_arguments.verbose, environment) |
107 shell_call('make -j%s install' % parsed_arguments.jobs, | 122 shell_call('make -j%s install' % parsed_arguments.jobs, |
108 parsed_arguments.verbose, environment) | 123 parsed_arguments.verbose, environment) |
109 | 124 |
110 def nss_make_and_copy(parsed_arguments, environment, install_prefix): | 125 def nss_make_and_copy(parsed_arguments, environment, install_prefix): |
111 # NSS uses a build system that's different from configure/make/install. All | 126 # NSS uses a build system that's different from configure/make/install. All |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 'prefix=%s' % install_prefix, | 167 'prefix=%s' % install_prefix, |
153 # Do not install in lib64/. | 168 # Do not install in lib64/. |
154 'lib=lib', | 169 'lib=lib', |
155 # Skip a step that requires sudo. | 170 # Skip a step that requires sudo. |
156 'RAISE_SETFCAP=no' | 171 'RAISE_SETFCAP=no' |
157 ] | 172 ] |
158 shell_call('make -j%s install %s' % (parsed_arguments.jobs, | 173 shell_call('make -j%s install %s' % (parsed_arguments.jobs, |
159 ' '.join(install_args)), parsed_arguments.verbose, environment) | 174 ' '.join(install_args)), parsed_arguments.verbose, environment) |
160 | 175 |
161 def build_and_install(parsed_arguments, environment, install_prefix): | 176 def build_and_install(parsed_arguments, environment, install_prefix): |
162 if parsed_arguments.library == 'pango-1.0': | 177 if parsed_arguments.build_method == 'destdir': |
163 # This needs an absolute path and thus cannot be in GYP. | 178 destdir_configure_make_install(parsed_arguments, environment, install_prefix
) |
| 179 elif parsed_arguments.build_method == 'prefix': |
| 180 prefix_configure_make_install(parsed_arguments, environment, install_prefix) |
| 181 elif parsed_arguments.build_method == 'custom_nss': |
| 182 nss_make_and_copy(parsed_arguments, environment, install_prefix) |
| 183 elif parsed_arguments.build_method == 'custom_libcap': |
| 184 libcap2_make_install(parsed_arguments, environment, install_prefix) |
| 185 elif parsed_arguments.build_method == 'custom_pango': |
164 parsed_arguments.custom_configure_flags += \ | 186 parsed_arguments.custom_configure_flags += \ |
165 ' --x-libraries=%s/lib' % install_prefix | 187 ' --x-libraries=%s/lib' % install_prefix |
166 parsed_arguments.custom_configure_flags += \ | 188 parsed_arguments.custom_configure_flags += \ |
167 ' --x-includes=%s/include' % install_prefix | 189 ' --x-includes=%s/include' % install_prefix |
168 | 190 prefix_configure_make_install(parsed_arguments, environment, install_prefix) |
169 if parsed_arguments.library == 'nss': | |
170 nss_make_and_copy(parsed_arguments, environment, install_prefix) | |
171 elif parsed_arguments.library == 'libcap2': | |
172 libcap2_make_install(parsed_arguments, environment, install_prefix) | |
173 else: | 191 else: |
174 configure_make_install(parsed_arguments, environment, install_prefix) | 192 raise Exception('Unrecognized build method: %s' % |
175 | 193 parsed_arguments.build_method) |
176 | 194 |
177 def download_build_install(parsed_arguments): | 195 def download_build_install(parsed_arguments): |
178 sanitizer_params = SUPPORTED_SANITIZERS[parsed_arguments.sanitizer_type] | 196 sanitizer_params = SUPPORTED_SANITIZERS[parsed_arguments.sanitizer_type] |
179 | 197 |
180 environment = os.environ.copy() | 198 environment = os.environ.copy() |
181 # Usage of environment variables CC and CXX prefers usage flags --c-compiler | 199 # Usage of environment variables CC and CXX prefers usage flags --c-compiler |
182 # and --cxx-compiler | 200 # and --cxx-compiler |
183 if 'CC' not in environment and parsed_arguments.c_compiler: | 201 if 'CC' not in environment and parsed_arguments.c_compiler: |
184 environment['CC'] = parsed_arguments.c_compiler | 202 environment['CC'] = parsed_arguments.c_compiler |
185 if 'CXX' not in environment and parsed_arguments.cxx_compiler: | 203 if 'CXX' not in environment and parsed_arguments.cxx_compiler: |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 argument_parser.add_argument('--custom-linker-flags', default='') | 273 argument_parser.add_argument('--custom-linker-flags', default='') |
256 argument_parser.add_argument('-s', '--sanitizer-type', required=True, | 274 argument_parser.add_argument('-s', '--sanitizer-type', required=True, |
257 choices=SUPPORTED_SANITIZERS.keys()) | 275 choices=SUPPORTED_SANITIZERS.keys()) |
258 argument_parser.add_argument('-v', '--verbose', action='store_true') | 276 argument_parser.add_argument('-v', '--verbose', action='store_true') |
259 argument_parser.add_argument('--check-build-deps', action='store_true') | 277 argument_parser.add_argument('--check-build-deps', action='store_true') |
260 argument_parser.add_argument('--c-compiler') | 278 argument_parser.add_argument('--c-compiler') |
261 argument_parser.add_argument('--cxx-compiler') | 279 argument_parser.add_argument('--cxx-compiler') |
262 # This should be a shell script to run before building specific libraries | 280 # This should be a shell script to run before building specific libraries |
263 # e.g. extracting archives with sources, patching makefiles, etc. | 281 # e.g. extracting archives with sources, patching makefiles, etc. |
264 argument_parser.add_argument('--run-before-build', default='') | 282 argument_parser.add_argument('--run-before-build', default='') |
| 283 argument_parser.add_argument('--build-method', default='destdir') |
265 | 284 |
266 # Ignore all empty arguments because in several cases gyp passes them to the | 285 # Ignore all empty arguments because in several cases gyp passes them to the |
267 # script, but ArgumentParser treats them as positional arguments instead of | 286 # script, but ArgumentParser treats them as positional arguments instead of |
268 # ignoring (and doesn't have such options). | 287 # ignoring (and doesn't have such options). |
269 parsed_arguments = argument_parser.parse_args( | 288 parsed_arguments = argument_parser.parse_args( |
270 [arg for arg in sys.argv[1:] if len(arg) != 0]) | 289 [arg for arg in sys.argv[1:] if len(arg) != 0]) |
271 # Ensure current working directory is this script directory. | 290 # Ensure current working directory is this script directory. |
272 os.chdir(get_script_absolute_path()) | 291 os.chdir(get_script_absolute_path()) |
273 # Ensure all build dependencies are installed. | 292 # Ensure all build dependencies are installed. |
274 if parsed_arguments.check_build_deps: | 293 if parsed_arguments.check_build_deps: |
275 check_library_build_dependencies(parsed_arguments.library) | 294 check_library_build_dependencies(parsed_arguments.library) |
276 | 295 |
277 download_build_install(parsed_arguments) | 296 download_build_install(parsed_arguments) |
278 | 297 |
279 | 298 |
280 if __name__ == '__main__': | 299 if __name__ == '__main__': |
281 main() | 300 main() |
OLD | NEW |