-/* $Id$
-
-This file is part of builder
-Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
#ifndef SOURCEPACKAGE_H_
#define SOURCEPACKAGE_H_
+#include <stdexcept>
#include <string>
#include "buildinfo.h"
#include "component.h"
#include "dependencycache.h"
#include "feature.h"
#include "package.h"
-#include "packageref.h"
class Builder;
+class BuildType;
+
+class bad_expansion: public std::runtime_error
+{
+public:
+ bad_expansion(const std::string &w): std::runtime_error(w) { }
+ virtual ~bad_expansion() throw() { }
+};
/**
A package that can be built by Builder.
class SourcePackage: public Package
{
public:
- enum InstallFlags
+ class Loader: public Msp::DataFile::DerivedObjectLoader<SourcePackage, Package>
{
- INCLUDE=1,
- BIN=2,
- LIB=4,
- DATA=8
- };
+ private:
+ std::map<std::string, std::string> install_map;
- /// Loads a package from a file.
- class Loader: public Package::Loader
- {
public:
- Loader(Package &);
- SourcePackage &get_object() { return static_cast<SourcePackage &>(pkg); }
+ Loader(SourcePackage &);
private:
+ virtual void finish();
void feature(const std::string &, const std::string &);
+ template<Component::Type>
+ void component(const std::string &);
void condition(const std::string &);
- void program(const std::string &);
- void library(const std::string &);
- void module(const std::string &);
- void headers(const std::string &);
void build_info();
+ void headers(const std::string &);
+ void tarball(const std::string &);
void tar_file(const std::string &);
};
- SourcePackage(Builder &, const std::string &, const Msp::Path::Path &);
- void set_path(const Msp::Path::Path &);
- const std::string &get_name() const { return name; }
- const std::string &get_version() const { return version; }
- const std::string &get_description() const { return description; }
- const Msp::Path::Path &get_source() const { return source; }
- Msp::Path::Path get_temp_dir() const;
- Msp::Path::Path get_out_dir() const;
- Msp::Path::Path get_prefix() const { return config.get_option("prefix").value; }
- const ComponentList &get_components() const { return components; }
- const Config &get_config() const { return config; }
- const BuildInfo &get_build_info() const { return build_info; }
- const BuildInfo &get_exported_binfo() const { return export_binfo; }
- Builder &get_builder() const { return builder; }
- unsigned get_install_flags();
- const std::string &get_arch() const { return config.get_option("arch").value; }
- LibMode get_library_mode() const;
- const PathList &get_tar_files() const { return tar_files; }
- DependencyCache &get_deps_cache() const { return deps_cache; }
- virtual void resolve_refs();
private:
- std::string version;
- std::string description;
+ std::string version;
+ std::string description;
- Msp::Path::Path source;
- PackageList all_reqs;
- FeatureList features;
- BuildInfo build_info;
+ Msp::FS::Path source;
+ const BuildType *build_type;
+ FeatureList features;
+ BuildInfo build_info;
ConditionList conditions;
ComponentList components;
- Config config;
- bool conf_done;
+ Config config;
mutable DependencyCache deps_cache;
- PathList tar_files;
- //Package(Builder &, const std::string &, const std::vector<std::string> &);
+public:
+ SourcePackage(Builder &, const std::string &, const Msp::FS::Path &);
+ const std::string &get_version() const { return version; }
+ const std::string &get_description() const { return description; }
+ const Msp::FS::Path &get_source() const { return source; }
+ Msp::FS::Path get_temp_dir() const;
+ Msp::FS::Path get_out_dir() const;
+ const ComponentList &get_components() const { return components; }
+ const Config &get_config() const { return config; }
+ void set_build_type(const BuildType &);
+ const BuildInfo &get_build_info() const { return build_info; }
+ Builder &get_builder() const { return builder; }
+
+ DependencyCache &get_deps_cache() const { return deps_cache; }
+ std::string expand_string(const std::string &) const;
+private:
virtual void do_configure(const StringMap &, unsigned);
- void init_config();
+
+ /** Initializes configuration options. */
+ void init_config();
+
+ /** Fills in build info based on configuration. All required packages must be
+ configured when this is called. */
virtual void create_build_info();
+
+ virtual void create_targets();
+
+ virtual void save_caches();
};
#endif