]> git.tdb.fi Git - builder.git/blobdiff - source/toolchain.cpp
Use priorities to determine the default toolchain
[builder.git] / source / toolchain.cpp
index 8790c83dca0737e186a868900cc8d2665343484b..c5b8caa9ffb6dbe2b9e13b79eb9dd6e43083318e 100644 (file)
@@ -1,4 +1,4 @@
-#include <algorithm>
+#include <msp/core/algorithm.h>
 #include <msp/core/maputils.h>
 #include "tool.h"
 #include "toolchain.h"
@@ -21,7 +21,8 @@ void Toolchain::add_tool(Tool *tool)
 
 void Toolchain::add_toolchain(Toolchain *chain)
 {
-       chains.push_back(chain);
+       auto i = upper_bound(chains, chain->get_priority(), [](int p, Toolchain *tc){ return p>tc->get_priority(); });
+       chains.insert(i, chain);
 }
 
 bool Toolchain::has_tool(const string &tag) const