]> git.tdb.fi Git - builder.git/commitdiff
Pass the full path to the Build file to SourcePackage and create a target for it
authorMikko Rasa <tdb@tdb.fi>
Tue, 17 Jul 2012 11:30:11 +0000 (14:30 +0300)
committerMikko Rasa <tdb@tdb.fi>
Tue, 17 Jul 2012 11:30:11 +0000 (14:30 +0300)
source/builder.cpp
source/builder.h
source/sourcepackage.cpp
source/sourcepackage.h

index 6c508026c6e7a67e6b32198609e3a5c112d21d9b..1c90aa8e2229ac6192fcc9bff7c92b7c59417e2a 100644 (file)
@@ -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<Builder>(b),
-       src(s)
+Builder::Loader::Loader(Builder &b):
+       DataFile::ObjectLoader<Builder>(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;
 
index 4359d4563f7214849b89ed6e4f3495e1565f36dc..b6c9ebcfc3caee4d6bfe57c59d7b69ba8be895b8 100644 (file)
@@ -32,11 +32,8 @@ class Builder: public Msp::RegisteredApplication<Builder>
 private:
        class Loader: public Msp::DataFile::ObjectLoader<Builder>
        {
-       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 &);
index 4b45bb73b643a5f7b3934f51bed4a40b2a1ad036..d0524e84dab7af88e1d48f40c63fdded7b00e677 100644 (file)
@@ -1,9 +1,11 @@
 #include <cstdlib>
+#include <msp/fs/utils.h>
 #include <msp/io/print.h>
 #include <msp/strings/lexicalcast.h>
 #include <msp/strings/utils.h>
 #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"));
 }
 
index c143a276f0db446b142d3e860172c3de2ff72324..b8d19090eed92aa5d653589d14296d50829442b8 100644 (file)
@@ -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;