version "0.9";
description "Mikkosoft Productions software builder";
- tar_file "bootstrap.sh";
- tar_file "Readme.txt";
- tar_file "License.txt";
-
require "mspcore";
require "mspstrings";
require "mspdatafile";
source "source";
install true;
};
+
+ tarball "@src"
+ {
+ source "bootstrap.sh";
+ source "Readme.txt";
+ source "License.txt";
+ };
};
#include "sharedlibrary.h"
#include "sourcepackage.h"
#include "systemlibrary.h"
-#include "tarball.h"
#include "unlink.h"
#include "virtualtarget.h"
PkgConfig *pc=new PkgConfig(*this, *spkg);
install->add_depend(new Install(*this, *spkg, *pc));
}
-
- tarballs->add_depend(new TarBall(*this, *spkg));
}
// Find dependencies until no new targets are created
#include "builder.h"
#include "component.h"
#include "executable.h"
+#include "file.h"
#include "header.h"
#include "install.h"
#include "objectfile.h"
#include "sharedlibrary.h"
#include "sourcepackage.h"
#include "staticlibrary.h"
+#include "tarball.h"
#include "target.h"
using namespace std;
PathList files=collect_source_files();
- bool build_exe=(type!=HEADERS);
-
- list<ObjectFile *> objs;
- list<FileTarget *> inst_tgts;
- for(PathList::const_iterator i=files.begin(); i!=files.end(); ++i)
+ if(type==TARBALL)
{
- string ext=FS::extpart(FS::basename(*i));
- if((ext==".cpp" || ext==".c") && build_exe)
+ string tarname=name;
+ if(name=="@src")
+ tarname=pkg.get_name()+"-"+pkg.get_version();
+ TarBall *result=new TarBall(builder, pkg, tarname);
+
+ if(name=="@src")
{
- SourceFile *src=new SourceFile(builder, this, i->str());
+ const TargetMap &targets=builder.get_targets();
+ for(TargetMap::const_iterator i=targets.begin(); i!=targets.end(); ++i)
+ if(i->second->get_package()==&pkg && !i->second->get_buildable())
+ result->add_depend(i->second);
+ files.push_back(pkg.get_source()/"Build");
+ }
- // Compile sources
- ObjectFile *obj=new ObjectFile(builder, *this, *src);
- objs.push_back(obj);
+ for(PathList::const_iterator i=files.begin(); i!=files.end(); ++i)
+ {
+ FileTarget *ft;
+ if(Target *tgt=builder.get_target(i->str()))
+ ft=dynamic_cast<FileTarget *>(tgt);
+ else
+ ft=new File(builder, *i);
+ result->add_depend(ft);
}
- else if(ext==".h")
+
+ Target *tarbls_tgt=builder.get_target("tarballs");
+ tarbls_tgt->add_depend(result);
+
+ return;
+ }
+
+ list<FileTarget *> inst_list;
+ 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)
// Install headers if requested
if(type==HEADERS && install)
- inst_tgts.push_back(hdr);
+ inst_list.push_back(hdr);
}
}
- if(build_exe)
+ if(type==PROGRAM || type==LIBRARY || type==MODULE)
{
- Binary *bin=0;
- StaticLibrary *slib=0;
- if(type==LIBRARY)
+ list<ObjectFile *> objs;
+ for(PathList::const_iterator i=files.begin(); i!=files.end(); ++i)
{
- bin=new SharedLibrary(builder, *this, objs);
- slib=new StaticLibrary(builder, *this, objs);
+ string ext=FS::extpart(FS::basename(*i));
+ if((ext==".cpp" || ext==".cc" || ext==".c"))
+ {
+ SourceFile *src=new SourceFile(builder, this, i->str());
+ ObjectFile *obj=new ObjectFile(builder, *this, *src);
+ objs.push_back(obj);
+ }
}
- else
- bin=new Executable(builder, *this, objs);
- if(&pkg==builder.get_main_package() && deflt)
+ list<FileTarget *> results;
+ if(type==LIBRARY)
{
- def_tgt->add_depend(bin);
- if(slib) def_tgt->add_depend(slib);
+ results.push_back(new SharedLibrary(builder, *this, objs));
+ results.push_back(new StaticLibrary(builder, *this, objs));
}
else
- {
- world->add_depend(bin);
- if(slib) world->add_depend(slib);
- }
+ results.push_back(new Executable(builder, *this, objs));
- if(install)
+ for(list<FileTarget *>::const_iterator i=results.begin(); i!=results.end(); ++i)
{
- inst_tgts.push_back(bin);
- if(slib)
- inst_tgts.push_back(slib);
+ if(&pkg==builder.get_main_package() && deflt)
+ def_tgt->add_depend(*i);
+ else
+ world->add_depend(*i);
+ if(install)
+ inst_list.push_back(*i);
}
}
Target *inst_tgt=builder.get_target("install");
- for(list<FileTarget *>::const_iterator i=inst_tgts.begin(); i!=inst_tgts.end(); ++i)
+ for(list<FileTarget *>::const_iterator i=inst_list.begin(); i!=inst_list.end(); ++i)
inst_tgt->add_depend(new Install(builder, pkg, **i));
}
enum Type
{
+ HEADERS,
PROGRAM,
LIBRARY,
MODULE,
- HEADERS
+ TARBALL
};
protected:
#include "file.h"
-using namespace std;
-
-File::File(Builder &b, const string &n):
- FileTarget(b, 0, n)
+File::File(Builder &b, const Msp::FS::Path &p):
+ FileTarget(b, 0, p)
{ }
class File: public FileTarget
{
public:
- File(Builder &, const std::string &);
+ File(Builder &, const Msp::FS::Path &);
virtual const char *get_type() const { return "File"; }
private:
virtual Action *create_action() { return 0; }
using namespace std;
using namespace Msp;
+namespace {
+
+bool component_sort(const Component &c1, const Component &c2)
+{ return c1.get_type()<c2.get_type(); }
+
+}
+
+
SourcePackage::SourcePackage(Builder &b, const string &n, const FS::Path &s):
Package(b, n),
source(s),
config(*this),
deps_cache(*this)
{
- tar_files.push_back(source/"Build");
+ components.push_back(Component(*this, Component::TARBALL, "@src"));
}
Msp::FS::Path SourcePackage::get_temp_dir() const
add("library", &Loader::library);
add("module", &Loader::module);
add("headers", &Loader::headers);
+ add("tarball", &Loader::tarball);
add("tar_file", &Loader::tar_file);
}
+void SourcePackage::Loader::finish()
+{
+ SourcePackage &spkg=static_cast<SourcePackage &>(pkg);
+ spkg.components.sort(component_sort);
+}
+
void SourcePackage::Loader::feature(const string &n, const string &d)
{
static_cast<SourcePackage &>(pkg).features.push_back(Feature(n, d));
load_sub(static_cast<SourcePackage &>(pkg).build_info);
}
+void SourcePackage::Loader::tarball(const string &n)
+{
+ SourcePackage &spkg=static_cast<SourcePackage &>(pkg);
+ if(n=="@src")
+ {
+ for(ComponentList::iterator i=spkg.components.begin(); i!=spkg.components.end(); ++i)
+ if(i->get_type()==Component::TARBALL && i->get_name()==n)
+ load_sub(*i);
+ }
+ else
+ {
+ Component trbl(spkg, Component::TARBALL, n);
+ load_sub(trbl);
+ }
+}
+
void SourcePackage::Loader::tar_file(const string &f)
{
+ IO::print("%s: Note: tar_file is deprecated\n", get_source());
SourcePackage &spkg=static_cast<SourcePackage &>(pkg);
- spkg.tar_files.push_back(spkg.source/f);
+ for(ComponentList::iterator i=spkg.components.begin(); i!=spkg.components.end(); ++i)
+ if(i->get_type()==Component::TARBALL && i->get_name()=="@src")
+ const_cast<PathList &>(i->get_sources()).push_back(spkg.source/f);
}
Loader(Package &);
SourcePackage &get_object() { return static_cast<SourcePackage &>(pkg); }
private:
+ virtual void finish();
void feature(const std::string &, const std::string &);
void condition(const std::string &);
void program(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 &);
};
Config config;
bool conf_done;
mutable DependencyCache deps_cache;
- PathList tar_files;
public:
SourcePackage(Builder &, const std::string &, const Msp::FS::Path &);
unsigned get_install_flags();
LibMode get_library_mode() const;
- const PathList &get_tar_files() const { return tar_files; }
DependencyCache &get_deps_cache() const { return deps_cache; }
private:
virtual void do_configure(const StringMap &, unsigned);
Distributed under the LGPL
*/
-#include "builder.h"
-#include "file.h"
#include "sourcepackage.h"
#include "tar.h"
#include "tarball.h"
using namespace std;
-TarBall::TarBall(Builder &b, const SourcePackage &p, const string &ev):
- FileTarget(b, &p, create_target_name(p, ev))
+TarBall::TarBall(Builder &b, const SourcePackage &p, const string &n):
+ FileTarget(b, &p, p.get_source()/(n+".tar"))
{
buildable=true;
}
return static_cast<const SourcePackage *>(package);
}
-void TarBall::find_depends()
-{
- const SourcePackage *spkg=dynamic_cast<const SourcePackage *>(package);
-
- const TargetMap &targets=builder.get_targets();
- for(TargetMap::const_iterator i=targets.begin(); i!=targets.end(); ++i)
- if(i->second->get_package()==package && i->second!=this && !i->second->get_buildable())
- add_depend(i->second);
-
- const PathList &tar_files=spkg->get_tar_files();
- for(PathList::const_iterator i=tar_files.begin(); i!=tar_files.end(); ++i)
- {
- Target *tgt=builder.get_target(i->str());
- if(!tgt)
- tgt=new File(builder, i->str());
- add_depend(tgt);
- }
-
- deps_ready=true;
-}
-
Action *TarBall::create_action()
{
return new Tar(builder, *this);
}
-
-string TarBall::create_target_name(const SourcePackage &pkg, const string &extra_ver)
-{
- string basename=pkg.get_name()+"-"+pkg.get_version();
- if(!extra_ver.empty())
- basename+="-"+extra_ver;
- basename+=".tar";
-
- return (pkg.get_source()/basename).str();
-}
class TarBall: public FileTarget
{
public:
- TarBall(Builder &, const SourcePackage &, const std::string & =std::string());
+ TarBall(Builder &, const SourcePackage &, const std::string &);
virtual const char *get_type() const { return "TarBall"; }
const SourcePackage *get_package() const;
- virtual void find_depends();
private:
virtual Action *create_action();
-
- static std::string create_target_name(const SourcePackage &, const std::string &);
};
#endif