mirror of
https://github.com/Mbed-TLS/mbedtls-framework.git
synced 2026-08-11 13:47:48 +00:00
Capture error message when building C files
Add a new exception `CompileError` to differtiate that the exception raised during the compilation. Signed-off-by: Gabor Mezei <[email protected]>
This commit is contained in:
@@ -11,6 +11,15 @@ import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
class CompileError(Exception):
|
||||
"""Excetion to represent an error during the compilation."""
|
||||
|
||||
def __init__(self, message):
|
||||
"""Save the error massage"""
|
||||
|
||||
super().__init__()
|
||||
self.message = message
|
||||
|
||||
def remove_file_if_exists(filename):
|
||||
"""Remove the specified file, ignoring errors."""
|
||||
if not filename:
|
||||
@@ -107,7 +116,13 @@ def compile_c_file(c_filename, exe_filename, include_dirs):
|
||||
else:
|
||||
cmd += ['-o' + exe_filename]
|
||||
|
||||
subprocess.check_call(cmd + [c_filename])
|
||||
try:
|
||||
subprocess.check_output(cmd + [c_filename],
|
||||
stderr=subprocess.PIPE,
|
||||
universal_newlines=True)
|
||||
|
||||
except subprocess.CalledProcessError as e:
|
||||
raise CompileError(e.stderr) from e
|
||||
|
||||
def get_c_expression_values(
|
||||
cast_to, printf_format,
|
||||
|
||||
Reference in New Issue
Block a user