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;
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);
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;
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 &);
#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"
}
-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"));
}
class Builder;
class BuildType;
+class FileTarget;
class bad_expansion: public std::runtime_error
{
std::string version;
std::string description;
+ FileTarget *build_file;
Msp::FS::Path source_dir;
const BuildType *build_type;
FeatureList features;
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;