version "0.1";
description "Mikkosoft Productions software builder";
+ tar_file "bootstrap.sh";
+ tar_file "Readme.txt";
+
require "mspcore";
require "mspstrings";
require "mspparser";
using namespace Msp;
Copy::Copy(Builder &b, const Package &pkg, const Path::Path &s, const Path::Path &d):
- Action(b),
+ InternalAction(b),
src(s),
- dest(d),
- worker(0)
+ dest(d)
{
announce(pkg.get_name(), "COPY", dest[-1]);
if(builder.get_verbose()>=2)
cout<<s<<" -> "<<d<<'\n';
-
+
if(!builder.get_dry_run())
worker=new Worker(*this);
}
-int Copy::check()
-{
- if(!worker) // True for dry run
- {
- signal_done.emit();
- return 0;
- }
-
- if(worker->get_done())
- {
- signal_done.emit();
- worker->join();
- return worker->get_error()?1:0;
- }
-
- return -1;
-}
-Copy::~Copy()
+Copy::Worker::Worker(Copy &c):
+ copy(c)
{
- delete worker;
+ launch();
}
void Copy::Worker::main()
{
Path::mkpath(copy.dest.subpath(0, copy.dest.size()-1), 0755);
-
+
// Remove old file. Not doing this would cause Bad Stuff when installing libraries.
if(unlink(copy.dest.str().c_str())<0 && errno!=ENOENT)
{
#include <msp/core/thread.h>
#include <msp/path/path.h>
-#include "action.h"
+#include "internalaction.h"
class Package;
/**
Copies a file to another place. Used by the Install target.
*/
-class Copy: public Action
+class Copy: public InternalAction
{
public:
Copy(Builder &, const Package &, const Msp::Path::Path &, const Msp::Path::Path &);
- int check();
- ~Copy();
private:
/**
A worker thread that actually does the data transfer.
*/
- class Worker: public Msp::Thread
+ class Worker: public InternalAction::Worker
{
public:
- Worker(Copy &i): copy(i), done(false), error(false) { launch(); }
- bool get_done() const { return done; }
- bool get_error() const { return error; }
+ Worker(Copy &);
private:
Copy ©
- bool done;
- bool error;
void main();
};
Msp::Path::Path src;
Msp::Path::Path dest;
- Worker *worker;
};
#endif
--- /dev/null
+/* $Id$
+
+This file is part of builder
+Copyright © 2007 Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
+#include "internalaction.h"
+
+InternalAction::~InternalAction()
+{
+ delete worker;
+}
+
+int InternalAction::check()
+{
+ if(!worker) // True for dry run
+ {
+ signal_done.emit();
+ return 0;
+ }
+
+ if(worker->get_done())
+ {
+ signal_done.emit();
+ worker->join();
+ return worker->get_error()?1:0;
+ }
+
+ return -1;
+}
+
+InternalAction::InternalAction(Builder &b):
+ Action(b),
+ worker(0)
+{ }
+
+
+InternalAction::Worker::Worker():
+ done(false),
+ error(false)
+{ }
--- /dev/null
+/* $Id$
+
+This file is part of builder
+Copyright © 2007 Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
+#ifndef INTERNALACTION_H_
+#define INTERNALACTION_H_
+
+#include <msp/core/thread.h>
+#include "action.h"
+
+class InternalAction: public Action
+{
+public:
+ virtual ~InternalAction();
+
+ virtual int check();
+protected:
+ class Worker: public Msp::Thread
+ {
+ public:
+ bool get_done() const { return done; }
+ bool get_error() const { return error; }
+ protected:
+ bool done;
+ bool error;
+
+ Worker();
+ };
+
+ Worker *worker;
+
+ InternalAction(Builder &);
+};
+
+#endif
using namespace Msp;
Tar::Tar(Builder &b, const TarBall &t):
- Action(b),
- tarball(t),
- worker(0)
+ InternalAction(b),
+ tarball(t)
{
string basename=tarball.get_name().substr(tarball.get_name().rfind('/')+1);
announce(tarball.get_package()->get_name(), "TAR ", basename);
if(builder.get_verbose()>=2)
cout<<"Create "<<basename<<'\n';
-
+
if(!builder.get_dry_run())
worker=new Worker(*this);
}
-Tar::~Tar()
-{
- delete worker;
-}
-
-int Tar::check()
-{
- if(!worker) // True for dry run
- {
- signal_done.emit();
- return 0;
- }
-
- if(worker->get_done())
- {
- signal_done.emit();
- worker->join();
- return worker->get_error()?1:0;
- }
-
- return -1;
-}
-
Tar::Worker::Worker(Tar &t):
- tar(t),
- done(false),
- error(false)
+ tar(t)
{
launch();
}
#define TAR_H_
#include <msp/core/thread.h>
-#include "action.h"
+#include "internalaction.h"
#include "misc.h"
class TarBall;
-class Tar: public Action
+class Tar: public InternalAction
{
public:
Tar(Builder &, const TarBall &);
- ~Tar();
-
- virtual int check();
private:
- class Worker: public Msp::Thread
+ class Worker: public InternalAction::Worker
{
public:
Worker(Tar &);
- bool get_done() const { return done; }
- bool get_error() const { return error; }
private:
Tar &tar;
- bool done;
- bool error;
void main();
void store_number(char *, unsigned, unsigned);
const TarBall &tarball;
StringList files;
- Worker *worker;
};
#endif