From 375c7c9770c5407af33058170d13d9801a508b30 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Sat, 17 Aug 2019 20:35:59 +0300 Subject: Don't load default options from directories which subdirectory contains --no-default-options --- libbutl/default-options.mxx | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'libbutl/default-options.mxx') diff --git a/libbutl/default-options.mxx b/libbutl/default-options.mxx index 62c7f92..403df47 100644 --- a/libbutl/default-options.mxx +++ b/libbutl/default-options.mxx @@ -7,7 +7,10 @@ #endif #ifndef __cpp_lib_modules_ts +#include + #include // move(), forward(), make_pair() +#include // reverse() #include #endif @@ -42,7 +45,7 @@ LIBBUTL_MODEXPORT namespace butl struct default_options_files { small_vector files; - optional start_dir; + optional start; }; template @@ -62,7 +65,11 @@ LIBBUTL_MODEXPORT namespace butl // Pass each default options file path to the specified function prior to // load (can be used for tracing, etc). The function signature is: // - // void (const path&, bool remote) + // void (const path&, bool remote, bool overwrite) + // + // Note that the function may be called for the same file twice if it was + // later discovered that it is in fact remote. In the second call the + // overwrite flag will be true. // // Throw `pair` on the underlying OS error with the // first half referring the filesystem entry the error relates to and pass @@ -78,13 +85,16 @@ LIBBUTL_MODEXPORT namespace butl // .build2/local/ subdirectories of each directory. For sys_dir they are // looked for in the directory itself (e.g., /etc/build2/). // - // Note that all the directories should be absolute and normalized. + // Note that the search is stopped at the directory containing a file with + // --no-default-options. + // + // Also note that all the directories should be absolute and normalized. // // The presence of the .git filesystem entry causes the options files in // this directory and any of its subdirectories to be considered remote // (note that in the current implementation this is the case even for files // from the .build2/local/ subdirectory since the mere location is not a - // sufficient ground to definititevly conclude that the file is not remote; + // sufficient ground to definitively conclude that the file is not remote; // to be sure we would need to query the VCS or some such). // template @@ -118,6 +128,13 @@ LIBBUTL_MODEXPORT namespace butl template O merge_default_options (const default_options&, const O&, F&&); + + // Find a common start (parent) directory stopping at home or root + // (excluding). + // + LIBBUTL_SYMEXPORT optional + default_options_start (const optional& home_dir, + const std::vector&); } #include -- cgit v1.1