Generate Godot send() kwarg map from Python on release#774
Open
bwhitman wants to merge 1 commit into
Open
Conversation
The send() kwarg-to-wire map was hand-duplicated in three places: amy/__init__.py _KW_MAP_LIST (the source of truth), godot/amy.gd, and a verbatim copy embedded in setup_godot.sh. The Godot copies had silently drifted ~20 entries behind Python (missing bus, patch_string, the synth sub-params, the sample/midi/cv params and the eg0/eg1 aliases) and carried a wrong type for volume. Generate the Godot map from the Python source the same way gen_amy_js_api.py does for the browser build: scripts/gen_amy_gd_api.py rewrites the BEGIN/END GENERATED region of godot/amy.gd from _KW_MAP_LIST (make godot-api), reusing the JS generator parser. release.yml runs it and folds godot/amy.gd into the tagged bump commit, so the released addon (built from godot/ at the tag) always matches. c-cpp.yml fails any PR where the map drifts or the GDScript stops parsing (gdparse). Also sort message() keys by _KW_PRIORITY like Python and JS so patch_string is emitted last (required now that it is in the map), and stop embedding a second amy.gd in setup_godot.sh -- it now copies godot/amy.gd, which also fixes a separate drift where the embedded copy lacked the web-configure block. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
send()kwarg → wire-code map was hand-duplicated in three places that had to be kept in sync manually:amy/__init__.py_KW_MAP_LIST— the source of truthgodot/amy.gd_KW_MAPsetup_godot.shThe Godot copies had silently drifted ~20 entries behind Python — missing
bus(the reported gap), pluspatch_string, thesynthsub-params (pedal,synth_flags,oscs_per_voice,to_synth,grab_midi_notes,note_source,synth_delay), the sample params,midi_cc/midi_note_cmd/cv_trigger,sequencer_run, and theeg0/eg1aliases — and carried a wrong type forvolume(Finstead ofL).JS doesn't have this problem:
scripts/gen_amy_js_api.pyalready generates it from_KW_MAP_LIST, and #773 now rebuilds it on release.Fix
Make Godot generated from the Python source, the same way JS is:
scripts/gen_amy_gd_api.py(new) rewrites the# BEGIN/END GENERATEDregion ofgodot/amy.gdfrom_KW_MAP_LIST, reusing the JS generator's parser so the two bindings can't disagree. Run viamake godot-api.release.ymlrunsmake godot-apinext to the web rebuild and foldsgodot/amy.gdinto the tagged bump commit — so the released addon (built fromgodot/at the tag) always matches the Python API.c-cpp.ymlgains agodot-apijob that fails any PR wheregodot/amy.gddrifts from_KW_MAP_LIST, and validates the generated GDScript withgdparse(the addon build never parsesamy.gd, so nothing else would catch a syntax error).Also in here
message()now sorts keys by_KW_PRIORITYlike Python/JS, sopatch_stringis emitted last — required now that it's in the map, since it consumes to the end of the message.setup_godot.sh: it nowcpsgodot/amy.gdinstead of embedding a copy. That third copy had drifted even further (also missingamy.gd's web-configure block), so this removes ~300 lines and a whole class of drift.Verification
make godot-apiis idempotent;godot/amy.gdnow has all 63 params, withbuspresent andvolumecorrected to["V", "L"].gdparse godot/amy.gdpasses (the lambda + typed loops are valid Godot 4 GDScript).bash -n setup_godot.shand YAML validation of both workflows pass.Follows #773 (already merged) — both regenerate artifacts into the release bump commit.
🤖 Generated with Claude Code