mirror of
https://github.com/YosysHQ/yosys
synced 2025-06-23 22:33:41 +00:00
wheels: fix missing yosys-abc/share directory
* `misc/__init__.py`: * checks if there's a `yosys-abc` in the same directory - if yes, sets the variable `sys._pyosys_abc` * checks if there's a `share` in the same directory - if yes, sets the variable `sys._pyosys_share_dirname` * `yosys.cc::init_share_dirname`: check for `sys._pyosys_share_dirname`, use it at the highest priority if Python is enabled * `yosys.cc::init_abc_executable_name`: check for `sys._pyosys_abc`, use it at at the highest priority if Python is enabled * `Makefile`: add new target, `share`, to only create the extra targets * `setup.py`: compile libyosys.so, yosys-abc and share, and copy them all as part of the pyosys build * `test/arch/ecp5/add_sub.py`: ported `add_sub.ys` to Python to act as a test for the share directory and abc with Python wheels, used in CI
This commit is contained in:
parent
8893dadc4b
commit
3d6b8b8e1a
6 changed files with 105 additions and 23 deletions
|
@ -554,17 +554,17 @@ void yosys_setup()
|
|||
#include "kernel/constids.inc"
|
||||
#undef X
|
||||
|
||||
#ifdef WITH_PYTHON
|
||||
// With Python 3.12, calling PyImport_AppendInittab on an already
|
||||
// initialized platform fails (such as when libyosys is imported
|
||||
// from a Python interpreter)
|
||||
if (!Py_IsInitialized()) {
|
||||
PyImport_AppendInittab((char*)"libyosys", INIT_MODULE);
|
||||
Py_Initialize();
|
||||
PyRun_SimpleString("import sys");
|
||||
signal(SIGINT, SIG_DFL);
|
||||
}
|
||||
#endif
|
||||
#ifdef WITH_PYTHON
|
||||
// With Python 3.12, calling PyImport_AppendInittab on an already
|
||||
// initialized platform fails (such as when libyosys is imported
|
||||
// from a Python interpreter)
|
||||
if (!Py_IsInitialized()) {
|
||||
PyImport_AppendInittab((char*)"libyosys", INIT_MODULE);
|
||||
Py_Initialize();
|
||||
PyRun_SimpleString("import sys");
|
||||
signal(SIGINT, SIG_DFL);
|
||||
}
|
||||
#endif
|
||||
|
||||
Pass::init_register();
|
||||
yosys_design = new RTLIL::Design;
|
||||
|
@ -1013,6 +1013,16 @@ void init_share_dirname()
|
|||
#else
|
||||
void init_share_dirname()
|
||||
{
|
||||
# ifdef WITH_PYTHON
|
||||
PyObject *sys_obj = PyImport_ImportModule("sys");
|
||||
|
||||
if (PyObject_HasAttrString(sys_obj, "_pyosys_share_dirname")) {
|
||||
PyObject *share_path_obj = PyObject_GetAttrString(sys_obj, "_pyosys_share_dirname");
|
||||
const char *share_path = PyUnicode_AsUTF8(share_path_obj);
|
||||
yosys_share_dirname = std::string(share_path);
|
||||
return;
|
||||
}
|
||||
# endif
|
||||
std::string proc_self_path = proc_self_dirname();
|
||||
# if defined(_WIN32) && !defined(YOSYS_WIN32_UNIX_DIR)
|
||||
std::string proc_share_path = proc_self_path + "share\\";
|
||||
|
@ -1058,12 +1068,20 @@ void init_abc_executable_name()
|
|||
}
|
||||
#else
|
||||
yosys_abc_executable = proc_self_dirname() + proc_program_prefix()+ "yosys-abc";
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
#ifndef ABCEXTERNAL
|
||||
# ifdef _WIN32
|
||||
if (!check_file_exists(yosys_abc_executable + ".exe") && check_file_exists(proc_self_dirname() + "..\\" + proc_program_prefix() + "yosys-abc.exe"))
|
||||
yosys_abc_executable = proc_self_dirname() + "..\\" + proc_program_prefix() + "yosys-abc";
|
||||
#endif
|
||||
# endif
|
||||
|
||||
# ifdef WITH_PYTHON
|
||||
PyObject *sys_obj = PyImport_ImportModule("sys");
|
||||
|
||||
if (PyObject_HasAttrString(sys_obj, "_pyosys_abc")) {
|
||||
PyObject *abc_path_obj = PyObject_GetAttrString(sys_obj, "_pyosys_abc");
|
||||
const char *abc_path = PyUnicode_AsUTF8(abc_path_obj);
|
||||
yosys_abc_executable = std::string(abc_path);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1132,7 +1150,7 @@ bool run_frontend(std::string filename, std::string command, RTLIL::Design *desi
|
|||
|
||||
if (command == "auto") {
|
||||
std::string filename_trim = filename;
|
||||
|
||||
|
||||
auto has_extension = [](const std::string& filename, const std::string& extension) {
|
||||
if (filename.size() >= extension.size()) {
|
||||
return filename.compare(filename.size() - extension.size(), extension.size(), extension) == 0;
|
||||
|
@ -1143,7 +1161,7 @@ bool run_frontend(std::string filename, std::string command, RTLIL::Design *desi
|
|||
if (has_extension(filename_trim, ".gz")) {
|
||||
filename_trim.erase(filename_trim.size() - 3);
|
||||
}
|
||||
|
||||
|
||||
if (has_extension(filename_trim, ".v")) {
|
||||
command = " -vlog2k";
|
||||
} else if (has_extension(filename_trim, ".sv")) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue