MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / run_command

Function run_command

crates/cli/src/tasks/cpp.rs:13–32  ·  view source on GitHub ↗

Execute a command in a working directory and verify it succeeds. On Windows, commands are wrapped in `cmd /C` to support `.bat` and `.cmd` files (e.g., `emcc.bat`, `emcmake.cmd`), which don't work with direct execution. Returns an error if the command fails (non-zero exit code).

(prog: &str, args: &[S], cwd: &Path)

Source from the content-addressed store, hash-verified

11///
12/// Returns an error if the command fails (non-zero exit code).
13fn run_command<S: AsRef<str>>(prog: &str, args: &[S], cwd: &Path) -> anyhow::Result<()> {
14 #[cfg(windows)]
15 {
16 let mut pieces: Vec<String> = Vec::with_capacity(1 + args.len());
17 pieces.push(prog.to_string());
18 pieces.extend(args.iter().map(|s| s.as_ref().to_string()));
19 duct::cmd("cmd", std::iter::once("/C").chain(pieces.iter().map(String::as_str)))
20 .dir(cwd)
21 .run()
22 .with_context(|| format!("failed running `{prog}`"))?;
23 }
24 #[cfg(not(windows))]
25 {
26 duct::cmd(prog, args.iter().map(|s| s.as_ref()))
27 .dir(cwd)
28 .run()
29 .with_context(|| format!("failed running `{prog}`"))?;
30 }
31 Ok(())
32}
33
34pub(crate) fn build_cpp(project_path: &Path, build_debug: bool) -> anyhow::Result<PathBuf> {
35 // Verify required tools are in PATH

Callers 1

build_cppFunction · 0.70

Calls 9

iterMethod · 0.65
OkFunction · 0.50
lenMethod · 0.45
pushMethod · 0.45
to_stringMethod · 0.45
extendMethod · 0.45
mapMethod · 0.45
as_refMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…