Skip to content

Commit 33c9d8e

Browse files
committed
feat(cli): Pull in cargo-script-mvs core logic
This is no where near the implementation we want but I think we should develop incrementally on top of what we already have. See https://github.com/epage/cargo-script-mvs/tree/main
1 parent c421e0b commit 33c9d8e

File tree

7 files changed

+1322
-34
lines changed

7 files changed

+1322
-34
lines changed

Cargo.lock

Lines changed: 58 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ exclude = [
1313
[workspace.dependencies]
1414
anyhow = "1.0.47"
1515
base64 = "0.21.0"
16+
blake3 = "1.3.3"
1617
bytesize = "1.0"
1718
cargo = { path = "" }
1819
cargo-credential = { version = "0.2.0", path = "credential/cargo-credential" }
@@ -66,6 +67,7 @@ pretty_env_logger = "0.4"
6667
proptest = "1.1.0"
6768
pulldown-cmark = { version = "0.9.2", default-features = false }
6869
rand = "0.8.5"
70+
regex = "1.8.3"
6971
rustfix = "0.6.0"
7072
same-file = "1.0.6"
7173
security-framework = "2.0.0"
@@ -79,6 +81,7 @@ sha2 = "0.10.6"
7981
shell-escape = "0.1.4"
8082
snapbox = { version = "0.4.0", features = ["diff", "path"] }
8183
strip-ansi-escapes = "0.1.0"
84+
syn = { version = "2.0.14", features = ["extra-traits", "full"] }
8285
tar = { version = "0.4.38", default-features = false }
8386
tempfile = "3.1.0"
8487
termcolor = "1.1.2"
@@ -112,6 +115,7 @@ path = "src/cargo/lib.rs"
112115
[dependencies]
113116
anyhow.workspace = true
114117
base64.workspace = true
118+
blake3.workspace = true
115119
bytesize.workspace = true
116120
cargo-platform.workspace = true
117121
cargo-util.workspace = true
@@ -147,7 +151,9 @@ os_info.workspace = true
147151
pasetors.workspace = true
148152
pathdiff.workspace = true
149153
pretty_env_logger = { workspace = true, optional = true }
154+
pulldown-cmark.workspace = true
150155
rand.workspace = true
156+
regex.workspace = true
151157
rustfix.workspace = true
152158
semver.workspace = true
153159
serde = { workspace = true, features = ["derive"] }
@@ -157,6 +163,7 @@ serde_json = { workspace = true, features = ["raw_value"] }
157163
sha1.workspace = true
158164
shell-escape.workspace = true
159165
strip-ansi-escapes.workspace = true
166+
syn.workspace = true
160167
tar.workspace = true
161168
tempfile.workspace = true
162169
termcolor.workspace = true

deny.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ allow = [
106106
"MIT-0",
107107
"Apache-2.0",
108108
"BSD-3-Clause",
109+
"BSD-2-Clause",
109110
"MPL-2.0",
110111
"Unicode-DFS-2016",
111112
"CC0-1.0",

src/bin/cargo/commands/run.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,26 @@ pub fn is_manifest_command(arg: &str) -> bool {
8989
1 < path.components().count() || path.extension() == Some(OsStr::new("rs"))
9090
}
9191

92-
pub fn exec_manifest_command(config: &Config, cmd: &str, _args: &[OsString]) -> CliResult {
92+
pub fn exec_manifest_command(config: &Config, cmd: &str, args: &[OsString]) -> CliResult {
9393
if !config.cli_unstable().script {
9494
return Err(anyhow::anyhow!("running `{cmd}` requires `-Zscript`").into());
9595
}
9696

97-
todo!("support for running manifest-commands is not yet implemented")
97+
let manifest_path = Path::new(cmd);
98+
if !manifest_path.exists() {
99+
return Err(
100+
anyhow::anyhow!("manifest `{}` does not exist", manifest_path.display()).into(),
101+
);
102+
}
103+
let manifest_path = crate::util::try_canonicalize(manifest_path)?;
104+
let script = cargo::util::toml::embedded::RawScript::parse_from(&manifest_path)?;
105+
let ws = script.to_workspace(config)?;
106+
107+
let mut compile_opts =
108+
cargo::ops::CompileOptions::new(config, cargo::core::compiler::CompileMode::Build)?;
109+
compile_opts.spec = cargo::ops::Packages::Default;
110+
111+
cargo::ops::run(&ws, &compile_opts, args).map_err(|err| to_run_error(config, err))
98112
}
99113

100114
fn to_run_error(config: &cargo::util::Config, err: anyhow::Error) -> CliError {

0 commit comments

Comments
 (0)