aboutsummaryrefslogtreecommitdiff
path: root/build2/cc
diff options
context:
space:
mode:
Diffstat (limited to 'build2/cc')
-rw-r--r--build2/cc/common.cxx3
-rw-r--r--build2/cc/common.hxx4
-rw-r--r--build2/cc/init.cxx24
-rw-r--r--build2/cc/link.cxx7
-rw-r--r--build2/cc/module.cxx16
-rw-r--r--build2/cc/pkgconfig.cxx13
-rw-r--r--build2/cc/target.cxx40
-rw-r--r--build2/cc/target.hxx31
8 files changed, 93 insertions, 45 deletions
diff --git a/build2/cc/common.cxx b/build2/cc/common.cxx
index e06898e..e022abb 100644
--- a/build2/cc/common.cxx
+++ b/build2/cc/common.cxx
@@ -869,8 +869,7 @@ namespace build2
// information. The idea is that when we auto-generate .pc files, we
// will copy those macros (or custom ones) from *.export.poptions.
//
- if (pkgconfig == nullptr ||
- !pkgconfig_load (act, *p.scope,
+ if (!pkgconfig_load (act, *p.scope,
*lt, a, s,
p.proj, name,
*pd, sysd, *usrd))
diff --git a/build2/cc/common.hxx b/build2/cc/common.hxx
index 5a245ca..3c4b693 100644
--- a/build2/cc/common.hxx
+++ b/build2/cc/common.hxx
@@ -120,7 +120,6 @@ namespace build2
bool modules; // x.features.modules
bool symexport; // x.features.symexport
- const process_path* pkgconfig; // pkgconfig.path (can be NULL).
const dir_paths& sys_lib_dirs; // x.sys_lib_dirs
const dir_paths& sys_inc_dirs; // x.sys_inc_dirs
@@ -163,7 +162,6 @@ namespace build2
const strings& std,
bool fm,
bool fs,
- const process_path* pkgc,
const dir_paths& sld,
const dir_paths& sid,
const target_type& src,
@@ -180,7 +178,7 @@ namespace build2
tstd (std),
modules (fm),
symexport (fs),
- pkgconfig (pkgc), sys_lib_dirs (sld), sys_inc_dirs (sid),
+ sys_lib_dirs (sld), sys_inc_dirs (sid),
x_src (src), x_mod (mod), x_hdr (hdr), x_inc (inc) {}
};
diff --git a/build2/cc/init.cxx b/build2/cc/init.cxx
index 733280a..7669add 100644
--- a/build2/cc/init.cxx
+++ b/build2/cc/init.cxx
@@ -105,8 +105,6 @@ namespace build2
assert (first);
- auto& vp (var_pool.rw (rs));
-
// Load cc.core.vars.
//
if (!cast_false<bool> (rs["cc.core.vars.loaded"]))
@@ -237,28 +235,6 @@ namespace build2
load_module (rs, rs, "bin.rc.config", loc);
}
- // Load (optionally) the pkgconfig module. Note that it registers the
- // pc{} target whether the pkg-config utility is found or not.
- //
- // @@ At some point we may also want to verify that targets matched
- // if it has already been loaded (by someone) else. Currently it
- // doesn't set pkgconfig.target. Perhaps only set if it was used
- // to derive the program name?
- //
- if (!cast_false<bool> (rs["pkgconfig.loaded"]))
- {
- // Prepare configuration hints.
- //
- variable_map h;
-
- // Note that this variable has not yet been registered.
- //
- const variable& t (vp.insert ("config.pkgconfig.target"));
- h.assign (t) = cast<target_triplet> (rs["cc.target"]);
-
- load_module (rs, rs, "pkgconfig", loc, true, h);
- }
-
return true;
}
diff --git a/build2/cc/link.cxx b/build2/cc/link.cxx
index 06c4bee..2f2ff76 100644
--- a/build2/cc/link.cxx
+++ b/build2/cc/link.cxx
@@ -19,9 +19,8 @@
#include <build2/diagnostics.hxx>
#include <build2/bin/target.hxx>
-#include <build2/pkgconfig/target.hxx>
-#include <build2/cc/target.hxx> // c
+#include <build2/cc/target.hxx> // c, pc*
#include <build2/cc/utility.hxx>
using namespace std;
@@ -464,9 +463,7 @@ namespace build2
target_lock pc (
add_adhoc_member (
act, t,
- ot == otype::a
- ? pkgconfig::pca::static_type
- : pkgconfig::pcs::static_type));
+ ot == otype::a ? pca::static_type : pcs::static_type));
// Note that here we always use the lib name prefix, even on
// Windows with VC. The reason is the user needs a consistent name
diff --git a/build2/cc/module.cxx b/build2/cc/module.cxx
index a18271c..0245def 100644
--- a/build2/cc/module.cxx
+++ b/build2/cc/module.cxx
@@ -12,6 +12,8 @@
#include <build2/bin/target.hxx>
+#include <build2/cc/target.hxx> // pc*
+
#include <build2/config/utility.hxx>
#include <build2/install/utility.hxx>
@@ -77,10 +79,10 @@ namespace build2
// Figure out which compiler we are dealing with, its target, etc.
//
const path& xc (cast<path> (*p.first));
- ci = cc::guess (x_lang,
- xc,
- cast_null<strings> (rs[config_c_coptions]),
- cast_null<strings> (rs[config_x_coptions]));
+ ci = build2::cc::guess (x_lang,
+ xc,
+ cast_null<strings> (rs[config_c_coptions]),
+ cast_null<strings> (rs[config_x_coptions]));
// Split/canonicalize the target. First see if the user asked us to
// use config.sub.
@@ -366,6 +368,12 @@ namespace build2
if (install_loaded)
install_path (rs, **ht, dir_path ("include"));
}
+
+ t.insert<pca> ();
+ t.insert<pcs> ();
+
+ if (install_loaded)
+ install_path<pc> (rs, dir_path ("pkgconfig"));
}
// Register rules.
diff --git a/build2/cc/pkgconfig.cxx b/build2/cc/pkgconfig.cxx
index 22ab774..f920dbd 100644
--- a/build2/cc/pkgconfig.cxx
+++ b/build2/cc/pkgconfig.cxx
@@ -20,9 +20,9 @@
#include <build2/install/utility.hxx>
#include <build2/bin/target.hxx>
-#include <build2/pkgconfig/target.hxx>
#include <build2/cc/types.hxx>
+#include <build2/cc/target.hxx> // pc
#include <build2/cc/utility.hxx>
#include <build2/cc/common.hxx>
@@ -464,7 +464,6 @@ namespace build2
{
tracer trace (x, "pkgconfig_load");
- assert (pkgconfig != nullptr);
assert (at != nullptr || st != nullptr);
// Iterate over pkgconf directories that correspond to the specified
@@ -1128,10 +1127,10 @@ namespace build2
const scope& bs (l.base_scope ());
const scope& rs (*bs.root_scope ());
- auto* pc (find_adhoc_member<pkgconfig::pc> (l));
- assert (pc != nullptr);
+ auto* t (find_adhoc_member<pc> (l));
+ assert (t != nullptr);
- const path& p (pc->path ());
+ const path& p (t->path ());
if (verb >= 2)
text << "cat >" << p;
@@ -1207,12 +1206,12 @@ namespace build2
n.erase (0, 3);
};
- if (auto* pc = find_adhoc_member<pkgconfig::pc> (l))
+ if (auto* t = find_adhoc_member<pc> (l))
{
// We also want to strip the lib prefix unless it is part of the
// target name while keeping custom library prefix/suffix, if any.
//
- n = pc->path ().leaf ().base ().base ().string ();
+ n = t->path ().leaf ().base ().base ().string ();
if (path::traits::compare (n.c_str (), n.size (),
l.name.c_str (), l.name.size ()) != 0)
diff --git a/build2/cc/target.cxx b/build2/cc/target.cxx
index 5fbf67d..6f8d541 100644
--- a/build2/cc/target.cxx
+++ b/build2/cc/target.cxx
@@ -49,5 +49,45 @@ namespace build2
&file_search,
false
};
+
+ const target_type pc::static_type
+ {
+ "pc",
+ &file::static_type,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ &target_search,
+ false
+ };
+
+ extern const char pca_ext[] = "static.pc"; // VC14 rejects constexpr.
+
+ const target_type pca::static_type
+ {
+ "pca",
+ &pc::static_type,
+ &file_factory<pca, pca_ext>,
+ &target_extension_fix<pca_ext>,
+ &target_pattern_fix<pca_ext>,
+ &target_print_0_ext_verb, // Fixed extension, no use printing.
+ &file_search,
+ false
+ };
+
+ extern const char pcs_ext[] = "shared.pc"; // VC14 rejects constexpr.
+
+ const target_type pcs::static_type
+ {
+ "pcs",
+ &pc::static_type,
+ &file_factory<pcs, pcs_ext>,
+ &target_extension_fix<pcs_ext>,
+ &target_pattern_fix<pcs_ext>,
+ &target_print_0_ext_verb, // Fixed extension, no use printing.
+ &file_search,
+ false
+ };
}
}
diff --git a/build2/cc/target.hxx b/build2/cc/target.hxx
index 4c9e4cb..a7fb7d4 100644
--- a/build2/cc/target.hxx
+++ b/build2/cc/target.hxx
@@ -57,6 +57,37 @@ namespace build2
static const target_type static_type;
virtual const target_type& dynamic_type () const {return static_type;}
};
+
+ // pkg-config file targets.
+ //
+ class pc: public file
+ {
+ public:
+ using file::file;
+
+ public:
+ static const target_type static_type;
+ };
+
+ class pca: public pc // .static.pc
+ {
+ public:
+ using pc::pc;
+
+ public:
+ static const target_type static_type;
+ virtual const target_type& dynamic_type () const {return static_type;}
+ };
+
+ class pcs: public pc // .shared.pc
+ {
+ public:
+ using pc::pc;
+
+ public:
+ static const target_type static_type;
+ virtual const target_type& dynamic_type () const {return static_type;}
+ };
}
}