mirror of
https://github.com/clockworklabs/SpacetimeDB.git
synced 2026-03-20 09:01:05 +08:00
# Description of Changes Updated the codegen table/function iteration functions to take in a parameter to check visibility in all locations for the supported languages. - Updated the util.rs functions for iterating tables/functions to check for a CodegenVisibility enum (IncludePrivate, or OnlyPublic) - Added a new CodegenOptions struct to pass around the CodegenVisibility and future flags, defaulted visibility to OnlyPublic - Updated the CLI to return a list of all private tables not included (added a TODO to check the --include-private opt): ```bash Optimising module with wasm-opt... Build finished successfully. Skipping private tables during codegen: secret_note, secret_order, secret_person. Generate finished successfully. ``` # API and ABI breaking changes Technically API breaking as the private tables will no longer be available. (GitHub labels are not working at the moment) # Expected complexity level and risk 1 - Simple change the testing took longer # Testing Turns out when you remove private tables you invalidate most of the module_bindings across the system! - [x] Rust test SDK for all languages - [x] C# SDK tests - [x] C# dotnet tests - [x] Updated and checked snap files - [x] Updated Blackholio (Unreal + Unity) module_bindings and tested - [x] Ran Unreal SDK tests --------- Signed-off-by: Jason Larabie <jason@clockworklabs.io>
42 lines
1.7 KiB
Rust
42 lines
1.7 KiB
Rust
use spacetimedb_codegen::{generate, CodegenOptions, Csharp, Rust, TypeScript};
|
|
use spacetimedb_data_structures::map::HashMap;
|
|
use spacetimedb_schema::def::ModuleDef;
|
|
use spacetimedb_testing::modules::{CompilationMode, CompiledModule};
|
|
use std::sync::OnceLock;
|
|
|
|
fn compiled_module() -> &'static ModuleDef {
|
|
static COMPILED_MODULE: OnceLock<ModuleDef> = OnceLock::new();
|
|
COMPILED_MODULE
|
|
.get_or_init(|| CompiledModule::compile("module-test", CompilationMode::Debug).extract_schema_blocking())
|
|
}
|
|
|
|
macro_rules! declare_tests {
|
|
($($name:ident => $lang:expr,)*) => ($(
|
|
#[test]
|
|
fn $name() {
|
|
let module = compiled_module();
|
|
let outfiles = generate(&module, &$lang, &CodegenOptions::default())
|
|
.into_iter()
|
|
.map(|f| (f.filename, f.code))
|
|
.collect::<HashMap<_, _>>();
|
|
let mut settings = insta::Settings::clone_current();
|
|
settings.set_sort_maps(true);
|
|
// Ignore the autogenerated comments with version info, since it changes with every
|
|
// build.
|
|
settings.add_filter(r"// This was generated using spacetimedb cli version \d+\.\d+\.\d+ .*", "VERSION_COMMENT");
|
|
// Ignore the place where the CLI version is put in the typescript REMOTE_MODULE info,
|
|
// so it isn't constantly changing.
|
|
settings.add_filter(r#"cliVersion: "\d+\.\d+\.\d+","#, r#"cliVersion: "X.Y.Z","#);
|
|
settings.bind(|| {
|
|
insta::assert_toml_snapshot!(outfiles);
|
|
});
|
|
}
|
|
)*);
|
|
}
|
|
|
|
declare_tests! {
|
|
test_codegen_csharp => Csharp { namespace: "SpacetimeDB" },
|
|
test_codegen_typescript => TypeScript,
|
|
test_codegen_rust => Rust,
|
|
}
|