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

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

Issue 1020583002: Instrumented libraries: more aggressive cleanup. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months 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 | no next file » | 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 platform 10 import platform
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 return os.path.join(self._source_dir, 'debian', 'instrumented_build') 192 return os.path.join(self._source_dir, 'debian', 'instrumented_build')
193 193
194 def temp_libdir(self): 194 def temp_libdir(self):
195 """Returns the directory under temp_dir() containing the DSOs.""" 195 """Returns the directory under temp_dir() containing the DSOs."""
196 return os.path.join(self.temp_dir(), self._libdir) 196 return os.path.join(self.temp_dir(), self._libdir)
197 197
198 def dest_libdir(self): 198 def dest_libdir(self):
199 """Returns the final location of the DSOs.""" 199 """Returns the final location of the DSOs."""
200 return os.path.join(self._destdir, self._libdir) 200 return os.path.join(self._destdir, self._libdir)
201 201
202 def cleanup_after_install(self):
203 """Removes unneeded files in self.temp_libdir()."""
204 # .la files are not needed, nuke them.
205 # In case --no-static is not supported, nuke any static libraries we built.
206 self.shell_call(
207 'find %s -name *.la -or -name *.a | xargs rm -f' % self.temp_libdir())
208 # .pc files are not needed.
209 self.shell_call('rm %s/pkgconfig -rf' % self.temp_libdir())
210
202 def make(self, args, jobs=None, env=None, cwd=None): 211 def make(self, args, jobs=None, env=None, cwd=None):
203 """Invokes `make'. 212 """Invokes `make'.
204 213
205 Invokes `make' with the specified args, using self._build_env and 214 Invokes `make' with the specified args, using self._build_env and
206 self._source_dir by default. 215 self._source_dir by default.
207 """ 216 """
208 if jobs is None: 217 if jobs is None:
209 jobs = self._jobs 218 jobs = self._jobs
210 if cwd is None: 219 if cwd is None:
211 cwd = self._source_dir 220 cwd = self._source_dir
(...skipping 17 matching lines...) Expand all
229 self.shell_call(configure_cmd, env=self._build_env, cwd=self._source_dir) 238 self.shell_call(configure_cmd, env=self._build_env, cwd=self._source_dir)
230 239
231 # Some makefiles use BUILDROOT or INSTALL_ROOT instead of DESTDIR. 240 # Some makefiles use BUILDROOT or INSTALL_ROOT instead of DESTDIR.
232 args = ['DESTDIR', 'BUILDROOT', 'INSTALL_ROOT'] 241 args = ['DESTDIR', 'BUILDROOT', 'INSTALL_ROOT']
233 make_args = ['%s=%s' % (name, self.temp_dir()) for name in args] 242 make_args = ['%s=%s' % (name, self.temp_dir()) for name in args]
234 self.make(make_args) 243 self.make(make_args)
235 244
236 # Some packages don't support parallel install. Use -j1 always. 245 # Some packages don't support parallel install. Use -j1 always.
237 self.make_install(make_args, jobs=1) 246 self.make_install(make_args, jobs=1)
238 247
239 # .la files are not needed, nuke them. 248 self.cleanup_after_install()
240 self.shell_call('rm %s/*.la -f' % self.temp_libdir())
241 249
242 self.fix_rpaths(self.temp_libdir()) 250 self.fix_rpaths(self.temp_libdir())
243 251
244 # Now move the contents of the temporary destdir to their final place. 252 # Now move the contents of the temporary destdir to their final place.
245 # We only care for the contents of LIBDIR. 253 # We only care for the contents of LIBDIR.
246 self.shell_call('cp %s/* %s/ -rdf' % (self.temp_libdir(), 254 self.shell_call('cp %s/* %s/ -rdf' % (self.temp_libdir(),
247 self.dest_libdir())) 255 self.dest_libdir()))
248 256
249 257
250 class LibcapBuilder(InstrumentedPackageBuilder): 258 class LibcapBuilder(InstrumentedPackageBuilder):
251 def build_and_install(self): 259 def build_and_install(self):
252 # libcap2 doesn't have a configure script 260 # libcap2 doesn't have a configure script
253 build_args = ['CC', 'CXX', 'CFLAGS', 'CXXFLAGS', 'LDFLAGS'] 261 build_args = ['CC', 'CXX', 'CFLAGS', 'CXXFLAGS', 'LDFLAGS']
254 make_args = [ 262 make_args = [
255 '%s="%s"' % (name, self._build_env[name]) for name in build_args 263 '%s="%s"' % (name, self._build_env[name]) for name in build_args
256 ] 264 ]
257 self.make(make_args) 265 self.make(make_args)
258 266
259 install_args = [ 267 install_args = [
260 'DESTDIR=%s' % self.temp_dir(), 268 'DESTDIR=%s' % self.temp_dir(),
261 'lib=%s' % self._libdir, 269 'lib=%s' % self._libdir,
262 # Skip a step that requires sudo. 270 # Skip a step that requires sudo.
263 'RAISE_SETFCAP=no' 271 'RAISE_SETFCAP=no'
264 ] 272 ]
265 self.make_install(install_args) 273 self.make_install(install_args)
266 274
275 self.cleanup_after_install()
276
267 self.fix_rpaths(self.temp_libdir()) 277 self.fix_rpaths(self.temp_libdir())
268 278
269 # Now move the contents of the temporary destdir to their final place. 279 # Now move the contents of the temporary destdir to their final place.
270 # We only care for the contents of LIBDIR. 280 # We only care for the contents of LIBDIR.
271 self.shell_call('cp %s/* %s/ -rdf' % (self.temp_libdir(), 281 self.shell_call('cp %s/* %s/ -rdf' % (self.temp_libdir(),
272 self.dest_libdir())) 282 self.dest_libdir()))
273 283
274 284
275 class Libpci3Builder(InstrumentedPackageBuilder): 285 class Libpci3Builder(InstrumentedPackageBuilder):
276 def package_version(self): 286 def package_version(self):
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 builder = LibcapBuilder(args, clobber) 427 builder = LibcapBuilder(args, clobber)
418 elif args.build_method == 'custom_libpci3': 428 elif args.build_method == 'custom_libpci3':
419 builder = Libpci3Builder(args, clobber) 429 builder = Libpci3Builder(args, clobber)
420 else: 430 else:
421 raise Exception('Unrecognized build method: %s' % args.build_method) 431 raise Exception('Unrecognized build method: %s' % args.build_method)
422 432
423 builder.download_build_install() 433 builder.download_build_install()
424 434
425 if __name__ == '__main__': 435 if __name__ == '__main__':
426 main() 436 main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698