From 9e5750ae2e3f837f80860aaab6b01e4d556213ed Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 27 Apr 2020 09:49:45 +0200 Subject: Rework tool importation along with cli module Specifically, now config. (like config.cli) is handled by the import machinery (it is like a shorter alias for config.import...exe that we already had). And the cli module now uses that instead of custom logic. This also adds support for uniform tool metadata extraction that is handled by the import machinery. As a result, a tool that follows the "build2 way" can be imported with metadata by the buildfile and/or corresponding module without any tool-specific code or brittleness associated with parsing --version or similar outputs. See the cli tool/module for details. Finally, two new flavors of the import directive are now supported: import! triggers immediate importation skipping any rule-specific logic while import? is optional import (analogous to using?). Note that optional import is always immediate. There is also the import-specific metadata attribute which can be specified for these two import flavors in order to trigger metadata importation. For example: import? [metadata] cli = cli%exe{cli} if ($cli != [null]) info "cli version $($cli:cli.version)" --- libbuild2/prerequisite-key.hxx | 44 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 libbuild2/prerequisite-key.hxx (limited to 'libbuild2/prerequisite-key.hxx') diff --git a/libbuild2/prerequisite-key.hxx b/libbuild2/prerequisite-key.hxx new file mode 100644 index 0000000..12b94a8 --- /dev/null +++ b/libbuild2/prerequisite-key.hxx @@ -0,0 +1,44 @@ +// file : libbuild2/prerequisite-key.hxx -*- C++ -*- +// license : MIT; see accompanying LICENSE file + +#ifndef LIBBUILD2_PREREQUISITE_KEY_HXX +#define LIBBUILD2_PREREQUISITE_KEY_HXX + +#include +#include +#include + +#include +#include + +#include + +namespace build2 +{ + // Light-weight (by being shallow-pointing) prerequisite key, similar + // to (and based on) target key. + // + // Note that unlike prerequisite, the key is not (necessarily) owned by a + // target. So for the key we instead have the base scope of the target that + // (would) own it. Note that we assume keys to be ephemeral enough for the + // base scope to remain unchanged. + // + class prerequisite_key + { + public: + using scope_type = build2::scope; + + const optional& proj; + target_key tk; // The .dir and .out members can be relative. + const scope_type* scope; // Can be NULL if tk.dir is absolute. + + template + bool is_a () const {return tk.is_a ();} + bool is_a (const target_type& tt) const {return tk.is_a (tt);} + }; + + LIBBUILD2_SYMEXPORT ostream& + operator<< (ostream&, const prerequisite_key&); +} + +#endif // LIBBUILD2_PREREQUISITE_KEY_HXX -- cgit v1.1