]> git.tdb.fi Git - builder.git/commitdiff
Eliminate all global typedefs, making misc.h finally unnecessary
authorMikko Rasa <tdb@tdb.fi>
Mon, 23 Jul 2012 20:18:29 +0000 (23:18 +0300)
committerMikko Rasa <tdb@tdb.fi>
Mon, 23 Jul 2012 20:18:29 +0000 (23:18 +0300)
21 files changed:
source/architecture.h
source/builder.cpp
source/builder.h
source/buildinfo.h
source/cache.h
source/component.cpp
source/component.h
source/condition.cpp
source/condition.h
source/config.h
source/csourcefile.cpp
source/csourcefile.h
source/feature.h
source/misc.h [deleted file]
source/package.cpp
source/package.h
source/pkgconfiggenerator.cpp
source/problem.h
source/sourcepackage.cpp
source/sourcepackage.h
source/virtualfilesystem.cpp

index 2d7ca5f18c8f51017b82ecebc96f3b15c730d321..4db809f19f3cbf0ef33e6706b8cc1bedae5f0619 100644 (file)
@@ -57,6 +57,4 @@ private:
        void parse_specification(const std::string &);
 };
 
-typedef std::map<std::string, Architecture> ArchMap;
-
 #endif
index 92f639c9c594e184f617dce0b204677bb7225ea5..f894de08fda7bfb55d0bade32d1f94055a7d26b9 100644 (file)
@@ -56,7 +56,6 @@ Builder::Builder(int argc, char **argv):
        string work_dir;
        bool full_paths = false;
        unsigned max_depth = 4;
-       StringList cmdline_warn;
        string prfx;
        string temp_str;
        string arch;
@@ -145,7 +144,7 @@ Builder::Builder(int argc, char **argv):
        {
                string::size_type equal = i->find('=');
                if(equal!=string::npos)
-                       cmdline_options.insert(StringMap::value_type(i->substr(0, equal), i->substr(equal+1)));
+                       cmdline_options.insert(Config::InputOptions::value_type(i->substr(0, equal), i->substr(equal+1)));
                else
                        cmdline_targets.push_back(*i);
        }
@@ -384,7 +383,7 @@ bool Builder::prepare_build()
 
        // Make the cmdline target depend on all targets mentioned on the command line
        Target *cmdline = new VirtualTarget(*this, "cmdline");
-       for(list<string>::iterator i=cmdline_targets.begin(); i!=cmdline_targets.end(); ++i)
+       for(NameList::iterator i=cmdline_targets.begin(); i!=cmdline_targets.end(); ++i)
        {
                Target *tgt = get_target(*i);
                if(!tgt)
@@ -403,7 +402,7 @@ bool Builder::prepare_build()
        cmdline->prepare();
 
        // Apply what-ifs
-       for(StringList::iterator i=what_if.begin(); i!=what_if.end(); ++i)
+       for(NameList::iterator i=what_if.begin(); i!=what_if.end(); ++i)
        {
                FileTarget *tgt = vfs.get_target(cwd/ *i);
                if(!tgt)
@@ -571,8 +570,8 @@ void Builder::package_help()
        const Config::OptionMap &options = config.get_options();
 
        IO::print("Required packages:\n  ");
-       const PackageList &requires = main_pkg->get_required_packages();
-       for(PackageList::const_iterator i=requires.begin(); i!=requires.end(); ++i)
+       const Package::Requirements &requires = main_pkg->get_required_packages();
+       for(Package::Requirements::const_iterator i=requires.begin(); i!=requires.end(); ++i)
        {
                if(i!=requires.begin())
                        IO::print(", ");
index b10d4600168b99aa3abdde1fe20b9bfb73e3e964..2f70fbd32a14257583e40cd07437f3f22b1af254 100644 (file)
@@ -11,7 +11,6 @@
 #include "buildtype.h"
 #include "config.h"
 #include "logger.h"
-#include "misc.h"
 #include "packagemanager.h"
 #include "problem.h"
 #include "target.h"
@@ -46,9 +45,11 @@ public:
        typedef std::map<std::string, Target *> TargetMap;
 
 private:
+       typedef std::list<std::string> NameList;
        typedef std::map<std::string, BuildType> BuildTypeMap;
+       typedef std::list<Problem> ProblemList;
 
-       StringList cmdline_targets;
+       NameList cmdline_targets;
        Config::InputOptions cmdline_options;
        Msp::FS::Path cwd;
 
@@ -74,7 +75,7 @@ private:
        bool show_progress;
        std::string build_file;
        unsigned jobs;
-       StringList what_if;
+       NameList what_if;
        bool conf_all;
        bool conf_only;
        bool build_all;
index e0929e7b1da9c8c9eec8bef0fd60e298697d8f55..595fe1a55ccd5bb414ebbe5febec8f86431465b2 100644 (file)
@@ -4,7 +4,7 @@
 #include <list>
 #include <string>
 #include <msp/datafile/objectloader.h>
-#include "misc.h"
+#include <msp/fs/path.h>
 
 /**
 Stores information about compiler command line parameters in a more abstract
index 86a5f4721b62031bec864c206925881d0c14da02..98739575e25d45a998fdbce2f17e77c7a50faefd 100644 (file)
@@ -2,7 +2,6 @@
 #define CACHE_H_
 
 #include <msp/time/timestamp.h>
-#include "misc.h"
 
 class SourcePackage;
 class Target;
index a63e3b05d371571af52888dce3b8a8a2f749138b..4a889cb1750903209638a2cb2b8d8b3945847793 100644 (file)
@@ -32,7 +32,7 @@ Component::Component(SourcePackage &p, Type t, const string &n):
 
 void Component::prepare()
 {
-       for(PackageList::const_iterator i=requires.begin(); i!=requires.end(); ++i)
+       for(Package::Requirements::const_iterator i=requires.begin(); i!=requires.end(); ++i)
                (*i)->prepare();
 }
 
@@ -40,20 +40,20 @@ void Component::create_build_info()
 {
        BuildInfo final_build_info;
 
-       const PackageList &pkg_reqs = package.get_required_packages();
-       PackageList direct_reqs = requires;
+       const Package::Requirements &pkg_reqs = package.get_required_packages();
+       Package::Requirements direct_reqs = requires;
        direct_reqs.insert(direct_reqs.end(), pkg_reqs.begin(), pkg_reqs.end());
 
-       PackageList all_reqs = direct_reqs;
-       for(PackageList::iterator i=all_reqs.begin(); i!=all_reqs.end(); ++i)
+       Package::Requirements all_reqs = direct_reqs;
+       for(Package::Requirements::iterator i=all_reqs.begin(); i!=all_reqs.end(); ++i)
        {
                BuildInfo::UpdateLevel level = BuildInfo::CHAINED;
                if(find(direct_reqs.begin(), direct_reqs.end(), *i)!=direct_reqs.end())
                        level = BuildInfo::DEPENDENCY;
                final_build_info.update_from((*i)->get_exported_build_info(), level);
 
-               const PackageList &reqs = (*i)->get_required_packages();
-               for(PackageList::const_iterator j=reqs.begin(); j!=reqs.end(); ++j)
+               const Package::Requirements &reqs = (*i)->get_required_packages();
+               for(Package::Requirements::const_iterator j=reqs.begin(); j!=reqs.end(); ++j)
                        if(find(all_reqs.begin(), all_reqs.end(), *j)==all_reqs.end())
                                all_reqs.push_back(*j);
        }
@@ -74,7 +74,7 @@ void Component::create_build_info()
 
        if(build_info.libmode<BuildInfo::DYNAMIC)
        {
-               for(PackageList::iterator i=all_reqs.begin(); i!=all_reqs.end(); ++i)
+               for(Package::Requirements::iterator i=all_reqs.begin(); i!=all_reqs.end(); ++i)
                {
                        const BuildInfo &ebi = (*i)->get_exported_build_info();
                        build_info.libpath.insert(build_info.libpath.end(), ebi.libpath.begin(), ebi.libpath.end());
@@ -87,7 +87,7 @@ void Component::create_targets() const
        Builder &builder = package.get_builder();
        const Toolchain &toolchain = builder.get_toolchain();
 
-       PathList source_filenames = collect_source_files();
+       SourceList source_filenames = collect_source_files();
        list<Target *> inst_list;
 
        string inst_loc;
@@ -96,7 +96,7 @@ void Component::create_targets() const
                const Tool &tar = toolchain.get_tool("TAR");
 
                list<Target *> files;
-               for(PathList::const_iterator i=source_filenames.begin(); i!=source_filenames.end(); ++i)
+               for(SourceList::const_iterator i=source_filenames.begin(); i!=source_filenames.end(); ++i)
                {
                        FileTarget *file = builder.get_vfs().get_target(*i);
                        if(!file)
@@ -126,7 +126,7 @@ void Component::create_targets() const
        else if(type==INSTALL)
        {
                inst_loc = name;
-               for(PathList::const_iterator i=source_filenames.begin(); i!=source_filenames.end(); ++i)
+               for(SourceList::const_iterator i=source_filenames.begin(); i!=source_filenames.end(); ++i)
                {
                        FileTarget *ft;
                        if(Target *tgt = builder.get_vfs().get_target(*i))
@@ -155,7 +155,7 @@ void Component::create_targets() const
        if(type==PROGRAM || type==LIBRARY || type==MODULE)
        {
                list<Target *> objs;
-               for(PathList::const_iterator i=source_filenames.begin(); i!=source_filenames.end(); ++i)
+               for(SourceList::const_iterator i=source_filenames.begin(); i!=source_filenames.end(); ++i)
                {
                        string ext = FS::extpart(FS::basename(*i));
                        const Tool *tool = toolchain.get_tool_for_suffix(ext, true);
@@ -207,10 +207,10 @@ void Component::create_targets() const
        }
 }
 
-PathList Component::collect_source_files() const
+Component::SourceList Component::collect_source_files() const
 {
-       PathList files;
-       for(StringList::const_iterator i=sources.begin(); i!=sources.end(); ++i)
+       SourceList files;
+       for(SourceList::const_iterator i=sources.begin(); i!=sources.end(); ++i)
        {
                FS::Path path(*i);
                if(FS::is_dir(path))
index 32cbe0a79ee7edeb04b777ab43201aae9d35faa1..e68bc38f612acc2d0476792f271b831477671ed8 100644 (file)
@@ -6,7 +6,6 @@
 #include <msp/fs/path.h>
 #include "buildinfo.h"
 #include "installmap.h"
-#include "misc.h"
 #include "package.h"
 
 class SourcePackage;
@@ -41,14 +40,16 @@ public:
                TARBALL
        };
 
+       typedef std::list<Msp::FS::Path> SourceList;
+
 protected:
        SourcePackage &package;
        Type type;
        std::string name;
-       StringList sources;
+       SourceList sources;
        bool install;
        BuildInfo build_info;
-       PackageList requires;
+       Package::Requirements requires;
        bool deflt;
        InstallMap install_map;
 
@@ -61,16 +62,16 @@ public:
 
        /** Returns a list of sources for the component.  They may refer to
        directories or individual files. */
-       const StringList &get_sources() const { return sources; }
+       const SourceList &get_sources() const { return sources; }
 
 protected:
        /** Returns a list of all source files for the component. */
-       PathList collect_source_files() const;
+       SourceList collect_source_files() const;
 
 public:
        bool get_install() const { return install; }
        const InstallMap &get_install_map() const { return install_map; }
-       const PackageList &get_required_packages() const { return requires; }
+       const Package::Requirements &get_required_packages() const { return requires; }
        bool is_default() const { return deflt; }
 
        /** Prepares any required packages. */
index 13861ba5aea01a8ad0466c44b3991094ad50f94d..413870e6cb20ab069374aa8781a5e7738f6cad2e 100644 (file)
@@ -18,11 +18,11 @@ Condition::Condition(SourcePackage &p, const string &expr):
 
                string::size_type token = i->find_first_of("=!");
                if(token==string::npos)
-                       expression.insert(StringMap::value_type(*i, "="));
+                       expression.insert(Expression::value_type(*i, "="));
                else if(token==0 && (*i)[0]=='!')
-                       expression.insert(StringMap::value_type(i->substr(1), "!"));
+                       expression.insert(Expression::value_type(i->substr(1), "!"));
                else
-                       expression.insert(StringMap::value_type(i->substr(0, token), i->substr(token)));
+                       expression.insert(Expression::value_type(i->substr(0, token), i->substr(token)));
        }
 }
 
@@ -31,7 +31,7 @@ bool Condition::eval()
        const Config &conf = pkg.get_config();
 
        bool result = true;
-       for(StringMap::iterator i=expression.begin(); i!=expression.end(); ++i)
+       for(Expression::iterator i=expression.begin(); i!=expression.end(); ++i)
        {
                bool neg = (i->second[0]=='!');
                unsigned start = 1;
index c1bf7a3f3da6423e1f8d64e148a6d63e43328afb..0cdc2bb482723e756dd94abcc32e94f9367045a3 100644 (file)
@@ -3,7 +3,6 @@
 
 #include <msp/datafile/loader.h>
 #include "buildinfo.h"
-#include "misc.h"
 
 class Config;
 class SourcePackage;
@@ -20,18 +19,21 @@ public:
                void build_info();
        };
 
+       typedef std::list<std::string> RequireList;
+
 private:
+       typedef std::map<std::string, std::string> Expression;
+       
        SourcePackage &pkg;
-       StringMap expression;
-       StringList requires;
+       Expression expression;
+       RequireList requires;
        BuildInfo build_info;
 
 public:
        Condition(SourcePackage &, const std::string &);
-       const StringList &get_requires() const { return requires; }
+       const RequireList &get_requires() const { return requires; }
        const BuildInfo &get_build_info() const { return build_info; }
        bool eval();
 };
-typedef std::list<Condition> ConditionList;
 
 #endif
index 92f558577d0c167454f3e05df0b112a0d1d57270..94997750b26497c4ab83003f41382b78b13104fb 100644 (file)
@@ -6,7 +6,6 @@
 #include <msp/datafile/loader.h>
 #include <msp/fs/path.h>
 #include <msp/time/timestamp.h>
-#include "misc.h"
 
 class SourcePackage;
 
index 553128743d8651e50cd0195f4c868727e312c2c3..ee301d7254d35b9699687e80f9d20d8663e83adb 100644 (file)
@@ -52,7 +52,7 @@ void CSourceFile::find_dependencies()
        BuildInfo::PathList local_incpath = incpath;
        local_incpath.push_front(FS::dirname(path).str());
 
-       for(list<string>::iterator i=includes.begin(); i!=includes.end(); ++i)
+       for(IncludeList::iterator i=includes.begin(); i!=includes.end(); ++i)
        {
                Target *hdr = builder.get_vfs().find_header(i->substr(1), ((*i)[0]=='"' ? local_incpath : incpath));
                if(hdr)
index b83c0db28a4209afb3231a5b424d8b21bbb9e05b..8c61a515db5544ef4e274d7037a41e456725fd07 100644 (file)
@@ -1,7 +1,6 @@
 #ifndef CSOURCEFILE_H_
 #define CSOURCEFILE_H_
 
-#include "misc.h"
 #include "sourcefile.h"
 
 /**
@@ -9,15 +8,18 @@ Represents a C or C++ source file.
 */
 class CSourceFile: public SourceFile
 {
+public:
+       typedef std::list<std::string> IncludeList;
+
 private:
-       StringList includes;
+       IncludeList includes;
 
 public:
        CSourceFile(Builder &, const Msp::FS::Path &);
        CSourceFile(Builder &, const Component &, const Msp::FS::Path &);
 
        virtual const char *get_type() const { return "CSourceFile"; }
-       const StringList &get_includes() const { return includes; }
+       const IncludeList &get_includes() const { return includes; }
 private:
        virtual void find_dependencies();
 };
index 657c86005c006e509bca0334b0f24e6ec9809160..8d496b33849e452cb71d7e0274d79eec1d166a73 100644 (file)
@@ -18,6 +18,4 @@ struct Feature
        Feature(const std::string &n): name(n) { }
 };
 
-typedef std::list<Feature> FeatureList;
-
 #endif
diff --git a/source/misc.h b/source/misc.h
deleted file mode 100644 (file)
index 45c6636..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef MISC_H_
-#define MISC_H_
-
-#include <list>
-#include <map>
-#include <string>
-#include <msp/fs/path.h>
-
-typedef std::list<std::string> StringList;
-typedef std::list<Msp::FS::Path> PathList;
-typedef std::map<std::string, std::string> StringMap;
-
-#endif
index 44444add8b04acb641d97fcccff567b4c74dae87..6cbc9328a43ba7a4556d28e7a55e43762256c969 100644 (file)
@@ -2,7 +2,6 @@
 #include <msp/strings/lexicalcast.h>
 #include <msp/strings/utils.h>
 #include "builder.h"
-#include "misc.h"
 #include "package.h"
 
 using namespace std;
@@ -22,7 +21,7 @@ void Package::prepare()
        if(prepared)
                return;
 
-       for(PackageList::const_iterator i=requires.begin(); i!=requires.end(); ++i)
+       for(Requirements::const_iterator i=requires.begin(); i!=requires.end(); ++i)
                (*i)->prepare();
 
        do_prepare();
index 8811390601c39ef2aa05b1ed201c7588ec667c34..3a7ba3ab3c19cd71410874eeb2fd0877098ac478 100644 (file)
@@ -10,8 +10,6 @@
 class Builder;
 class Package;
 
-typedef std::list<Package *> PackageList;
-
 /**
 A package is a distributable piece of software.  Package information may be
 obtained in several ways: Build files of source packages, pkg-config for binary
@@ -29,12 +27,14 @@ public:
                void require(const std::string &);
        };
 
+       typedef std::list<Package *> Requirements;
+
 protected:
        Builder &builder;
 
        std::string name;
 
-       PackageList requires;
+       Requirements requires;
        BuildInfo export_binfo;
        bool prepared;
 
@@ -46,7 +46,7 @@ public:
 
        const std::string &get_name() const { return name; }
        Builder &get_builder() const { return builder; }
-       const PackageList &get_required_packages() const { return requires; }
+       const Requirements &get_required_packages() const { return requires; }
 
        const BuildInfo &get_exported_build_info() const { return export_binfo; }
 
index bd807d4581ba3e173367f8b040c63d30b4cc608b..b4ba545249110d1340bf0bb99460bb07cea51458 100644 (file)
@@ -44,8 +44,8 @@ void PkgConfigGenerator::Worker::main()
        IO::print(out, "Version: %s\n", spkg.get_version());
 
        IO::print(out, "Requires:");
-       const PackageList &reqs = spkg.get_required_packages();
-       for(PackageList::const_iterator i=reqs.begin(); i!=reqs.end(); ++i)
+       const Package::Requirements &reqs = spkg.get_required_packages();
+       for(Package::Requirements::const_iterator i=reqs.begin(); i!=reqs.end(); ++i)
                if((*i)->get_use_pkgconfig())
                        IO::print(out, " %s", (*i)->get_name());
        out.put('\n');
index 83de7dfaf34831b8d2d9db5e97d5916fa47745b8..d3d10d49d0f6736d8bbfc2698f3294420b5683f2 100644 (file)
@@ -4,8 +4,6 @@
 #include <list>
 #include <string>
 
-class Package;
-
 struct Problem
 {
        std::string package;
@@ -14,6 +12,4 @@ struct Problem
        Problem(const std::string &p, const std::string &d): package(p), descr(d) { }
 };
 
-typedef std::list<Problem> ProblemList;
-
 #endif
index 77440d6057112bf013a41c1b221ff7b924a6372c..1c5ca246fcf8cbcdb0ff521da013723e4a0217ad 100644 (file)
@@ -6,7 +6,6 @@
 #include "binarypackage.h"
 #include "builder.h"
 #include "file.h"
-#include "misc.h"
 #include "pkgconfigfile.h"
 #include "tool.h"
 #include "sourcepackage.h"
@@ -168,10 +167,11 @@ void SourcePackage::Loader::finish()
        {
                for(ComponentList::iterator j=obj.components.begin(); j!=obj.components.end(); ++j)
                {
-                       const StringList &sources = j->get_sources();
-                       for(StringList::const_iterator k=sources.begin(); k!=sources.end(); ++k)
+                       const Component::SourceList &sources = j->get_sources();
+                       for(Component::SourceList::const_iterator k=sources.begin(); k!=sources.end(); ++k)
                        {
-                               if(!i->first.compare(0, k->size(), *k))
+                               string k_str = k->str();
+                               if(!i->first.compare(0, k_str.size(), k_str))
                                {
                                        const_cast<InstallMap &>(j->get_install_map()).add_mapping(obj.source_dir/i->first, i->second);
                                }
@@ -223,9 +223,9 @@ void SourcePackage::Loader::headers(const string &n)
        IO::print("%s: Note: headers components are deprecated\n", get_source());
        Component comp(obj, Component::LIBRARY, n);
        load_sub(comp);
-       const StringList &sources = comp.get_sources();
-       for(StringList::const_iterator i=sources.begin(); i!=sources.end(); ++i)
-               install_map[*i] = "include/"+comp.get_name();
+       const Component::SourceList &sources = comp.get_sources();
+       for(Component::SourceList::const_iterator i=sources.begin(); i!=sources.end(); ++i)
+               install_map[i->str()] = "include/"+comp.get_name();
 }
 
 void SourcePackage::Loader::if_feature(const string &cond)
@@ -278,5 +278,5 @@ void SourcePackage::Loader::tar_file(const string &f)
        IO::print("%s: Note: tar_file is deprecated\n", get_source());
        for(ComponentList::iterator i=obj.components.begin(); i!=obj.components.end(); ++i)
                if(i->get_type()==Component::TARBALL && i->get_name()=="@src")
-                       const_cast<StringList &>(i->get_sources()).push_back((obj.source_dir/f).str());
+                       const_cast<Component::SourceList &>(i->get_sources()).push_back((obj.source_dir/f).str());
 }
index f2740199387110add553ffe021c51ef8014f8ecb..0aab392308d089c2621ee0515819ea2c540a870f 100644 (file)
@@ -55,6 +55,8 @@ public:
        typedef std::list<Component> ComponentList;
 
 private:
+       typedef std::list<Feature> FeatureList;
+
        std::string version;
        std::string description;
 
index ec23ef5a2e1fbf3d1c944a14dbda85e2258319d3..19bc8db6fe2e4cf0ef24255ccd02bef5b5d7fbca 100644 (file)
@@ -6,7 +6,6 @@
 #include "builder.h"
 #include "csourcefile.h"
 #include "executable.h"
-#include "misc.h"
 #include "sharedlibrary.h"
 #include "staticlibrary.h"
 #include "tool.h"