aboutsummaryrefslogtreecommitdiff
path: root/build/cli
diff options
context:
space:
mode:
Diffstat (limited to 'build/cli')
-rw-r--r--build/cli/rule.cxx43
-rw-r--r--build/cli/target26
-rw-r--r--build/cli/target.cxx6
3 files changed, 40 insertions, 35 deletions
diff --git a/build/cli/rule.cxx b/build/cli/rule.cxx
index 3bcd074..c0c8fe0 100644
--- a/build/cli/rule.cxx
+++ b/build/cli/rule.cxx
@@ -58,15 +58,13 @@ namespace build
// cli.options are possible and we can determine whether the
// --suppress-inline option is present.
//
- if (t.h () == nullptr)
+ if (t.h == nullptr)
{
- cxx::hxx& h (search<cxx::hxx> (t.dir, t.name, nullptr, nullptr));
- h.group = &t;
- t.h (h);
+ t.h = &search<cxx::hxx> (t.dir, t.name, nullptr, nullptr);
+ t.h->group = &t;
- cxx::cxx& c (search<cxx::cxx> (t.dir, t.name, nullptr, nullptr));
- c.group = &t;
- t.c (c);
+ t.c = & search<cxx::cxx> (t.dir, t.name, nullptr, nullptr);
+ t.c->group = &t;
bool inl (true);
if (auto val = t["cli.options"])
@@ -83,9 +81,8 @@ namespace build
if (inl)
{
- cxx::ixx& i (search<cxx::ixx> (t.dir, t.name, nullptr, nullptr));
- i.group = &t;
- t.i (i);
+ t.i = &search<cxx::ixx> (t.dir, t.name, nullptr, nullptr);
+ t.i->group = &t;
}
}
@@ -132,7 +129,7 @@ namespace build
// For ixx{}, verify it is part of the group.
//
- if (t.is_a<cxx::ixx> () && g->i () == nullptr)
+ if (t.is_a<cxx::ixx> () && g->i == nullptr)
{
level3 ([&]{trace << "generation of inline file " << t
<< " is disabled with --suppress-inline";});
@@ -154,10 +151,10 @@ namespace build
// Derive file names for the members.
//
- t.h ()->derive_path ();
- t.c ()->derive_path ();
- if (t.i () != nullptr)
- t.i ()->derive_path ();
+ t.h->derive_path ();
+ t.c->derive_path ();
+ if (t.i != nullptr)
+ t.i->derive_path ();
// Inject dependency on the output directory.
//
@@ -228,10 +225,10 @@ namespace build
// See if we need to pass any --?xx-suffix options.
//
- append_extension (args, *t.h (), "--hxx-suffix", "hxx");
- append_extension (args, *t.c (), "--cxx-suffix", "cxx");
- if (t.i () != nullptr)
- append_extension (args, *t.i (), "--ixx-suffix", "ixx");
+ append_extension (args, *t.h, "--hxx-suffix", "hxx");
+ append_extension (args, *t.c, "--cxx-suffix", "cxx");
+ if (t.i != nullptr)
+ append_extension (args, *t.i, "--ixx-suffix", "ixx");
append_options (args, t, "cli.options");
@@ -283,10 +280,10 @@ namespace build
//
bool r (false);
- if (t.i () != nullptr)
- r = rmfile (t.i ()->path (), *t.i ()) || r;
- r = rmfile (t.c ()->path (), *t.c ()) || r;
- r = rmfile (t.h ()->path (), *t.h ()) || r;
+ if (t.i != nullptr)
+ r = rmfile (t.i->path (), *t.i) || r;
+ r = rmfile (t.c->path (), *t.c) || r;
+ r = rmfile (t.h->path (), *t.h) || r;
t.mtime (timestamp_nonexistent);
diff --git a/build/cli/target b/build/cli/target
index d733668..a32f718 100644
--- a/build/cli/target
+++ b/build/cli/target
@@ -28,15 +28,23 @@ namespace build
public:
using mtime_target::mtime_target;
- target* m[3] {nullptr, nullptr, nullptr};
-
- cxx::hxx* h () const {return static_cast<cxx::hxx*> (m[0]);}
- cxx::cxx* c () const {return static_cast<cxx::cxx*> (m[1]);}
- cxx::ixx* i () const {return static_cast<cxx::ixx*> (m[2]);}
-
- void h (cxx::hxx& t) {m[0] = &t;}
- void c (cxx::cxx& t) {m[1] = &t;}
- void i (cxx::ixx& t) {m[2] = &t;}
+ union
+ {
+ // It is theoretically possible that the compiler will add
+ // padding between the members of this struct. This would
+ // mean that the optimal alignment for a pointer is greater
+ // than its size (and that an array of pointer is sub-
+ // optimally aligned). We will deal with such a beast of
+ // an architecture when we see it.
+ //
+ struct
+ {
+ cxx::hxx* h;
+ cxx::cxx* c;
+ cxx::ixx* i;
+ };
+ target* m[3] = {nullptr, nullptr, nullptr};
+ };
virtual group_view
group_members (action) const;
diff --git a/build/cli/target.cxx b/build/cli/target.cxx
index 2f8b54c..95198e1 100644
--- a/build/cli/target.cxx
+++ b/build/cli/target.cxx
@@ -32,8 +32,8 @@ namespace build
group_view cli_cxx::
group_members (action) const
{
- return m[0] != nullptr
- ? group_view {m, (m[2] != nullptr ? 3U : 2U)}
+ return h != nullptr
+ ? group_view {m, (i != nullptr ? 3U : 2U)}
: group_view {nullptr, 0};
}
@@ -43,7 +43,7 @@ namespace build
// The rule has been matched which means the members should
// be resolved and paths assigned.
//
- return file_mtime (h ()->path ());
+ return file_mtime (h->path ());
}
const target_type cli_cxx::static_type