Mahlet-Inc / hobbits

A multi-platform GUI for bit-based analysis, processing, and visualization
https://mahlet-inc.github.io
MIT License
660 stars 45 forks source link

Relative imports for kaitai structs do not work #168

Open aronwk-aaron opened 11 months ago

aronwk-aaron commented 11 months ago

I'm trying to use relative imports with kaitai, which is a supported doc however, I get file not found in the tmp directory when I try to do this image

Here is the file I am trying to use:

meta:
  id: chat
  file-extension: worldchat
  endian: le
  imports:
  - ../header
seq:
  - id: packet_header
    type: header::data
  - id: chat_channel
    type: u1
    enum: chat_channel
  - id: unkonown2
    type: u2
  - id: message
    type: u4_wstr
enums:
  chat_channel:
    ....

This is the file structure: image

Let me know if there's any other info that I can provide to help resolve this isse

hello-adam commented 10 months ago

this is probably caused by the fact that the hobbits kaitai plugin prepares and compiles ksy data in a separate temporary folder. I think some people have had luck with compiling the dependency types first so that they are cached/available in the built-in Python interpreter (?). Obviously that's not a great solution, so I won't close this. Understanding some of the hackiness in the plugin might help get around limitations (or help you decide when not to try to do something in hobbits).

aronwk-aaron commented 10 months ago

yeah, imports seems to be an overall hacky and unfinished feature of kaitai editor's viewers. the official webIDE doesn't work with relative imports unless they are in the same directory (or you do a little song and dance and shuffle the files around a few times to get them to work) and the vscode plugin (which I think is unsupported at this point) also doesn't work with relative imports.

I didn't see any issues about it on here so I thought I would make one. I'm just trying to find a way to prototype and test locally quickly, which hobbits was my last hope lol I really love the interface and design of it overall. so hopefully this can be fix in the future