From 7daa7916182025d737f439da5fe5d67fe1a2fb8c Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 29 Jun 2020 08:45:09 +0200 Subject: Add legal{} target type and config.install.legal variable This allows separation of legal files (LICENSE, AUTHORS, etc) from other documentation. For example: ./: ... doc{README} legal{LICENSE} $ b install ... config.install.legal=/usr/share/licenses/hello/ --- doc/manual.cli | 1 + libbuild2/context.cxx | 1 + libbuild2/install/init.cxx | 24 ++++++++++++++---------- libbuild2/target.cxx | 13 +++++++++++++ libbuild2/target.hxx | 14 +++++++++++++- 5 files changed, 42 insertions(+), 11 deletions(-) diff --git a/doc/manual.cli b/doc/manual.cli index c0ae061..104d6cd 100644 --- a/doc/manual.cli +++ b/doc/manual.cli @@ -2248,6 +2248,7 @@ data data_root/share// config.install.data include data_root/include/ config.install.include doc data_root/share/doc// config.install.doc +legal doc/ config.install.legal man data_root/share/man/ config.install.man man man/man/ config.install.man \ diff --git a/libbuild2/context.cxx b/libbuild2/context.cxx index 202cd35..d62965c 100644 --- a/libbuild2/context.cxx +++ b/libbuild2/context.cxx @@ -264,6 +264,7 @@ namespace build2 t.insert (); t.insert (); t.insert (); + t.insert (); t.insert (); t.insert (); diff --git a/libbuild2/install/init.cxx b/libbuild2/install/init.cxx index d0fb4bc..480eec4 100644 --- a/libbuild2/install/init.cxx +++ b/libbuild2/install/init.cxx @@ -150,7 +150,8 @@ namespace build2 static const path cmd ("install"); - static const dir_path dir_root ("root"); + static const dir_path dir_data_root ("root"); + static const dir_path dir_exec_root ("root"); static const dir_path dir_sbin (dir_path ("exec_root") /= "sbin"); static const dir_path dir_bin (dir_path ("exec_root") /= "bin"); @@ -161,9 +162,10 @@ namespace build2 static const dir_path dir_data (dir_path ("data_root") /= "share"); static const dir_path dir_include (dir_path ("data_root") /= "include"); - static const dir_path dir_doc (dir_path (dir_data) /= "doc"); - static const dir_path dir_man (dir_path (dir_data) /= "man"); - static const dir_path dir_man1 (dir_path ("man") /= "man1"); + static const dir_path dir_doc (dir_path (dir_data) /= "doc"); + static const dir_path dir_legal ("doc"); + static const dir_path dir_man (dir_path (dir_data) /= "man"); + static const dir_path dir_man1 (dir_path ("man") /= "man1"); static const group_rule group_rule_ (true /* see_through_only */); @@ -252,8 +254,8 @@ namespace build2 set_dir (s, rs, "root", abs_dir_path ()); - set_dir (s, rs, "data_root", dir_root); - set_dir (s, rs, "exec_root", dir_root, false, "755"); + set_dir (s, rs, "data_root", dir_data_root); + set_dir (s, rs, "exec_root", dir_exec_root, false, "755"); set_dir (s, rs, "sbin", dir_sbin); set_dir (s, rs, "bin", dir_bin); @@ -265,6 +267,7 @@ namespace build2 set_dir (s, rs, "include", dir_include); set_dir (s, rs, "doc", dir_path (dir_doc) /= n, true); + set_dir (s, rs, "legal", dir_legal); set_dir (s, rs, "man", dir_man); set_dir (s, rs, "man1", dir_man1); @@ -286,10 +289,11 @@ namespace build2 // Configure "installability" for built-in target types. // - install_path (bs, dir_path ("bin")); // Install into install.bin. - install_path (bs, dir_path ("doc")); // Install into install.doc. - install_path (bs, dir_path ("man")); // Install into install.man. - install_path (bs, dir_path ("man1")); // Install into install.man1. + install_path (bs, dir_path ("bin")); + install_path (bs, dir_path ("doc")); + install_path (bs, dir_path ("legal")); + install_path (bs, dir_path ("man")); + install_path (bs, dir_path ("man1")); return true; } diff --git a/libbuild2/target.cxx b/libbuild2/target.cxx index a543f34..232b0b1 100644 --- a/libbuild2/target.cxx +++ b/libbuild2/target.cxx @@ -1239,6 +1239,19 @@ namespace build2 false }; + const target_type legal::static_type + { + "legal", + &doc::static_type, + &target_factory, + &target_extension_fix, // Same as file (no extension). + nullptr, /* default_extension */ + nullptr, /* pattern */ // Same as file. + &target_print_1_ext_verb, // Same as file. + &file_search, + false + }; + static const char* man_extension (const target_key& tk, const scope*) { diff --git a/libbuild2/target.hxx b/libbuild2/target.hxx index d4b287b..a97097f 100644 --- a/libbuild2/target.hxx +++ b/libbuild2/target.hxx @@ -1756,7 +1756,7 @@ namespace build2 virtual const target_type& dynamic_type () const {return static_type;} }; - // Common documentation file targets. + // Common documentation file target. // class LIBBUILD2_SYMEXPORT doc: public file { @@ -1768,6 +1768,18 @@ namespace build2 virtual const target_type& dynamic_type () const {return static_type;} }; + // Legal files (LICENSE, AUTHORS, COPYRIGHT, etc). + // + class LIBBUILD2_SYMEXPORT legal: public doc + { + public: + using doc::doc; + + public: + static const target_type static_type; + virtual const target_type& dynamic_type () const {return static_type;} + }; + // The problem with man pages is this: different platforms have // different sets of sections. What seems to be the "sane" set // is 1-9 (Linux and BSDs). SysV (e.g., Solaris) instead maps -- cgit v1.1