From fd641f3f10499d4368822b0776ded4c47f152ae7 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 15 Jul 2016 08:30:31 +0200 Subject: Name and cleanup extra VC files (.pdb, .ilk, .idb) --- build2/cxx/compile.cxx | 57 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 51 insertions(+), 6 deletions(-) (limited to 'build2/cxx/compile.cxx') diff --git a/build2/cxx/compile.cxx b/build2/cxx/compile.cxx index 25416e8..504df7f 100644 --- a/build2/cxx/compile.cxx +++ b/build2/cxx/compile.cxx @@ -223,7 +223,7 @@ namespace build2 switch (a) { case perform_update_id: return &perform_update; - case perform_clean_id: return &perform_clean_depdb; + case perform_clean_id: return &perform_clean; default: return noop_recipe; // Configure update. } } @@ -1208,7 +1208,7 @@ namespace build2 append_options (args, t, "cxx.poptions"); append_options (args, t, "cxx.coptions"); - string std, out; // Storage. + string std, out, out1; // Storage. append_std (args, rs, cid, t, std); @@ -1219,11 +1219,38 @@ namespace build2 if (verb < 3) args.push_back ("/nologo"); - //@@ VC: What is the default value for /MP, should we override? - - // The /Fo: option (object file name) only became available in - // VS2013/12.0. + // The /F*: option variants with separate names only became available + // in VS2013/12.0. Why do we bother? Because the command line suddenly + // becomes readable. + + // The presence of /Zi or /ZI causes the compiler to write debug info + // to the .pdb file. By default it is a shared file called vcNN.pdb + // (where NN is the VC version) created (wait for it) in the current + // working directory (and not the directory of the .obj file). Also, + // because it is shared, there is a special Windows service that + // serializes access. We, of course, want none of that so we will + // create a .pdb per object file. + // + // Note that this also changes the name of the .idb file (used for + // minimal rebuild and incremental compilation) by taking /Fd value + // replacing the .pdb extension to .idb. + // + // Note also that what we are doing here appears to be incompatible + // with PCH (/Y* options) and /Gm (minimal rebuild). // + if (find_option ("/Zi", args) || find_option ("/ZI", args)) + { + if (cver >= 18) + args.push_back ("/Fd:"); + else + out1 = "/Fd"; + + out1 += relo.string (); + out1 += ".pdb"; + + args.push_back (out1.c_str ()); + } + if (cver >= 18) { args.push_back ("/Fo:"); @@ -1303,6 +1330,24 @@ namespace build2 } } + target_state compile:: + perform_clean (action a, target& xt) + { + file& t (static_cast (xt)); + + scope& rs (t.root_scope ()); + const string& cid (cast (rs["cxx.id"])); + + initializer_list e; + + if (cid == "msvc") + e = {"+.d", "+.idb", "+.pdb"}; + else + e = {"+.d"}; + + return clean_extra (a, t, e); + } + compile compile::instance; } } -- cgit v1.1