+/* $Id$ */
+
binary_package "opengl"
{
build_info
};
};
-architecture "arm" "arm-linux-gnu";
-architecture "win32" "i586-mingw32msvc";
+architecture "arm"
+{
+ prefix "arm-linux-gnu";
+};
+
+architecture "win32"
+{
+ prefix "i586-mingw32msvc";
+};
profile "debug"
{
--- /dev/null
+/* $Id$
+
+This file is part of builder
+Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
+#include "architecture.h"
+#include "builder.h"
+
+using namespace std;
+using namespace Msp;
+
+Architecture::Architecture(Builder &b, const string &n):
+ builder(b),
+ name(n)
+{ }
+
+void Architecture::set_tool(const string &t, const string &p)
+{
+ tools[t]=p;
+}
+
+std::string Architecture::get_tool(const string &t) const
+{
+ StringMap::const_iterator i=tools.find(t);
+ if(i!=tools.end())
+ {
+ if(i->second[0]=='-')
+ return prefix+i->second;
+ else
+ return i->second;
+ }
+
+ if(name!="native")
+ {
+ const Architecture &native=builder.get_architecture("native");
+ return prefix+"-"+native.get_tool(t);
+ }
+ else
+ throw KeyError("Unknown tool");
+}
+
+
+Architecture::Loader::Loader(Architecture &a):
+ arch(a)
+{
+ add("prefix", &Architecture::prefix);
+ add("tool", &Loader::tool);
+}
+
+void Architecture::Loader::tool(const string &t, const string &p)
+{
+ arch.tools[t]=p;
+}
--- /dev/null
+/* $Id$
+
+This file is part of builder
+Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
+#ifndef ARCHITECTURE_H_
+#define ARCHITECTURE_H_
+
+#include <msp/datafile/loader.h>
+#include "misc.h"
+
+class Builder;
+
+class Architecture
+{
+public:
+ class Loader: public Msp::DataFile::Loader
+ {
+ public:
+ Loader(Architecture &);
+ Architecture &get_object() { return arch; }
+ private:
+ Architecture &arch;
+
+ void tool(const std::string &t, const std::string &p);
+ };
+
+ Architecture(Builder &b, const std::string &n);
+ void set_tool(const std::string &t, const std::string &p);
+ std::string get_tool(const std::string &t) const;
+ const std::string &get_prefix() const { return prefix; }
+private:
+ Builder &builder;
+ std::string name;
+ std::string prefix;
+ StringMap tools;
+};
+
+typedef std::map<std::string, Architecture> ArchMap;
+
+#endif
{
const Component &comp=lib.get_component();
- argv.push_back(builder.get_tool("AR", comp.get_package().get_arch()));
+ std::string tool="AR";
+ argv.push_back(builder.get_architecture(comp.get_package().get_arch()).get_tool(tool));
argv.push_back("rc");
argv.push_back(lib.get_name());
if(!builder.get_dry_run())
Path::mkpath(lpath.subpath(0, lpath.size()-1), 0755);
- announce(comp.get_package().get_name(), "AR ", relative(lpath, comp.get_package().get_source()).str());
+ announce(comp.get_package().get_name(), tool, relative(lpath, comp.get_package().get_source()).str());
launch();
}
cwd=Path::getcwd();
- archs.insert(StringMap::value_type("native", ""));
-
- StringMap &native_tools=tools.insert(ToolMap::value_type("native", StringMap())).first->second;
- native_tools.insert(StringMap::value_type("CC", "gcc"));
- native_tools.insert(StringMap::value_type("CXX", "g++"));
- native_tools.insert(StringMap::value_type("LD", "gcc"));
- native_tools.insert(StringMap::value_type("LDXX", "g++"));
- native_tools.insert(StringMap::value_type("AR", "ar"));
+ Architecture &native_arch=archs.insert(ArchMap::value_type("native", Architecture(*this, "native"))).first->second;
+ native_arch.set_tool("CC", "gcc");
+ native_arch.set_tool("CXX", "g++");
+ native_arch.set_tool("LD", "gcc");
+ native_arch.set_tool("LXX", "g++");
+ native_arch.set_tool("AR", "ar");
const char *home=getenv("HOME");
if(home)
syspath.push_back("/usr/lib");
}
else
- syspath.push_back("/usr/"+get_arch_prefix(arch)+"/lib");
+ syspath.push_back("/usr/"+get_architecture(arch).get_prefix()+"/lib");
Target *tgt=0;
for(StringList::iterator j=syspath.begin(); (!tgt && j!=syspath.end()); ++j)
return tgt;
}
-const string &Builder::get_arch_prefix(const string &arch) const
+const Architecture &Builder::get_architecture(const string &arch) const
{
- StringMap::const_iterator i=archs.find(arch);
+ ArchMap::const_iterator i=archs.find(arch);
if(i==archs.end())
throw InvalidParameterValue("Unknown architecture");
return i->second;
}
-string Builder::get_tool(const std::string &tool, const std::string &arch)
-{
- ToolMap::iterator i=tools.find(arch);
- if(i!=tools.end())
- {
- StringMap::iterator j=i->second.find(tool);
- if(j!=i->second.end())
- return j->second;
- }
-
- // Either the arch, or the tool within the arch was not found
- i=tools.find("native");
- StringMap::iterator j=i->second.find(tool);
- if(j==i->second.end())
- throw InvalidParameterValue("Unknown tool");
-
- return get_arch_prefix(arch)+"-"+j->second;
-}
-
void Builder::apply_profile_template(Config &config, const string &pt) const
{
vector<string> parts=split(pt, '-');
add("package", &Loader::package);
}
-void Builder::Loader::architecture(const string &a, const string &p)
+void Builder::Loader::architecture(const string &n)
{
- bld.archs.insert(StringMap::value_type(a, p));
+ Architecture arch(bld, n);
+ load_sub(arch);
+ bld.archs.insert(ArchMap::value_type(n, arch));
}
void Builder::Loader::binpkg(const string &n)
#include <msp/core/application.h>
#include <msp/datafile/loader.h>
#include <msp/path/path.h>
+#include "architecture.h"
#include "config.h"
#include "misc.h"
#include "problem.h"
Target *get_header(const std::string &, const std::string &, const std::string &, const StringList &);
Target *get_library(const std::string &, const std::string &, const StringList &, LibMode);
const Msp::Path::Path &get_cwd() const { return cwd; }
- const std::string &get_arch_prefix(const std::string &) const;
- std::string get_tool(const std::string &, const std::string &);
+ const Architecture &get_architecture(const std::string &) const;
void apply_profile_template(Config &, const std::string &) const;
void add_target(Target *);
void problem(const std::string &, const std::string &);
Builder &bld;
Msp::Path::Path src;
- void architecture(const std::string &, const std::string &);
+ void architecture(const std::string &);
void binpkg(const std::string &);
void profile(const std::string &);
void package(const std::string &);
typedef std::list<Package *> PackageList;
typedef std::map<std::string, Package *> PackageMap;
- typedef std::map<std::string, StringMap> ToolMap;
typedef std::map<std::string, StringMap> ProfileTemplateMap;
StringList cmdline_targets;
TargetMap includes;
TargetMap libraries;
- ToolMap tools; //< arch, tool name -> program name
- StringMap archs; //< arch -> prefix
+ ArchMap archs;
ProfileTemplateMap profile_tmpl;
ProblemList problems;
else
tool="CC";
- argv.push_back(builder.get_tool(tool, comp.get_package().get_arch()));
+ argv.push_back(builder.get_architecture(comp.get_package().get_arch()).get_tool(tool));
argv.push_back("-c");
-
+
const BuildInfo &binfo=comp.get_build_info();
for(list<string>::const_iterator i=binfo.cflags.begin(); i!=binfo.cflags.end(); ++i)
argv.push_back(*i);
argv.push_back("-I"+*i);
for(list<string>::const_iterator i=binfo.defines.begin(); i!=binfo.defines.end(); ++i)
argv.push_back("-D"+*i);
-
+
Path::Path opath=obj.get_name();
argv.push_back("-o");
argv.push_back(opath.str());
const Component &comp=exe.get_component();
//XXX Determine whether to use g++ or gcc
- argv.push_back(builder.get_tool("LDXX", comp.get_package().get_arch()));
-
+ string tool="LXX";
+ argv.push_back(builder.get_architecture(comp.get_package().get_arch()).get_tool(tool));
+
if(comp.get_type()==Component::LIBRARY || comp.get_type()==Component::MODULE)
argv.push_back("-shared");
else if(comp.get_package().get_library_mode()==ALL_STATIC)
argv.push_back(*i);
for(list<string>::const_iterator i=binfo.libpath.begin(); i!=binfo.libpath.end(); ++i)
argv.push_back("-L"+*i);
-
+
argv.push_back("-o");
argv.push_back(exe.get_name());
const TargetList &deps=exe.get_depends();
if(!builder.get_dry_run())
Path::mkpath(epath.subpath(0, epath.size()-1), 0755);
- announce(comp.get_package().get_name(), "LINK", relative(epath, comp.get_package().get_source()).str());
+ announce(comp.get_package().get_name(), tool, relative(epath, comp.get_package().get_source()).str());
launch();
}
--- /dev/null
+/* $Id$
+
+This file is part of builder
+Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
+#ifndef PROBLEM_H_
+#define PROBLEM_H_
+
+#include <list>
+#include <string>
+
+class Package;
+
+struct Problem
+{
+ std::string package;
+ std::string descr;
+
+ Problem(const std::string &p, const std::string &d): package(p), descr(d) { }
+};
+
+typedef std::list<Problem> ProblemList;
+
+#endif