From ad720fabd468974e3909f62a0f4e4e3cf0d03aef Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 15 Apr 2015 11:59:58 +0200 Subject: Initial library support --- build/target | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) (limited to 'build/target') diff --git a/build/target b/build/target index dd62ec8..5495061 100644 --- a/build/target +++ b/build/target @@ -20,6 +20,7 @@ #include // map_iterator_adapter #include #include +#include #include #include #include // compare_*, extension_pool @@ -93,12 +94,13 @@ namespace build ~target () = default; target (dir_path d, std::string n, const std::string* e) - : dir (std::move (d)), name (std::move (n)), ext (e) {} + : dir (std::move (d)), name (std::move (n)), ext (e), + variables (nullptr) {} const dir_path dir; // Absolute and normalized. const std::string name; - const std::string* ext; // Extension, NULL means unspecified. - + const std::string* ext; // Extension, NULL means unspecified, + // empty means no extension. public: // Most qualified scope that contains this target. // @@ -112,6 +114,8 @@ namespace build scope* root_scope () const; + // Prerequisites. + // public: typedef std::vector> @@ -119,6 +123,25 @@ namespace build prerequisites_type prerequisites; + // Target-specific variables. + // + public: + variable_map variables; + + const variable_map& + ro_variables () const {return variables;} + + // Variable lookup in this target and all its outer scopes. + // + value_proxy + operator[] (const variable&); + + value_proxy + operator[] (const std::string& name) + { + return operator[] (variable_pool.find (name)); + } + public: target_state state; @@ -328,6 +351,14 @@ namespace build void path (path_type p) {assert (path_.empty ()); path_ = std::move (p);} + // Return a path derived from target's dir, name, and, if specified, + // ext. If ext is not specified, then use default_ext. If name_prefix + // if not NULL, add it before the name part. + // + path_type + derived_path (const char* default_ext = nullptr, + const char* name_prefix = nullptr); + protected: virtual timestamp load_mtime () const; -- cgit v1.1