aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbuild2/file.cxx4
-rw-r--r--libbuild2/file.hxx5
-rw-r--r--libbuild2/parser.cxx4
-rw-r--r--libbuild2/scope.hxx28
4 files changed, 27 insertions, 14 deletions
diff --git a/libbuild2/file.cxx b/libbuild2/file.cxx
index 3ded45e..b93a20a 100644
--- a/libbuild2/file.cxx
+++ b/libbuild2/file.cxx
@@ -307,7 +307,7 @@ namespace build2
{
tracer trace ("source_once");
- if (!once.buildfiles.insert (bf).second)
+ if (!once.root_extra->insert_buildfile (bf))
{
l5 ([&]{trace << "skipping already sourced " << bf;});
return false;
@@ -954,7 +954,7 @@ namespace build2
// process hard to reason about. But we may try to bootstrap the same
// root scope multiple time.
//
- else if (rs.buildfiles.insert (bf).second)
+ else if (rs.root_extra->insert_buildfile (bf))
{
// Extract the project name and amalgamation variable value so that
// we can make them available while loading bootstrap.build.
diff --git a/libbuild2/file.hxx b/libbuild2/file.hxx
index f5eb3f9..5847498 100644
--- a/libbuild2/file.hxx
+++ b/libbuild2/file.hxx
@@ -116,10 +116,11 @@ namespace build2
bool
source_once (scope& root, scope& base, const path&);
- // As above but checks against the specified scope rather than base.
+ // As above but checks against the specified root scope rather than this
+ // root scope.
//
LIBBUILD2_SYMEXPORT bool
- source_once (scope& root, scope& base, const path&, scope& once);
+ source_once (scope& root, scope& base, const path&, scope& once_root);
// Create project's root scope. Only set the src_root variable if the passed
// src_root value is not empty.
diff --git a/libbuild2/parser.cxx b/libbuild2/parser.cxx
index b4df45b..29fe23f 100644
--- a/libbuild2/parser.cxx
+++ b/libbuild2/parser.cxx
@@ -3050,7 +3050,9 @@ namespace build2
l6 ([&]{trace (l) << "absolute path " << p;});
- if (!root_->buildfiles.insert (p).second) // Note: may be "new" root.
+ // Note: may be "new" root.
+ //
+ if (!root_->root_extra->insert_buildfile (p))
{
l5 ([&]{trace (l) << "skipping already included " << p;});
continue;
diff --git a/libbuild2/scope.hxx b/libbuild2/scope.hxx
index 7989d59..3d31ff1 100644
--- a/libbuild2/scope.hxx
+++ b/libbuild2/scope.hxx
@@ -4,8 +4,6 @@
#ifndef LIBBUILD2_SCOPE_HXX
#define LIBBUILD2_SCOPE_HXX
-#include <unordered_set>
-
#include <libbuild2/types.hxx>
#include <libbuild2/forward.hxx>
#include <libbuild2/utility.hxx>
@@ -302,13 +300,6 @@ namespace build2
//
variable_type_map target_vars;
- // Set of buildfiles already loaded for this scope. The included
- // buildfiles are checked against the project's root scope while
- // imported -- against the global scope (global_scope).
- //
- public:
- std::unordered_set<path> buildfiles;
-
// Target types.
//
// Note that target types are project-wide (even if the module that
@@ -523,6 +514,25 @@ namespace build2
//
module_map modules;
+ // Buildfiles already loaded for this project.
+ //
+ // We don't expect too many of them per project so let's use vector
+ // with linear search.
+ //
+ paths buildfiles;
+
+ bool
+ insert_buildfile (const path& f)
+ {
+ bool r (find (buildfiles.begin (),
+ buildfiles.end (),
+ f) == buildfiles.end ());
+ if (r)
+ buildfiles.push_back (f);
+
+ return r;
+ }
+
// Variable override cache.
//
mutable variable_override_cache override_cache;