Skip to content

Building on unix fails when targeting windows #13

@Rjected

Description

@Rjected

When building a project cross-platform that depends on crunchy:

cargo build --target x86_64-pc-windows-gnu

This currently fails with an error like this:

error: couldn't read /home/runner/work/reth/reth/target/x86_64-pc-windows-gnu/debug/build/crunchy-f1c0e4cba7d0aa5b/out\lib.rs: No such file or directory (os error 2)
  --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crunchy-0.2.3/src/lib.rs:37:1
   |
37 | include!(concat!(env!("OUT_DIR"), "\\lib.rs"));
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in the macro `include` (in Nightly builds, run with -Z macro-backtrace for more info)

error: could not compile `crunchy` (lib) due to 1 previous error

I'm not sure why the lib.rs needs to be included like this, but now any project that uses crunchy requires that the host path separator is the same as the target path separator.

crunchy/src/lib.rs

Lines 36 to 40 in df1e539

#[cfg(target_os = "windows")]
include!(concat!(env!("OUT_DIR"), "\\lib.rs"));
#[cfg(not(target_os = "windows"))]
include!(concat!(env!("OUT_DIR"), "/lib.rs"));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions