aboutsummaryrefslogtreecommitdiff
path: root/build2/config/module
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-08-12 16:23:37 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-08-12 17:04:22 +0200
commit83b5af87efef571b707fc1f409f22571a9f5054c (patch)
tree4961218154dbe2237f017b9e068ffe80fa025ed7 /build2/config/module
parent0fd7815cbc6557811df4f1b6ffb40461474b8534 (diff)
Add support for ordering modules in config.build
Diffstat (limited to 'build2/config/module')
-rw-r--r--build2/config/module18
1 files changed, 15 insertions, 3 deletions
diff --git a/build2/config/module b/build2/config/module
index 7360cf6..21a7e28 100644
--- a/build2/config/module
+++ b/build2/config/module
@@ -5,6 +5,7 @@
#ifndef BUILD2_CONFIG_MODULE
#define BUILD2_CONFIG_MODULE
+#include <map>
#include <algorithm> // find_if()
#include <butl/prefix-map>
@@ -49,15 +50,26 @@ namespace build2
struct saved_modules: butl::prefix_map<string, saved_variables, '.'>
{
- vector<const_iterator> sequence;
+ // Priority order with INT32_MIN being the highest. Modules with the
+ // same priority are saved in the order inserted.
+ //
+ // Generally, the idea is that we want higher-level modules at the top
+ // of the file since that's the configuration that we usualy want to
+ // change. So we have the following priority bands/defaults:
+ //
+ // 101-200/150 - code generators (e.g., yacc, bison)
+ // 201-300/250 - compilers (e.g., C, C++),
+ // 301-400/350 - binutils (ar, ld)
+ //
+ std::multimap<std::int32_t, const_iterator> order;
iterator
- insert (string name)
+ insert (string name, int prio = 0)
{
auto p (emplace (move (name), saved_variables ()));
if (p.second)
- sequence.push_back (p.first);
+ order.emplace (prio, p.first);
return p.first;
}