-
Notifications
You must be signed in to change notification settings - Fork 17
refactor: generate schema code in build.rs
#83
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
base: v/2.x.x
Are you sure you want to change the base?
Conversation
e75a175 to
807889d
Compare
build.rs
3d3cbf4 to
4ec87bd
Compare
conditional compilation optional `autoupdate` feature use feature instead of cfg to avoid recompiling everything wip fix include models/spec wip generate models.rs store generated rust in git update autogen feature deps grab specs from online fixes route everything except endpoints now cleanup codegen preserve schema map order cleanup meta.rs final codegen in build.rs cleanup endpoints codegen build and docs tidying document build info for clippy cfgs actually working now, oops cleanup bare urls for rustdoc newtype enum fix rephrase docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request refactors the schema code generation by moving it from JavaScript into Rust via the build script (build.rs). Key changes include integrating code generation logic into the Rust build process, migrating tests into production modules, and updating the Cargo.toml/build configuration to support autogeneration.
Reviewed Changes
Copilot reviewed 59 out of 60 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| riven/src/consts/game_type.rs | Tests now reside inline; removed separate test file for GameType |
| riven/src/consts/game_mode.rs | Removed manual game mode definitions in favor of generated code |
| riven/build/main.rs | New build script handling autogen behavior and config environment vars |
| riven/build/autogen/* | New modules handling schema parsing, enum generation, endpoints, etc. |
| riven/Cargo.toml and README.md | Updated configuration and documentation for the autogen feature |
| .cargo/config.toml | Build configuration now forces compilation of the autogen build script |
Files not reviewed (1)
- autogen_src.bash: Language not supported
Comments suppressed due to low confidence (1)
riven/build/autogen/spec.rs:285
- The error message in this assert statement is unclear; consider rephrasing it to clearly indicate that nested object schemas cannot be converted into a type name.
assert!(properties.is_none(), "Schema for is nested object, cannot turn into type name",);
| } => { | ||
| assert!( | ||
| properties.is_none(), | ||
| "Schema for is nested object, cannot turn into type name", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Schema is for nested object, cannot turn into type name",
|
Maybe even splitting the generated code into a separate crate would be useful. To separate the compilation unit, and to repair our broken semantic versioning |
8e8fcae to
3afa333
Compare
|
Make sure to handle #91 tournament regions |
1ca4567 to
c8a9b13
Compare
Instead of in javascript.
The the
riven_autogencfg option (forrustc) enables the build script. If unset, the build script is not even compiled, which ensures fast builds when Riven is used as a dependency. If set, the build script will be compiled but the actual behavior depends on theRIVEN_AUTOGEN_DEVMODEenvironment variable. If unset or set to"outdir"will generating files toOUT_DIRto be used by Riven (instead of the checked-insrcfiles). If set to"src", the build script will overwrite the files insrcdirectly (this is what./autogen_src.bashdoes). If set to"none", the build script will be built but will not generate any files.The build script will not generally re-run after the initial build, unless the
RIVEN_AUTOGEN_NONCEenvironment variable changes, or something else in the build configuration changes. For example, settingRIVEN_AUTOGEN_NONCEto the current date will trigger an update once a day, assuming the build configuration otherwise doesn't change: