From edb6076ccae6347acb84868563144a63e6ceba02 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 17 Jul 2012 14:30:11 +0300 Subject: [PATCH] Pass the full path to the Build file to SourcePackage and create a target for it --- source/builder.cpp | 9 ++++----- source/builder.h | 5 +---- source/sourcepackage.cpp | 9 +++++++-- source/sourcepackage.h | 3 +++ 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/source/builder.cpp b/source/builder.cpp index 6c50802..1c90aa8 100644 --- a/source/builder.cpp +++ b/source/builder.cpp @@ -365,7 +365,7 @@ int Builder::load_build_file(const FS::Path &fn) logger.log("files", format("Reading %s", fn)); DataFile::Parser parser(in, fn.str()); - Loader loader(*this, fn.subpath(0, fn.size()-1)); + Loader loader(*this); loader.load(parser); return 0; @@ -579,9 +579,8 @@ string Builder::usagemsg; string Builder::helpmsg; -Builder::Loader::Loader(Builder &b, const FS::Path &s): - DataFile::ObjectLoader(b), - src(s) +Builder::Loader::Loader(Builder &b): + DataFile::ObjectLoader(b) { add("architecture", &Loader::architecture); add("binary_package", &Loader::binpkg); @@ -618,7 +617,7 @@ void Builder::Loader::profile(const string &) void Builder::Loader::package(const string &n) { - SourcePackage *pkg = new SourcePackage(obj, n, src); + SourcePackage *pkg = new SourcePackage(obj, n, get_source()); if(!obj.main_pkg) obj.main_pkg = pkg; diff --git a/source/builder.h b/source/builder.h index 4359d45..b6c9ebc 100644 --- a/source/builder.h +++ b/source/builder.h @@ -32,11 +32,8 @@ class Builder: public Msp::RegisteredApplication private: class Loader: public Msp::DataFile::ObjectLoader { - private: - Msp::FS::Path src; - public: - Loader(Builder &, const Msp::FS::Path &); + Loader(Builder &); private: void architecture(const std::string &); void binpkg(const std::string &); diff --git a/source/sourcepackage.cpp b/source/sourcepackage.cpp index 4b45bb7..d0524e8 100644 --- a/source/sourcepackage.cpp +++ b/source/sourcepackage.cpp @@ -1,9 +1,11 @@ #include +#include #include #include #include #include "binarypackage.h" #include "builder.h" +#include "file.h" #include "misc.h" #include "pkgconfigfile.h" #include "tool.h" @@ -20,15 +22,18 @@ bool component_sort(const Component &c1, const Component &c2) } -SourcePackage::SourcePackage(Builder &b, const string &n, const FS::Path &s): +SourcePackage::SourcePackage(Builder &b, const string &n, const FS::Path &f): Package(b, n), - source_dir(s), + source_dir(FS::dirname(f)), build_type(0), config(*this), deps_cache(*this) { config.load(); + build_file = builder.get_vfs().get_target(f); + if(!build_file) + build_file = new File(builder, *this, f); components.push_back(Component(*this, Component::TARBALL, "@src")); } diff --git a/source/sourcepackage.h b/source/sourcepackage.h index c143a27..b8d1909 100644 --- a/source/sourcepackage.h +++ b/source/sourcepackage.h @@ -13,6 +13,7 @@ class Builder; class BuildType; +class FileTarget; class bad_expansion: public std::runtime_error { @@ -57,6 +58,7 @@ private: std::string version; std::string description; + FileTarget *build_file; Msp::FS::Path source_dir; const BuildType *build_type; FeatureList features; @@ -70,6 +72,7 @@ public: const std::string &get_version() const { return version; } const std::string &get_description() const { return description; } + FileTarget &get_build_file() const { return *build_file; } const Msp::FS::Path &get_source_directory() const { return source_dir; } Msp::FS::Path get_temp_dir() const; Msp::FS::Path get_out_dir() const; -- 2.43.0