]> git.tdb.fi Git - builder.git/commitdiff
Add a toolchain field to Architecture
authorMikko Rasa <tdb@tdb.fi>
Sat, 28 Aug 2021 11:41:07 +0000 (14:41 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 28 Aug 2021 12:12:40 +0000 (15:12 +0300)
source/architecture.cpp
source/architecture.h
source/builder.cpp

index ba25afd77b27c997656cb37f843e0a7092c5c646..9ce1acef6c59883f8684eb324f2d594bb17f675f 100644 (file)
@@ -61,6 +61,13 @@ const char *systems[] =
        0
 };
 
+const char *toolchains[] =
+{
+       "gnu",
+       "clang",
+       0
+};
+
 const char *aliases[] =
 {
        "pc",              "x86",
@@ -74,6 +81,8 @@ const char *aliases[] =
        "power macintosh", "ppc",
        "armeabi",         "arm",
        "v7a",             "armv7a",
+       "gcc",             "gnu",
+       "mingw",           "windows-gnu",
        0
 };
 
@@ -122,12 +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);
        if(!fpu.empty())
                name += format("-%s", fpu);
-       name += format("-%d-%s", bits, system);
+       name += format("-%d-%s-%s", bits, system, toolchain);
 
        if(system=="windows")
        {
@@ -160,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!=fpu && *i!=system)
+               else if(*i!=type && *i!=cpu && *i!=fpu && *i!=system && *i!=toolchain)
                        return negate;
        }
        return !negate;
@@ -263,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);
index 153230244f6aedfdce7fd6a5648619108fe93d12..c1446b462949c662eb5f0b117f315f38a42c83f3 100644 (file)
@@ -29,6 +29,7 @@ private:
        std::string fpu;
        std::string system;
        unsigned bits;
+       std::string toolchain;
        std::string name;
        bool native;
        std::string cross_prefix;
@@ -45,6 +46,7 @@ public:
        unsigned get_bits() const { return bits; }
        const std::string &get_cpu() const { return cpu; }
        const std::string &get_fpu() const { return fpu; }
+       const std::string &get_toolchain() const { return toolchain; }
        bool match_name(const std::string &) const;
        std::string best_match(const std::list<std::string> &) const;
        bool is_native() const { return native; }
index b49bc7577909471b81459be1ee13c76e0651d194..7ef1ea1dcfd6d498969647a4cc7fe6f71f669db1 100644 (file)
@@ -86,12 +86,12 @@ void Builder::set_temp_directory(const FS::Path &p)
 
 void Builder::add_default_tools()
 {
-       const string &sys = current_arch->get_system();
-       if(sys=="android")
+       const string &arch_tc = current_arch->get_toolchain();
+       if(current_arch->get_system()=="android")
                toolchain.add_toolchain(new AndroidTools(*this, *current_arch));
-       else if((sys=="darwin" || sys=="freebsd") && vfs.find_binary("clang"))
+       else if(arch_tc=="clang")
                toolchain.add_toolchain(new ClangTools(*this, *current_arch));
-       else
+       else if(arch_tc=="gnu")
                toolchain.add_toolchain(new GnuTools(*this, *current_arch));
        toolchain.add_toolchain(new BuiltinTools(*this));
        toolchain.add_tool(new DataTool(*this));