godotengine / godot-cpp

C++ bindings for the Godot script API
MIT License
1.76k stars 580 forks source link

[3.4] Default api.json file shipped in the branch breakes binding_generator.py execution #653

Open Flarkk opened 3 years ago

Flarkk commented 3 years ago

Hi there, I've just switched to 3.4 and wanted to update my godot-cpp build. I'm running scons SConstruct platform=linux generate_bindings=yes use_custom_api_file=yes custom_api_file=godot-headers/extension_api.json bits=64 use_llvm=yes -j8, with extension_api.json being the default json provided along with the 3.4 branch.

I get the following python error :

TypeError: string indices must be integers:
  File "/path/to/godot-cpp/SConstruct", line 467:
    binding_generator.generate_bindings(json_api_file, env['generate_template_get_node'])
  File "/path/to/godot-cpp/binding_generator.py", line 69:
    used_classes = get_used_classes(c)
  File "/path/to/godot-cpp/binding_generator.py", line 807:
    for method in c["methods"]:

Here is the code pointed out by the error (iterating a dictionary indeed gives the key, which is a string, so not supposed to be accessed by index, am I wrong ?): https://github.com/godotengine/godot-cpp/blob/68ce78179f90be9bec8cc88106dba0c244bdc4f6/binding_generator.py#L67-L69

Is it reproduced by you guys ? Any idea to workaround is welcomed ! Alternatively please tell me if I've missed something !

Flarkk commented 3 years ago

Further investigations : I've generated a fresh new api.json from the official stable 3.4 Godot binary. Now the python error has gone. I think the default .json provided along with the godot-cpp 3.4 branch is broken.

But now, I get a bunch of compilation errors related to #include <gdnative/basis.h> directive, which raises fatal error: 'gdnative/basis.h' file not found. I've no gdnative directory anywhere in godot-cpp nor godot-headers codebases, so I wonder what I'm missing here.

Any clue ?

Flarkk commented 3 years ago

Allright, so gdnative directory seems to come from godot source, gdnative module. I'm wondering if such a dependency is intentional ? It seems weird at first sight as it prevents from building godot-cpp without having the full godot source. What do you think ?

Flarkk commented 3 years ago

Final comment, hopefully :

I realize that gdnative is actually provided by godot-headers, but I’ve not pulled the right branch when updating godot-cpp.

I’ll have a try tomorrow and hopefully reduce this issue to the only remaining (minor) problem which is : default api.json is broken

BastiaanOlij commented 3 years ago

Just to rule this out, make sure you are on the right branches and that you pull the submodules. If you've clone godot-cpp from master you're building Godot 4.0 extensions, not Godot 3.x gdnative modules.

Flarkk commented 3 years ago

Allright, everything has compiled after having set the correct branches both for godot-cpp and godot-headers. I'm now renaming this issue so that it focuses on the default json file.