From: Mikko Rasa Date: Sun, 3 Dec 2017 15:05:28 +0000 (+0200) Subject: Clean up compiler and linker constructors X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;ds=inline;h=f41742cb2b21241634c123561b71ee1667cb1ff4;p=builder.git Clean up compiler and linker constructors Now that the system path is populated in do_prepare, it's no longer necessary to pass the sysroot as a constructor parameter. --- diff --git a/source/androidcompiler.cpp b/source/androidcompiler.cpp index 01daa2a..e45715e 100644 --- a/source/androidcompiler.cpp +++ b/source/androidcompiler.cpp @@ -13,7 +13,7 @@ using namespace std; 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()) @@ -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"); + 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"); } diff --git a/source/androidlinker.cpp b/source/androidlinker.cpp index 5f35446..67c76c2 100644 --- a/source/androidlinker.cpp +++ b/source/androidlinker.cpp @@ -4,10 +4,9 @@ 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 &sources, const string &) diff --git a/source/clangcompiler.cpp b/source/clangcompiler.cpp index 7ad47ed..f0ab939 100644 --- a/source/clangcompiler.cpp +++ b/source/clangcompiler.cpp @@ -3,8 +3,8 @@ 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); } diff --git a/source/clangcompiler.h b/source/clangcompiler.h index c848b75..656b9d2 100644 --- a/source/clangcompiler.h +++ b/source/clangcompiler.h @@ -6,7 +6,7 @@ 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 diff --git a/source/gnucompiler.cpp b/source/gnucompiler.cpp index 16e7cca..6335aaf 100644 --- a/source/gnucompiler.cpp +++ b/source/gnucompiler.cpp @@ -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") @@ -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); - - if(!sysroot.empty()) - build_info.sysroot = sysroot; } Target *GnuCompiler::create_source(const Component &comp, const FS::Path &path) const diff --git a/source/gnucompiler.h b/source/gnucompiler.h index 4b82e6f..307aa5e 100644 --- a/source/gnucompiler.h +++ b/source/gnucompiler.h @@ -13,7 +13,7 @@ appropriate type. 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; diff --git a/source/gnulinker.cpp b/source/gnulinker.cpp index adc3efc..faa6202 100644 --- a/source/gnulinker.cpp +++ b/source/gnulinker.cpp @@ -21,7 +21,7 @@ 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"); @@ -29,9 +29,6 @@ GnuLinker::GnuLinker(Builder &b, const Architecture &a, const FS::Path &sysroot) processing_unit = COMPONENT; - if(!sysroot.empty()) - build_info.sysroot = sysroot; - 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() { + 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(&compiler)) { diff --git a/source/gnulinker.h b/source/gnulinker.h index 7841700..e8a4e3c 100644 --- a/source/gnulinker.h +++ b/source/gnulinker.h @@ -32,7 +32,7 @@ private: 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 &, const std::string &);