From 01d848149c22a69a62eada5fedc2406c54d95ba8 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 5 Apr 2019 09:41:18 +0200 Subject: Support for --dry-run|-n mode, perform update part --- build2/cc/windows-rpath.cxx | 67 ++++++++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 25 deletions(-) (limited to 'build2/cc/windows-rpath.cxx') diff --git a/build2/cc/windows-rpath.cxx b/build2/cc/windows-rpath.cxx index 46fe75b..0a19db2 100644 --- a/build2/cc/windows-rpath.cxx +++ b/build2/cc/windows-rpath.cxx @@ -290,23 +290,9 @@ namespace build2 mkdir (ad, 3); } - const char* pa (windows_manifest_arch (tcpu)); - - if (verb >= 3) - text << "cat >" << am; - - try + // Symlink or copy the DLLs. + // { - ofdstream ofs (am); - - ofs << "\n" - << "\n" - << " \n"; - const scope& as (*t.root_scope ().weak_scope ()); // Amalgamation. auto link = [&as, &ad] (const path& f, const path& l) @@ -328,15 +314,20 @@ namespace build2 // part of the same amalgamation. This way if the amalgamation is // moved as a whole, the links will remain valid. // - if (f.sub (as.out_path ())) - mksymlink (f.relative (ad), l); - else - mksymlink (f, l); + if (!dry_run) + { + if (f.sub (as.out_path ())) + mksymlink (f.relative (ad), l); + else + mksymlink (f, l); + } print ("ln -s"); } catch (const system_error& e) { + // Note: can never end up here on dry-run. + // Note that we are not guaranteed (here and below) that the // system_error exception is of the generic category. // @@ -378,7 +369,6 @@ namespace build2 } } } - }; for (const windows_dll& wd: dlls) @@ -398,13 +388,40 @@ namespace build2 path pp (*wd.pdb); link (pp, ad / pp.leaf ()); } - - ofs << " \n"; } + } + + if (verb >= 3) + text << "cat >" << am; + + if (dry_run) + return; + + auto_rmfile rm (am); + + try + { + ofdstream os (am); + + const char* pa (windows_manifest_arch (tcpu)); + + os << "\n" + << "\n" + << " \n"; + + + + for (const windows_dll& wd: dlls) + os << " \n"; - ofs << "\n"; + os << "\n"; - ofs.close (); + os.close (); + rm.cancel (); } catch (const io_error& e) { -- cgit v1.1