Skip to content

Commit dc4c31e

Browse files
committed
Build using relative path in repo if Windows lost symlink
1 parent b53ebef commit dc4c31e

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

serde_derive_internals/build.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
use std::path::Path;
2+
3+
fn main() {
4+
// Sometimes on Windows the git checkout does not correctly wire up the
5+
// symlink from serde_derive_internals/src to serde_derive/src/internals.
6+
// When this happens we'll just build based on relative paths within the git
7+
// repo.
8+
let mod_behind_symlink = Path::new("src/mod.rs");
9+
if !mod_behind_symlink.exists() {
10+
println!("cargo:rustc-cfg=serde_build_from_git");
11+
}
12+
}

serde_derive_internals/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ extern crate syn;
4040
extern crate proc_macro2;
4141
extern crate quote;
4242

43-
#[path = "src/mod.rs"]
43+
#[cfg_attr(serde_build_from_git, path = "../serde_derive/src/internals/mod.rs")]
44+
#[cfg_attr(not(serde_build_from_git), path = "src/mod.rs")]
4445
mod internals;
4546

4647
pub use internals::*;

0 commit comments

Comments
 (0)