Skip to content
Draft
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
19 changes: 14 additions & 5 deletions bin/sozo/src/commands/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use anyhow::Result;
use clap::{Args, Parser};
use colored::{ColoredString, Colorize};
use dojo_bindgen::{BuiltinPlugins, PluginManager};
use dojo_world::local::{ResourceLocal, WorldLocal};
use dojo_world::ResourceType;
use dojo_world::local::{ResourceLocal, WorldLocal};
use scarb::core::{Config, Package, TargetKind};
use scarb::ops::CompileOpts;
use scarb_ui::args::{FeaturesSpec, PackagesFilter};
Expand Down Expand Up @@ -38,6 +38,10 @@ pub struct BuildArgs {
#[arg(help = "Generate Unreal Engine bindings.")]
pub unrealengine: bool,

#[arg(long)]
#[arg(help = "Generate Go bindings.")]
pub golang: bool,

#[arg(long)]
#[arg(help = "Output directory.", default_value = "bindings")]
pub bindings_output: String,
Expand All @@ -60,25 +64,25 @@ pub struct BuildArgs {
pub struct StatOptions {
#[arg(long = "stats.by-tag")]
#[arg(help = "Sort the stats by tag.")]
#[arg(conflicts_with_all = ["stats.by-sierra-mb", "stats.by-sierra-felts", "stats.by-casm-felts"])]
#[arg(conflicts_with_all = ["sort_by_sierra_mb", "sort_by_sierra_felts", "sort_by_casm_felts"])]
#[arg(default_value_t = false)]
pub sort_by_tag: bool,

#[arg(long = "stats.by-sierra-mb")]
#[arg(help = "Sort the stats by Sierra file size in MB.")]
#[arg(conflicts_with_all = ["stats.by-tag", "stats.by-sierra-felts", "stats.by-casm-felts"])]
#[arg(conflicts_with_all = ["sort_by_tag", "sort_by_sierra_felts", "sort_by_casm_felts"])]
#[arg(default_value_t = false)]
pub sort_by_sierra_mb: bool,

#[arg(long = "stats.by-sierra-felts")]
#[arg(help = "Sort the stats by Sierra program size in felts.")]
#[arg(conflicts_with_all = ["stats.by-tag", "stats.by-sierra-mb", "stats.by-casm-felts"])]
#[arg(conflicts_with_all = ["sort_by_tag", "sort_by_sierra_mb", "sort_by_casm_felts"])]
#[arg(default_value_t = false)]
pub sort_by_sierra_felts: bool,

#[arg(long = "stats.by-casm-felts")]
#[arg(help = "Sort the stats by Casm bytecode size in felts.")]
#[arg(conflicts_with_all = ["stats.by-tag", "stats.by-sierra-mb", "stats.by-sierra-felts"])]
#[arg(conflicts_with_all = ["sort_by_tag", "sort_by_sierra_mb", "sort_by_sierra_felts"])]
#[arg(default_value_t = false)]
pub sort_by_casm_felts: bool,
}
Expand Down Expand Up @@ -138,6 +142,10 @@ impl BuildArgs {
builtin_plugins.push(BuiltinPlugins::UnrealEngine);
}

if self.golang {
builtin_plugins.push(BuiltinPlugins::Golang);
}

// Custom plugins are always empty for now.
let bindgen = PluginManager {
profile_name: ws.current_profile().expect("Profile expected").to_string(),
Expand Down Expand Up @@ -223,6 +231,7 @@ impl Default for BuildArgs {
recs: false,
unity: false,
unrealengine: false,
golang: false,
bindings_output: "bindings".to_string(),
stats: StatOptions::default(),
packages: None,
Expand Down
2 changes: 2 additions & 0 deletions crates/dojo/bindgen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use plugins::typescript::TypescriptPlugin;
use plugins::typescript_v2::TypeScriptV2Plugin;
use plugins::unity::UnityPlugin;
use plugins::unrealengine::UnrealEnginePlugin;
use plugins::golang::GolangPlugin;
use plugins::BuiltinPlugin;
pub use plugins::BuiltinPlugins;

Expand Down Expand Up @@ -105,6 +106,7 @@ impl PluginManager {
BuiltinPlugins::UnrealEngine => Box::new(UnrealEnginePlugin::new()),
BuiltinPlugins::TypeScriptV2 => Box::new(TypeScriptV2Plugin::new()),
BuiltinPlugins::Recs => Box::new(TypescriptRecsPlugin::new()),
BuiltinPlugins::Golang => Box::new(GolangPlugin::new()),
};

let files = builder.generate_code(&data).await?;
Expand Down
Loading
Loading