using namespace std;
using namespace Msp;
+Binary::Binary(Builder &b, const FS::Path &p):
+ FileTarget(b, 0, p)
+{ }
+
Binary::Binary(Builder &b, const Component &c, const list<ObjectFile *> &objs):
FileTarget(b, &c.get_package(), generate_target_path(c))
{
void Binary::find_depends()
{
if(!component)
+ {
+ deps_ready = true;
return;
+ }
const SourcePackage &spkg = component->get_package();
LibMode libmode = spkg.get_library_mode();
Produces a binary file, which may be either a standalone executable or a shared
library.
*/
-class Binary: public virtual FileTarget
+class Binary: public FileTarget
{
protected:
+ Binary(Builder &, const Msp::FS::Path &);
Binary(Builder &, const Component &, const std::list<ObjectFile *> &);
public:
virtual void find_depends();
#include "pkgconfiggenerator.h"
#include "sharedlibrary.h"
#include "sourcepackage.h"
-#include "systemlibrary.h"
#include "tar.h"
#include "task.h"
#include "virtualtarget.h"
#include "sourcepackage.h"
Executable::Executable(Builder &b, const Component &c, const std::list<ObjectFile *> &objs):
- FileTarget(b, &c.get_package(), generate_target_path(c)),
Binary(b, c, objs)
{
install_location = "bin";
Task *GnuLinker::run(const Target &target) const
{
const Binary &bin = dynamic_cast<const Binary &>(target);
- const SharedLibrary *shlib = dynamic_cast<const SharedLibrary *>(&bin);
string command = "gcc";
const Component &comp = *bin.get_component();
- if(shlib)
+ if(const SharedLibrary *shlib = dynamic_cast<const SharedLibrary *>(&bin))
{
argv.push_back("-shared");
argv.push_back("-fPIC");
argv.push_back(relative(obj->get_path(), work_dir).str());
else if(StaticLibrary *stlib = dynamic_cast<StaticLibrary *>(tgt))
argv.push_back(stlib->get_path().str());
- else if(Library *lib = dynamic_cast<Library *>(tgt))
- argv.push_back("-l"+lib->get_libname());
+ else if(SharedLibrary *shlib = dynamic_cast<SharedLibrary *>(tgt))
+ argv.push_back("-l"+shlib->get_libname());
}
if(!builder.get_dry_run())
+++ /dev/null
-#include "library.h"
-
-Library::Library(Builder &b, const Package *p, const Msp::FS::Path &a, const std::string &l):
- FileTarget(b, p, a),
- libname(l)
-{ }
+++ /dev/null
-#ifndef LIBRARY_H_
-#define LIBRARY_H_
-
-#include "filetarget.h"
-
-class Library: public virtual FileTarget
-{
-protected:
- std::string libname;
-
- Library(Builder &, const Package *, const Msp::FS::Path &, const std::string &);
-public:
- const std::string &get_libname() const { return libname; }
-};
-
-#endif
using namespace std;
using namespace Msp;
+SharedLibrary::SharedLibrary(Builder &b, const Msp::FS::Path &p):
+ Binary(b, p)
+{
+ libname = FS::basepart(FS::basename(path));
+ if(!libname.compare(0, 3, "lib"))
+ libname = libname.substr(3);
+}
+
SharedLibrary::SharedLibrary(Builder &b, const Component &c, const list<ObjectFile *> &objs):
- FileTarget(b, &c.get_package(), generate_target_path(c)),
Binary(b, c, objs),
- Library(b, &c.get_package(), path, c.get_name()),
+ libname(c.get_name()),
soname(create_soname(c))
{
install_location = "lib";
#define SHAREDLIB_H_
#include "binary.h"
-#include "library.h"
/**
-Represents a shared library. Mainly exists to give extra information to the
-user.
+Represents a shared library. It has two special properties: libname and
+soname. Libname is the name used by the linker. Soname is the canonical
+filename of the library, including version number. If the owning package has
+no version, soname will be empty.
*/
-class SharedLibrary: public Binary, public Library
+class SharedLibrary: public Binary
{
private:
+ std::string libname;
std::string soname;
public:
+ SharedLibrary(Builder &, const Msp::FS::Path &);
SharedLibrary(Builder &, const Component &, const std::list<ObjectFile *> &);
+
virtual const char *get_type() const { return "SharedLibrary"; }
+ const std::string &get_libname() const { return libname; }
const std::string &get_soname() const { return soname; }
private:
#include "staticlibrary.h"
using namespace std;
+using namespace Msp;
+
+StaticLibrary::StaticLibrary(Builder &b, const FS::Path &p):
+ FileTarget(b, 0, p)
+{ }
StaticLibrary::StaticLibrary(Builder &b, const Component &c, const list<ObjectFile *> &objs):
- FileTarget(b, &c.get_package(), generate_target_path(c)),
- Library(b, package, path, c.get_name())
+ FileTarget(b, &c.get_package(), generate_target_path(c))
{
component = &c;
for(list<ObjectFile *>::const_iterator i=objs.begin(); i!=objs.end(); ++i)
#ifndef STATICLIBRARY_H_
#define STATICLIBRARY_H_
-#include "library.h"
+#include "filetarget.h"
class Component;
class ObjectFile;
/**
A static library target.
*/
-class StaticLibrary: public Library
+class StaticLibrary: public FileTarget
{
public:
+ StaticLibrary(Builder &, const Msp::FS::Path &);
StaticLibrary(Builder &, const Component &, const std::list<ObjectFile *> &);
virtual const char *get_type() const { return "StaticLibrary"; }
+++ /dev/null
-#include <msp/fs/path.h>
-#include <msp/fs/utils.h>
-#include "systemlibrary.h"
-
-using namespace std;
-using namespace Msp;
-
-SystemLibrary::SystemLibrary(Builder &b, const FS::Path &p):
- FileTarget(b, 0, p),
- Library(b, 0, p, extract_libname(p))
-{ }
-
-string SystemLibrary::extract_libname(const FS::Path &p)
-{
- string result = FS::basepart(FS::basename(p));
- if(!result.compare(0, 3, "lib"))
- result.erase(0, 3);
- return result;
-}
+++ /dev/null
-#ifndef SYSTEMLIBRARY_H_
-#define SYSTEMLIBRARY_H_
-
-#include "library.h"
-
-/**
-A library that doesn't belong to any known package.
-*/
-class SystemLibrary: public Library
-{
-public:
- SystemLibrary(Builder &, const Msp::FS::Path &);
-
- virtual const char *get_type() const { return "SystemLibrary"; }
-private:
- static std::string extract_libname(const Msp::FS::Path &);
-};
-
-#endif
#include "csourcefile.h"
#include "misc.h"
#include "sharedlibrary.h"
-#include "systemlibrary.h"
+#include "staticlibrary.h"
#include "virtualfilesystem.h"
using namespace std;
{
FileTarget *tgt = get_target(fn);
if(!tgt)
- return new SystemLibrary(builder, fn.str());
+ return new SharedLibrary(builder, fn);
else if(mode==DYNAMIC || !tgt->get_package())
return tgt;
}
if(FileTarget *tgt = get_target(fn))
return tgt;
else
- return new SystemLibrary(builder, fn.str());
+ return new StaticLibrary(builder, fn);
}
return 0;