Provide a showcase for print_commands.py and remove some old code

This commit is contained in:
Thomas Nagy 2016-05-28 16:05:00 +02:00
parent a615bb56c1
commit 8407845787
No known key found for this signature in database
GPG Key ID: 67A565EDFDF90E64
1 changed files with 2 additions and 41 deletions

View File

@ -1,8 +1,6 @@
#! /usr/bin/env python
# encoding: utf-8
# Thomas Nagy, 2011 (ita)
import sys
# Thomas Nagy, 2016 (ita)
def options(opt):
opt.load('compiler_c')
@ -11,43 +9,6 @@ def configure(conf):
conf.load('compiler_c')
def build(bld):
bld.load('print_commands')
bld.program(source='main.c', target='app')
customize_ze_outputs()
def customize_ze_outputs():
# first, display strings, people like them
from waflib import Utils, Logs
from waflib.Context import Context
def exec_command(self, cmd, **kw):
subprocess = Utils.subprocess
kw['shell'] = isinstance(cmd, str)
if isinstance(cmd, str):
Logs.info('%s' % cmd)
else:
Logs.info('%s' % ' '.join(cmd)) # here is the change
Logs.debug('runner_env: kw=%s' % kw)
try:
if self.logger:
self.logger.info(cmd)
kw['stdout'] = kw['stderr'] = subprocess.PIPE
p = subprocess.Popen(cmd, **kw)
(out, err) = p.communicate()
if out:
self.logger.debug('out: %s' % out.decode(sys.stdout.encoding or 'iso8859-1'))
if err:
self.logger.error('err: %s' % err.decode(sys.stdout.encoding or 'iso8859-1'))
return p.returncode
else:
p = subprocess.Popen(cmd, **kw)
return p.wait()
except OSError:
return -1
Context.exec_command = exec_command
# and change the outputs for tasks too
from waflib.Task import Task
def display(self):
return '' # no output on empty strings
Task.__str__ = display