aboutsummaryrefslogtreecommitdiff
path: root/build2/bin
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-07-27 14:45:05 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-07-27 14:45:05 +0200
commitbf959a7fc119f9156c4b84c9d0a10900d9153f8d (patch)
treed19b96238f58e305d936d186901edd1cf98e0c93 /build2/bin
parent24f74ea70a19ccd7bcb489853fc73a972ab8638f (diff)
Initial infrastructure for utility libraries
Diffstat (limited to 'build2/bin')
-rw-r--r--build2/bin/init.cxx27
-rw-r--r--build2/bin/rule.cxx27
-rw-r--r--build2/bin/rule.hxx18
-rw-r--r--build2/bin/target.cxx78
-rw-r--r--build2/bin/target.hxx71
5 files changed, 173 insertions, 48 deletions
diff --git a/build2/bin/init.cxx b/build2/bin/init.cxx
index 71c580b..fb9dd71 100644
--- a/build2/bin/init.cxx
+++ b/build2/bin/init.cxx
@@ -24,8 +24,7 @@ namespace build2
{
namespace bin
{
- static const obj_rule obj_;
- static const bmi_rule bmi_;
+ static const fail_rule fail_;
static const lib_rule lib_;
// Default config.bin.*.lib values.
@@ -368,10 +367,17 @@ namespace build2
t.insert<bmia> ();
t.insert<bmis> ();
+ t.insert<libu> ();
+ t.insert<libue> ();
+ t.insert<libua> ();
+ t.insert<libus> ();
+
t.insert<lib> ();
t.insert<liba> ();
t.insert<libs> ();
+ // Note: libu*{} are not installable.
+ //
if (install_loaded)
{
install_path<liba> (bs, dir_path ("lib")); // Install in install.lib.
@@ -422,22 +428,25 @@ namespace build2
{
auto& r (bs.rules);
- r.insert<obj> (perform_update_id, "bin.obj", obj_);
- r.insert<obj> (perform_clean_id, "bin.obj", obj_);
+ r.insert<obj> (perform_update_id, "bin.obj", fail_);
+ r.insert<obj> (perform_clean_id, "bin.obj", fail_);
+
+ r.insert<bmi> (perform_update_id, "bin.bmi", fail_);
+ r.insert<bmi> (perform_clean_id, "bin.bmi", fail_);
- r.insert<bmi> (perform_update_id, "bin.bmi", bmi_);
- r.insert<bmi> (perform_clean_id, "bin.bmi", bmi_);
+ r.insert<libu> (perform_update_id, "bin.libu", fail_);
+ r.insert<libu> (perform_clean_id, "bin.libu", fail_);
r.insert<lib> (perform_update_id, "bin.lib", lib_);
- r.insert<lib> (perform_clean_id, "bin.lib", lib_);
+ r.insert<lib> (perform_clean_id, "bin.lib", lib_);
- // Configure member.
+ // Configure members.
//
r.insert<lib> (configure_update_id, "bin.lib", lib_);
if (install_loaded)
{
- r.insert<lib> (perform_install_id, "bin.lib", lib_);
+ r.insert<lib> (perform_install_id, "bin.lib", lib_);
r.insert<lib> (perform_uninstall_id, "bin.lib", lib_);
}
}
diff --git a/build2/bin/rule.cxx b/build2/bin/rule.cxx
index b6e5a53..bb9036b 100644
--- a/build2/bin/rule.cxx
+++ b/build2/bin/rule.cxx
@@ -17,35 +17,22 @@ namespace build2
{
namespace bin
{
- // obj
+ // fail_rule
//
- match_result obj_rule::
+ match_result fail_rule::
match (action a, target& t, const string&) const
{
- fail << diag_doing (a, t) << " target group" <<
- info << "explicitly select obje{}, obja{}, or objs{} member";
-
- return false;
- }
-
- recipe obj_rule::
- apply (action, target&) const {return empty_recipe;}
+ const char* n (t.dynamic_type ().name); // Ignore derived type.
- // bmi
- //
- match_result bmi_rule::
- match (action a, target& t, const string&) const
- {
fail << diag_doing (a, t) << " target group" <<
- info << "explicitly select bmie{}, bmia{}, or bmis{} member";
-
- return false;
+ info << "explicitly select " << n << "e{}, " << n << "a{}, or "
+ << n << "s{} member" << endf;
}
- recipe bmi_rule::
+ recipe fail_rule::
apply (action, target&) const {return empty_recipe;}
- // lib
+ // lib_rule
//
// The whole logic is pretty much as if we had our two group members as
// our prerequisites.
diff --git a/build2/bin/rule.hxx b/build2/bin/rule.hxx
index 4637479..b4835dc 100644
--- a/build2/bin/rule.hxx
+++ b/build2/bin/rule.hxx
@@ -14,22 +14,12 @@ namespace build2
{
namespace bin
{
- class obj_rule: public rule
+ // Fail rule for obj{}, bmi{}, and libu{}.
+ //
+ class fail_rule: public rule
{
public:
- obj_rule () {}
-
- virtual match_result
- match (action, target&, const string&) const override;
-
- virtual recipe
- apply (action, target&) const override;
- };
-
- class bmi_rule: public rule
- {
- public:
- bmi_rule () {}
+ fail_rule () {}
virtual match_result
match (action, target&, const string&) const override;
diff --git a/build2/bin/target.cxx b/build2/bin/target.cxx
index f0e0152..aa37202 100644
--- a/build2/bin/target.cxx
+++ b/build2/bin/target.cxx
@@ -10,6 +10,30 @@ namespace build2
{
namespace bin
{
+ const target_type libx::static_type
+ {
+ "libx",
+ &target::static_type,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ &target_search,
+ false
+ };
+
+ const target_type libux::static_type
+ {
+ "libux",
+ &file::static_type,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ &target_search,
+ false
+ };
+
// Note that we link groups during the load phase since this is often
// relied upon when setting target-specific variables (e.g., we may set a
// common value for lib{} and then append liba/libs-specific values to
@@ -19,7 +43,7 @@ namespace build2
extern const char ext_var[] = "extension"; // VC14 rejects constexpr.
- // obj*{} and bmi*{} member factory.
+ // obj*{}, bmi*{}, libu*{} member factory.
//
template <typename M, typename G>
static pair<target*, optional<string>>
@@ -61,6 +85,18 @@ namespace build2
false
};
+ const target_type libue::static_type
+ {
+ "libue",
+ &libux::static_type,
+ &m_factory<libue, libu>,
+ &target_extension_var<ext_var, nullptr>,
+ &target_pattern_var<ext_var, nullptr>,
+ nullptr,
+ &target_search, // Note: not _file(); don't look for an existing file.
+ false
+ };
+
const target_type obja::static_type
{
"obja",
@@ -85,6 +121,18 @@ namespace build2
false
};
+ const target_type libua::static_type
+ {
+ "libua",
+ &libux::static_type,
+ &m_factory<libua, libu>,
+ &target_extension_var<ext_var, nullptr>,
+ &target_pattern_var<ext_var, nullptr>,
+ nullptr,
+ &target_search, // Note: not _file(); don't look for an existing file.
+ false
+ };
+
const target_type objs::static_type
{
"objs",
@@ -109,7 +157,19 @@ namespace build2
false
};
- // obj{} and bmi{} group factory.
+ const target_type libus::static_type
+ {
+ "libus",
+ &libux::static_type,
+ &m_factory<libus, libu>,
+ &target_extension_var<ext_var, nullptr>,
+ &target_pattern_var<ext_var, nullptr>,
+ nullptr,
+ &target_search, // Note: not _file(); don't look for an existing file.
+ false
+ };
+
+ // obj{}, bmi{}, and libu{} group factory.
//
template <typename G, typename E, typename A, typename S>
static pair<target*, optional<string>>
@@ -164,6 +224,18 @@ namespace build2
false
};
+ const target_type libu::static_type
+ {
+ "libu",
+ &libx::static_type,
+ &g_factory<libu, libue, libua, libus>,
+ nullptr,
+ nullptr,
+ nullptr,
+ &target_search,
+ false
+ };
+
// What extensions should we use? At the outset, this is platform-
// dependent. And if we consider cross-compilation, is it build or
// host-dependent? Feels like it should be host-dependent so that
@@ -238,7 +310,7 @@ namespace build2
const target_type lib::static_type
{
"lib",
- &target::static_type,
+ &libx::static_type,
&lib_factory,
nullptr,
nullptr,
diff --git a/build2/bin/target.hxx b/build2/bin/target.hxx
index 13d7596..e0c0358 100644
--- a/build2/bin/target.hxx
+++ b/build2/bin/target.hxx
@@ -117,6 +117,73 @@ namespace build2
virtual const target_type& dynamic_type () const {return static_type;}
};
+ // Common base for lib{} and libu{} groups.
+ //
+ class libx: public target
+ {
+ public:
+ using target::target;
+
+ public:
+ static const target_type static_type;
+ };
+
+ // The libu{} target group (utility library).
+ //
+ // All the members are static libraries that differ base on the kind of
+ // object files they contains. Note that the group is more like obj{}
+ // rather than lib{} in that one does not build the group directly rather
+ // picking a suitable member.
+ //
+ class libux: public file // Common base of all libuX{} static libraries.
+ {
+ public:
+ using file::file;
+
+ public:
+ static const target_type static_type;
+ };
+
+ class libue: public libux
+ {
+ public:
+ using libux::libux;
+
+ public:
+ static const target_type static_type;
+ virtual const target_type& dynamic_type () const {return static_type;}
+ };
+
+ class libua: public libux
+ {
+ public:
+ using libux::libux;
+
+ public:
+ static const target_type static_type;
+ virtual const target_type& dynamic_type () const {return static_type;}
+ };
+
+ class libus: public libux
+ {
+ public:
+ using libux::libux;
+
+ public:
+ static const target_type static_type;
+ virtual const target_type& dynamic_type () const {return static_type;}
+ };
+
+ class libu: public libx
+ {
+ public:
+ using libx::libx;
+
+ public:
+ static const target_type static_type;
+ virtual const target_type& dynamic_type () const {return static_type;}
+ };
+
// The lib{} target group.
//
class liba: public file
@@ -149,10 +216,10 @@ namespace build2
const libs* s = nullptr;
};
- class lib: public target, public lib_members
+ class lib: public libx, public lib_members
{
public:
- using target::target;
+ using libx::libx;
virtual group_view
group_members (action_type) const override;