aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-06-29 08:45:09 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-06-29 08:45:09 +0200
commit7daa7916182025d737f439da5fe5d67fe1a2fb8c (patch)
tree7604da6f22d2262dbdddd60053cc897dc5b478b3
parentd1d28c5f261e39013b8b987d58b3c0acaa8c762b (diff)
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/
-rw-r--r--doc/manual.cli1
-rw-r--r--libbuild2/context.cxx1
-rw-r--r--libbuild2/install/init.cxx24
-rw-r--r--libbuild2/target.cxx13
-rw-r--r--libbuild2/target.hxx14
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/<project>/ config.install.data
include data_root/include/ config.install.include
doc data_root/share/doc/<project>/ config.install.doc
+legal doc/ config.install.legal
man data_root/share/man/ config.install.man
man<N> man/man<N>/ config.install.man<N>
\
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<fsdir> ();
t.insert<exe> ();
t.insert<doc> ();
+ t.insert<legal> ();
t.insert<man> ();
t.insert<man1> ();
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<exe> (bs, dir_path ("bin")); // Install into install.bin.
- install_path<doc> (bs, dir_path ("doc")); // Install into install.doc.
- install_path<man> (bs, dir_path ("man")); // Install into install.man.
- install_path<man1> (bs, dir_path ("man1")); // Install into install.man1.
+ install_path<exe> (bs, dir_path ("bin"));
+ install_path<doc> (bs, dir_path ("doc"));
+ install_path<legal> (bs, dir_path ("legal"));
+ install_path<man> (bs, dir_path ("man"));
+ install_path<man1> (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<legal>,
+ &target_extension_fix<file_ext_def>, // 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