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

Unified Diff: third_party/instrumented_libraries/scripts/download_build_install.py

Issue 2735013004: Instrumented libraries: improve parallel build (Closed)
Patch Set: open('...', 'w') Created 3 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 side-by-side diff with in-line comments
Download patch
Index: third_party/instrumented_libraries/scripts/download_build_install.py
diff --git a/third_party/instrumented_libraries/scripts/download_build_install.py b/third_party/instrumented_libraries/scripts/download_build_install.py
index 68511a507ab966954423fec22634430bc335d8da..3b9722b48c83b2327ec42870ad7ffbe319453699 100755
--- a/third_party/instrumented_libraries/scripts/download_build_install.py
+++ b/third_party/instrumented_libraries/scripts/download_build_install.py
@@ -7,6 +7,7 @@
import argparse
import ast
+import fcntl
import os
import platform
import re
@@ -49,7 +50,6 @@ class InstrumentedPackageBuilder(object):
self._cc = args.cc
self._cxx = args.cxx
self._extra_configure_flags = unescape_flags(args.extra_configure_flags)
- self._jobs = args.jobs
self._libdir = args.libdir
self._package = args.package
self._patch = real_path(args.patch) if args.patch else None
@@ -98,7 +98,7 @@ class InstrumentedPackageBuilder(object):
# libappindicator1 needs this.
self._build_env['CSC'] = '/usr/bin/mono-csc'
- def shell_call(self, command, env=None, cwd=None):
+ def shell_call(self, command, env=None, cwd=None, ignore_ret_code=False):
"""Wrapper around subprocess.Popen().
Calls command with specific environment and verbosity using
@@ -108,6 +108,10 @@ class InstrumentedPackageBuilder(object):
command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
env=env, shell=True, cwd=cwd)
stdout, stderr = child.communicate()
+ if ignore_ret_code:
+ if self._verbose:
+ print stdout
+ return
if self._verbose or child.returncode:
print stdout
if child.returncode:
@@ -123,8 +127,14 @@ class InstrumentedPackageBuilder(object):
if get_fresh_source:
shutil.rmtree(self._working_dir, ignore_errors=True)
os.makedirs(self._working_dir)
+
+ # Download one source package at a time, otherwise, there will
+ # be connection errors in gnutls_handshake().
+ lock = open('apt-source-lock', 'w')
+ fcntl.flock(lock, fcntl.LOCK_EX)
self.shell_call('apt-get source %s' % self._package,
cwd=self._working_dir)
+ fcntl.flock(lock, fcntl.LOCK_UN)
(dirpath, dirnames, filenames) = os.walk(self._working_dir).next()
@@ -215,20 +225,19 @@ class InstrumentedPackageBuilder(object):
# .pc files are not needed.
self.shell_call('rm %s/pkgconfig -rf' % self.temp_libdir())
- def make(self, args, jobs=None, env=None, cwd=None):
+ def make(self, args, env=None, cwd=None, ignore_ret_code=False):
"""Invokes `make'.
Invokes `make' with the specified args, using self._build_env and
self._source_dir by default.
"""
- if jobs is None:
- jobs = self._jobs
if cwd is None:
cwd = self._source_dir
if env is None:
env = self._build_env
- cmd = ['make', '-j%s' % jobs] + args
- self.shell_call(' '.join(cmd), env=env, cwd=cwd)
+ cmd = ['make'] + args
+ self.shell_call(' '.join(cmd), env=env, cwd=cwd,
+ ignore_ret_code=ignore_ret_code)
def make_install(self, args, **kwargs):
"""Invokes `make install'."""
@@ -238,7 +247,7 @@ class InstrumentedPackageBuilder(object):
"""Builds and installs the DSOs.
Builds the package with ./configure + make, installs it to a temporary
- location, then moves the relevant files to their permanent location.
+ location, then moves the relevant files to their permanent location.
"""
configure_cmd = './configure --libdir=/%s/ %s' % (
self._libdir, self._extra_configure_flags)
@@ -249,8 +258,7 @@ class InstrumentedPackageBuilder(object):
make_args = ['%s=%s' % (name, self.temp_dir()) for name in args]
self.make(make_args)
- # Some packages don't support parallel install. Use -j1 always.
- self.make_install(make_args, jobs=1)
+ self.make_install(make_args)
self.cleanup_after_install()
@@ -371,14 +379,9 @@ class NSSBuilder(InstrumentedPackageBuilder):
temp_dir = os.path.join(self._source_dir, 'nss')
temp_libdir = os.path.join(temp_dir, 'lib')
- # Parallel build is not supported. Also, the build happens in
- # <source_dir>/nss.
- try:
- self.make(make_args, jobs=1, cwd=temp_dir)
- except Exception:
- # Building fails after all the required DSOs have been built, so ignore
- # the error.
- pass
+ # The build happens in <source_dir>/nss. Building fails after all
+ # the required DSOs have been built, so ignore the error.
+ self.make(make_args, cwd=temp_dir, ignore_ret_code=True)
self.fix_rpaths(temp_libdir)
@@ -395,6 +398,7 @@ class NSSBuilder(InstrumentedPackageBuilder):
class StubBuilder(InstrumentedPackageBuilder):
def download_build_install(self):
self._touch(os.path.join(self._destdir, '%s.txt' % self._package))
+ self.shell_call('mkdir -p %s' % self.dest_libdir())
self._touch(os.path.join(self.dest_libdir(), '%s.so.0' % self._package))
def _touch(self, path):
@@ -406,7 +410,6 @@ def main():
parser = argparse.ArgumentParser(
description='Download, build and install an instrumented package.')
- parser.add_argument('-j', '--jobs', type=int, default=1)
parser.add_argument('-p', '--package', required=True)
parser.add_argument(
'-i', '--product-dir', default='.',

Powered by Google App Engine
This is Rietveld 408576698