mystor / rust-cpp

Embed C++ directly inside your rust code!
Apache License 2.0
795 stars 44 forks source link

Submodule skipping `mod.rs`, not found by `cpp_build`. #88

Closed rubdos closed 3 years ago

rubdos commented 3 years ago

Consider:

src/main.rs:

mod foo;

fn main() {
    println!("Hello, world!");
}

src/foo.rs:

mod bar;

src/foo/bar/mod.rs (empty)

The above compiles with just cargo build. Now add

build.rs:

fn main() {
    let mut cfg = cpp_build::Config::new();
    cfg.build("src/main.rs");
}

This does not compile. I do not know the name of this feature in new Rust versions, but it should probably work.

error: failed to run custom build command for `cpp-build-modules v0.1.0 (/tmp/cpp-build-modules)`

Caused by:
  process didn't exit successfully: `/tmp/cpp-build-modules/target/debug/build/cpp-build-modules-015f8b4ab4e5a60a/build-script-build` (exit code: 101)
  --- stderr
  thread 'main' panicked at 'No file with module definition for `mod bar` in file "src/foo.rs"', /home/rsmet/.cargo/registry/src/github.com-1ecc6299db9ec823/cpp_build-0.5.5/src/parser.rs:643:9
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed
ogoffart commented 3 years ago

Thanks for the bug report. Release cpp 0.5.6 which fixes this issue