summary refs log tree commit diff
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@irenes.space>2026-08-10 01:20:53 -0700
committerIrene Knapp <ireneista@irenes.space>2026-08-10 01:20:53 -0700
commit87f60b880bd1ce586972f9b70dd6c627b1df92cd (patch)
tree66eedf896f3df0398e2478c2024ba8ec12aec3f0
parentbbe9d5993bb922ad6b33a21c3557143cecaf960d (diff)
simpler include paths for assets in the output directory
Force-Push: yes
Change-Id: Iecc7163cab1bcfe3b4b6fa8f8f648e87f514b706
-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?"