]> sigrok.org Git - sigrok-util.git/blob - cross-compile/mingw/srd_decodersdir.patch
sigrok-cross-mingw: Pass DDK include path to libserialport.
[sigrok-util.git] / cross-compile / mingw / srd_decodersdir.patch
1 diff --git a/srd.c b/srd.c
2 index f5b885f..1599957 100644
3 --- a/srd.c
4 +++ b/srd.c
5 @@ -140,16 +140,32 @@ SRD_API int srd_init(const char *path)
6         /* Add our own module to the list of built-in modules. */
7         PyImport_AppendInittab("sigrokdecode", PyInit_sigrokdecode);
8  
9 +       /*
10 +        * MinGW: Hardcode the frontend's install dir as PYTHONHOME.
11 +        * The NSIS installers will place python*.dll and python*.zip (which
12 +        * contains all required libs and Python modules) there.
13 +        *
14 +        * Also hardcode that only the Python stdlib and the libsigrokdecode
15 +        * PDs in the 'decoders' subdirectory in the frontend's install
16 +        * directory are ever used/found by Python. This avoids various issues
17 +        * with other Python libs and modules installed on the same system.
18 +        */
19 +
20         /* Initialize the Python interpreter. */
21 +       Py_SetPythonHome(L".");
22         Py_Initialize();
23 +       PyRun_SimpleString("import sys; sys.path = ['python32.zip']");
24  
25 +#if 0
26         /* Installed decoders. */
27         if ((ret = srd_decoder_searchpath_add(DECODERS_DIR)) != SRD_OK) {
28                 Py_Finalize();
29                 return ret;
30         }
31 +#endif
32  
33         /* Path specified by the user. */
34 +       path = "decoders";
35         if (path) {
36                 if ((ret = srd_decoder_searchpath_add(path)) != SRD_OK) {
37                         Py_Finalize();