diff --git a/README.md b/README.md index 2b8674b7..d44a77d3 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ Options: -v, --verbose Increase verbosity --trace Trace the execution of the program --dry-run Do not actually run the command + --build-graph generate build graph -h, --help Print help ``` diff --git a/crates/moon/tests/test_cases/mod.rs b/crates/moon/tests/test_cases/mod.rs index f5ac8914..d0f48422 100644 --- a/crates/moon/tests/test_cases/mod.rs +++ b/crates/moon/tests/test_cases/mod.rs @@ -3548,20 +3548,11 @@ fn test_deny_warn() { "#]], ); - let out = snapbox::cmd::Command::new(moon_bin()) - .current_dir(&dir) - .args(["check", "--deny-warn", "--sort-input"]) - .assert() - .failure() - .get_output() - .stdout - .to_owned(); - check( - std::str::from_utf8(&out).unwrap(), + &get_err_stdout_with_args_and_replace_dir(&dir, ["check", "--deny-warn", "--sort-input"]), expect![[r#" - failed: check: username/hello/lib - "#]], + failed: moonc check -error-format json -w @a -alert @all-raise-throw-unsafe+deprecated $ROOT/lib/hello.mbt -o $ROOT/target/wasm-gc/release/check/lib/lib.mi -pkg username/hello/lib -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -pkg-sources username/hello/lib:$ROOT/lib -target wasm-gc + "#]], ); check( @@ -3613,19 +3604,10 @@ fn test_deny_warn() { "#]], ); - let out = snapbox::cmd::Command::new(moon_bin()) - .current_dir(&dir) - .args(["build", "--deny-warn", "--sort-input"]) - .assert() - .failure() - .get_output() - .stdout - .to_owned(); - check( - std::str::from_utf8(&out).unwrap(), + &get_err_stdout_with_args_and_replace_dir(&dir, ["build", "--deny-warn", "--sort-input"]), expect![[r#" - failed: build-package: username/hello/lib + failed: moonc build-package -error-format json -w @a -alert @all-raise-throw-unsafe+deprecated $ROOT/lib/hello.mbt -o $ROOT/target/wasm-gc/release/build/lib/lib.core -pkg username/hello/lib -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -pkg-sources username/hello/lib:$ROOT/lib -target wasm-gc "#]], ); } diff --git a/crates/moon/tests/test_cases/moon_build_package.in/moon.test b/crates/moon/tests/test_cases/moon_build_package.in/moon.test index 72065f84..c567cf31 100644 --- a/crates/moon/tests/test_cases/moon_build_package.in/moon.test +++ b/crates/moon/tests/test_cases/moon_build_package.in/moon.test @@ -2,11 +2,31 @@ moonc build-package ./src/lib/hello.mbt -o ./target/wasm-gc/release/build/lib/lib.core -pkg username/hello/lib -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -pkg-sources username/hello/lib:./src/lib -target wasm-gc moonc build-package ./src/top.mbt -o ./target/wasm-gc/release/build/hello.core -pkg username/hello -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -i ./target/wasm-gc/release/build/lib/lib.mi:lib -pkg-sources username/hello:./src -target wasm-gc - $ moon build --build-graph + $ moon build --build-graph --sort-input + generated build graph: ${WORK_DIR}/target/wasm-gc/release/build/build_graph.dot Finished. moon: ran 2 tasks, now up to date $ xls ./target/wasm-gc/release/build/lib/ lib.core lib.mi $ xls ./target/wasm-gc/release/build/ .moon-lock build.moon_db build.output build_graph.dot hello.core hello.mi lib moon.db + $ xcat ./target/wasm-gc/release/build/build_graph.dot + digraph BuildGraph { + "./target/wasm-gc/release/build/hello.core" [shape=box, style=filled, fillcolor=black, fontcolor=white]; + "./target/wasm-gc/release/build/hello.mi" [shape=box, color=black, ]; + "./src/top.mbt" [shape=box, color=black, ]; + "./target/wasm-gc/release/build/lib/lib.mi" [shape=box, color=black, ]; + "./target/wasm-gc/release/build/lib/lib.core" [shape=box, style=filled, fillcolor=black, fontcolor=white]; + "./src/lib/hello.mbt" [shape=box, color=black, ]; + "build-package: username/hello" [shape=ellipse]; + "./src/top.mbt" -> "build-package: username/hello"; + "./target/wasm-gc/release/build/lib/lib.mi" -> "build-package: username/hello"; + "build-package: username/hello" -> "./target/wasm-gc/release/build/hello.core"; + "build-package: username/hello" -> "./target/wasm-gc/release/build/hello.mi"; + "build-package: username/hello/lib" [shape=ellipse]; + "./src/lib/hello.mbt" -> "build-package: username/hello/lib"; + "build-package: username/hello/lib" -> "./target/wasm-gc/release/build/lib/lib.core"; + "build-package: username/hello/lib" -> "./target/wasm-gc/release/build/lib/lib.mi"; + } + diff --git a/crates/moonbuild/src/entry.rs b/crates/moonbuild/src/entry.rs index 60fd131f..8aad2192 100644 --- a/crates/moonbuild/src/entry.rs +++ b/crates/moonbuild/src/entry.rs @@ -227,7 +227,8 @@ fn vis_build_graph(state: &State, moonbuild_opt: &MoonbuildOpt) { } dot.push_str("}\n"); - std::fs::write(path, dot).expect("Unable to write dot file"); + std::fs::write(&path, dot).expect("Unable to write dot file"); + eprintln!("generated build graph: {}", path.display()); } pub fn run_check( diff --git a/crates/moonutil/src/cli.rs b/crates/moonutil/src/cli.rs index 83d17062..db3a7de8 100644 --- a/crates/moonutil/src/cli.rs +++ b/crates/moonutil/src/cli.rs @@ -51,6 +51,6 @@ pub struct UniversalFlags { pub dry_run: bool, /// generate build graph - #[clap(long, global = true)] + #[clap(long, global = true, conflicts_with = "dry_run")] pub build_graph: bool, } diff --git a/docs/manual-zh/src/tutorial.md b/docs/manual-zh/src/tutorial.md index eee79e6b..726f167e 100644 --- a/docs/manual-zh/src/tutorial.md +++ b/docs/manual-zh/src/tutorial.md @@ -48,6 +48,7 @@ -v, --verbose Increase verbosity --trace Trace the execution of the program --dry-run Do not actually run the command + --build-graph generate build graph -h, --help Print help ``` diff --git a/docs/manual/src/tutorial.md b/docs/manual/src/tutorial.md index 2b63d15f..9c4f4a30 100644 --- a/docs/manual/src/tutorial.md +++ b/docs/manual/src/tutorial.md @@ -48,6 +48,7 @@ Before you begin with this tutorial, make sure you have installed the following: -v, --verbose Increase verbosity --trace Trace the execution of the program --dry-run Do not actually run the command + --build-graph generate build graph -h, --help Print help ```