pybindings: make errors in Python scripts stop nextpnr execution

Signed-off-by: David Shah <dave@ds0.me>
This commit is contained in:
David Shah 2019-04-17 11:12:58 +01:00
parent ede81dc095
commit 9fa13b5adc
2 changed files with 7 additions and 3 deletions

View File

@ -23,6 +23,7 @@
#include "pybindings.h"
#include "arch_pybindings.h"
#include "jsonparse.h"
#include "log.h"
#include "nextpnr.h"
#include <boost/filesystem.hpp>
@ -267,12 +268,15 @@ void execute_python_file(const char *python_file)
fprintf(stderr, "Fatal error: file not found %s\n", python_file);
exit(1);
}
PyRun_SimpleFile(fp, python_file);
int result = PyRun_SimpleFile(fp, python_file);
fclose(fp);
if (result == -1) {
log_error("Error occurred while executing Python script %s\n", python_file);
}
} catch (boost::python::error_already_set const &) {
// Parse and output the exception
std::string perror_str = parse_python_exception();
std::cout << "Error in Python: " << perror_str << std::endl;
log_error("Error in Python: %s\n", perror_str.c_str());
}
}

View File

@ -22,7 +22,7 @@ ParameterConfig.__new__.__defaults__ = (False, True, 1, None)
Write a design as FASM
ctx: nextpnr context
paramCfg: ParameterConfig describing how to write parameters
paramCfg: map from (celltype, parametername) -> ParameterConfig describing how to write parameters
f: output file
"""
def write_fasm(ctx, paramCfg, f):