Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write build-catalogue (c)make errors to stdout and stderr #1679

Merged
merged 5 commits into from
Oct 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions scripts/build-catalogue.in
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,32 @@ with TemporaryDirectory() as tmp:
if verbose:
out, err = (None, None)
else:
out, err = (sp.DEVNULL, sp.DEVNULL)
sp.run('cmake ..', shell=True, check=True, stdout=out, stderr=err)
sp.run('make', shell=True, check=True, stdout=out, stderr=err)
shutil.copy2(f'{name}-catalogue.so', pwd)
out, err = (sp.PIPE, sp.PIPE)
try:
sp.run('cmake ..', shell=True, check=True, stdout=out, stderr=err)
sp.run('make', shell=True, check=True, stdout=out, stderr=err)
shutil.copy2(f'{name}-catalogue.so', pwd)
except sp.CalledProcessError as e:
import sys, traceback as tb

if not verbose:
# Not in verbose mode, so we have captured the
# `stdout` and `stderr` and can print it to the user.
sys.stdout.write("Build log:\n")
sys.stdout.write(e.stdout.decode())
sys.stderr.write(tb.format_exc() + " Error:\n\n")
sys.stderr.write(e.stderr.decode())
else:
# In verbose mode the outputs weren't captured and
# have been streamed to `stdout` and `stderr` already.
sys.stderr.write(
"Catalogue building error occurred."
+ " Check stdout log for underlying error,"
+ " or omit verbose flag to capture it."
)
sys.stdout.flush()
sys.stderr.flush()
exit(e.returncode)

if not quiet:
print(f'Catalogue has been built and copied to {pwd}/{name}-catalogue.so')