Skip to content

Commit 099f7c6

Browse files
committed
Add golang bindgen support
1 parent 3cb5095 commit 099f7c6

File tree

5 files changed

+762
-6
lines changed

5 files changed

+762
-6
lines changed

bin/sozo/src/commands/build.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use anyhow::Result;
44
use clap::{Args, Parser};
55
use colored::{ColoredString, Colorize};
66
use dojo_bindgen::{BuiltinPlugins, PluginManager};
7-
use dojo_world::local::{ResourceLocal, WorldLocal};
87
use dojo_world::ResourceType;
8+
use dojo_world::local::{ResourceLocal, WorldLocal};
99
use scarb::core::{Config, Package, TargetKind};
1010
use scarb::ops::CompileOpts;
1111
use scarb_ui::args::{FeaturesSpec, PackagesFilter};
@@ -38,6 +38,10 @@ pub struct BuildArgs {
3838
#[arg(help = "Generate Unreal Engine bindings.")]
3939
pub unrealengine: bool,
4040

41+
#[arg(long)]
42+
#[arg(help = "Generate Go bindings.")]
43+
pub golang: bool,
44+
4145
#[arg(long)]
4246
#[arg(help = "Output directory.", default_value = "bindings")]
4347
pub bindings_output: String,
@@ -60,25 +64,25 @@ pub struct BuildArgs {
6064
pub struct StatOptions {
6165
#[arg(long = "stats.by-tag")]
6266
#[arg(help = "Sort the stats by tag.")]
63-
#[arg(conflicts_with_all = ["stats.by-sierra-mb", "stats.by-sierra-felts", "stats.by-casm-felts"])]
67+
#[arg(conflicts_with_all = ["sort_by_sierra_mb", "sort_by_sierra_felts", "sort_by_casm_felts"])]
6468
#[arg(default_value_t = false)]
6569
pub sort_by_tag: bool,
6670

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

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

7983
#[arg(long = "stats.by-casm-felts")]
8084
#[arg(help = "Sort the stats by Casm bytecode size in felts.")]
81-
#[arg(conflicts_with_all = ["stats.by-tag", "stats.by-sierra-mb", "stats.by-sierra-felts"])]
85+
#[arg(conflicts_with_all = ["sort_by_tag", "sort_by_sierra_mb", "sort_by_sierra_felts"])]
8286
#[arg(default_value_t = false)]
8387
pub sort_by_casm_felts: bool,
8488
}
@@ -138,6 +142,10 @@ impl BuildArgs {
138142
builtin_plugins.push(BuiltinPlugins::UnrealEngine);
139143
}
140144

145+
if self.golang {
146+
builtin_plugins.push(BuiltinPlugins::Golang);
147+
}
148+
141149
// Custom plugins are always empty for now.
142150
let bindgen = PluginManager {
143151
profile_name: ws.current_profile().expect("Profile expected").to_string(),
@@ -223,6 +231,7 @@ impl Default for BuildArgs {
223231
recs: false,
224232
unity: false,
225233
unrealengine: false,
234+
golang: false,
226235
bindings_output: "bindings".to_string(),
227236
stats: StatOptions::default(),
228237
packages: None,

crates/dojo/bindgen/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use plugins::typescript::TypescriptPlugin;
1717
use plugins::typescript_v2::TypeScriptV2Plugin;
1818
use plugins::unity::UnityPlugin;
1919
use plugins::unrealengine::UnrealEnginePlugin;
20+
use plugins::golang::GolangPlugin;
2021
use plugins::BuiltinPlugin;
2122
pub use plugins::BuiltinPlugins;
2223

@@ -105,6 +106,7 @@ impl PluginManager {
105106
BuiltinPlugins::UnrealEngine => Box::new(UnrealEnginePlugin::new()),
106107
BuiltinPlugins::TypeScriptV2 => Box::new(TypeScriptV2Plugin::new()),
107108
BuiltinPlugins::Recs => Box::new(TypescriptRecsPlugin::new()),
109+
BuiltinPlugins::Golang => Box::new(GolangPlugin::new()),
108110
};
109111

110112
let files = builder.generate_code(&data).await?;

0 commit comments

Comments
 (0)