struct Initializer
{
Initializer() {
- Yosys::log_streams.push_back(&std::cout);
- Yosys::log_error_stderr = true;
- Yosys::yosys_setup();
- Yosys::yosys_banner();
+ if(!Yosys::yosys_already_setup())
+ {
+ Yosys::log_streams.push_back(&std::cout);
+ Yosys::log_error_stderr = true;
+ Yosys::yosys_setup();
+ Yosys::yosys_banner();
+ }
}
Initializer(Initializer const &) {}
# include <sys/sysctl.h>
#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 <errno.h>
IdString::get_reference(empty_id.index_);
#ifdef WITH_PYTHON
+ PyImport_AppendInittab((char*)"libyosys", INIT_MODULE);
Py_Initialize();
PyRun_SimpleString("import sys");
PyRun_SimpleString("sys.path.append(\"./\")");
log_push();
}
+bool yosys_already_setup()
+{
+ return already_setup;
+}
+
bool already_shutdown = false;
void yosys_shutdown()