X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Farchitecture.cpp;h=2c5d383ec3622cc25a9caa61b4e4448c41547ea1;hb=70325e0d3996adb97b99d45445a34c9334566803;hp=a9434986a91170a3de3ef4c7e6462b7b2ee1c911;hpb=081e13e6f146d1685bdcb1ec1c82752f4c6d264d;p=builder.git diff --git a/source/architecture.cpp b/source/architecture.cpp index a943498..2c5d383 100644 --- a/source/architecture.cpp +++ b/source/architecture.cpp @@ -1,11 +1,9 @@ #include -#ifndef WIN32 -#include -#endif #include #include #include "architecture.h" #include "builder.h" +#include "sysutils.h" using namespace std; using namespace Msp; @@ -42,6 +40,15 @@ const char *cpus[] = 0 }; +const char *fpus[] = +{ + "387", "x86", + "sse", "x86", + "vfpv3", "arm", + "neon", "arm", + 0 +}; + const char *systems[] = { "linux", @@ -52,10 +59,18 @@ const char *systems[] = 0 }; +const char *toolchains[] = +{ + "gnu", + "clang", + 0 +}; + const char *aliases[] = { "pc", "x86", "x86_64", "x86-64", + "x64", "x86-64", "amd64", "x86-64", "i586", "pentium", "i686", "pentiumpro", @@ -65,6 +80,8 @@ const char *aliases[] = "power macintosh", "ppc", "armeabi", "arm", "v7a", "armv7a", + "gcc", "gnu", + "mingw", "windows-gnu", 0 }; @@ -77,18 +94,9 @@ Architecture::Architecture(Builder &b, const string &spec): { if(spec.empty()) { -#ifdef WIN32 - system = "windows"; -#else - utsname un; - if(uname(&un)==0) - { - system = tolower(un.sysname); - parse_specification(tolower(un.machine)); - // We really only want to set type for the default arch - cpu.clear(); - } -#endif + parse_specification(get_system_type()); + // We really only want to set type for the default arch + cpu.clear(); bits = sizeof(void *)*numeric_limits::digits; native = true; } @@ -113,11 +121,23 @@ Architecture::Architecture(Builder &b, const string &spec): else if(bits==native_arch.bits) native = true; } + + if(toolchain.empty()) + { + if((system=="darwin" || system=="freebsd") && builder.get_vfs().find_binary("clang")) + toolchain = "clang"; + else + toolchain = "gnu"; + } + name = type; if(!cpu.empty()) name += format("-%s", cpu); - name += format("-%d-%s", bits, system); + if(!fpu.empty()) + name += format("-%s", fpu); + name += format("-%d-%s-%s", bits, system, toolchain); + object_patterns.push_back(Pattern("%.o")); if(system=="windows") { sharedlib_patterns.push_back(Pattern("%.dll")); @@ -126,6 +146,7 @@ Architecture::Architecture(Builder &b, const string &spec): even though technically they are linked statically. */ sharedlib_patterns.push_back(Pattern("lib%.dll.a")); staticlib_patterns.push_back(Pattern("lib%.a")); + staticlib_patterns.push_back(Pattern("%.lib")); executable_patterns.push_back(Pattern("%.exe")); } else @@ -148,12 +169,36 @@ bool Architecture::match_name(const string &pattern) const { if((*i=="32" && bits==32) || (*i=="64" && bits==64)) ; - else if(*i!=type && *i!=cpu && *i!=system) + else if(*i!=type && *i!=cpu && *i!=fpu && *i!=system && *i!=toolchain) return negate; } return !negate; } +string Architecture::best_match(const vector &names) const +{ + string best; + unsigned best_size = 0; + for(vector::const_iterator i=names.begin(); i!=names.end(); ++i) + if(match_name(*i)) + { + /* 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(string::const_iterator j=i->begin(); j!=i->end(); ++j) + size += (*j=='-'); + + if(size>best_size) + { + best = *i; + best_size = size; + } + } + + return best; +} + void Architecture::resolve_aliases(vector &parts) { for(unsigned i=0; i(*i);