Add option for supplying stub dependencies at build time#1336
Open
r-dean wants to merge 1 commit into
Open
Conversation
7b9c321 to
aef1a82
Compare
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.
Add
--depflag for build-time stub generation with module dependenciesCurrently, projects with multiple interdependent extension modules are forced to use
INSTALL_TIMEstub generation (or a hacky workaround), because build-time generation has no mechanism to handle modules that depend on other modules.I generally prefer to keep as much stuff at build time as possible as I find it keeps things more modular and debuggable. For sufficiently complex projects moving everything to install time might be the way to go, but in my usage I've found that I just want to express one or two binding modules that another depends on.
This PR adds a
--dep PATH=NAMEflag to stubgen (and a correspondingMODULE_DEPparameter tonanobind_add_stub()) that loads a dependency module from a file path and registers it under a provided name. This allows build-time stub generation to work correctly for multi-module projects.Example usage
Tests
Includes test modules (
test_dep_base_ext,test_dep_other_ext,test_dep_child_ext) that exercise cross-module inheritance and multiple dependencies withMODULE_DEP. All existing stub tests continue to pass.