From 101987533ca35e4aa3515b25415f1abba46e796f Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 9 Jul 2020 10:50:42 +0200 Subject: Add support for ad hoc importation --- libbuild2/file.hxx | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'libbuild2/file.hxx') diff --git a/libbuild2/file.hxx b/libbuild2/file.hxx index 856a248..aa30e39 100644 --- a/libbuild2/file.hxx +++ b/libbuild2/file.hxx @@ -68,6 +68,28 @@ namespace build2 LIBBUILD2_SYMEXPORT pair find_out_root (const dir_path&, optional& altn); + // Look for a buildfile starting from the specified directory and continuing + // in the parent directories until root. Return nullopt if not found. + // + LIBBUILD2_SYMEXPORT optional + find_buildfile (const dir_path& base, + const dir_path& root, + optional& altn, + const path& name = {}); + + // If the buildfile cannot be found in the target's directory itself, then + // this function can be used to try and find a nearest buildfile that could + // plausibly define this target. Return nullopt if not found and empty path + // if the implied buildfile in the target's directory should be assumed. + // + LIBBUILD2_SYMEXPORT optional + find_plausible_buildfile (const name& tgt, + const scope& rs, + const dir_path& src_base, + const dir_path& src_root, + optional& altn, + const path& name = {}); + // Project's loading stage during which the parsing is performed. // enum class load_stage @@ -95,7 +117,7 @@ namespace build2 source (scope& root, scope& base, lexer&, load_stage = load_stage::rest); // As above but first check if this buildfile has already been sourced for - // the base scope. Return false if the file has already been sourced. + // the root scope. Return false if the file has already been sourced. // bool source_once (scope& root, scope& base, const path&); @@ -253,9 +275,14 @@ namespace build2 // // ad hoc // - // The target is imported by specifying its path directly with - // config.import..[.]. For example, this can be - // used to import an installed target. + // The target is imported by having its path specifed directly with + // config.import..[.]. For example, this can be used to + // import an installed target. + // + // Note that this is also the kind assigned to an import that uses an + // unqualified absolute target name or a relative directory (which we also + // call ad hoc; in a sense it's the same thing, just the path is hardcoded + // directly in the buildfile). // // // normal -- cgit v1.1