From a84ff43b183181e0a12c6d5e31c1f366d39ce2fe Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 31 Jul 2017 18:42:47 +0200 Subject: Experimental (and probably broken) pkg-config generation support --- build2/install/init.cxx | 10 ++++---- build2/install/rule.cxx | 60 +++++++++++++++++++++++++++------------------- build2/install/rule.hxx | 8 ++++++- build2/install/utility.hxx | 6 +++++ 4 files changed, 55 insertions(+), 29 deletions(-) (limited to 'build2/install') diff --git a/build2/install/init.cxx b/build2/install/init.cxx index 1d51be2..0e8118a 100644 --- a/build2/install/init.cxx +++ b/build2/install/init.cxx @@ -141,10 +141,11 @@ namespace build2 static const dir_path dir_root ("root"); - static const dir_path dir_sbin (dir_path ("exec_root") /= "sbin"); - static const dir_path dir_bin (dir_path ("exec_root") /= "bin"); - static const dir_path dir_lib (dir_path ("exec_root") /= "lib"); - static const dir_path dir_libexec (dir_path ("exec_root") /= "libexec"); + static const dir_path dir_sbin (dir_path ("exec_root") /= "sbin"); + static const dir_path dir_bin (dir_path ("exec_root") /= "bin"); + static const dir_path dir_lib (dir_path ("exec_root") /= "lib"); + static const dir_path dir_libexec (dir_path ("exec_root") /= "libexec"); + static const dir_path dir_pkgconfig (dir_path ("lib") /= "pkgconfig"); static const dir_path dir_data (dir_path ("data_root") /= "share"); static const dir_path dir_include (dir_path ("data_root") /= "include"); @@ -240,6 +241,7 @@ namespace build2 set_dir (s, rs, "bin", dir_bin); set_dir (s, rs, "lib", dir_lib); set_dir (s, rs, "libexec", dir_path (dir_libexec) /= n, true); + set_dir (s, rs, "pkgconfig", dir_pkgconfig, false, "644"); set_dir (s, rs, "data", dir_path (dir_data) /= n, true); set_dir (s, rs, "include", dir_include); diff --git a/build2/install/rule.cxx b/build2/install/rule.cxx index f2fc233..6b75cea 100644 --- a/build2/install/rule.cxx +++ b/build2/install/rule.cxx @@ -199,35 +199,30 @@ namespace build2 // if (a.operation () == update_id) { - // Save the prerequisite targets that we found since the - // call to match_delegate() below will wipe them out. + // Save the prerequisite targets that we found since the call to + // match_delegate() below will wipe them out. // prerequisite_targets pts; + pts.swap (t.prerequisite_targets); - if (!t.prerequisite_targets.empty ()) - pts.swap (t.prerequisite_targets); - - // Find the "real" update rule, that is, the rule that would - // have been found if we signalled that we do not match from - // match() above. + // Find the "real" update rule, that is, the rule that would have been + // found if we signalled that we do not match from match() above. // recipe d (match_delegate (a, t, *this).first); - // If we have no installable prerequisites, then simply redirect - // to it. - // - if (pts.empty ()) - return d; - - // Ok, the worst case scenario: we need to cause update of - // prerequisite targets and also delegate to the real update. - // - return [pts = move (pts), d = move (d)] ( - action a, const target& t) mutable -> target_state + return [pts = move (pts), d = move (d), this] + (action a, const target& t) mutable -> target_state { - // Do the target update first. + // Do the target update first (we cannot call noop_recipe). // - target_state r (execute_delegate (d, a, t)); + recipe_function** f (d.target ()); + target_state r (f != nullptr && *f == &noop_action + ? target_state::unchanged + : execute_delegate (d, a, t)); + + // Then the extra hook. + // + r |= update_extra (a, t); // Swap our prerequisite targets back in and execute. // @@ -251,10 +246,21 @@ namespace build2 } void file_rule:: - install_extra (const file&, const install_dir&) const {} + install_extra (const file&, const install_dir&) const + { + } bool file_rule:: - uninstall_extra (const file&, const install_dir&) const {return false;} + uninstall_extra (const file&, const install_dir&) const + { + return false; + } + + target_state file_rule:: + update_extra (action, const target&) const + { + return target_state::unchanged; + } struct install_dir { @@ -296,7 +302,7 @@ namespace build2 // for (const scope* p (&s); p != nullptr; p = p->parent_scope ()) { - if (l.belongs (*p)) // Ok since no target/type in lookup. + if (l.belongs (*p, true)) // Include target type/pattern-specific. { // The target can be in out or src. // @@ -388,6 +394,12 @@ namespace build2 return rs; } + dir_path + resolve_dir (const target& t, dir_path d) + { + return move (resolve (t, move (d)).back ().dir); + } + // On Windows we use MSYS2 install.exe and MSYS2 by default ignores // filesystem permissions (noacl mount option). And this means, for // example, that .exe that we install won't be runnable by Windows (MSYS2 diff --git a/build2/install/rule.hxx b/build2/install/rule.hxx index ad0d8ec..617beab 100644 --- a/build2/install/rule.hxx +++ b/build2/install/rule.hxx @@ -70,6 +70,12 @@ namespace build2 virtual bool uninstall_extra (const file&, const install_dir&) const; + // Extra update for install hooks. It is executed after the target has + // been updated but only for those that will actually be installed. + // + virtual target_state + update_extra (action, const target&) const; + // Installation "commands". // // If verbose is false, then only print the command at verbosity level 2 @@ -98,7 +104,7 @@ namespace build2 const path& name, bool verbose); - private: + protected: target_state perform_install (action, const target&) const; diff --git a/build2/install/utility.hxx b/build2/install/utility.hxx index dfd1915..21c0c44 100644 --- a/build2/install/utility.hxx +++ b/build2/install/utility.hxx @@ -51,6 +51,12 @@ namespace build2 { return install_mode (s, T::static_type, move (m)); } + + // Resolve relative installation directory path (e.g., include/libfoo) to + // its absolute directory path (e.g., /usr/include/libfoo). + // + dir_path + resolve_dir (const target&, dir_path); // rule.cxx } } -- cgit v1.1