]> git.tdb.fi Git - builder.git/commitdiff
Clean up compiler and linker constructors
authorMikko Rasa <tdb@tdb.fi>
Sun, 3 Dec 2017 15:05:28 +0000 (17:05 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 3 Dec 2017 15:05:28 +0000 (17:05 +0200)
Now that the system path is populated in do_prepare, it's no longer
necessary to pass the sysroot as a constructor parameter.

source/androidcompiler.cpp
source/androidlinker.cpp
source/clangcompiler.cpp
source/clangcompiler.h
source/gnucompiler.cpp
source/gnucompiler.h
source/gnulinker.cpp
source/gnulinker.h

index 01daa2a65c6ea2318bcf0a6f79366945e2309575..e45715e5a7313068ff66663406473f1e52608565 100644 (file)
@@ -13,7 +13,7 @@ using namespace std;
 using namespace Msp;
 
 AndroidCompiler::AndroidCompiler(Builder &b, const Architecture &a, const string &t, const AndroidNdk &n):
 using namespace Msp;
 
 AndroidCompiler::AndroidCompiler(Builder &b, const Architecture &a, const string &t, const AndroidNdk &n):
-       GnuCompiler(b, a, t, n.get_platform_sysroot()),
+       GnuCompiler(b, a, t),
        ndk(n)
 {
        if(ndk.get_root_dir().empty())
        ndk(n)
 {
        if(ndk.get_root_dir().empty())
@@ -25,8 +25,9 @@ AndroidCompiler::AndroidCompiler(Builder &b, const Architecture &a, const string
 
        if(ndk.get_platform_sysroot().empty())
                problems.push_back("Android platform not found");
 
        if(ndk.get_platform_sysroot().empty())
                problems.push_back("Android platform not found");
+       else
+               build_info.sysroot = ndk.get_platform_sysroot();
 
 
-       build_info.incpath.insert(build_info.incpath.end(), system_path.begin(), system_path.end());
        if(tag=="CXX")
                build_info.libs.push_back("gnustl_static");
 }
        if(tag=="CXX")
                build_info.libs.push_back("gnustl_static");
 }
index 5f35446d3034b622cff5864906ca4f5a40c76dd4..67c76c29fe908ba3a3dea1131f0872e31fbb4744 100644 (file)
@@ -4,10 +4,9 @@
 using namespace std;
 
 AndroidLinker::AndroidLinker(Builder &b, const Architecture &a, const AndroidNdk &ndk):
 using namespace std;
 
 AndroidLinker::AndroidLinker(Builder &b, const Architecture &a, const AndroidNdk &ndk):
-       GnuLinker(b, a, ndk.get_platform_sysroot())
+       GnuLinker(b, a)
 {
 {
-       set_command((ndk.get_bin_dir()/command).str());
-       build_info.libpath.insert(build_info.libpath.end(), system_path.begin(), system_path.end());
+       build_info.sysroot = ndk.get_platform_sysroot();
 }
 
 Target *AndroidLinker::create_target(const list<Target *> &sources, const string &)
 }
 
 Target *AndroidLinker::create_target(const list<Target *> &sources, const string &)
index 7ad47ed45986b55f2ba7f81fa76eae7c75a7b91b..f0ab93916a8a91c24a2c7b4ae1740ec367189ea6 100644 (file)
@@ -3,8 +3,8 @@
 using namespace std;
 using namespace Msp;
 
 using namespace std;
 using namespace Msp;
 
-ClangCompiler::ClangCompiler(Builder &b, const Architecture &a, const string &t, const FS::Path &r):
-       GnuCompiler(b, a, t, r)
+ClangCompiler::ClangCompiler(Builder &b, const Architecture &a, const string &t):
+       GnuCompiler(b, a, t)
 {
        set_command((tag=="CXX" ? "clang++" : "clang"), true);
 }
 {
        set_command((tag=="CXX" ? "clang++" : "clang"), true);
 }
index c848b758c13452857ea02989297e9ce64f0c071a..656b9d20dff4be43b2f8148eef5957fd3c9d50b4 100644 (file)
@@ -6,7 +6,7 @@
 class ClangCompiler: public GnuCompiler
 {
 public:
 class ClangCompiler: public GnuCompiler
 {
 public:
-       ClangCompiler(Builder &, const Architecture &, const std::string &, const Msp::FS::Path & = Msp::FS::Path());
+       ClangCompiler(Builder &, const Architecture &, const std::string &);
 };
 
 #endif
 };
 
 #endif
index 16e7ccac1d88da73a34776e288980b295f4f0747..6335aaf3cc4f51ce513b06ad3735de751e05db56 100644 (file)
@@ -27,7 +27,7 @@ const char *cpus[] =
 
 }
 
 
 }
 
-GnuCompiler::GnuCompiler(Builder &b, const Architecture &a, const string &t, const FS::Path &sysroot):
+GnuCompiler::GnuCompiler(Builder &b, const Architecture &a, const string &t):
        Tool(b, a, t)
 {
        if(tag=="CC")
        Tool(b, a, t)
 {
        if(tag=="CC")
@@ -50,9 +50,6 @@ GnuCompiler::GnuCompiler(Builder &b, const Architecture &a, const string &t, con
                throw invalid_argument("GnuCompiler::GnuCompiler");
 
        set_command((tag=="CXX" ? "g++" : "gcc"), true);
                throw invalid_argument("GnuCompiler::GnuCompiler");
 
        set_command((tag=="CXX" ? "g++" : "gcc"), true);
-
-       if(!sysroot.empty())
-               build_info.sysroot = sysroot;
 }
 
 Target *GnuCompiler::create_source(const Component &comp, const FS::Path &path) const
 }
 
 Target *GnuCompiler::create_source(const Component &comp, const FS::Path &path) const
index 4b82e6f4f7ad30d47c8a9b0e5e7eadb53f931b76..307aa5ee4115921357ba033b4ceb6437f3c0202a 100644 (file)
@@ -13,7 +13,7 @@ appropriate type.
 class GnuCompiler: public Tool
 {
 public:
 class GnuCompiler: public Tool
 {
 public:
-       GnuCompiler(Builder &, const Architecture &, const std::string &, const Msp::FS::Path & = Msp::FS::Path());
+       GnuCompiler(Builder &, const Architecture &, const std::string &);
 
        virtual Target *create_source(const Component &, const Msp::FS::Path &) const;
        virtual Target *create_source(const Msp::FS::Path &) const;
 
        virtual Target *create_source(const Component &, const Msp::FS::Path &) const;
        virtual Target *create_source(const Msp::FS::Path &) const;
index adc3efcfcf6ad72d933b8e401836cbd935e34091..faa62024e250aee1414caab7f52aed7ed794ebe8 100644 (file)
@@ -21,7 +21,7 @@
 using namespace std;
 using namespace Msp;
 
 using namespace std;
 using namespace Msp;
 
-GnuLinker::GnuLinker(Builder &b, const Architecture &a, const FS::Path &sysroot):
+GnuLinker::GnuLinker(Builder &b, const Architecture &a):
        Tool(b, a, "LINK")
 {
        input_suffixes.push_back(".o");
        Tool(b, a, "LINK")
 {
        input_suffixes.push_back(".o");
@@ -29,9 +29,6 @@ GnuLinker::GnuLinker(Builder &b, const Architecture &a, const FS::Path &sysroot)
 
        processing_unit = COMPONENT;
 
 
        processing_unit = COMPONENT;
 
-       if(!sysroot.empty())
-               build_info.sysroot = sysroot;
-
        default_linker = new Linker(*this, "CC");
        cxx_linker = new Linker(*this, "CXX");
 }
        default_linker = new Linker(*this, "CC");
        cxx_linker = new Linker(*this, "CXX");
 }
@@ -220,6 +217,10 @@ string GnuLinker::Linker::create_build_signature(const BuildInfo &binfo) const
 
 void GnuLinker::Linker::do_prepare()
 {
 
 void GnuLinker::Linker::do_prepare()
 {
+       parent.prepare();
+       build_info = parent.get_build_info();
+       system_path = parent.get_system_path();
+
        Tool &compiler = builder.get_toolchain().get_tool(compiler_tag);
        if(dynamic_cast<GnuCompiler *>(&compiler))
        {
        Tool &compiler = builder.get_toolchain().get_tool(compiler_tag);
        if(dynamic_cast<GnuCompiler *>(&compiler))
        {
index 784170023bafb84a33633356a889245ee848acaf..e8a4e3ce996f749659485aa7133ec9ec82fcf58e 100644 (file)
@@ -32,7 +32,7 @@ private:
        Linker *cxx_linker;
 
 public:
        Linker *cxx_linker;
 
 public:
-       GnuLinker(Builder &, const Architecture &, const Msp::FS::Path & = Msp::FS::Path());
+       GnuLinker(Builder &, const Architecture &);
        ~GnuLinker();
 
        virtual Target *create_target(const std::list<Target *> &, const std::string &);
        ~GnuLinker();
 
        virtual Target *create_target(const std::list<Target *> &, const std::string &);