From 83b5af87efef571b707fc1f409f22571a9f5054c Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 12 Aug 2016 16:23:37 +0200 Subject: Add support for ordering modules in config.build --- build2/config/module | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'build2/config/module') 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 #include // find_if() #include @@ -49,15 +50,26 @@ namespace build2 struct saved_modules: butl::prefix_map { - vector 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 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; } -- cgit v1.1