]> sigrok.org Git - sigrok-util.git/commitdiff
sigrok-fwextract-kingst-la2016: concentrate RCC flags in one spot master github/master
authorGerhard Sittig <redacted>
Sun, 29 Jan 2023 07:38:04 +0000 (08:38 +0100)
committerGerhard Sittig <redacted>
Sun, 29 Jan 2023 08:06:15 +0000 (09:06 +0100)
Move the symbolic identifiers for RCC flag bits to one common location
in the Qt resource handling support code. Previous versions kept them
local to individual methods which referenced them.

cross-compile/mingw/mxe_fixes.patch
firmware/kingst-la/sigrok-fwextract-kingst-la2016
source/drv-protocol.c

index 72a4dd00219623c32079aa6d30df580e37307c3d..b62d5137e54e0972be3abc562992dc21e9dad59c 100644 (file)
@@ -1,3 +1,12 @@
+Implementor's note: These patches currently (2022-11) don't apply to
+recent MXE, their context has changed. The patches' motivation might
+have become obsolete, too. This needs reconsideration. When in doubt,
+attempt to build with an MXE toolchain which omits these "MXE fixes"
+(which actually are downgrades of tools and libraries, while mainline
+MXE has upgraded and could have fixed previous issues). Older notes
+from a previous implementation follow below.
+
+
 These patches are currently required to get a properly working
 MXE setup for sigrok usage.
 
@@ -15,6 +24,9 @@ MXE setup for sigrok usage.
 
 See the other file for a libusb discussion.
 
+
+Change from binutils 2.28 to 2.35.
+
 diff --git a/src/binutils-1-fixes.patch b/src/binutils-1-fixes.patch
 deleted file mode 100644
 index 357428fe..00000000
@@ -168,6 +180,7 @@ index 357428fe..00000000
 - 
 -   if (pe_def_file->version_major != -1)
 -     {
+
 diff --git a/src/binutils.mk b/src/binutils.mk
 index 9721b581..8eab8bf3 100644
 --- a/src/binutils.mk
@@ -183,6 +196,10 @@ index 9721b581..8eab8bf3 100644
  $(PKG)_SUBDIR   := binutils-$($(PKG)_VERSION)
  $(PKG)_FILE     := binutils-$($(PKG)_VERSION).tar.bz2
  $(PKG)_URL      := https://ftp.gnu.org/gnu/binutils/$($(PKG)_FILE)
+
+
+Provide glib fixing patches. As well as downgrade to 2.44.1.
+
 diff --git a/src/glib-1-fixes.patch b/src/glib-1-fixes.patch
 index 764ece9e..428cc6a9 100644
 --- a/src/glib-1-fixes.patch
@@ -494,6 +511,7 @@ index 764ece9e..428cc6a9 100644
 -         {
 -           g_set_error (error,
 -                        G_IO_ERROR,
+
 diff --git a/src/glib-2-format.patch b/src/glib-2-format.patch
 new file mode 100644
 index 00000000..3d594af0
@@ -577,6 +595,7 @@ index 00000000..3d594af0
 +   glib_gpi_cast='(gint64)'
 +   glib_gpui_cast='(guint64)'
 +   ;;
+
 diff --git a/src/glib.mk b/src/glib.mk
 index 825b86bb..499a45b8 100644
 --- a/src/glib.mk
@@ -598,7 +617,7 @@ index 825b86bb..499a45b8 100644
      cd '$(BUILD_DIR)' && '$(SOURCE_DIR)/configure' \
          $(MXE_CONFIGURE_OPTS) \
          --enable-regex \
-+      --disable-compile-warnings \
++        --disable-compile-warnings \
          --disable-threads \
          --disable-selinux \
          --disable-inotify \
@@ -606,7 +625,7 @@ index 825b86bb..499a45b8 100644
      cd '$(SOURCE_DIR)' && NOCONFIGURE=true ./autogen.sh
      cd '$(BUILD_DIR)' && '$(SOURCE_DIR)/configure' \
          $(MXE_CONFIGURE_OPTS) \
-+      --disable-compile-warnings \
++        --disable-compile-warnings \
          --enable-regex \
          --disable-threads \
          --disable-selinux \
@@ -614,7 +633,7 @@ index 825b86bb..499a45b8 100644
      cd '$(SOURCE_DIR)' && NOCONFIGURE=true ./autogen.sh
      cd '$(BUILD_DIR)' && '$(SOURCE_DIR)/configure' \
          $(MXE_CONFIGURE_OPTS) \
-+      --disable-compile-warnings \
++        --disable-compile-warnings \
          --with-threads=win32 \
          --with-pcre=system \
          --with-libiconv=gnu \
index 3575b04928a7989523ac69da288aa8e543cae7a2..d69071903c25c92bc2c911d49ffccc1d29fd51c8 100755 (executable)
@@ -39,6 +39,9 @@ parseelf = importlib.util.module_from_spec(spec)
 spec.loader.exec_module(parseelf)
 
 class qt_resources(object):
+    RCCFileInfo_Compressed = 0x01
+    RCCFileInfo_Directory = 0x02
+
     def __init__(self, program):
         self._elf = parseelf.elf(program)
         self._elf_sections = {} # idx -> data
@@ -75,7 +78,6 @@ class qt_resources(object):
         return self._res_datas[offset:offset + length]
 
     def _read_resources(self):
-        RCCFileInfo_Directory = 0x02
         def read_table():
             table = []
             offset = 0
@@ -83,7 +85,7 @@ class qt_resources(object):
                 name_offset, flags = struct.unpack(">IH", self._res_struct[offset:offset+4+2])
                 offset += 6
                 name = self._get_resource_name(name_offset)
-                if flags & RCCFileInfo_Directory:
+                if flags & self.RCCFileInfo_Directory:
                     child_count, first_child_offset = struct.unpack(">II", self._res_struct[offset:offset + 4 + 4])
                     offset += 4 + 4
                     table.append((name, flags, child_count, first_child_offset))
@@ -94,29 +96,35 @@ class qt_resources(object):
             return table
         def read_dir_entries(table, which, parents=[]):
             name, flags = which[:2]
-            if not flags & RCCFileInfo_Directory:
+            if not flags & self.RCCFileInfo_Directory:
                 raise Exception("not a directory!")
             child_count, first_child = which[2:]
             for i in range(child_count):
                 child = table[first_child + i]
-                if child[1] & RCCFileInfo_Directory:
+                flags = child[1]
+                if flags & self.RCCFileInfo_Directory:
                     read_dir_entries(table, child, parents + [child[0]])
                 else:
                     country, language, data_offset = child[2:]
                     full_name = "/".join(parents + [child[0]])
                     self._resources[full_name] = data_offset
+                    self._resource_flags[full_name] = flags
 
         self._res_datas = self._get_elf_sym_value("_ZL16qt_resource_data")
         self._res_names = self._get_elf_sym_value("_ZL16qt_resource_name")
         self._res_struct = self._get_elf_sym_value("_ZL18qt_resource_struct")
 
         self._resources = {} # res_fn -> res_offset
+        self._resource_flags = {} # res_fn -> RCC_flags
         table = read_table()
         read_dir_entries(table, table[0])
 
     def get_resource(self, res_fn):
         offset = self._resources[res_fn]
+        flags = self._resource_flags[res_fn]
         data = self._get_resource_data(offset)
+        if flags & self.RCCFileInfo_Compressed:
+            data = zlib.decompress(data[4:])
         return data
 
     def find_resource_names(self, res_fn_re):
index 1b300bbeb87331cd9931cea6a4de57610cea71a8..b331b6baa699f97744bbfaa0a28f1e366ab1ffea 100644 (file)
@@ -27,10 +27,12 @@ SR_PRIV int {lib}_receive_data(int fd, int revents, void *cb_data)
 
        (void)fd;
 
-       if (!(sdi = cb_data))
+       sdi = cb_data;
+       if (!sdi)
                return TRUE;
 
-       if (!(devc = sdi->priv))
+       devc = sdi->priv;
+       if (!devc)
                return TRUE;
 
        if (revents == G_IO_IN) {{