From: Mikko Rasa Date: Sun, 8 Jul 2012 23:14:28 +0000 (+0300) Subject: Don't store component locally in object and source files X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=2aaad259f2dff58c1e909f1e6d83961e78fd7d3e;p=builder.git Don't store component locally in object and source files --- diff --git a/source/csourcefile.cpp b/source/csourcefile.cpp index 0ff4286..7a26bb5 100644 --- a/source/csourcefile.cpp +++ b/source/csourcefile.cpp @@ -19,15 +19,15 @@ CSourceFile::CSourceFile(Builder &b, const Component &c, const FS::Path &p): { string ext = FS::extpart(FS::basename(path)); if(ext==".h" || ext==".H" || ext==".hpp") - install_location = "include/"+comp->get_name(); + install_location = "include/"+component->get_name(); } void CSourceFile::find_depends() { - if(!comp || !mtime) + if(!component || !mtime) return; - const SourcePackage &spkg = comp->get_package(); + const SourcePackage &spkg = component->get_package(); string relname = FS::relative(path, spkg.get_source()).str(); DependencyCache &deps_cache = spkg.get_deps_cache(); @@ -49,7 +49,7 @@ void CSourceFile::find_depends() deps_cache.set_deps(relname, includes); } - const BuildInfo::PathList &incpath = comp->get_build_info().incpath; + const BuildInfo::PathList &incpath = component->get_build_info().incpath; BuildInfo::PathList local_incpath = incpath; local_incpath.push_front(FS::dirname(path).str()); diff --git a/source/gnuarchiver.cpp b/source/gnuarchiver.cpp index 3f96cbf..71edc42 100644 --- a/source/gnuarchiver.cpp +++ b/source/gnuarchiver.cpp @@ -39,7 +39,7 @@ Target *GnuArchiver::create_target(const list &sources, const string & throw invalid_argument("GnuArchiver::create_target"); } - const Component &comp = objs.front()->get_component(); + const Component &comp = *objs.front()->get_component(); StaticLibrary *lib = new StaticLibrary(builder, comp, objs); lib->set_tool(*this); return lib; diff --git a/source/gnucompiler.cpp b/source/gnucompiler.cpp index 8df1a72..747d963 100644 --- a/source/gnucompiler.cpp +++ b/source/gnucompiler.cpp @@ -40,7 +40,7 @@ Target *GnuCompiler::create_target(const list &sources, const string & Task *GnuCompiler::run(const Target &target) const { const ObjectFile &object = dynamic_cast(target); - const Component &comp = object.get_component(); + const Component &comp = *object.get_component(); ExternalTask::Arguments argv; argv.push_back(executable->get_path().str()); diff --git a/source/gnulinker.cpp b/source/gnulinker.cpp index 719780b..1335287 100644 --- a/source/gnulinker.cpp +++ b/source/gnulinker.cpp @@ -63,7 +63,7 @@ Target *GnuLinker::create_target(const list &sources, const string &ar throw invalid_argument("GnuLinker::create_target"); } - const Component &comp = objs.front()->get_component(); + const Component &comp = *objs.front()->get_component(); Binary *bin = 0; if(arg=="shared") bin = new SharedLibrary(builder, comp, objs); diff --git a/source/objectfile.cpp b/source/objectfile.cpp index 7db1b2d..22f11fa 100644 --- a/source/objectfile.cpp +++ b/source/objectfile.cpp @@ -11,9 +11,9 @@ using namespace Msp; ObjectFile::ObjectFile(Builder &b, const Component &c, SourceFile &s): FileTarget(b, &c.get_package(), generate_target_path(c, FS::relative(s.get_path(), c.get_package().get_source()).str())), - comp(c), source(s) { + component = &c; add_depend(&source); } diff --git a/source/objectfile.h b/source/objectfile.h index 9754095..2e9b6e1 100644 --- a/source/objectfile.h +++ b/source/objectfile.h @@ -3,7 +3,6 @@ #include "filetarget.h" -class Component; class SourceFile; /** @@ -12,7 +11,6 @@ Object files are compiled from source files. class ObjectFile: public FileTarget { private: - const Component ∁ SourceFile &source; public: @@ -22,7 +20,6 @@ private: public: virtual const char *get_type() const { return "ObjectFile"; } - const Component &get_component() const { return comp; } SourceFile &get_source() const { return source; } /** Processes as many new dependences as possible. Some may be created on diff --git a/source/sourcefile.cpp b/source/sourcefile.cpp index 13b337e..220facd 100644 --- a/source/sourcefile.cpp +++ b/source/sourcefile.cpp @@ -3,6 +3,7 @@ #include "sourcepackage.h" SourceFile::SourceFile(Builder &b, const Component *c, const Msp::FS::Path &p): - FileTarget(b, (c ? &c->get_package() : 0), p), - comp(c) -{ } + FileTarget(b, (c ? &c->get_package() : 0), p) +{ + component = c; +} diff --git a/source/sourcefile.h b/source/sourcefile.h index 9f126ac..30a5080 100644 --- a/source/sourcefile.h +++ b/source/sourcefile.h @@ -3,17 +3,10 @@ #include "filetarget.h" -class Component; - class SourceFile: public FileTarget { protected: - const Component *comp; - SourceFile(Builder &, const Component *, const Msp::FS::Path &); - -public: - const Component *get_component() const { return comp; } }; #endif