Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi file support + Dependency graph ordering #103

Merged
merged 4 commits into from
Oct 19, 2022

Conversation

rooooooooob
Copy link
Collaborator

@rooooooooob rooooooooob commented Oct 5, 2022

For generating larger projects it may be desirable to generate into different files. Now --input can take a directory. If it is given a directory it will read all .cddl files and generate each in its own .rs file for export. Serialization/*Encodings are still all in one file. This resolves #95

Also includes dependency graph ordering that fixes #93 and is essential for multi file support where the cyclic references are across file boundaries. This should also fix #98

For generating larger projects it may be desirable to generate into
different files. Now --input can take a directory. If it is given a
directory it will read all .cddl files and generate each in its own .rs
file for export. Serialization/*Encodings are still all in one file.
cddl doesn't support parsing incomplete cddl strings so will error
on some inputs. This works around it by merging it into 1 file with
scope markers then using those instead to mark scope.
@rooooooooob
Copy link
Collaborator Author

I'll combine the dep graph stuff into this if we can't get this merged before that is completed (likely today, or if not, tomorrow). They're both kind of related anyway, since for large .cddl files like babbage.cddl when we split it up we can't possibly have things ordered properly to avoid the dep graph ordering when things refer to things in other files.

// This approeach was chosen over comments as those were finicky when not attached
// to specific structs, and the existing comment parsing ast was not suited for this.
// If, in the future, cddl released a feature flag to allow partial cddl we can just
// remove all this and revert back the commit before this one for scope handling.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense to me

src/parsing.rs Outdated Show resolved Hide resolved
Fixes #93

This is extra important with multi file support now, as it can be
impossible in some cases to order things properly when the circular
dependencies were across multiple files. Now `babbage.cddl` processes
totally fine even when separated across many files.

This commit also includes some fixes for multi file support with
inter-file dependencies (e.g. fixes for visibility/module use/etc).
@rooooooooob rooooooooob changed the title Multi file support Multi file support + Dependency graph ordering Oct 6, 2022
@SebastienGllmt SebastienGllmt merged commit 8baf996 into master Oct 19, 2022
@SebastienGllmt SebastienGllmt deleted the multi-file-support branch October 19, 2022 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants