summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--build.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/build.rs b/build.rs
index a6c5756..fcd166d 100644
--- a/build.rs
+++ b/build.rs
@@ -186,11 +186,17 @@ fn generate_asset_module(asset_paths: BTreeSet<PathBuf>) -> Result<()> {
     } else {
       Path::new(&source_dir).join(&asset_path).to_path_buf()
     };
+
     let mut include_path = include_path.to_path_buf();
-    include_path = include_path.strip_prefix(&source_dir)?.to_path_buf();
-    for _ in Path::new(&out_dir).strip_prefix(&source_dir)?.components() {
-      include_path = Path::new("../").join(include_path).to_path_buf();
+    if include_path.starts_with(&out_dir) {
+      include_path = include_path.strip_prefix(&out_dir)?.to_path_buf();
+    } else {
+      include_path = include_path.strip_prefix(&source_dir)?.to_path_buf();
+      for _ in Path::new(&out_dir).strip_prefix(&source_dir)?.components() {
+        include_path = Path::new("../").join(include_path).to_path_buf();
+      }
     }
+
     let include_path = include_path
             .to_str()
             .ok_or(Error("Can't stringify path - weird filesystem?"