+++ /dev/null
-#include "androidccompiler.h"
-#include "androidtools.h"
-
-AndroidCCompiler::AndroidCCompiler(Builder &b, const Architecture &a, const AndroidNdk &ndk):
- GnuCCompiler(b, a, ndk.get_platform_sysroot())
-{
- set_command((ndk.get_bin_dir()/command).str());
- build_info.incpath.insert(build_info.incpath.end(), system_path.begin(), system_path.end());
-}
+++ /dev/null
-#ifndef ANDROIDCCOMPILER_H_
-#define ANDROIDCCOMPILER_H_
-
-#include "gnuccompiler.h"
-
-class AndroidNdk;
-
-class AndroidCCompiler: public GnuCCompiler
-{
-public:
- AndroidCCompiler(Builder &, const Architecture &, const AndroidNdk &);
-};
-
-#endif
--- /dev/null
+#include <msp/fs/dir.h>
+#include <msp/fs/stat.h>
+#include <msp/strings/format.h>
+#include "androidcompiler.h"
+#include "androidtools.h"
+#include "builder.h"
+
+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()),
+ ndk(n)
+{
+ set_command((ndk.get_bin_dir()/command).str());
+ build_info.incpath.insert(build_info.incpath.end(), system_path.begin(), system_path.end());
+ if(tag=="CXX")
+ build_info.libs.push_back("gnustl_static");
+}
+
+void AndroidCompiler::do_prepare()
+{
+ GnuCompiler::do_prepare();
+ if(executable && tag=="CXX")
+ {
+ FS::Path libstdcxx_path = ndk.get_root_dir()/"sources"/"cxx-stl"/"gnu-libstdc++"/version;
+
+ FS::Path public_dir = libstdcxx_path/"include";
+ system_path.push_back(public_dir);
+ build_info.incpath.push_back(public_dir);
+
+ FS::Path arch_path = libstdcxx_path/"libs";
+ builder.get_logger().log("files", format("Traversing %s", arch_path.str()));
+ string arch_dir = architecture->best_match(list_files(arch_path));
+ if(!arch_dir.empty())
+ {
+ build_info.incpath.push_back(libstdcxx_path/"libs"/arch_dir/"include");
+ build_info.libpath.push_back(libstdcxx_path/"libs"/arch_dir);
+ }
+ }
+}
--- /dev/null
+#ifndef ANDROIDCOMPILER_H_
+#define ANDROIDCOMPILER_H_
+
+#include "gnucompiler.h"
+
+class AndroidNdk;
+
+class AndroidCompiler: public GnuCompiler
+{
+private:
+ const AndroidNdk &ndk;
+
+public:
+ AndroidCompiler(Builder &, const Architecture &, const std::string &, const AndroidNdk &);
+
+protected:
+ virtual void do_prepare();
+};
+
+#endif
+++ /dev/null
-#include <msp/fs/dir.h>
-#include <msp/strings/format.h>
-#include "androidcxxcompiler.h"
-#include "androidtools.h"
-#include "architecture.h"
-#include "builder.h"
-
-using namespace std;
-using namespace Msp;
-
-AndroidCxxCompiler::AndroidCxxCompiler(Builder &b, const Architecture &a, const AndroidNdk &n):
- GnuCxxCompiler(b, a, n.get_platform_sysroot()),
- ndk(n)
-{
- set_command((ndk.get_bin_dir()/command).str());
- build_info.incpath.insert(build_info.incpath.end(), system_path.begin(), system_path.end());
- build_info.libs.push_back("gnustl_static");
-}
-
-void AndroidCxxCompiler::do_prepare()
-{
- GnuCxxCompiler::do_prepare();
- if(executable)
- {
- FS::Path libstdcxx_path = ndk.get_root_dir()/"sources"/"cxx-stl"/"gnu-libstdc++"/version;
-
- FS::Path public_dir = libstdcxx_path/"include";
- system_path.push_back(public_dir);
- build_info.incpath.push_back(public_dir);
-
- FS::Path arch_path = libstdcxx_path/"libs";
- builder.get_logger().log("files", format("Traversing %s", arch_path.str()));
- string arch_dir = architecture->best_match(list_files(arch_path));
- if(!arch_dir.empty())
- {
- build_info.incpath.push_back(libstdcxx_path/"libs"/arch_dir/"include");
- build_info.libpath.push_back(libstdcxx_path/"libs"/arch_dir);
- }
- }
-}
+++ /dev/null
-#ifndef ANDROIDCXXCOMPILER_H_
-#define ANDROIDCXXCOMPILER_H_
-
-#include "gnucxxcompiler.h"
-
-class AndroidNdk;
-
-class AndroidCxxCompiler: public GnuCxxCompiler
-{
-private:
- const AndroidNdk &ndk;
-
-public:
- AndroidCxxCompiler(Builder &, const Architecture &, const AndroidNdk &);
-
-protected:
- virtual void do_prepare();
-};
-
-#endif
#include <msp/strings/utils.h>
#include "androidarchiver.h"
#include "androidassetpackagingtool.h"
-#include "androidccompiler.h"
-#include "androidcxxcompiler.h"
+#include "androidcompiler.h"
#include "androidlinker.h"
#include "androidmanifestgenerator.h"
#include "androidtools.h"
sdk.select_api_level(highest_common);
ndk.select_api_level(highest_common);
- add_tool(new AndroidCCompiler(builder, arch, ndk));
- add_tool(new AndroidCxxCompiler(builder, arch, ndk));
+ add_tool(new AndroidCompiler(builder, arch, "CC", ndk));
+ add_tool(new AndroidCompiler(builder, arch, "CXX", ndk));
add_tool(new AndroidLinker(builder, arch, ndk));
add_tool(new AndroidArchiver(builder, arch, ndk));
add_tool(new AndroidManifestGenerator(builder));
+++ /dev/null
-#include "clangccompiler.h"
-
-ClangCCompiler::ClangCCompiler(Builder &b, const Architecture &a):
- GnuCCompiler(b, a)
-{
- set_command("clang", true);
-}
+++ /dev/null
-#ifndef CLANGCCOMPILER_H_
-#define CLANGCCOMPILER_H_
-
-#include "gnuccompiler.h"
-
-class ClangCCompiler: public GnuCCompiler
-{
-public:
- ClangCCompiler(Builder &, const Architecture &);
-};
-
-#endif
--- /dev/null
+#include "clangcompiler.h"
+
+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)
+{
+ set_command((tag=="CXX" ? "clang++" : "clang"), true);
+}
--- /dev/null
+#ifndef CLANGCOMPILER_H_
+#define CLANGCOMPILER_H_
+
+#include "gnucompiler.h"
+
+class ClangCompiler: public GnuCompiler
+{
+public:
+ ClangCompiler(Builder &, const Architecture &, const std::string &, const Msp::FS::Path & = Msp::FS::Path());
+};
+
+#endif
+++ /dev/null
-#include "clangcxxcompiler.h"
-
-ClangCxxCompiler::ClangCxxCompiler(Builder &b, const Architecture &a):
- GnuCxxCompiler(b, a)
-{
- set_command("clang++", true);
-}
+++ /dev/null
-#ifndef CLANGCXXCOMPILER_H_
-#define CLANGCXXCOMPILER_H_
-
-#include "gnucxxcompiler.h"
-
-class ClangCxxCompiler: public GnuCxxCompiler
-{
-public:
- ClangCxxCompiler(Builder &, const Architecture &);
-};
-
-#endif
+++ /dev/null
-#include "clangobjccompiler.h"
-
-ClangObjCCompiler::ClangObjCCompiler(Builder &b, const Architecture &a):
- GnuObjCCompiler(b, a)
-{
- set_command("clang", true);
-}
+++ /dev/null
-#ifndef CLANGOBJCCOMPILER_H_
-#define CLANGOBJCCOMPILER_H_
-
-#include "gnuobjccompiler.h"
-
-class ClangObjCCompiler: public GnuObjCCompiler
-{
-public:
- ClangObjCCompiler(Builder &, const Architecture &);
-};
-
-#endif
+++ /dev/null
-#include "csourcefile.h"
-#include "gnuccompiler.h"
-
-using namespace std;
-using namespace Msp;
-
-GnuCCompiler::GnuCCompiler(Builder &b, const Architecture &a, const FS::Path &sysroot):
- GnuCompiler(b, a, "CC", sysroot)
-{
- set_command("gcc", true);
- input_suffixes.push_back(".c");
- aux_suffixes.push_back(".h");
-}
-
-Target *GnuCCompiler::create_source(const Component &comp, const FS::Path &path) const
-{
- return new CSourceFile(builder, comp, path);
-}
-
-Target *GnuCCompiler::create_source(const FS::Path &path) const
-{
- return new CSourceFile(builder, path);
-}
+++ /dev/null
-#ifndef GNUCCOMPILER_H_
-#define GNUCCOMPILER_H_
-
-#include "gnucompiler.h"
-
-/**
-The GNU C compiler, commonly known as gcc.
-*/
-class GnuCCompiler: public GnuCompiler
-{
-public:
- GnuCCompiler(Builder &, const Architecture &, const Msp::FS::Path & = Msp::FS::Path());
-
- virtual Target *create_source(const Component &, const Msp::FS::Path &) const;
- virtual Target *create_source(const Msp::FS::Path &) const;
-};
-
-#endif
#include <msp/core/maputils.h>
#include <msp/fs/dir.h>
+#include <msp/fs/stat.h>
#include <msp/fs/utils.h>
#include <msp/strings/format.h>
#include <msp/strings/utils.h>
#include "architecture.h"
#include "builder.h"
#include "component.h"
+#include "csourcefile.h"
#include "externaltask.h"
#include "gnucompiler.h"
+#include "objcsourcefile.h"
#include "objectfile.h"
#include "sourcefile.h"
#include "sourcepackage.h"
GnuCompiler::GnuCompiler(Builder &b, const Architecture &a, const string &t, const FS::Path &sysroot):
Tool(b, a, t)
{
+ if(tag=="CC")
+ {
+ input_suffixes.push_back(".c");
+ aux_suffixes.push_back(".h");
+ }
+ else if(tag=="CXX")
+ {
+ input_suffixes.push_back(".cpp");
+ input_suffixes.push_back(".cc");
+ aux_suffixes.push_back(".hpp");
+ }
+ else if(tag=="OBJC")
+ {
+ input_suffixes.push_back(".m");
+ build_info.libs.push_back("objc");
+ }
+ else
+ throw invalid_argument("GnuCompiler::GnuCompiler");
+
+ set_command((tag=="CXX" ? "g++" : "gcc"), true);
+
if(!sysroot.empty())
{
build_info.sysroot = sysroot;
system_path.push_back("/usr/"+architecture->get_cross_prefix()+"/include");
}
+Target *GnuCompiler::create_source(const Component &comp, const FS::Path &path) const
+{
+ if(tag=="OBJC")
+ return new ObjCSourceFile(builder, comp, path);
+ else
+ return new CSourceFile(builder, comp, path);
+}
+
+Target *GnuCompiler::create_source(const FS::Path &path) const
+{
+ if(tag=="OBJC")
+ return new ObjCSourceFile(builder, path);
+ else
+ return new CSourceFile(builder, path);
+}
+
Target *GnuCompiler::create_target(const list<Target *> &sources, const string &)
{
if(sources.size()!=1)
{
version = strip(ExternalTask::run_and_capture_output(argv));
builder.get_logger().log("tools", format("%s version is %s", FS::basename(executable->get_path()), version));
+
+ if(tag=="CXX")
+ {
+ const FS::Path &sysroot = build_info.sysroot;
+ FS::Path cxx_path = sysroot/"usr"/"include"/"c++"/version;
+ if(FS::is_dir(cxx_path))
+ system_path.push_back(cxx_path);
+ }
}
catch(const runtime_error &)
{ }
protected:
std::string version;
+public:
GnuCompiler(Builder &, const Architecture &, const std::string &, const Msp::FS::Path & = Msp::FS::Path());
-public:
+ virtual Target *create_source(const Component &, const Msp::FS::Path &) const;
+ virtual Target *create_source(const Msp::FS::Path &) const;
virtual Target *create_target(const std::list<Target *> &, const std::string &);
virtual std::string create_build_signature(const BuildInfo &) const;
protected:
+++ /dev/null
-#include <msp/fs/stat.h>
-#include "csourcefile.h"
-#include "gnucxxcompiler.h"
-
-using namespace std;
-using namespace Msp;
-
-GnuCxxCompiler::GnuCxxCompiler(Builder &b, const Architecture &a, const FS::Path &sysroot):
- GnuCompiler(b, a, "CXX", sysroot)
-{
- set_command("g++", true);
- input_suffixes.push_back(".cpp");
- input_suffixes.push_back(".cc");
- aux_suffixes.push_back(".hpp");
-}
-
-Target *GnuCxxCompiler::create_source(const Component &comp, const FS::Path &path) const
-{
- return new CSourceFile(builder, comp, path);
-}
-
-Target *GnuCxxCompiler::create_source(const FS::Path &path) const
-{
- return new CSourceFile(builder, path);
-}
-
-void GnuCxxCompiler::do_prepare()
-{
- GnuCompiler::do_prepare();
- if(!version.empty())
- {
- const FS::Path &sysroot = build_info.sysroot;
- FS::Path cxx_path = sysroot/"usr"/"include"/"c++"/version;
- if(FS::is_dir(cxx_path))
- system_path.push_back(cxx_path);
- }
-}
+++ /dev/null
-#ifndef GNUCXXCOMPILER_H_
-#define GNUCXXCOMPILER_H_
-
-#include "gnucompiler.h"
-
-/**
-The GNU C++ compiler, commonly known as g++.
-*/
-class GnuCxxCompiler: public GnuCompiler
-{
-public:
- GnuCxxCompiler(Builder &, const Architecture &, const Msp::FS::Path & = Msp::FS::Path());
-
- virtual Target *create_source(const Component &, const Msp::FS::Path &) const;
- virtual Target *create_source(const Msp::FS::Path &) const;
-
-protected:
- virtual void do_prepare();
-};
-
-#endif
+++ /dev/null
-#include "gnuobjccompiler.h"
-#include "objcsourcefile.h"
-
-using namespace Msp;
-
-GnuObjCCompiler::GnuObjCCompiler(Builder &b, const Architecture &a, const FS::Path &sysroot):
- GnuCompiler(b, a, "OBJC", sysroot)
-{
- set_command("gcc", true);
- input_suffixes.push_back(".m");
- build_info.libs.push_back("objc");
-}
-
-Target *GnuObjCCompiler::create_source(const Component &comp, const FS::Path &path) const
-{
- return new ObjCSourceFile(builder, comp, path);
-}
-
-Target *GnuObjCCompiler::create_source(const FS::Path &path) const
-{
- return new ObjCSourceFile(builder, path);
-}
+++ /dev/null
-#ifndef GNUOBJCCOMPILER_H_
-#define GNUOBJCCOMPILER_H_
-
-#include "gnucompiler.h"
-
-class GnuObjCCompiler: public GnuCompiler
-{
-public:
- GnuObjCCompiler(Builder &, const Architecture &, const Msp::FS::Path & = Msp::FS::Path());
-
- virtual Target *create_source(const Component &, const Msp::FS::Path &) const;
- virtual Target *create_source(const Msp::FS::Path &) const;
-};
-
-#endif
#include "architecture.h"
#include "builder.h"
-#include "clangccompiler.h"
-#include "clangcxxcompiler.h"
-#include "clangobjccompiler.h"
+#include "clangcompiler.h"
#include "gnuarchiver.h"
-#include "gnuccompiler.h"
-#include "gnucxxcompiler.h"
+#include "gnucompiler.h"
#include "gnulinker.h"
-#include "gnuobjccompiler.h"
#include "mingwdlltool.h"
#include "systemtools.h"
const string &sys = arch.get_system();
if((sys=="darwin" || sys=="freebsd") && builder.get_vfs().find_binary("clang"))
{
- add_tool(new ClangCCompiler(builder, arch));
- add_tool(new ClangCxxCompiler(builder, arch));
- add_tool(new ClangObjCCompiler(builder, arch));
+ add_tool(new ClangCompiler(builder, arch, "CC"));
+ add_tool(new ClangCompiler(builder, arch, "CXX"));
+ add_tool(new ClangCompiler(builder, arch, "OBJC"));
}
else
{
- add_tool(new GnuCCompiler(builder, arch));
- add_tool(new GnuCxxCompiler(builder, arch));
- add_tool(new GnuObjCCompiler(builder, arch));
+ add_tool(new GnuCompiler(builder, arch, "CC"));
+ add_tool(new GnuCompiler(builder, arch, "CXX"));
+ add_tool(new GnuCompiler(builder, arch, "OBJC"));
}
add_tool(new GnuLinker(builder, arch));