From e0b72f24c3e7ea14dc8da54dc0bfc62f43334f3b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 15 May 2019 12:57:38 +0200 Subject: Cleanup clean_extra() mess (pun intended) --- build2/cc/link-rule.cxx | 92 ++++++++++++++++++++++++++++--------------------- 1 file changed, 52 insertions(+), 40 deletions(-) (limited to 'build2/cc/link-rule.cxx') 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 ()); + ltype lt (link_type (t)); + const match_data& md (t.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 ()); + 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); } } } -- cgit v1.1