From 6779ea02fb07ba39d162300dd18297ba2027846a Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Sun, 24 Sep 2017 02:29:13 +0300 Subject: Get rid of pkgconfig module --- bootstrap-mingw.bat | 1 - bootstrap-msvc.bat | 1 - bootstrap.gmake | 3 +- bootstrap.sh | 1 - build2/b.cxx | 4 - build2/c/init.cxx | 1 - build2/cc/common.cxx | 3 +- build2/cc/common.hxx | 4 +- build2/cc/init.cxx | 24 ------ build2/cc/link.cxx | 7 +- build2/cc/module.cxx | 16 +++- build2/cc/pkgconfig.cxx | 13 ++-- build2/cc/target.cxx | 40 ++++++++++ build2/cc/target.hxx | 31 ++++++++ build2/cxx/init.cxx | 1 - build2/pkgconfig/init.cxx | 175 -------------------------------------------- build2/pkgconfig/init.hxx | 37 ---------- build2/pkgconfig/target.cxx | 54 -------------- build2/pkgconfig/target.hxx | 48 ------------ 19 files changed, 94 insertions(+), 370 deletions(-) delete mode 100644 build2/pkgconfig/init.cxx delete mode 100644 build2/pkgconfig/init.hxx delete mode 100644 build2/pkgconfig/target.cxx delete mode 100644 build2/pkgconfig/target.hxx 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 #include #include -#include #include 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 (rs["pkgconfig.path"]), cast (rs[cm.x_sys_lib_dirs]), cast (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 (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 (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 (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 #include -#include -#include // c +#include // c, pc* #include 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 +#include // pc* + #include #include @@ -77,10 +79,10 @@ namespace build2 // Figure out which compiler we are dealing with, its target, etc. // const path& xc (cast (*p.first)); - ci = cc::guess (x_lang, - xc, - cast_null (rs[config_c_coptions]), - cast_null (rs[config_x_coptions])); + ci = build2::cc::guess (x_lang, + xc, + cast_null (rs[config_c_coptions]), + cast_null (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 (); + t.insert (); + + if (install_loaded) + install_path (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 #include -#include #include +#include // pc #include #include @@ -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 (l)); - assert (pc != nullptr); + auto* t (find_adhoc_member (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 (l)) + if (auto* t = find_adhoc_member (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, + &target_extension_fix, + &target_pattern_fix, + &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, + &target_extension_fix, + &target_pattern_fix, + &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 (rs["pkgconfig.path"]), cast (rs[cm.x_sys_lib_dirs]), cast (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 - -#include -#include -#include -#include - -#include -#include - -#include - -using namespace std; -using namespace butl; - -namespace build2 -{ - namespace pkgconfig - { - bool - config_init (scope& rs, - scope& bs, - const location& l, - unique_ptr&, - 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 ("config.pkgconfig", true)); - const variable& x_path (vp.insert ("pkgconfig.path")); - - const variable& c_x_tgt ( - vp.insert ("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 (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 -pkg-config. - // - if (pp.empty ()) - { - if (const auto* t = cast_null (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&, - 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 (rs["pkgconfig.config.loaded"])) - { - if (!load_module (rs, rs, "pkgconfig.config", loc, optional, hints)) - conf = false; - } - else if (!cast_false (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 (); - rs.target_types.insert (); - - if (cast_false (rs["install.loaded"])) - install::install_path (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 -#include - -#include - -namespace build2 -{ - namespace pkgconfig - { - bool - config_init (scope&, - scope&, - const location&, - unique_ptr&, - bool, - bool, - const variable_map&); - - bool - init (scope&, - scope&, - const location&, - unique_ptr&, - 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 - -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, - &target_extension_fix, - &target_pattern_fix, - &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, - &target_extension_fix, - &target_pattern_fix, - &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 -#include - -#include - -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 -- cgit v1.1