aboutsummaryrefslogtreecommitdiff
path: root/build2/cc
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-05-15 12:57:38 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-05-15 12:57:38 +0200
commite0b72f24c3e7ea14dc8da54dc0bfc62f43334f3b (patch)
treea6fa29d4fd507592ec98fa56643c4775b835efe0 /build2/cc
parentfbc9a384e013fdb38b56f42e3850915474cb5785 (diff)
Cleanup clean_extra() mess (pun intended)
Diffstat (limited to 'build2/cc')
-rw-r--r--build2/cc/compile-rule.cxx13
-rw-r--r--build2/cc/link-rule.cxx92
2 files changed, 58 insertions, 47 deletions
diff --git a/build2/cc/compile-rule.cxx b/build2/cc/compile-rule.cxx
index 3458a1b..bdfa0f0 100644
--- a/build2/cc/compile-rule.cxx
+++ b/build2/cc/compile-rule.cxx
@@ -5880,18 +5880,17 @@ namespace build2
{
const file& t (xt.as<file> ());
- using ct = compiler_type;
+ clean_extras extras;
switch (ctype)
{
- case ct::gcc: return clean_extra (a, t, {".d", x_pext, ".t"});
- case ct::clang: return clean_extra (a, t, {".d", x_pext});
- case ct::msvc: return clean_extra (a, t, {".d", x_pext, ".idb", ".pdb"});
- case ct::icc: return clean_extra (a, t, {".d"});
+ case compiler_type::gcc: extras = {".d", x_pext, ".t"}; break;
+ case compiler_type::clang: extras = {".d", x_pext}; break;
+ case compiler_type::msvc: extras = {".d", x_pext, ".idb", ".pdb"};break;
+ case compiler_type::icc: extras = {".d"}; break;
}
- assert (false);
- return target_state::unchanged;
+ return perform_clean_extra (a, t, extras);
}
}
}
diff --git a/build2/cc/link-rule.cxx b/build2/cc/link-rule.cxx
index 0365a3b..80ba503 100644
--- a/build2/cc/link-rule.cxx
+++ b/build2/cc/link-rule.cxx
@@ -2780,65 +2780,77 @@ namespace build2
perform_clean (action a, const target& xt) const
{
const file& t (xt.as<file> ());
+
ltype lt (link_type (t));
+ const match_data& md (t.data<match_data> ());
- //@@ TODO add .t to clean if _WIN32 (currently that would be just too
- // messy).
+ clean_extras extras;
+ clean_adhoc_extras adhoc_extras;
- if (lt.executable ())
+ if (md.binless)
+ ; // Clean prerequsites/members.
+ else
{
- if (tclass == "windows")
+ if (tclass != "windows")
{
- if (tsys == "mingw32")
- return clean_extra (
- a, t, {".d", ".dlls/", ".manifest.o", ".manifest"});
- else
- // Assuming it's VC or alike. Clean up .ilk in case the user
- // enabled incremental linking (note that .ilk replaces .exe).
+ if (lt.shared_library ())
+ {
+ // Here we can have a bunch of symlinks that we need to remove. If
+ // the paths are empty, then they will be ignored.
//
- return clean_extra (
- a, t, {".d", ".dlls/", ".manifest", "-.ilk"});
- }
- // For other platforms it's the defaults.
- }
- else
- {
- const match_data& md (t.data<match_data> ());
+ const libs_paths& paths (md.libs_data);
- if (md.binless)
- return clean_extra (a, t, {nullptr}); // Clean prerequsites/members.
+ extras = {".d",
+ paths.link.string ().c_str (),
+ paths.soname.string ().c_str (),
+ paths.interm.string ().c_str ()};
+ }
- if (lt.shared_library ())
+ // For executable and static library it's the default.
+ }
+ else if (tsys == "mingw32")
{
- if (tclass == "windows")
+ if (lt.executable ())
{
- // Assuming it's VC or alike. Clean up .exp and .ilk.
+ extras = {".d", ".dlls/", ".manifest.o", ".manifest"};
+ }
+
+ // For shared and static library it's the default.
+ }
+ else
+ {
+ // Assuming MSVC or alike.
+ //
+ if (lt.executable ())
+ {
+ // Clean up .ilk in case the user enabled incremental linking
+ // (notice that the .ilk extension replaces .exe).
+ //
+ extras = {".d", ".dlls/", ".manifest", "-.ilk"};
+ }
+ else if (lt.shared_library ())
+ {
+ // Clean up .ilk and .exp.
//
// Note that .exp is based on the .lib, not .dll name. And with
// versioning their bases may not be the same.
//
- // @@ ADHOC: member order.
- //
- if (tsys != "mingw32")
- return clean_extra (a, t, {{".d", "-.ilk"}, {"-.exp"}});
+ extras = {".d", "-.ilk"};
+ adhoc_extras.push_back ({libi::static_type, {"-.exp"}});
}
- else
- {
- // Here we can have a bunch of symlinks that we need to remove. If
- // the paths are empty, then they will be ignored.
- //
- const libs_paths& paths (md.libs_data);
- return clean_extra (a, t, {".d",
- paths.link.string ().c_str (),
- paths.soname.string ().c_str (),
- paths.interm.string ().c_str ()});
- }
+ // For static library it's the default.
}
- // For static library it's the defaults.
+
+ if (extras.empty ())
+ extras = {".d"}; // Default.
+
+#ifdef _WIN32
+ extras.push_back (".t"); // Options file.
+#endif
}
- return clean_extra (a, t, {".d"});
+ return perform_clean_extra (a, t, extras, adhoc_extras);
}
}
}