source "Readme.txt";
source "License.txt";
};
+
+ install "share/builder"
+ {
+ source "builderrc";
+ };
};
native_arch->set_tool("AR", "ar");
load_build_file((FS::get_sys_data_dir(argv[0], "builder")/"builderrc").str());
- load_build_file((FS::get_home_dir()/".builderrc").str());
+ load_build_file((FS::get_user_data_dir("builder")/"rc").str());
if(arch.empty())
current_arch=native_arch;
Target *def_tgt=builder.get_target("default");
PathList files=collect_source_files();
+ list<FileTarget *> inst_list;
+ string inst_loc;
if(type==TARBALL)
{
string tarname=name;
return;
}
-
- list<FileTarget *> inst_list;
- for(PathList::const_iterator i=files.begin(); i!=files.end(); ++i)
+ else if(type==INSTALL)
{
- string ext=FS::extpart(FS::basename(*i));
- if(ext==".h")
+ inst_loc=name;
+ for(PathList::const_iterator i=files.begin(); i!=files.end(); ++i)
{
- FileTarget *hdr=dynamic_cast<FileTarget *>(builder.get_target(i->str()));
- if(!hdr)
- hdr=new Header(builder, this, i->str());
+ FileTarget *ft;
+ if(Target *tgt=builder.get_target(i->str()))
+ ft=dynamic_cast<FileTarget *>(tgt);
+ else
+ ft=new File(builder, pkg, *i);
+ inst_list.push_back(ft);
+ }
+ }
+ else
+ {
+ for(PathList::const_iterator i=files.begin(); i!=files.end(); ++i)
+ {
+ string ext=FS::extpart(FS::basename(*i));
+ if(ext==".h")
+ {
+ FileTarget *hdr=dynamic_cast<FileTarget *>(builder.get_target(i->str()));
+ if(!hdr)
+ hdr=new Header(builder, *this, i->str());
- // Install headers if requested
- if(type==HEADERS && install)
- inst_list.push_back(hdr);
+ // Install headers if requested
+ if(type==HEADERS && install)
+ inst_list.push_back(hdr);
+ }
}
}
string ext=FS::extpart(FS::basename(*i));
if((ext==".cpp" || ext==".cc" || ext==".c"))
{
- SourceFile *src=new SourceFile(builder, this, i->str());
+ SourceFile *src=new SourceFile(builder, *this, i->str());
ObjectFile *obj=new ObjectFile(builder, *this, *src);
objs.push_back(obj);
}
Target *inst_tgt=builder.get_target("install");
for(list<FileTarget *>::const_iterator i=inst_list.begin(); i!=inst_list.end(); ++i)
- inst_tgt->add_depend(new Install(builder, pkg, **i));
+ inst_tgt->add_depend(new Install(builder, pkg, **i, inst_loc));
}
PathList Component::collect_source_files() const
enum Type
{
HEADERS,
- PROGRAM,
LIBRARY,
+ PROGRAM,
MODULE,
- TARBALL
+ TARBALL,
+ INSTALL
};
protected:
+++ /dev/null
-/* $Id$
-
-This file is part of builder
-Copyright © 2007, 2009 Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
-#include "file.h"
-
-File::File(Builder &b, const Msp::FS::Path &p):
- FileTarget(b, 0, p)
-{ }
#include "filetarget.h"
/**
-Just a file. Any file, not attached to a package.
+Just an arbitary file. No special meaning attached.
*/
class File: public FileTarget
{
public:
- File(Builder &, const Msp::FS::Path &);
+ File(Builder &b, const Msp::FS::Path &t): FileTarget(b, 0, t) { }
+ File(Builder &b, Package &p, const Msp::FS::Path &t): FileTarget(b, &p, t) { }
virtual const char *get_type() const { return "File"; }
private:
virtual Action *create_action() { return 0; }
*/
class Header: public SourceFile
{
+protected:
+ Header(Builder &b, const std::string &f): SourceFile(b, f) { }
public:
- Header(Builder &b, const Component *c, const std::string &f): SourceFile(b, c, f) { }
+ Header(Builder &b, const Component &c, const std::string &f): SourceFile(b, c, f) { }
virtual const char *get_type() const { return "Header"; }
};
class SystemHeader: public Header
{
public:
- SystemHeader(Builder &b, const std::string &f): Header(b, 0, f) { }
+ SystemHeader(Builder &b, const std::string &f): Header(b, f) { }
virtual const char *get_type() const { return "SystemHeader"; }
- virtual void find_depends() { deps_ready=true; }
};
#endif
using namespace std;
using namespace Msp;
-Install::Install(Builder &b, const SourcePackage &p, FileTarget &s):
- FileTarget(b, &p, generate_target_path(s)),
+Install::Install(Builder &b, const SourcePackage &p, FileTarget &s, const std::string &loc):
+ FileTarget(b, &p, generate_target_path(s, loc)),
source(s)
{
buildable=true;
return new Copy(builder, *package, source.get_path(), path);
}
-FS::Path Install::generate_target_path(const FileTarget &tgt)
+FS::Path Install::generate_target_path(const FileTarget &tgt, const std::string &loc)
{
- const SourcePackage *spkg=dynamic_cast<const SourcePackage *>(tgt.get_package());
+ if(!tgt.get_package())
+ throw InvalidParameterValue("Can't install package-less targets");
- FS::Path base=spkg->get_builder().get_prefix();
+ FS::Path base=tgt.get_package()->get_builder().get_prefix();
string tgtname=FS::basename(tgt.get_path());
string mid;
- if(const Header *hdr=dynamic_cast<const Header *>(&tgt))
+ if(!loc.empty())
+ mid=loc;
+ else if(const Header *hdr=dynamic_cast<const Header *>(&tgt))
{
if(hdr->get_component()->get_type()!=Component::HEADERS)
throw Exception("Header install from non-header component?");
FileTarget &source;
public:
- Install(Builder &, const SourcePackage &, FileTarget &);
+ Install(Builder &, const SourcePackage &, FileTarget &, const std::string & =std::string());
virtual const char *get_type() const { return "Install"; }
FileTarget &get_source() const { return source; }
private:
virtual void check_rebuild();
virtual Action *create_action();
- static Msp::FS::Path generate_target_path(const FileTarget &);
+ static Msp::FS::Path generate_target_path(const FileTarget &i, const std::string &);
};
#endif
using namespace std;
using namespace Msp;
-SourceFile::SourceFile(Builder &b, const Component *c, const FS::Path &p):
- FileTarget(b, (c ? &c->get_package() : 0), p),
- comp(c)
+SourceFile::SourceFile(Builder &b, const FS::Path &p):
+ FileTarget(b, 0, p),
+ comp(0)
+{ }
+
+SourceFile::SourceFile(Builder &b, const Component &c, const FS::Path &p):
+ FileTarget(b, &c.get_package(), p),
+ comp(&c)
{ }
void SourceFile::find_depends()
{
if(!comp)
+ {
+ deps_ready=true;
return;
+ }
const SourcePackage &spkg=comp->get_package();
string relname=FS::relative(name, spkg.get_source()).str();
}
catch(const IO::FileNotFound &)
{
+ // XXX WTF?
return;
}
}
const Component *comp;
StringList includes;
+protected:
+ SourceFile(Builder &, const Msp::FS::Path &);
public:
- SourceFile(Builder &, const Component *, const Msp::FS::Path &);
+ SourceFile(Builder &, const Component &, const Msp::FS::Path &);
virtual const char *get_type() const { return "SourceFile"; }
const StringList &get_includes() const { return includes; }
const Component *get_component() const { return comp; }
}
deps_cache.load();
-
- /*for(PackageList::iterator i=all_reqs.begin(); i!=all_reqs.end(); ++i)
- (*i)->configure(opts, flag&2);*/
}
void SourcePackage::init_config()
add("build_info", &Loader::build_info);
add("feature", &Loader::feature);
add("if", &Loader::condition);
- add("program", &Loader::program);
- add("library", &Loader::library);
- add("module", &Loader::module);
- add("headers", &Loader::headers);
+ add("program", &Loader::component<Component::PROGRAM>);
+ add("library", &Loader::component<Component::LIBRARY>);
+ add("module", &Loader::component<Component::MODULE>);
+ add("headers", &Loader::component<Component::HEADERS>);
+ add("install", &Loader::component<Component::INSTALL>);
add("tarball", &Loader::tarball);
add("tar_file", &Loader::tar_file);
}
spkg.conditions.push_back(cond);
}
-void SourcePackage::Loader::program(const string &n)
-{
- SourcePackage &spkg=static_cast<SourcePackage &>(pkg);
- Component prog(spkg, Component::PROGRAM, n);
- load_sub(prog);
- spkg.components.push_back(prog);
-}
-
-void SourcePackage::Loader::library(const string &n)
-{
- SourcePackage &spkg=static_cast<SourcePackage &>(pkg);
- Component prog(spkg, Component::LIBRARY, n);
- load_sub(prog);
- spkg.components.push_back(prog);
-}
-
-void SourcePackage::Loader::module(const string &n)
-{
- SourcePackage &spkg=static_cast<SourcePackage &>(pkg);
- Component prog(spkg, Component::MODULE, n);
- load_sub(prog);
- spkg.components.push_back(prog);
-}
-
-void SourcePackage::Loader::headers(const string &n)
+template<Component::Type t>
+void SourcePackage::Loader::component(const string &n)
{
SourcePackage &spkg=static_cast<SourcePackage &>(pkg);
- Component prog(spkg, Component::HEADERS, n);
- load_sub(prog);
- spkg.components.push_back(prog);
+ Component comp(spkg, t, n);
+ load_sub(comp);
+ spkg.components.push_back(comp);
}
void SourcePackage::Loader::build_info()
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 tarball(const std::string &);
void tar_file(const std::string &);