]> git.tdb.fi Git - builder.git/blobdiff - source/architecture.cpp
Add a toolchain field to Architecture
[builder.git] / source / architecture.cpp
index ac31abdc30428307fd46278a44508b1222872dfb..9ce1acef6c59883f8684eb324f2d594bb17f675f 100644 (file)
@@ -1,5 +1,5 @@
 #include <limits>
-#ifndef WIN32
+#ifndef _WIN32
 #include <sys/utsname.h>
 #endif
 #include <msp/strings/format.h>
@@ -42,6 +42,15 @@ const char *cpus[] =
        0
 };
 
+const char *fpus[] =
+{
+       "387",   "x86",
+       "sse",   "x86",
+       "vfpv3", "arm",
+       "neon",  "arm",
+       0
+};
+
 const char *systems[] =
 {
        "linux",
@@ -52,6 +61,13 @@ const char *systems[] =
        0
 };
 
+const char *toolchains[] =
+{
+       "gnu",
+       "clang",
+       0
+};
+
 const char *aliases[] =
 {
        "pc",              "x86",
@@ -65,6 +81,8 @@ const char *aliases[] =
        "power macintosh", "ppc",
        "armeabi",         "arm",
        "v7a",             "armv7a",
+       "gcc",             "gnu",
+       "mingw",           "windows-gnu",
        0
 };
 
@@ -77,7 +95,7 @@ Architecture::Architecture(Builder &b, const string &spec):
 {
        if(spec.empty())
        {
-#ifdef WIN32
+#ifdef _WIN32
                system = "windows";
 #else
                utsname un;
@@ -113,10 +131,21 @@ 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);
 
        if(system=="windows")
        {
@@ -126,6 +155,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,7 +178,7 @@ 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;
@@ -235,6 +265,15 @@ void Architecture::parse_specification(const string &spec)
                                ok = true;
                        }
 
+               for(unsigned j=0; (!ok && fpus[j]); j+=2)
+                       if(*i==fpus[j])
+                       {
+                               if(fpus[j+1]!=type)
+                                       throw invalid_argument("Conflicting FPU specification");
+                               fpu = *i;
+                               ok = true;
+                       }
+
                for(unsigned j=0; (!ok && systems[j]); ++j)
                        if(*i==systems[j])
                        {
@@ -242,6 +281,13 @@ void Architecture::parse_specification(const string &spec)
                                ok = true;
                        }
 
+               for(unsigned j=0; (!ok && toolchains[j]); ++j)
+                       if(*i==toolchains[j])
+                       {
+                               toolchain = *i;
+                               ok = true;
+                       }
+
                if(!ok && (*i=="32" || *i=="64"))
                {
                        bits = lexical_cast<unsigned>(*i);