mirror of
https://gitlab.com/ita1024/waf.git
synced 2024-11-22 01:46:15 +01:00
Provide a showcase for print_commands.py and remove some old code
This commit is contained in:
parent
a615bb56c1
commit
8407845787
@ -1,8 +1,6 @@
|
|||||||
#! /usr/bin/env python
|
#! /usr/bin/env python
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
# Thomas Nagy, 2011 (ita)
|
# Thomas Nagy, 2016 (ita)
|
||||||
|
|
||||||
import sys
|
|
||||||
|
|
||||||
def options(opt):
|
def options(opt):
|
||||||
opt.load('compiler_c')
|
opt.load('compiler_c')
|
||||||
@ -11,43 +9,6 @@ def configure(conf):
|
|||||||
conf.load('compiler_c')
|
conf.load('compiler_c')
|
||||||
|
|
||||||
def build(bld):
|
def build(bld):
|
||||||
|
bld.load('print_commands')
|
||||||
bld.program(source='main.c', target='app')
|
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
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user