2
0
mirror of https://gitlab.com/ita1024/waf.git synced 2024-12-25 02:35:04 +01:00
waf/playground/display/wscript
2015-09-28 21:44:50 +02:00

54 lines
1.3 KiB
Python

#! /usr/bin/env python
# encoding: utf-8
# Thomas Nagy, 2011 (ita)
import sys
def options(opt):
opt.load('compiler_c')
def configure(conf):
conf.load('compiler_c')
def build(bld):
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