From fed56805f58760883d590cd741a7597d4fc84600 Mon Sep 17 00:00:00 2001 From: Steve Pham <82231385+spham-amzn@users.noreply.github.com> Date: Tue, 18 May 2021 10:09:09 -0700 Subject: [PATCH] Fix issue with layout tool and symlinks on Mac (#791) * - Fix reversed symlink logic for Non-Windows file systems - Add additional logic to clear existing symlink if it exists before re-applying * Update to remove pre-existing reference regardless if its a symlink or not --- cmake/Tools/layout_tool.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmake/Tools/layout_tool.py b/cmake/Tools/layout_tool.py index 82d10f412f..8f573b61f5 100755 --- a/cmake/Tools/layout_tool.py +++ b/cmake/Tools/layout_tool.py @@ -333,7 +333,9 @@ def create_link(src:pathlib.Path, tgt:pathlib.Path, copy): import _winapi _winapi.CreateJunction(str(src), str(tgt)) else: - src.symlink_to(tgt, target_is_directory=True) + if tgt.exists(): + tgt.unlink() + tgt.symlink_to(src, target_is_directory=True) except OSError as e: raise common.LmbrCmdError(f"Error trying to create {link_type} {src} => {tgt} : {e}", e.errno)