Skip to content

Conversation

@MingweiSamuel
Copy link
Owner

@MingweiSamuel MingweiSamuel commented Mar 7, 2025

Instead of in javascript.

The the riven_autogen cfg option (for rustc) 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 the RIVEN_AUTOGEN_DEVMODE environment variable. If unset or set to "outdir" will generating files to OUT_DIR to be used by Riven (instead of the checked-in src files). If set to "src", the build script will overwrite the files in src directly (this is what ./autogen_src.bash does). 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_NONCE environment variable changes, or something else in the build configuration changes. For example, setting RIVEN_AUTOGEN_NONCE to the current date will trigger an update once a day, assuming the build configuration otherwise doesn't change:

RUSTFLAGS="--cfg riven_autogen" RIVEN_AUTOGEN_NONCE="$(date +%Y-%m-%d)" cargo build

@MingweiSamuel MingweiSamuel changed the title refactor: generate schema code in build.rs refactor: generate schema code in build.rs (wip) Mar 7, 2025
@MingweiSamuel MingweiSamuel changed the title refactor: generate schema code in build.rs (wip) refactor: generate schema code in Rust instead of JS (wip) Mar 12, 2025
@MingweiSamuel MingweiSamuel force-pushed the buildrs branch 3 times, most recently from e75a175 to 807889d Compare March 17, 2025 01:04
@MingweiSamuel MingweiSamuel changed the title refactor: generate schema code in Rust instead of JS (wip) refactor: generate schema code in build.rs Mar 18, 2025
@MingweiSamuel MingweiSamuel marked this pull request as ready for review March 18, 2025 01:47
@MingweiSamuel MingweiSamuel force-pushed the buildrs branch 3 times, most recently from 3d3cbf4 to 4ec87bd Compare March 19, 2025 23:31
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
@MingweiSamuel MingweiSamuel requested a review from Copilot March 27, 2025 23:08
Copy link

Copilot AI left a 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",
Copy link
Owner Author

@MingweiSamuel MingweiSamuel Mar 27, 2025

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",

@MingweiSamuel MingweiSamuel mentioned this pull request Apr 11, 2025
6 tasks
@MingweiSamuel
Copy link
Owner Author

MingweiSamuel commented Apr 11, 2025

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

@MingweiSamuel MingweiSamuel force-pushed the v/2.x.x branch 2 times, most recently from 8e8fcae to 3afa333 Compare April 24, 2025 23:55
@MingweiSamuel
Copy link
Owner Author

Make sure to handle #91 tournament regions

@MingweiSamuel
Copy link
Owner Author

a673505
e636017

changes need to be included

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants