aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2017-09-24 02:29:13 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2017-09-25 00:30:49 +0300
commit6779ea02fb07ba39d162300dd18297ba2027846a (patch)
tree2543cfd4a4afd2113e2f298a8ede4019cc795ae1
parent984a0217af64c734938c330b09ed21d1253dea8d (diff)
Get rid of pkgconfig module
-rw-r--r--bootstrap-mingw.bat1
-rw-r--r--bootstrap-msvc.bat1
-rw-r--r--bootstrap.gmake3
-rwxr-xr-xbootstrap.sh1
-rw-r--r--build2/b.cxx4
-rw-r--r--build2/c/init.cxx1
-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
-rw-r--r--build2/cxx/init.cxx1
-rw-r--r--build2/pkgconfig/init.cxx175
-rw-r--r--build2/pkgconfig/init.hxx37
-rw-r--r--build2/pkgconfig/target.cxx54
-rw-r--r--build2/pkgconfig/target.hxx48
19 files changed, 94 insertions, 370 deletions
diff --git a/bootstrap-mingw.bat b/bootstrap-mingw.bat
index fbec68a..7ed5fcf 100644
--- a/bootstrap-mingw.bat
+++ b/bootstrap-mingw.bat
@@ -72,7 +72,6 @@ set "src=%src% build2\test\*.cxx"
set "src=%src% build2\test\script\*.cxx"
set "src=%src% build2\version\*.cxx"
set "src=%src% build2\install\*.cxx"
-set "src=%src% build2\pkgconfig\*.cxx"
set "src=%src% %libbutl%\libbutl\*.cxx"
rem Get the compile options.
diff --git a/bootstrap-msvc.bat b/bootstrap-msvc.bat
index a83bb5b..b5a84f4 100644
--- a/bootstrap-msvc.bat
+++ b/bootstrap-msvc.bat
@@ -103,7 +103,6 @@ set "src=%src% build2\test"
set "src=%src% build2\test\script"
set "src=%src% build2\version"
set "src=%src% build2\install"
-set "src=%src% build2\pkgconfig"
set "src=%src% %libbutl%\libbutl"
rem Get the compile options.
diff --git a/bootstrap.gmake b/bootstrap.gmake
index 0b2c43f..980b90e 100644
--- a/bootstrap.gmake
+++ b/bootstrap.gmake
@@ -126,8 +126,7 @@ cli \
test/script \
test \
version \
-install \
-pkgconfig
+install
build2_src := $(wildcard $(src_root)/build2/*.cxx)
build2_src += $(foreach d,$(sub_dirs),$(wildcard $(src_root)/build2/$d/*.cxx))
diff --git a/bootstrap.sh b/bootstrap.sh
index 49b0494..0b33156 100755
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -128,7 +128,6 @@ src="$src build2/test/*.cxx"
src="$src build2/test/script/*.cxx"
src="$src build2/version/*.cxx"
src="$src build2/install/*.cxx"
-src="$src build2/pkgconfig/*.cxx"
src="$src $libbutl/libbutl/*.cxx"
# Note that for as long as we support GCC 4.9 we have to compile in the C++14
diff --git a/build2/b.cxx b/build2/b.cxx
index 0520bd8..746d5fd 100644
--- a/build2/b.cxx
+++ b/build2/b.cxx
@@ -51,7 +51,6 @@ using namespace std;
#include <build2/cli/init.hxx>
#include <build2/test/init.hxx>
#include <build2/install/init.hxx>
-#include <build2/pkgconfig/init.hxx>
#include <build2/version/init.hxx>
namespace build2
@@ -324,9 +323,6 @@ main (int argc, char* argv[])
bm["bin.rc.config"] = mf {nullptr, &bin::rc_config_init};
bm["bin.rc"] = mf {nullptr, &bin::rc_init};
- bm["pkgconfig.config"] = mf {nullptr, &pkgconfig::config_init};
- bm["pkgconfig"] = mf {nullptr, &pkgconfig::init};
-
bm["cc.core.vars"] = mf {nullptr, &cc::core_vars_init};
bm["cc.core.config"] = mf {nullptr, &cc::core_config_init};
bm["cc.core"] = mf {nullptr, &cc::core_init};
diff --git a/build2/c/init.cxx b/build2/c/init.cxx
index 1190eae..45097bb 100644
--- a/build2/c/init.cxx
+++ b/build2/c/init.cxx
@@ -298,7 +298,6 @@ namespace build2
false, // No C modules yet.
false, // No __symexport support since no modules.
- cast_null<process_path> (rs["pkgconfig.path"]),
cast<dir_paths> (rs[cm.x_sys_lib_dirs]),
cast<dir_paths> (rs[cm.x_sys_inc_dirs]),
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;}
+ };
}
}
diff --git a/build2/cxx/init.cxx b/build2/cxx/init.cxx
index 4a72c90..ca75de3 100644
--- a/build2/cxx/init.cxx
+++ b/build2/cxx/init.cxx
@@ -508,7 +508,6 @@ namespace build2
modules,
symexport,
- cast_null<process_path> (rs["pkgconfig.path"]),
cast<dir_paths> (rs[cm.x_sys_lib_dirs]),
cast<dir_paths> (rs[cm.x_sys_inc_dirs]),
diff --git a/build2/pkgconfig/init.cxx b/build2/pkgconfig/init.cxx
deleted file mode 100644
index 9526aa7..0000000
--- a/build2/pkgconfig/init.cxx
+++ /dev/null
@@ -1,175 +0,0 @@
-// file : build2/pkgconfig/init.cxx -*- C++ -*-
-// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
-// license : MIT; see accompanying LICENSE file
-
-#include <build2/pkgconfig/init.hxx>
-
-#include <build2/scope.hxx>
-#include <build2/target.hxx>
-#include <build2/variable.hxx>
-#include <build2/diagnostics.hxx>
-
-#include <build2/config/utility.hxx>
-#include <build2/install/utility.hxx>
-
-#include <build2/pkgconfig/target.hxx>
-
-using namespace std;
-using namespace butl;
-
-namespace build2
-{
- namespace pkgconfig
- {
- bool
- config_init (scope& rs,
- scope& bs,
- const location& l,
- unique_ptr<module_base>&,
- bool,
- bool optional,
- const variable_map& hints)
- {
- tracer trace ("pkgconfig::config_init");
- l5 ([&]{trace << "for " << bs.out_path ();});
-
- // We only support root loading (which means there can only be one).
- //
- if (&rs != &bs)
- fail (l) << "pkgconfig.config module must be loaded in project root";
-
- // Enter variables.
- //
- // config.pkgconfig.target is a hint.
- //
- auto& vp (var_pool.rw (rs));
-
- const variable& c_x (vp.insert<path> ("config.pkgconfig", true));
- const variable& x_path (vp.insert<process_path> ("pkgconfig.path"));
-
- const variable& c_x_tgt (
- vp.insert<target_triplet> ("config.pkgconfig.target"));
-
- // Configure.
- //
-
- // Adjust module priority (between compilers and binutils).
- //
- config::save_module (rs, "pkgconfig", 325);
-
- process_path pp;
- bool new_val (false); // Set any new values?
-
- auto p (config::omitted (rs, c_x));
-
- if (p.first)
- {
- const path& x (cast<path> (p.first));
-
- try
- {
- // If this is a user-specified value, then it's non-optional.
- //
- pp = process::path_search (x, true);
- new_val = p.second;
- }
- catch (const process_error& e)
- {
- fail << "unable to execute " << x << ": " << e;
- }
- }
-
- string d; // Default name (pp.initial may be its shallow copy).
-
- // If we have a target hint, then next try <triplet>-pkg-config.
- //
- if (pp.empty ())
- {
- if (const auto* t = cast_null<target_triplet> (hints[c_x_tgt]))
- {
- d = t->string ();
- d += "-pkg-config";
-
- l5 ([&]{trace << "trying " << d;});
- pp = process::try_path_search (d, true);
- }
- }
-
- // Finallly, try just pkg-config.
- //
- if (pp.empty ())
- {
- d = "pkg-config";
-
- l5 ([&]{trace << "trying " << d;});
- pp = process::try_path_search (d, true);
- }
-
- bool conf (!pp.empty ());
-
- if (!conf && !optional)
- fail (l) << "unable to find pkg-config program";
-
- // Config report.
- //
- if (verb >= (new_val ? 2 : 3))
- {
- diag_record dr (text);
- dr << "pkgconfig " << project (rs) << '@' << rs.out_path () << '\n';
-
- if (conf)
- dr << " pkg-config " << pp;
- else
- dr << " pkg-config " << "not found, leaving unconfigured";
- }
-
- if (conf)
- rs.assign (x_path) = move (pp);
-
- return conf;
- }
-
- bool
- init (scope& rs,
- scope&,
- const location& loc,
- unique_ptr<module_base>&,
- bool,
- bool optional,
- const variable_map& hints)
- {
- tracer trace ("pkgconfig::init");
- l5 ([&]{trace << "for " << rs.out_path ();});
-
- // Load pkgconfig.config.
- //
- bool conf (true);
- if (!cast_false<bool> (rs["pkgconfig.config.loaded"]))
- {
- if (!load_module (rs, rs, "pkgconfig.config", loc, optional, hints))
- conf = false;
- }
- else if (!cast_false<bool> (rs["pkgconfig.config.configured"]))
- {
- if (!optional)
- fail << "pkgconfig module could not be configured" <<
- info << "re-run with -V option for more information";
-
- conf = false;
- }
-
- // Register the target type and configure its default "installability".
- //
- // Note that we do it whether we found pkg-config or not since these are
- // used to produce .pc files which we do regardless.
- //
- rs.target_types.insert<pca> ();
- rs.target_types.insert<pcs> ();
-
- if (cast_false<bool> (rs["install.loaded"]))
- install::install_path<pc> (rs, dir_path ("pkgconfig"));
-
- return conf;
- }
- }
-}
diff --git a/build2/pkgconfig/init.hxx b/build2/pkgconfig/init.hxx
deleted file mode 100644
index eed224f..0000000
--- a/build2/pkgconfig/init.hxx
+++ /dev/null
@@ -1,37 +0,0 @@
-// file : build2/pkgconfig/init.hxx -*- C++ -*-
-// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
-// license : MIT; see accompanying LICENSE file
-
-#ifndef BUILD2_PKGCONFIG_INIT_HXX
-#define BUILD2_PKGCONFIG_INIT_HXX
-
-#include <build2/types.hxx>
-#include <build2/utility.hxx>
-
-#include <build2/module.hxx>
-
-namespace build2
-{
- namespace pkgconfig
- {
- bool
- config_init (scope&,
- scope&,
- const location&,
- unique_ptr<module_base>&,
- bool,
- bool,
- const variable_map&);
-
- bool
- init (scope&,
- scope&,
- const location&,
- unique_ptr<module_base>&,
- bool,
- bool,
- const variable_map&);
- }
-}
-
-#endif // BUILD2_PKGCONFIG_INIT_HXX
diff --git a/build2/pkgconfig/target.cxx b/build2/pkgconfig/target.cxx
deleted file mode 100644
index 7752f58..0000000
--- a/build2/pkgconfig/target.cxx
+++ /dev/null
@@ -1,54 +0,0 @@
-// file : build2/pkgconfig/target.cxx -*- C++ -*-
-// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
-// license : MIT; see accompanying LICENSE file
-
-#include <build2/pkgconfig/target.hxx>
-
-using namespace std;
-using namespace butl;
-
-namespace build2
-{
- namespace pkgconfig
- {
- 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/pkgconfig/target.hxx b/build2/pkgconfig/target.hxx
deleted file mode 100644
index feb8d80..0000000
--- a/build2/pkgconfig/target.hxx
+++ /dev/null
@@ -1,48 +0,0 @@
-// file : build2/pkgconfig/target.hxx -*- C++ -*-
-// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
-// license : MIT; see accompanying LICENSE file
-
-#ifndef BUILD2_PKGCONFIG_TARGET_HXX
-#define BUILD2_PKGCONFIG_TARGET_HXX
-
-#include <build2/types.hxx>
-#include <build2/utility.hxx>
-
-#include <build2/target.hxx>
-
-namespace build2
-{
- namespace pkgconfig
- {
- 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;}
- };
- }
-}
-
-#endif // BUILD2_PKGCONFIG_TARGET_HXX