kaitai-io / kaitai_struct_visualizer

Kaitai Struct: visualizer and hex viewer tool
https://rubygems.org/gems/kaitai-struct-visualizer
GNU General Public License v3.0
284 stars 25 forks source link

Allow "ksv" to use pre-compiled Ruby-files instead of compiling itself. #26

Closed ams-tschoening closed 5 years ago

ams-tschoening commented 5 years ago

If one runs into problems with the compiled KSY and things break because bugs/missing implementation in the compiler most likely, sometimes it's easier to change formerly generated Ruby to test which changes lead to successful Ruby and afterwards change the compiler accordingly. With the former behaviour of "ksv" compiling always using temporary directories, this was pretty much impossible to achieve and one needed to change the compiler always to generate new code. But for people new to Scala and Ruby (like me) this is a pretty difficult roundtrip.

So "ksv" has been enhanced so that some pre-compiled Ruby file can be given instead of some KSY and "ksv" doesn't compile in that case anymore. Instead, by convention all Ruby files in the parent dir of the given file are required and the given file name is used as main class. Both approaches are pretty much what "ksv" implemented currently anyway.

This helped me debugging https://github.com/kaitai-io/kaitai_struct/issues/552.

ams-tschoening commented 5 years ago

I had different implementations in mind, like providing an additional option --pre-compiled taking a path or a boolean, but reusing the already available paths for KSY-files and deciding based on their extension seems the easier approach to me. It's like switching between if compilation is necessary by ksv or not pretty much transparently.

GreyCat commented 5 years ago

Makes sense, thanks for sharing this!