mirror of
ssh://git.janware.com/janware/proj/jw-pkg
synced 2026-04-25 17:45:55 +02:00
jw.pkg.cmds.projects.CmdBuild: Use run_cmd("make")
Use run_cmd() for centralized process handling, instead of hand-rolled Popen(). Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
0cb6a7972c
commit
838b745581
1 changed files with 20 additions and 22 deletions
|
|
@ -4,6 +4,7 @@ import os, re, sys, subprocess, datetime, time
|
||||||
from argparse import Namespace, ArgumentParser
|
from argparse import Namespace, ArgumentParser
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
|
|
||||||
|
from ...lib.util import run_cmd
|
||||||
from ...lib.log import *
|
from ...lib.log import *
|
||||||
from ..Cmd import Cmd
|
from ..Cmd import Cmd
|
||||||
from ..CmdProjects import CmdProjects
|
from ..CmdProjects import CmdProjects
|
||||||
|
|
@ -84,32 +85,29 @@ class CmdBuild(Cmd): # export
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
async def run_make(module, target, cur_project, num_projects):
|
async def run_make(module, target, cur_project, num_projects):
|
||||||
#make_cmd = "make " + target + " 2>&1"
|
|
||||||
make_cmd = [ "make", target ]
|
make_cmd = [ "make", target ]
|
||||||
path = self.app.find_dir(module, pretty=False)
|
wd = self.app.find_dir(module, pretty=False)
|
||||||
delim_len = 120
|
title = '---- [%d/%d]: Running "%s" in %s -' % (cur_project, num_projects, ' '.join(make_cmd), wd)
|
||||||
delim = '---- [%d/%d]: running %s in %s -' % (cur_project, num_projects, make_cmd, path)
|
|
||||||
delim = delim + '-' * (delim_len - len(delim))
|
|
||||||
|
|
||||||
print(',' + delim + ' >')
|
|
||||||
|
|
||||||
patt = self.app.is_excluded_from_build(module)
|
patt = self.app.is_excluded_from_build(module)
|
||||||
if patt is not None:
|
if patt is not None:
|
||||||
|
print(',' + title + ' >')
|
||||||
print('| Configured to skip build on platform >' + patt + '<')
|
print('| Configured to skip build on platform >' + patt + '<')
|
||||||
print('`' + delim + ' <')
|
print('`' + title + ' <')
|
||||||
return
|
return
|
||||||
|
|
||||||
os.chdir(path)
|
try:
|
||||||
p = subprocess.Popen(make_cmd, shell=False, stdout=subprocess.PIPE, stderr=None, close_fds=True)
|
stdout, stderr = await run_cmd(
|
||||||
for line in iter(p.stdout.readline, b''):
|
*make_cmd,
|
||||||
line = line.decode(sys.stdout.encoding)
|
wd=wd,
|
||||||
sys.stdout.write('| ' + line) # avoid extra newlines from print()
|
throw=True,
|
||||||
sys.stdout.flush()
|
verbose=True,
|
||||||
p.wait()
|
cmd_input=None,
|
||||||
print('`' + delim + ' <')
|
env=None,
|
||||||
if p.returncode:
|
title=title
|
||||||
print(' '.join(make_cmd) + ' failed')
|
)
|
||||||
raise Exception(time.strftime("%Y-%m-%d %H:%M") + ": failed to make target " + target + " in module " + module + " below base " + self.app.projs_root)
|
except Exception as e:
|
||||||
|
raise RuntimeError(f'Failed to make target "{target}" in module "{module}" below base {self.app.projs_root}: {str(e)}')
|
||||||
|
|
||||||
async def run_make_on_modules(modules, order, target):
|
async def run_make_on_modules(modules, order, target):
|
||||||
cur_project = 0
|
cur_project = 0
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue