Skip to content

Commit 9c501aa

Browse files
committed
remove --mod option
This was only used for the build subcommand, but all subcommands potentially need to know where the go module is e.g. to locate `componentize-go.toml` files, so we should either promote it to be a subcommand-independent option or drop it and require that `componentize-go` be run in the directory containing the module of interest. I chose the latter in this case, but we could certainly revisit that.
1 parent 0f17434 commit 9c501aa

File tree

2 files changed

+3
-24
lines changed

2 files changed

+3
-24
lines changed

src/cmd_build.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use std::{path::PathBuf, process::Command};
77
/// If the module is not going to be adapted to the component model,
88
/// set the `only_wasip1` arg to true.
99
pub fn build_module(
10-
go_module: Option<&PathBuf>,
1110
out: Option<&PathBuf>,
1211
go_path: Option<&PathBuf>,
1312
only_wasip1: bool,
@@ -33,22 +32,11 @@ pub fn build_module(
3332
.to_str()
3433
.ok_or_else(|| anyhow!("Output path is not valid unicode"))?;
3534

36-
let module_path = match &go_module {
37-
Some(p) => {
38-
if !p.is_dir() {
39-
return Err(anyhow!("Module path '{}' is not a directory", p.display()));
40-
}
41-
p.to_str()
42-
.ok_or_else(|| anyhow!("Module path is not valid unicode"))?
43-
}
44-
None => ".",
45-
};
46-
4735
// The -buildmode flag mutes the module's output, so it is ommitted
4836
let module_args = [
4937
"build",
5038
"-C",
51-
module_path,
39+
".",
5240
"-ldflags=-checklinkname=0",
5341
"-o",
5442
out_path,
@@ -57,7 +45,7 @@ pub fn build_module(
5745
let component_args = [
5846
"build",
5947
"-C",
60-
module_path,
48+
".",
6149
"-buildmode=c-shared",
6250
"-ldflags=-checklinkname=0",
6351
"-o",

src/command.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,6 @@ pub struct Build {
9191
#[arg(long, short = 'o')]
9292
pub output: Option<PathBuf>,
9393

94-
/// The directory containing the "go.mod" file (or current directory if `None`).
95-
#[arg(long = "mod")]
96-
pub mod_path: Option<PathBuf>,
97-
9894
/// The path to the Go binary (or look for binary in PATH if `None`).
9995
#[arg(long)]
10096
pub go: Option<PathBuf>,
@@ -170,12 +166,7 @@ pub fn run<T: Into<OsString> + Clone, I: IntoIterator<Item = T>>(args: I) -> Res
170166

171167
fn build(wit_opts: WitOpts, build: Build) -> Result<()> {
172168
// Build a wasm module using `go build`.
173-
let module = build_module(
174-
build.mod_path.as_ref(),
175-
build.output.as_ref(),
176-
build.go.as_ref(),
177-
build.wasip1,
178-
)?;
169+
let module = build_module(build.output.as_ref(), build.go.as_ref(), build.wasip1)?;
179170

180171
if !build.wasip1 {
181172
// Embed the WIT documents in the wasip1 component.

0 commit comments

Comments
 (0)