--- /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
#include "clangccompiler.h"
#include "clangcxxcompiler.h"
+#include "clangobjccompiler.h"
#include "clangtools.h"
ClangTools::ClangTools(Builder &builder, const Architecture &arch)
{
add_tool(new ClangCCompiler(builder, arch));
add_tool(new ClangCxxCompiler(builder, arch));
+ add_tool(new ClangObjCCompiler(builder, arch));
}
install_location = FS::Path("include")/package->get_name();
}
+void CSourceFile::parse_includes(IO::Base &in)
+{
+ static Regex r_include("^[ \t]*#include[ \t]+([\"<].*)[\">]");
+
+ string line;
+ while(in.getline(line))
+ if(RegMatch match = r_include.match(line))
+ includes.push_back(match[1].str);
+}
+
void CSourceFile::find_dependencies()
{
if(!component || !mtime)
builder.get_logger().log("files", format("Reading includes from %s", path.str()));
- Regex r_include("^[ \t]*#include[ \t]+([\"<].*)[\">]");
-
- string line;
- while(in.getline(line))
- if(RegMatch match = r_include.match(line))
- includes.push_back(match[1].str);
-
+ parse_includes(in);
cache.set_values(this, "includes", includes);
}
#ifndef CSOURCEFILE_H_
#define CSOURCEFILE_H_
+#include <msp/io/base.h>
#include "sourcefile.h"
/**
public:
typedef std::list<std::string> IncludeList;
-private:
+protected:
IncludeList includes;
public:
virtual const char *get_type() const { return "CSourceFile"; }
const IncludeList &get_includes() const { return includes; }
-private:
+protected:
+ virtual void parse_includes(Msp::IO::Base &);
virtual void find_dependencies();
virtual void modified();
};
argv.push_back(relative(bin.get_path(), work_dir).str());
bool static_link_ok = (binfo.libmode<=BuildInfo::STATIC);
+ bool need_l_objc = false;
const Target::Dependencies &depends = target.get_dependencies();
for(Target::Dependencies::const_iterator i=depends.begin(); i!=depends.end(); ++i)
Target *tgt = (*i)->get_real_target();
if(ObjectFile *obj = dynamic_cast<ObjectFile *>(tgt))
+ {
argv.push_back(relative(obj->get_path(), work_dir).str());
+ /* XXX This is a hack. A more generic way is needed for tools to pass
+ information down the chain. */
+ if(obj->get_tool()->get_tag()=="OBJC")
+ need_l_objc = true;
+ }
else if(StaticLibrary *stlib = dynamic_cast<StaticLibrary *>(tgt))
argv.push_back((file?file:stlib)->get_path().str());
else if(SharedLibrary *shlib = dynamic_cast<SharedLibrary *>(tgt))
}
}
+ if(need_l_objc)
+ argv.push_back("-lobjc");
if(static_link_ok)
argv.push_back("-static");
else if(architecture->get_system()=="windows")
--- /dev/null
+#include "gnuobjccompiler.h"
+#include "objcsourcefile.h"
+
+using namespace Msp;
+
+GnuObjCCompiler::GnuObjCCompiler(Builder &b, const Architecture &a):
+ GnuCompiler(b, a, "OBJC")
+{
+ set_command("gcc", true);
+ input_suffixes.push_back(".m");
+}
+
+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 &);
+
+ virtual Target *create_source(const Component &, const Msp::FS::Path &) const;
+ virtual Target *create_source(const Msp::FS::Path &) const;
+};
+
+#endif
#include "gnuccompiler.h"
#include "gnucxxcompiler.h"
#include "gnulinker.h"
+#include "gnuobjccompiler.h"
#include "gnutools.h"
#include "mingwdlltool.h"
{
add_tool(new GnuCCompiler(builder, arch));
add_tool(new GnuCxxCompiler(builder, arch));
+ add_tool(new GnuObjCCompiler(builder, arch));
add_tool(new GnuLinker(builder, arch));
add_tool(new GnuArchiver(builder, arch));
if(arch.get_system()=="windows")
--- /dev/null
+#include <msp/strings/regex.h>
+#include "objcsourcefile.h"
+
+using namespace std;
+using namespace Msp;
+
+ObjCSourceFile::ObjCSourceFile(Builder &b, const FS::Path &p):
+ CSourceFile(b, p)
+{ }
+
+ObjCSourceFile::ObjCSourceFile(Builder &b, const Component &c, const FS::Path &p):
+ CSourceFile(b, c, p)
+{ }
+
+void ObjCSourceFile::parse_includes(IO::Base &in)
+{
+ static Regex r_include("^[ \t]*#(include|import)[ \t]+([\"<].*)[\">]");
+
+ string line;
+ while(in.getline(line))
+ if(RegMatch match = r_include.match(line))
+ includes.push_back(match[2].str);
+}
--- /dev/null
+#ifndef OBJCSOURCEFILE_H_
+#define OBJCSOURCEFILE_H_
+
+#include "csourcefile.h"
+
+/**
+Represents an Objective-C source file.
+*/
+class ObjCSourceFile: public CSourceFile
+{
+public:
+ ObjCSourceFile(Builder &, const Msp::FS::Path &);
+ ObjCSourceFile(Builder &, const Component &, const Msp::FS::Path &);
+
+ virtual const char *get_type() const { return "ObjCSourceFile"; }
+
+protected:
+ virtual void parse_includes(Msp::IO::Base &);
+};
+
+#endif