From f303ec225c294c695711bead8310d3a7b23baade Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 15 Aug 2019 08:57:50 +0200 Subject: Implement libs_paths symlinking support on Windows Also, temporarily enable libs_paths::link on Windows for testing. --- build2/cc/link-rule.cxx | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) (limited to 'build2/cc/link-rule.cxx') diff --git a/build2/cc/link-rule.cxx b/build2/cc/link-rule.cxx index c9e4ee3..f2ee33f 100644 --- a/build2/cc/link-rule.cxx +++ b/build2/cc/link-rule.cxx @@ -413,6 +413,10 @@ namespace build2 append_ext (ip); li.derive_path (move (ip), tsys == "mingw32" ? "a" : "lib"); } + + //@@ TMP + lk = b; + append_ext (lk); } else if (!v.empty ()) { @@ -2823,7 +2827,8 @@ namespace build2 if (lt.shared_library ()) { - // For shared libraries we may need to create a bunch of symlinks. + // For shared libraries we may need to create a bunch of symlinks (or + // fallback to hardlinks/copies on Windows). // auto ln = [] (const path& f, const path& l) { @@ -2835,16 +2840,29 @@ namespace build2 try { - // The -f part. - // - if (file_exists (l, false /* follow_symlinks */)) - try_rmfile (l); + try + { + // The -f part. + // + if (file_exists (l, false /* follow_symlinks */)) + try_rmfile (l); - mksymlink (f, l); + mkanylink (f, l, true /* copy */); + } + catch (system_error& e) + { + throw pair (entry_type::symlink, + move (e)); + } } - catch (const system_error& e) + catch (const pair& e) { - fail << "unable to create symlink " << l << ": " << e; + const char* w (e.first == entry_type::regular ? "copy" : + e.first == entry_type::symlink ? "symlink" : + e.first == entry_type::other ? "hardlink" : + nullptr); + + fail << "unable to make " << w << ' ' << l << ": " << e.second; } }; -- cgit v1.1