From e71eaecb9a31304fe5e096ea29660ea25c1bfa9f Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 30 Sep 2006 19:59:37 +0000 Subject: [PATCH] Allow requirements for components Use include path from component instead of package when resolving ObjectFile dependencies --- source/component.cpp | 21 +++++++++++++++++++++ source/component.h | 4 ++++ source/objectfile.cpp | 2 +- source/package.cpp | 2 ++ source/package.h | 1 + 5 files changed, 29 insertions(+), 1 deletion(-) diff --git a/source/component.cpp b/source/component.cpp index e0630e6..6d80f3b 100644 --- a/source/component.cpp +++ b/source/component.cpp @@ -10,9 +10,24 @@ Component::Component(Package &p, Type t, const string &n): install(false) { } +void Component::resolve_refs() +{ + for(list::iterator i=requires.begin(); i!=requires.end(); ++i) + i->resolve(); +} + void Component::create_build_info() { build_info.add(pkg.get_build_info()); + + for(list::iterator i=requires.begin(); i!=requires.end(); ++i) + { + if(!i->get_package()) + continue; + i->get_package()->create_build_info(); + build_info.add(i->get_package()->get_exported_binfo()); + } + build_info.unique(); } @@ -23,6 +38,7 @@ Component::Loader::Loader(Component &c): add("install", &Component::install); add("install_headers", &Component::install_headers); add("build_info", &Loader::build_info); + add("require", &Loader::require); } void Component::Loader::source(const string &s) @@ -30,6 +46,11 @@ void Component::Loader::source(const string &s) comp.sources.push_back(comp.pkg.get_source()/s); } +void Component::Loader::require(const string &n) +{ + comp.requires.push_back(PackageRef(comp.pkg.get_builder(), n)); +} + void Component::Loader::build_info() { load_sub(comp.build_info); diff --git a/source/component.h b/source/component.h index b1ce222..04a0a41 100644 --- a/source/component.h +++ b/source/component.h @@ -6,6 +6,7 @@ #include #include "buildinfo.h" #include "misc.h" +#include "packageref.h" class Package; @@ -21,6 +22,7 @@ public: Component ∁ void source(const std::string &); + void require(const std::string &); void build_info(); }; @@ -40,6 +42,7 @@ public: const BuildInfo &get_build_info() const { return build_info; } bool get_install() const { return install; } const std::string &get_install_headers() const { return install_headers; } + void resolve_refs(); void create_build_info(); protected: Package &pkg; @@ -49,6 +52,7 @@ protected: bool install; std::string install_headers; BuildInfo build_info; + std::list requires; }; typedef std::list ComponentList; diff --git a/source/objectfile.cpp b/source/objectfile.cpp index bba701d..8fbbed1 100644 --- a/source/objectfile.cpp +++ b/source/objectfile.cpp @@ -59,7 +59,7 @@ void ObjectFile::find_depends(Target *tgt) const list &includes=src->get_includes(); for(list::const_iterator i=includes.begin(); i!=includes.end(); ++i) { - Target *hdr2=builder.get_header(*i, path, package->get_build_info().incpath); + Target *hdr2=builder.get_header(*i, path, comp.get_build_info().incpath); if(hdr2 && !contains(depends, hdr2)) add_depend(hdr2); } diff --git a/source/package.cpp b/source/package.cpp index 2d5d97c..c55e5f4 100644 --- a/source/package.cpp +++ b/source/package.cpp @@ -38,6 +38,8 @@ void Package::resolve_refs() { for(list::iterator i=requires.begin(); i!=requires.end(); ++i) i->resolve(); + for(ComponentList::iterator i=components.begin(); i!=components.end(); ++i) + i->resolve_refs(); } void Package::create_build_info() diff --git a/source/package.h b/source/package.h index d5402ef..bb2c413 100644 --- a/source/package.h +++ b/source/package.h @@ -40,6 +40,7 @@ public: const std::list &get_requires() const { return requires; } const BuildInfo &get_build_info() const { return build_info; } const BuildInfo &get_exported_binfo() const { return export_binfo; } + Builder &get_builder() const { return builder; } void resolve_refs(); void create_build_info(); void process_options(const RawOptionMap &); -- 2.43.0