diff options
Diffstat (limited to 'build2/pkgconfig')
-rw-r--r-- | build2/pkgconfig/init.cxx | 24 | ||||
-rw-r--r-- | build2/pkgconfig/target.cxx | 54 | ||||
-rw-r--r-- | build2/pkgconfig/target.hxx | 48 |
3 files changed, 120 insertions, 6 deletions
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 <build2/diagnostics.hxx> #include <build2/config/utility.hxx> +#include <build2/install/utility.hxx> + +#include <build2/pkgconfig/target.hxx> using namespace std; using namespace butl; @@ -128,7 +131,7 @@ namespace build2 bool init (scope& rs, - scope& bs, + scope&, const location& loc, unique_ptr<module_base>&, 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<bool> (rs["pkgconfig.config.loaded"])) { if (!load_module (rs, rs, "pkgconfig.config", loc, optional, hints)) - return false; + conf = false; } else if (!cast_false<bool> (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<pca> (); + rs.target_types.insert<pcs> (); - return true; + if (cast_false<bool> (rs["install.loaded"])) + install::install_path<pc> (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 <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 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 <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 |