Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hard coded build script means ineffective watches when the file is in a non standard location #205

Open
alerque opened this issue Aug 13, 2024 · 4 comments

Comments

@alerque
Copy link

alerque commented Aug 13, 2024

The location of build.rs to watch seems to be hard coded as the Cargo default:

static DEFAULT_WATCHES: &[&str] = &["src", "tests", "benches", "examples", "build.rs"];

This location is, however, configurable. I do so in most of my projects to group build tooling out of the way of the top level directory when possible:

[package]
build = "build-aux/build.rs"

This location is not watched, hence changes to the file do not trigger updates in bacon.

I would suggest the Cargo manifest actually be read and the value of build (if set), and fall back to the default if it is not set. There might even be a way to query the active value out of Cargo, but I don't know what it is. Somewhat unhelpfully cargo read-manifest buries the relevant info a bit. For example on my git-warp-time project that relocates the build script, the info ends up here:

$ cargo read-manifest | jq -r '.targets[] | select(.kind[0] == "custom-build") | .src_path'
/home/caleb/projects/git-warp-time/build-aux/build.rs
@Canop
Copy link
Owner

Canop commented Aug 13, 2024

I would suggest the Cargo manifest actually be read and the value of build (if set)

I'll have a look.

In the meantime, do we agree that you can simply add watch = ["build-aux/build.rs"] to your jobs ?

@alerque
Copy link
Author

alerque commented Aug 13, 2024

In the meantime, do we agree that you can simply add watch = ["build-aux/build.rs"] to your jobs?

I haven't tried it yet, but possibly yes. Is that value additive? Or will I also have to list of everything else that will affect the build?

Even so it's still unexpected that the things Cargo knows about the source layout isn't taken into account.

@Canop
Copy link
Owner

Canop commented Aug 13, 2024

It's additive. And you can use watch = ["build-aux"] if you want to react to changes of all files in build-aux.

Even so it's still unexpected that the things Cargo knows about the source layout isn't taken into account.

Last time I checked, there was no good solution in the rust ecosystem for getting the information regarding the project's metadata. As I'd rather not maintain that part myself I use cargo-metadata whose design isn't great.

I'll have a look regarding the build part in cargo-metadata when I find some time.

@alerque
Copy link
Author

alerque commented Aug 13, 2024

Fair enough, and thanks for the info.

Before I opened this issue I had a quick look at the source to see if this was something I could easily fix, but since I didn't see if/where the manifest was being read at all it wasn't obvious how to fix this.

Last time I checked, there was no good solution in the rust ecosystem for getting the information regarding the project's metadata.

Yes, this is an ongoing gripe of mine with Cargo. By itself it's a pretty capable tool and I grant it has decent UX. But it does not play nice with other build systems or tooling at all. Even though bacon isn't a build system it shares this issue of having to guess/reproduce what sources go into a build without much from Cargo to go on.

(And thanks for bacon, I love it!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants