argv.push_back("--variable=source");
argv.push_back(n);
string srcdir=strip(run_command(argv));
- cout<<srcdir;
list<Path::Path> dirs;
if(!srcdir.empty())
return i->second;
string fn=include.substr(1);
- Target *tgt;
+ Target *tgt=0;
if(include[0]=='"' && (tgt=check_header(Path::Path(from)/fn)))
return tgt;
if((tgt=check_header(Path::Path("/usr/include")/fn)))
while(!new_pkgs.empty())
{
Package *pkg=new_pkgs.front();
+ if(pkg==default_pkg)
+ pkg->process_options(cmdline_options);
new_pkgs.erase(new_pkgs.begin());
pkg->resolve_refs();
}
if(create_targets())
return 1;
- for(TargetMap::iterator i=targets.begin(); i!=targets.end(); ++i)
- cout<<i->second->get_name()<<' '<<i->second->get_type()<<' '<<i->second->get_rebuild()<<' '<<i->second->get_rebuild_reason()<<'\n';
+ /*for(TargetMap::iterator i=targets.begin(); i!=targets.end(); ++i)
+ cout<<i->second->get_name()<<' '<<i->second->get_type()<<' '<<i->second->get_rebuild()<<' '<<i->second->get_rebuild_reason()<<'\n';*/
cout<<"Active targets: "<<targets.size()<<'\n';
list<Action *> actions;
bool fail=false;
+ if(!cmdline->get_rebuild())
+ cout<<"Already up to date\n";
+
while(cmdline->get_rebuild() && !fail)
{
if(actions.empty() && !fail)
Target *tgt=cmdline->get_buildable_target();
if(tgt)
{
- cout<<"Build "<<tgt->get_name()<<'\n';
+ //cout<<"Build "<<tgt->get_name()<<'\n';
Action *action=tgt->build();
if(action)
actions.push_back(action);
if(status>0)
fail=true;
}
+ else
+ ++i;
}
}
+#include <fstream>
#include <msp/error.h>
+#include <msp/path/utils.h>
+#include <msp/time/utils.h>
#include "config.h"
using namespace std;
}
}
+ if(changed)
+ mtime=Time::now();
+
return changed;
}
+void Config::load(const Path::Path &fn)
+{
+ ifstream in(fn.str().c_str());
+ if(!in) return;
+
+ struct stat st;
+ Path::stat(fn, st);
+ mtime=Time::TimeStamp::from_unixtime(st.st_mtime);
+}
+
Config::Option::Option(const string &n, const string &v, const string &d):
name(n),
defv(v),
#include <map>
#include <string>
+#include <msp/parser/loader.h>
+#include <msp/path/path.h>
+#include <msp/time/timestamp.h>
#include "option.h"
typedef std::map<std::string, std::string> RawOptionMap;
void add_option(const std::string &, const std::string &, const std::string &);
const Option &get_option(const std::string &) const;
+ const Msp::Time::TimeStamp &get_mtime() const { return mtime; }
bool is_option(const std::string &) const;
bool process(const RawOptionMap &);
- void load(const std::string &);
+ void load(const Msp::Path::Path &);
private:
+ class Loader: public Msp::Parser::Loader
+ {
+ };
+
OptionMap options;
+ Msp::Time::TimeStamp mtime;
};
#endif
--- /dev/null
+#ifndef COPY_H_
+#define COPY_H_
+
+#include <msp/core/thread.h>
+#include <msp/path/path.h>
+#include "action.h"
+
+class Copy: public Action
+{
+public:
+ Copy(Builder &, const Msp::Path::Path &, const Msp::Path::Path &);
+ int check();
+private:
+ class Worker: public Msp::Thread
+ {
+ public:
+ Worker(Copy &i): copy(i), done(false) { launch(); }
+ bool get_done() const { return done; }
+ private:
+ Copy ©
+ bool done;
+
+ void main();
+ };
+
+ Msp::Path::Path src;
+ Msp::Path::Path dest;
+ Worker worker;
+};
+
+#endif
void ExternalAction::launch()
{
- if(builder.get_verbose()>=1)
+ if(builder.get_verbose()>=2)
{
for(list<string>::const_iterator i=argv.begin(); i!=argv.end(); ++i)
{
+++ /dev/null
-#ifndef INSTALL_H_
-#define INSTALL_H_
-
-#include <msp/core/thread.h>
-#include <msp/path/path.h>
-#include "action.h"
-
-class Install: public Action
-{
-public:
- Install(const Msp::Path::Path &, const Msp::Path::Path &);
-private:
- class Worker: public Msp::Thread
- {
- public:
- Worker(Install &i): install(i), done(false) { launch(); }
- private:
- Install &install;
- bool done;
-
- void main();
- };
-
- Msp::Path::Path src;
- Msp::Path::Path dest;
- Worker worker;
-};
-
-#endif
+#include <msp/strconv.h>
#include <msp/strutils.h>
#include "builder.h"
#include "misc.h"
if(flags&LIB)
export_binfo.libpath.push_back((Path::Path(config.get_option("prefix").value)/"lib").str());
+ string optimize=config.get_option("optimize").value;
+ if(strtol(optimize))
+ {
+ build_info.cflags.push_back("-O"+optimize);
+ string cpu=config.get_option("cpu").value;
+ if(cpu!="auto")
+ build_info.cflags.push_back("-march="+cpu);
+ }
+
+ if(strtobool(config.get_option("debug").value))
+ build_info.cflags.push_back("-ggdb");
+
build_info.unique();
export_binfo.unique();
{
buildable=true;
- config.add_option("tempdir", "temp", "Directory for storing temporary files");
- config.add_option("optimize", "0", "Apply compiler optimizations");
- config.add_option("debug", "0", "Produce debugging symbols");
+ config.add_option("tempdir", "temp", "Directory for storing temporary files");
+ config.add_option("optimize", "0", "Apply compiler optimizations");
+ config.add_option("debug", "0", "Produce debugging symbols");
+ config.add_option("cpu", "auto", "CPU type to optimize for");
+ config.add_option("arch", "native", "Architecture for cross-compiling");
const char *home=getenv("HOME");
unsigned flags=get_install_flags();
#include <msp/path/utils.h>
#include "action.h"
#include "builder.h"
+#include "package.h"
#include "target.h"
using namespace std;
mark_rebuild((*i)->get_name()+" needs rebuilding");
}
}
+ if(!rebuild && package && package->get_config().get_mtime()>mtime)
+ mark_rebuild("Package options changed");
}
Action *Target::build(Action *action)