dnaka91 / llvm-cov-pretty

More beautiful HTML reports for llvm-cov/cargo-llvm-cov
GNU Affero General Public License v3.0
28 stars 3 forks source link

build.rs fails with odd error when git submodules are not fetched #13

Open jayvdb opened 1 month ago

jayvdb commented 1 month ago

Describe the bug

Local build from a new repo fails with the following if the submodules havent been fetched:

llvm-cov-pretty> cargo build
   Compiling llvm-cov-pretty v0.1.9 (/home/jayvdb/rust/llvm-cov-pretty)
error: failed to run custom build command for `llvm-cov-pretty v0.1.9 (/home/jayvdb/rust/llvm-cov-pretty)`

Caused by:
  process didn't exit successfully: `/home/jayvdb/rust/llvm-cov-pretty/target/debug/build/llvm-cov-pretty-0dd84e369c6fdec6/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-changed=assets/themes/1337-Scheme/1337.tmTheme

  --- stderr
  thread 'main' panicked at build.rs:98:65:
  called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }

Expected behavior

An error explaining git submodules need to be fetched.

Or better, a warning that no themes will be available, so that cargo install --git https://github.com/dnaka91/llvm-cov-pretty will work albeit degraded.

To reproduce

No response

What operating system are you using?

None

Terminal output

No response

Additional context

No response

dnaka91 commented 1 month ago

This is a tricky issue, and I guess improving the error message is pretty much all that can be done here.

For when I publish it to crates.io, I actually do a dirty publish, meaning that the style.css is generated and included in the package that is uploaded, but that file is never tracked so you wouldn't be able to find or pull it from this repo without other steps.

Of course this could be committed to the repo, but I'm very strongly against committing any file that can be generated on the fly during the build.

Putting the file in the package in this way is just a workaround because the submodule information isn't saved.

But in case of a cargo install --git ... we might have a chance that we can pull in the submodule from the build.rs as an extra step, just have to be careful to detect if we are in a git repo or not (to not break the regular cargo install).

I'll have a go at it and we'll see how it goes (not sure when I get to it though. Currently I'm not making much use of my own tool :sweat_smile:)

jayvdb commented 1 month ago

I think using install --git will be rare, so probably not worth the effort at this stage.