pw_build: Support symlinks in mirror_tree.py

The source path needs to be resolved before linking it in case it is a
symlink.

Change-Id: I394cbefc3ab2092a814cd74aa9d22d92050b7b5b
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/39220
Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com>
Commit-Queue: Rob Mohr <mohrr@google.com>
Reviewed-by: Rob Mohr <mohrr@google.com>
diff --git a/pw_build/py/pw_build/mirror_tree.py b/pw_build/py/pw_build/mirror_tree.py
index 8687af6..ef7e455 100644
--- a/pw_build/py/pw_build/mirror_tree.py
+++ b/pw_build/py/pw_build/mirror_tree.py
@@ -52,8 +52,9 @@
         if dest.exists():
             dest.unlink()
 
-        # Use a hard link to avoid unnecessary copies.
-        os.link(source, dest)
+        # Use a hard link to avoid unnecessary copies. Resolve the source before
+        # linking in case it is a symlink.
+        os.link(source.resolve(), dest)
 
         yield dest