+#include <msp/core/algorithm.h>
#include <msp/fs/utils.h>
#include <msp/io/print.h>
#include "analyzer.h"
depends.insert(depends.end(), tdeps.begin(), tdeps.end());
}
- depends.sort(full_paths ? target_order_full : target_order);
+ sort(depends, (full_paths ? target_order_full : target_order));
for(Target *d: depends)
build_depend_table(*d, depth+1);
#ifndef ANALYZER_H_
#define ANALYZER_H_
-#include <list>
#include <map>
#include <set>
#include <string>
Builder &builder;
Mode mode;
- std::list<TableRow> table;
+ std::vector<TableRow> table;
unsigned max_depth;
bool full_paths;
std::map<const Target *, std::set<Target *> > rdepends;
Builder &builder = package.get_builder();
BuildGraph &build_graph = builder.get_build_graph();
- list<Target *> contents;
+ vector<Target *> contents;
for(const auto &kvp: build_graph.get_targets())
if(kvp.second->get_package()==&package)
if(InstalledFile *inst = dynamic_cast<InstalledFile *>(kvp.second))
for(const string &p: permissions)
manifest->add_permission(p);
- list<Target *> resource_sources;
+ vector<Target *> resource_sources;
resource_sources.push_back(manifest);
const Toolchain &toolchain = builder.get_toolchain();
Tool &aapt = toolchain.get_tool("AAPT");
Target *resource_bundle = aapt.create_target(resource_sources);
- list<Target *> apk_sources;
+ vector<Target *> apk_sources;
+ apk_sources.reserve(1+contents.size());
apk_sources.push_back(resource_bundle);
const Architecture &arch = package.get_builder().get_current_arch();
problems.push_back("Android platform not found");
}
-Target *AndroidAssetPackagingTool::create_target(const list<Target *> &sources, const string &)
+Target *AndroidAssetPackagingTool::create_target(const vector<Target *> &sources, const string &)
{
AndroidManifestFile *manifest = 0;
- list<FileTarget *> resources;
+ vector<FileTarget *> resources;
+ resources.reserve(sources.size());
for(Target *s: sources)
{
if(AndroidManifestFile *m = dynamic_cast<AndroidManifestFile *>(s))
argv.push_back("-F");
argv.push_back(FS::relative(res.get_path(), work_dir).str());
- list<FS::Path> resource_dirs;
+ vector<FS::Path> resource_dirs;
+ resource_dirs.reserve(res.get_dependencies().size());
for(Target *d: res.get_dependencies())
{
FileTarget *file = dynamic_cast<FileTarget *>(d);
public:
AndroidAssetPackagingTool(Builder &, const AndroidSdk &);
- Target *create_target(const std::list<Target *> &, const std::string &) override;
+ Target *create_target(const std::vector<Target *> &, const std::string &) override;
Task *run(const Target &) const override;
};
build_info.sysroot = ndk.get_platform_sysroot();
}
-Target *AndroidLinker::create_target(const list<Target *> &sources, const string &)
+Target *AndroidLinker::create_target(const vector<Target *> &sources, const string &)
{
return GnuLinker::create_target(sources, "shared");
}
public:
AndroidLinker(Builder &, const Architecture &, const AndroidNdk &);
- Target *create_target(const std::list<Target *> &, const std::string &) override;
+ Target *create_target(const std::vector<Target *> &, const std::string &) override;
};
#endif
Tool(b, "AMG")
{ }
-Target *AndroidManifestGenerator::create_target(const list<Target *> &, const string &)
+Target *AndroidManifestGenerator::create_target(const vector<Target *> &, const string &)
{
throw logic_error("not implemented");
}
public:
AndroidManifestGenerator(Builder &);
- Target *create_target(const std::list<Target *> &, const std::string &) override;
+ Target *create_target(const std::vector<Target *> &, const std::string &) override;
Task *run(const Target &) const override;
};
using namespace std;
-AndroidPackageFile::AndroidPackageFile(Builder &b, const Component &c, AndroidResourceBundle &resource_bundle, const list<FileTarget *> &other_files):
+AndroidPackageFile::AndroidPackageFile(Builder &b, const Component &c, AndroidResourceBundle &resource_bundle, const vector<FileTarget *> &other_files):
FileTarget(b, c.get_package(), c.get_package().get_output_directory()/(c.get_name()+".apk"))
{
component = &c;
class AndroidPackageFile: public FileTarget
{
public:
- AndroidPackageFile(Builder &, const Component &, AndroidResourceBundle &, const std::list<FileTarget *> &);
+ AndroidPackageFile(Builder &, const Component &, AndroidResourceBundle &, const std::vector<FileTarget *> &);
const char *get_type() const override { return "AndroidPackageFile"; }
};
using namespace std;
-AndroidResourceBundle::AndroidResourceBundle(Builder &b, const Component &c, AndroidManifestFile &manifest, const list<FileTarget *> &resources):
+AndroidResourceBundle::AndroidResourceBundle(Builder &b, const Component &c, AndroidManifestFile &manifest, const vector<FileTarget *> &resources):
FileTarget(b, c.get_package(), c.get_package().get_temp_directory()/c.get_name()/(c.get_name()+".ap_"))
{
component = &c;
class AndroidResourceBundle: public FileTarget
{
public:
- AndroidResourceBundle(Builder &, const Component &, AndroidManifestFile &, const std::list<FileTarget *> &);
+ AndroidResourceBundle(Builder &, const Component &, AndroidManifestFile &, const std::vector<FileTarget *> &);
const char *get_type() const override { return "AndroidResourceBundle"; }
};
set_command("jar");
}
-Target *ApkBuilder::create_target(const list<Target *> &sources, const string &)
+Target *ApkBuilder::create_target(const vector<Target *> &sources, const string &)
{
AndroidResourceBundle *resource_bundle = 0;
- list<FileTarget *> other_files;
+ vector<FileTarget *> other_files;
+ other_files.reserve(sources.size());
for(Target *s: sources)
{
if(AndroidResourceBundle *r = dynamic_cast<AndroidResourceBundle *>(s))
argv.push_back("u");
FS::Path input_path;
- list<FS::Path> files;
+ vector<FS::Path> files;
+ files.reserve(apk.get_dependencies().size());
for(Target *d: apk.get_dependencies())
{
FileTarget *file = dynamic_cast<FileTarget *>(d);
public:
ApkBuilder(Builder &);
- Target *create_target(const std::list<Target *> &, const std::string &) override;
+ Target *create_target(const std::vector<Target *> &, const std::string &) override;
protected:
void do_prepare() override;
public:
std::string name;
bool native;
std::string cross_prefix;
- std::map<std::string, std::list<Pattern>> filename_patterns;
+ std::map<std::string, std::vector<Pattern>> filename_patterns;
public:
Architecture(Builder &b, const std::string &spec);
const std::string &get_cross_prefix() const { return cross_prefix; }
template<typename T>
- const std::list<Pattern> &get_patterns() const;
+ const std::vector<Pattern> &get_patterns() const;
template<typename T>
std::string create_filename(const std::string &) const;
};
template<typename T>
-inline const std::list<Pattern> &Architecture::get_patterns() const
+inline const std::vector<Pattern> &Architecture::get_patterns() const
{
auto i = filename_patterns.find(typeid(T).name());
if(i!=filename_patterns.end())
return i->second;
- static std::list<Pattern> empty;
+ static std::vector<Pattern> empty;
return empty;
}
template<typename T>
inline std::string Architecture::create_filename(const std::string &base) const
{
- const std::list<Pattern> &patterns = get_patterns<T>();
+ const std::vector<Pattern> &patterns = get_patterns<T>();
return patterns.empty() ? base : patterns.front().apply(base);
}
FileTarget(b, p)
{ }
-Binary::Binary(Builder &b, const Component &c, const string &p, const list<ObjectFile *> &objs):
+Binary::Binary(Builder &b, const Component &c, const string &p, const vector<ObjectFile *> &objs):
FileTarget(b, c.get_package(), c.get_package().get_output_directory()/p),
objects(objs)
{
BuildInfo static_binfo;
protected:
- std::list<ObjectFile *> objects;
+ std::vector<ObjectFile *> objects;
Binary(Builder &, const Msp::FS::Path &);
- Binary(Builder &, const Component &, const std::string &, const std::list<ObjectFile *> &);
+ Binary(Builder &, const Component &, const std::string &, const std::vector<ObjectFile *> &);
public:
void collect_build_info(BuildInfo &) const override;
const Toolchain &toolchain = builder.get_toolchain();
const Toolchain &pkg_tools = package.get_toolchain();
- list<Target *> objs;
- list<FS::Path> source_filenames = collect_source_files();
+ vector<Target *> objs;
+ vector<FS::Path> source_filenames = collect_source_files();
+ objs.reserve(source_filenames.size());
for(auto i=source_filenames.begin(); i!=source_filenames.end(); ++i)
{
string ext = FS::extpart(FS::basename(*i));
Tool *gen = pkg_tools.get_tool_for_suffix(ext);
if(gen)
{
- list<Target *> templates;
+ vector<Target *> templates;
templates.push_back(gen->create_source(*this, *i));
Tool::ProcessingUnit processing_unit = gen->get_processing_unit();
if(processing_unit!=Tool::ONE_FILE)
{
FS::Path source_dir = FS::dirname(*i);
- auto j = i;
- for(++j; j!=source_filenames.end(); )
+ for(auto j=next(i); j!=source_filenames.end(); )
{
if((processing_unit!=Tool::DIRECTORY || FS::dirname(*j)==source_dir) &&
pkg_tools.get_tool_for_suffix(FS::extpart(FS::basename(*j)))==gen)
{
templates.push_back(gen->create_source(*this, *j));
// Remove additional files so they won't get processed again
- source_filenames.erase(j++);
+ j = source_filenames.erase(j);
}
else
++j;
Tool &linker = toolchain.get_tool("LINK");
- list<Target *> results;
+ vector<Target *> results;
+ results.reserve(2);
if(type==LIBRARY)
{
Tool &archiver = toolchain.get_tool("AR");
private:
Type type;
- std::list<const Component *> uses;
+ std::vector<const Component *> uses;
public:
BinaryComponent(SourcePackage &, const std::string &, Type);
bool has_relative_paths = any_of(export_binfo.libpath.begin(), export_binfo.libpath.end(), is_relative) ||
any_of(export_binfo.incpath.begin(), export_binfo.incpath.end(), is_relative);
- list<FS::Path> bases;
+ vector<FS::Path> bases;
/* If we have any relative paths that need resolving, or we have no paths at
all and are not using pkg-config, look for files in prefix */
private:
Msp::FS::Path base_path;
- std::list<std::string> headers;
+ std::vector<std::string> headers;
BuildInfo static_binfo;
public:
+#include <deque>
#include <set>
#include <msp/core/except.h>
#include <msp/core/maputils.h>
logger = (l ? l : &default_logger);
}
-list<string> Builder::collect_problems() const
+vector<string> Builder::collect_problems() const
{
- list<string> problems;
+ vector<string> problems;
set<const Package *> broken_packages;
set<const Component *> broken_components;
set<const Tool *> broken_tools;
// Cleaning doesn't care about ordering, so a simpler method can be used
set<Target *> clean_tgts;
- list<Target *> queue;
+ deque<Target *> queue;
queue.push_back(&build_graph.get_goals());
while(!queue.empty())
#ifndef BUILDER_H_
#define BUILDER_H_
-#include <list>
#include <map>
#include <string>
#include <msp/datafile/loader.h>
void set_logger(const Logger *);
const Logger &get_logger() const { return *logger; }
- std::list<std::string> collect_problems() const;
+ std::vector<std::string> collect_problems() const;
/** Loads a build file. If opts is not null, it is used to configure any
packages loaded from this file. If all is true, external packages are also
bool no_externals = false;
unsigned verbose = 1;
bool silent = false;
- list<string> log_channels;
+ vector<string> log_channels;
string build_type;
GetOpt getopt;
builder.set_architecture(tolower(arch));
- list<FS::Path> start_files;
+ vector<FS::Path> start_files;
start_files.push_back(FS::get_sys_data_dir()/"builderrc");
start_files.push_back(FS::get_user_data_dir()/"rc");
for(const FS::Path &f: start_files)
BuildGraph &build_graph = builder.get_build_graph();
PackageManager &package_manager = builder.get_package_manager();
- list<string> package_details;
+ vector<string> package_details;
for(const auto &kvp: package_manager.get_packages())
{
if(!kvp.second->is_prepared())
if(build_graph.get_goals().is_broken())
{
- list<string> problems = builder.collect_problems();
+ vector<string> problems = builder.collect_problems();
IO::print(IO::cerr, "The following problems were detected:\n");
for(const string &p: problems)
IO::print(IO::cerr, " %s\n", p);
class BuilderCLI: public Msp::RegisteredApplication<BuilderCLI>
{
private:
- std::list<std::string> cmdline_targets;
+ std::vector<std::string> cmdline_targets;
Config::InputOptions cmdline_options;
Msp::FS::Path cwd;
bool show_progress;
std::string build_file;
unsigned jobs;
- std::list<std::string> what_if;
+ std::vector<std::string> what_if;
bool conf_all;
bool conf_only;
bool build_all;
namespace {
-/** Removes any duplicate entries from a list, leaving only the first one. The
-order of other elements is preserved. O(nlogn) efficiency. */
+/** Removes any duplicate entries from a vector, leaving only the first one.
+The order of other elements is preserved. */
template<typename T>
-void unique(list<T> &l)
+void unique(vector<T> &v)
{
- set<T> seen;
- for(auto i=l.begin(); i!=l.end(); )
+ vector<T> seen;
+ for(auto i=v.begin(); i!=v.end(); )
{
- if(seen.count(*i))
- l.erase(i++);
+ auto j = lower_bound(seen, *i);
+ if(j!=seen.end() && *j==*i)
+ i = v.erase(i);
else
- seen.insert(*i++);
+ seen.insert(j, *i++);
}
}
#ifndef BUILDINFO_H_
#define BUILDINFO_H_
-#include <list>
#include <string>
+#include <vector>
#include <msp/datafile/objectloader.h>
#include <msp/fs/path.h>
Tracked<Msp::FS::Path> sysroot;
std::map<std::string, std::string> defines;
- std::list<Msp::FS::Path> incpath;
- std::list<Msp::FS::Path> local_incpath;
- std::list<Msp::FS::Path> libpath;
- std::list<std::string> libs;
+ std::vector<Msp::FS::Path> incpath;
+ std::vector<Msp::FS::Path> local_incpath;
+ std::vector<Msp::FS::Path> libpath;
+ std::vector<std::string> libs;
Tracked<LibraryMode> libmode;
Tracked<RuntimePathMode> rpath_mode;
std::map<std::string, LibraryMode> libmodes;
- std::list<std::string> keep_symbols;
+ std::vector<std::string> keep_symbols;
std::map<std::string, LanguageStandard> standards;
Tracked<bool> threads;
Tracked<bool> debug;
#ifndef CACHE_H_
#define CACHE_H_
-#include <list>
#include <map>
+#include <vector>
#include <msp/fs/path.h>
#include <msp/time/timestamp.h>
class Cache
{
public:
- using Values = std::list<std::string>;
+ using Values = std::vector<std::string>;
private:
using Key = std::pair<std::string, std::string>;
Tool(b, "CCJG")
{ }
-Target *CompileCommandsGenerator::create_target(const list<Target *> &, const string &)
+Target *CompileCommandsGenerator::create_target(const vector<Target *> &, const string &)
{
throw logic_error("Not implemented");
}
public:
CompileCommandsGenerator(Builder &);
- Target *create_target(const std::list<Target *> &, const std::string &) override;
+ Target *create_target(const std::vector<Target *> &, const std::string &) override;
Task *run(const Target &) const override;
};
return binfo;
}
-list<FS::Path> Component::collect_source_files() const
+vector<FS::Path> Component::collect_source_files() const
{
- list<FS::Path> files;
+ vector<FS::Path> files;
for(const FS::Path &p: sources)
{
if(FS::is_dir(p))
{
- list<FS::Path> dirs;
+ vector<FS::Path> dirs;
+ dirs.reserve(1+overlays.size());
dirs.push_back(p);
for(const string &o: overlays)
{
protected:
SourcePackage &package;
std::string name;
- std::list<Msp::FS::Path> sources;
- std::list<std::string> overlays;
+ std::vector<Msp::FS::Path> sources;
+ std::vector<std::string> overlays;
bool install;
BuildInfo build_info;
Package::Requirements requires;
bool deflt;
InstallMap install_map;
- std::list<std::string> problems;
+ std::vector<std::string> problems;
Component(SourcePackage &, const std::string &);
public:
/** Returns a list of sources for the component. They may refer to
directories or individual files. */
- const std::list<Msp::FS::Path> &get_sources() const { return sources; }
+ const std::vector<Msp::FS::Path> &get_sources() const { return sources; }
- const std::list<std::string> &get_overlays() const { return overlays; }
+ const std::vector<std::string> &get_overlays() const { return overlays; }
protected:
/** Returns a list of all source files for the component. */
- std::list<Msp::FS::Path> collect_source_files() const;
+ std::vector<Msp::FS::Path> collect_source_files() const;
public:
bool get_install() const { return install; }
const InstallMap &get_install_map() const { return install_map; }
const Package::Requirements &get_required_packages() const { return requires; }
bool is_default() const { return deflt; }
- const std::list<std::string> &get_problems() const { return problems; }
+ const std::vector<std::string> &get_problems() const { return problems; }
/** Prepares any required packages. */
void prepare();
Tool(b, "CP")
{ }
-Target *Copy::create_target(const list<Target *> &sources, const string &arg)
+Target *Copy::create_target(const vector<Target *> &sources, const string &arg)
{
FileTarget &file_tgt = dynamic_cast<FileTarget &>(*sources.front());
InstalledFile *inst = new InstalledFile(builder, *file_tgt.get_package(), file_tgt, arg);
public:
Copy(Builder &);
- Target *create_target(const std::list<Target *> &, const std::string &) override;
+ Target *create_target(const std::vector<Target *> &, const std::string &) override;
Task *run(const Target &) const override;
};
const BuildInfo &build_info = component->get_build_info_for_path(path);
const auto &incpath = build_info.incpath;
- VirtualFileSystem::SearchPath local_incpath = incpath;
- local_incpath.insert(local_incpath.begin(), build_info.local_incpath.begin(), build_info.local_incpath.end());
- local_incpath.push_front(FS::dirname(path).str());
+ VirtualFileSystem::SearchPath local_incpath;
+ local_incpath.reserve(1+build_info.local_incpath.size()+incpath.size());
+ local_incpath.push_back(FS::dirname(path).str());
+ local_incpath.insert(local_incpath.end(), build_info.local_incpath.begin(), build_info.local_incpath.end());
+ local_incpath.insert(local_incpath.end(), incpath.begin(), incpath.end());
Tool *compiler = builder.get_toolchain().get_tool_for_suffix(FS::extpart(FS::basename(path)), true);
if(compiler)
class CSourceFile: public SourceFile
{
protected:
- std::list<std::string> includes;
+ std::vector<std::string> includes;
public:
CSourceFile(Builder &, const Msp::FS::Path &);
CSourceFile(Builder &, const Component &, const Msp::FS::Path &);
const char *get_type() const override { return "CSourceFile"; }
- const std::list<std::string> &get_includes() const { return includes; }
+ const std::vector<std::string> &get_includes() const { return includes; }
protected:
virtual void parse_includes(Msp::IO::Base &);
void find_dependencies() override;
using namespace std;
-DataPack::DataPack(Builder &b, const Component &c, const list<FileTarget *> &f):
+DataPack::DataPack(Builder &b, const Component &c, const vector<FileTarget *> &f):
FileTarget(b, c.get_package(), generate_target_path(c)),
files(f)
{
class DataPack: public FileTarget
{
private:
- std::list<FileTarget *> files;
+ std::vector<FileTarget *> files;
public:
- DataPack(Builder &, const Component &, const std::list<FileTarget *> &);
+ DataPack(Builder &, const Component &, const std::vector<FileTarget *> &);
private:
static Msp::FS::Path generate_target_path(const Component &);
public:
const char *get_type() const override { return "DataPack"; }
- const std::list<FileTarget *> &get_files() const { return files; }
+ const std::vector<FileTarget *> &get_files() const { return files; }
};
#endif
Builder &builder = package.get_builder();
Tool &dcomp = builder.get_toolchain().get_tool("DATA");
- list<Target *> files;
+ vector<Target *> files;
for(const FS::Path &s: collect_source_files())
{
string ext = FS::extpart(FS::basename(s));
return new DataTransform(builder, comp, path);
}
-Target *DataTool::create_target(const list<Target *> &sources, const string &arg)
+Target *DataTool::create_target(const vector<Target *> &sources, const string &arg)
{
if(arg=="collection")
{
{
if(sources.empty())
throw invalid_argument("DataTool::create_target");
- list<FileTarget *> files;
+ vector<FileTarget *> files;
+ files.reserve(sources.size());
for(Target *t: sources)
files.push_back(&dynamic_cast<FileTarget &>(*t));
DataPack *pack = new DataPack(builder, *files.front()->get_component(), files);
DataTool(Builder &);
Target *create_source(const Component &, const Msp::FS::Path &) const override;
- Target *create_target(const std::list<Target *> &, const std::string &) override;
+ Target *create_target(const std::vector<Target *> &, const std::string &) override;
std::string create_build_signature(const BuildInfo &) const override;
Task *run(const Target &) const override;
};
void DataTransform::find_dependencies()
{
- list<string> files;
+ vector<string> files;
Cache &cache = component->get_package().get_cache();
const Time::TimeStamp &cache_mtime = cache.get_mtime();
if(mtime<cache_mtime && dir_mtime<cache_mtime && cache.has_key(this, "files"))
Binary(b, p)
{ }
-Executable::Executable(Builder &b, const Component &c, const list<ObjectFile *> &objs):
+Executable::Executable(Builder &b, const Component &c, const vector<ObjectFile *> &objs):
Binary(b, c, b.get_current_arch().create_filename<Executable>(c.get_name()), objs)
{
install_location = "bin";
{
public:
Executable(Builder &, const Msp::FS::Path &);
- Executable(Builder &, const Component &, const std::list<ObjectFile *> &);
+ Executable(Builder &, const Component &, const std::vector<ObjectFile *> &);
const char *get_type() const override { return "Executable"; }
};
using namespace std;
using namespace Msp;
-ExportDefinitions::ExportDefinitions(Builder &b, const Component &c, const list<ObjectFile *> &objs):
+ExportDefinitions::ExportDefinitions(Builder &b, const Component &c, const vector<ObjectFile *> &objs):
FileTarget(b, c.get_package(), generate_target_path(c))
{
component = &c;
class ExportDefinitions: public FileTarget
{
public:
- ExportDefinitions(Builder &, const Component &, const std::list<ObjectFile *> &);
+ ExportDefinitions(Builder &, const Component &, const std::vector<ObjectFile *> &);
private:
static Msp::FS::Path generate_target_path(const Component &);
std::string name;
std::string description;
std::string default_value;
- std::list<std::string> choices;
+ std::vector<std::string> choices;
bool exported;
Feature(const std::string &);
return string();
const BuildInfo &binfo = (component ? component->get_build_info() : package->get_build_info());
- list<string> sigs;
+ vector<string> sigs;
+
+ if(arch_in_build_sig)
+ if(const Architecture *arch = tool->get_architecture())
+ sigs.push_back(arch->get_name());
+
+ sigs.push_back(tool->create_build_signature(binfo));
+
if(nested_build_sig && component)
{
- set<const Tool *> depend_tools;
+ vector<const Tool *> seen_tools;
+ vector<string> tool_sigs;
for(Target *d: depends)
- if(d->get_component()==component && d->get_tool())
- depend_tools.insert(d->get_tool());
-
- for(const Tool *t: depend_tools)
- sigs.push_back(t->create_build_signature(binfo));
- sigs.sort();
- sigs.push_front(tool->create_build_signature(binfo));
+ if(const Tool *t = d->get_tool())
+ if(d->get_component()==component && !any_equals(seen_tools, t))
+ {
+ seen_tools.push_back(t);
+ tool_sigs.push_back(t->create_build_signature(binfo));
+ }
+
+ sort(tool_sigs);
+ sigs.insert(sigs.end(), make_move_iterator(tool_sigs.begin()), make_move_iterator(tool_sigs.end()));
}
- else
- sigs.push_back(tool->create_build_signature(binfo));
-
- if(arch_in_build_sig)
- if(const Architecture *arch = tool->get_architecture())
- sigs.push_front(arch->get_name());
return join(sigs.begin(), sigs.end(), ";");
}
processing_unit = COMPONENT;
}
-Target *GnuArchiver::create_target(const list<Target *> &sources, const string &)
+Target *GnuArchiver::create_target(const vector<Target *> &sources, const string &)
{
if(sources.empty())
throw invalid_argument("GnuArchiver::create_target");
- list<ObjectFile *> objs;
+ vector<ObjectFile *> objs;
+ objs.reserve(sources.size());
for(Target *s: sources)
objs.push_back(&dynamic_cast<ObjectFile &>(*s));
public:
GnuArchiver(Builder &, const Architecture &);
- Target *create_target(const std::list<Target *> &, const std::string &) override;
+ Target *create_target(const std::vector<Target *> &, const std::string &) override;
Task *run(const Target &) const override;
};
return new CSourceFile(builder, path);
}
-Target *GnuCompiler::create_target(const list<Target *> &sources, const string &)
+Target *GnuCompiler::create_target(const vector<Target *> &sources, const string &)
{
if(sources.size()!=1)
throw invalid_argument("GnuCompiler::create_target");
Target *create_source(const Component &, const Msp::FS::Path &) const override;
Target *create_source(const Msp::FS::Path &) const override;
- Target *create_target(const std::list<Target *> &, const std::string &) override;
+ Target *create_target(const std::vector<Target *> &, const std::string &) override;
std::string create_build_signature(const BuildInfo &) const override;
protected:
void do_prepare() override;
delete cxx_linker;
}
-Target *GnuLinker::create_target(const list<Target *> &sources, const string &arg)
+Target *GnuLinker::create_target(const vector<Target *> &sources, const string &arg)
{
if(sources.empty())
throw invalid_argument("GnuLinker::create_target");
- list<ObjectFile *> objs;
+ vector<ObjectFile *> objs;
+ objs.reserve(sources.size());
Linker *linker = default_linker;
for(Target *s: sources)
{
GnuLinker(Builder &, const Architecture &);
~GnuLinker();
- Target *create_target(const std::list<Target *> &, const std::string &) override;
+ Target *create_target(const std::vector<Target *> &, const std::string &) override;
Target *create_install(Target &) const override;
protected:
void do_prepare() override;
#ifndef INSTALLMAP_H_
#define INSTALLMAP_H_
-#include <list>
+#include <vector>
#include <msp/datafile/objectloader.h>
#include <msp/fs/path.h>
Msp::FS::Path install;
};
- std::list<Entry> entries;
+ std::vector<Entry> entries;
public:
/** Adds an install mapping. Multiple mappings can be specified for the
set_command("jarsigner");
}
-Target *JarSigner::create_target(const list<Target *> &, const string &)
+Target *JarSigner::create_target(const vector<Target *> &, const string &)
{
throw logic_error("not implemented");
}
public:
JarSigner(Builder &);
- Target *create_target(const std::list<Target *> &, const std::string &) override;
+ Target *create_target(const std::vector<Target *> &, const std::string &) override;
Task *run(const Target &) const override;
};
set_command("dlltool", true);
}
-Target *MingwDllTool::create_target(const list<Target *> &sources, const string &)
+Target *MingwDllTool::create_target(const vector<Target *> &sources, const string &)
{
if(sources.size()!=1)
throw invalid_argument("MingwDllTool::create_target");
SharedLibrary &shlib = dynamic_cast<SharedLibrary &>(*sources.front());
- list<ObjectFile *> objs;
+ vector<ObjectFile *> objs;
+ objs.reserve(shlib.get_dependencies().size());
for(Target *d: shlib.get_dependencies())
if(ObjectFile *obj = dynamic_cast<ObjectFile *>(d))
objs.push_back(obj);
public:
MingwDllTool(Builder &, const Architecture &);
- Target *create_target(const std::list<Target *> &, const std::string &) override;
+ Target *create_target(const std::vector<Target *> &, const std::string &) override;
Target *create_install(Target &) const override;
Task *run(const Target &) const override;
};
set_command((ms_tools.get_vc_bin_dir()/"lib.exe").str(), false);
}
-Target *MsvcArchiver::create_target(const list<Target *> &sources, const string &)
+Target *MsvcArchiver::create_target(const vector<Target *> &sources, const string &)
{
if(sources.empty())
throw invalid_argument("MsvcArchiver::create_target");
- list<ObjectFile *> objs;
+ vector<ObjectFile *> objs;
+ objs.reserve(sources.size());
for(Target *s: sources)
objs.push_back(&dynamic_cast<ObjectFile &>(*s));
public:
MsvcArchiver(Builder &, const Architecture &, const MicrosoftTools &);
- Target *create_target(const std::list<Target *> &, const std::string &) override;
+ Target *create_target(const std::vector<Target *> &, const std::string &) override;
Task *run(const Target &) const override;
};
return new CSourceFile(builder, path);
}
-Target *MsvcCompiler::create_target(const list<Target *> &sources, const string &)
+Target *MsvcCompiler::create_target(const vector<Target *> &sources, const string &)
{
if(sources.size()!=1)
throw invalid_argument("MsvcCompiler::create_target");
Target *create_source(const Component &, const Msp::FS::Path &) const override;
Target *create_source(const Msp::FS::Path &) const override;
- Target *create_target(const std::list<Target *> &, const std::string &) override;
+ Target *create_target(const std::vector<Target *> &, const std::string &) override;
std::string create_build_signature(const BuildInfo &) const override;
protected:
set_command((ms_tools.get_vc_bin_dir()/"link.exe").str(), false);
}
-Target *MsvcLinker::create_target(const list<Target *> &sources, const string &arg)
+Target *MsvcLinker::create_target(const vector<Target *> &sources, const string &arg)
{
if(sources.empty())
throw invalid_argument("MsvcLinker::create_target");
- list<ObjectFile *> objs;
+ vector<ObjectFile *> objs;
+ objs.reserve(sources.size());
for(Target *s: sources)
objs.push_back(&dynamic_cast<ObjectFile &>(*s));
public:
MsvcLinker(Builder &, const Architecture &, const MicrosoftTools &);
- Target *create_target(const std::list<Target *> &, const std::string &) override;
+ Target *create_target(const std::vector<Target *> &, const std::string &) override;
std::string create_build_signature(const BuildInfo &) const override;
protected:
#ifndef PACKAGE_H_
#define PACKAGE_H_
-#include <list>
#include <string>
+#include <vector>
#include <msp/datafile/objectloader.h>
#include "buildinfo.h"
#include "conditionalloader.h"
void require(const std::string &);
};
- using Requirements = std::list<Package *>;
+ using Requirements = std::vector<Package *>;
protected:
Builder &builder;
Requirements requires;
BuildInfo export_binfo;
bool prepared;
- std::list<std::string> problems;
+ std::vector<std::string> problems;
bool use_pkgconfig;
public:
bool is_prepared() const { return prepared; }
- const std::list<std::string> &get_problems() const { return problems; }
+ const std::vector<std::string> &get_problems() const { return problems; }
virtual void save_caches() { }
};
#ifndef PACKAGEMANAGER_H_
#define PACKAGEMANAGER_H_
-#include <list>
#include <map>
#include <string>
+#include <vector>
#include <msp/fs/path.h>
class Builder;
{
private:
Builder &builder;
- std::list<Msp::FS::Path> pkg_path;
- std::list<Msp::FS::Path> pkg_dirs;
- std::list<Msp::FS::Path> binpkg_path;
- std::list<Msp::FS::Path> binpkg_files;
+ std::vector<Msp::FS::Path> pkg_path;
+ std::vector<Msp::FS::Path> pkg_dirs;
+ std::vector<Msp::FS::Path> binpkg_path;
+ std::vector<Msp::FS::Path> binpkg_files;
bool no_externals;
std::map<std::string, Package *> packages;
Package *main_pkg;
return result;
}
-list<string> Pattern::apply_list(const list<Pattern> &patterns, const string &body)
+vector<string> Pattern::apply_list(const vector<Pattern> &patterns, const string &body)
{
- list<string> result;
+ vector<string> result;
for(const Pattern &p: patterns)
result.push_back(p.apply(body));
return result;
#ifndef PATTERN_H_
#define PATTERN_H_
-#include <list>
#include <string>
+#include <vector>
/**
Stores a filename pattern. A pattern consists of a prefix and a suffix, and
std::string apply(const std::string &) const;
/** Applies a list of patterns to the same body. */
- static std::list<std::string> apply_list(const std::list<Pattern> &, const std::string &);
+ static std::vector<std::string> apply_list(const std::vector<Pattern> &, const std::string &);
};
#endif
{
}
-Target *PkgConfigGenerator::create_target(const list<Target *> &, const string &)
+Target *PkgConfigGenerator::create_target(const vector<Target *> &, const string &)
{
throw logic_error("Not implemented");
}
public:
PkgConfigGenerator(Builder &);
- Target *create_target(const std::list<Target *> &, const std::string &) override;
+ Target *create_target(const std::vector<Target *> &, const std::string &) override;
Task *run(const Target &) const override;
};
libname = libname.substr(3);
}
-SharedLibrary::SharedLibrary(Builder &b, const Component &c, const list<ObjectFile *> &objs):
+SharedLibrary::SharedLibrary(Builder &b, const Component &c, const vector<ObjectFile *> &objs):
Binary(b, c, generate_filename(c), objs),
libname(c.get_name()),
import_lib(0)
public:
SharedLibrary(Builder &, const Msp::FS::Path &);
- SharedLibrary(Builder &, const Component &, const std::list<ObjectFile *> &);
+ SharedLibrary(Builder &, const Component &, const std::vector<ObjectFile *> &);
private:
static std::string generate_filename(const Component &);
{
Builder &builder = package.get_builder();
- list<Target *> files;
- files.insert(files.begin(), &package.get_build_file());
+ vector<Target *> files;
+ files.push_back(&package.get_build_file());
for(const FS::Path &s: collect_source_files())
{
return new TemplateFile(builder, comp, path);
}
-Target *SourceGenerator::create_target(const list<Target *> &sources, const string &)
+Target *SourceGenerator::create_target(const vector<Target *> &sources, const string &)
{
if(sources.empty())
throw invalid_argument("SourceGenerator::create_target");
private:
const SourcePackage &package;
- std::list<std::string> out_suffixes;
- std::list<std::string> arguments;
+ std::vector<std::string> out_suffixes;
+ std::vector<std::string> arguments;
std::string out_argument;
public:
SourceGenerator(Builder &, const SourcePackage &, const std::string &);
Target *create_source(const Component &, const Msp::FS::Path &) const override;
- Target *create_target(const std::list<Target *> &, const std::string &) override;
+ Target *create_target(const std::vector<Target *> &, const std::string &) override;
Task *run(const Target &) const override;
};
other components wil be created first */
auto i = find(obj.components, obj.source_archive);
if(i!=obj.components.end())
- obj.components.splice(obj.components.end(), obj.components, i);
+ {
+ obj.components.erase(i);
+ obj.components.push_back(obj.source_archive);
+ }
}
void SourcePackage::Loader::feature(const string &n, const string &d)
Msp::FS::Path source_dir;
const BuildType *build_type;
Toolchain local_tools;
- std::list<Feature> features;
+ std::vector<Feature> features;
BuildInfo build_info;
- std::list<Component *> components;
+ std::vector<Component *> components;
SourceArchiveComponent *source_archive;
Config config;
mutable Cache cache;
FileTarget(b, p)
{ }
-StaticLibrary::StaticLibrary(Builder &b, const Component &c, const list<ObjectFile *> &objs):
+StaticLibrary::StaticLibrary(Builder &b, const Component &c, const vector<ObjectFile *> &objs):
FileTarget(b, c.get_package(), c.get_package().get_output_directory()/generate_filename(c))
{
component = &c;
public:
StaticLibrary(Builder &, const Msp::FS::Path &);
- StaticLibrary(Builder &, const Component &, const std::list<ObjectFile *> &);
+ StaticLibrary(Builder &, const Component &, const std::vector<ObjectFile *> &);
private:
static std::string generate_filename(const Component &);
processing_unit = COMPONENT;
}
-Target *Tar::create_target(const list<Target *> &sources, const string &arg)
+Target *Tar::create_target(const vector<Target *> &sources, const string &arg)
{
if(sources.empty() || !sources.front()->get_package())
throw invalid_argument("Tar::create_target");
public:
Tar(Builder &);
- Target *create_target(const std::list<Target *> &, const std::string &) override;
+ Target *create_target(const std::vector<Target *> &, const std::string &) override;
Task *run(const Target &) const override;
};
#ifndef TARGET_H_
#define TARGET_H_
-#include <list>
#include <map>
#include <set>
#include <string>
+#include <vector>
#include <sigc++/signal.h>
#include <msp/time/timestamp.h>
class Target
{
public:
- using Dependencies = std::list<Target *>;
+ using Dependencies = std::vector<Target *>;
protected:
enum State
Tool *tool;
State state;
std::string rebuild_reason;
- std::list<std::string> problems;
+ std::vector<std::string> problems;
Dependencies depends;
Dependencies trans_depends;
public:
bool is_broken() const { return state==BROKEN; }
- const std::list<std::string> &get_problems() const { return problems; }
+ const std::vector<std::string> &get_problems() const { return problems; }
/** Prepares the target by finding dependencies, recursively preparing them
and then checking whether rebuilding is needed. */
sigc::signal<void, bool> signal_finished;
protected:
- std::list<Msp::FS::Path> files;
+ std::vector<Msp::FS::Path> files;
bool unlink;
Task();
Target *Tool::create_target(Target &source, const string &arg)
{
- list<Target *> sources;
+ vector<Target *> sources;
sources.push_back(&source);
return create_target(sources, arg);
}
return parent.create_source(p);
}
-Target *SubTool::create_target(const list<Target *> &s, const string &a)
+Target *SubTool::create_target(const vector<Target *> &s, const string &a)
{
return parent.create_target(s, a);
}
#ifndef TOOL_H_
#define TOOL_H_
-#include <list>
#include <string>
+#include <vector>
#include <msp/fs/path.h>
#include "buildinfo.h"
#include "virtualfilesystem.h"
std::string tag;
std::string command;
FileTarget *executable;
- std::list<std::string> input_suffixes;
- std::list<std::string> aux_suffixes;
+ std::vector<std::string> input_suffixes;
+ std::vector<std::string> aux_suffixes;
ProcessingUnit processing_unit;
VirtualFileSystem::SearchPath system_path;
BuildInfo build_info;
bool prepared;
- std::list<std::string> problems;
+ std::vector<std::string> problems;
Tool(Builder &, const std::string &);
Tool(Builder &, const Architecture &, const std::string &);
FileTarget *get_executable() const { return executable; }
/// Returns a list of suffixes that can be processed with this tool.
- const std::list<std::string> &get_input_suffixes() const { return input_suffixes; }
+ const std::vector<std::string> &get_input_suffixes() const { return input_suffixes; }
/** Returns a list of suffixes that are associated with this tool, but can't
be processed directly. For example C and C++ headers. */
- const std::list<std::string> &get_auxiliary_suffixes() const { return aux_suffixes; }
+ const std::vector<std::string> &get_auxiliary_suffixes() const { return aux_suffixes; }
/** Indicates whether the tool can accept a suffix. If aux is true,
auxiliary suffixes are considered as well */
/** Creates a target from sources. The exact types of accepted sources
depends on the tool. The optional second argument can be used to select an
alternative target type for tools that can create multiple kinds of targets. */
- virtual Target *create_target(const std::list<Target *> &, const std::string & = std::string()) = 0;
+ virtual Target *create_target(const std::vector<Target *> &, const std::string & = std::string()) = 0;
/** Creates an install target for a target created by this tool. Can return
null if the tool does not want to handle installing in a special way. */
virtual void do_prepare() { }
public:
- const std::list<std::string> &get_problems() const { return problems; }
+ const std::vector<std::string> &get_problems() const { return problems; }
/** Invokes the tool to build a target. This should not be called directly;
use Target::build() instead. */
public:
Target *create_source(const Component &, const Msp::FS::Path &) const override;
Target *create_source(const Msp::FS::Path &) const override;
- Target *create_target(const std::list<Target *> &, const std::string & = std::string()) override;
+ Target *create_target(const std::vector<Target *> &, const std::string & = std::string()) override;
Target *create_install(Target &) const override;
std::string create_build_signature(const BuildInfo &) const override;
};
#ifndef TOOLCHAIN_H_
#define TOOLCHAIN_H_
-#include <list>
#include <map>
#include <string>
+#include <vector>
class Tool;
{
private:
std::map<std::string, Tool *> tools;
- std::list<Toolchain *> chains;
+ std::vector<Toolchain *> chains;
public:
~Toolchain();
Tool(b, "VCXG")
{ }
-Target *VcxProjectGenerator::create_target(const list<Target *> &, const string &)
+Target *VcxProjectGenerator::create_target(const vector<Target *> &, const string &)
{
throw logic_error("Not implemented");
}
public:
VcxProjectGenerator(Builder &);
- Target *create_target(const std::list<Target *> &, const std::string &) override;
+ Target *create_target(const std::vector<Target *> &, const std::string &) override;
Task *run(const Target &) const override;
};
const Architecture &arch = builder.get_current_arch();
- list<string> shared_names;
+ vector<string> shared_names;
bool use_import_lib = false;
if(mode!=BuildInfo::FORCE_STATIC)
{
shared_names = Pattern::apply_list(arch.get_patterns<SharedLibrary>(), lib);
}
- list<string> static_names;
+ vector<string> static_names;
if(mode!=BuildInfo::FORCE_DYNAMIC)
static_names = Pattern::apply_list(arch.get_patterns<StaticLibrary>(), lib);
for(const FS::Path &p: combined_path)
{
- const list<string> *cur_names = (mode>=BuildInfo::DYNAMIC ? &shared_names : &static_names);
+ const vector<string> *cur_names = (mode>=BuildInfo::DYNAMIC ? &shared_names : &static_names);
for(auto j=cur_names->begin(); j!=cur_names->end(); )
{
FS::Path filename = p / *j;
#ifndef VIRTUALFILESYSTEM_H_
#define VIRTUALFILESYSTEM_H_
-#include <list>
#include <map>
#include <set>
+#include <vector>
#include <msp/fs/path.h>
#include "buildinfo.h"
class VirtualFileSystem
{
public:
- using SearchPath = std::list<Msp::FS::Path>;
+ using SearchPath = std::vector<Msp::FS::Path>;
private:
Builder &builder;
Tool(b, "VSSG")
{ }
-Target *VsSolutionGenerator::create_target(const list<Target *> &, const string &)
+Target *VsSolutionGenerator::create_target(const vector<Target *> &, const string &)
{
throw logic_error("Not implemented");
}
public:
VsSolutionGenerator(Builder &);
- Target *create_target(const std::list<Target *> &, const std::string &) override;
+ Target *create_target(const std::vector<Target *> &, const std::string &) override;
Task *run(const Target &) const override;
};