dearimgui / dear_bindings

C header (and language binding metadata) generator for Dear ImGui
MIT License
221 stars 12 forks source link

Allow running dear_bindings.py from anywhere #30

Closed madebr closed 1 year ago

madebr commented 1 year ago

Running the bindings generator failed when running it from another directory: e.g.

python ~/projects/dear_bindings/dear_bindings.py -o cimgui imgui/imgui.h

failed with:

Template file ./src/templates/common-header-template.h could not be found (note that template file names are expected to match source file names, so if you have renamed imgui.h you will need to rename the template as well). The common template file is included regardless of source file name.
Exception during conversion:
Traceback (most recent call last):
  File "/home/maarten/projects/dear_bindings/dear_bindings.py", line 439, in <module>
    convert_header(args.src, args.output, args.templatedir)
  File "/home/maarten/projects/dear_bindings/dear_bindings.py", line 390, in convert_header
    insert_header_templates(file, template_dir, src_file_name_only, ".h", expansions)
  File "/home/maarten/projects/dear_bindings/dear_bindings.py", line 48, in insert_header_templates
    insert_single_template(dest_file,
  File "/home/maarten/projects/dear_bindings/dear_bindings.py", line 36, in insert_single_template
    sys.exit(2)
SystemExit: 2

Giving the template directory a default absolute path fixed this.

ShironekoBen commented 1 year ago

This looks pretty sensible - I'm unfortunately a little snowed under right now so I can't check it immediately, but as soon as I get a chance I'll give it a quick try and then hopefully get it merged. Thanks!

ShironekoBen commented 1 year ago

I finally got a moment to look at this and it all looks good, so I've gone ahead and merged it. Thanks very much for the PR!