Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion crates/cli/src/subcommands/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use std::io::Read;
pub fn cli() -> clap::Command {
clap::Command::new("generate")
.about("Generate client files for a spacetime module.")
.override_usage("spacetime generate --lang <LANG> --out-dir <DIR> [--project-path <DIR> | --bin-path <PATH> | --module-name <MODULE_NAME> | --uproject-dir <DIR>]")
.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>]")
.arg(
Arg::new("wasm_file")
.value_parser(clap::value_parser!(PathBuf))
Expand Down Expand Up @@ -93,6 +93,11 @@ pub fn cli() -> clap::Command {
.help("The module name that should be used for DLL export macros (required for lang unrealcpp)")
.required_if_eq("lang", "unrealcpp")
)
.arg(
Arg::new("module_prefix")
.long("module-prefix")
.help("The module prefix to use for generated types (only used with --lang unrealcpp)")
)
.arg(
Arg::new("lang")
.required(true)
Expand Down Expand Up @@ -135,6 +140,7 @@ pub async fn exec_ex(
let lang = *args.get_one::<Language>("lang").unwrap();
let namespace = args.get_one::<String>("namespace").unwrap();
let module_name = args.get_one::<String>("module_name");
let module_prefix = args.get_one::<String>("module_prefix");
let force = args.get_flag("force");
let build_options = args.get_one::<String>("build_options").unwrap();

Expand Down Expand Up @@ -186,6 +192,7 @@ pub async fn exec_ex(
unreal_cpp_lang = UnrealCpp {
module_name: module_name.as_ref().unwrap(),
uproject_dir: out_dir,
module_prefix: module_prefix.as_ref().map(|s| s.as_str()).unwrap_or(""),
};
&unreal_cpp_lang as &dyn Lang
}
Expand Down
1 change: 1 addition & 0 deletions crates/codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ spacetimedb-schema.workspace = true
anyhow.workspace = true
convert_case.workspace = true
itertools.workspace = true
serde_json.workspace = true

[dev-dependencies]
fs-err.workspace = true
Expand Down
1,103 changes: 770 additions & 333 deletions crates/codegen/src/unrealcpp.rs

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion docs/docs/05-CLI Reference/01-cli-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ Run `spacetime rename --help` for more detailed information.

Generate client files for a spacetime module.

**Usage:** `spacetime spacetime generate --lang <LANG> --out-dir <DIR> [--project-path <DIR> | --bin-path <PATH> | --module-name <MODULE_NAME> | --uproject-dir <DIR>]`
**Usage:** `spacetime spacetime generate --lang <LANG> --out-dir <DIR> [--project-path <DIR> | --bin-path <PATH> | --module-name <MODULE_NAME> | --uproject-dir <DIR> | --module-prefix <PREFIX>]`

Run `spacetime help publish` for more detailed information.

Expand All @@ -269,6 +269,7 @@ Run `spacetime help publish` for more detailed information.
Default value: `SpacetimeDB.Types`

- `--module-name <MODULE_NAME>` — The module name that should be used for DLL export macros (required for lang unrealcpp)
- `--module-prefix <MODULE_PREFIX>` — The module prefix to use for generated types (only used with --lang unrealcpp)
- `-l`, `--lang <LANG>` — The language to generate

Possible values: `csharp`, `typescript`, `rust`, `unrealcpp`
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct TESTCLIENT_API FTestClientOptionalInt32
bool bHasValue = false;

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SpacetimeDB", meta = (EditCondition = "bHasValue"))
int32 Value;
int32 Value = 0;

FTestClientOptionalInt32() = default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct TESTCLIENT_API FTestClientOptionalSimpleEnum
bool bHasValue = false;

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SpacetimeDB", meta = (EditCondition = "bHasValue"))
ESimpleEnumType Value;
ESimpleEnumType Value = static_cast<ESimpleEnumType>(0);

FTestClientOptionalSimpleEnum() = default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#pragma once
#include "CoreMinimal.h"
#include "BSATN/UESpacetimeDB.h"
#include "ModuleBindings/Optionals/TestClientOptionalInt32.g.h"
#include "TestClientOptionalVecOptionalInt32.g.generated.h"

USTRUCT(BlueprintType)
Expand Down
Loading
Loading