mirror of https://github.com/YosysHQ/yosys.git
Fixed issue when using a python plugin in the yosys shell
This commit is contained in:
parent
d79a2808cf
commit
5864db3c2b
|
@ -2783,10 +2783,13 @@ namespace YOSYS_PYTHON {
|
||||||
struct Initializer
|
struct Initializer
|
||||||
{
|
{
|
||||||
Initializer() {
|
Initializer() {
|
||||||
Yosys::log_streams.push_back(&std::cout);
|
if(!Yosys::yosys_already_setup())
|
||||||
Yosys::log_error_stderr = true;
|
{
|
||||||
Yosys::yosys_setup();
|
Yosys::log_streams.push_back(&std::cout);
|
||||||
Yosys::yosys_banner();
|
Yosys::log_error_stderr = true;
|
||||||
|
Yosys::yosys_setup();
|
||||||
|
Yosys::yosys_banner();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Initializer(Initializer const &) {}
|
Initializer(Initializer const &) {}
|
||||||
|
|
|
@ -55,6 +55,16 @@
|
||||||
# include <sys/sysctl.h>
|
# include <sys/sysctl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef WITH_PYTHON
|
||||||
|
#if PY_MAJOR_VERSION >= 3
|
||||||
|
# define INIT_MODULE PyInit_libyosys
|
||||||
|
extern "C" PyObject* INIT_MODULE();
|
||||||
|
#else
|
||||||
|
# define INIT_MODULE initlibyosys
|
||||||
|
extern "C" void INIT_MODULE();
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
@ -482,6 +492,7 @@ void yosys_setup()
|
||||||
IdString::get_reference(empty_id.index_);
|
IdString::get_reference(empty_id.index_);
|
||||||
|
|
||||||
#ifdef WITH_PYTHON
|
#ifdef WITH_PYTHON
|
||||||
|
PyImport_AppendInittab((char*)"libyosys", INIT_MODULE);
|
||||||
Py_Initialize();
|
Py_Initialize();
|
||||||
PyRun_SimpleString("import sys");
|
PyRun_SimpleString("import sys");
|
||||||
PyRun_SimpleString("sys.path.append(\"./\")");
|
PyRun_SimpleString("sys.path.append(\"./\")");
|
||||||
|
@ -496,6 +507,11 @@ void yosys_setup()
|
||||||
log_push();
|
log_push();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool yosys_already_setup()
|
||||||
|
{
|
||||||
|
return already_setup;
|
||||||
|
}
|
||||||
|
|
||||||
bool already_shutdown = false;
|
bool already_shutdown = false;
|
||||||
|
|
||||||
void yosys_shutdown()
|
void yosys_shutdown()
|
||||||
|
|
|
@ -278,6 +278,11 @@ namespace hashlib {
|
||||||
}
|
}
|
||||||
|
|
||||||
void yosys_setup();
|
void yosys_setup();
|
||||||
|
|
||||||
|
#ifdef WITH_PYTHON
|
||||||
|
bool yosys_already_setup();
|
||||||
|
#endif
|
||||||
|
|
||||||
void yosys_shutdown();
|
void yosys_shutdown();
|
||||||
|
|
||||||
#ifdef YOSYS_ENABLE_TCL
|
#ifdef YOSYS_ENABLE_TCL
|
||||||
|
|
Loading…
Reference in New Issue