-
Notifications
You must be signed in to change notification settings - Fork 162
Description
Describe the bug
If Buider::custom_gendir is used to output generated code into a custom directory, then include_cpp tries to read that directory relative to itself, rather than relative to cargo root direcotory. That is, custom output location does not work.
To Reproduce
src/main.rs:
use autocxx::prelude::*;
include_cpp! {#include "compute.h"}
fn main() {}
build.rs:
fn main() {
autocxx_build::Builder::new("src/main.rs", ["src"])
.custom_gendir("src/subdirectory/".into()) // <-- Comment this line
.build().unwrap().compile("compute");
}
The custom_gendir(...) generates code to directory src/subdirectory as expected, but following compile error is thrown:
error: couldn't read
src/src/subdirectory/rs/autocxx-ffi-default-gen.rs: No such file or directory (os error 2)
--> src/main.rs:2:1
|
2 | include_cpp! {}
| ^^^^^^^^^^^^^^^
|
= note: this error originates in the macroincludewhich comes from the expansion of the macroinclude_cpp(in Nightly builds, run with -Z macro-backtrace for more info)error: could not compile
my_autocxx(bin "my_autocxx") due to 1 previous error
That is, include tries to read from src/src/subdirectory rather than from src/subdirectory where the code was generated.
Workaround
Create a symlink that directs to the correct directory