Skip to content

Unpredictable output path for generated files #949

Closed
@emartinfigma

Description

@emartinfigma

We are trying to integrate cxx into a larger CMake-based build system.

Following some other examples we have a build.rs that contains:

fn main() {
    let _ = cxx_build::bridge("src/lib.rs");
}

Ultimately cmake generates a command line that looks like:

cargo build --target-dir /.../build/emscripten-1.40.1/rust --target=wasm32-unknown-emscripten --release

What's super confusing here is that, when executed by Ninja (which prints the command line it's running), that ends up writing lib.rs.cc/.h under

build/emscripten-1.40.1/rust/cxxbridge/...

but if I copy paste the same command from the command line, it puts them under

build/emscripten-1.40.1/rust/wasm32-unknown-emscripten/cxxbridge/...

In both cases, they contain a directory tree like

├── cxxbridge
│   ├── fullscreen-link (our crate name)
│   │   └── src
│   │       ├── lib.rs.cc -> ...symlink to a file in the build output that has a hash in the name...

For the life of me I cannot figure out what is the difference between how these two commands are run. It must be obeying some environment variable or something? Could the names of the path components leading up to the input or output dir matter? What else can I investigate to try figure out the cause of this?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    integrationHow cxx fits into the big picture of an organization's codebase and builds

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions