pybindings: make errors in Python scripts stop nextpnr execution
Signed-off-by: David Shah <dave@ds0.me>
This commit is contained in:
parent
ede81dc095
commit
9fa13b5adc
@ -23,6 +23,7 @@
|
|||||||
#include "pybindings.h"
|
#include "pybindings.h"
|
||||||
#include "arch_pybindings.h"
|
#include "arch_pybindings.h"
|
||||||
#include "jsonparse.h"
|
#include "jsonparse.h"
|
||||||
|
#include "log.h"
|
||||||
#include "nextpnr.h"
|
#include "nextpnr.h"
|
||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
#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);
|
fprintf(stderr, "Fatal error: file not found %s\n", python_file);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
PyRun_SimpleFile(fp, python_file);
|
int result = PyRun_SimpleFile(fp, python_file);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
if (result == -1) {
|
||||||
|
log_error("Error occurred while executing Python script %s\n", python_file);
|
||||||
|
}
|
||||||
} catch (boost::python::error_already_set const &) {
|
} catch (boost::python::error_already_set const &) {
|
||||||
// Parse and output the exception
|
// Parse and output the exception
|
||||||
std::string perror_str = parse_python_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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ ParameterConfig.__new__.__defaults__ = (False, True, 1, None)
|
|||||||
Write a design as FASM
|
Write a design as FASM
|
||||||
|
|
||||||
ctx: nextpnr context
|
ctx: nextpnr context
|
||||||
paramCfg: ParameterConfig describing how to write parameters
|
paramCfg: map from (celltype, parametername) -> ParameterConfig describing how to write parameters
|
||||||
f: output file
|
f: output file
|
||||||
"""
|
"""
|
||||||
def write_fasm(ctx, paramCfg, f):
|
def write_fasm(ctx, paramCfg, f):
|
||||||
|
Loading…
Reference in New Issue
Block a user