@@ -114,8 +114,53 @@ Next, this should be included in the ``.cpp`` file we're adding compatibility me
114114
115115 #include "core/variant/typed_array.h"
116116
117- And finally, the changes reported by the API validation step should be added to a validation file. Because this was
118- done during the development of 4.3, the validation file would be in the ``misc/extension_api_validation/4.2-stable/ `` folder:
117+ Finally, the GDExtension API changes need to be recorded. To do this, first compile Godot on the ``master `` branch, and
118+ then run it with the ``--dump-extension-api `` flag:
119+
120+ .. code-block :: shell
121+
122+ git switch master
123+ scons
124+ godot --dump-extension-api
125+
126+ This will create a file named ``extension_api.json `` in your current directory. Switch to your feature branch, recompile Godot,
127+ and then run it with the ``--validate-extension-api `` flag followed by the path to the ``extension_api.json `` file you just generated:
128+
129+ .. code-block :: shell
130+
131+ git switch my-feature-branch
132+ scons
133+ godot --validate-extension-api /path/to/extension_api.json
134+
135+ This will generate some lines starting with ``Validate extension JSON `` like so:
136+
137+ .. code-block :: text
138+
139+ Validate extension JSON: Error: Field 'classes/AStar2D/methods/get_id_path/arguments': size changed value in new API, from 2 to 3.
140+ Validate extension JSON: Error: Field 'classes/AStar2D/methods/get_point_path/arguments': size changed value in new API, from 2 to 3.
141+ Validate extension JSON: Error: Field 'classes/AStar3D/methods/get_id_path/arguments': size changed value in new API, from 2 to 3.
142+ Validate extension JSON: Error: Field 'classes/AStar3D/methods/get_point_path/arguments': size changed value in new API, from 2 to 3.
143+ Validate extension JSON: Error: Field 'classes/AStarGrid2D/methods/get_id_path/arguments': size changed value in new API, from 2 to 3.
144+ Validate extension JSON: Error: Field 'classes/AStarGrid2D/methods/get_point_path/arguments': size changed value in new API, from 2 to 3.
145+
146+ .. attention ::
147+
148+ If you get a ``Hash changed `` error for a method, it means that the compatibility binding is missing or incorrect.
149+ Such lines shouldn't be added to the validation file, but fixed by binding the proper compatibility method.
150+ Make sure to double-check the following:
151+
152+ - For the compatibility method (the one whose name ends with the PR number), the argument types, names, and default
153+ values must be identical to the version of the method from before your changes.
154+ - In ``_bind_compatibility_methods() ``, argument names provided to the ``D_METHOD() `` macro in ``ClassDB::bind_compatibility_method() ``
155+ must be identical to those from the ``ClassDB::bind_method() `` call for the original method.
156+
157+ Add these lines, followed by a comment explaining what the API change was and the actions taken to prevent breakage,
158+ to a validation file named after the GitHub pull request ID and placed in the folder of the Godot version it would have broken compatibility for.
159+
160+ Since this example was for PR #88047, its file name would be ``GH-88047.txt ``, and because this was done during
161+ the development of 4.3 (thus changing from 4.2), the file would be in the ``misc/extension_api_validation/4.2-stable/ `` folder.
162+
163+ See below for a complete example of such a file for this PR:
119164
120165.. code-block :: text
121166 :caption: misc/extension_api_validation/4.2-stable/GH-88047.txt
@@ -132,10 +177,7 @@ done during the development of 4.3, the validation file would be in the ``misc/e
132177 Added optional "allow_partial_path" argument to get_id_path and get_point_path methods in AStar classes.
133178 Compatibility methods registered.
134179
135- If you get a "Hash changed" error for a method, it means that the compatibility binding is missing or incorrect.
136- Such lines shouldn't be added to the validation file, but fixed by binding the proper compatibility method.
137-
138180 And that's it! You might run into a bit more complicated cases, like rearranging arguments,
139- changing return types, etc., but this covers the basic on how to use this system.
181+ changing return types, etc., but this covers the basics on how to use this system.
140182
141183For more information, see `pull request #76446 <https://github.com/godotengine/godot/pull/76446 >`_.
0 commit comments