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

lalrpop_mod! looks under build subdirectory instead of crate root #690

Open
littlebenlittle opened this issue Oct 12, 2022 · 2 comments
Open

Comments

@littlebenlittle
Copy link

Running cargo build results in couldn't read target/debug/build/xmd-lalrpop-<id>/out/src/calculator1.lalrpop: no such file or directory.

I can get the build script to finish if I use lalrpop_mod!(pub calculator1, "/../../../../../src/calculator1.lalrpop") but that really doesn't look like the intended way to use the macro.

Using cargo -V cargo 1.60.0 (d1fd9fe 2022-03-01)

Project layout based on calculator example example:

.
├── build.rs
├── Cargo.lock
├── Cargo.toml
└── src
   ├── lib.rs
   └── calculator1.lalrpop

src/lib.rs:

#[macro_use] extern crate lalrpop_util;

lalrpop_mod!(pub calculator1, "/src/calculator1.lalrpop");
@an-inconspicuous-semicolon

I found the reason for this. It is because in the macro lalrpop_mod! it looks for the file in env!("OUT_DIR")/argument-given-to-macro

The issue comes with the fact that cargo sets OUT_DIR on build. so when OUT_DIR=foobar cargo build is run, OUT_DIR gets set to the binary output dir, rather than foobar

the fix for this is to change the enviroment variable used inside lalrpop_mod! to something like LALRPOP_OUT_DIR

@an-inconspicuous-semicolon

Also note that this is expected behavior as of v0.16.0
documentation

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