diff --git a/scripts/mbedtls_framework/c_build_helper.py b/scripts/mbedtls_framework/c_build_helper.py index f2cbbe4af..16845fcba 100644 --- a/scripts/mbedtls_framework/c_build_helper.py +++ b/scripts/mbedtls_framework/c_build_helper.py @@ -11,6 +11,15 @@ 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,