X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Farchitecture.cpp;h=9662bbaa6f08e2dbcaeef2f9a75c9df77818b99d;hb=d1f9551e05c9d341149eb490e05b1465d3d6b711;hp=2efcd5e3e4ee23dc9294cfb04f261ab06ce8f1c8;hpb=7c2db9e2b91da953701be233336c5bfa1f3c4af0;p=builder.git diff --git a/source/architecture.cpp b/source/architecture.cpp index 2efcd5e..9662bba 100644 --- a/source/architecture.cpp +++ b/source/architecture.cpp @@ -96,9 +96,7 @@ const char *aliases[] = } Architecture::Architecture(Builder &b, const string &spec): - builder(b), - bits(0), - native(false) + builder(b) { if(spec.empty()) { @@ -177,7 +175,7 @@ Architecture::Architecture(Builder &b, const string &spec): } } -bool Architecture::match_name(const string &pattern) const +bool Architecture::match_name(const string &pattern, unsigned *quality) const { bool negate = (pattern[0]=='!'); vector parts = split(pattern.substr(negate), "-"); @@ -187,31 +185,32 @@ bool Architecture::match_name(const string &pattern) const if((p=="32" && bits==32) || (p=="64" && bits==64)) ; else if(p!=type && p!=cpu && p!=fpu && p!=system && p!=toolchain) + { + if(quality) + *quality = 0; return negate; + } } + + if(quality) + *quality = parts.size(); return !negate; } string Architecture::best_match(const vector &names) const { string best; - unsigned best_size = 0; + unsigned best_quality = 0; for(const string &n: names) - if(match_name(n)) - { - /* TODO Do full parse and alias resolution here? Otherwise x86 and - x86_64 are treated as equally good, even though the latter is more - specific. */ - unsigned size = 1; - for(char c: n) - size += (c=='-'); - - if(size>best_size) + { + unsigned quality; + if(match_name(n, &quality)) + if(quality>best_quality) { best = n; - best_size = size; + best_quality = quality; } - } + } return best; }