Skip to content

Commit 5c90b69

Browse files
Reworked Unreal codegen to handle multi-modules and added new --module-prefix for the generate command to support it
1 parent 141048c commit 5c90b69

File tree

4 files changed

+778
-336
lines changed

4 files changed

+778
-336
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/cli/src/subcommands/generate.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use std::io::Read;
2525
pub fn cli() -> clap::Command {
2626
clap::Command::new("generate")
2727
.about("Generate client files for a spacetime module.")
28-
.override_usage("spacetime generate --lang <LANG> --out-dir <DIR> [--project-path <DIR> | --bin-path <PATH> | --module-name <MODULE_NAME> | --uproject-dir <DIR>]")
28+
.override_usage("spacetime generate --lang <LANG> --out-dir <DIR> [--project-path <DIR> | --bin-path <PATH> | --module-name <MODULE_NAME> | --uproject-dir <DIR> | --module-prefix <PREFIX>]")
2929
.arg(
3030
Arg::new("wasm_file")
3131
.value_parser(clap::value_parser!(PathBuf))
@@ -93,6 +93,11 @@ pub fn cli() -> clap::Command {
9393
.help("The module name that should be used for DLL export macros (required for lang unrealcpp)")
9494
.required_if_eq("lang", "unrealcpp")
9595
)
96+
.arg(
97+
Arg::new("module_prefix")
98+
.long("module-prefix")
99+
.help("The module prefix to use for generated types (only used with --lang unrealcpp)")
100+
)
96101
.arg(
97102
Arg::new("lang")
98103
.required(true)
@@ -135,6 +140,7 @@ pub async fn exec_ex(
135140
let lang = *args.get_one::<Language>("lang").unwrap();
136141
let namespace = args.get_one::<String>("namespace").unwrap();
137142
let module_name = args.get_one::<String>("module_name");
143+
let module_prefix = args.get_one::<String>("module_prefix");
138144
let force = args.get_flag("force");
139145
let build_options = args.get_one::<String>("build_options").unwrap();
140146

@@ -186,6 +192,7 @@ pub async fn exec_ex(
186192
unreal_cpp_lang = UnrealCpp {
187193
module_name: module_name.as_ref().unwrap(),
188194
uproject_dir: out_dir,
195+
module_prefix: module_prefix.as_ref().map(|s| s.as_str()).unwrap_or(""),
189196
};
190197
&unreal_cpp_lang as &dyn Lang
191198
}

crates/codegen/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ spacetimedb-schema.workspace = true
1515
anyhow.workspace = true
1616
convert_case.workspace = true
1717
itertools.workspace = true
18+
serde_json.workspace = true
1819

1920
[dev-dependencies]
2021
fs-err.workspace = true

0 commit comments

Comments
 (0)