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

Unified Diff: lib/naclports/source_package.py

Issue 839083003: Add initial support for color output in the build system (Closed) Base URL: https://chromium.googlesource.com/external/naclports.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « lib/naclports/package.py ('k') | lib/naclports/util.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/naclports/source_package.py
diff --git a/lib/naclports/source_package.py b/lib/naclports/source_package.py
index 5dbbc31178ece9d206619e68fb5fecd6eafd23a0..6c607021e1fdb2afa9c8487bcfe7c7162503fc35 100644
--- a/lib/naclports/source_package.py
+++ b/lib/naclports/source_package.py
@@ -34,13 +34,17 @@ def RedirectStdoutStderr(filename):
return
with open(filename, 'a') as stream:
+ old_stdout = sys.stdout
+ old_stderr = sys.stderr
sys.stdout = stream
sys.stderr = stream
+ util.CheckStdoutForColorSupport()
try:
yield
finally:
- sys.stdout = sys.__stdout__
- sys.stderr = sys.__stdout__
+ sys.stdout = old_stdout
+ sys.stderr = old_stderr
+ util.CheckStdoutForColorSupport()
def FormatTimeDelta(delta):
@@ -233,7 +237,7 @@ class SourcePackage(package.Package):
self.CheckInstallable()
if force is None and self.IsInstalled():
- Log('Already installed %s' % self.InfoString())
+ self.LogStatus('Already installed')
return
if build_deps:
@@ -254,7 +258,7 @@ class SourcePackage(package.Package):
self.Build(build_deps, force)
if self.IsAnyVersionInstalled():
- Log('Uninstalling existing %s' % self.InfoString())
+ self.LogStatus('Uninstalling existing')
self.GetInstalledPackage().DoUninstall()
binary_package.BinaryPackage(package_file).Install()
@@ -269,17 +273,13 @@ class SourcePackage(package.Package):
self.InstallDeps(force)
if not force and self.IsBuilt():
- Log('Already built %s' % self.InfoString())
+ self.LogStatus('Already built')
return
log_root = os.path.join(paths.OUT_DIR, 'logs')
util.Makedirs(log_root)
- if util.verbose:
- prefix = '*** '
- else:
- prefix = ''
- Log('%sBuilding %s' % (prefix, self.InfoString()))
+ self.LogStatus('Building')
if util.verbose:
log_filename = None
@@ -303,7 +303,7 @@ class SourcePackage(package.Package):
util.verbose = old_verbose
duration = FormatTimeDelta(time.time() - start)
- Log('Build complete %s [took %s]' % (self.InfoString(), duration))
+ util.LogHeading('Build complete', ' [took %s]' % duration)
def RunBuildSh(self):
build_port = os.path.join(paths.TOOLS_DIR, 'build_port.sh')
@@ -381,7 +381,7 @@ class SourcePackage(package.Package):
raise Error("Upstream archive or patch has changed.\n" +
"Please remove existing checkout and try again: '%s'" % dest)
- self.Banner('Extracting')
+ util.LogHeading('Extracting')
util.Makedirs(paths.OUT_DIR)
tmp_output_path = tempfile.mkdtemp(dir=paths.OUT_DIR)
try:
@@ -410,11 +410,6 @@ class SourcePackage(package.Package):
def Log(self, message):
Log('%s: %s' % (message, self.InfoString()))
- def Banner(self, message):
- Log("#####################################################################")
- self.Log(message)
- Log("#####################################################################")
-
def GetStampDir(self):
return os.path.join(paths.STAMP_DIR, self.NAME)
@@ -435,7 +430,7 @@ class SourcePackage(package.Package):
self.RunCmd(cmd)
return
- self.Banner('Patching')
+ util.LogHeading('Patching')
Log('Init git repo: %s' % src_dir)
try:
InitGitRepo(src_dir)
@@ -571,7 +566,7 @@ class SourcePackage(package.Package):
raise Error('Upstream archive or patch has changed.\n' +
"Please remove existing checkout and try again: '%s'" % dest)
- self.Banner('Cloning')
+ util.LogHeading('Cloning')
# Ensure local mirror is up-to-date
git_mirror, git_commit = self.GitCloneToMirror()
# Clone from the local mirror.
« no previous file with comments | « lib/naclports/package.py ('k') | lib/naclports/util.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698