FileTarget(b, 0, p)
{ }
-Binary::Binary(Builder &b, const Component &c, const list<ObjectFile *> &objs):
- FileTarget(b, &c.get_package(), generate_target_path(c))
+Binary::Binary(Builder &b, const Component &c, const std::string &p, const list<ObjectFile *> &objs):
+ FileTarget(b, &c.get_package(), c.get_package().get_out_dir()/p)
{
component = &c;
for(list<ObjectFile *>::const_iterator i=objs.begin(); i!=objs.end(); ++i)
deps_ready = true;
}
-
-FS::Path Binary::generate_target_path(const Component &c)
-{
- const SourcePackage &pkg = c.get_package();
- string prefix, suffix;
- const string &sys = pkg.get_builder().get_current_arch().get_system();
-
- if(c.get_type()==Component::LIBRARY)
- {
- prefix = "lib";
- if(sys=="windows")
- suffix = ".dll";
- else
- suffix = ".so";
- }
- else if(c.get_type()==Component::MODULE)
- suffix = ".m";
- else if(c.get_type()==Component::PROGRAM)
- {
- if(sys=="windows")
- suffix = ".exe";
- }
-
- return pkg.get_out_dir()/(prefix+c.get_name()+suffix);
-}
{
protected:
Binary(Builder &, const Msp::FS::Path &);
- Binary(Builder &, const Component &, const std::list<ObjectFile *> &);
+ Binary(Builder &, const Component &, const std::string &, const std::list<ObjectFile *> &);
+
public:
virtual void find_depends();
-protected:
- /** Returns the path for the binary. We can't do this in the constructor
- since we need to pass the value to the Target c'tor. */
- static Msp::FS::Path generate_target_path(const Component &);
};
#endif
+#include "builder.h"
#include "component.h"
#include "executable.h"
#include "sourcepackage.h"
+using namespace std;
+using namespace Msp;
+
Executable::Executable(Builder &b, const Component &c, const std::list<ObjectFile *> &objs):
- Binary(b, c, objs)
+ Binary(b, c, generate_filename(c), objs)
{
install_location = "bin";
}
+
+string Executable::generate_filename(const Component &comp)
+{
+ const Architecture &arch = comp.get_package().get_builder().get_current_arch();
+ return arch.get_executable_patterns().front().apply(comp.get_name());
+}
{
public:
Executable(Builder &, const Component &, const std::list<ObjectFile *> &);
+
virtual const char *get_type() const { return "Executable"; }
+private:
+ static std::string generate_filename(const Component &);
};
#endif
#include <msp/fs/utils.h>
#include <msp/strings/format.h>
+#include "builder.h"
#include "component.h"
#include "sharedlibrary.h"
#include "sourcepackage.h"
}
SharedLibrary::SharedLibrary(Builder &b, const Component &c, const list<ObjectFile *> &objs):
- Binary(b, c, objs),
+ Binary(b, c, generate_filename(c), objs),
libname(c.get_name()),
soname(create_soname(c))
{
}
}
+string SharedLibrary::generate_filename(const Component &comp)
+{
+ if(comp.get_type()==Component::MODULE)
+ return comp.get_name()+".m";
+ else
+ {
+ const Architecture &arch = comp.get_package().get_builder().get_current_arch();
+ return arch.get_shared_library_patterns().front().apply(comp.get_name());
+ }
+}
+
string SharedLibrary::create_soname(const Component &c)
{
const string &ver = c.get_package().get_version();
const std::string &get_soname() const { return soname; }
private:
+ static std::string generate_filename(const Component &);
std::string create_soname(const Component &);
};
+#include "builder.h"
#include "component.h"
#include "objectfile.h"
#include "sourcepackage.h"
Msp::FS::Path StaticLibrary::generate_target_path(const Component &c)
{
- return c.get_package().get_out_dir()/("lib"+c.get_name()+".a");
+ const Architecture &arch = c.get_package().get_builder().get_current_arch();
+ return c.get_package().get_out_dir()/
+ arch.get_static_library_patterns().front().apply(c.get_name());
}