aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build2/context.cxx5
-rw-r--r--build2/target.cxx44
-rw-r--r--build2/target.hxx17
-rw-r--r--buildfile2
4 files changed, 65 insertions, 3 deletions
diff --git a/build2/context.cxx b/build2/context.cxx
index 7067d8f..95230a6 100644
--- a/build2/context.cxx
+++ b/build2/context.cxx
@@ -526,6 +526,11 @@ namespace build2
t.insert<man1> ();
{
+ auto& tt (t.insert<manifest> ());
+ t.insert_file ("manifest", tt);
+ }
+
+ {
auto& tt (t.insert<buildfile> ());
t.insert_file ("buildfile", tt);
}
diff --git a/build2/target.cxx b/build2/target.cxx
index 201bd15..13db67e 100644
--- a/build2/target.cxx
+++ b/build2/target.cxx
@@ -1035,4 +1035,48 @@ namespace build2
&file_search,
false
};
+
+ static const char*
+ manifest_target_extension (const target_key& tk)
+ {
+ // If the name is special 'manifest', then there is no extension,
+ // otherwise it is .manifest.
+ //
+ return *tk.name == "manifest" ? "" : "manifest";
+ }
+
+ static bool
+ manifest_target_pattern (const target_type&,
+ const scope&,
+ string& v,
+ bool r)
+ {
+ size_t p (path::traits::find_extension (v));
+
+ if (r)
+ {
+ assert (p != string::npos);
+ v.resize (p);
+ }
+ else if (p == string::npos && v != "manifest")
+ {
+ v += ".manifest";
+ return true;
+ }
+
+ return false;
+ }
+
+ const target_type manifest::static_type
+ {
+ "manifest",
+ &doc::static_type,
+ &target_factory<manifest>,
+ &manifest_target_extension,
+ nullptr, /* default_extension */
+ &manifest_target_pattern,
+ nullptr,
+ &file_search,
+ false
+ };
}
diff --git a/build2/target.hxx b/build2/target.hxx
index 2f32064..05a748c 100644
--- a/build2/target.hxx
+++ b/build2/target.hxx
@@ -1626,8 +1626,6 @@ namespace build2
// Common documentation file targets.
//
- // @@ Maybe these should be in the built-in doc module?
- //
class doc: public file
{
public:
@@ -1692,6 +1690,21 @@ namespace build2
virtual const target_type& dynamic_type () const {return static_type;}
};
+ // We derive manifest from doc rather than file so that it get automatically
+ // installed into the same place where the rest of the documentation goes.
+ // If you think about it, it's kind of a documentation, similar to (but
+ // better than) the version file that many projects come with.
+ //
+ class manifest: public doc
+ {
+ public:
+ using doc::doc;
+
+ public:
+ static const target_type static_type;
+ virtual const target_type& dynamic_type () const {return static_type;}
+ };
+
// Common implementation of the target factory, extension, and search
// functions.
//
diff --git a/buildfile b/buildfile
index 7c129d8..38c95ce 100644
--- a/buildfile
+++ b/buildfile
@@ -4,7 +4,7 @@
./: {*/ -build/ -config/ -old-tests/} \
doc{INSTALL LICENSE NEWS README version} \
- file{INSTALL.cli bootstrap* config.guess config.sub manifest}
+ file{INSTALL.cli bootstrap* config.guess config.sub} manifest
# The version file is auto-generated (by the version module) from manifest.
# Include it in distribution and don't remove when cleaning in src (so that