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

How to handle untracked output generated as a build side-effect #3012

Open
bobozaur opened this issue Nov 20, 2024 · 0 comments
Open

How to handle untracked output generated as a build side-effect #3012

bobozaur opened this issue Nov 20, 2024 · 0 comments

Comments

@bobozaur
Copy link

Hello,

We encountered this when using sqlx, which can cache compile-time query execution into some files for offline use (without a database).

In a Cargo workspace, people would generally run cargo sqlx prepare with a live database active and the query files would be generated, by default within the crate directory in a .sqlx directory. We wanted to emulate this behavior using Bazel. The sqlx proc-macros do all the heavy lifting and all that's needed for the query files to be generated are some environment variables to be set, specifically DATABASE_URL and SQLX_OFFLINE_DIR.

However, the query files get generated at compile time and they are not declared as output. The query files are named using the convention query-{SQL-HASH}.json so the names are not really deterministic, but we can control the location where they get generated through the SQLX_OFFLINE_DIR environment variable. However, this directory must exist before the target is built, as otherwise the proc-macros will fail.

How could we go about capturing/excavating these query files? Is there some approach to be taken for situations like these? The main problem seems to be that regardless of what gets passed as SQLX_OFFLINE_DIR the query files are untracked and there's no way to reference them.

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

1 participant