From e815af118562c68794efbd310c887acd8eae800c Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 24 Jun 2015 13:53:28 +0200 Subject: First take on the cli module plus necessary infrastructure --- build/target.txx | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 build/target.txx (limited to 'build/target.txx') diff --git a/build/target.txx b/build/target.txx new file mode 100644 index 0000000..6fe3f33 --- /dev/null +++ b/build/target.txx @@ -0,0 +1,44 @@ +// file : build/target.txx -*- C++ -*- +// copyright : Copyright (c) 2014-2015 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#include +#include // extension_pool +#include +#include + +namespace build +{ + template + const std::string& + target_extension_fix (const target_key&, scope&) + { + return extension_pool.find (ext); + } + + template + const std::string& + target_extension_var (const target_key& tk, scope& s) + { + auto val (s[var]); + + if (!val) + { + diag_record dr; + dr << fail << "no default extension in variable " << var + << info << "required to derive file name for "; + + // This is a bit hacky: we may be dealing with a target (see + // file::derive_path()) or prerequsite (see search_existing_file()). + // So we are going to check if dir is absolute. If it is, then + // we assume this is a target, otherwise -- prerequsite. + // + if (tk.dir->absolute ()) + dr << "target " << tk; + else + dr << "prerequisite " << prerequisite_key {tk, &s}; + } + + return extension_pool.find (val.as ()); + } +} -- cgit v1.1