From 4776ab7859e71bb6cec004a1aea05324ad33fd1d Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 19 Aug 2016 15:35:06 +0200 Subject: Implement uninstall operation --- build2/cc/common | 7 ++++++- build2/cc/link.cxx | 14 ++++++++++---- build2/cc/module.cxx | 33 ++++++++++++++++++--------------- 3 files changed, 34 insertions(+), 20 deletions(-) (limited to 'build2/cc') diff --git a/build2/cc/common b/build2/cc/common index 95f205a..2be290a 100644 --- a/build2/cc/common +++ b/build2/cc/common @@ -84,6 +84,7 @@ namespace build2 const char* x_compile; // Rule names. const char* x_link; const char* x_install; + const char* x_uninstall; // Cached values for some commonly-used variables. // @@ -122,6 +123,7 @@ namespace build2 const char* compile, const char* link, const char* install, + const char* uninstall, const string& id, const string& tg, const string& sys, @@ -130,7 +132,10 @@ namespace build2 const target_type* const* hdr, const target_type* const* inc) : config_data (cd), - x_compile (compile), x_link (link), x_install (install), + x_compile (compile), + x_link (link), + x_install (install), + x_uninstall (uninstall), cid (id), ctg (tg), tsys (sys), tclass (class_), x_src (src), x_hdr (hdr), x_inc (inc) {} }; diff --git a/build2/cc/link.cxx b/build2/cc/link.cxx index df1fa7e..61dd0ad 100644 --- a/build2/cc/link.cxx +++ b/build2/cc/link.cxx @@ -595,8 +595,12 @@ namespace build2 // "library meta-information protocol". Don't do this if we are // called from the install rule just to check if we would match. // + auto op (a.operation ()); + auto oop (a.outer_operation ()); + if (seen_lib && lt != otype::e && - a.operation () != install_id && a.outer_operation () != install_id) + op != install_id && oop != install_id && + op != uninstall_id && oop != uninstall_id) { if (t.group != nullptr) t.group->prerequisite_targets.clear (); // lib{}'s @@ -1087,6 +1091,8 @@ namespace build2 { tracer trace (x, "link::perform_update"); + auto oop (a.outer_operation ()); + file& t (static_cast (xt)); scope& rs (t.root_scope ()); @@ -1107,7 +1113,7 @@ namespace build2 // assembly itself is generated later, after updating the target. Omit // it if we are updating for install. // - if (a.outer_operation () != install_id) + if (oop != install_id && oop != uninstall_id) rpath_timestamp = windows_rpath_timestamp (t); path mf ( @@ -1354,7 +1360,7 @@ namespace build2 { if (libs* ls = pt->is_a ()) { - if (a.outer_operation () != install_id) + if (oop != install_id && oop != uninstall_id) { sargs.push_back ("-Wl,-rpath," + ls->path ().directory ().string ()); @@ -1781,7 +1787,7 @@ namespace build2 // if (lt == otype::e && tclass == "windows") { - if (a.outer_operation () != install_id) + if (oop != install_id && oop != uninstall_id) windows_rpath_assembly (t, cast (rs[x_target_cpu]), rpath_timestamp, diff --git a/build2/cc/module.cxx b/build2/cc/module.cxx index ec7178b..d3849e1 100644 --- a/build2/cc/module.cxx +++ b/build2/cc/module.cxx @@ -307,30 +307,32 @@ namespace build2 link& lr (*this); install& ir (*this); - r.insert (perform_update_id, x_compile, cr); - r.insert (perform_clean_id, x_compile, cr); - r.insert (configure_update_id, x_compile, cr); + r.insert (perform_update_id, x_compile, cr); + r.insert (perform_clean_id, x_compile, cr); + r.insert (configure_update_id, x_compile, cr); - r.insert (perform_update_id, x_link, lr); - r.insert (perform_clean_id, x_link, lr); - r.insert (configure_update_id, x_link, lr); + r.insert (perform_update_id, x_link, lr); + r.insert (perform_clean_id, x_link, lr); + r.insert (configure_update_id, x_link, lr); - r.insert (perform_install_id, x_install, ir); + r.insert (perform_install_id, x_install, ir); + r.insert (perform_uninstall_id, x_uninstall, ir); // Only register static object/library rules if the bin.ar module is // loaded (by us or by the user). // if (cast_false (b["bin.ar.loaded"])) { - r.insert (perform_update_id, x_compile, cr); - r.insert (perform_clean_id, x_compile, cr); - r.insert (configure_update_id, x_compile, cr); + r.insert (perform_update_id, x_compile, cr); + r.insert (perform_clean_id, x_compile, cr); + r.insert (configure_update_id, x_compile, cr); - r.insert (perform_update_id, x_link, lr); - r.insert (perform_clean_id, x_link, lr); - r.insert (configure_update_id, x_link, lr); + r.insert (perform_update_id, x_link, lr); + r.insert (perform_clean_id, x_link, lr); + r.insert (configure_update_id, x_link, lr); - r.insert (perform_install_id, x_install, ir); + r.insert (perform_install_id, x_install, ir); + r.insert (perform_uninstall_id, x_uninstall, ir); } r.insert (perform_update_id, x_compile, cr); @@ -341,7 +343,8 @@ namespace build2 r.insert (perform_clean_id, x_link, lr); r.insert (configure_update_id, x_link, lr); - r.insert (perform_install_id, x_install, ir); + r.insert (perform_install_id, x_install, ir); + r.insert (perform_uninstall_id, x_uninstall, ir); } } } -- cgit v1.1