From a84ff43b183181e0a12c6d5e31c1f366d39ce2fe Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 31 Jul 2017 18:42:47 +0200 Subject: Experimental (and probably broken) pkg-config generation support --- build2/pkgconfig/init.cxx | 24 +++++++++++++++----- build2/pkgconfig/target.cxx | 54 +++++++++++++++++++++++++++++++++++++++++++++ build2/pkgconfig/target.hxx | 48 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 120 insertions(+), 6 deletions(-) create mode 100644 build2/pkgconfig/target.cxx create mode 100644 build2/pkgconfig/target.hxx (limited to 'build2/pkgconfig') diff --git a/build2/pkgconfig/init.cxx b/build2/pkgconfig/init.cxx index fa22421..9526aa7 100644 --- a/build2/pkgconfig/init.cxx +++ b/build2/pkgconfig/init.cxx @@ -10,6 +10,9 @@ #include #include +#include + +#include using namespace std; using namespace butl; @@ -128,7 +131,7 @@ namespace build2 bool init (scope& rs, - scope& bs, + scope&, const location& loc, unique_ptr&, bool, @@ -136,14 +139,15 @@ namespace build2 const variable_map& hints) { tracer trace ("pkgconfig::init"); - l5 ([&]{trace << "for " << bs.out_path ();}); + 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)) - return false; + conf = false; } else if (!cast_false (rs["pkgconfig.config.configured"])) { @@ -151,13 +155,21 @@ namespace build2 fail << "pkgconfig module could not be configured" << info << "re-run with -V option for more information"; - return false; + conf = false; } - // For now pkgconfig and pkgconfig.config is pretty much the same. + // 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 (); - return true; + if (cast_false (rs["install.loaded"])) + install::install_path (rs, dir_path ("pkgconfig")); + + return conf; } } } diff --git a/build2/pkgconfig/target.cxx b/build2/pkgconfig/target.cxx new file mode 100644 index 0000000..7752f58 --- /dev/null +++ b/build2/pkgconfig/target.cxx @@ -0,0 +1,54 @@ +// 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 new file mode 100644 index 0000000..feb8d80 --- /dev/null +++ b/build2/pkgconfig/target.hxx @@ -0,0 +1,48 @@ +// 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